示例#1
0
        public EBTStatus resume(Agent pAgent, EBTStatus status)
        {
            BranchTask   parent      = null;
            BehaviorTask currentTask = base.m_currentTask;

            while (currentTask != null)
            {
                BranchTask task3 = currentTask as BranchTask;
                if (task3 != null)
                {
                    parent      = task3;
                    currentTask = task3.GetCurrentTask();
                }
                else
                {
                    parent = currentTask.GetParent();
                    break;
                }
            }
            if (parent != null)
            {
                parent.onexit_action(pAgent, status);
                parent.SetReturnStatus(status);
            }
            return(status);
        }
示例#2
0
        public EBTStatus resume(Agent pAgent, EBTStatus status)
        {
            BranchTask   prev = null;
            BehaviorTask p    = this.m_currentTask;

            while (p != null)
            {
                BranchTask branch = p as BranchTask;
                if (branch != null)
                {
                    prev = branch;
                    p    = branch.GetCurrentTask();
                }
                else
                {
                    prev = p.GetParent();
                    break;
                }
            }

            if (prev != null)
            {
                //prev is the last interrupted node, to find and let its parent update with 'status' which is the subtree's return status
                Debug.Check(status == EBTStatus.BT_SUCCESS || status == EBTStatus.BT_FAILURE);
                prev.onexit_action(pAgent, status);

                prev.SetReturnStatus(status);
            }

            return(status);
        }
示例#3
0
        protected EBTStatus tickCurrentNode(Agent pAgent)
        {
            EBTStatus status = this.m_currentTask.GetStatus();

            if ((status != EBTStatus.BT_INVALID) && (status != EBTStatus.BT_RUNNING))
            {
                return(status);
            }
            BehaviorTask currentTask = this.m_currentTask;
            EBTStatus    childStatus = this.m_currentTask.exec(pAgent);

            if (childStatus != EBTStatus.BT_RUNNING)
            {
                BranchTask parent = currentTask.GetParent();
                this.SetCurrentTask(null);
                while ((parent != null) && (parent != this))
                {
                    childStatus = parent.update(pAgent, childStatus);
                    if (childStatus == EBTStatus.BT_RUNNING)
                    {
                        return(EBTStatus.BT_RUNNING);
                    }
                    parent.onexit_action(pAgent, childStatus);
                    parent.m_status = childStatus;
                    parent          = parent.GetParent();
                }
            }
            return(childStatus);
        }
示例#4
0
        protected EBTStatus tickCurrentNode(Agent pAgent)
        {
            Debug.Check(this.m_currentTask != null);

            EBTStatus s = this.m_currentTask.GetStatus();

            if (s == EBTStatus.BT_INVALID || s == EBTStatus.BT_RUNNING)
            {
                //this.m_currentTask could be cleared in ::tick, to remember it
                BehaviorTask currentTask = this.m_currentTask;
                EBTStatus    status      = this.m_currentTask.exec(pAgent);

                //give the handling back to parents
                if (status != EBTStatus.BT_RUNNING)
                {
                    Debug.Check(currentTask.m_status == EBTStatus.BT_SUCCESS ||
                                currentTask.m_status == EBTStatus.BT_FAILURE ||
                                (currentTask.m_status == EBTStatus.BT_INVALID && currentTask.NeedRestart()));

                    BranchTask parentBranch = currentTask.GetParent();

                    this.SetCurrentTask(null);

                    //back track the parents until the branch
                    while (parentBranch != null && parentBranch != this)
                    {
                        status = parentBranch.update(pAgent, status);
                        if (status == EBTStatus.BT_RUNNING)
                        {
                            return(EBTStatus.BT_RUNNING);
                        }

                        parentBranch.onexit_action(pAgent, status);

                        parentBranch.m_status = status;

                        Debug.Check(parentBranch.m_currentTask == null);

                        parentBranch = parentBranch.GetParent();
                    }
                }

                return(status);
            }

            return(s);
        }
示例#5
0
        public EBTStatus resume(Agent pAgent, EBTStatus status)
        {
            BranchTask branchTask = null;
            BranchTask branchTask2;

            for (BehaviorTask currentTask = this.m_currentTask; currentTask != null; currentTask = branchTask2.GetCurrentTask())
            {
                branchTask2 = (currentTask as BranchTask);
                if (branchTask2 == null)
                {
                    branchTask = currentTask.GetParent();
                    break;
                }
                branchTask = branchTask2;
            }
            if (branchTask != null)
            {
                branchTask.onexit_action(pAgent, status);
                branchTask.SetReturnStatus(status);
            }
            return(status);
        }