Class AvoidTask

All Implemented Interfaces:
PriorityTask, Task

public class AvoidTask extends ChaseTask
Moves away from a target entity until a safe distance is reached or line of sight is lost
  • Constructor Details

    • AvoidTask

      public AvoidTask(Entity target, int priority, float safeDistance, float minAvoidDistance, boolean isBoss)
      Initialises the avoid task.
      Parameters:
      target - The entity to avoid.
      priority - Task priority when avoiding (0 when not avoiding).
      safeDistance - Minimum distance to maintain from the target.
      minAvoidDistance - Minimum distance to avoid moving away from the target.
  • Method Details

    • start

      public void start()
      Starts the avoidance behavior by initializing and starting the movement task. Triggers the "avoidStart" event to indicate the beginning of avoidance.
      Specified by:
      start in interface Task
      Overrides:
      start in class ChaseTask
    • update

      public void update()
      Updates the avoidance behavior by setting the current target for the movement task and updating its state. If the movement task is not active, it restarts the task.
      Specified by:
      update in interface Task
      Overrides:
      update in class ChaseTask
    • getPriority

      public int getPriority()
      Returns the priority level of the avoidance behavior. Determines the priority based on whether the task is currently active or inactive.
      Specified by:
      getPriority in interface PriorityTask
      Overrides:
      getPriority in class ChaseTask
      Returns:
      the priority level of the avoidance behavior.