Class Loop

java.lang.Object
net.citizensnpcs.api.ai.tree.Loop
All Implemented Interfaces:
Behavior

public class Loop extends Object implements Behavior
A decorator Behavior that continues to execute its child behavior as long as a condition returns true and the behavior returns BehaviorStatus.SUCCESS.
  • Constructor Details

  • Method Details

    • reset

      public void reset()
      Description copied from interface: Behavior
      Resets the behavior and any state it is holding.
      Specified by:
      reset in interface Behavior
    • run

      public BehaviorStatus run()
      Description copied from interface: Behavior
      Runs the behavior for one 'tick', optionally changing the state that it is in.
      Specified by:
      run in interface Behavior
      Returns:
      The new state
    • shouldExecute

      public boolean shouldExecute()
      Description copied from interface: Behavior
      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 Behavior.run() which is repeatedly called by the executing node.
      Specified by:
      shouldExecute in interface Behavior
    • createWithCondition

      public static Loop createWithCondition(Behavior wrapping, Supplier<Boolean> condition)