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
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBehavior(Behavior behavior, int priority) Registers aBehaviorwith a given priority.voidRegisters aGoalwith a given priority.voidRegisters a goal which can reprioritise itself dynamically every tick.voidCancels and resets the currently executing goal.voidclear()Clears the goal controller of allGoals.booleanbooleanisPaused()voidremoveBehavior(Behavior behavior) Removes the givenBehaviorfrom rotation.voidremoveGoal(Goal goal) Removes aGoalfrom rotation.voidsetPaused(boolean paused) Sets whether the controller is paused.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
addBehavior
Registers aBehaviorwith a given priority.- Parameters:
behavior- The behaviorpriority- The priority- See Also:
-
addGoal
Registers aGoalwith 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 allGoals. 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 givenBehaviorfrom rotation.- Parameters:
behavior- The behavior to remove
-
removeGoal
Removes aGoalfrom rotation.- Parameters:
goal- The goal to remove
-
setPaused
void setPaused(boolean paused) Sets whether the controller is paused. While paused, no newGoals will be selected and any executing goals will be suspended.- Parameters:
paused- Whether to pause execution
-