Enum ai_behavior::Behavior[][src]

pub enum Behavior<A> {
Show 14 variants WaitForPressed(Button), WaitForReleased(Button), Wait(f64), WaitForever, Action(A), Fail(Box<Behavior<A>>), AlwaysSucceed(Box<Behavior<A>>), Select(Vec<Behavior<A>>), If(Box<Behavior<A>>, Box<Behavior<A>>, Box<Behavior<A>>), Sequence(Vec<Behavior<A>>), While(Box<Behavior<A>>, Vec<Behavior<A>>), WhenAll(Vec<Behavior<A>>), WhenAny(Vec<Behavior<A>>), After(Vec<Behavior<A>>),
}
Expand description

Describes a behavior.

This is used for more complex event logic. Can also be used for game AI.

Variants

WaitForPressed(Button)

Wait for a button to be pressed.

Returns Success when the button is pressed, otherwise it returns Running.

Tuple Fields of WaitForPressed

0: Button
WaitForReleased(Button)

Wait for a button to be released.

Returns Success when the button is released, otherwise it returns Running.

Tuple Fields of WaitForReleased

0: Button
Wait(f64)

Waits an amount of time before continuing.

f64: Time in seconds

Tuple Fields of Wait

0: f64
WaitForever

Wait forever.

Action(A)

A high level description of an action.

Tuple Fields of Action

0: A
Fail(Box<Behavior<A>>)

Converts Success into Failure and vice versa.

Tuple Fields of Fail

0: Box<Behavior<A>>
AlwaysSucceed(Box<Behavior<A>>)

Ignores failures and returns Success.

Tuple Fields of AlwaysSucceed

0: Box<Behavior<A>>
Select(Vec<Behavior<A>>)

Runs behaviors one by one until a behavior succeeds.

If a behavior fails it will try the next one. Fails if the last behavior fails. Can be thought of as a short-circuited logical OR gate.

Tuple Fields of Select

0: Vec<Behavior<A>>
If(Box<Behavior<A>>, Box<Behavior<A>>, Box<Behavior<A>>)

If(condition, success, failure)

Tuple Fields of If

0: Box<Behavior<A>>1: Box<Behavior<A>>2: Box<Behavior<A>>
Sequence(Vec<Behavior<A>>)

Runs behaviors one by one until all succeeded.

The sequence fails if a behavior fails. The sequence succeeds if all the behavior succeeds. Can be thought of as a short-circuited logical AND gate.

Tuple Fields of Sequence

0: Vec<Behavior<A>>
While(Box<Behavior<A>>, Vec<Behavior<A>>)

Loops while conditional behavior is running.

Succeeds if the conditional behavior succeeds. Fails if the conditional behavior fails, or if any behavior in the loop body fails.

Tuple Fields of While

0: Box<Behavior<A>>1: Vec<Behavior<A>>
WhenAll(Vec<Behavior<A>>)

Runs all behaviors in parallel until all succeeded.

Succeeds if all behaviors succeed. Fails is any behavior fails.

Tuple Fields of WhenAll

0: Vec<Behavior<A>>
WhenAny(Vec<Behavior<A>>)

Runs all behaviors in parallel until one succeeds.

Succeeds if one behavior succeeds. Fails if all behaviors failed.

Tuple Fields of WhenAny

0: Vec<Behavior<A>>
After(Vec<Behavior<A>>)

Runs all behaviors in parallel until all succeeds in sequence.

Succeeds if all behaviors succeed, but only if succeeding in sequence. Fails if one behavior fails.

Tuple Fields of After

0: Vec<Behavior<A>>

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Deserialize this value from the given Serde deserializer. Read more

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

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.