Struct aspen::BehaviorTree
[−]
[src]
pub struct BehaviorTree { /* fields omitted */ }
Main behavior tree struct.
A behavior tree is considered to have been run to completion when it
returns either Status::Succeeded
or Status::Failed
when ticked. Unlike a
Node
, the BehaviorTree
will not automatically reset itself when ticked.
Instead, ticking or running a completed behavior tree will just return the
value of the last tick - it must be explicitly reset.
Methods
impl BehaviorTree
[src]
fn new(root: Node) -> BehaviorTree
Create a new behavior tree with the supplied Node
as the root.
impl BehaviorTree
[src]
fn root(&self) -> &Node
Returns a reference to the root node.
fn tick(&mut self) -> Status
Tick the behavior tree a single time.
If the tree has already been run to completion, this will simply return the value of the last tick.
fn reset(&mut self)
Reset the tree so that it can be run again.
fn run<F>(&mut self, freq: f32, hook: Option<F>) -> Status where
F: FnMut(&BehaviorTree),
F: FnMut(&BehaviorTree),
Run the behavior tree until it either succeeds or fails.
This makes no guarantees that it will run at the specified frequency. If a single tick takes longer than the alloted tick time, then it will do so silently.
If the hook is supplied, it will be run after every tick. A reference to this behavior tree will be supplied as an argument.
NOTE: The only time this will return Status::Running
is if the frequency is zero
and the behavior tree is running after the first tick.