Class EngineerCombatTask
java.lang.Object
com.csse3200.game.ai.tasks.DefaultTask
com.csse3200.game.components.tasks.human.EngineerCombatTask
- All Implemented Interfaces:
PriorityTask
,Task
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
-
Method Summary
Modifier and TypeMethodDescriptioncom.badlogic.gdx.math.Vector2
Fetches the nearest target from the array of detected target positions created during the last call of isTargetVisibleint
Simplified getPriority function, returns the priority of the taskboolean
Uses a raycast to determine whether there are any targets in detection range.void
start()
Runs the task and triggers Engineer's idle animation.void
stop()
For stopping the running taskvoid
update()
The update method is what is run every time the TaskRunner in the AiTaskComponent calls update().void
Engineer state machineMethods inherited from class com.csse3200.game.ai.tasks.DefaultTask
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 interfaceTask
- Overrides:
start
in classDefaultTask
-
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 interfaceTask
- Overrides:
update
in classDefaultTask
-
updateEngineerState
public void updateEngineerState()Engineer state machine -
stop
public void stop()For stopping the running task- Specified by:
stop
in interfaceTask
- Overrides:
stop
in classDefaultTask
-
getPriority
public int getPriority()Simplified getPriority function, returns the priority of the task- Specified by:
getPriority
in interfacePriorityTask
- 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.
-