public override void copyto(BehaviorTask target)
            {
                base.copyto(target);

                Debug.Check(target is CompositeStochasticTask);
                CompositeStochasticTask ttask = (CompositeStochasticTask)target;

                ttask.m_set = this.m_set;
            }
        public override bool IsValid(Agent pAgent, BehaviorTask pTask)
        {
            if (!(pTask.GetNode() is DecoratorFailureUntil))
            {
                return false;
            }

            return base.IsValid(pAgent, pTask);
        }
Exemple #3
0
        public override bool IsValid(Agent pAgent, BehaviorTask pTask)
        {
            if (!(pTask.GetNode() is And))
            {
                return false;
            }

            return base.IsValid(pAgent, pTask);
        }
Exemple #4
0
            public override void copyto(BehaviorTask target)
            {
                base.copyto(target);

                Debug.Check(target is SelectorLoopTask);
                SelectorLoopTask ttask = (SelectorLoopTask)target;

                ttask.m_activeChildIndex = this.m_activeChildIndex;
            }
        public override bool IsValid(Agent pAgent, BehaviorTask pTask)
        {
            if (!(pTask.GetNode() is DecoratorAlwaysSuccess))
            {
                return false;
            }

            return base.IsValid(pAgent, pTask);
        }
Exemple #6
0
            public override void copyto(BehaviorTask target)
            {
                base.copyto(target);

                Debug.Check(target is WaitFramesTask);
                WaitFramesTask ttask = (WaitFramesTask)target;
                ttask.m_start = this.m_start;
                ttask.m_frames = this.m_frames;
            }
Exemple #7
0
            public override void copyto(BehaviorTask target)
            {
                base.copyto(target);

                Debug.Check(target is DecoratorCountTask);
                DecoratorCountTask ttask = (DecoratorCountTask)target;

                ttask.m_n = this.m_n;
            }
Exemple #8
0
        public override void copyto(BehaviorTask target)
        {
            base.copyto(target);

            Debug.Check(target is WaitforSignalTask);
            WaitforSignalTask ttask = (WaitforSignalTask)target;

            ttask.m_bTriggered = this.m_bTriggered;
        }
        public override bool IsValid(Agent pAgent, BehaviorTask pTask)
        {
            if (!(pTask.GetNode() is SelectorStochastic))
            {
                return false;
            }

            return base.IsValid(pAgent, pTask);
        }
Exemple #10
0
            public override void copyto(BehaviorTask target)
            {
                base.copyto(target);

                Debug.Check(target is DecoratorTimeTask);
                DecoratorTimeTask ttask = (DecoratorTimeTask)target;

                ttask.m_start = this.m_start;
                ttask.m_time = this.m_time;
            }
Exemple #11
0
            public override void copyto(BehaviorTask target)
            {
                base.copyto(target);

                Debug.Check(target is WaitStateTask);
                WaitStateTask ttask = (WaitStateTask)target;

                ttask.m_start = this.m_start;
                ttask.m_time = this.m_time;
            }
Exemple #12
0
        public override bool IsValid(Agent pAgent, BehaviorTask pTask)
        {
            if (!(pTask.GetNode() is Noop))
            {
                return false;
            }

            //used in unittest
            //return base.IsValid(pAgent, pTask);
            return true;
        }
        public static string GetTickInfo(Agent pAgent, BehaviorTask b, string action)
        {
            #if !BEHAVIAC_RELEASE
            if (Config.IsLoggingOrSocketing)
            {
                if (pAgent != null && pAgent.IsMasked())
                {
                    //BEHAVIAC_PROFILE("GetTickInfo", true);

                    string bClassName = b.GetClassNameString();

                    //filter out intermediate bt, whose class name is empty
                    if (!string.IsNullOrEmpty(bClassName))
                    {
                        int nodeId = b.GetId();
                        BehaviorTreeTask bt = pAgent != null ? pAgent.btgetcurrent() : null;

                        //TestBehaviorGroup\scratch.xml.EventetTask[0]:enter
                        string bpstr = "";
                        if (bt != null)
                        {
                            string btName = bt.GetName();

                            bpstr = string.Format("{0}.xml->", btName);
                        }

                        bpstr += string.Format("{0}[{1}]", bClassName, nodeId);

                        if (!string.IsNullOrEmpty(action))
                        {
                            bpstr += string.Format(":{0}", action);
                        }

                        return bpstr;
                    }
                }
            }
            #endif
            return string.Empty;
        }
