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. -
Method Summary
Modifier and TypeMethodDescriptionvoid
activate()
Activates the cooldown task.void
Deactivate the cooldown task, preventing it from being scheduled.int
Returns the priority of this task.void
start()
Starts the cooldown.void
stop()
When the cooldown task is stopped, gravity is restored and a 'cooldownEnd' event is triggered.void
update()
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.- Parameters:
waitTime
- duration (in seconds) to wait before teleporting the entity back to its original position
-
-
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. Starts a wait subtask, disables gravity, and triggers a"cooldownStart"
event for animations TO BE ADDED.- Specified by:
start
in interfaceTask
- Overrides:
start
in classDefaultTask
-
update
public void update()Advance wait task. Once the cooldown wait has elapsed, the entity is teleported back to its patrol start or spawn position the cooldown task is stopped. Calls deactivate() to stop task being runnable.- Specified by:
update
in interfaceTask
- Overrides:
update
in classDefaultTask
-
getPriority
public int getPriority()Returns the priority of this task. The cooldown is only considered runnable while active is true.- Specified by:
getPriority
in interfacePriorityTask
- Returns:
- priority 5 when active, otherwise -1 (disabled)
-
stop
public void stop()When the cooldown task is stopped, gravity is restored and a 'cooldownEnd' event is triggered.- Specified by:
stop
in interfaceTask
- Overrides:
stop
in classDefaultTask
-