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 TypeMethodDescriptionvoidcreate(TaskRunner taskRunner) When task is created, attach event listener to task owner.voidstart()Starts the panic task by initializing the movement task and triggering the "runStart" event.voidstop()Stops the panic task and the associated movement task.voidSets the priority of the task to the active priority when triggered by an event.voidupdate()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
getPriorityMethods inherited from class com.csse3200.game.ai.tasks.DefaultTask
getStatusMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:TimedTaskWhen 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:
startin interfaceTask- Overrides:
startin classDefaultTask
-
triggerActivePriority
public void triggerActivePriority()Description copied from class:TimedTaskSets the priority of the task to the active priority when triggered by an event.- Overrides:
triggerActivePriorityin 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.
-