Moonstormstaticcapturable
Based on game build 714014 | Last updated: 2026-03-03
Overview
MoonstormStaticCapturable is a lightweight component that enables an entity to be tracked as a target for moonstormstaticcatcher components (e.g., during boss phase mechanics). It maintains a set of active targeters, fires callbacks when targeting state changes, and notifies other systems via events when it is first targeted, no longer targeted, or caught. It is designed to work in conjunction with the moonstormstaticcatcher component.
Usage example
local inst = CreateEntity()
inst:AddComponent("moonstormstaticcapturable")
inst.components.moonstormstaticcapturable:SetOnTargetedFn(function(entity)
print("Entity is now being targeted!")
end)
inst.components.moonstormstaticcapturable:SetOnCaughtFn(function(entity, targeter, doer)
print("Entity was caught!")
end)
Dependencies & tags
Components used: None identified
Tags: Adds/removes moonstormstaticcapturable tag based on enabled state.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
enabled | boolean | true | Whether the capturable state is active; controls presence of the moonstormstaticcapturable tag. |
targeters | table | {} | Internal map of objects that are currently targeting this entity. |
ontargetedfn | function? | nil | Optional callback invoked when the entity transitions from untargeted to targeted. |
onuntargetedfn | function? | nil | Optional callback invoked when the entity transitions from targeted to untargeted. |
oncaughtfn | function? | nil | Optional callback invoked when the entity is caught (typically by a moonstormstaticcatcher). |
Main functions
SetEnabled(enabled)
- Description: Enables or disables the capturable state. When disabled, the
moonstormstaticcapturabletag is removed; when enabled, the tag is added. - Parameters:
enabled(boolean) – whether to enable the component. - Returns: Nothing.
- Error states: None.
IsEnabled()
- Description: Returns whether the component is currently enabled.
- Parameters: None.
- Returns: boolean –
trueif enabled,falseotherwise.
SetOnTargetedFn(fn)
- Description: Sets a callback function to be invoked when the entity transitions from untargeted to targeted.
- Parameters:
fn(function(entity) ornil) – callback that receives the entity instance. - Returns: Nothing.
SetOnUntargetedFn(fn)
- Description: Sets a callback function to be invoked when the entity transitions from targeted to untargeted.
- Parameters:
fn(function(entity) ornil) – callback that receives the entity instance. - Returns: Nothing.
SetOnCaughtFn(fn)
- Description: Sets a callback function to be invoked when the entity is caught.
- Parameters:
fn(function(entity, targeter, doer) ornil) – callback with entity, the object that was targeting it, and the object performing the catch. - Returns: Nothing.
IsTargeted()
- Description: Returns whether the entity is currently being targeted.
- Parameters: None.
- Returns: boolean –
trueif at least one targeter is registered,falseotherwise.
OnTargeted(obj)
- Description: Called by
moonstormstaticcatcherto register a new targeter. Triggers themoonstormstaticcapturable_targetedevent if this is the first targeter. - Parameters:
obj(entity/table) – the object that is now targeting this entity. - Returns: Nothing.
- Error states: Ignores duplicate targeters (idempotent behavior).
OnUntargeted(obj)
- Description: Called by
moonstormstaticcatcherto unregister a targeter. Triggers themoonstormstaticcapturable_untargetedevent if no targeters remain. - Parameters:
obj(entity/table) – the object that is no longer targeting this entity. - Returns: Nothing.
- Error states: Safely handles removal of non-registered targeters.
OnCaught(obj, doer)
- Description: Called by
moonstormstaticcatcherwhen the entity is successfully caught. Fires amoonstormstatic_caughtevent on thedoer(if provided) and invokes theoncaughtfncallback. - Parameters:
obj(entity/table) – the targeter object.
doer(entity ornil) – the entity performing the catch. - Returns: Nothing.
Events & listeners
- Listens to:
onremoveevent on targeter objects (viainst:ListenForEvent("onremove", ...)), to automatically untarget when a targeter is removed. - Pushes:
moonstormstaticcapturable_targeted– when the first targeter is added.moonstormstaticcapturable_untargeted– when the last targeter is removed.moonstormstatic_caught(on thedoerentity) – when caught (viadoer:PushEvent).