using GadgetCore.API;
using HarmonyLib;

namespace StorageExpansion.Patches
{

  [HarmonyPatch(typeof(GameScript))]
  [HarmonyPatch("LoadGame")]
  [HarmonyGadget("StorageExpansion")]
  public static class Patch_GameScript_LoadGame
  {
    [HarmonyPrefix]
    public static void Prefix(GameScript __instance, Item[] ___storage)
		{
			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");
			}
		}
  }
}