pub struct AnimationStateMachine {
pub states: HashMap<String, AnimState>,
pub transitions: Vec<AnimTransition>,
pub params: HashMap<String, f32>,
pub triggers: HashMap<String, bool>,
pub current_state: Option<String>,
}Expand description
Simple animation state machine.
Fields§
§states: HashMap<String, AnimState>§transitions: Vec<AnimTransition>§params: HashMap<String, f32>§triggers: HashMap<String, bool>§current_state: Option<String>Implementations§
Source§impl AnimationStateMachine
impl AnimationStateMachine
pub fn new() -> Self
pub fn add_state(&mut self, state: AnimState)
pub fn add_transition(&mut self, transition: AnimTransition)
pub fn set_param(&mut self, name: &str, value: f32)
pub fn set_trigger(&mut self, name: &str)
pub fn start(&mut self, state: &str)
Sourcepub fn evaluate(&mut self, animation_done: bool) -> Option<String>
pub fn evaluate(&mut self, animation_done: bool) -> Option<String>
Evaluate transitions. Returns the new animation name if state changed.
Sourcepub fn current_animation(&self) -> Option<&str>
pub fn current_animation(&self) -> Option<&str>
Current animation name from the active state.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AnimationStateMachine
impl RefUnwindSafe for AnimationStateMachine
impl Send for AnimationStateMachine
impl Sync for AnimationStateMachine
impl Unpin for AnimationStateMachine
impl UnsafeUnpin for AnimationStateMachine
impl UnwindSafe for AnimationStateMachine
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> 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>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<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>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> 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)
Convert
&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)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.