Class PanicTask

All Implemented Interfaces:
PriorityTask, Task

public class PanicTask extends TimedTask implements PriorityTask
A panic task that causes the owner's entity to move randomly within a specified range for a certain duration. The task is triggered by an event and has a priority that determines its execution order.
  • 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
    PanicTask(String trigger, float duration, int priority, com.badlogic.gdx.math.Vector2 panicRange, com.badlogic.gdx.math.Vector2 panicSpeed)
    Constructs a PanicTask with the specified parameters.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    create(TaskRunner taskRunner)
    When task is created, attach event listener to task owner.
    void
    Starts the panic task by initializing the movement task and triggering the "runStart" event.
    void
    Stops the panic task and the associated movement task.
    void
    Sets the priority of the task to the active priority when triggered by an event.
    void
    Updates the panic task by checking if movement has finished, and if so, restarting the movement task.

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

    getPriority

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

    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.PriorityTask

    getPriority

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

    getStatus
  • Constructor Details

    • PanicTask

      public PanicTask(String trigger, float duration, int priority, com.badlogic.gdx.math.Vector2 panicRange, com.badlogic.gdx.math.Vector2 panicSpeed)
      Constructs a PanicTask with the specified parameters.
      Parameters:
      trigger - The event trigger that activates this task.
      duration - The duration for which the panic behavior will occur.
      priority - The priority of the panic task.
      panicRange - The range within which the entity will move randomly.
      panicSpeed - The speed at which the entity will move during panic.
  • Method Details

    • create

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

      public void start()
      Starts the panic task by initializing the movement task and triggering the "runStart" event.
      Specified by:
      start in interface Task
      Overrides:
      start in class DefaultTask
    • triggerActivePriority

      public void triggerActivePriority()
      Description copied from class: TimedTask
      Sets the priority of the task to the active priority when triggered by an event.
      Overrides:
      triggerActivePriority in class TimedTask
    • update

      public void update()
      Updates the panic task by checking if movement has finished, and if so, restarting the movement task.
      Specified by:
      update in interface Task
      Overrides:
      update in class TimedTask
    • stop

      public void stop()
      Stops the panic task and the associated movement task.
      Specified by:
      stop in interface Task
      Overrides:
      stop in class TimedTask