Interface GoalController

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

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.
      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.
      goal - The goal
      priority - The goal priority
    • 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.
      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()
      Whether a goal is currently being executed
    • isPaused

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

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

      void removeGoal(Goal goal)
      Removes a Goal from rotation.
      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.
      paused - Whether to pause execution