[][src]Enum ai_behavior::State

pub enum State<A, S> {
    WaitForPressedState(Button),
    WaitForReleasedState(Button),
    ActionState(A, Option<S>),
    FailState(Box<State<A, S>>),
    AlwaysSucceedState(Box<State<A, S>>),
    WaitState(f64f64),
    WaitForeverState,
    IfState(Box<Behavior<A>>, Box<Behavior<A>>, StatusBox<State<A, S>>),
    SelectState(Vec<Behavior<A>>, usizeBox<State<A, S>>),
    SequenceState(Vec<Behavior<A>>, usizeBox<State<A, S>>),
    WhileState(Box<State<A, S>>, Vec<Behavior<A>>, usizeBox<State<A, S>>),
    WhenAllState(Vec<Option<State<A, S>>>),
    WhenAnyState(Vec<Option<State<A, S>>>),
    AfterState(usizeVec<State<A, S>>),
}

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(f64f64)

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>>, StatusBox<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>>, usizeBox<State<A, S>>)

Keeps track of a Select behavior.

SequenceState(Vec<Behavior<A>>, usizeBox<State<A, S>>)

Keeps track of an Sequence behavior.

WhileState(Box<State<A, S>>, Vec<Behavior<A>>, usizeBox<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(usizeVec<State<A, S>>)

Keeps track of an After behavior.

Implementations

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]

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: Clone, S: Clone> Clone for State<A, S>[src]

impl<'de, A, S> Deserialize<'de> for State<A, S> where
    A: Deserialize<'de>,
    S: Deserialize<'de>, 
[src]

impl<A: PartialEq, S: PartialEq> PartialEq<State<A, S>> for State<A, S>[src]

impl<A, S> Serialize for State<A, S> where
    A: Serialize,
    S: Serialize
[src]

impl<A, S> StructuralPartialEq for State<A, S>[src]

Auto Trait Implementations

impl<A, S> RefUnwindSafe for State<A, S> where
    A: RefUnwindSafe,
    S: RefUnwindSafe

impl<A, S> Send for State<A, S> where
    A: Send,
    S: Send

impl<A, S> Sync for State<A, S> where
    A: Sync,
    S: Sync

impl<A, S> Unpin for State<A, S> where
    A: Unpin,
    S: Unpin

impl<A, S> UnwindSafe for State<A, S> where
    A: UnwindSafe,
    S: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.