Package net.citizensnpcs.api.ai
Class SimpleGoalController
java.lang.Object
net.citizensnpcs.api.ai.SimpleGoalController
- All Implemented Interfaces:
Iterable<GoalController.GoalEntry>,Runnable,GoalController
A simple
GoalController implementation that stores goals as a ArrayList. It works with both
Behavior, Goal and will also consider PrioritisableGoals if implemented.-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface net.citizensnpcs.api.ai.GoalController
GoalController.GoalEntry -
Constructor Summary
Constructors -
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()iterator()voidremoveBehavior(Behavior behavior) Removes the givenBehaviorfrom rotation.voidremoveGoal(Goal goal) Removes aGoalfrom rotation.voidrun()voidsetPaused(boolean paused) Sets whether the controller is paused.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
SimpleGoalController
public SimpleGoalController()
-
-
Method Details
-
addBehavior
Description copied from interface:GoalControllerRegisters aBehaviorwith a given priority.- Specified by:
addBehaviorin interfaceGoalController- Parameters:
behavior- The behaviorpriority- The priority- See Also:
-
addGoal
Description copied from interface:GoalControllerRegisters aGoalwith a given priority. Priority must be greater than 0.- Specified by:
addGoalin interfaceGoalController- Parameters:
goal- The goalpriority- The goal priority
-
addPrioritisableGoal
Description copied from interface:GoalControllerRegisters 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.- Specified by:
addPrioritisableGoalin interfaceGoalController- Parameters:
goal-
-
cancelCurrentExecution
public void cancelCurrentExecution()Description copied from interface:GoalControllerCancels and resets the currently executing goal.- Specified by:
cancelCurrentExecutionin interfaceGoalController
-
clear
public void clear()Description copied from interface:GoalControllerClears the goal controller of allGoals. Will stop the execution of any current goal.- Specified by:
clearin interfaceGoalController
-
isExecutingGoal
public boolean isExecutingGoal()- Specified by:
isExecutingGoalin interfaceGoalController- Returns:
- Whether a goal is currently being executed
-
isPaused
public boolean isPaused()- Specified by:
isPausedin interfaceGoalController- Returns:
- Whether the controller is currently paused
- See Also:
-
iterator
- Specified by:
iteratorin interfaceIterable<GoalController.GoalEntry>
-
removeBehavior
Description copied from interface:GoalControllerRemoves the givenBehaviorfrom rotation.- Specified by:
removeBehaviorin interfaceGoalController- Parameters:
behavior- The behavior to remove
-
removeGoal
Description copied from interface:GoalControllerRemoves aGoalfrom rotation.- Specified by:
removeGoalin interfaceGoalController- Parameters:
goal- The goal to remove
-
run
public void run() -
setPaused
public void setPaused(boolean paused) Description copied from interface:GoalControllerSets whether the controller is paused. While paused, no newGoals will be selected and any executing goals will be suspended.- Specified by:
setPausedin interfaceGoalController- Parameters:
paused- Whether to pause execution
-