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]
fn new<F: Fn() -> bool + 'static>(func: F) -> Node
Constructs a new Condition node that will run the given function.
Trait Implementations
impl Internals for Condition
[src]
fn tick(&mut self) -> Status
Ticks the internal state of the node a single time. Read more
fn reset(&mut self)
Resets the internal state of the node. Read more
fn type_name(&self) -> &'static str
Returns the string "Condition".
fn children(&self) -> Option<Vec<&Node>>
Returns a vector of references to this node's children. Read more