public class SimpleGoalController extends Object implements GoalController
GoalController
implementation that stores goals as a ArrayList
. It works with both
Behavior
, Goal
and will also consider PrioritisableGoal
s if implemented.Modifier and Type | Class and Description |
---|---|
class |
SimpleGoalController.SimpleGoalSelector |
GoalController.GoalEntry
Constructor and Description |
---|
SimpleGoalController() |
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() |
Iterator<GoalController.GoalEntry> |
iterator() |
void |
removeBehavior(Behavior behavior)
Removes the given
Behavior from rotation. |
void |
removeGoal(Goal goal)
Removes a
Goal from rotation. |
void |
run() |
void |
setPaused(boolean paused)
Sets whether the controller is paused.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public void addBehavior(Behavior behavior, int priority)
GoalController
Behavior
with a given priority.addBehavior
in interface GoalController
behavior
- The behaviorpriority
- The priorityGoalController.addGoal(Goal, int)
public void addGoal(Goal goal, int priority)
GoalController
Goal
with a given priority. Priority must be greater than 0.addGoal
in interface GoalController
goal
- The goalpriority
- The goal prioritypublic void addPrioritisableGoal(PrioritisableGoal goal)
GoalController
addPrioritisableGoal
in interface GoalController
public void cancelCurrentExecution()
GoalController
cancelCurrentExecution
in interface GoalController
public void clear()
GoalController
Goal
s. Will stop the execution of any current goal.clear
in interface GoalController
public boolean isExecutingGoal()
isExecutingGoal
in interface GoalController
public boolean isPaused()
isPaused
in interface GoalController
GoalController.setPaused(boolean)
public Iterator<GoalController.GoalEntry> iterator()
iterator
in interface Iterable<GoalController.GoalEntry>
public void removeBehavior(Behavior behavior)
GoalController
Behavior
from rotation.removeBehavior
in interface GoalController
behavior
- The behavior to removepublic void removeGoal(Goal goal)
GoalController
Goal
from rotation.removeGoal
in interface GoalController
goal
- The goal to removepublic void setPaused(boolean paused)
GoalController
Goal
s will be selected and any executing
goals will be suspended.setPaused
in interface GoalController
paused
- Whether to pause executionCopyright © 2021. All rights reserved.