Forestdaywalkerspawner
Based on game build 714014 | Last updated: 2026-03-03
Overview
ForestDayWalkerSpawner orchestrates the spawning logic for the Day Walker boss in the Forest world. It tracks respawn delays (days_to_spawn), manages the relationship with the bigjunk entity (junk pile), and synchronizes with shard_daywalkerspawner to determine when and where Day Walker should appear. It also persists state across saves and tracks boss defeat to increment the boss's power_level. This component only exists on the master simulation and is intended to be attached to a world-level entity.
Usage example
-- Typically added automatically to the world entity in the Forest
-- Manual usage in modding would look like:
local world = TheWorld
world:AddComponent("forestdaywalkerspawner")
-- To force an immediate spawn attempt (if conditions met):
world.components.forestdaywalkerspawner:OnDayChange()
Dependencies & tags
Components used: wagpunk_manager, shard_daywalkerspawner
Tags: Checks daywalker tag via entity; does not add/remove tags itself.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
days_to_spawn | number | TUNING.DAYWALKER_RESPAWN_DAYS_COUNT | Days remaining until the next Day Walker spawn attempt (decremented per OnDayChange). |
power_level | number | 1 | Current difficulty tier of the Day Walker; increments to max 2 on defeat. |
bigjunk | entity or nil | nil | Reference to the bigjunk entity (the junk pile) used for spawning Day Walker. |
daywalker | entity or nil | nil | Reference to the currently active Day Walker entity. |
Main functions
IncrementPowerLevel()
- Description: Increases the
power_levelby1, capped at2. Typically called after Day Walker is defeated. - Parameters: None.
- Returns: Nothing.
GetPowerLevel()
- Description: Returns the current
power_level. - Parameters: None.
- Returns: number — the current power level (
1or2).
TryToSetDayWalkerJunkPile()
- Description: Attempts to retrieve and cache the
bigjunkentity viawagpunk_manager:GetBigJunk(). Required before spawning Day Walker from the junk pile. - Parameters: None.
- Returns:
trueifbigjunkwas successfully set (or already set);falseotherwise.
ShouldShakeJunk()
- Description: Determines whether the junk pile is currently active and should be shaken (i.e., Day Walker is buried there).
- Parameters: None.
- Returns:
trueifbigjunk ~= nil;falseotherwise.
CanSpawnFromJunk()
- Description: Evaluates whether the forest can spawn Day Walker from the junk pile right now.
- Parameters: None.
- Returns:
trueifbigjunkis active and ready to spawn, or if shard conditions match anddays_to_spawn <= 0; otherwisefalse. - Error states: Returns
falseifdaywalkeralready exists, or if the shard spawner is not pointing to"forestjunkpile".
OnDayChange()
- Description: Called daily to decrement
days_to_spawn. When countdown reaches0, triggers spawning logic viabigjunk:StartDaywalkerBuried()(if setup succeeds), and resets the countdown. - Parameters: None.
- Returns: Nothing.
- Error states: Returns early if
daywalkerorbigjunkalready exists, or if shard spawner location is not"forestjunkpile".
WatchDaywalker(daywalker)
- Description: Registers a listener on the
daywalkerentity to handle post-defeat cleanup andpower_levelincrement. Clears thebigjunkreference and setsdaywalker. - Parameters:
daywalker(entity) — the Day Walker instance being watched. - Returns: Nothing.
HasDaywalker()
- Description: Checks whether a Day Walker is currently active.
- Parameters: None.
- Returns:
trueifdaywalker ~= nil;falseotherwise.
OnPostInit()
- Description: Called after component initialization. If
TUNING.SPAWN_DAYWALKERis enabled, sets up the"cycles"event listener and triggers an immediateOnDayChange()ifdays_to_spawn <= 0. - Parameters: None.
- Returns: Nothing.
OnSave()
- Description: Serializes component state (including
days_to_spawn,power_level, and references todaywalker/bigjunkbyGUID) for saving. - Parameters: None.
- Returns:
{ data, refs }where:data(table) — containsdays_to_spawn,power_level, and optionallydaywalker_GUID,bigjunk_GUID.refs(table ornil) — list ofGUIDs of referenced entities.
OnLoad(data)
- Description: Restores component state from saved data during world load.
- Parameters:
data(table ornil) — saved data table. - Returns: Nothing.
- Error states: Returns early if
dataisnil.
LoadPostPass(ents, data)
- Description: Resolves saved entity
GUIDs to live entities using theentstable post-load. Setsself.daywalkerandself.bigjunk. - Parameters:
ents(table) — map ofGUID -> entity.data(table) — loaded data (may includedaywalker_GUID,bigjunk_GUID).
- Returns: Nothing.
Events & listeners
-
Listens to:
"cycles"(onTheWorld) — triggersOnDayChange()."onremove"(onself.daywalker) — triggers power level increment and saves defeat.
-
Pushes:
- None identified.