Exemple #14
0
        private static bool reset_handler(BehaviorTask node, Agent pAgent, object user_data)
        {
            node.m_status = EBTStatus.BT_INVALID;

            node.onreset(pAgent);
            node.SetCurrentTask(null);

            return true;
        }
Exemple #15
0
 public virtual void SetCurrentTask(BehaviorTask task)
 {
 }
Exemple #16
0
        public static string GetTickInfo(Agent pAgent, BehaviorTask bt, string action)
        {
            string result = GetTickInfo(pAgent, bt.GetNode(), action);

            return result;
        }
Exemple #17
0
        protected override void addChild(BehaviorTask pBehavior)
        {
            pBehavior.SetParent(this);

            this.m_root = pBehavior;
        }
 protected abstract void addChild(BehaviorTask pBehavior);
        public EBTStatus exec(Agent pAgent, EBTStatus childStatus)
        {
#if !BEHAVIAC_RELEASE
            Debug.Check(this.m_node == null || this.m_node.IsValid(pAgent, this),
                        string.Format("Agent In BT:{0} while the Agent used for: {1}", this.m_node.GetAgentType(), pAgent.GetClassTypeName()));

            string classStr    = (this.m_node != null ? this.m_node.GetClassNameString() : "BT");
            int    nodeId      = (this.m_node != null ? this.m_node.GetId() : -1);
            string taskClassid = string.Format("{0}[{1}]", classStr, nodeId);

            AutoProfileBlockSend profiler_block = new AutoProfileBlockSend(taskClassid, pAgent);
#endif//#if !BEHAVIAC_RELEASE
            bool bEnterResult = false;

            if (this.m_status == EBTStatus.BT_RUNNING)
            {
                bEnterResult = true;
            }
            else
            {
                //reset it to invalid when it was success/failure
                this.m_status = EBTStatus.BT_INVALID;
                bEnterResult  = this.onenter_action(pAgent);
            }

            if (bEnterResult)
            {
#if !BEHAVIAC_RELEASE
                if (Config.IsLoggingOrSocketing)
                {
                    string btStr = BehaviorTask.GetTickInfo(pAgent, this, "update");

                    //empty btStr is for internal BehaviorTreeTask
                    if (!string.IsNullOrEmpty(btStr))
                    {
                        LogManager.Instance.Log(pAgent, btStr, EActionResult.EAR_none, LogMode.ELM_tick);
                    }
                }
#endif
                bool bValid = this.CheckParentUpdatePreconditions(pAgent);

                if (bValid)
                {
                    this.m_status = this.update_current(pAgent, childStatus);
                }
                else
                {
                    this.m_status = EBTStatus.BT_FAILURE;

                    if (this.GetCurrentTask() != null)
                    {
                        this.update_current(pAgent, EBTStatus.BT_FAILURE);
                    }
                }

                if (this.m_status != EBTStatus.BT_RUNNING)
                {
                    //clear it

                    this.onexit_action(pAgent, this.m_status);

                    //this node is possibly ticked by its parent or by the topBranch who records it as currrent node
                    //so, we can't here reset the topBranch's current node
                }
                else
                {
                    BranchTask tree = this.GetTopManageBranchTask();

                    if (tree != null)
                    {
                        tree.SetCurrentTask(this);
                    }
                }
            }
            else
            {
                this.m_status = EBTStatus.BT_FAILURE;
            }

#if !BEHAVIAC_RELEASE
            profiler_block.Close();
#endif

            return(this.m_status);
        }
        public static string GetTickInfo(Agent pAgent, BehaviorTask bt, string action)
        {
            string result = GetTickInfo(pAgent, bt.GetNode(), action);

            return(result);
        }
 public virtual void copyto(BehaviorTask target)
 {
     target.m_status = this.m_status;
 }
