Quaker
Overview
The Quaker component orchestrates large-scale environmental earthquakes across the world. It handles scheduling quake phases (waiting, warning, quaking), spawning debris based on terrain and configuration, managing player-specific drop timing, emitting earthquake sounds, and responding to game events like explosions, player joins/leaves, and mini-quakes. It runs exclusively on the master simulation and synchronizes playback state to clients via network variables.
Dependencies & Tags
- Relies on
TheWorldand its components (Map,SoundEmitter,riftspawner,rabbitkingmanager). - Uses
SourceModifierListto support pausing/quarantining earthquake activity. - Registers the network variables
quakesoundintensityandminiquakesoundintensity. - Listens to common world-scoped events:
ms_playerjoined,ms_playerleft,ms_miniquake,ms_forcequake,explosion,pausequakes,unpausequakes. - Adds no tags to entities.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
inst | Component | self.inst passed to constructor | The owning entity (typically TheWorld) for the quaker component. |
_debrispersecond | number | 1 | Controls debris spawn rate (items per second) during an active quake. |
_mammalsremaining | number | 0 | Tracks remaining valid mammal spawns (rabbit, mole, carrat); prevents overpopulation during quakes. |
_task | Task | nil | Future task scheduled to transition between quake states (WAITING → WARNING → QUAKING). |
_frequencymultiplier | number | TUNING.QUAKE_FREQUENCY_MULTIPLIER | Global multiplier applied to next quake delay (e.g., for mod overrides). |
_quakedata | table | nil | Configuration data for quake timing, duration, debris, and mammals. Populated in initialization. |
_debris | table | Default loot table (rocks, flint, gems, etc.) | Global fallback debris table when no matching tile tag is found. |
_tagdebris | table | { lunacyarea = ..., nocavein = {} } | Tile-tag-specific debris tables, indexed by tile tag name. |
_activeplayers | table | {} | List of players currently subscribed to quake debris events. |
_scheduleddrops | table | {} | Maps player entities to their pending drop-task references. |
_pausesources | SourceModifierList | Initialized with boolean mode and false default | Tracks paused states of earthquakes (e.g., from world mods or achievements). |
_quakesoundintensity | net_tinybyte | 0 | Network variable indicating quake sound intensity: 0 (off), 1 (warning), 2 (quaking). |
_miniquakesoundintensity | net_bool | false | Network variable indicating whether a mini-quake is playing. |
Main Functions
SetQuakeData(data)
- Description: Sets the global quake configuration (timing, debris, mammals) and schedules the next quake if enabled (non-zero frequency multiplier).
- Parameters:
data— A table containingwarningtime,quaketime,debrispersecond,nextquake, and optionallymammalsfields, each supporting functions for dynamic values.
SetDebris(data)
- Description: Replaces the global fallback debris loot table.
- Parameters:
data— An array of debris table entries, each withweight(number) andloot(array of prefab names).
SetTagDebris(tile, data)
- Description: Assigns or clears a tile-specific debris table (for overwriting fallback debris on specific tile types like
lunacyareaornocavein). - Parameters:
tile— Tile tag string;data— Debris table or an empty table to prevent debris on that tile.
IsQuaking()
- Description: Returns
trueif a full quake or mini-quake is currently active (sound intensity > 1 or mini-quake active). - Returns:
boolean
Events & Listeners
-
Listens to:
quakesoundintensitydirty: TriggersOnQuakeSoundIntensityDirtyon non-dedicated clients to manage global earthquake sound playback and intensity.miniquakesoundintensitydirty: TriggersOnMiniQuakeSoundIntensityDirtyon non-dedicated clients to manage mini-quake sound playback.ms_playerjoined(on master): TriggersOnPlayerJoinedto add player to active players list and schedule drops if quaking.ms_playerleft(on master): TriggersOnPlayerLeftto cancel pending drops and remove player from active list.ms_miniquake(on master): TriggersOnMiniQuaketo handle mini-quake events (spawn debris, shake cameras, play sound).ms_forcequake(on master): TriggersOnForceQuaketo immediately start a quake (full or override), returningfalseif already quaking.explosion(on master): TriggersOnExplosionto accelerate or skip warning phase depending on quake state.pausequakes(on master): Adds a pause modifier via_pausesources.unpausequakes(on master): Removes a pause modifier via_pausesources.
-
Emits:
startquake: Sent when a full quake begins, with payload{ duration = ..., debrisperiod = ... }.warnquake: Sent during the warning phase before the main quake starts.endquake: Sent when a full quake ends (after quake time expires).
Events & Listeners
Listens to world-scoped events (as detailed in the table above). Does not emit any custom events beyond those listed.