Ejemplo n.º 1
0
        public void Rehash()
        {
            //Debug.Log("Rehashing Tag " + this.Name);
            PartCategories.Clear();
            VisibleParts.Clear();

            bool newResearched = false;

            foreach (AvailablePart part in IncludedParts)
            {
                if (!ConfigHandler.Instance.HideUnresearchedTags || (ResearchAndDevelopment.PartModelPurchased(part) && ResearchAndDevelopment.PartTechAvailable(part)))
                {
                    PartCategories.Add(part.category);
                    VisibleParts.Add(part.name);
                    newResearched = true;
                }
            }

            VisiblePartCategories.Clear();
            VisiblePartCategories.UnionWith(PartCategories);
            foreach (PartTag child in ChildTags)
            {
                VisibleParts.UnionWith(child.VisibleParts);
                VisiblePartCategories.UnionWith(child.VisiblePartCategories);

                newResearched |= child.Researched;
            }

            isResearched = newResearched;
            if (Parent != null)
            {
                Parent.Rehash();
            }
            UpdateTagList();
        }
Ejemplo n.º 2
0
        internal void AutoTagByMod()
        {
            CreateAllPartTag();

            HashSet <PartTag> smallTags = new HashSet <PartTag>();


            foreach (KeyValuePair <string, HashSet <AvailablePart> > kv in HashedModCatalog)
            {
                if (kv.Key != "")
                {
                    HashSet <AvailablePart> toAdd = new HashSet <AvailablePart>();
                    foreach (AvailablePart modPart in kv.Value)
                    {
                        if (!ConfigHandler.Instance.AutotagOnlyUntagged || !RootTag.VisibleParts.Contains(modPart.title))
                        {
                            toAdd.Add(modPart);
                        }
                    }
                    if (toAdd.Count > 0)
                    {
                        PartTag existingTag           = RootTag.ChildTags.FirstOrDefault(stag => stag.Name == kv.Key);
                        LinkedListNode <PartTag> node = null;
                        if (existingTag != null)
                        {
                            node = RootTag.ChildTags.Find(existingTag);
                        }
                        PartTag tag = new PartTag();
                        tag.Name = kv.Key;
                        if (ResourceProxy.Instance.IconExists(kv.Key))
                        {
                            tag.IconName = kv.Key;
                        }
                        tag.AddParts(toAdd);
                        if (tag.VisibleParts.Count < ConfigHandler.Instance.SmallModTagPartCount)
                        {
                            smallTags.Add(tag);
                        }
                        RootTag.AddChild(tag);
                        AutoGroupTag(tag);
                        if (existingTag != null && node != null)
                        {
                            RootTag.ChildTags.Remove(tag);
                            node.Value.Parent = null;
                            node.Value        = tag;
                            if (tag.IconName == "")
                            {
                                tag.IconName = existingTag.IconName;
                            }
                        }
                    }
                }
            }
            List <PartTag> toDelete = new List <PartTag>();

            foreach (PartTag tag in RootTag.ChildTags)
            {
                if (tag.Name == "Small Mods")
                {
                    toDelete.Add(tag);
                }
            }
            toDelete.ForEach(tag => tag.Delete());
            if (smallTags.Count > 1)
            {
                PartTag smallTag = new PartTag();
                smallTag.Name     = "Small Mods";
                smallTag.IconName = "SmallMods";
                foreach (var tag in smallTags)
                {
                    smallTag.AddChild(tag);
                }
                RootTag.AddChild(smallTag);
            }

            RootTag.Rehash();
        }