pub struct TimerData {
pub duration: u64,
pub elapsed: u64,
pub finished: bool,
pub mode: TimerModeData,
}Expand description
Intermediate data representation of a Bevy Timer.
Fields§
§duration: u64Duration in nanoseconds
elapsed: u64Elapsed time in nanoseconds
finished: boolWhether the timer has finished
mode: TimerModeDataTimer mode (once or repeating)
Implementations§
Source§impl TimerData
impl TimerData
Sourcepub fn new(
duration_nanos: u64,
elapsed_nanos: u64,
finished: bool,
mode: TimerModeData,
) -> Self
pub fn new( duration_nanos: u64, elapsed_nanos: u64, finished: bool, mode: TimerModeData, ) -> Self
Create a new TimerData.
Sourcepub fn from_secs(secs: f32, mode: TimerModeData) -> Self
pub fn from_secs(secs: f32, mode: TimerModeData) -> Self
Create a TimerData from seconds (like Bevy’s Timer::from_seconds).
Sourcepub fn from_duration(duration: Duration, mode: TimerModeData) -> Self
pub fn from_duration(duration: Duration, mode: TimerModeData) -> Self
Create a TimerData from a Duration.
Sourcepub fn validate(&self) -> Result<(), TimerDataError>
pub fn validate(&self) -> Result<(), TimerDataError>
Validate that this TimerData is in a consistent state.
Returns an error if elapsed exceeds duration on a Once timer.
Repeating timers may have elapsed > duration (they wrap around).
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Whether the timer has finished.
Sourcepub fn fraction(&self) -> f32
pub fn fraction(&self) -> f32
Fraction of the timer elapsed, from 0.0 to 1.0.
Returns 0.0 if duration is zero.
Sourcepub fn fraction_remaining(&self) -> f32
pub fn fraction_remaining(&self) -> f32
Fraction of the timer remaining, from 1.0 to 0.0.
Returns 0.0 if duration is zero.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TimerData
impl<'de> Deserialize<'de> for TimerData
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>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for TimerData
impl StructuralPartialEq for TimerData
Auto Trait Implementations§
impl Freeze for TimerData
impl RefUnwindSafe for TimerData
impl Send for TimerData
impl Sync for TimerData
impl Unpin for TimerData
impl UnwindSafe for TimerData
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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)
Converts
&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)
Converts
&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
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Converts this type into the system output type.
Source§impl<T> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>
fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>
Source§impl<T> TypeData for T
impl<T> TypeData for T
Source§fn clone_type_data(&self) -> Box<dyn TypeData>
fn clone_type_data(&self) -> Box<dyn TypeData>
Creates a type-erased clone of this value.