Interface GoalController

All Superinterfaces:
Iterable<GoalController.GoalEntry>, Runnable
All Known Implementing Classes:
SimpleGoalController

public interface GoalController extends Runnable, Iterable<GoalController.GoalEntry>
Represents a collection of goals that are prioritised and executed, allowing behaviour trees via a GoalSelector or by implementing Behavior. In general, using Behavior is preferred due to mapping more closely to traditional behavior trees. The highest priority Goal that returns true in Goal.shouldExecute(GoalSelector) is executed. Any existing goals with a lower priority are replaced via Goal.reset().
  • Method Details

    • addBehavior

      void addBehavior(Behavior behavior, int priority)
      Registers a Behavior with a given priority.
      Parameters:
      behavior - The behavior
      priority - The priority
      See Also:
    • addGoal

      void addGoal(Goal goal, int priority)
      Registers a Goal with a given priority. Priority must be greater than 0.
      Parameters:
      priority - The goal priority
      goal - The goal
    • addPrioritisableGoal

      void addPrioritisableGoal(PrioritisableGoal goal)
      Registers a goal which can reprioritise itself dynamically every tick. Implementation note: this may slow down individual goal controller ticks as the list must be sorted every tick.
      Parameters:
      goal -
    • cancelCurrentExecution

      void cancelCurrentExecution()
      Cancels and resets the currently executing goal.
    • clear

      void clear()
      Clears the goal controller of all Goals. Will stop the execution of any current goal.
    • isExecutingGoal

      boolean isExecutingGoal()
      Returns:
      Whether a goal is currently being executed
    • isPaused

      boolean isPaused()
      Returns:
      Whether the controller is currently paused
      See Also:
    • removeBehavior

      void removeBehavior(Behavior behavior)
      Removes the given Behavior from rotation.
      Parameters:
      behavior - The behavior to remove
    • removeGoal

      void removeGoal(Goal goal)
      Removes a Goal from rotation.
      Parameters:
      goal - The goal to remove
    • setPaused

      void setPaused(boolean paused)
      Sets whether the controller is paused. While paused, no new Goals will be selected and any executing goals will be suspended.
      Parameters:
      paused - Whether to pause execution