Class WanderTask
java.lang.Object
com.csse3200.game.ai.tasks.DefaultTask
com.csse3200.game.components.tasks.WanderTask
- All Implemented Interfaces:
PriorityTask,Task
Represents a task that causes the entity to wander around by moving to random positions within a specified range of its starting position.
The entity will wait for a certain amount of time between movements. Requires an entity with a PhysicsMovementComponent.
-
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
ConstructorsConstructorDescriptionWanderTask(com.badlogic.gdx.math.Vector2 wanderRange, float waitTime) Creates a new WanderTask. -
Method Summary
Modifier and TypeMethodDescriptionchargetDirection(com.badlogic.gdx.math.Vector2 destination) Determines the direction from the entity's current position to the destination position.intvoidstart()Start running this task.voidupdate()Run one frame of the task.Methods inherited from class com.csse3200.game.ai.tasks.DefaultTask
create, getStatus, stop
-
Constructor Details
-
WanderTask
public WanderTask(com.badlogic.gdx.math.Vector2 wanderRange, float waitTime) Creates a new WanderTask.- Parameters:
wanderRange- The distance in X and Y that the entity can move from its position when start() is called.waitTime- The duration in seconds to wait between wandering.
-
-
Method Details
-
getPriority
public int getPriority()- Specified by:
getPriorityin interfacePriorityTask
-
start
public void start()Description copied from interface:TaskStart running this task. This will usually be called by an AI controller.- Specified by:
startin interfaceTask- Overrides:
startin classDefaultTask
-
update
public void update()Description copied from interface:TaskRun one frame of the task. Similar to the update() in Components.- Specified by:
updatein interfaceTask- Overrides:
updatein classDefaultTask
-
getDirection
public char getDirection(com.badlogic.gdx.math.Vector2 destination) Determines the direction from the entity's current position to the destination position.- Parameters:
destination- The destination position to which the direction is calculated.- Returns:
- A character representing the direction ('<', '>', or '=') relative to the current position.
-