Exemple #22
0
 public override void copyto(BehaviorTask target)
 {
     base.copyto(target);
     SelectorLoop.SelectorLoopTask selectorLoopTask = (SelectorLoop.SelectorLoopTask)target;
     selectorLoopTask.m_activeChildIndex = this.m_activeChildIndex;
 }
Exemple #23
0
 public override bool IsValid(Agent pAgent, BehaviorTask pTask)
 {
     return(pTask.GetNode() is SelectorLoop && base.IsValid(pAgent, pTask));
 }
Exemple #24
0
 public override bool IsValid(Agent pAgent, BehaviorTask pTask)
 {
     return((pTask.GetNode() is behaviac.Action) && base.IsValid(pAgent, pTask));
 }
Exemple #25
0
            protected override EBTStatus update(Agent pAgent, EBTStatus childStatus)
            {
                Parallel node  = (Parallel)base.GetNode();
                bool     flag  = false;
                bool     flag2 = false;
                bool     flag3 = false;
                bool     flag4 = true;
                bool     flag5 = true;
                bool     flag6 = node.m_childFinishPolicy == CHILDFINISH_POLICY.CHILDFINISH_LOOP;

                for (int i = 0; i < base.m_children.Count; i++)
                {
                    BehaviorTask task   = base.m_children[i];
                    EBTStatus    status = task.GetStatus();
                    if ((flag6 || (status == EBTStatus.BT_RUNNING)) || (status == EBTStatus.BT_INVALID))
                    {
                        EBTStatus status2 = task.exec(pAgent);
                        switch (status2)
                        {
                        case EBTStatus.BT_FAILURE:
                        {
                            flag2 = true;
                            flag5 = false;
                            continue;
                        }

                        case EBTStatus.BT_SUCCESS:
                        {
                            flag  = true;
                            flag4 = false;
                            continue;
                        }
                        }
                        if (status2 == EBTStatus.BT_RUNNING)
                        {
                            flag3 = true;
                            flag4 = false;
                            flag5 = false;
                        }
                    }
                    else if (status == EBTStatus.BT_SUCCESS)
                    {
                        flag  = true;
                        flag4 = false;
                    }
                    else
                    {
                        flag2 = true;
                        flag5 = false;
                    }
                }
                EBTStatus status3 = !flag3 ? EBTStatus.BT_FAILURE : EBTStatus.BT_RUNNING;

                if (((node.m_failPolicy == FAILURE_POLICY.FAIL_ON_ALL) && flag4) || ((node.m_failPolicy == FAILURE_POLICY.FAIL_ON_ONE) && flag2))
                {
                    status3 = EBTStatus.BT_FAILURE;
                }
                else if (((node.m_succeedPolicy == SUCCESS_POLICY.SUCCEED_ON_ALL) && flag5) || ((node.m_succeedPolicy == SUCCESS_POLICY.SUCCEED_ON_ONE) && flag))
                {
                    status3 = EBTStatus.BT_SUCCESS;
                }
                if ((node.m_exitPolicy == EXIT_POLICY.EXIT_ABORT_RUNNINGSIBLINGS) && ((status3 == EBTStatus.BT_FAILURE) || (status3 == EBTStatus.BT_SUCCESS)))
                {
                    for (int j = 0; j < base.m_children.Count; j++)
                    {
                        BehaviorTask task2 = base.m_children[j];
                        if (task2.GetStatus() == EBTStatus.BT_RUNNING)
                        {
                            task2.abort(pAgent);
                        }
                    }
                }
                return(status3);
            }
            protected override EBTStatus update(Agent pAgent, EBTStatus childStatus)
            {
                Parallel parallel = (Parallel)base.GetNode();
                bool     flag     = false;
                bool     flag2    = false;
                bool     flag3    = false;
                bool     flag4    = true;
                bool     flag5    = true;
                bool     flag6    = parallel.m_childFinishPolicy == CHILDFINISH_POLICY.CHILDFINISH_LOOP;

                for (int i = 0; i < this.m_children.Count; i++)
                {
                    BehaviorTask behaviorTask = this.m_children[i];
                    EBTStatus    status       = behaviorTask.GetStatus();
                    if (flag6 || status == EBTStatus.BT_RUNNING || status == EBTStatus.BT_INVALID)
                    {
                        EBTStatus eBTStatus = behaviorTask.exec(pAgent);
                        if (eBTStatus == EBTStatus.BT_FAILURE)
                        {
                            flag2 = true;
                            flag5 = false;
                        }
                        else if (eBTStatus == EBTStatus.BT_SUCCESS)
                        {
                            flag  = true;
                            flag4 = false;
                        }
                        else if (eBTStatus == EBTStatus.BT_RUNNING)
                        {
                            flag3 = true;
                            flag4 = false;
                            flag5 = false;
                        }
                    }
                    else if (status == EBTStatus.BT_SUCCESS)
                    {
                        flag  = true;
                        flag4 = false;
                    }
                    else
                    {
                        flag2 = true;
                        flag5 = false;
                    }
                }
                EBTStatus eBTStatus2 = flag3 ? EBTStatus.BT_RUNNING : EBTStatus.BT_FAILURE;

                if ((parallel.m_failPolicy == FAILURE_POLICY.FAIL_ON_ALL && flag4) || (parallel.m_failPolicy == FAILURE_POLICY.FAIL_ON_ONE && flag2))
                {
                    eBTStatus2 = EBTStatus.BT_FAILURE;
                }
                else if ((parallel.m_succeedPolicy == SUCCESS_POLICY.SUCCEED_ON_ALL && flag5) || (parallel.m_succeedPolicy == SUCCESS_POLICY.SUCCEED_ON_ONE && flag))
                {
                    eBTStatus2 = EBTStatus.BT_SUCCESS;
                }
                if (parallel.m_exitPolicy == EXIT_POLICY.EXIT_ABORT_RUNNINGSIBLINGS && (eBTStatus2 == EBTStatus.BT_FAILURE || eBTStatus2 == EBTStatus.BT_SUCCESS))
                {
                    for (int j = 0; j < this.m_children.Count; j++)
                    {
                        BehaviorTask behaviorTask2 = this.m_children[j];
                        EBTStatus    status2       = behaviorTask2.GetStatus();
                        if (status2 == EBTStatus.BT_RUNNING)
                        {
                            behaviorTask2.abort(pAgent);
                        }
                    }
                }
                return(eBTStatus2);
            }
 public override bool IsValid(Agent pAgent, BehaviorTask pTask)
 {
     return(pTask.GetNode() is Parallel && base.IsValid(pAgent, pTask));
 }
        protected override void addChild(BehaviorTask pBehavior)
        {
            pBehavior.SetParent(this);

            this.m_children.Add(pBehavior);
        }
 public static void DestroyTask(BehaviorTask task)
 {
 }
 public void SetRootTask(BehaviorTask pRoot)
 {
     this.addChild(pRoot);
 }
