Tree

Struct Tree 

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

A behavior tree framework for creating game AI structures.

Implementations§

Source§

impl Tree

Source

pub fn seq(nodes: &Vec<Tree>) -> Tree

Creates a new sequence node that executes an array of child nodes in order.

§Arguments
  • nodes - A vector of child nodes.
§Returns
  • Leaf - A new sequence node.
Source

pub fn sel(nodes: &Vec<Tree>) -> Tree

Creates a new selector node that selects and executes one of its child nodes that will succeed.

§Arguments
  • nodes - A vector of child nodes.
§Returns
  • Leaf - A new selector node.
Source

pub fn con(name: &str, handler: Box<dyn FnMut(&Blackboard) -> bool>) -> Tree

Creates a new condition node that executes a check handler function when executed.

§Arguments
  • name - The name of the condition.
  • check - A function that takes a blackboard object and returns a boolean value.
§Returns
  • Leaf - A new condition node.
Source

pub fn act(action_name: &str) -> Tree

Creates a new action node that executes an action when executed. This node will block the execution until the action finishes.

§Arguments
  • action_name - The name of the action to execute.
§Returns
  • Leaf - A new action node.
Source

pub fn command(action_name: &str) -> Tree

Creates a new command node that executes a command when executed. This node will return right after the action starts.

§Arguments
  • action_name - The name of the command to execute.
§Returns
  • Leaf - A new command node.
Source

pub fn wait(duration: f64) -> Tree

Creates a new wait node that waits for a specified duration when executed.

§Arguments
  • duration - The duration to wait in seconds.
§Returns
  • A new wait node of type Leaf.
Source

pub fn countdown(time: f64, node: &Tree) -> Tree

Creates a new countdown node that executes a child node continuously until a timer runs out.

§Arguments
  • time - The time limit in seconds.
  • node - The child node to execute.
§Returns
  • A new countdown node of type Leaf.
Source

pub fn timeout(time: f64, node: &Tree) -> Tree

Creates a new timeout node that executes a child node until a timer runs out.

§Arguments
  • time - The time limit in seconds.
  • node - The child node to execute.
§Returns
  • A new timeout node of type Leaf.
Source

pub fn repeat(times: i32, node: &Tree) -> Tree

Creates a new repeat node that executes a child node a specified number of times.

§Arguments
  • times - The number of times to execute the child node.
  • node - The child node to execute.
§Returns
  • A new repeat node of type Leaf.
Source

pub fn repeat_forever(node: &Tree) -> Tree

Creates a new repeat node that executes a child node repeatedly.

§Arguments
  • node - The child node to execute.
§Returns
  • A new repeat node of type Leaf.
Source

pub fn retry(times: i32, node: &Tree) -> Tree

Creates a new retry node that executes a child node repeatedly until it succeeds or a maximum number of retries is reached.

§Arguments
  • times - The maximum number of retries.
  • node - The child node to execute.
§Returns
  • A new retry node of type Leaf.
Source

pub fn retry_until_pass(node: &Tree) -> Tree

Creates a new retry node that executes a child node repeatedly until it succeeds.

§Arguments
  • node - The child node to execute.
§Returns
  • A new retry node of type Leaf.

Trait Implementations§

Source§

impl Clone for Tree

Source§

fn clone(&self) -> Tree

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Drop for Tree

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl IObject for Tree

Source§

fn raw(&self) -> i64

Source§

fn obj(&self) -> &dyn IObject

Source§

fn as_any(&self) -> &dyn Any

Source§

fn get_id(&self) -> i32

Auto Trait Implementations§

§

impl Freeze for Tree

§

impl RefUnwindSafe for Tree

§

impl Send for Tree

§

impl Sync for Tree

§

impl Unpin for Tree

§

impl UnwindSafe for Tree

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.