E - type of the blackboard object that tasks use to read or modify game statepublic class BehaviorTree<E> extends Task<E>
| Modifier and Type | Class and Description |
|---|---|
static interface |
BehaviorTree.Listener<E>
The listener interface for receiving task events.
|
Task.Status| Modifier and Type | Field and Description |
|---|---|
Array<BehaviorTree.Listener<E>> |
listeners |
| Constructor and Description |
|---|
BehaviorTree()
Creates a
BehaviorTree with no root task and no blackboard object. |
BehaviorTree(Task<E> rootTask)
Creates a behavior tree with a root task and no blackboard object.
|
BehaviorTree(Task<E> rootTask,
E object)
Creates a behavior tree with a root task and a blackboard object.
|
| Modifier and Type | Method and Description |
|---|---|
protected int |
addChildToTask(Task<E> child)
This method will add a child, namely the root, to this behavior tree.
|
void |
addListener(BehaviorTree.Listener<E> listener) |
void |
childFail(Task<E> runningTask)
This method will be called when one of the children of this task fails.
|
void |
childRunning(Task<E> runningTask,
Task<E> reporter)
This method will be called when one of the ancestors of this task needs to run again.
|
void |
childSuccess(Task<E> runningTask)
This method will be called when one of the children of this task succeeds.
|
protected Task<E> |
copyTo(Task<E> task)
Copies this task to the given task.
|
Task<E> |
getChild(int i) |
int |
getChildCount() |
E |
getEntity()
Returns the blackboard object of this behavior tree.
|
void |
notifyChildAdded(Task<E> task,
int index) |
void |
notifyStatusUpdated(Task<E> task,
Task.Status previousStatus) |
void |
removeListener(BehaviorTree.Listener<E> listener) |
void |
removeListeners() |
void |
reset()
Resets this task to make it restart from scratch on next run.
|
void |
run()
This method contains the update logic of this task.
|
void |
setEntity(E object)
Sets the blackboard object of this behavior tree.
|
void |
step()
This method should be called when game entity needs to make decisions: call this in game loop or after a fixed time slice if
the game is real-time, or on entity's turn if the game is turn-based
|
addChild, cancel, cancelRunningChildren, checkGuard, cloneTask, end, fail, getGuard, getStatus, running, setControl, setGuard, start, successpublic Array<BehaviorTree.Listener<E>> listeners
public BehaviorTree()
BehaviorTree with no root task and no blackboard object. Both the root task and the blackboard object must
be set before running this behavior tree, see addChild() and setObject()
respectively.public BehaviorTree(Task<E> rootTask)
addChild() and setObject()
respectively.rootTask - the root task of this tree. It can be null.public BehaviorTree(Task<E> rootTask, E object)
addChild() and setObject()
respectively.rootTask - the root task of this tree. It can be null.object - the blackboard. It can be null.public E getEntity()
public void setEntity(E object)
object - the new blackboardprotected int addChildToTask(Task<E> child)
addChildToTask in class Task<E>child - the root task to addIllegalStateException - if the root task is already set.public int getChildCount()
getChildCount in class Task<E>public void childRunning(Task<E> runningTask, Task<E> reporter)
TaskchildRunning in class Task<E>runningTask - the task that needs to run againreporter - the task that reports, usually one of this task's childrenpublic void childFail(Task<E> runningTask)
Taskpublic void childSuccess(Task<E> runningTask)
TaskchildSuccess in class Task<E>runningTask - the task that succeededpublic void step()
public void run()
TaskTask.running(),
Task.success() or Task.fail() exactly once.public void reset()
Taskprotected Task<E> copyTo(Task<E> task)
Taskpublic void addListener(BehaviorTree.Listener<E> listener)
public void removeListener(BehaviorTree.Listener<E> listener)
public void removeListeners()
public void notifyStatusUpdated(Task<E> task, Task.Status previousStatus)
Copyright © 2017. All rights reserved.