Exemplo n.º 1
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.º 2
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);
            }