protected sealed override int onUpdate(TBTWorkingData wData) { int runningState = TBTRunningStatus.FINISHED; TBTActionLeafContext thisContext = getContext <TBTActionLeafContext>(wData); if (thisContext.status == ACTION_READY) { onEnter(wData); thisContext.needExit = true; thisContext.status = ACTION_RUNNING; } if (thisContext.status == ACTION_RUNNING) { runningState = onExecute(wData); if (TBTRunningStatus.IsFinished(runningState)) { thisContext.status = ACTION_FINISHED; } } if (thisContext.status == ACTION_FINISHED) { if (thisContext.needExit) { onExit(wData, runningState); } thisContext.status = ACTION_READY; thisContext.needExit = false; } return(runningState); }
protected sealed override int onUpdate(TBTWorkingData wData) { int runningState = TBTRunningStatus.FINISHED; TBTActionLeafContext thisContext = getContext <TBTActionLeafContext>(wData); // 只执行一次 if (thisContext.status == ACTION_READY) { onEnter(wData); thisContext.needExit = true; thisContext.status = ACTION_RUNNING; } // status是ACTION_RUNNING,但是thisContext.status是其他的状态 if (thisContext.status == ACTION_RUNNING) { // TBTRunningStatus是内部的执行状态,status是TBTActionLeaf是的状态 runningState = onExecute(wData); if (TBTRunningStatus.IsFinished(runningState)) { thisContext.status = ACTION_FINISHED; } } if (thisContext.status == ACTION_FINISHED) { if (thisContext.needExit) { onExit(wData, runningState); } // 返回默认状态 thisContext.status = ACTION_READY; thisContext.needExit = false; } return(runningState); }
protected sealed override void onTransition(TBTWorkingData wData) { TBTActionLeafContext thisContext = getContext <TBTActionLeafContext>(wData); if (thisContext.needExit) { onExit(wData, TBTRunningStatus.TRANSITION); } thisContext.status = ACTION_READY; thisContext.needExit = false; }