pub enum State<A, S> {
Show 14 variants
WaitForPressedState(Button),
WaitForReleasedState(Button),
ActionState(A, Option<S>),
FailState(Box<State<A, S>>),
AlwaysSucceedState(Box<State<A, S>>),
WaitState(f64, f64),
WaitForeverState,
IfState(Box<Behavior<A>>, Box<Behavior<A>>, Status, Box<State<A, S>>),
SelectState(Vec<Behavior<A>>, usize, Box<State<A, S>>),
SequenceState(Vec<Behavior<A>>, usize, Box<State<A, S>>),
WhileState(Box<State<A, S>>, Vec<Behavior<A>>, usize, Box<State<A, S>>),
WhenAllState(Vec<Option<State<A, S>>>),
WhenAnyState(Vec<Option<State<A, S>>>),
AfterState(usize, Vec<State<A, S>>),
}Expand description
Keeps track of a behavior.
Variants§
WaitForPressedState(Button)
Returns Success when button is pressed.
WaitForReleasedState(Button)
Returns Success when button is released.
ActionState(A, Option<S>)
Executes an action.
FailState(Box<State<A, S>>)
Converts Success into Failure and vice versa.
AlwaysSucceedState(Box<State<A, S>>)
Ignores failures and always return Success.
WaitState(f64, f64)
Keeps track of waiting for a period of time before continuing.
f64: Total time in seconds to wait
f64: Time elapsed in seconds
WaitForeverState
Waits forever.
IfState(Box<Behavior<A>>, Box<Behavior<A>>, Status, Box<State<A, S>>)
Keeps track of an If behavior.
If status is Running, then it evaluates the condition.
If status is Success, then it evaluates the success behavior.
If status is Failure, then it evaluates the failure behavior.
SelectState(Vec<Behavior<A>>, usize, Box<State<A, S>>)
Keeps track of a Select behavior.
SequenceState(Vec<Behavior<A>>, usize, Box<State<A, S>>)
Keeps track of an Sequence behavior.
WhileState(Box<State<A, S>>, Vec<Behavior<A>>, usize, Box<State<A, S>>)
Keeps track of a While behavior.
WhenAllState(Vec<Option<State<A, S>>>)
Keeps track of a WhenAll behavior.
WhenAnyState(Vec<Option<State<A, S>>>)
Keeps track of a WhenAny behavior.
AfterState(usize, Vec<State<A, S>>)
Keeps track of an After behavior.
Implementations§
Source§impl<A: Clone, S> State<A, S>
impl<A: Clone, S> State<A, S>
Sourcepub fn event<E, F>(&mut self, e: &E, f: &mut F) -> (Status, f64)
pub fn event<E, F>(&mut self, e: &E, f: &mut F) -> (Status, f64)
Updates the cursor that tracks an event.
The action need to return status and remaining delta time. Returns status and the remaining delta time.
Passes event, delta time in seconds, action and state to closure. The closure should return a status and remaining delta time.