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 TypeMethodDescriptionvoid
activate()
Activate the chase task, making it eligible for scheduling.void
Deactivate the chase task, preventing it from being scheduled.int
Get the current priority of the task.void
start()
Initialise and start movement towards target.void
stop()
Stop the chase behaviour and movement subtask.void
update()
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:
start
in interfaceTask
- Overrides:
start
in classDefaultTask
-
update
public void update()Update the chase behaviour each frame.- Specified by:
update
in interfaceTask
- Overrides:
update
in classDefaultTask
-
stop
public void stop()Stop the chase behaviour and movement subtask.- Specified by:
stop
in interfaceTask
- Overrides:
stop
in classDefaultTask
-
getPriority
public int getPriority()Get the current priority of the task. Enables task handover if end conditions are met.- Specified by:
getPriority
in interfacePriorityTask
- Returns:
- -1 if inactive or end conditions are met. Otherwise, 10 while active.
-