public interface GoalController extends Runnable, Iterable<GoalController.GoalEntry>
GoalSelector
or by implementing Behavior
.
In general, using Behavior
is preferred due to mapping more closely to traditional behavior trees.
The highest priority Goal
that returns true in Goal.shouldExecute(GoalSelector)
is executed. Any
existing goals with a lower priority are replaced via Goal.reset()
.Modifier and Type | Interface and Description |
---|---|
static interface |
GoalController.GoalEntry |
Modifier and Type | Method and Description |
---|---|
void |
addBehavior(Behavior behavior,
int priority)
Registers a
Behavior with a given priority. |
void |
addGoal(Goal goal,
int priority)
Registers a
Goal with a given priority. |
void |
addPrioritisableGoal(PrioritisableGoal goal)
Registers a goal which can reprioritise itself dynamically every tick.
|
void |
cancelCurrentExecution()
Cancels and resets the currently executing goal.
|
void |
clear()
Clears the goal controller of all
Goal s. |
boolean |
isExecutingGoal() |
boolean |
isPaused() |
void |
removeBehavior(Behavior behavior)
Removes the given
Behavior from rotation. |
void |
removeGoal(Goal goal)
Removes a
Goal from rotation. |
void |
setPaused(boolean paused)
Sets whether the controller is paused.
|
forEach, iterator, spliterator
void addBehavior(Behavior behavior, int priority)
Behavior
with a given priority.behavior
- The behaviorpriority
- The priorityaddGoal(Goal, int)
void addGoal(Goal goal, int priority)
Goal
with a given priority. Priority must be greater than 0.priority
- The goal prioritygoal
- The goalvoid addPrioritisableGoal(PrioritisableGoal goal)
goal
- void cancelCurrentExecution()
void clear()
Goal
s. Will stop the execution of any current goal.boolean isExecutingGoal()
boolean isPaused()
setPaused(boolean)
void removeBehavior(Behavior behavior)
Behavior
from rotation.behavior
- The behavior to removevoid removeGoal(Goal goal)
Goal
from rotation.goal
- The goal to removevoid setPaused(boolean paused)
Goal
s will be selected and any executing
goals will be suspended.paused
- Whether to pause executionCopyright © 2021. All rights reserved.