Skip to main content

Moonstormlightningmanager

Based on game build 714014 | Last updated: 2026-03-03

Overview

MoonstormLightningManager is a component that generates visual lightning effects on the ground during moonstorms. It operates by periodically evaluating player position and lighting strike points within a camera-relative radius where valid ground and moonstorm nodes exist. It relies on the moonstorms component's _moonstorm_nodes data and dynamically adjusts spawn frequency based on camera distance.

This component is attached to an entity (typically the world or a controller entity) and updates per-frame while active, spawning fx prefabs (moonstorm_ground_lightning_fx) at appropriate locations.

Usage example

local inst = CreateEntity()
inst:AddComponent("moonstormlightningmanager")
-- The component starts automatically when moonstorms are active (via event listener).
-- No manual activation is required; it responds to "moonstorm_nodes_dirty_relay".

Dependencies & tags

Components used: moonstorms (via TheWorld.net.components.moonstorms) Tags: None identified.

Properties

PropertyTypeDefault ValueDescription
spark.per_secnumber5Base rate of lightning attempts per second.
spark.spawn_ratenumber0Accumulated spawn counter; triggers spawn when >= 1.0.
spark.checkfnfunctioncheckgroundFunction used to validate if lightning can spawn at a point.
spark.spawnfnfunctionSpawnLightningFunction called to spawn the lightning fx.
sparks_per_secnumber1Multiplier base (unused in current implementation).
sparks_idle_timenumber5Unused in current implementation.
sparks_per_sec_modnumber1.0Modifiable multiplier for effective spawn rate; can be zeroed to stop spawning.

Main functions

OnUpdate(dt)

  • Description: Called each frame while the component is updating. Handles time-accumulated lightning spawn logic based on camera distance and moonstorm node presence.
  • Parameters: dt (number) – Delta time in seconds since the last frame.
  • Returns: Nothing.
  • Error states: Exits early if ThePlayer or TheWorld.Map is nil. Stops updating if sparks_per_sec_mod <= 0.0.

Events & listeners

  • Listens to: moonstorm_nodes_dirty_relay – When received, toggles component update state based on whether moonstorm nodes exist (_moonstorm_nodes:value()). Starts updating when nodes are present, stops otherwise. Registered on TheWorld.
  • Pushes: None.