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 int OnUpdate(BtWorkingData workData) { BtActionPrioritizedSelectorContext thisContext = GetContext <BtActionPrioritizedSelectorContext>(workData); int runningState = BtRunningStatus.FINISHED; if (thisContext._currentSelectedIndex != thisContext._lastSelectedIndex) { if (IsIndexValid(thisContext._lastSelectedIndex)) { BtAction node = GetChild <BtAction>(thisContext._lastSelectedIndex); node.Transition(workData); } thisContext._lastSelectedIndex = thisContext._currentSelectedIndex; } if (IsIndexValid(thisContext._lastSelectedIndex)) { BtAction node = GetChild <BtAction>(thisContext._lastSelectedIndex); runningState = node.Update(workData); if (BtRunningStatus.IsFinished(runningState)) { thisContext._lastSelectedIndex = -1; } } return(runningState); }