Class BombPatrolTask

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

public class BombPatrolTask extends DefaultTask implements PriorityTask
Task that makes an entity move through a sequence of waypoints, pausing briefly at each. The entity patrols back and forth along its route, reversing direction when it reaches the end, and repeats this indefinitely. Requires the entity to have a PatrolRouteComponent which defines the set of waypoints to follow. Note: This task only controls behaviour during the patrol itself. Resetting the entity back to its starting waypoint (e.g. after switching from chase mode back to patrol) is handled separately by a cooldown task. For full patrol-chase-cooldown cycles, both tasks should be added to the entity's AITaskComponent.
  • Constructor Details

    • BombPatrolTask

      public BombPatrolTask(float waitTime)
      Creates a patrol starting from a fixed start position.
      Parameters:
      waitTime - specifies how long to wait at each waypoint before moving to the next.
  • Method Details

    • getPriority

      public int getPriority()
      Return a low priority of 1.
      Specified by:
      getPriority in interface PriorityTask
    • start

      public void start()
      Set up subtasks (wait, movement) and begin moving toward first waypoint.
      Specified by:
      start in interface Task
      Overrides:
      start in class DefaultTask
    • update

      public void update()
      Advance the patrol state. Handles swapping between wait and movement tasks based on their status.
      Specified by:
      update in interface Task
      Overrides:
      update in class DefaultTask
    • stop

      public void stop()
      Stop the patrol task and its current subtask
      Specified by:
      stop in interface Task
      Overrides:
      stop in class DefaultTask
    • isWaiting

      public boolean isWaiting()
      Check if waiting.
      Returns:
      true if currentTask is waitTask
    • isMoving

      public boolean isMoving()
      Check if moving.
      Returns:
      true if currentTask is movementTask
    • getIndex

      public int getIndex()
      Get the current index pointing to a waypoint.
      Returns:
      int current index
    • isMovingForward

      public boolean isMovingForward()
      Check patrol direction.
      Returns:
      true for forward, otherwise false
    • getTargetWaypoint

      public com.badlogic.gdx.math.Vector2 getTargetWaypoint()
      Get the waypoint of current index
      Returns:
      target waypoint