using GadgetCore.API;
using HarmonyLib;

namespace StorageExpansion.Patches
{

  [HarmonyPatch(typeof(GameScript))]
  [HarmonyPatch("SaveGame")]
  [HarmonyGadget("StorageExpansion")]
  public static class Patch_GameScript_SaveGame
  {
    [HarmonyPostfix]
    public static void Postfix(GameScript __instance, int dood, Item[] ___storage)
		{
			for (int i = 0; i < Core.settingAmountPages * Core.settingAmountSlots; i++)
			{
				PreviewLabs.PlayerPrefs.SetInt("storage" + i + "id", ___storage[i].id);
				PreviewLabs.PlayerPrefs.SetInt("storage" + i + "q", ___storage[i].q);
				PreviewLabs.PlayerPrefs.SetInt("storage" + i + "exp", ___storage[i].exp);
				PreviewLabs.PlayerPrefs.SetInt("storage" + i + "tier", ___storage[i].tier);
				PreviewLabs.PlayerPrefs.SetInt("storage" + i + "corrupted", ___storage[i].corrupted);
				PreviewLabs.PlayerPrefs.SetInt("storage" + i + "a0", ___storage[i].aspect[0]);
				PreviewLabs.PlayerPrefs.SetInt("storage" + i + "a1", ___storage[i].aspect[1]);
				PreviewLabs.PlayerPrefs.SetInt("storage" + i + "a2", ___storage[i].aspect[2]);
				PreviewLabs.PlayerPrefs.SetInt("storage" + i + "aL0", ___storage[i].aspectLvl[0]);
				PreviewLabs.PlayerPrefs.SetInt("storage" + i + "aL1", ___storage[i].aspectLvl[1]);
				PreviewLabs.PlayerPrefs.SetInt("storage" + i + "aL2", ___storage[i].aspectLvl[2]);
			}
		}
  }
}