Browse Source

[2.0.6.6] Added SaveStorage fix for compatibility with other mods

Zariteis 3 months ago
parent
commit
f27dd23876

+ 2 - 2
IronmanChest.cs

@@ -5,10 +5,10 @@ using UnityEngine.SceneManagement;
 
 
 namespace IronmanChest
 namespace IronmanChest
 {
 {
-  [Gadget("IronmanChest")]
+  [Gadget("IronmanChest", RequiredOnClients: false)]
   public class IronmanChest : Gadget<IronmanChest>
   public class IronmanChest : Gadget<IronmanChest>
   {
   {
-    public const string MOD_VERSION = "1.0"; // Set this to the version of your mod.
+    public const string MOD_VERSION = "1.1"; // Set this to the version of your mod.
     public const string CONFIG_VERSION = "1.0"; // Increment this whenever you change your mod's config file.
     public const string CONFIG_VERSION = "1.0"; // Increment this whenever you change your mod's config file.
 
 
     public override IGadgetConfigMenu GetConfigMenu() { return null; }
     public override IGadgetConfigMenu GetConfigMenu() { return null; }

+ 1 - 1
Patches/Patch_GameScript_EraseCharacter.cs

@@ -12,7 +12,7 @@ namespace IronmanChest.Patches
 {
 {
 
 
   [HarmonyPatch(typeof(GameScript))]
   [HarmonyPatch(typeof(GameScript))]
-  [HarmonyPatch("EraseCharacter")]
+  [HarmonyPatch(nameof(GameScript.EraseCharacter))]
   [HarmonyGadget("IronmanChest")]
   [HarmonyGadget("IronmanChest")]
   public static class Patch_GameScript_EraseCharacter
   public static class Patch_GameScript_EraseCharacter
   {
   {

+ 1 - 1
Patches/Patch_GameScript_LoadGame.cs

@@ -5,7 +5,7 @@ namespace IronmanChest.Patches
 {
 {
 
 
   [HarmonyPatch(typeof(GameScript))]
   [HarmonyPatch(typeof(GameScript))]
-  [HarmonyPatch("LoadGame")]
+  [HarmonyPatch(nameof(GameScript.LoadGame))]
   [HarmonyGadget("IronmanChest")]
   [HarmonyGadget("IronmanChest")]
   public static class Patch_GameScript_LoadGame
   public static class Patch_GameScript_LoadGame
   {
   {

+ 1 - 1
Patches/Patch_GameScript_Retry.cs

@@ -12,7 +12,7 @@ namespace IronmanChest.Patches
 {
 {
 
 
   [HarmonyPatch(typeof(GameScript))]
   [HarmonyPatch(typeof(GameScript))]
-  [HarmonyPatch("Retry")]
+  [HarmonyPatch(nameof(GameScript.Retry))]
   [HarmonyGadget("IronmanChest")]
   [HarmonyGadget("IronmanChest")]
   public static class Patch_GameScript_Retry
   public static class Patch_GameScript_Retry
   {
   {

+ 1 - 1
Patches/Patch_GameScript_SaveGame.cs

@@ -5,7 +5,7 @@ namespace IronmanChest.Patches
 {
 {
 
 
   [HarmonyPatch(typeof(GameScript))]
   [HarmonyPatch(typeof(GameScript))]
-  [HarmonyPatch("SaveGame")]
+  [HarmonyPatch(nameof(GameScript.SaveGame))]
   [HarmonyGadget("IronmanChest")]
   [HarmonyGadget("IronmanChest")]
   public static class Patch_GameScript_SaveGame
   public static class Patch_GameScript_SaveGame
   {
   {

+ 57 - 0
Patches/Patch_GameScript_SaveStorage.cs

@@ -0,0 +1,57 @@
+using GadgetCore.API;
+using HarmonyLib;
+
+namespace IronmanChest.Patches
+{
+
+  [HarmonyPatch(typeof(GameScript))]
+  [HarmonyPatch(nameof(GameScript.SaveStorage))]
+  [HarmonyGadget("IronmanChest")]
+  public static class Patch_GameScript_SaveStorage
+  {
+    [HarmonyPrefix]
+    public static void Prefix(GameScript __instance, Item[] ___storage, ref int ___storageLevel)
+    {
+      if (Menuu.curProfession == 1)
+      {
+        PreviewLabs.PlayerPrefs.SetInt(Menuu.curChar + "ironmanstorageLevel", ___storageLevel);
+        for (int i = 0; i < Core.settingAmountPages * Core.settingAmountSlots; i++)
+        {
+          PreviewLabs.PlayerPrefs.SetInt(Menuu.curChar + "ironmanstorage" + i + "id", ___storage[i].id);
+          PreviewLabs.PlayerPrefs.SetInt(Menuu.curChar + "ironmanstorage" + i + "q", ___storage[i].q);
+          PreviewLabs.PlayerPrefs.SetInt(Menuu.curChar + "ironmanstorage" + i + "exp", ___storage[i].exp);
+          PreviewLabs.PlayerPrefs.SetInt(Menuu.curChar + "ironmanstorage" + i + "tier", ___storage[i].tier);
+          PreviewLabs.PlayerPrefs.SetInt(Menuu.curChar + "ironmanstorage" + i + "corrupted", ___storage[i].corrupted);
+          PreviewLabs.PlayerPrefs.SetInt(Menuu.curChar + "ironmanstorage" + i + "a0", ___storage[i].aspect[0]);
+          PreviewLabs.PlayerPrefs.SetInt(Menuu.curChar + "ironmanstorage" + i + "a1", ___storage[i].aspect[1]);
+          PreviewLabs.PlayerPrefs.SetInt(Menuu.curChar + "ironmanstorage" + i + "a2", ___storage[i].aspect[2]);
+          PreviewLabs.PlayerPrefs.SetInt(Menuu.curChar + "ironmanstorage" + i + "aL0", ___storage[i].aspectLvl[0]);
+          PreviewLabs.PlayerPrefs.SetInt(Menuu.curChar + "ironmanstorage" + i + "aL1", ___storage[i].aspectLvl[1]);
+          PreviewLabs.PlayerPrefs.SetInt(Menuu.curChar + "ironmanstorage" + i + "aL2", ___storage[i].aspectLvl[2]);
+        }
+        ___storageLevel = PreviewLabs.PlayerPrefs.GetInt("storageLevel");
+        for (int i = 0; i < Core.settingAmountPages * Core.settingAmountSlots; i++)
+        {
+          ___storage[i].id = PreviewLabs.PlayerPrefs.GetInt("storage" + i + "id");
+          ___storage[i].q = PreviewLabs.PlayerPrefs.GetInt("storage" + i + "q");
+          ___storage[i].exp = PreviewLabs.PlayerPrefs.GetInt("storage" + i + "exp");
+          ___storage[i].tier = PreviewLabs.PlayerPrefs.GetInt("storage" + i + "tier");
+          ___storage[i].corrupted = PreviewLabs.PlayerPrefs.GetInt("storage" + i + "corrupted");
+          ___storage[i].aspect[0] = PreviewLabs.PlayerPrefs.GetInt("storage" + i + "a0");
+          ___storage[i].aspect[1] = PreviewLabs.PlayerPrefs.GetInt("storage" + i + "a1");
+          ___storage[i].aspect[2] = PreviewLabs.PlayerPrefs.GetInt("storage" + i + "a2");
+          ___storage[i].aspectLvl[0] = PreviewLabs.PlayerPrefs.GetInt("storage" + i + "aL0");
+          ___storage[i].aspectLvl[1] = PreviewLabs.PlayerPrefs.GetInt("storage" + i + "aL1");
+          ___storage[i].aspectLvl[2] = PreviewLabs.PlayerPrefs.GetInt("storage" + i + "aL2");
+        }
+      }
+    }
+
+    [HarmonyPostfix]
+    [HarmonyPriority(Priority.Low)]
+    public static void Postfix(GameScript __instance, Item[] ___storage, ref int ___storageLevel)
+    {
+      Patch_GameScript_LoadGame.Postfix(__instance, ___storage, ref ___storageLevel);
+    }
+  }
+}

+ 1 - 1
Patches/Patch_GameScript_UpgradeStorage.cs

@@ -5,7 +5,7 @@ namespace IronmanChest.Patches
 {
 {
 
 
   [HarmonyPatch(typeof(GameScript))]
   [HarmonyPatch(typeof(GameScript))]
-  [HarmonyPatch("UpgradeStorage")]
+  [HarmonyPatch(nameof(GameScript.UpgradeStorage))]
   [HarmonyGadget("IronmanChest")]
   [HarmonyGadget("IronmanChest")]
   public static class Patch_GameScript_UpgradeStorage
   public static class Patch_GameScript_UpgradeStorage
   {
   {

+ 1 - 1
Patches/Patch_Menuu_EraseCharacter.cs

@@ -5,7 +5,7 @@ namespace IronmanChest.Patches
 {
 {
 
 
   [HarmonyPatch(typeof(Menuu))]
   [HarmonyPatch(typeof(Menuu))]
-  [HarmonyPatch("EraseCharacter")]
+  [HarmonyPatch(nameof(Menuu.EraseCharacter))]
   [HarmonyGadget("IronmanChest")]
   [HarmonyGadget("IronmanChest")]
   public static class Patch_Menuu_EraseCharacter
   public static class Patch_Menuu_EraseCharacter
   {
   {

+ 1 - 1
Patches/Patch_PlayerScript_Update.cs

@@ -12,7 +12,7 @@ namespace IronmanChest.Patches
 {
 {
 
 
   [HarmonyPatch(typeof(PlayerScript))]
   [HarmonyPatch(typeof(PlayerScript))]
-  [HarmonyPatch("Update")]
+  [HarmonyPatch(nameof(PlayerScript.Update))]
   [HarmonyGadget("IronmanChest")]
   [HarmonyGadget("IronmanChest")]
   public static class Patch_PlayerScript_Update
   public static class Patch_PlayerScript_Update
   {
   {