Class ChaseTask

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

public class ChaseTask extends DefaultTask implements PriorityTask
Event-activated chase behaviour. This task is made eligible for scheduling via external calls to activate() (e.g. 'enemyActivated' in EnemyFactory). The entity chases the target until either: - The target is farther than maxChaseDistance - Line of sight is broken for more than LOS_GRACE_MS after initial sighting To prevent the task from finishing immediately if the entity starts far away/out of LOS, these end conditions are only applicable after an initial active grace period ends. Re-activate chase via new calls to activate() only.
  • 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
    ChaseTask(Entity target, float maxChaseDistance, float activeGracePeriod)
    Creates a new chase task that will pursue the given target entity
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Activate the chase task, making it eligible for scheduling.
    void
    Deactivate the chase task, preventing it from being scheduled.
    int
    Get the current priority of the task.
    void
    Initialise and start movement towards target.
    void
    Stop the chase behaviour and movement subtask.
    void
    Update the chase behaviour each frame.

    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

    • ChaseTask

      public ChaseTask(Entity target, float maxChaseDistance, float activeGracePeriod)
      Creates a new chase task that will pursue the given target entity
      Parameters:
      target - entity to chase
      maxChaseDistance - threshold where chase ends
      activeGracePeriod - time in seconds that entity chases before end conditions apply
  • Method Details

    • activate

      public void activate()
      Activate the chase task, making it eligible for scheduling. Called by external systems (e.g. 'enemyActivated' in response to security camera)
    • deactivate

      public void deactivate()
      Deactivate the chase task, preventing it from being scheduled.
    • start

      public void start()
      Initialise and start movement towards target.
      Specified by:
      start in interface Task
      Overrides:
      start in class DefaultTask
    • update

      public void update()
      Update the chase behaviour each frame.
      Specified by:
      update in interface Task
      Overrides:
      update in class DefaultTask
    • stop

      public void stop()
      Stop the chase behaviour and movement subtask.
      Specified by:
      stop in interface Task
      Overrides:
      stop in class DefaultTask
    • getPriority

      public int getPriority()
      Get the current priority of the task. Enables task handover if end conditions are met.
      Specified by:
      getPriority in interface PriorityTask
      Returns:
      -1 if inactive or end conditions are met. Otherwise, 10 while active.