Esempio n. 1
0
        public static void AddAllInMods()
        {
            HashSet <string> hashSet = new HashSet <string>();

            foreach (ModContentPack item in (from m in LoadedModManager.RunningMods
                                             orderby m.OverwritePriority
                                             select m).ThenBy((ModContentPack x) => LoadedModManager.RunningModsListForReading.IndexOf(x)))
            {
                hashSet.Clear();
                foreach (T item2 in GenDefDatabase.DefsToGoInDatabase <T>(item))
                {
                    if (hashSet.Contains(item2.defName))
                    {
                        Log.Error("Mod " + item + " has multiple " + typeof(T) + "s named " + item2.defName + ". Skipping.");
                    }
                    else
                    {
                        if (item2.defName == "UnnamedDef")
                        {
                            string text = "Unnamed" + typeof(T).Name + Rand.Range(1, 100000).ToString() + "A";
                            Log.Error(typeof(T).Name + " in " + item.ToString() + " with label " + item2.label + " lacks a defName. Giving name " + text);
                            item2.defName = text;
                        }
                        if (defsByName.TryGetValue(item2.defName, out T value))
                        {
                            Remove(value);
                        }
                        Add(item2);
                    }
                }
            }
        }
Esempio n. 2
0
        public static void AddAllInMods()
        {
            HashSet <string> hashSet = new HashSet <string>();

            foreach (ModContentPack item in Enumerable.ThenBy <ModContentPack, int>(Enumerable.OrderBy <ModContentPack, int>(LoadedModManager.RunningMods, (Func <ModContentPack, int>)((ModContentPack m) => m.OverwritePriority)), (Func <ModContentPack, int>)((ModContentPack x) => LoadedModManager.RunningModsListForReading.IndexOf(x))))
            {
                hashSet.Clear();
                foreach (T item2 in GenDefDatabase.DefsToGoInDatabase <T>(item))
                {
                    if (hashSet.Contains(((Def)(object)item2).defName))
                    {
                        Log.Error("Mod " + item + " has multiple " + typeof(T) + "s named " + ((Def)(object)item2).defName + ". Skipping.");
                    }
                    else
                    {
                        if (((Def)(object)item2).defName == "UnnamedDef")
                        {
                            string text = "Unnamed" + typeof(T).Name + Rand.Range(1, 100000).ToString() + "A";
                            Log.Error(typeof(T).Name + " in " + item.ToString() + " with label " + ((Def)(object)item2).label + " lacks a defName. Giving name " + text);
                            ((Def)(object)item2).defName = text;
                        }
                        T def = default(T);
                        if (DefDatabase <T> .defsByName.TryGetValue(((Def)(object)item2).defName, out def))
                        {
                            DefDatabase <T> .Remove(def);
                        }
                        DefDatabase <T> .Add(item2);
                    }
                }
            }
        }
        public static void AddAllInMods()
        {
            HashSet <string> hashSet = new HashSet <string>();

            foreach (ModContentPack modContentPack in (from m in LoadedModManager.RunningMods
                                                       orderby m.OverwritePriority
                                                       select m).ThenBy((ModContentPack x) => LoadedModManager.RunningModsListForReading.IndexOf(x)))
            {
                hashSet.Clear();
                foreach (T t in GenDefDatabase.DefsToGoInDatabase <T>(modContentPack))
                {
                    if (hashSet.Contains(t.defName))
                    {
                        Log.Error(string.Concat(new object[]
                        {
                            "Mod ",
                            modContentPack,
                            " has multiple ",
                            typeof(T),
                            "s named ",
                            t.defName,
                            ". Skipping."
                        }), false);
                    }
                    else
                    {
                        if (t.defName == "UnnamedDef")
                        {
                            string text = "Unnamed" + typeof(T).Name + Rand.Range(1, 100000).ToString() + "A";
                            Log.Error(string.Concat(new string[]
                            {
                                typeof(T).Name,
                                " in ",
                                modContentPack.ToString(),
                                " with label ",
                                t.label,
                                " lacks a defName. Giving name ",
                                text
                            }), false);
                            t.defName = text;
                        }
                        T def;
                        if (DefDatabase <T> .defsByName.TryGetValue(t.defName, out def))
                        {
                            DefDatabase <T> .Remove(def);
                        }
                        DefDatabase <T> .Add(t);
                    }
                }
            }
        }
Esempio n. 4
0
        public static void AddAllInMods()
        {
            HashSet <string> hashSet = new HashSet <string>();

            foreach (ModContentPack item in LoadedModManager.RunningMods.OrderBy((ModContentPack m) => m.OverwritePriority).ThenBy((ModContentPack x) => LoadedModManager.RunningModsListForReading.IndexOf(x)))
            {
                hashSet.Clear();
                foreach (T item2 in GenDefDatabase.DefsToGoInDatabase <T>(item))
                {
                    if (!hashSet.Add(item2.defName))
                    {
                        Log.Error("Mod " + item + " has multiple " + typeof(T) + "s named " + item2.defName + ". Skipping.");
                    }
                    else
                    {
                        AddDef(item2, item.ToString());
                    }
                }
            }
            foreach (T item3 in LoadedModManager.PatchedDefsForReading.OfType <T>())
            {
                AddDef(item3, "Patches");
            }
            void AddDef(T def, string sourceName)
            {
                if (def.defName == "UnnamedDef")
                {
                    string text = "Unnamed" + typeof(T).Name + Rand.Range(1, 100000).ToString() + "A";
                    Log.Error(typeof(T).Name + " in " + sourceName + " with label " + def.label + " lacks a defName. Giving name " + text);
                    def.defName = text;
                }
                if (defsByName.TryGetValue(def.defName, out T value))
                {
                    Remove(value);
                }
                Add(def);
            }
        }
        public static void AddAllInMods()
        {
            HashSet <string> hashSet = new HashSet <string>();

            foreach (ModContentPack item in LoadedModManager.RunningMods.OrderBy((ModContentPack m) => m.OverwritePriority).ThenBy((ModContentPack x) => LoadedModManager.RunningModsListForReading.IndexOf(x)))
            {
                hashSet.Clear();
                foreach (T item2 in GenDefDatabase.DefsToGoInDatabase <T>(item))
                {
                    if (!hashSet.Add(item2.defName))
                    {
                        Log.Error(string.Concat("Mod ", item, " has multiple ", typeof(T), "s named ", item2.defName, ". Skipping."));
                    }
                    else
                    {
                        AddDef(item2, item.ToString());
                    }
                }
            }
            foreach (T item3 in LoadedModManager.PatchedDefsForReading.OfType <T>())
            {
                AddDef(item3, "Patches");
            }