ModSaveBackups
This Sailwind mod creates separate save files for your mod data and also handles making and loading backups.
模組介紹 作者原文
ModSaveBackups
Intended to be used mainly by modders as a dependency, but can also be used by players.
Incorporates the ModSave class from SailwindModdingHelper by App24 so now
this can be more thought of as ModSave with Backups.
Using this mod will allow you to create a save file for you Sailwind mod data separate from the main save file for the game.
This mod will also create backups of that mod save file when the game makes backups of the main save file. If you load a backup
save then the corresponding backup mod save file will be loaded.
Usage
Make a Serializable save container class to hold the data you wish to save:
[Serializable]
public class ExampleSaveContainer
{
public Dictionary exampleDict;
public bool exampleBool;
}
Then make a patch to save the data on save and a patch to load the data on load:
[HarmonyPatch(typeof(SaveLoadManager))]
private class SaveLoadManagerPatches
{
[HarmonyPostfix]
[HarmonyPatch("SaveModData")]
public static void DoSaveGamePatch()
{
var saveContainer = new ExampleSaveContainer();
saveContainer.exampleDict = MyModGameObject.instance.exampleDict.ToDictionary(
entry => entry.Key,
entry => entry.Value);
saveContainer.exampleBool = MyModGameObject.instance.exampleBool;
ModSave.Save(Plugin.instance.Info, saveContainer);
}
[HarmonyPostfix]
[HarmonyPatch("LoadModData")]
public static void LoadModDataPatch()
{
if (!ModSave.Load(Plugin.instance.Info, out ExampleSaveContainer saveContainer))
{
Plugin.logger.LogWarning("Save file loading failed. If this is the first time loading this save with this mod, this is normal.");
return;
}
if (saveContainer.portBadges!= null)
{
LoadDictionary(saveContainer.portBadges, PortsVisitedUI.instance.portBadges);
foreach (KeyValuePair item in saveContainer.exampleDict)
{
if (MyModGameObject.instance.exampleDict.ContainsKey(item.Key))
{
MyModGameObject.instance.exampleDict[item.Key] = item.Value;
continue;
}
Plugin.logger.LogWarning($"LoadData: {item.Key} not found in game");
}
}
if (saveContainer.exampleBool!= null)
MyModGameObject.instance.exampleBool = saveContainer.exampleBool
}
}
Requires
- BepInEx 5.4.23
Installation
Place the ModSaveBackups.dll into the Sailwind/BepInEx/Plugins folder.
Consider supporting me 🤗
安裝與使用 安裝:按包內說明操作
- 解壓本站下載的壓縮包,先讀包內的 readme / 說明檔案。
- 多數模組依賴遊戲的模組載入器:常見做法是用社群模組管理器(如 r2modman)選中本遊戲安裝,由管理器自動處理載入器與依賴。
- 手動安裝時,把模組檔案放進遊戲目錄下對應的 Mod / plugins 資料夾。
- 啟動遊戲確認載入成功;帶「前置依賴」的模組需要把依賴一併安裝。
不同模組的安裝位置差異較大,包內說明是最可靠的依據。
下面這些內容需要先安裝,否則該模組不會生效: