Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
        protected override void OnTransition(BTWorkingData wData)
        {
            var      thisContext = (BTCActionSequence *)wData.GetContext(_uniqueKey);
            BTAction node        = GetChild <BTAction>(thisContext->currentSelectedIndex);

            if (node != null)
            {
                node.Transition(wData);
            }
            thisContext->currentSelectedIndex = -1;
        }
Exemplo n.º 4
0
        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);
        }