public static void InitializeMods() { int num = 0; foreach (ModMetaData item2 in ModsConfig.ActiveModsInLoadOrder.ToList()) { DeepProfiler.Start("Initializing " + item2); try { if (!item2.RootDir.Exists) { ModsConfig.SetActive(item2.PackageId, active: false); Log.Warning("Failed to find active mod " + item2.Name + "(" + item2.PackageIdPlayerFacing + ") at " + item2.RootDir); } else { ModContentPack item = new ModContentPack(item2.RootDir, item2.PackageId, item2.PackageIdPlayerFacing, num, item2.Name); num++; runningMods.Add(item); } } catch (Exception arg) { Log.Error("Error initializing mod: " + arg); ModsConfig.SetActive(item2.PackageId, active: false); } finally { DeepProfiler.End(); } } }
public static void InitializeMods() { int num = 0; foreach (ModMetaData modMetaData in ModsConfig.ActiveModsInLoadOrder.ToList <ModMetaData>()) { DeepProfiler.Start("Initializing " + modMetaData); if (!modMetaData.RootDir.Exists) { ModsConfig.SetActive(modMetaData.Identifier, false); Log.Warning(string.Concat(new object[] { "Failed to find active mod ", modMetaData.Name, "(", modMetaData.Identifier, ") at ", modMetaData.RootDir }), false); DeepProfiler.End(); } else { ModContentPack item = new ModContentPack(modMetaData.RootDir, num, modMetaData.Name); num++; LoadedModManager.runningMods.Add(item); DeepProfiler.End(); } } }
public static void RebuildModList() { nestedRebuildInProgress = rebuildingModList; rebuildingModList = true; string s = "Rebuilding mods list"; mods.Clear(); WorkshopItems.EnsureInit(); s += "\nAdding official mods from content folder:"; foreach (string item in from d in new DirectoryInfo(GenFilePaths.OfficialModsFolderPath).GetDirectories() select d.FullName) { ModMetaData modMetaData = new ModMetaData(item, official: true); if (TryAddMod(modMetaData)) { s = s + "\n Adding " + modMetaData.ToStringLong(); } } s += "\nAdding mods from mods folder:"; foreach (string item2 in from d in new DirectoryInfo(GenFilePaths.ModsFolderPath).GetDirectories() select d.FullName) { ModMetaData modMetaData2 = new ModMetaData(item2); if (TryAddMod(modMetaData2)) { s = s + "\n Adding " + modMetaData2.ToStringLong(); } } s += "\nAdding mods from Steam:"; foreach (WorkshopItem item3 in WorkshopItems.AllSubscribedItems.Where((WorkshopItem it) => it is WorkshopItem_Mod)) { ModMetaData modMetaData3 = new ModMetaData(item3); if (TryAddMod(modMetaData3)) { s = s + "\n Adding " + modMetaData3.ToStringLong(); } } s += "\nDeactivating not-installed mods:"; ModsConfig.DeactivateNotInstalledMods(delegate(string log) { s = s + "\n " + log; }); if (Prefs.SimulateNotOwningRoyalty) { ModsConfig.SetActive(ModContentPack.RoyaltyModPackageId, active: false); } if (mods.Count((ModMetaData m) => m.Active) == 0) { s += "\nThere are no active mods. Activating Core mod."; mods.First((ModMetaData m) => m.IsCoreMod).Active = true; } RecacheRoyaltyInstalled(); if (Prefs.LogVerbose) { Log.Message(s); } rebuildingModList = false; nestedRebuildInProgress = false; }
public static void LoadAllActiveMods() { XmlInheritance.Clear(); int num = 0; foreach (ModMetaData item2 in ModsConfig.ActiveModsInLoadOrder.ToList()) { DeepProfiler.Start("Initializing " + item2); if (!item2.RootDir.Exists) { ModsConfig.SetActive(item2.Identifier, false); Log.Warning("Failed to find active mod " + item2.Name + "(" + item2.Identifier + ") at " + item2.RootDir); DeepProfiler.End(); } else { ModContentPack item = new ModContentPack(item2.RootDir, num, item2.Name); num++; LoadedModManager.runningMods.Add(item); DeepProfiler.End(); } } for (int i = 0; i < LoadedModManager.runningMods.Count; i++) { ModContentPack modContentPack = LoadedModManager.runningMods[i]; DeepProfiler.Start("Loading " + modContentPack + " content"); modContentPack.ReloadContent(); DeepProfiler.End(); } foreach (Type item3 in typeof(Mod).InstantiableDescendantsAndSelf()) { if (!LoadedModManager.runningModClasses.ContainsKey(item3)) { ModContentPack modContentPack2 = (from modpack in LoadedModManager.runningMods where modpack.assemblies.loadedAssemblies.Contains(item3.Assembly) select modpack).FirstOrDefault(); LoadedModManager.runningModClasses[item3] = (Mod)Activator.CreateInstance(item3, modContentPack2); } } for (int j = 0; j < LoadedModManager.runningMods.Count; j++) { ModContentPack modContentPack3 = LoadedModManager.runningMods[j]; DeepProfiler.Start("Loading " + modContentPack3); modContentPack3.LoadDefs(LoadedModManager.runningMods.SelectMany((ModContentPack rm) => rm.Patches)); DeepProfiler.End(); } foreach (ModContentPack runningMod in LoadedModManager.runningMods) { foreach (PatchOperation patch in runningMod.Patches) { patch.Complete(runningMod.Name); } runningMod.ClearPatchesCache(); } XmlInheritance.Clear(); }
public static void InitializeMods() { int num = 0; foreach (ModMetaData current in ModsConfig.ActiveModsInLoadOrder.ToList <ModMetaData>()) { DeepProfiler.Start("Initializing " + current); try { if (!current.RootDir.Exists) { ModsConfig.SetActive(current.Identifier, false); Log.Warning(string.Concat(new object[] { "Failed to find active mod ", current.Name, "(", current.Identifier, ") at ", current.RootDir }), false); } else { ModContentPack item = new ModContentPack(current.RootDir, num, current.Name); num++; LoadedModManager.runningMods.Add(item); } } catch (Exception arg) { Log.Error("Error initializing mod: " + arg, false); ModsConfig.SetActive(current.Identifier, false); } finally { DeepProfiler.End(); } } }
public static void SetActive(ModMetaData mod, bool active) { ModsConfig.SetActive(mod.Identifier, active); }
public static void LoadAllActiveMods() { XmlInheritance.Clear(); int num = 0; foreach (ModMetaData current in ModsConfig.ActiveModsInLoadOrder.ToList <ModMetaData>()) { DeepProfiler.Start("Initializing " + current); if (!current.RootDir.Exists) { ModsConfig.SetActive(current.Identifier, false); Log.Warning(string.Concat(new object[] { "Failed to find active mod ", current.Name, "(", current.Identifier, ") at ", current.RootDir })); DeepProfiler.End(); } else { ModContentPack item = new ModContentPack(current.RootDir, num, current.Name); num++; LoadedModManager.runningMods.Add(item); DeepProfiler.End(); } } for (int i = 0; i < LoadedModManager.runningMods.Count; i++) { ModContentPack modContentPack = LoadedModManager.runningMods[i]; DeepProfiler.Start("Loading " + modContentPack + " content"); modContentPack.ReloadContent(); DeepProfiler.End(); } foreach (Type type in typeof(Mod).InstantiableDescendantsAndSelf()) { if (!LoadedModManager.runningModClasses.ContainsKey(type)) { ModContentPack modContentPack2 = (from modpack in LoadedModManager.runningMods where modpack.assemblies.loadedAssemblies.Contains(type.Assembly) select modpack).FirstOrDefault <ModContentPack>(); LoadedModManager.runningModClasses[type] = (Mod)Activator.CreateInstance(type, new object[] { modContentPack2 }); } } for (int j = 0; j < LoadedModManager.runningMods.Count; j++) { ModContentPack modContentPack3 = LoadedModManager.runningMods[j]; DeepProfiler.Start("Loading " + modContentPack3); modContentPack3.LoadDefs(LoadedModManager.runningMods.SelectMany((ModContentPack rm) => rm.Patches)); DeepProfiler.End(); } foreach (ModContentPack current2 in LoadedModManager.runningMods) { foreach (PatchOperation current3 in current2.Patches) { current3.Complete(current2.Name); } current2.ClearPatchesCache(); } XmlInheritance.Clear(); }