Class PatrolRouteComponent

java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.enemy.PatrolRouteComponent

public class PatrolRouteComponent extends Component
A component that stores the patrol route for an enemy entity, which is represented as an ordered list of waypoints. This component should be added to any entity that is expected to perform patrol behaviour (via PatrolTask) so the route can be queried.
  • Constructor Details

    • PatrolRouteComponent

      public PatrolRouteComponent(com.badlogic.gdx.math.Vector2[] waypoints)
      Create a new PatrolRouteComponent with the supplied waypoints.
      Parameters:
      waypoints - an array of world positions defining the patrol route
  • Method Details

    • numWaypoints

      public int numWaypoints()
      Get number of waypoints in patrol route
      Returns:
      number of waypoints in the patrol
    • patrolStart

      public com.badlogic.gdx.math.Vector2 patrolStart()
      Get the first waypoint of the patrol route
      Returns:
      first waypoint of the patrol
    • getWaypointAt

      public com.badlogic.gdx.math.Vector2 getWaypointAt(int i)
      Get the waypoint at a given index
      Parameters:
      i - Index of desired waypoint
      Returns:
      Vector2 corresponding to waypoint at the index
      Throws:
      IndexOutOfBoundsException - if index outside bounds of waypoints
    • getWaypoints

      public com.badlogic.gdx.math.Vector2[] getWaypoints()
      Get an array of cumulative waypoints built from the patrol steps.
      Returns:
      an array of waypoints or null
      Throws:
      IllegalStateException - if waypoints not initialised