Ejemplo n.º 1
0
        private static void Postfix(uGUI_BlueprintsTab __instance)
        {
            if (Core.BlueprintHideList == null)
            {
                GenerateList(__instance);
            }

            foreach (KeyValuePair <TechCategory, List <TechType> > keyValuePair in Core.BlueprintHideList)
            {
                foreach (TechType techType in keyValuePair.Value)
                {
                    if (__instance.entries.ContainsKey(keyValuePair.Key) && __instance.entries[keyValuePair.Key].entries.ContainsKey(techType))
                    {
                        uGUI_BlueprintsTab.CategoryEntry categoryEntry = __instance.entries[keyValuePair.Key];
                        uGUI_BlueprintEntry entry = __instance.entries[keyValuePair.Key].entries[techType];

                        NotificationManager.main.UnregisterTarget(entry);
                        categoryEntry.entries.Remove(techType);
                        Object.Destroy(entry.gameObject);
                        if (categoryEntry.entries.Count == 0)
                        {
                            Object.Destroy(categoryEntry.title.gameObject);
                            Object.Destroy(categoryEntry.canvas.gameObject);
                            __instance.entries.Remove(keyValuePair.Key);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private static void GenerateList(uGUI_BlueprintsTab instance)
        {
            string path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(Core)).Location) + "/Defaults.Json";

            if (!File.Exists(path))
            {
                Core.BlueprintHideList = GenerateDictionary(instance, path);
            }
            if (Core.BlueprintHideList == null)
            {
                Core.BlueprintHideList = GenerateDictionary(instance);
            }
        }
Ejemplo n.º 3
0
        private static Dictionary <TechCategory, List <TechType> > GenerateDictionary(uGUI_BlueprintsTab instance, string path = "")
        {
            var defaults   = new Dictionary <string, List <string> >();
            var dictionary = new Dictionary <TechCategory, List <TechType> >();

            foreach (TechCategory techCategory in instance.entries.Keys)
            {
                defaults[techCategory.ToString()] = new List <string>();
                dictionary[techCategory]          = new List <TechType>();
                foreach (TechType techType in instance.entries[techCategory].entries.Keys)
                {
                    defaults[techCategory.ToString()].Add(techType.AsString());
                    if (Core.TechTypeHidelist.Contains(techType.AsString()) || Core.RecipeBlacklist.Contains(techType.AsString()) || Core.TechCategoryHidelist.Contains(techCategory.ToString()))
                    {
                        dictionary[techCategory].Add(techType);
                    }
                }
                if (defaults[techCategory.ToString()].Count == 0)
                {
                    defaults.Remove(techCategory.ToString());
                }

                if (dictionary[techCategory].Count == 0)
                {
                    dictionary.Remove(techCategory);
                }
            }

            if (path != "")
            {
                using (var writer = new StreamWriter(path))
                {
                    writer.WriteLine(JsonConvert.SerializeObject(defaults, Formatting.Indented));
                }
            }
            defaults.Clear();
            return(dictionary);
        }