Skip to main content

EffectSlot

Struct EffectSlot 

Source
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>

Source

pub fn new( resource: &'a AnimationResource<'a>, effect_name_hash: u32, seed: u32, ) -> Result<Self, SSRuntimeError>

Source

pub fn get_seed(&self) -> u32

Source

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.

Source

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.

Source

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.

Auto Trait Implementations§

§

impl<'a> Freeze for EffectSlot<'a>

§

impl<'a> RefUnwindSafe for EffectSlot<'a>

§

impl<'a> Send for EffectSlot<'a>

§

impl<'a> Sync for EffectSlot<'a>

§

impl<'a> Unpin for EffectSlot<'a>

§

impl<'a> UnsafeUnpin for EffectSlot<'a>

§

impl<'a> UnwindSafe for EffectSlot<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more