Shatterfx
Overview
This component provides controlled playback of shatter-related animations for an entity. It maintains a set of named animation levels and ensures proper sequencing—including optional pre-animation frames—when transitioning between shatter states (e.g., partial → full destruction).
Dependencies & Tags
- Requires:
AnimStatecomponent (used viaself.inst.AnimState). - No explicit components are added or tags set/remediated in the constructor.
- Relies on
self.insthaving a validAnimStatecomponent available at runtime.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
inst | GObject | (passed in) | Reference to the owning entity instance. |
level | number? | nil | Current active shatter level (index into self.levels), or nil if none active. |
levels | table | {} | Map of valid animation configurations, keyed by level index (e.g., { [1] = { pre = "shatter_p0", anim = "shatter_0" } }). |
Main Functions
SetLevel(level)
- Description: Sets the current shatter animation level, playing the corresponding animation sequence. If a prior level is inactive, it plays an optional
preanimation before looping the main animation (anim) indefinitely. Ensures the requested level does not exceed available levels and prevents redundant re-sets. - Parameters:
level(number): 1-based index specifying the desired shatter state. Internally clamped to#self.levels.
Events & Listeners
None identified.