Class ChaseTask
java.lang.Object
com.csse3200.game.ai.tasks.DefaultTask
com.csse3200.game.components.tasks.ChaseTask
- All Implemented Interfaces:
PriorityTask,Task
Event-activated chase behaviour.
This task is made eligible for scheduling via external calls to activate() (e.g. 'enemyActivated' in EnemyFactory).
The entity chases the target until either:
- The target is farther than maxChaseDistance
- Line of sight is broken for more than LOS_GRACE_MS after initial sighting
To prevent the task from finishing immediately if the entity starts far away/out of LOS, these end conditions
are only applicable after an initial active grace period ends.
Re-activate chase via new calls to activate() only.
-
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 TypeMethodDescriptionvoidactivate()Activate the chase task, making it eligible for scheduling.voidDeactivate the chase task, preventing it from being scheduled.intGet the current priority of the task.voidstart()Initialise and start movement towards target.voidstop()Stop the chase behaviour and movement subtask.voidupdate()Update the chase behaviour each frame.Methods inherited from class com.csse3200.game.ai.tasks.DefaultTask
create, getStatus
-
Constructor Details
-
ChaseTask
Creates a new chase task that will pursue the given target entity- Parameters:
target- entity to chasemaxChaseDistance- threshold where chase endsactiveGracePeriod- time in seconds that entity chases before end conditions apply
-
-
Method Details
-
activate
public void activate()Activate the chase task, making it eligible for scheduling. Called by external systems (e.g. 'enemyActivated' in response to security camera) -
deactivate
public void deactivate()Deactivate the chase task, preventing it from being scheduled. -
start
public void start()Initialise and start movement towards target.- Specified by:
startin interfaceTask- Overrides:
startin classDefaultTask
-
update
public void update()Update the chase behaviour each frame.- Specified by:
updatein interfaceTask- Overrides:
updatein classDefaultTask
-
stop
public void stop()Stop the chase behaviour and movement subtask.- Specified by:
stopin interfaceTask- Overrides:
stopin classDefaultTask
-
getPriority
public int getPriority()Get the current priority of the task. Enables task handover if end conditions are met.- Specified by:
getPriorityin interfacePriorityTask- Returns:
- -1 if inactive or end conditions are met. Otherwise, 10 while active.
-