Exemple #1
0
  @Override
  public BehaviorStatus run() {
    tickParallel();
    BehaviorStatus status = null;
    if (executing == null) {
      if ((executing = getNextBehavior()) == null) {
        return BehaviorStatus.FAILURE;
      }

      if (executing.shouldExecute()) {
        prepareForExecution(executing);
      } else {
        status = BehaviorStatus.FAILURE;
      }
    }
    if (status == null) {
      status = executing.run();
    }
    if (status == BehaviorStatus.FAILURE) {
      if (retryChildren) {
        stopExecution(executing);
        executing = null;
        return BehaviorStatus.RUNNING;
      }
    } else if (status == BehaviorStatus.RESET_AND_REMOVE) {
      getBehaviors().remove(executing);
      stopExecution(executing);
      executing = null;
      return BehaviorStatus.SUCCESS;
    }
    return status;
  }