pub struct TreeBuilder { /* private fields */ }Expand description
Fluent builder for assembling BehaviorNode trees.
§Example
ⓘ
let root = TreeBuilder::sequence("root")
.leaf("idle", |_bb, _dt| NodeStatus::Success)
.selector("patrol_or_attack")
.leaf("patrol", patrol_fn)
.leaf("attack", attack_fn)
.end()
.build();Implementations§
Source§impl TreeBuilder
impl TreeBuilder
Sourcepub fn parallel(name: &str, policy: ParallelPolicy) -> Self
pub fn parallel(name: &str, policy: ParallelPolicy) -> Self
Begin a new top-level Parallel.
Sourcepub fn sequence_child(self, name: &str) -> Self
pub fn sequence_child(self, name: &str) -> Self
Push a Sequence child onto the current composite.
Sourcepub fn selector_child(self, name: &str) -> Self
pub fn selector_child(self, name: &str) -> Self
Push a Selector child onto the current composite.
Sourcepub fn parallel_child(self, name: &str, policy: ParallelPolicy) -> Self
pub fn parallel_child(self, name: &str, policy: ParallelPolicy) -> Self
Push a Parallel child onto the current composite.
Sourcepub fn decorator(self, name: &str, kind: DecoratorKind) -> Self
pub fn decorator(self, name: &str, kind: DecoratorKind) -> Self
Push a Decorator child onto the current composite.
Sourcepub fn leaf<F>(self, name: &str, tick_fn: F) -> Self
pub fn leaf<F>(self, name: &str, tick_fn: F) -> Self
Add a leaf node to the current composite or decorator.
Sourcepub fn leaf_full<Enter, Tick, Exit>(
self,
name: &str,
enter_fn: Enter,
tick_fn: Tick,
exit_fn: Exit,
) -> Selfwhere
Enter: FnMut(&mut Blackboard) + 'static,
Tick: FnMut(&mut Blackboard, f32) -> NodeStatus + 'static,
Exit: FnMut(&mut Blackboard, NodeStatus) + 'static,
pub fn leaf_full<Enter, Tick, Exit>(
self,
name: &str,
enter_fn: Enter,
tick_fn: Tick,
exit_fn: Exit,
) -> Selfwhere
Enter: FnMut(&mut Blackboard) + 'static,
Tick: FnMut(&mut Blackboard, f32) -> NodeStatus + 'static,
Exit: FnMut(&mut Blackboard, NodeStatus) + 'static,
Add a full leaf with enter/exit callbacks.
Sourcepub fn subtree_ref(self, name: &str) -> Self
pub fn subtree_ref(self, name: &str) -> Self
Add a subtree reference node.
Sourcepub fn node(self, node: BehaviorNode) -> Self
pub fn node(self, node: BehaviorNode) -> Self
Add an already-built node as a child.
Sourcepub fn build(self) -> BehaviorNode
pub fn build(self) -> BehaviorNode
Finish building and return the root BehaviorNode.
Panics if not at the outermost frame.
Sourcepub fn into_tree(self, tree_name: &str) -> BehaviorTree
pub fn into_tree(self, tree_name: &str) -> BehaviorTree
Convenience: build and wrap in a BehaviorTree.
Auto Trait Implementations§
impl Freeze for TreeBuilder
impl !RefUnwindSafe for TreeBuilder
impl !Send for TreeBuilder
impl !Sync for TreeBuilder
impl Unpin for TreeBuilder
impl UnsafeUnpin for TreeBuilder
impl !UnwindSafe for TreeBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.