Enum ai_behavior::State [] [src]

pub enum State<A, S> {
    PressedState(Button),
    ReleasedState(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

PressedState(Button)

Returns Success when button is pressed.

ReleasedState(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.

Methods

impl<A: Clone, S> State<A, S>
[src]

fn new(behavior: Behavior<A>) -> Self

Creates a state from a behavior.

fn event<E, F>(&mut self, e: &E, f: &mut F) -> (Status, f64) where 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 for State<A, S>
[src]

fn eq(&self, __arg_0: &State<A, S>) -> bool

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, __arg_0: &State<A, S>) -> bool

This method tests for !=.

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

fn encode<__SAS: Encoder>(&self, __arg_0: &mut __SAS) -> Result<(), __SAS::Error>

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

fn decode<__DAS: Decoder>(__arg_0: &mut __DAS) -> Result<State<A, S>, __DAS::Error>

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

fn clone(&self) -> State<A, S>

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)
1.0.0

Performs copy-assignment from source. Read more