Struct aspen::std_nodes::Sequence [] [src]

pub struct Sequence { /* fields omitted */ }

A node that will tick its children in order as long as they succeed.

This node will tick all of its children in order until one of them returns either Status::Running or Status::Failed. If none do, this node succeeds.

The difference between this node and an ActiveSequence is that this node will resume ticking at the last running node whereas the active version will always restart ticking from the beginning. That makes the active sequence good for things that always need to be rechecked and this version good for completing actions. Once a node is ticked to completion, this version will not revisit it.

This node is equivalent to an "and" statement.

State

Initialized: Before being ticked after being created or reset.

Running: The latest ticked child node return that it was running.

Succeeded: All child nodes succeeded.

Failed: All child nodes failed.

Children

Any number of children. A child node will only be ticked if all the nodes to the left succeeded and this node has not yet completed.

Unlike the active version, children nodes will only be reset when this node is reset.

Examples

A node that returns success:

let mut node = Sequence::new(vec![
    AlwaysSucceed::new(),
    AlwaysSucceed::new(),
    AlwaysSucceed::new()
]);
assert_eq!(node.tick(), Status::Succeeded);

A node that returns it is running:

let mut node = Sequence::new(vec![
    AlwaysSucceed::new(),
    AlwaysRunning::new(),
    AlwaysFail::new()
]);
assert_eq!(node.tick(), Status::Running);

A node that returns it failed:

let mut node = Sequence::new(vec![
    AlwaysSucceed::new(),
    AlwaysSucceed::new(),
    AlwaysFail::new()
]);
assert_eq!(node.tick(), Status::Failed);

Methods

impl Sequence
[src]

Creates a new Sequence node from a vector of Nodes.

Trait Implementations

impl Internals for Sequence
[src]

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

Resets the internal state of the node. Read more

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

Returns the string "Sequence".