Exemple #31
0
        protected override void addChild(BehaviorTask pBehavior)
        {
            pBehavior.SetParent(this);

            this.m_children.Add(pBehavior);
        }
Exemple #32
0
 protected SingeChildTask()
 {
     m_root = null;
 }
Exemple #33
0
        private EBTStatus execCurrentTask(Agent pAgent, EBTStatus childStatus)
        {
            Debug.Check(this.m_currentTask != null && this.m_currentTask.GetStatus() == EBTStatus.BT_RUNNING);

            //this.m_currentTask could be cleared in ::tick, to remember it
            EBTStatus status = this.m_currentTask.exec(pAgent, childStatus);

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

                BranchTask parentBranch = this.m_currentTask.GetParent();

                this.m_currentTask = null;

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

                    if (status == EBTStatus.BT_RUNNING)
                    {
                        return EBTStatus.BT_RUNNING;
                    }

                    Debug.Check(parentBranch == this || parentBranch.m_status == status);
                    if (parentBranch == this)
                    {
                        break;
                    }

                    parentBranch = parentBranch.GetParent();
                }
            }

            return status;
        }
 public virtual void SetCurrentTask(BehaviorTask task)
 {
 }
Exemple #35
0
            protected override EBTStatus update(Agent pAgent, EBTStatus childStatus)
            {
                int num = -1;

                for (int i = 0; i < this.m_children.Count; i++)
                {
                    WithPreconditionTask withPreconditionTask = (WithPreconditionTask)this.m_children[i];
                    BehaviorTask         behaviorTask         = withPreconditionTask.PreconditionNode();
                    EBTStatus            eBTStatus            = behaviorTask.exec(pAgent);
                    if (eBTStatus == EBTStatus.BT_SUCCESS)
                    {
                        num = i;
                        break;
                    }
                }
                if (num != -1)
                {
                    if (this.m_activeChildIndex != -1)
                    {
                        WithPreconditionTask withPreconditionTask2 = (WithPreconditionTask)this.m_children[this.m_activeChildIndex];
                        BehaviorTask         behaviorTask2         = withPreconditionTask2.Action();
                        WithPreconditionTask withPreconditionTask3 = (WithPreconditionTask)this.m_children[num];
                        BehaviorTask         behaviorTask3         = withPreconditionTask3.Action();
                        if (behaviorTask2 != behaviorTask3)
                        {
                            behaviorTask2.abort(pAgent);
                            withPreconditionTask2.abort(pAgent);
                            this.m_activeChildIndex = num;
                        }
                    }
                    for (int j = 0; j < this.m_children.Count; j++)
                    {
                        WithPreconditionTask withPreconditionTask4 = (WithPreconditionTask)this.m_children[j];
                        EBTStatus            eBTStatus2            = withPreconditionTask4.exec(pAgent);
                        if (j >= num)
                        {
                            if (j > num)
                            {
                                BehaviorTask behaviorTask4 = withPreconditionTask4.PreconditionNode();
                                EBTStatus    eBTStatus3    = behaviorTask4.exec(pAgent);
                                if (eBTStatus3 != EBTStatus.BT_SUCCESS)
                                {
                                    goto IL_153;
                                }
                            }
                            BehaviorTask behaviorTask5 = withPreconditionTask4.Action();
                            EBTStatus    eBTStatus4    = behaviorTask5.exec(pAgent);
                            if (eBTStatus4 == EBTStatus.BT_RUNNING)
                            {
                                this.m_activeChildIndex = num;
                            }
                            else if (eBTStatus4 == EBTStatus.BT_FAILURE || eBTStatus4 == EBTStatus.BT_INVALID)
                            {
                                goto IL_153;
                            }
                            return(eBTStatus4);
                        }
                        IL_153 :;
                    }
                }
                return(EBTStatus.BT_FAILURE);
            }
        protected override void addChild(BehaviorTask pBehavior)
        {
            pBehavior.SetParent(this);

            this.m_root = pBehavior;
        }
