protected override bool onenter(Agent pAgent)
            {
                ReferencedBehavior pNode = this.GetNode() as ReferencedBehavior;

                Debug.Check(pNode != null);

                if (pNode != null)
                {
                    this.m_nextStateId = -1;

                    string szTreePath = pNode.GetReferencedTree(pAgent);

                    //to create the task on demand
                    if (this.m_subTree == null || szTreePath != this.m_subTree.GetName())
                    {
                        if (this.m_subTree != null)
                        {
                            Workspace.Instance.DestroyBehaviorTreeTask(this.m_subTree, pAgent);
                        }

                        this.m_subTree = Workspace.Instance.CreateBehaviorTreeTask(szTreePath);
                        pNode.SetTaskParams(pAgent, this.m_subTree);
                    }
                    else if (this.m_subTree != null)
                    {
                        this.m_subTree.reset(pAgent);
                    }

                    pNode.SetTaskParams(pAgent, this.m_subTree);

                    return(true);
                }

                return(false);
            }
Exemple #2
0
            protected override bool onenter(Agent pAgent)
            {
                ReferencedBehavior pNode = this.GetNode() as ReferencedBehavior;

                Debug.Check(pNode != null);

                this.m_nextStateId = -1;

                pNode.SetTaskParams(pAgent);

                this.m_subTree = Workspace.Instance.CreateBehaviorTreeTask(pNode.m_referencedBehaviorPath);

                return(true);
            }
Exemple #3
0
        protected override bool onenter(Agent pAgent)
        {
            Debug.Check(this.m_node is ReferencedBehavior);
            ReferencedBehavior pNode = this.m_node as ReferencedBehavior;
            Debug.Check(pNode != null);

#if !BEHAVIAC_RELEASE
            _logged = false;
#endif
            pNode.SetTaskParams(pAgent);
            this.m_subTree = Workspace.Instance.CreateBehaviorTreeTask(pNode.ReferencedTree);

            return true;
        }
Exemple #4
0
        public override bool decompose(BehaviorNode node, PlannerTaskComplex seqTask, int depth, Planner planner)
        {
            ReferencedBehavior taskSubTree = (ReferencedBehavior)node;
            bool bOk = false;

            Debug.Check(taskSubTree != null);
            int depth2 = planner.GetAgent().Variables.Depth;

            using (AgentState currentState = planner.GetAgent().Variables.Push(false))
            {
                Agent pAgent = planner.GetAgent();

                string           szTreePath  = taskSubTree.GetReferencedTree(pAgent);
                BehaviorTreeTask subTreeTask = Workspace.Instance.CreateBehaviorTreeTask(szTreePath);

                taskSubTree.SetTaskParams(pAgent, subTreeTask);

                Task task = taskSubTree.RootTaskNode(planner.GetAgent());

                if (task != null)
                {
                    planner.LogPlanReferenceTreeEnter(planner.GetAgent(), taskSubTree);
                    //task.Parent.InstantiatePars(this.LocalVars);

                    BehaviorTreeTask oldCurrentTreeTask = pAgent.ExcutingTreeTask;
                    pAgent.ExcutingTreeTask = subTreeTask;
                    PlannerTask childTask = planner.decomposeNode(task, depth);
                    pAgent.ExcutingTreeTask = oldCurrentTreeTask;

                    if (childTask != null)
                    {
                        //taskSubTree.SetTaskParams(planner.GetAgent(), childTask);
                        PlannerTaskReference subTreeRef = (PlannerTaskReference)seqTask;

                        subTreeRef.SubTreeTask = subTreeTask;
                        seqTask.AddChild(childTask);
                        bOk = true;
                    }

                    //task.Parent.UnInstantiatePars(this.LocalVars);
                    planner.LogPlanReferenceTreeExit(planner.GetAgent(), taskSubTree);
                    Debug.Check(true);
                }
            }

            Debug.Check(planner.GetAgent().Variables.Depth == depth2);
            return(bOk);
        }
Exemple #5
0
        protected override bool onenter(Agent pAgent)
        {
            Debug.Check(this.m_node is ReferencedBehavior);
            ReferencedBehavior pNode = this.m_node as ReferencedBehavior;

            Debug.Check(pNode != null);

#if !BEHAVIAC_RELEASE
            _logged = false;
#endif

            //this.m_subTree = Workspace.Instance.CreateBehaviorTreeTask(pNode.GetReferencedTree(pAgent));
            Debug.Check(this.m_subTree != null);
            pNode.SetTaskParams(pAgent, this.m_subTree);

            this.oldTreeTask_       = pAgent.ExcutingTreeTask;
            pAgent.ExcutingTreeTask = this.m_subTree;

            return(true);
        }
        //~ReferencedBehavior()
        //{
        //}

        public override bool decompose(BehaviorNode node, PlannerTaskComplex seqTask, int depth, Planner planner)
        {
            ReferencedBehavior taskSubTree = (ReferencedBehavior)node;
            bool bOk = false;

            Debug.Check(taskSubTree != null);
            int depth2 = planner.GetAgent().Variables.Depth;

            using (AgentState currentState = planner.GetAgent().Variables.Push(false))
            {
                //planner.agent.Variables.Log(planner.agent, true);
                taskSubTree.SetTaskParams(planner.GetAgent());

                Task task = taskSubTree.RootTaskNode(planner.GetAgent());

                if (task != null)
                {
                    planner.LogPlanReferenceTreeEnter(planner.GetAgent(), taskSubTree);
                    task.Parent.InstantiatePars(planner.GetAgent());

                    PlannerTask childTask = planner.decomposeNode(task, depth);

                    if (childTask != null)
                    {
                        seqTask.AddChild(childTask);
                        bOk = true;
                    }

                    task.Parent.UnInstantiatePars(planner.GetAgent());
                    planner.LogPlanReferenceTreeExit(planner.GetAgent(), taskSubTree);
                    Debug.Check(true);
                }
            }

            Debug.Check(planner.GetAgent().Variables.Depth == depth2);
            return(bOk);
        }