Package net.glowstone.entity.ai
Class TaskManager
java.lang.Object
net.glowstone.entity.ai.TaskManager
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add the task with this name, or replace it with a new instance if it already exists.void
addTask
(EntityTask task) Add the given task, replacing any existing task with the same name.void
cancel
(EntityTask task) Cancels and unregisters the given task.void
Cancels and unregisters all tasks.getNewTask
(String name) Returns a new instance of the task with a given name.getTask
(Class<? extends EntityTask> clazz) Returns the existing task whose class is exactly a given class (and not a subclass -- this will always return null for an abstract type).Returns the existing task with a given name.void
pulse()
void
Rebuild the list of tasks according to(EntityType, MobState)
.
-
Constructor Details
-
TaskManager
-
-
Method Details
-
getTask
Returns the existing task with a given name.- Parameters:
name
- the name to look up- Returns:
- the task with that name, or null if no registered task matches
-
getTask
Returns the existing task whose class is exactly a given class (and not a subclass -- this will always return null for an abstract type).- Parameters:
clazz
- the class to look up- Returns:
- one of this manager's tasks that's an instance of that class and not a subclass, or null if no such tasks are registered
-
getNewTask
Returns a new instance of the task with a given name.- Parameters:
name
- the task name to look up- Returns:
- a task with the given name, or null if none match or the matching task class doesn't have a parameterless constructor
-
updateState
public void updateState()Rebuild the list of tasks according to(EntityType, MobState)
. -
cancel
Cancels and unregisters the given task.- Parameters:
task
- the task to cancel
-
cancelTasks
public void cancelTasks()Cancels and unregisters all tasks. -
pulse
public void pulse() -
addTask
Add the given task, replacing any existing task with the same name.- Parameters:
task
- the task to add
-
addTask
Add the task with this name, or replace it with a new instance if it already exists.- Parameters:
taskName
- the task name
-