Exemple #37
0
        protected EBTStatus resume_branch(Agent pAgent, EBTStatus status)
        {
            Debug.Check(this.m_currentTask != null);
            Debug.Check(status == EBTStatus.BT_SUCCESS || status == EBTStatus.BT_FAILURE);

            BranchTask parent = null;

            if (this.m_currentTask.GetNode().IsManagingChildrenAsSubTrees())
            {
                parent = (BranchTask)this.m_currentTask;
            }
            else
            {
                parent = this.m_currentTask.GetParent();
            }

            //clear it as it ends and the next exec might need to set it
            this.m_currentTask = null;

            EBTStatus s = parent.exec(pAgent, status);

            return s;
        }
Exemple #38
0
 public override bool IsValid(Agent pAgent, BehaviorTask pTask)
 {
     return((pTask.GetNode() is Sequence) && base.IsValid(pAgent, pTask));
 }
Exemple #39
0
        public override void copyto(BehaviorTask target)
        {
            base.copyto(target);

            Debug.Check(target is CompositeTask);
            CompositeTask ttask = target as CompositeTask;

            ttask.m_activeChildIndex = this.m_activeChildIndex;

            Debug.Check(this.m_children.Count > 0);
            Debug.Check(this.m_children.Count == ttask.m_children.Count);

            int count = this.m_children.Count;

            for (int i = 0; i < count; ++i)
            {
                BehaviorTask childTask = this.m_children[i];
                BehaviorTask childTTask = ttask.m_children[i];

                childTask.copyto(childTTask);
            }
        }
