Package net.citizensnpcs.api.ai
Interface GoalController
- All Superinterfaces:
Iterable<GoalController.GoalEntry>
,Runnable
- All Known Implementing Classes:
SimpleGoalController
Represents a collection of goals that are prioritised and executed, allowing behaviour trees via a
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()
.-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addBehavior
(Behavior behavior, int priority) Registers aBehavior
with a given priority.void
Registers aGoal
with a given priority.void
Registers a goal which can reprioritise itself dynamically every tick.void
Cancels and resets the currently executing goal.void
clear()
Clears the goal controller of allGoal
s.boolean
boolean
isPaused()
void
removeBehavior
(Behavior behavior) Removes the givenBehavior
from rotation.void
removeGoal
(Goal goal) Removes aGoal
from rotation.void
setPaused
(boolean paused) Sets whether the controller is paused.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
addBehavior
Registers aBehavior
with a given priority.- Parameters:
behavior
- The behaviorpriority
- The priority- See Also:
-
addGoal
Registers aGoal
with a given priority. Priority must be greater than 0.- Parameters:
goal
- The goalpriority
- The goal priority
-
addPrioritisableGoal
Registers a goal which can reprioritise itself dynamically every tick. Implementation note: this may slow down individual goal controller ticks as the list must be sorted every tick.- Parameters:
goal
-
-
cancelCurrentExecution
void cancelCurrentExecution()Cancels and resets the currently executing goal. -
clear
void clear()Clears the goal controller of allGoal
s. Will stop the execution of any current goal. -
isExecutingGoal
boolean isExecutingGoal()- Returns:
- Whether a goal is currently being executed
-
isPaused
boolean isPaused()- Returns:
- Whether the controller is currently paused
- See Also:
-
removeBehavior
Removes the givenBehavior
from rotation.- Parameters:
behavior
- The behavior to remove
-
removeGoal
Removes aGoal
from rotation.- Parameters:
goal
- The goal to remove
-
setPaused
void setPaused(boolean paused) Sets whether the controller is paused. While paused, no newGoal
s will be selected and any executing goals will be suspended.- Parameters:
paused
- Whether to pause execution
-