public virtual void Init(ModManager modManager, GameManager gameManager) { this.gameManager = gameManager; this.modManager = modManager; modInstallPath = Path.Combine(Application.persistentDataPath, "Mods"); Directory.CreateDirectory(modInstallPath); modDirectory = new ModDirectory(modInstallPath, true, false); Mod.DefaultDirectory = modDirectory; inited = true; gameManager.ConsoleWindow.WriteLine($"ModLoader initialized. Path: {modInstallPath}"); UpdateModList(); List <string> loadedMods = SaveLoadService.Load <List <string> >(""); if (loadedMods == null) { loadedMods = new List <string>(); } List <string> unloadedMods = LoadMods(loadedMods); foreach (string um in unloadedMods) { loadedMods.Remove(um); } SaveLoadService.Save(modsLoadedFileName, JsonUtility.ToJson(loadedMods)); }
public ModMergeContext(IEnumerable <ModConflictDescriptor> source, Action <ModMergeContext> save) { Result = new MergedMod("Merge result", source); modFiles = Result.Files; LeftBefore = ReactiveCommand.Create <ModFileToMerge>(DoBefore); LeftAfter = ReactiveCommand.Create <ModFileToMerge>(DoAfter); RightBefore = ReactiveCommand.Create <ModFileToMerge>(DoBefore); RightAfter = ReactiveCommand.Create <ModFileToMerge>(DoAfter); saveAction = save; Save = ReactiveCommand.Create(DoSave, _canSave); _rootDirectory = ModDirectory.CreateRoot(Result.ToModConflictDescriptor()); }
public virtual void UpdateModList() { if (!inited) { gameManager.ConsoleWindow.WriteLine("ModLoader was not initialized, can't update mod list."); return; } modList.Clear(); // Create a list of the mods we have in the mod directory. if (modDirectory.HasMods) { foreach (string modName in modDirectory.GetModNames()) { ModInfo mi = new ModInfo(); mi.path = modDirectory.GetModPath(modName); mi.fileName = modName; IModInfo modInfo = modDirectory.GetMod(mi.fileName); mi.modName = modInfo.NameInfo.ModName; mi.identifier = $"{modInfo.ModAuthor.ToLower()}.{modInfo.NameInfo.ModName.ToLower()}"; modList.Add(mi); } } // Add mods from the command line. if (Mod.CommandLine.HasMods) { foreach (Uri modPath in Mod.CommandLine.AllMods) { ModInfo mi = new ModInfo(); mi.commandLine = true; mi.path = modPath; mi.fileName = System.IO.Path.GetFileName(modPath.LocalPath); IModInfo modInfo = ModDirectory.GetMod(new FileInfo(mi.path.LocalPath)); mi.modName = modInfo.NameInfo.ModName; mi.identifier = $"{modInfo.ModAuthor.ToLower()}.{modInfo.NameInfo.ModName.ToLower()}"; modList.Add(mi); } } }
public IModInfo GetModInfo(ModInfo modInfo) { return(ModDirectory.GetMod(new FileInfo(modInfo.path.LocalPath))); }