예제 #1
0
 /// <summary>
 /// Disposes SaveAPI <see cref="Hook"/>s, unloads <see cref="AdvancedGameStatsManager"/> and nulls custom <see cref="SaveManager.SaveType"/>s
 /// </summary>
 public static void Unload()
 {
     if (!m_loaded)
     {
         return;
     }
     AdvancedGameSave    = null;
     AdvancedMidGameSave = null;
     saveHook?.Dispose();
     loadHook?.Dispose();
     resetHook?.Dispose();
     beginSessionHook?.Dispose();
     endSessionHook?.Dispose();
     clearAllStatsHook?.Dispose();
     deleteMidGameSaveHook?.Dispose();
     midgameSaveHook?.Dispose();
     invalidateSaveHook?.Dispose();
     revalidateSaveHook?.Dispose();
     frameDelayedInitizlizationHook?.Dispose();
     moveSessionStatsHook?.Dispose();
     prerequisiteHook?.Dispose();
     clearActiveGameDataHook?.Dispose();
     AdvancedGameStatsManager.Save();
     AdvancedGameStatsManager.Unload();
     BreachShopTool.Unload();
     m_loaded = false;
 }
예제 #2
0
 /// <summary>
 /// Call this method in your <see cref="ETGModule.Init"/> method. Adds SaveAPI <see cref="Hook"/>s, loads <see cref="AdvancedGameStatsManager"/> and setups the custom <see cref="SaveManager.SaveType"/>s
 /// </summary>
 /// <param name="prefix">Mod prefix for SaveTypes</param>
 public static void Setup(string prefix)
 {
     if (m_loaded)
     {
         return;
     }
     AdvancedGameSave = new SaveManager.SaveType
     {
         filePattern       = "Slot{0}." + prefix + "Save",
         encrypted         = true,
         backupCount       = 3,
         backupPattern     = "Slot{0}." + prefix + "Backup.{1}",
         backupMinTimeMin  = 45,
         legacyFilePattern = prefix + "GameStatsSlot{0}.txt"
     };
     AdvancedMidGameSave = new SaveManager.SaveType
     {
         filePattern       = "Active{0}." + prefix + "Game",
         legacyFilePattern = prefix + "ActiveSlot{0}.txt",
         encrypted         = true,
         backupCount       = 0,
         backupPattern     = "Active{0}." + prefix + "Backup.{1}",
         backupMinTimeMin  = 60
     };
     for (int i = 0; i < 3; i++)
     {
         SaveManager.SaveSlot saveSlot = (SaveManager.SaveSlot)i;
         SaveTools.SafeMove(Path.Combine(SaveManager.OldSavePath, string.Format(AdvancedGameSave.legacyFilePattern, saveSlot)), Path.Combine(SaveManager.OldSavePath,
                                                                                                                                             string.Format(AdvancedGameSave.filePattern, saveSlot)), false);
         SaveTools.SafeMove(Path.Combine(SaveManager.OldSavePath, string.Format(AdvancedGameSave.filePattern, saveSlot)), Path.Combine(SaveManager.OldSavePath,
                                                                                                                                       string.Format(AdvancedGameSave.filePattern, saveSlot)), false);
         SaveTools.SafeMove(SaveTools.PathCombine(SaveManager.SavePath, "01", string.Format(AdvancedGameSave.filePattern, saveSlot)), Path.Combine(SaveManager.SavePath,
                                                                                                                                                   string.Format(AdvancedGameSave.filePattern, saveSlot)), true);
     }
     AdvancedGameStatsManager.Load();
     saveHook = new Hook(
         typeof(GameStatsManager).GetMethod("Save", BindingFlags.Public | BindingFlags.Static),
         typeof(DaveAPIManager).GetMethod("SaveHook")
         );
     loadHook = new Hook(
         typeof(GameStatsManager).GetMethod("Load", BindingFlags.Public | BindingFlags.Static),
         typeof(DaveAPIManager).GetMethod("LoadHook")
         );
     resetHook = new Hook(
         typeof(GameStatsManager).GetMethod("DANGEROUS_ResetAllStats", BindingFlags.Public | BindingFlags.Static),
         typeof(DaveAPIManager).GetMethod("ResetHook")
         );
     beginSessionHook = new Hook(
         typeof(GameStatsManager).GetMethod("BeginNewSession", BindingFlags.Public | BindingFlags.Instance),
         typeof(DaveAPIManager).GetMethod("BeginSessionHook")
         );
     endSessionHook = new Hook(
         typeof(GameStatsManager).GetMethod("EndSession", BindingFlags.Public | BindingFlags.Instance),
         typeof(DaveAPIManager).GetMethod("EndSessionHook")
         );
     clearAllStatsHook = new Hook(
         typeof(GameStatsManager).GetMethod("ClearAllStatsGlobal", BindingFlags.Public | BindingFlags.Instance),
         typeof(DaveAPIManager).GetMethod("ClearAllStatsHook")
         );
     deleteMidGameSaveHook = new Hook(
         typeof(SaveManager).GetMethod("DeleteCurrentSlotMidGameSave", BindingFlags.Public | BindingFlags.Static),
         typeof(DaveAPIManager).GetMethod("DeleteMidGameSaveHook")
         );
     midgameSaveHook = new Hook(
         typeof(GameManager).GetMethod("DoMidgameSave", BindingFlags.Public | BindingFlags.Static),
         typeof(DaveAPIManager).GetMethod("MidgameSaveHook")
         );
     invalidateSaveHook = new Hook(
         typeof(GameManager).GetMethod("InvalidateMidgameSave", BindingFlags.Public | BindingFlags.Static),
         typeof(DaveAPIManager).GetMethod("InvalidateSaveHook")
         );
     revalidateSaveHook = new Hook(
         typeof(GameManager).GetMethod("RevalidateMidgameSave", BindingFlags.Public | BindingFlags.Static),
         typeof(DaveAPIManager).GetMethod("RevalidateSaveHook")
         );
     frameDelayedInitizlizationHook = new Hook(
         typeof(Dungeon).GetMethod("FrameDelayedMidgameInitialization", BindingFlags.NonPublic | BindingFlags.Instance),
         typeof(DaveAPIManager).GetMethod("FrameDelayedInitizlizationHook")
         );
     moveSessionStatsHook = new Hook(
         typeof(GameStatsManager).GetMethod("MoveSessionStatsToSavedSessionStats", BindingFlags.Public | BindingFlags.Instance),
         typeof(DaveAPIManager).GetMethod("MoveSessionStatsHook")
         );
     prerequisiteHook = new Hook(
         typeof(DungeonPrerequisite).GetMethod("CheckConditionsFulfilled", BindingFlags.Public | BindingFlags.Instance),
         typeof(DaveAPIManager).GetMethod("PrerequisiteHook")
         );
     clearActiveGameDataHook = new Hook(
         typeof(GameManager).GetMethod("ClearActiveGameData", BindingFlags.Public | BindingFlags.Instance),
         typeof(DaveAPIManager).GetMethod("ClearActiveGameDataHook")
         );
     BreachShopTool.DoSetup();
     m_loaded = true;
 }