Struct aspen::BehaviorTree
[−]
[src]
pub struct BehaviorTree<'a, S> { /* fields omitted */ }
Main behavior tree struct.
Methods
impl<'a, S> BehaviorTree<'a, S>
[src]
fn new(root: Node<'a, S>) -> BehaviorTree<'a, S>
Create a new behavior tree with the supplied Node
as the root.
fn root(&self) -> &Node<'a, S>
Returns a reference to the root node.
fn tick(&mut self, world: &mut S) -> Status
Tick the behavior tree a single time.
If the tree has already been completed, ticking it again will reset it.
When the tree is reset, it will return an Initialized
status a single
time.
fn reset(&mut self)
Reset the tree to a state identical to before it had ran.
fn run<F>(&mut self, freq: f64, world: &mut S, hook: Option<F>) -> Status where
F: FnMut(&BehaviorTree<'a, S>),
F: FnMut(&BehaviorTree<'a, S>),
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, it will log a warning unless the specified frequency is infinite.
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.