Class CooldownTask
java.lang.Object
com.csse3200.game.ai.tasks.DefaultTask
com.csse3200.game.components.tasks.CooldownTask
- All Implemented Interfaces:
PriorityTask,Task
A cooldown task that activates after a chase has ended.
When activated, the entity remains idle for a set cooldown duration,
then teleports back to either:
- The start of its patrol route (if one exists)
- Its original spawn position (if no patrol route exists)
This ensures drones reset to their initial state instead of
beelining back manually.
-
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
ConstructorsConstructorDescriptionCooldownTask(float waitTime) Creates a cooldown task with the given wait duration and teleport type.(teleportStart by default)CooldownTask(float waitTime, String teleportEvent) -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate()Activates the cooldown task.voidDeactivate the cooldown task, preventing it from being scheduled.intReturns the priority of this task.booleanCheck if teleporting.booleanCheck if waiting.voidstart()Starts the cooldown.voidstop()When the cooldown task is stopped, a 'cooldownEnd' event is triggered.voidupdate()Advance wait task.Methods inherited from class com.csse3200.game.ai.tasks.DefaultTask
create, getStatus
-
Constructor Details
-
CooldownTask
public CooldownTask(float waitTime) Creates a cooldown task with the given wait duration and teleport type.(teleportStart by default)- Parameters:
waitTime- duration (in seconds) to wait before teleporting the entity back to its original position
-
CooldownTask
-
-
Method Details
-
activate
public void activate()Activates the cooldown task. Typically triggered by a "playerLost" event. -
deactivate
public void deactivate()Deactivate the cooldown task, preventing it from being scheduled. Typically called in response to a `playerDetected` event. -
start
public void start()Starts the cooldown. Creates a wait and teleport wait subtask, starts wait and triggers a"cooldownStart"event.- Specified by:
startin interfaceTask- Overrides:
startin classDefaultTask
-
update
public void update()Advance wait task. Once the cooldown wait has elapsed, the entity starts the teleport wait while animation is played (triggered by 'teleportStart') then teleports back to its patrol start or spawn position. Calls deactivate() to stop task being runnable.- Specified by:
updatein interfaceTask- Overrides:
updatein classDefaultTask
-
getPriority
public int getPriority()Returns the priority of this task. The cooldown is only considered runnable while active is true.- Specified by:
getPriorityin interfacePriorityTask- Returns:
- priority 5 when active, otherwise -1 (disabled)
-
stop
public void stop()When the cooldown task is stopped, a 'cooldownEnd' event is triggered.- Specified by:
stopin interfaceTask- Overrides:
stopin classDefaultTask
-
isTeleporting
public boolean isTeleporting()Check if teleporting.- Returns:
- true if currentTask is teleportWait
-
isWaiting
public boolean isWaiting()Check if waiting.- Returns:
- true if currentTask is waitTask
-