Class WanderTask

java.lang.Object
com.csse3200.game.ai.tasks.DefaultTask
com.csse3200.game.components.tasks.WanderTask
All Implemented Interfaces:
PriorityTask, Task

public class WanderTask extends DefaultTask implements PriorityTask
Wander around by moving a random position within a range of the starting position. Wait a little bit 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

    Constructors
    Constructor
    Description
    WanderTask(com.badlogic.gdx.math.Vector2 wanderRange, float waitTime)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Gets the priority level of the wander task.
    void
    Starts the wander task by initializing movement and waiting tasks, and triggering relevant events.
    void
    Updates the wander task by handling task switching based on the current task's status.

    Methods inherited from class com.csse3200.game.ai.tasks.DefaultTask

    create, getStatus, stop

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.csse3200.game.ai.tasks.Task

    create, getStatus, stop
  • Constructor Details

    • WanderTask

      public WanderTask(com.badlogic.gdx.math.Vector2 wanderRange, float waitTime)
      Parameters:
      wanderRange - Distance in X and Y the entity can move from its position when start() is called.
      waitTime - How long in seconds to wait between wandering.
  • Method Details

    • getPriority

      public int getPriority()
      Gets the priority level of the wander task.
      Specified by:
      getPriority in interface PriorityTask
      Returns:
      The priority level (1 for low priority).
    • start

      public void start()
      Starts the wander task by initializing movement and waiting tasks, and triggering relevant events.
      Specified by:
      start in interface Task
      Overrides:
      start in class DefaultTask
    • update

      public void update()
      Updates the wander task by handling task switching based on the current task's status.
      Specified by:
      update in interface Task
      Overrides:
      update in class DefaultTask