-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlugin.cs
More file actions
33 lines (27 loc) · 1.11 KB
/
Plugin.cs
File metadata and controls
33 lines (27 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using BepInEx;
using HarmonyLib;
namespace DecryptedSaves
{
[BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
public class Plugin : BaseUnityPlugin
{
private void Awake()
{
Harmony harmony = new Harmony(PluginInfo.PLUGIN_GUID);
// Patch save method
harmony.Patch(
AccessTools.Method(typeof(SaveAndLoad), "Saving"),
null,
new HarmonyMethod(AccessTools.Method(typeof(Plugin), "PreventEncryption"))
);
// Plugin startup logic
Logger.LogInfo($"Plugin {PluginInfo.PLUGIN_GUID} is loaded!");
}
[HarmonyPostfix]
public static void PreventEncryption(SaveAndLoad __instance)
{
COTLDataReadWriter<DataManager> _saveFileReadWriter = Traverse.Create(Singleton<SaveAndLoad>.Instance).Field("_saveFileReadWriter").GetValue() as COTLDataReadWriter<DataManager>;
_saveFileReadWriter.Write(DataManager.Instance, SaveAndLoad.MakeSaveSlot(SaveAndLoad.SAVE_SLOT), false, true);
}
}
}