Skip to main content

BehaviorTreeElement

Struct BehaviorTreeElement 

Source
pub struct BehaviorTreeElement { /* private fields */ }
Expand description

A tree elements.

Implementations§

Source§

impl BehaviorTreeElement

Source

pub fn create( kind: TreeElementKind, behavior: BehaviorPtr, data: BehaviorData, ) -> Self

Construct a BehaviorTreeElement.

Source

pub fn new( kind: TreeElementKind, behavior: BehaviorPtr, data: BehaviorData, children: BehaviorTreeElementList, conditions: Conditions, ) -> Self

Construct a BehaviorTreeElement.

Source

pub const fn uid(&self) -> u16

Get the uid.

Source

pub const fn id(&self) -> &Arc<str>

Get the id.

Source

pub const fn name(&self) -> &Arc<str>

Returns the name of the behavior.

Source

pub const fn data(&self) -> &BehaviorData

Returns a reference to the BehaviorData.

Source

pub const fn data_mut(&mut self) -> &mut BehaviorData

Returns a mutable reference to the BehaviorData.

Source

pub const fn behavior(&self) -> &BehaviorPtr

Returns a reference to the behavior.

Source

pub const fn behavior_mut(&mut self) -> &mut BehaviorPtr

Returns a mutable reference to the behavior.

Source

pub const fn blackboard(&self) -> &Databoard

Returns a reference to the blackboard.

Source

pub const fn blackboard_mut(&mut self) -> &mut Databoard

Returns a reference to the blackboard.

Source

pub const fn children(&self) -> &BehaviorTreeElementList

Returns the children.

Source

pub const fn children_mut(&mut self) -> &mut BehaviorTreeElementList

Returns the children mutable.

Source

pub const fn pre_conditions(&self) -> &PreConditions

Returns the pre conditions.

Source

pub const fn pre_conditions_mut(&mut self) -> &mut PreConditions

Returns the pre condition mutables.

Source

pub const fn post_conditions(&self) -> &PostConditions

Returns the post conditions.

Source

pub const fn post_conditions_mut(&mut self) -> &mut PostConditions

Returns the post conditions mutable.

Source

pub fn halt(&mut self, runtime: &SharedRuntime) -> Result<(), Error>

Halts the element and all its children considering postconditions.

§Errors
Source

pub async fn tick(&mut self, runtime: &SharedRuntime) -> BehaviorResult

Ticks the element considering pre- and postconditions.

§Errors
Source

pub fn halt_child_at( &mut self, index: usize, runtime: &SharedRuntime, ) -> Result<(), Error>

Halts child at index.

§Errors
  • if index is out of childrens bounds.
Source

pub fn halt_children_from( &mut self, index: usize, runtime: &SharedRuntime, ) -> Result<(), Error>

Halt all children at and beyond index.

§Errors
  • if index is out of childrens bounds.
Source

pub fn halt_children(&mut self, runtime: &SharedRuntime) -> Result<(), Error>

Halt all children at and beyond index.

§Errors
  • if index is out of childrens bounds.
Source

pub fn reset_state(&mut self)

Reset state of element.

Source

pub fn add_pre_state_change_callback<T>(&mut self, name: Arc<str>, callback: T)
where T: Fn(&BehaviorData, &mut BehaviorState) + Send + Sync + 'static,

Add a pre state change callback with the given name. The name is not unique, which is important when removing callback.

Source

pub fn remove_pre_state_change_callback(&mut self, name: &str)

Remove any pre state change callback with the given name.

Source

pub fn children_iter(&self) -> impl DoubleEndedIterator<Item = &Self>

Return an iterator over the children.

Source

pub fn children_iter_mut( &mut self, ) -> impl DoubleEndedIterator<Item = &mut Self>

Return a mutable iterator over the children.

Source

pub fn iter(&self) -> impl Iterator<Item = &Self>

Get an iterator over the tree element.

Source

pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut Self>

Get a mutable iterator over the tree element.

Source

pub const fn kind(&self) -> TreeElementKind

Source

pub const fn groot2_path(&self) -> &Arc<str>

Returns the Groot2 style ‘path’ of the element.

Source

pub const fn state(&self) -> BehaviorState

Returns the current state of the element.

Source

pub fn add_child(&mut self, child: Self)

Adds a child to the elements children list.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.