[−][src]Enum ai_behavior::State
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.
Methods
impl<A: Clone, S> State<A, S>
[src]
pub fn new(behavior: Behavior<A>) -> Self
[src]
Creates a state from a behavior.
pub fn event<E, F>(&mut self, e: &E, f: &mut F) -> (Status, f64) where
E: GenericEvent,
F: FnMut(ActionArgs<E, A, S>) -> (Status, f64),
[src]
E: GenericEvent,
F: FnMut(ActionArgs<E, A, S>) -> (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.
Trait Implementations
impl<A: PartialEq, S: PartialEq> PartialEq<State<A, S>> for State<A, S>
[src]
impl<A: Clone, S: Clone> Clone for State<A, S>
[src]
fn clone(&self) -> State<A, S>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<A, S> Serialize for State<A, S> where
A: Serialize,
S: Serialize,
[src]
A: Serialize,
S: Serialize,
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<'de, A, S> Deserialize<'de> for State<A, S> where
A: Deserialize<'de>,
S: Deserialize<'de>,
[src]
A: Deserialize<'de>,
S: Deserialize<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
Auto Trait Implementations
impl<A, S> Send for State<A, S> where
A: Send,
S: Send,
A: Send,
S: Send,
impl<A, S> Sync for State<A, S> where
A: Sync,
S: Sync,
A: Sync,
S: Sync,
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,