Class EngineerCombatTask

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

public class EngineerCombatTask extends DefaultTask implements PriorityTask
The AI Task for the Engineer entity. The Engineer will scan for targets within its detection range and trigger events to change its state accordingly. This task must be called once the Engineer has appropiately moved into position.
  • 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
    EngineerCombatTask(float maxRange)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    com.badlogic.gdx.math.Vector2
    Fetches the nearest target from the array of detected target positions created during the last call of isTargetVisible
    int
    Simplified getPriority function, returns the priority of the task
    boolean
    Uses a raycast to determine whether there are any targets in detection range.
    void
    Runs the task and triggers Engineer's idle animation.
    void
    For stopping the running task
    void
    The update method is what is run every time the TaskRunner in the AiTaskComponent calls update().
    void
    Engineer state machine

    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

    • EngineerCombatTask

      public EngineerCombatTask(float maxRange)
      Parameters:
      maxRange - The maximum range of the Engineer's weapon.
  • Method Details

    • start

      public void start()
      Runs the task and triggers Engineer's idle animation.
      Specified by:
      start in interface Task
      Overrides:
      start in class DefaultTask
    • update

      public void update()
      The update method is what is run every time the TaskRunner in the AiTaskComponent calls update(). triggers events depending on the presence or otherwise of targets in the detection range
      Specified by:
      update in interface Task
      Overrides:
      update in class DefaultTask
    • updateEngineerState

      public void updateEngineerState()
      Engineer state machine
    • stop

      public void stop()
      For stopping the running task
      Specified by:
      stop in interface Task
      Overrides:
      stop in class DefaultTask
    • getPriority

      public int getPriority()
      Simplified getPriority function, returns the priority of the task
      Specified by:
      getPriority in interface PriorityTask
      Returns:
      priority as an integer value. If mobs are visible, return the current priority, otherwise return 0.
    • isTargetVisible

      public boolean isTargetVisible()
      Uses a raycast to determine whether there are any targets in detection range. Performs multiple raycasts to a range of points at x = engineer.x + maxRange, and a range of y values above and below current y position. Allows the engineer entity to detect mobs in adjacent lanes.
      Returns:
      true if a target is detected, false otherwise
    • fetchTarget

      public com.badlogic.gdx.math.Vector2 fetchTarget()
      Fetches the nearest target from the array of detected target positions created during the last call of isTargetVisible
      Returns:
      a Vector2 position of the nearest mob detected.