Class AvoidTask
java.lang.Object
com.csse3200.game.ai.tasks.DefaultTask
com.csse3200.game.components.tasks.ChaseTask
com.csse3200.game.components.tasks.AvoidTask
- All Implemented Interfaces:
PriorityTask
,Task
Moves away from a target entity until a safe distance is reached 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.components.tasks.ChaseTask
debugRenderer, hit, maxChaseDistance, movementTask, physics, priority, target, viewDistance
Fields inherited from class com.csse3200.game.ai.tasks.DefaultTask
owner, status
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
Returns the priority level of the avoidance behavior.void
start()
Starts the avoidance behavior by initializing and starting the movement task.void
update()
Updates the avoidance behavior by setting the current target for the movement task and updating its state.Methods inherited from class com.csse3200.game.components.tasks.ChaseTask
getDistanceToTarget, getViewDistance, isBoss, isTargetVisible, stop
Methods inherited from class com.csse3200.game.ai.tasks.DefaultTask
create, getStatus, setOwner
-
Constructor Details
-
AvoidTask
public AvoidTask(Entity target, int priority, float safeDistance, float minAvoidDistance, boolean isBoss) Initialises the avoid task.- Parameters:
target
- The entity to avoid.priority
- Task priority when avoiding (0 when not avoiding).safeDistance
- Minimum distance to maintain from the target.minAvoidDistance
- Minimum distance to avoid moving away from the target.
-
-
Method Details
-
start
public void start()Starts the avoidance behavior by initializing and starting the movement task. Triggers the "avoidStart" event to indicate the beginning of avoidance. -
update
public void update()Updates the avoidance behavior by setting the current target for the movement task and updating its state. If the movement task is not active, it restarts the task. -
getPriority
public int getPriority()Returns the priority level of the avoidance behavior. Determines the priority based on whether the task is currently active or inactive.- Specified by:
getPriority
in interfacePriorityTask
- Overrides:
getPriority
in classChaseTask
- Returns:
- the priority level of the avoidance behavior.
-