Class Precondition

java.lang.Object
net.citizensnpcs.api.ai.tree.BehaviorGoalAdapter
net.citizensnpcs.api.ai.tree.Precondition
All Implemented Interfaces:
Goal, Behavior

public abstract class Precondition extends BehaviorGoalAdapter
  • Field Details

    • condition

      protected final Condition condition
  • Constructor Details

    • Precondition

      protected Precondition(Condition condition)
  • Method Details

    • runPrecondition

      public static Precondition runPrecondition(Condition condition)
      Creates a Precondition that returns either BehaviorStatus.SUCCESS or BehaviorStatus.FAILURE depending on the underlying Condition's return status.
      Parameters:
      condition - The condition to check while executing
      Returns:
      The precondition behavior
    • wrappingPrecondition

      public static Precondition wrappingPrecondition(Behavior wrapping, Condition condition)
      Creates a Precondition that wraps the shouldExecute method in Behavior. When shouldExecute is called, the given Condition will be checked before the wrapped behavior's method is called.
      Parameters:
      wrapping - The behavior to wrap calls to
      condition - The execution condition
      Returns:
      The precondition behavior