Class PanicTask
java.lang.Object
com.csse3200.game.ai.tasks.DefaultTask
com.csse3200.game.ai.tasks.TimedTask
com.csse3200.game.components.tasks.PanicTask
- All Implemented Interfaces:
PriorityTask
,Task
A panic task that causes the owner's entity to move randomly within a specified range for a certain duration.
The task is triggered by an event and has a priority that determines its execution order.
-
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.void
start()
Starts the panic task by initializing the movement task and triggering the "runStart" event.void
stop()
Stops the panic task and the associated movement task.void
Sets the priority of the task to the active priority when triggered by an event.void
update()
Updates the panic task by checking if movement has finished, and if so, restarting the movement task.Methods inherited from class com.csse3200.game.ai.tasks.TimedTask
getPriority
Methods inherited from class com.csse3200.game.ai.tasks.DefaultTask
getStatus
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.csse3200.game.ai.tasks.PriorityTask
getPriority
-
Constructor Details
-
PanicTask
public PanicTask(String trigger, float duration, int priority, com.badlogic.gdx.math.Vector2 panicRange, com.badlogic.gdx.math.Vector2 panicSpeed) Constructs a PanicTask with the specified parameters.- Parameters:
trigger
- The event trigger that activates this task.duration
- The duration for which the panic behavior will occur.priority
- The priority of the panic task.panicRange
- The range within which the entity will move randomly.panicSpeed
- The speed at which the entity will move during panic.
-
-
Method Details
-
create
Description copied from class:TimedTask
When task is created, attach event listener to task owner. -
start
public void start()Starts the panic task by initializing the movement task and triggering the "runStart" event.- Specified by:
start
in interfaceTask
- Overrides:
start
in classDefaultTask
-
triggerActivePriority
public void triggerActivePriority()Description copied from class:TimedTask
Sets the priority of the task to the active priority when triggered by an event.- Overrides:
triggerActivePriority
in classTimedTask
-
update
public void update()Updates the panic task by checking if movement has finished, and if so, restarting the movement task. -
stop
public void stop()Stops the panic task and the associated movement task.
-