pub struct BehaviorTree {
pub name: String,
pub bb: Blackboard,
pub registry: SubtreeRegistry,
pub last_status: NodeStatus,
pub sim_time: f64,
pub active: bool,
/* private fields */
}Expand description
The top-level behavior tree that owns a root node, a blackboard, and an optional subtree registry.
Fields§
§name: StringHuman-readable label for debugging.
bb: Blackboard§registry: SubtreeRegistry§last_status: NodeStatusStatus returned by the last tick() call.
sim_time: f64Total accumulated simulation time in seconds.
active: boolWhether the tree is currently active.
Implementations§
Source§impl BehaviorTree
impl BehaviorTree
pub fn new(name: &str, root: BehaviorNode) -> Self
Sourcepub fn tick(&mut self, dt: f32) -> NodeStatus
pub fn tick(&mut self, dt: f32) -> NodeStatus
Tick the entire tree by dt seconds. Advances the blackboard clock
and resolves any SubtreeRef nodes via the registry.
Sourcepub fn set_active(&mut self, active: bool)
pub fn set_active(&mut self, active: bool)
Pause / resume ticking.
Sourcepub fn blackboard(&self) -> &Blackboard
pub fn blackboard(&self) -> &Blackboard
Access the blackboard immutably.
Sourcepub fn blackboard_mut(&mut self) -> &mut Blackboard
pub fn blackboard_mut(&mut self) -> &mut Blackboard
Access the blackboard mutably (useful for injecting sensor data).
Sourcepub fn registry_mut(&mut self) -> &mut SubtreeRegistry
pub fn registry_mut(&mut self) -> &mut SubtreeRegistry
Access the subtree registry mutably (register subtrees after build).
Sourcepub fn node_names(&self) -> Vec<String>
pub fn node_names(&self) -> Vec<String>
Collect all node names in the tree (depth-first).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BehaviorTree
impl !RefUnwindSafe for BehaviorTree
impl !Send for BehaviorTree
impl !Sync for BehaviorTree
impl Unpin for BehaviorTree
impl UnsafeUnpin for BehaviorTree
impl !UnwindSafe for BehaviorTree
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.