Exemplo n.º 1
0
        /**
         * return the path relative to the workspace path
         */

        public string GetName()
        {
            Debug.Check(this.m_node is BehaviorTree);
            BehaviorTree bt = this.m_node as BehaviorTree;

            Debug.Check(bt != null);
            return(bt.GetName());
        }
Exemplo n.º 2
0
        public void btunloadall()
        {
            ListView <BehaviorTree> listView = new ListView <BehaviorTree>();

            using (ListView <BehaviorTreeTask> .Enumerator enumerator = this.BehaviorTreeTasks.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    BehaviorTreeTask current      = enumerator.get_Current();
                    BehaviorNode     node         = current.GetNode();
                    BehaviorTree     behaviorTree = (BehaviorTree)node;
                    bool             flag         = false;
                    using (ListView <BehaviorTree> .Enumerator enumerator2 = listView.GetEnumerator())
                    {
                        while (enumerator2.MoveNext())
                        {
                            BehaviorTree current2 = enumerator2.get_Current();
                            if (current2 == behaviorTree)
                            {
                                flag = true;
                                break;
                            }
                        }
                    }
                    if (!flag)
                    {
                        listView.Add(behaviorTree);
                    }
                    Workspace.DestroyBehaviorTreeTask(current, this);
                }
            }
            using (ListView <BehaviorTree> .Enumerator enumerator3 = listView.GetEnumerator())
            {
                while (enumerator3.MoveNext())
                {
                    BehaviorTree current3 = enumerator3.get_Current();
                    this.btunload_pars(current3);
                    Workspace.UnLoad(current3.GetName());
                }
            }
            this.BehaviorTreeTasks.Clear();
            this.m_currentBT = null;
            this.BTStack.Clear();
            this.Variables.Unload();
        }
Exemplo n.º 3
0
            private bool ReQuery(Agent pAgent)
            {
                Query pQueryNode = this.GetNode() as Query;

                if (pQueryNode != null)
                {
                    List <Query.Descriptor_t> qd = pQueryNode.GetDescriptors();

                    if (qd.Count > 0)
                    {
                        Dictionary <string, BehaviorTree> bs = Workspace.Instance.GetBehaviorTrees();

                        BehaviorTree btFound       = null;
                        float        similarityMax = -1.0f;

                        var e = bs.Values.GetEnumerator();
                        while (e.MoveNext())
                        {
                            string domains = e.Current.GetDomains();

                            if (string.IsNullOrEmpty(pQueryNode.m_domain) || (!string.IsNullOrEmpty(domains) && domains.IndexOf(pQueryNode.m_domain) != -1))
                            {
                                List <BehaviorTree.Descriptor_t> bd = e.Current.GetDescriptors();
                                float similarity = pQueryNode.ComputeSimilarity(qd, bd);

                                if (similarity > similarityMax)
                                {
                                    similarityMax = similarity;
                                    btFound       = e.Current;
                                }
                            }
                        }

                        if (btFound != null)
                        {
                            pAgent.btreferencetree(btFound.GetName());
                            //pAgent.btexec();

                            return(true);
                        }
                    }
                }

                return(false);
            }
Exemplo n.º 4
0
        private static string GetParentTreeName(BehaviorNode n)
        {
            string btName = null;

            if (n is ReferencedBehavior)
            {
                n = n.Parent;
            }

            bool bIsTree    = false;
            bool bIsRefTree = false;

            while (n != null)
            {
                bIsTree    = (n is BehaviorTree);
                bIsRefTree = (n is ReferencedBehavior);

                if (bIsTree || bIsRefTree)
                {
                    break;
                }

                n = n.Parent;
            }

            if (bIsTree)
            {
                BehaviorTree bt = n as BehaviorTree;
                btName = bt.GetName();
            }
            else if (bIsRefTree)
            {
                ReferencedBehavior refTree = n as ReferencedBehavior;
                btName = refTree.ReferencedTree;
            }
            else
            {
                Debug.Check(false);
            }

            return(btName);
        }
Exemplo n.º 5
0
            private bool ReQuery(Agent pAgent)
            {
                Query query = base.GetNode() as Query;

                if (query != null)
                {
                    List <Query.Descriptor_t> descriptors = query.GetDescriptors();
                    if (descriptors.get_Count() > 0)
                    {
                        DictionaryView <string, BehaviorTree> behaviorTrees = Workspace.GetBehaviorTrees();
                        BehaviorTree behaviorTree = null;
                        float        num          = -1f;
                        using (DictionaryView <string, BehaviorTree> .Enumerator enumerator = behaviorTrees.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                KeyValuePair <string, BehaviorTree> current = enumerator.get_Current();
                                BehaviorTree value   = current.get_Value();
                                string       domains = value.GetDomains();
                                if (string.IsNullOrEmpty(query.m_domain) || (!string.IsNullOrEmpty(domains) && domains.IndexOf(query.m_domain) != -1))
                                {
                                    List <BehaviorTree.Descriptor_t> descriptors2 = value.GetDescriptors();
                                    float num2 = query.ComputeSimilarity(descriptors, descriptors2);
                                    if (num2 > num)
                                    {
                                        num          = num2;
                                        behaviorTree = value;
                                    }
                                }
                            }
                        }
                        if (behaviorTree != null)
                        {
                            pAgent.btreferencetree(behaviorTree.GetName());
                            return(true);
                        }
                    }
                }
                return(false);
            }
Exemplo n.º 6
0
            private bool ReQuery(Agent pAgent)
            {
                Query node = base.GetNode() as Query;

                if (node != null)
                {
                    List <Query.Descriptor_t> descriptors = node.GetDescriptors();
                    if (descriptors.Count > 0)
                    {
                        DictionaryView <string, BehaviorTree> behaviorTrees = Workspace.GetBehaviorTrees();
                        BehaviorTree tree = null;
                        float        num  = -1f;
                        foreach (KeyValuePair <string, BehaviorTree> pair in behaviorTrees)
                        {
                            BehaviorTree tree2   = pair.Value;
                            string       domains = tree2.GetDomains();
                            if (string.IsNullOrEmpty(node.m_domain) || (!string.IsNullOrEmpty(domains) && (domains.IndexOf(node.m_domain) != -1)))
                            {
                                List <BehaviorTree.Descriptor_t> c = tree2.GetDescriptors();
                                float num2 = node.ComputeSimilarity(descriptors, c);
                                if (num2 > num)
                                {
                                    num  = num2;
                                    tree = tree2;
                                }
                            }
                        }
                        if (tree != null)
                        {
                            pAgent.btreferencetree(tree.GetName());
                            return(true);
                        }
                    }
                }
                return(false);
            }
Exemplo n.º 7
0
        public string GetName()
        {
            BehaviorTree node = base.m_node as BehaviorTree;

            return(node.GetName());
        }
Exemplo n.º 8
0
        public string GetName()
        {
            BehaviorTree behaviorTree = this.m_node as BehaviorTree;

            return(behaviorTree.GetName());
        }