Exemple #40
0
        protected override void onexit(Agent pAgent, EBTStatus s)
        {
            BehaviorTask pParent = this.GetParent();

            Debug.Check(pParent is SelectorLoop.SelectorLoopTask);
        }
Exemple #41
0
        public override void copyto(BehaviorTask target)
        {
            base.copyto(target);

            // Debug.Check(target is DecoratorTask);
            // DecoratorTask ttask = (DecoratorTask)target;
        }
 public override bool IsValid(Agent pAgent, BehaviorTask pTask)
 {
     return((pTask.GetNode() is DecoratorAlwaysRunning) && base.IsValid(pAgent, pTask));
 }
Exemple #43
0
        public override void copyto(BehaviorTask target)
        {
            base.copyto(target);

            Debug.Check(target is SingeChildTask);
            SingeChildTask ttask = target as SingeChildTask;

            if (this.m_root != null)
            {
                //referencebehavior/query, etc.
                if (ttask.m_root == null)
                {
                    BehaviorNode pNode = this.m_root.GetNode();
                    Debug.Check(pNode is BehaviorTree);
                    ttask.m_root = pNode.CreateAndInitTask();

                    //Debug.Check(ttask.m_root is BehaviorTreeTask);
                    //BehaviorTreeTask btt = ttask.m_root as BehaviorTreeTask;
                    //btt.ModifyId(ttask);
                }

                Debug.Check(ttask.m_root != null);
                this.m_root.copyto(ttask.m_root);
            }
        }
 protected override void addChild(BehaviorTask pBehavior)
 {
     base.addChild(pBehavior);
 }
Exemple #45
0
 public static void DestroyTask(BehaviorTask task)
 {
     //nothing
 }
 public override void copyto(BehaviorTask target)
 {
     base.copyto(target);
 }
Exemple #47
0
 public virtual void copyto(BehaviorTask target)
 {
     target.m_status = this.m_status;
 }
Exemple #48
0
        public override void Clear()
        {
            base.Clear();

            this.m_currentTask = null;
        }
Exemple #49
0
        private static bool abort_handler(BehaviorTask node, Agent pAgent, object user_data)
        {
            if (node.m_status == EBTStatus.BT_RUNNING)
            {
                node.onexit_action(pAgent, EBTStatus.BT_FAILURE);

                node.m_status = EBTStatus.BT_FAILURE;
                node.SetCurrentTask(null);
            }

            return true;
        }
Exemple #50
0
 public override bool IsValid(Agent pAgent, BehaviorTask pTask)
 {
     return((pTask.GetNode() is WithPrecondition) && base.IsValid(pAgent, pTask));
 }
Exemple #51
0
 public void SetRootTask(BehaviorTask pRoot)
 {
     this.addChild(pRoot);
 }
