Crate beehave [] [src]

A simple library for defining and evaluating behaviour trees on an actor.

Building A Behaviour Tree

let world_behaviour: Selector<World> = behaviour_selector!("World Root", [
      condition_decorator!("Ensure Can Shine",
          |world: &mut World| {
              world.can_shine()
          },
          action!("Cycle Day/Night", |world: &mut World| {
              world.toggle_sun()
          })
      ),
      condition_decorator!("Ensure Can Rain",
          |world: &mut World| {
              world.can_rain()
          },
          action!("Rain", |world: &mut World| {
              world.rain()
          })
      )
  ]);

Evaluating A Behaviour Tree

world_behaviour.evaluate(&mut world);

Macros

action
behaviour_selector
behaviour_sequence
condition
condition_decorator
node

Structs

Action

A simple callback function performed on the actor.

Conditional

A simple action performed on the actor.

ConditionalDecorator

A decorator which only evaluates the child node if the callback function returns true.

Node

A simple callback function performed on the actor.

Selector

A composite node which stops evaluating it's children and returns BehaviourResult::Success when a child returns BehaviourResult::Success.

Sequence

A composite node which stops evaluating it's children and returns BehaviourResult::Failure when a child returns BehaviourResult::Failure.

Enums

BehaviourResult

The result from a BehaviourNode evaluating an actor.

Traits

BehaviourNode

A type which is used to represent a node on the behaviour tree.