Interface Behavior

All Known Implementing Classes:
AbstractBlockBreaker, BehaviorGoalAdapter, BlockBreaker, Callback, Composite, Decorator, Empty, FollowPathGoal, ForwardingBehaviorGoalAdapter, IfElse, Loop, MoveToGoal, Precondition, RetryDecorator, Selector, Sequence, StatusMapper, TargetNearbyEntityGoal, TimerDecorator, WanderGoal

public interface Behavior
The base class for the second iteration of the Goal API, which can be made backwards compatible by extending BehaviorGoalAdapter. A behavior is a common term for the parts of a behavior tree, which is a simple directed acyclic graph (DAG) for AI. It is a simple state machine using BehaviorStatus. Nodes are executed in a top-down fashion through the tree. For legacy reasons, the tree is executed as a number of executing nodes which are transitioned between using the BehaviorStatus they return. New child nodes are selected to become executing nodes based on shouldExecute(). The selection behavior can vary, e.g. running a list of nodes using Sequence or choosing from children nodes using Selector. The executing nodes are repeatedly run() until the return result changes from BehaviorStatus.RUNNING.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Resets the behavior and any state it is holding.
    run()
    Runs the behavior for one 'tick', optionally changing the state that it is in.
    boolean
    Returns whether the behavior is ready to run.
  • Method Details

    • reset

      void reset()
      Resets the behavior and any state it is holding.
    • run

      Runs the behavior for one 'tick', optionally changing the state that it is in.
      Returns:
      The new state
    • shouldExecute

      boolean shouldExecute()
      Returns whether the behavior is ready to run. Note this is called once when deciding whether to start execution of a leaf node. The actual execution status is determined by the return value of run() which is repeatedly called by the executing node.