Class TargetDetectionTasks

java.lang.Object
com.csse3200.game.ai.tasks.DefaultTask
com.csse3200.game.components.tasks.TargetDetectionTasks
All Implemented Interfaces:
PriorityTask, Task
Direct Known Subclasses:
AttackTask, IdleTask

public abstract class TargetDetectionTasks extends DefaultTask implements PriorityTask
  • Field Details

    • attackRange

      protected final float attackRange
    • physics

      protected final PhysicsEngine physics
    • debugRenderer

      protected final DebugRenderer debugRenderer
    • hit

      protected final RaycastHit hit
  • Constructor Details

    • TargetDetectionTasks

      protected TargetDetectionTasks(float attackRange)
  • Method Details

    • getDistanceToTarget

      protected float getDistanceToTarget()
      Gets the distance to the nearest visible target
      Returns:
      the distance to the nearest target or a MAX VALUE if there is no target
    • getActivePriority

      protected abstract int getActivePriority(float distance, Entity target)
      Gets the priority when the task is active.
      Parameters:
      distance - the distance to the target
      target - the target entity
      Returns:
      the priority value
    • getInactivePriority

      protected abstract int getInactivePriority(float distance, Entity target)
      Gets the priority when the task is inactive.
      Parameters:
      distance - the distance to the target
      target - the target entity
      Returns:
      the priority value
    • getPriority

      public int getPriority()
      Determines the tasks priority
      • When active: returns 1 if target is in range and visible, otherwise -1.
      • When inactive: returns 1 if target is in range and visible, otherwise -1.
      Specified by:
      getPriority in interface PriorityTask
      Returns:
      the tasks priority
    • isTargetVisible

      protected boolean isTargetVisible(Entity target)
      Determines if a target is visible by checking for obstacles in the current entities line of sight
      Parameters:
      target - the target to check
      Returns:
      true if the target is visible, false otherwise
    • getNearestVisibleTarget

      protected Entity getNearestVisibleTarget()
      Finds the nearest visible target within attack range.
      Returns:
      the closest visible target within range, or null if none
    • getAllTargets

      protected List<Entity> getAllTargets()