Skip to main content

Lunarsupernovaburning

Overview

This component manages the lunar burn effect applied during the Alter Guardian's Phase 4 (supernova) mechanic in DST. It tracks sources of "supernovaburning" state, spawns and positions associated visual effects, and periodically inflicts damage on both the entity and its mount (if any), scaled by the number of valid burning sources.

Dependencies & Tags

  • Requires components: health, rider (optional), colouradder (added dynamically), grogginess (optional, updated conditionally)
  • Adds/removes tags: None (does not modify entity tags directly)
  • Removes itself via inst:RemoveComponent("lunarsupernovaburning") when no sources remain or the entity becomes invalid/unargetable

Properties

PropertyTypeDefault ValueDescription
instEntitynil (injected by Class)The entity this component is attached to
sourcestable{}Map of active sources (keys are entities with "supernovaburning" state) to their visual effect prefabs
firsttickbooleantrueTracks if this is the first update tick; reset to nil after first damage application
wasdamagingbooleanfalseIndicates whether damage was applied in the previous update tick

Main Functions

OnRemoveFromEntity()

  • Description: Cleans up when the component is removed: unregisters lunar burn source from health, removes visual tint, and removes all associated visual effect prefabs.
  • Parameters: None (implicit self)

GetFxSize()

  • Description: Determines the appropriate visual effect size (small, med, or large) and radius based on the entity's physics radius and tags (e.g., "epic", "largecreature"), considering mounted entities when applicable.
  • Parameters: None (implicit self)
  • Returns: Two values: a string ("small", "med", "large") and a numeric radius.

AddSource(source)

  • Description: Registers a new source entity (expected to have "supernovaburning" state) and spawns a corresponding visual effect prefab (alterguardian_lunar_supernova_burn_fx). Positions the effect based on relative location during the next update.
  • Parameters:
    • source (Entity): The entity being tracked as a lunar burn source.

OnUpdate(dt)

  • Description: Core logic called every tick. Validates active sources (removing invalid or out-of-range ones), updates visual effect positions, and applies periodic damage and grogginess effects when sources are present. Removes itself if no valid sources remain or the entity becomes untargetable.
  • Parameters:
    • dt (number): Delta time (unused explicitly; tick-based logic dominates).

Events & Listeners

  • Listens for component removal via OnRemoveFromEntity() (called automatically by the ECS on component removal)
  • Does not listen for game events (e.g., via inst:ListenForEvent)
  • Does not push custom events via inst:PushEvent