Class RobotTargetDetectionTasks
java.lang.Object
com.csse3200.game.ai.tasks.DefaultTask
com.csse3200.game.components.tasks.RobotTargetDetectionTasks
- All Implemented Interfaces:
PriorityTask
,Task
- Direct Known Subclasses:
RobotAttackTask
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.csse3200.game.ai.tasks.Task
Task.Status
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final float
protected final DebugRenderer
protected final RaycastHit
protected final PhysicsEngine
protected short
Fields inherited from class com.csse3200.game.ai.tasks.DefaultTask
owner, status
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
RobotTargetDetectionTasks
(float attackRange, short targetLayer) -
Method Summary
Modifier and TypeMethodDescriptionprotected float
Gets the distance to the nearest visible targetprotected Entity
Finds the nearest visible target within attack range.int
Determines the tasks priority When active: returns1
if target is in range and visible, otherwise-1
.Methods inherited from class com.csse3200.game.ai.tasks.DefaultTask
create, getStatus, start, stop, update
-
Field Details
-
attackRange
protected final float attackRange -
physics
-
debugRenderer
-
hit
-
targetLayer
protected short targetLayer
-
-
Constructor Details
-
RobotTargetDetectionTasks
protected RobotTargetDetectionTasks(float attackRange, short targetLayer)
-
-
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
-
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 interfacePriorityTask
- Returns:
- the tasks priority
- When active: returns
-
getNearestVisibleTarget
Finds the nearest visible target within attack range.- Returns:
- the closest visible target within range, or
null
if none
-