Class ChaseTask

java.lang.Object
com.csse3200.game.ai.tasks.DefaultTask
com.csse3200.game.components.tasks.ChaseTask
All Implemented Interfaces:
PriorityTask, Task
Direct Known Subclasses:
AvoidTask, MazeChaseTask, PauseTask

public class ChaseTask extends DefaultTask implements PriorityTask
Chases a target entity until they get too far away or line of sight is lost
  • Field Details

    • target

      protected final Entity target
    • priority

      protected final int priority
    • viewDistance

      protected final float viewDistance
    • maxChaseDistance

      protected final float maxChaseDistance
    • physics

      protected final PhysicsEngine physics
    • debugRenderer

      protected final DebugRenderer debugRenderer
    • hit

      protected final RaycastHit hit
    • movementTask

      protected MovementTask movementTask
  • Constructor Details

    • ChaseTask

      public ChaseTask(Entity target, int priority, float viewDistance, float maxChaseDistance, com.badlogic.gdx.math.Vector2 speed, boolean isBoss)
      Parameters:
      target - The entity to chase.
      priority - Task priority when chasing (0 when not chasing).
      viewDistance - Maximum distance from the entity at which chasing can start.
      maxChaseDistance - Maximum distance from the entity while chasing before giving up.
  • Method Details

    • isBoss

      public boolean isBoss()
    • start

      public void start()
      Moves the entity in the direction of the entities target (often the player)
      Specified by:
      start in interface Task
      Overrides:
      start in class DefaultTask
    • update

      public void update()
      Updates the direction in which the entity needs to move in, checks every frame to see where the player is to determine this.
      Specified by:
      update in interface Task
      Overrides:
      update in class DefaultTask
    • getViewDistance

      public float getViewDistance()
    • stop

      public void stop()
      Description copied from interface: Task
      Stop the task immediately. This can be called at any time by the AI controller.
      Specified by:
      stop in interface Task
      Overrides:
      stop in class DefaultTask
    • getPriority

      public int getPriority()
      Specified by:
      getPriority in interface PriorityTask
    • getDistanceToTarget

      protected float getDistanceToTarget()
    • isTargetVisible

      protected boolean isTargetVisible()