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 PrioritisableGoal
s if implemented.-
Nested Class Summary
Nested classes/interfaces inherited from interface net.citizensnpcs.api.ai.GoalController
GoalController.GoalEntry
-
Constructor 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()
iterator()
void
removeBehavior
(Behavior behavior) Removes the givenBehavior
from rotation.void
removeGoal
(Goal goal) Removes aGoal
from rotation.void
run()
void
setPaused
(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, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
SimpleGoalController
public SimpleGoalController()
-
-
Method Details
-
addBehavior
Description copied from interface:GoalController
Registers aBehavior
with a given priority.- Specified by:
addBehavior
in interfaceGoalController
- Parameters:
behavior
- The behaviorpriority
- The priority- See Also:
-
addGoal
Description copied from interface:GoalController
Registers aGoal
with a given priority. Priority must be greater than 0.- Specified by:
addGoal
in interfaceGoalController
- Parameters:
goal
- The goalpriority
- The goal priority
-
addPrioritisableGoal
Description copied from interface:GoalController
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.- Specified by:
addPrioritisableGoal
in interfaceGoalController
- Parameters:
goal
-
-
cancelCurrentExecution
public void cancelCurrentExecution()Description copied from interface:GoalController
Cancels and resets the currently executing goal.- Specified by:
cancelCurrentExecution
in interfaceGoalController
-
clear
public void clear()Description copied from interface:GoalController
Clears the goal controller of allGoal
s. Will stop the execution of any current goal.- Specified by:
clear
in interfaceGoalController
-
isExecutingGoal
public boolean isExecutingGoal()- Specified by:
isExecutingGoal
in interfaceGoalController
- Returns:
- Whether a goal is currently being executed
-
isPaused
public boolean isPaused()- Specified by:
isPaused
in interfaceGoalController
- Returns:
- Whether the controller is currently paused
- See Also:
-
iterator
- Specified by:
iterator
in interfaceIterable<GoalController.GoalEntry>
-
removeBehavior
Description copied from interface:GoalController
Removes the givenBehavior
from rotation.- Specified by:
removeBehavior
in interfaceGoalController
- Parameters:
behavior
- The behavior to remove
-
removeGoal
Description copied from interface:GoalController
Removes aGoal
from rotation.- Specified by:
removeGoal
in interfaceGoalController
- Parameters:
goal
- The goal to remove
-
run
public void run() -
setPaused
public void setPaused(boolean paused) Description copied from interface:GoalController
Sets whether the controller is paused. While paused, no newGoal
s will be selected and any executing goals will be suspended.- Specified by:
setPaused
in interfaceGoalController
- Parameters:
paused
- Whether to pause execution
-