pub struct EffectInstance { /* private fields */ }Expand description
Runtime instance of an author-defined effect.
Implementations§
Source§impl EffectInstance
impl EffectInstance
Sourcepub fn new(
id: impl Into<EffectId>,
duration_secs: Option<f32>,
stacks: u32,
) -> Self
pub fn new( id: impl Into<EffectId>, duration_secs: Option<f32>, stacks: u32, ) -> Self
Creates an effect instance with an initial duration and stack count.
The provided duration is stored as both the original duration and the
current remaining duration. None means indefinite.
Sourcepub fn with_runtime_state(
id: impl Into<EffectId>,
duration_secs: Option<f32>,
remaining_secs: Option<f32>,
stacks: u32,
) -> Self
pub fn with_runtime_state( id: impl Into<EffectId>, duration_secs: Option<f32>, remaining_secs: Option<f32>, stacks: u32, ) -> Self
Creates an effect instance with explicit original and remaining durations.
This is useful when hydrating effect state from author-owned save data or
when forwarding an already-ticked instance. Durations are normalized to
finite, non-negative values; None means indefinite.
Sourcepub fn from_definition(definition: &EffectDefinition) -> Self
pub fn from_definition(definition: &EffectDefinition) -> Self
Creates an instance from a registered definition’s defaults.
Sourcepub fn duration_secs(&self) -> Option<f32>
pub fn duration_secs(&self) -> Option<f32>
Returns the initial duration captured when the instance was applied.
None means the effect is indefinite.
Sourcepub fn remaining_secs(&self) -> Option<f32>
pub fn remaining_secs(&self) -> Option<f32>
Returns remaining duration. None means indefinite.
Sourcepub fn remaining_ratio(&self) -> Option<f32>
pub fn remaining_ratio(&self) -> Option<f32>
Returns the remaining fraction of the original duration.
Timed effects return a value clamped to 0.0..=1.0. Indefinite effects
return None because they have no finite denominator.
Sourcepub fn snapshot(&self) -> EffectInstanceSnapshot
pub fn snapshot(&self) -> EffectInstanceSnapshot
Returns a serializable snapshot of this effect instance.
Trait Implementations§
Source§impl Clone for EffectInstance
impl Clone for EffectInstance
Source§impl Debug for EffectInstance
impl Debug for EffectInstance
Source§impl<'de> Deserialize<'de> for EffectInstance
impl<'de> Deserialize<'de> for EffectInstance
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl PartialEq for EffectInstance
impl PartialEq for EffectInstance
Source§impl Serialize for EffectInstance
impl Serialize for EffectInstance
impl StructuralPartialEq for EffectInstance
Auto Trait Implementations§
impl Forget for EffectInstance
impl Freeze for EffectInstance
impl Move for EffectInstance
impl RefUnwindSafe for EffectInstance
impl Send for EffectInstance
impl Sync for EffectInstance
impl Unpin for EffectInstance
impl UnsafeUnpin for EffectInstance
impl UnwindSafe for EffectInstance
Blanket Implementations§
Source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
Source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
T ShaderType for self. When used in AsBindGroup
derives, it is safe to assume that all images in self exist.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ConditionalSend for Twhere
T: Send,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more