//------------------------------------------------------ protected override bool OnEvaluate(/*in*/ BTWorkingData wData) { var thisContext = (BTCActionParallel *)wData.GetContext(_uniqueKey); thisContext->evaluationStatus.Init(false); bool finalResult = false; for (int i = 0; i < GetChildCount(); ++i) { BTAction node = GetChild <BTAction>(i); bool ret = node.Evaluate(wData); //early break if (_evaluationRelationship == ECHILDREN_RELATIONSHIP.AND && ret == false) { finalResult = false; break; } if (ret == true) { finalResult = true; } thisContext->evaluationStatus[i] = ret; } return(finalResult); }
//------------------------------------------------------ protected override bool OnEvaluate(/*in*/ BTWorkingData wData) { var thisContext = (BTCActionSequence *)wData.GetContext(_uniqueKey); int checkedNodeIndex = -1; if (IsIndexValid(thisContext->currentSelectedIndex)) { checkedNodeIndex = thisContext->currentSelectedIndex; } else { checkedNodeIndex = 0; } if (IsIndexValid(checkedNodeIndex)) { BTAction node = GetChild <BTAction>(checkedNodeIndex); if (node.Evaluate(wData)) { thisContext->currentSelectedIndex = checkedNodeIndex; return(true); } } return(false); }
protected sealed override int OnUpdate(BTWorkingData wData){ int runningState = BTRunningStatus.FINISHED; var thisContext = (BTCActionLeaf*) wData.GetContext(_uniqueKey); #if DEBUG BTCActionLeaf __DEBUGval = *thisContext; #endif if (thisContext->status == ACTION_READY) { OnEnter(wData); thisContext->needExit = true; thisContext->status = ACTION_RUNNING; } if (thisContext->status == ACTION_RUNNING) { runningState = OnExecute(wData); if (BTRunningStatus.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 override int OnUpdate(BTWorkingData wData) { var thisContext = (BTCActionPrioritizedSelector *)wData.GetContext(_uniqueKey); int runningState = BTRunningStatus.FINISHED; if (thisContext->currentSelectedIndex != thisContext->lastSelectedIndex) { if (IsIndexValid(thisContext->lastSelectedIndex)) { BTAction node = GetChild <BTAction>(thisContext->lastSelectedIndex); node.Transition(wData); } thisContext->lastSelectedIndex = thisContext->currentSelectedIndex; } if (IsIndexValid(thisContext->lastSelectedIndex)) { BTAction node = GetChild <BTAction>(thisContext->lastSelectedIndex); runningState = node.Update(wData); if (BTRunningStatus.IsFinished(runningState)) { thisContext->lastSelectedIndex = -1; } } return(runningState); }
protected override int OnUpdate(BTWorkingData wData) { var thisContext = (BTCActionSequence *)wData.GetContext(_uniqueKey); int runningStatus = BTRunningStatus.FINISHED; BTAction node = GetChild <BTAction>(thisContext->currentSelectedIndex); runningStatus = node.Update(wData); if (_continueIfErrorOccors == false && BTRunningStatus.IsError(runningStatus)) { thisContext->currentSelectedIndex = -1; return(runningStatus); } if (BTRunningStatus.IsFinished(runningStatus)) { thisContext->currentSelectedIndex++; if (IsIndexValid(thisContext->currentSelectedIndex)) { runningStatus = BTRunningStatus.EXECUTING; } else { thisContext->currentSelectedIndex = -1; } } return(runningStatus); }
protected sealed override void OnTransition(BTWorkingData wData){ var thisContext = (BTCActionLeaf*) wData.GetContext(_uniqueKey); if (thisContext->needExit) { OnExit(wData, BTRunningStatus.TRANSITION); } thisContext->status = ACTION_READY; thisContext->needExit = false; }
protected override void OnTransition(BTWorkingData wData) { var thisContext = (BTActionLoopContext *)wData.GetContext(_uniqueKey); if (IsIndexValid(0)) { BTAction node = GetChild <BTAction>(0); node.Transition(wData); } thisContext->currentCount = 0; }
protected override void OnTransition(BTWorkingData wData) { var thisContext = (BTCActionPrioritizedSelector *)wData.GetContext(_uniqueKey); BTAction node = GetChild <BTAction>(thisContext->lastSelectedIndex); if (node != null) { node.Transition(wData); } thisContext->lastSelectedIndex = -1; }
protected override void OnTransition(BTWorkingData wData) { var thisContext = (BTCActionParallel *)wData.GetContext(_uniqueKey); for (int i = 0; i < GetChildCount(); ++i) { BTAction node = GetChild <BTAction>(i); node.Transition(wData); } //clear running status thisContext->StatusRunning.Init((byte)(int)BTRunningStatus.EXECUTING); }
protected override bool OnEvaluate(/*in*/ BTWorkingData wData) { var thisContext = (BTCActionNonPrioritizedSelector *)wData.GetContext(_uniqueKey); //check last node first if (IsIndexValid(thisContext->currentSelectedIndex)) { BTAction node = GetChild <BTAction>(thisContext->currentSelectedIndex); if (node.Evaluate(wData)) { return(true); } } return(base.OnEvaluate(wData)); }
//------------------------------------------------------- protected override bool OnEvaluate(/*in*/ BTWorkingData wData) { var thisContext = (BTActionLoopContext *)wData.GetContext(_uniqueKey); bool checkLoopCount = (_loopCount == INFINITY || thisContext->currentCount < _loopCount); if (checkLoopCount == false) { return(false); } if (IsIndexValid(0)) { BTAction node = GetChild <BTAction>(0); return(node.Evaluate(wData)); } return(false); }
protected override int OnUpdate(BTWorkingData wData) { var thisContext = (BTCActionParallel *)wData.GetContext(_uniqueKey); //first time initialization bool hasFinished = false; bool hasExecuting = false; for (int i = 0; i < GetChildCount(); ++i) { if (thisContext->evaluationStatus[i] == false) { continue; } if (BTRunningStatus.IsFinished(thisContext->StatusRunning[i])) { hasFinished = true; continue; } BTAction node = GetChild <BTAction>(i); int runningStatus = node.Update(wData); if (BTRunningStatus.IsFinished(runningStatus)) { hasFinished = true; } else { hasExecuting = true; } thisContext->StatusRunning[i] = (byte)runningStatus; } if (_runningStatusRelationship == ECHILDREN_RELATIONSHIP.OR && hasFinished || _runningStatusRelationship == ECHILDREN_RELATIONSHIP.AND && hasExecuting == false) { thisContext->StatusRunning.Init((byte)(int)BTRunningStatus.EXECUTING); return(BTRunningStatus.FINISHED); } return(BTRunningStatus.EXECUTING); }
protected override bool OnEvaluate(/*in*/ BTWorkingData wData) { var thisContext = (BTCActionPrioritizedSelector *)wData.GetContext(_uniqueKey); thisContext->currentSelectedIndex = -1; int childCount = GetChildCount(); for (int i = 0; i < childCount; ++i) { BTAction node = GetChild <BTAction>(i); if (node.Evaluate(wData)) { thisContext->currentSelectedIndex = i; return(true); } } return(false); }
protected override int OnUpdate(BTWorkingData wData) { var thisContext = (BTActionLoopContext *)wData.GetContext(_uniqueKey); int runningStatus = BTRunningStatus.FINISHED; if (IsIndexValid(0)) { BTAction node = GetChild <BTAction>(0); runningStatus = node.Update(wData); if (BTRunningStatus.IsFinished(runningStatus)) { thisContext->currentCount++; if (thisContext->currentCount < _loopCount || _loopCount == INFINITY) { runningStatus = BTRunningStatus.EXECUTING; } } } return(runningStatus); }
protected void* GetUserContextData(BTWorkingData wData){ return ((byte*) wData.GetContext(_uniqueKey) + sizeof(BTCActionLeaf)); }
public override object[] GetRuntimeData(BTWorkingData wData){ return new object[] {*(BTCActionLeaf*) wData.GetContext(_uniqueKey)}; }
public override object[] GetRuntimeData(BTWorkingData wData) { return(new object[] { *(BTCActionParallel *)wData.GetContext(_uniqueKey), }); }
public override object[] GetRuntimeData(BTWorkingData wData) { return(new object[] { *(BTCActionPrioritizedSelector *)wData.GetContext(_uniqueKey), }); }