Class DefaultTask

java.lang.Object
com.deco2800.game.ai.tasks.DefaultTask
All Implemented Interfaces:
Task
Direct Known Subclasses:
ChaseTask, MovementTask, ObstacleAttackTask, WaitTask, WanderTask

public abstract class DefaultTask
extends java.lang.Object
implements Task
A default task implementation that stores the associated entity and updates status when starting/stopping a task. Removes some boilerplate code from each task.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface com.deco2800.game.ai.tasks.Task

    Task.Status
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected TaskRunner owner  
    protected Task.Status status  
  • Constructor Summary

    Constructors 
    Constructor Description
    DefaultTask()  
  • Method Summary

    Modifier and Type Method Description
    void create​(TaskRunner taskRunner)
    Create the task and attach it to the task runner.
    Task.Status getStatus()
    Get the current status of the task.
    void start()
    Start running this task.
    void stop()
    Stop the task immediately.
    void update()
    Run one frame of the task.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • create

      public void create​(TaskRunner taskRunner)
      Description copied from interface: Task
      Create the task and attach it to the task runner.
      Specified by:
      create in interface Task
      Parameters:
      taskRunner - Task runner to attach to
    • start

      public void start()
      Description copied from interface: Task
      Start running this task. This will usually be called by an AI controller.
      Specified by:
      start in interface Task
    • update

      public void update()
      Description copied from interface: Task
      Run one frame of the task. Similar to the update() in Components.
      Specified by:
      update in interface Task
    • stop

      public void stop()
      Description copied from interface: Task
      Stop the task immediately. This can be called at any time by the AI controller.
      Specified by:
      stop in interface Task
    • getStatus

      public Task.Status getStatus()
      Description copied from interface: Task
      Get the current status of the task.
      Specified by:
      getStatus in interface Task
      Returns:
      status