Class TaskManager

java.lang.Object
net.glowstone.entity.ai.TaskManager

public class TaskManager extends Object
  • Constructor Details

  • Method Details

    • getTask

      public EntityTask getTask(String name)
      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

      public EntityTask 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).
      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

      public EntityTask getNewTask(String name)
      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

      public void cancel(EntityTask task)
      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

      public void addTask(EntityTask task)
      Add the given task, replacing any existing task with the same name.
      Parameters:
      task - the task to add
    • addTask

      public void addTask(String taskName)
      Add the task with this name, or replace it with a new instance if it already exists.
      Parameters:
      taskName - the task name