예제 #1
0
        //------------------------------------------------------
        protected override bool onEvaluate(/*in*/ BehaviourTreeData wData)
        {
            TBTActionParallelContext thisContext = getContext <TBTActionParallelContext>(wData);

            initListTo <bool>(thisContext.evaluationStatus, false);
            bool finalResult = false;

            for (int i = 0; i < GetChildCount(); ++i)
            {
                BehaviourAction node = GetChild <BehaviourAction>(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);
        }
예제 #2
0
 protected override bool onEvaluate(/*in*/ BehaviourTreeData wData)
 {
     BehaviourActionPrioritizedSelector.TBTActionPrioritizedSelectorContext thisContext =
         getContext <BehaviourActionPrioritizedSelector.TBTActionPrioritizedSelectorContext>(wData);
     //check last node first
     if (IsIndexValid(thisContext.currentSelectedIndex))
     {
         BehaviourAction node = GetChild <BehaviourAction>(thisContext.currentSelectedIndex);
         if (node.Evaluate(wData))
         {
             return(true);
         }
     }
     return(base.onEvaluate(wData));
 }
예제 #3
0
        //-------------------------------------------------------
        protected override bool onEvaluate(/*in*/ BehaviourTreeData wData)
        {
            TBTActionLoopContext thisContext = getContext <TBTActionLoopContext>(wData);
            bool checkLoopCount = (_loopCount == INFINITY || thisContext.currentCount < _loopCount);

            if (checkLoopCount == false)
            {
                return(false);
            }
            if (IsIndexValid(0))
            {
                BehaviourAction node = GetChild <BehaviourAction>(0);
                return(node.Evaluate(wData));
            }
            return(false);
        }
예제 #4
0
        //------------------------------------------------------
        protected override bool onEvaluate(/*in*/ BehaviourTreeData wData)
        {
            TBTActionSequenceContext thisContext = getContext <TBTActionSequenceContext>(wData);
            int checkedNodeIndex = -1;

            if (IsIndexValid(thisContext.currentSelectedIndex))
            {
                checkedNodeIndex = thisContext.currentSelectedIndex;
            }
            else
            {
                checkedNodeIndex = 0;
            }
            if (IsIndexValid(checkedNodeIndex))
            {
                BehaviourAction node = GetChild <BehaviourAction>(checkedNodeIndex);
                if (node.Evaluate(wData))
                {
                    thisContext.currentSelectedIndex = checkedNodeIndex;
                    return(true);
                }
            }
            return(false);
        }