Skip to main content

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 TheWorld and its components (Map, SoundEmitter, riftspawner, rabbitkingmanager).
  • Uses SourceModifierList to support pausing/quarantining earthquake activity.
  • Registers the network variables quakesoundintensity and miniquakesoundintensity.
  • Listens to common world-scoped events: ms_playerjoined, ms_playerleft, ms_miniquake, ms_forcequake, explosion, pausequakes, unpausequakes.
  • Adds no tags to entities.

Properties

PropertyTypeDefault ValueDescription
instComponentself.inst passed to constructorThe owning entity (typically TheWorld) for the quaker component.
_debrispersecondnumber1Controls debris spawn rate (items per second) during an active quake.
_mammalsremainingnumber0Tracks remaining valid mammal spawns (rabbit, mole, carrat); prevents overpopulation during quakes.
_taskTasknilFuture task scheduled to transition between quake states (WAITING → WARNING → QUAKING).
_frequencymultipliernumberTUNING.QUAKE_FREQUENCY_MULTIPLIERGlobal multiplier applied to next quake delay (e.g., for mod overrides).
_quakedatatablenilConfiguration data for quake timing, duration, debris, and mammals. Populated in initialization.
_debristableDefault loot table (rocks, flint, gems, etc.)Global fallback debris table when no matching tile tag is found.
_tagdebristable{ lunacyarea = ..., nocavein = {} }Tile-tag-specific debris tables, indexed by tile tag name.
_activeplayerstable{}List of players currently subscribed to quake debris events.
_scheduleddropstable{}Maps player entities to their pending drop-task references.
_pausesourcesSourceModifierListInitialized with boolean mode and false defaultTracks paused states of earthquakes (e.g., from world mods or achievements).
_quakesoundintensitynet_tinybyte0Network variable indicating quake sound intensity: 0 (off), 1 (warning), 2 (quaking).
_miniquakesoundintensitynet_boolfalseNetwork 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 containing warningtime, quaketime, debrispersecond, nextquake, and optionally mammals fields, 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 with weight (number) and loot (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 lunacyarea or nocavein).
  • Parameters: tile — Tile tag string; data — Debris table or an empty table to prevent debris on that tile.

IsQuaking()

  • Description: Returns true if a full quake or mini-quake is currently active (sound intensity > 1 or mini-quake active).
  • Returns: boolean

Events & Listeners

  • Listens to:

    • quakesoundintensitydirty: Triggers OnQuakeSoundIntensityDirty on non-dedicated clients to manage global earthquake sound playback and intensity.
    • miniquakesoundintensitydirty: Triggers OnMiniQuakeSoundIntensityDirty on non-dedicated clients to manage mini-quake sound playback.
    • ms_playerjoined (on master): Triggers OnPlayerJoined to add player to active players list and schedule drops if quaking.
    • ms_playerleft (on master): Triggers OnPlayerLeft to cancel pending drops and remove player from active list.
    • ms_miniquake (on master): Triggers OnMiniQuake to handle mini-quake events (spawn debris, shake cameras, play sound).
    • ms_forcequake (on master): Triggers OnForceQuake to immediately start a quake (full or override), returning false if already quaking.
    • explosion (on master): Triggers OnExplosion to 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.