-
Notifications
You must be signed in to change notification settings - Fork 18
High Level Overview
Here you can find an overview of some of the inner workings of the Behavior system.
The Actor is a decorated Entity, a class that facilitates adds Behavior related functionality to a given Entity.
Important parts of the Actor class:
-
Actor(EntityRef)
constructor - an Actor can only be constructed over a given Entity -
getEntity()
- returns the underlying entity -
getComponent()
,getComponentField()
,hasComponent()
- QoL methods providing easier access to some parts of the underlying entity
and the following:
dataMap
, getValue()
, setValue()
- Data map functionality: every Behavior Node manipulates its stateful information through these methods, so the Nodes themselves can be stateless / reusable. the
id
arguments are the tree-unique IDs of the Nodes.
blackboard
, readFromBlackboard()
, writeToBlackboard()
- Blackboard functionality - the Blackboard is there to facilitate inter-node communication: while in
dataMap
every node has its own little corner where it stores its info,blackboard
is the shared space where nodes can co-ordinate any higher level stateful goals.
Behavior trees are composed of objects implementing the TreeNode
interface. There are composite nodes, action nodes and decorators, but in an effort not to duplicate information too much, here's a link to the part of the wiki that explains the TreeNode
s in detail.
The system is as follows: every Actor
instance (entity with a behavior) has an associated Interpreter
. That interpreter uses a BehaviorTreeRunner
(currently DefaultBehaviorTreeRunner
as we aren't using the bytecode/ASM parts of the system) to work on the given tree - there is a BehaviorTreeRunner
for every given Actor.
What's important is the BehaviorTree
is a data class; it provides the underlying tree data, but it's shared between Actors, using the Intepreter/BehaviorTreeRunner combo.