Exemple #52
0
        public EBTStatus ParallelUpdate(Agent pAgent, List <BehaviorTask> children)
        {
            bool sawSuccess    = false;
            bool sawFail       = false;
            bool sawRunning    = false;
            bool sawAllFails   = true;
            bool sawAllSuccess = true;

            bool bLoop = (this.m_childFinishPolicy == CHILDFINISH_POLICY.CHILDFINISH_LOOP);

            // go through all m_children
            for (int i = 0; i < children.Count; ++i)
            {
                BehaviorTask pChild = children[i];

                EBTStatus treeStatus = pChild.GetStatus();

                if (bLoop || (treeStatus == EBTStatus.BT_RUNNING || treeStatus == EBTStatus.BT_INVALID))
                {
                    EBTStatus status = pChild.exec(pAgent);

                    if (status == EBTStatus.BT_FAILURE)
                    {
                        sawFail       = true;
                        sawAllSuccess = false;
                    }
                    else if (status == EBTStatus.BT_SUCCESS)
                    {
                        sawSuccess  = true;
                        sawAllFails = false;
                    }
                    else if (status == EBTStatus.BT_RUNNING)
                    {
                        sawRunning    = true;
                        sawAllFails   = false;
                        sawAllSuccess = false;
                    }
                }
                else if (treeStatus == EBTStatus.BT_SUCCESS)
                {
                    sawSuccess  = true;
                    sawAllFails = false;
                }
                else
                {
                    Debug.Check(treeStatus == EBTStatus.BT_FAILURE);

                    sawFail       = true;
                    sawAllSuccess = false;
                }
            }

            EBTStatus result = sawRunning ? EBTStatus.BT_RUNNING : EBTStatus.BT_FAILURE;

            if ((this.m_failPolicy == FAILURE_POLICY.FAIL_ON_ALL && sawAllFails) ||
                (this.m_failPolicy == FAILURE_POLICY.FAIL_ON_ONE && sawFail))
            {
                result = EBTStatus.BT_FAILURE;
            }
            else if ((this.m_succeedPolicy == SUCCESS_POLICY.SUCCEED_ON_ALL && sawAllSuccess) ||
                     (this.m_succeedPolicy == SUCCESS_POLICY.SUCCEED_ON_ONE && sawSuccess))
            {
                result = EBTStatus.BT_SUCCESS;
            }

            //else if (m_failPolicy == FAIL_ON_ALL && m_succeedPolicy == SUCCEED_ON_ALL && sawRunning)
            //{
            //  return EBTStatus.BT_RUNNING;
            //}

            if (this.m_exitPolicy == EXIT_POLICY.EXIT_ABORT_RUNNINGSIBLINGS && (result == EBTStatus.BT_FAILURE || result == EBTStatus.BT_SUCCESS))
            {
                for (int i = 0; i < children.Count; ++i)
                {
                    BehaviorTask pChild = children[i];
                    //Debug.Check(BehaviorTreeTask.DynamicCast(pChild));
                    EBTStatus treeStatus = pChild.GetStatus();

                    if (treeStatus == EBTStatus.BT_RUNNING)
                    {
                        pChild.abort(pAgent);
                    }
                }
            }

            return(result);
        }
 public override void copyto(BehaviorTask target)
 {
     base.copyto(target);
     DecoratorCountLimit.DecoratorCountLimitTask task = (DecoratorCountLimit.DecoratorCountLimitTask)target;
     task.m_bInited = this.m_bInited;
 }
 public override bool IsValid(Agent pAgent, BehaviorTask pTask)
 {
     return(pTask.GetNode() is WaitforSignal && base.IsValid(pAgent, pTask));
 }
Exemple #55
0
 public override void copyto(BehaviorTask target)
 {
     base.copyto(target);
 }
 public override bool IsValid(Agent pAgent, BehaviorTask pTask)
 {
     return((pTask.GetNode() is DecoratorCountLimit) && base.IsValid(pAgent, pTask));
 }