Package com.csse3200.game.ai.tasks
Class TimedTask
java.lang.Object
com.csse3200.game.ai.tasks.DefaultTask
com.csse3200.game.ai.tasks.TimedTask
- All Implemented Interfaces:
PriorityTask
,Task
- Direct Known Subclasses:
PanicTask
A task that runs for a set amount of time (depending on priority). This task must be triggered by an event.
The task will run unless overridden by a task with higher priority.
-
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
create
(TaskRunner taskRunner) When task is created, attach event listener to task owner.int
Return priorityvoid
stop()
Stops task and sets back to inactive priority.void
Sets the priority of the task to the active priority when triggered by an event.void
update()
Increment running time every update.Methods inherited from class com.csse3200.game.ai.tasks.DefaultTask
getStatus, start
-
Constructor Details
-
TimedTask
Constructs a TimedTask with specified parameters.- Parameters:
trigger
- The event trigger that activates this task.duration
- The duration for which this task will run.priority
- The initial priority of the task.
-
-
Method Details
-
create
When task is created, attach event listener to task owner.- Specified by:
create
in interfaceTask
- Overrides:
create
in classDefaultTask
- Parameters:
taskRunner
- Task runner to attach to
-
triggerActivePriority
public void triggerActivePriority()Sets the priority of the task to the active priority when triggered by an event. -
update
public void update()Increment running time every update.- Specified by:
update
in interfaceTask
- Overrides:
update
in classDefaultTask
-
stop
public void stop()Stops task and sets back to inactive priority.- Specified by:
stop
in interfaceTask
- Overrides:
stop
in classDefaultTask
-
getPriority
public int getPriority()Return priority- Specified by:
getPriority
in interfacePriorityTask
- Returns:
- priority
-