Struct aspen::std_nodes::Repeat [] [src]

pub struct Repeat { /* fields omitted */ }

A node that will repeat its child a specific number of times, possibly infinite.

A repeat node will report that it is running until its child node has been run to completion the specified number of times, upon which it will be considered successful. This could also be an infinite number, in which case this node will always be considered running.

State

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

Running: Until the child node has been reset the specified number of times. If there is no limit, always.

Succeeded: Once the child has been reset the specified number of times. If there is no limit, never.

Failed: Never.

Children

One. It is ticked or reset whenever the repeat node is ticked or reset. It also may be reset multiple times before the repeat node is reset or completed.

Examples

Force the child to be reset a specific number of times:

let run_limit = 5;
let child = AlwaysFail::new();
let mut node = Repeat::with_limit(child, run_limit);

// Subtract one since there is a run in the assert
for _ in 0..(run_limit - 1) {
    assert_eq!(node.tick(), Status::Running);
}
assert_eq!(node.tick(), Status::Succeeded);

Methods

impl Repeat
[src]

Creates a new Repeat node that will repeat forever.

Creates a new Repeat node that will only repeat a limited number of times.

The limit specifies the number of times this node can be run. A limit of zero means that the node will instantly succeed.

Trait Implementations

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