Struct aspen::std_nodes::Decorator [] [src]

pub struct Decorator { /* fields omitted */ }

A node whose status is determined by running a function on its child's status.

This node will tick its child and then run the supplied function on the child's return status.

State

Initialized: Depends on function.

Running: Depends on function.

Succeeded: Depends on function.

Failed: Depends on function.

Children

Takes a single child which is ticked or reset every time the Decorator is ticked or reset. The child may be ticked to completion multiple times before the decorator is done.

Examples

A decorator that inverts the return status of its child:

fn invert(s: Status) -> Status
{
    if s == Status::Succeeded { Status::Failed }
    else if s == Status::Failed { Status::Succeeded }
    else { s }
}

let child = AlwaysSucceed::new();
let mut node = Decorator::new(child, Box::new(invert));
assert_eq!(node.tick(), Status::Failed);

Methods

impl Decorator
[src]

Creates a new Decorator node with the supplied child node and function to be run on the child's status.

Trait Implementations

impl Internals for Decorator
[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 "Decorator".