protected override int OnUpdate(BtWorkingData workData) { BtActionSequenceContext thisContext = GetContext <BtActionSequenceContext>(workData); int runningStatus = BtRunningStatus.FINISHED; BtAction node = GetChild <BtAction>(thisContext.current_selected_index); runningStatus = node.Update(workData); if (_continueIfErrorOccors == false && BtRunningStatus.IsError(runningStatus)) { thisContext.current_selected_index = -1; return(runningStatus); } if (BtRunningStatus.IsFinished(runningStatus)) { thisContext.current_selected_index++; if (IsIndexValid(thisContext.current_selected_index)) { runningStatus = BtRunningStatus.EXECUTING; } else { thisContext.current_selected_index = -1; } } return(runningStatus); }
protected override void OnTransition(BtWorkingData workData) { BtActionSequenceContext this_context = GetContext <BtActionSequenceContext>(workData); BtAction node = GetChild <BtAction>(this_context.current_selected_index); if (node != null) { node.Transition(workData); } this_context.current_selected_index = -1; }
protected override bool OnEvaluate(BtWorkingData workData) { BtActionSequenceContext thisContext = GetContext <BtActionSequenceContext>(workData); int checkedNodeIndex = IsIndexValid(thisContext.current_selected_index) ? thisContext.current_selected_index : 0; if (IsIndexValid(checkedNodeIndex)) { BtAction node = GetChild <BtAction>(checkedNodeIndex); if (node.Evaluate(workData)) { thisContext.current_selected_index = checkedNodeIndex; return(true); } } return(false); }