Class FollowTask
java.lang.Object
com.csse3200.game.ai.tasks.DefaultTask
com.csse3200.game.components.tasks.ChaseTask
com.csse3200.game.components.tasks.FollowTask
- All Implemented Interfaces:
PriorityTask
,Task
- Direct Known Subclasses:
TamedFollowTask
Follows a target entity until they get too far away or line of sight is lost
-
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
ConstructorsConstructorDescriptionFollowTask
(Entity target, int priority, float viewDistance, float maxFollowDistance, float stoppingDistance, com.badlogic.gdx.math.Vector2 speed) FollowTask
(Entity target, int priority, float viewDistance, float maxFollowDistance, float stoppingDistance, com.badlogic.gdx.math.Vector2 speed, boolean checkVisibility) -
Method Summary
Modifier and TypeMethodDescriptionprotected int
Determines the priority when the follow task is inactive based on the distance to the target, the visibility of the target entity, and the stopping distance.void
start()
Starts the follow task by initializing the movement task and triggering the "followStart" event.void
stop()
Stops the follow task and the associated movement task, and triggers the "followStop" event.void
update()
Updates the follow task by updating the movement task and stopping it if the entity is too close to the target.Methods inherited from class com.csse3200.game.components.tasks.ChaseTask
getActivePriority, getDistanceToTarget, getMovementTask, getPriority, getRawPriority, getTarget, getViewDistance, isTargetVisible, setMovementTask
Methods inherited from class com.csse3200.game.ai.tasks.DefaultTask
create, getStatus
-
Constructor Details
-
FollowTask
public FollowTask(Entity target, int priority, float viewDistance, float maxFollowDistance, float stoppingDistance, com.badlogic.gdx.math.Vector2 speed) - Parameters:
target
- The entity to follow.priority
- Task priority when following (0 when not following).viewDistance
- Maximum distance from the entity at which following can start.maxFollowDistance
- Maximum distance from the entity while following before giving up.stoppingDistance
- The distance at which the entity stops following target.speed
- The speed at which the entity follows the player.
-
FollowTask
public FollowTask(Entity target, int priority, float viewDistance, float maxFollowDistance, float stoppingDistance, com.badlogic.gdx.math.Vector2 speed, boolean checkVisibility) - Parameters:
target
- The entity to follow.priority
- Task priority when following (0 when not following).viewDistance
- Maximum distance from the entity at which following can start.maxFollowDistance
- Maximum distance from the entity while following before giving up.stoppingDistance
- The distance at which the entity stops following target.speed
- The speed at which the entity follows the player.checkVisibility
- Checks to see if the entity will consider obstacles in its path.
-
-
Method Details
-
start
public void start()Starts the follow task by initializing the movement task and triggering the "followStart" event. -
update
public void update()Updates the follow task by updating the movement task and stopping it if the entity is too close to the target. -
stop
public void stop()Stops the follow task and the associated movement task, and triggers the "followStop" event. -
getInactivePriority
protected int getInactivePriority()Determines the priority when the follow task is inactive based on the distance to the target, the visibility of the target entity, and the stopping distance.- Overrides:
getInactivePriority
in classChaseTask
- Returns:
- The inactive priority level or -1 if conditions are not met.
-