Class RunAwayTask

All Implemented Interfaces:
PriorityTask, Task

public class RunAwayTask extends ChaseTask
Runs from a target entity until they get too far away or line of sight is lost
  • 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
    RunAwayTask(Entity target, int priority, float viewDistance, float maxRunDistance, com.badlogic.gdx.math.Vector2 runSpeed)
     
    RunAwayTask(Entity target, int priority, float viewDistance, float maxRunDistance, com.badlogic.gdx.math.Vector2 runSpeed, boolean checkVisibility)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected int
    Determines the priority when the RunAwayTask is active based on the distance to the target and the visibility of the target entity and whether the animal is tamed.
    protected int
    Determines the priority when the RunAwayTask is inactive based on the distance to the target and the visibility of the target entity and whether the animal is tamed.
    void
    Starts the chase task by initializing the movement task and triggering the run events.
    void
    Stops the RunAwayTask and the associated movement task, and triggers the "runAwayStop" event.
    void
    Updates the RunAwayTask by updating the movement task and restarting it if necessary.

    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

    • RunAwayTask

      public RunAwayTask(Entity target, int priority, float viewDistance, float maxRunDistance, com.badlogic.gdx.math.Vector2 runSpeed)
      Parameters:
      target - The entity to run from.
      priority - Task priority when running (0 when not running away).
      viewDistance - Maximum distance from the entity at which running away can start.
      maxRunDistance - Maximum distance from the entity before stopping.
    • RunAwayTask

      public RunAwayTask(Entity target, int priority, float viewDistance, float maxRunDistance, com.badlogic.gdx.math.Vector2 runSpeed, boolean checkVisibility)
      Parameters:
      target - The entity to run from.
      priority - Task priority when running (0 when not running away).
      viewDistance - Maximum distance from the entity at which running away can start.
      maxRunDistance - Maximum distance from the entity before stopping.
      checkVisibility - Whether to consider visability when running away.
  • Method Details

    • start

      public void start()
      Starts the chase task by initializing the movement task and triggering the run events.
      Specified by:
      start in interface Task
      Overrides:
      start in class ChaseTask
    • update

      public void update()
      Updates the RunAwayTask by updating the movement task and restarting it if necessary.
      Specified by:
      update in interface Task
      Overrides:
      update in class ChaseTask
    • stop

      public void stop()
      Stops the RunAwayTask and the associated movement task, and triggers the "runAwayStop" event.
      Specified by:
      stop in interface Task
      Overrides:
      stop in class ChaseTask
    • getActivePriority

      protected int getActivePriority()
      Determines the priority when the RunAwayTask is active based on the distance to the target and the visibility of the target entity and whether the animal is tamed.
      Overrides:
      getActivePriority in class ChaseTask
      Returns:
      The active priority level or -1 if conditions are not met.
    • getInactivePriority

      protected int getInactivePriority()
      Determines the priority when the RunAwayTask is inactive based on the distance to the target and the visibility of the target entity and whether the animal is tamed.
      Overrides:
      getInactivePriority in class ChaseTask
      Returns:
      The inactive priority level or -1 if conditions are not met.