Class TimedTask

java.lang.Object
com.csse3200.game.ai.tasks.DefaultTask
com.csse3200.game.ai.tasks.TimedTask
All Implemented Interfaces:
PriorityTask, Task
Direct Known Subclasses:
PanicTask

public class TimedTask extends DefaultTask implements PriorityTask
A task that runs for a set amount of time (depending on priority). This task must be triggered by an event. The task will run unless overridden by a task with higher priority.
  • Constructor Details

    • TimedTask

      public TimedTask(String trigger, float duration, int priority)
      Constructs a TimedTask with specified parameters.
      Parameters:
      trigger - The event trigger that activates this task.
      duration - The duration for which this task will run.
      priority - The initial priority of the task.
  • Method Details

    • create

      public void create(TaskRunner taskRunner)
      When task is created, attach event listener to task owner.
      Specified by:
      create in interface Task
      Overrides:
      create in class DefaultTask
      Parameters:
      taskRunner - Task runner to attach to
    • triggerActivePriority

      public void triggerActivePriority()
      Sets the priority of the task to the active priority when triggered by an event.
    • update

      public void update()
      Increment running time every update.
      Specified by:
      update in interface Task
      Overrides:
      update in class DefaultTask
    • stop

      public void stop()
      Stops task and sets back to inactive priority.
      Specified by:
      stop in interface Task
      Overrides:
      stop in class DefaultTask
    • getPriority

      public int getPriority()
      Return priority
      Specified by:
      getPriority in interface PriorityTask
      Returns:
      priority