Struct aspen::std_nodes::Condition [] [src]

pub struct Condition { /* fields omitted */ }

A node whose status is determined by a function.

When ticked, this node will run the supplied function to determine its return value. If the function returns true, the node is considered successful - it is considered failed otherwise. Note that this means the node will never be in a running state. As such, all supplied functions should be able to be completed within a single tick's amount of time.

State

Initialized: Before being ticked after either being created or reset.

Running: Never.

Succeeded: If the supplied function returns true.

Failed: If the supplied function returns false.

Children

None

Examples

A condition node that checks whether or not it is possible to subtract two unsigned integers:

const FIRST: u32 = 10;
const SECOND: u32 = 100;

let mut node = Condition::new(|| FIRST > SECOND );
assert_eq!(node.tick(), Status::Failed);

Methods

impl Condition
[src]

Constructs a new Condition node that will run the given function.

Trait Implementations

impl Internals for Condition
[src]

Ticks the internal state of the node a single time. Read more

Resets the internal state of the node. Read more

Returns the string "Condition".

Returns a vector of references to this node's children. Read more