程序包 cn.wjybxx.btree

类 Decorator<T>

java.lang.Object
cn.wjybxx.btree.Task<T>
cn.wjybxx.btree.Decorator<T>
所有已实现的接口:
ICancelTokenListener
直接已知子类:
AlwaysCheckGuard, AlwaysFail, AlwaysRunning, AlwaysSuccess, Inverter, LoopDecorator, OnlyOnce, StateMachineTask, SubtreeRef

public abstract class Decorator<T> extends Task<T>
装饰任务(最多只有一个子节点)
作者:
wjybxx date - 2023/11/25
  • 字段详细资料

    • child

      protected Task<T> child
  • 构造器详细资料

    • Decorator

      public Decorator()
    • Decorator

      public Decorator(Task<T> child)
  • 方法详细资料

    • stopRunningChildren

      protected void stopRunningChildren()
      从类复制的说明: Task
      停止所有运行中的子节点 1.该方法在自身的exit之前调用 2.如果有特殊的子节点(钩子任务),也需要在这里停止
      覆盖:
      stopRunningChildren 在类中 Task<T>
    • onChildRunning

      protected void onChildRunning(Task<T> child)
      从类复制的说明: Task
      子节点还需要继续运行 1.child在运行期间只会通知一次 2.该方法不应该触发状态迁移,即不应该使自己进入完成状态
      指定者:
      onChildRunning 在类中 Task<T>
    • onEventImpl

      protected void onEventImpl(@Nonnull Object event)
      从类复制的说明: Task
      对于控制节点,通常将事件派发给约定的子节点或钩子节点。 对于叶子节点,通常自身处理事件。 注意: 1.转发事件时应该调用子节点的Task.onEvent(Object)方法 2.在AI这样的领域中,建议将事件转化为信息存储在Task或黑板中,而不是尝试立即做出反应。 3.Task.isExecuting()方法很重要
      指定者:
      onEventImpl 在类中 Task<T>
    • indexChild

      public final int indexChild(Task<?> task)
      覆盖:
      indexChild 在类中 Task<T>
      返回:
      index or -1
    • childStream

      public final Stream<Task<T>> childStream()
      从类复制的说明: Task
      该接口主要用于测试,该接口有一定的开销
      指定者:
      childStream 在类中 Task<T>
    • getChildCount

      public final int getChildCount()
      从类复制的说明: Task
      子节点的数量(仅包括普通意义上的child,不包括钩子任务)
      指定者:
      getChildCount 在类中 Task<T>
    • getChild

      public final Task<T> getChild(int index)
      从类复制的说明: Task
      获取指定索引的child
      指定者:
      getChild 在类中 Task<T>
    • addChildImpl

      protected final int addChildImpl(Task<T> task)
      指定者:
      addChildImpl 在类中 Task<T>
      返回:
      为child分配的index
    • setChildImpl

      protected final Task<T> setChildImpl(int index, Task<T> task)
      指定者:
      setChildImpl 在类中 Task<T>
      返回:
      索引位置旧的child
    • removeChildImpl

      protected final Task<T> removeChildImpl(int index)
      指定者:
      removeChildImpl 在类中 Task<T>
      返回:
      index对应的child
    • getChild

      public Task<T> getChild()
    • setChild

      public void setChild(Task<T> child)