Class IdleTask
java.lang.Object
com.csse3200.game.ai.tasks.DefaultTask
com.csse3200.game.components.tasks.TargetDetectionTasks
com.csse3200.game.components.tasks.IdleTask
- All Implemented Interfaces:
PriorityTask
,Task
Keeps an entity idle until a target entity is detected within the attack range.
A list of available target entities is monitored to determine whether the current entity should remain idle or prepare for an attack, based on the target's distance and visibility. The closest visible target is found and if the target is outside the entity's range of attack, entity remains idle. Otherwise, this task becomes inactive and another task (attack task) takes over.
-
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.components.tasks.TargetDetectionTasks
attackRange, debugRenderer, hit, physics
Fields inherited from class com.csse3200.game.ai.tasks.DefaultTask
owner, status
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected int
getActivePriority
(float dst, Entity target) If task is currently running, determine whether to stay runningprotected int
getInactivePriority
(float dst, Entity target) If task is not currently running, determine if it should runvoid
update()
Run one frame of the task.Methods inherited from class com.csse3200.game.components.tasks.TargetDetectionTasks
getAllTargets, getDistanceToTarget, getNearestVisibleTarget, getPriority, isTargetVisible
Methods inherited from class com.csse3200.game.ai.tasks.DefaultTask
create, getStatus, start, stop
-
Constructor Details
-
IdleTask
public IdleTask(float attackRange) Creates an IdleTask- Parameters:
attackRange
- the maximum distance at which the entity can attack a target
-
-
Method Details
-
update
public void update()Description copied from interface:Task
Run one frame of the task. Similar to the update() in Components.- Specified by:
update
in interfaceTask
- Overrides:
update
in classDefaultTask
-
getActivePriority
If task is currently running, determine whether to stay running- Specified by:
getActivePriority
in classTargetDetectionTasks
- Parameters:
dst
- the distance to the targettarget
- the target entity- Returns:
-1
if an enemy is within attack range (deactivate), otherwise1
(stay idle)
-
getInactivePriority
If task is not currently running, determine if it should run- Specified by:
getInactivePriority
in classTargetDetectionTasks
- Parameters:
dst
- the distance to the targettarget
- the target entity- Returns:
-1
if an enemy is within attack range otherwise1
(start task)
-