pub struct EffectSlot<'a> { /* private fields */ }Expand description
High-level effect slot: wraps EffectContext with the per-slot lifecycle
state. Callers resolve the active effect event externally (via Context::get_active_effect_event)
and feed it to step() along with frame timing — step owns transition
detection, accumulator, dead-effect skip, simulator update, and draw-plan
build in one call.
The cross-language contract is identical in Rust / C / Web: 1) construct
once per effect part, 2) call step() per frame with the resolved event
and timing, 3) read draw_plan_buf only when visible == true and only
before the next step().
Implementations§
Source§impl<'a> EffectSlot<'a>
impl<'a> EffectSlot<'a>
pub fn new( resource: &'a AnimationResource<'a>, effect_name_hash: u32, seed: u32, ) -> Result<Self, SSRuntimeError>
pub fn get_seed(&self) -> u32
Sourcepub fn is_independent(&self) -> bool
pub fn is_independent(&self) -> bool
Whether the slot is currently running independently of the parent’s
frame. Reflects the most recently seen EventEffect.independent;
used by callers to decide whether to schedule continuous tick updates.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Reset the slot’s playback / “last started key” memory to its
just-created state. The host calls this on an explicit head-out
(play / replay) so a re-played animation re-fires the effect from
scratch instead of debouncing the first key as the same one it last
started. The resource binding, emitter caches and simulator
are left intact — forcing last_event_frame = -1 makes the next step
transition, which re-seeds the simulator via the existing ctx.reset()
path.
Sourcepub fn step(
&mut self,
ev: ss_effect_event_info,
parent_frame: f32,
delta_seconds: f32,
fps: f32,
parent_looped: bool,
y_flip: bool,
vert_stride: u8,
draw: bool,
) -> ss_effect_step_result
pub fn step( &mut self, ev: ss_effect_event_info, parent_frame: f32, delta_seconds: f32, fps: f32, parent_looped: bool, y_flip: bool, vert_stride: u8, draw: bool, ) -> ss_effect_step_result
Advance the slot one frame and, when draw is set, build its draw plan.
draw is whether the Player draws the part this frame, that is whether the
part is in the frame’s draw_order. A hidden part is not, and its slot
still has to step every frame so an independently playing effect keeps
time; with draw == false the step moves only that (the clock and the
transition state) and returns not visible. The particles are a function of
the effect’s time alone, so the next drawn step builds exactly the plan it
would have built had every step drawn.