Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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;
        }
Esempio n. 3
0
        protected override void OnTransition(BtWorkingData workData)
        {
            BtActionPrioritizedSelectorContext thisContext = GetContext <BtActionPrioritizedSelectorContext>(workData);
            BtAction node = GetChild <BtAction>(thisContext._lastSelectedIndex);

            if (node != null)
            {
                node.Transition(workData);
            }
            thisContext._lastSelectedIndex = -1;
        }