using Harmony; using KCM.LoadSaveOverrides; using System; using System.IO; using UnityEngine; namespace KCM { public static class LoadSaveLoadAtPathHook { public static byte[] saveData = new byte[1]; public static string lastLoadedPath = string.Empty; } public static class LoadSaveLoadHook { public static byte[] saveBytes = null; public static bool memoryStreamHook = false; public static MultiplayerSaveContainer saveContainer = null; } [HarmonyPatch(typeof(LoadSave), "LoadAtPath")] public class LoadSaveLoadAtPathCaptureHook { public static void Prefix(string path) { try { if (string.IsNullOrEmpty(path)) return; LoadSaveLoadAtPathHook.lastLoadedPath = path; if (!File.Exists(path)) return; LoadSaveLoadAtPathHook.saveData = File.ReadAllBytes(path); Main.Log($"Captured save bytes from: {path} ({LoadSaveLoadAtPathHook.saveData.Length} bytes)"); } catch (Exception ex) { Main.Log("Failed capturing save bytes from LoadSave.LoadAtPath"); Main.Log(ex); } } } }