Class CooldownTask

java.lang.Object
com.csse3200.game.ai.tasks.DefaultTask
com.csse3200.game.components.tasks.CooldownTask
All Implemented Interfaces:
PriorityTask, Task

public class CooldownTask extends DefaultTask implements PriorityTask
A cooldown task that activates after a chase has ended. When activated, the entity remains idle for a set cooldown duration, then teleports back to either: - The start of its patrol route (if one exists) - Its original spawn position (if no patrol route exists) This ensures drones reset to their initial state instead of beelining back manually.
  • Nested Class Summary

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

    Task.Status
  • Field Summary

    Fields inherited from class com.csse3200.game.ai.tasks.DefaultTask

    owner, status
  • Constructor Summary

    Constructors
    Constructor
    Description
    CooldownTask(float waitTime)
    Creates a cooldown task with the given wait duration.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Activates the cooldown task.
    void
    Deactivate the cooldown task, preventing it from being scheduled.
    int
    Returns the priority of this task.
    void
    Starts the cooldown.
    void
    When the cooldown task is stopped, gravity is restored and a 'cooldownEnd' event is triggered.
    void
    Advance wait task.

    Methods inherited from class com.csse3200.game.ai.tasks.DefaultTask

    create, getStatus

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.csse3200.game.ai.tasks.Task

    create, getStatus
  • Constructor Details

    • CooldownTask

      public CooldownTask(float waitTime)
      Creates a cooldown task with the given wait duration.
      Parameters:
      waitTime - duration (in seconds) to wait before teleporting the entity back to its original position
  • Method Details

    • activate

      public void activate()
      Activates the cooldown task. Typically triggered by a "playerLost" event.
    • deactivate

      public void deactivate()
      Deactivate the cooldown task, preventing it from being scheduled. Typically called in response to a `playerDetected` event.
    • start

      public void start()
      Starts the cooldown. Starts a wait subtask, disables gravity, and triggers a "cooldownStart" event for animations TO BE ADDED.
      Specified by:
      start in interface Task
      Overrides:
      start in class DefaultTask
    • update

      public void update()
      Advance wait task. Once the cooldown wait has elapsed, the entity is teleported back to its patrol start or spawn position the cooldown task is stopped. Calls deactivate() to stop task being runnable.
      Specified by:
      update in interface Task
      Overrides:
      update in class DefaultTask
    • getPriority

      public int getPriority()
      Returns the priority of this task. The cooldown is only considered runnable while active is true.
      Specified by:
      getPriority in interface PriorityTask
      Returns:
      priority 5 when active, otherwise -1 (disabled)
    • stop

      public void stop()
      When the cooldown task is stopped, gravity is restored and a 'cooldownEnd' event is triggered.
      Specified by:
      stop in interface Task
      Overrides:
      stop in class DefaultTask