Decompiled source of AutoSaver v1.1.1

plugins/Marioalexsan.AutoSaver.dll

Decompiled 6 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using HarmonyLib;
using Marioalexsan.AutoSaver.HarmonyReversePatches;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("Marioalexsan.AutoSaver")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1+afc244d7dad3617ba10a8d8c3874a5c2dd8e1d51")]
[assembly: AssemblyProduct("AutoSaver")]
[assembly: AssemblyTitle("Marioalexsan.AutoSaver")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Marioalexsan.AutoSaver
{
	[BepInPlugin("Marioalexsan.AutoSaver", "AutoSaver", "1.1.1")]
	public class AutoSaverMod : BaseUnityPlugin
	{
		public const string MoreBankTabsIndentifier = "com.16mb.morebanktabs";

		private Harmony _harmony;

		private TimeSpan _elapsedTime;

		private readonly char[] BannedChars;

		private TimeSpan _autosaveInterval;

		private int _saveCountToKeep;

		private readonly string ModDataFolderName;

		public ManualLogSource Logger { get; private set; }

		public static AutoSaverMod Instance { get; private set; }

		public bool SaveOnMapChange { get; private set; }

		public bool CharacterActive { get; private set; }

		public bool AutosaveActive => CharacterActive;

		public bool EnableExperimentalFeatures { get; private set; }

		public KeyCode SaveMultiplayerKeyCode { get; private set; }

		public bool DetectedMoreBankTabsMod { get; private set; }

		public string SanitizedCurrentTime
		{
			get
			{
				string text = DateTime.UtcNow.ToString("yyyy:MM:dd-HH:mm:ss", CultureInfo.InvariantCulture);
				for (int i = 0; i < BannedChars.Length; i++)
				{
					text = text.Replace($"{BannedChars[i]}", "_");
				}
				return text;
			}
		}

		private string ModDataFolderPath => Path.Combine(ProfileDataManager._current._dataPath, ModDataFolderName);

		private string CharacterFolderPath => Path.Combine(ModDataFolderPath, "Characters");

		private string ItemBankFolderPath => Path.Combine(ModDataFolderPath, "ItemBank");

		private string MultiSavesFolderPath => Path.Combine(ModDataFolderPath, "Multi");

		private void Awake()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			Instance = this;
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"AutoSaver patching...");
			_harmony = new Harmony("Marioalexsan.AutoSaver");
			_harmony.PatchAll();
			Logger.LogInfo((object)"AutoSaver configuring...");
			Configure();
			Logger.LogInfo((object)"AutoSaver initialized!");
		}

		private void Configure()
		{
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			int value = ((BaseUnityPlugin)this).Config.Bind<int>("General", "BackupInterval", 4, "Interval between save backups, in minutes (min 1, max 60).").Value;
			value = Math.Max(Math.Min(value, 60), 1);
			_autosaveInterval = TimeSpan.FromMinutes(value);
			_saveCountToKeep = ((BaseUnityPlugin)this).Config.Bind<int>("General", "SavesToKeep", 15, "Maximum number of saves to keep (min 5, max 50).").Value;
			_saveCountToKeep = Math.Max(Math.Min(_saveCountToKeep, 50), 5);
			SaveOnMapChange = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "SaveOnMapChange", false, "Set to true to trigger autosaving whenever a new level is loaded.").Value;
			EnableExperimentalFeatures = ((BaseUnityPlugin)this).Config.Bind<bool>("Experimental", "EnableExperimentalFeatures", false, "Set to true to enable experimental features.").Value;
			SaveMultiplayerKeyCode = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Experimental", "SaveMultiplayerKeyCode", (KeyCode)270, "Key to trigger saving other people's saves in multiplayer under the \"Multi\" folder." + Environment.NewLine + "Note that saves saved in this way are lackluster.").Value;
		}

		internal void GameEntered()
		{
			Logger.LogInfo((object)"Game entered / map switched. Activating character autosaves.");
			ProfileDataManager._current.Load_ItemStorageData();
			RunAutosaves();
			_elapsedTime = TimeSpan.Zero;
			CharacterActive = true;
		}

		internal void GameExited()
		{
			Logger.LogInfo((object)"Game exited. Stopping character autosaves.");
			RunAutosaves();
			_elapsedTime = TimeSpan.Zero;
			CharacterActive = false;
		}

		private void Update()
		{
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			if (!DetectedMoreBankTabsMod && Chainloader.PluginInfos.ContainsKey("com.16mb.morebanktabs"))
			{
				DetectedMoreBankTabsMod = true;
				Logger.LogInfo((object)"Detected MoreBankTabs mod (com.16mb.morebanktabs).");
				Logger.LogInfo((object)"Will try to backup the extra bank tabs.");
			}
			if (AutosaveActive)
			{
				_elapsedTime += TimeSpan.FromSeconds(Time.deltaTime);
				if (_elapsedTime >= _autosaveInterval)
				{
					_elapsedTime = TimeSpan.Zero;
					RunAutosaves();
				}
				else
				{
					if (!CharacterAutoSaver.SaveDone)
					{
						AutosaveCurrentCharacter();
					}
					if (!ItemBankAutoSaver.SaveDone)
					{
						AutosaveCurrentItemBank();
					}
				}
			}
			if (!EnableExperimentalFeatures || !Input.GetKeyDown(SaveMultiplayerKeyCode))
			{
				return;
			}
			Logger.LogInfo((object)"[Experimental] Saving every online player's saves.");
			Player[] array = Object.FindObjectsOfType<Player>();
			foreach (Player val in array)
			{
				Logger.LogInfo((object)("Saving player data for " + val._nickname));
				Directory.CreateDirectory(MultiSavesFolderPath);
				CharacterAutoSaver.TrySaveSpecificProfileToLocation(val, Path.Combine(MultiSavesFolderPath, SanitizePlayerName(val)));
				if (!CharacterAutoSaver.SaveDone)
				{
					Logger.LogWarning((object)$"Failed to do save for {val._nickname}. Current game status is {val._currentGameCondition}.");
				}
			}
		}

		private void RunAutosaves()
		{
			AutosaveCurrentCharacter();
			AutosaveCurrentItemBank();
		}

		public string SanitizePlayerName(Player player)
		{
			string text = player._nickname;
			for (int i = 0; i < BannedChars.Length; i++)
			{
				text = text.Replace($"{BannedChars[i]}", $"_{i}");
			}
			return text;
		}

		public string GetBackupNameForCurrentPlayer()
		{
			return $"{SanitizePlayerName(Player._mainPlayer)}_slot{ProfileDataManager._current._selectedFileIndex}";
		}

		private void RunItemBankGarbageCollector()
		{
			if (!Directory.Exists(ItemBankFolderPath))
			{
				Logger.LogWarning((object)("Couldn't find backup path " + ItemBankFolderPath + " to run garbage collection for."));
				return;
			}
			List<string> list = new List<string>();
			foreach (string item in Directory.EnumerateDirectories(ItemBankFolderPath))
			{
				list.Add(Path.GetFileName(item));
			}
			list.Remove("_latest");
			list.Sort();
			while (list.Count > _saveCountToKeep)
			{
				string path = list[0];
				list.RemoveAt(0);
				string text = Path.Combine(ItemBankFolderPath, path);
				if (!text.Contains(ModDataFolderName))
				{
					throw new InvalidOperationException("Got an invalid folder to delete " + text + ", please notify the mod developer!");
				}
				Directory.Delete(Path.Combine(ItemBankFolderPath, path), recursive: true);
			}
		}

		private void RunCharacterGarbageCollector()
		{
			string text = Path.Combine(CharacterFolderPath, GetBackupNameForCurrentPlayer());
			if (!Directory.Exists(text))
			{
				Logger.LogWarning((object)("Couldn't find backup path " + text + " to run garbage collection for."));
				return;
			}
			List<string> list = new List<string>();
			foreach (string item in Directory.EnumerateFiles(text))
			{
				list.Add(Path.GetFileName(item));
			}
			list.Remove("_latest");
			list.Sort();
			while (list.Count > _saveCountToKeep)
			{
				string path = list[0];
				list.RemoveAt(0);
				string text2 = Path.Combine(CharacterFolderPath, GetBackupNameForCurrentPlayer(), path);
				if (!text2.Contains(ModDataFolderName))
				{
					throw new InvalidOperationException("Got an invalid file to delete " + text2 + ", please notify the mod developer!");
				}
				File.Delete(text2);
			}
		}

		private void AutosaveCurrentItemBank()
		{
			try
			{
				Directory.CreateDirectory(ModDataFolderPath);
				string text = Path.Combine(ItemBankFolderPath, SanitizedCurrentTime);
				Directory.CreateDirectory(text);
				ItemBankAutoSaver.TrySaveCurrentProfileToLocation(text);
				if (ItemBankAutoSaver.SaveDone)
				{
					if (DetectedMoreBankTabsMod)
					{
						ItemBankAutoSaver.SaveModBankTabsToLocation(text);
					}
					string text2 = Path.Combine(ItemBankFolderPath, "_latest");
					Directory.CreateDirectory(text2);
					foreach (string item in Directory.EnumerateFiles(text))
					{
						File.Copy(item, Path.Combine(text2, Path.GetFileName(item)), overwrite: true);
					}
				}
				RunItemBankGarbageCollector();
			}
			catch (Exception arg)
			{
				Logger.LogError((object)"Failed to autosave!");
				Logger.LogError((object)$"Exception message: {arg}");
			}
		}

		private void AutosaveCurrentCharacter()
		{
			try
			{
				if (!Object.op_Implicit((Object)(object)Player._mainPlayer))
				{
					Logger.LogError((object)"Couldn't autosave! No main player found.");
					return;
				}
				Directory.CreateDirectory(ModDataFolderPath);
				string text = Path.Combine(CharacterFolderPath, GetBackupNameForCurrentPlayer());
				Directory.CreateDirectory(text);
				string text2 = Path.Combine(text, SanitizedCurrentTime);
				CharacterAutoSaver.TrySaveCurrentProfileToLocation(text2);
				if (CharacterAutoSaver.SaveDone)
				{
					File.Copy(text2, Path.Combine(text, "_latest"), overwrite: true);
				}
				RunCharacterGarbageCollector();
			}
			catch (Exception arg)
			{
				Logger.LogError((object)"Couldn't autosave!");
				Logger.LogError((object)$"Exception message: {arg}");
			}
		}

		public AutoSaverMod()
		{
			char[] invalidPathChars = Path.GetInvalidPathChars();
			char[] invalidFileNameChars = Path.GetInvalidFileNameChars();
			int num = 0;
			char[] array = new char[invalidPathChars.Length + invalidFileNameChars.Length];
			char[] array2 = invalidPathChars;
			foreach (char c in array2)
			{
				array[num] = c;
				num++;
			}
			char[] array3 = invalidFileNameChars;
			foreach (char c in array3)
			{
				array[num] = c;
				num++;
			}
			BannedChars = array;
			DetectedMoreBankTabsMod = false;
			ModDataFolderName = "Marioalexsan_AutoSaver";
			((BaseUnityPlugin)this)..ctor();
		}
	}
	internal static class ModInfo
	{
		public const string PLUGIN_GUID = "Marioalexsan.AutoSaver";

		public const string PLUGIN_NAME = "AutoSaver";

		public const string PLUGIN_VERSION = "1.1.1";
	}
}
namespace Marioalexsan.AutoSaver.HarmonyReversePatches
{
	[HarmonyPatch(typeof(ProfileDataManager), "Save_ProfileData")]
	internal static class CharacterAutoSaver
	{
		private static string SaveLocationOverride;

		private static string TempContents;

		private static Player TargetPlayer;

		internal static bool SaveDone { get; private set; } = true;


		public static void TrySaveCurrentProfileToLocation(string location)
		{
			if (SaveDone)
			{
				AutoSaverMod.Instance.Logger.LogInfo((object)"Triggering character save process...");
			}
			SaveLocationOverride = location;
			SaveDone = false;
			TargetPlayer = Player._mainPlayer;
			SaveProfileData(ProfileDataManager._current);
		}

		public static void TrySaveSpecificProfileToLocation(Player player, string location)
		{
			if (SaveDone)
			{
				AutoSaverMod.Instance.Logger.LogInfo((object)"Triggering character save process...");
			}
			SaveLocationOverride = location;
			SaveDone = false;
			TargetPlayer = player;
			SaveProfileData(ProfileDataManager._current);
		}

		[HarmonyReversePatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPriority(0)]
		private static void SaveProfileData(ProfileDataManager __instance)
		{
			Transpiler(null);
			throw new NotImplementedException("Stub method");
			static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> data)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Expected O, but got Unknown
				//IL_0076: Unknown result type (might be due to invalid IL or missing references)
				//IL_007c: Expected O, but got Unknown
				//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bd: Expected O, but got Unknown
				//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cb: Expected O, but got Unknown
				//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ec: Expected O, but got Unknown
				//IL_0130: Unknown result type (might be due to invalid IL or missing references)
				//IL_0136: Expected O, but got Unknown
				//IL_0151: Unknown result type (might be due to invalid IL or missing references)
				//IL_0157: Expected O, but got Unknown
				//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f5: Expected O, but got Unknown
				//IL_0244: Unknown result type (might be due to invalid IL or missing references)
				//IL_0250: Expected O, but got Unknown
				CodeMatcher val = new CodeMatcher(data, (ILGenerator)null);
				int num = 0;
				while (true)
				{
					val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
					{
						new CodeMatch((OpCode?)OpCodes.Call, (object)SymbolExtensions.GetMethodInfo((Expression<Action>)(() => File.WriteAllText(null, null))), (string)null)
					});
					if (val.IsInvalid)
					{
						break;
					}
					num++;
					val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[5]
					{
						new CodeInstruction(OpCodes.Stsfld, (object)AccessTools.Field(typeof(CharacterAutoSaver), "TempContents")),
						new CodeInstruction(OpCodes.Pop, (object)null),
						new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(CharacterAutoSaver), "SaveLocationOverride")),
						new CodeInstruction(OpCodes.Call, (object)SymbolExtensions.GetMethodInfo((Expression<Action>)(() => MarkSaveDone(null)))),
						new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(CharacterAutoSaver), "TempContents"))
					});
					val.Advance(1);
				}
				if (num != 3)
				{
					AutoSaverMod.Instance.Logger.LogWarning((object)$"WARNING: Expected {3} patch locations, got {num}.");
					AutoSaverMod.Instance.Logger.LogWarning((object)"Either the vanilla code changed, or mods added extra stuff. This may or may not cause issues.");
				}
				val.Start();
				num = 0;
				while (true)
				{
					val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
					{
						new CodeMatch((OpCode?)OpCodes.Ldsfld, (object)AccessTools.Field(typeof(Player), "_mainPlayer"), (string)null)
					});
					if (val.IsInvalid)
					{
						break;
					}
					List<Label> list = val.Instruction.labels.ToList();
					val.RemoveInstruction();
					val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { CodeInstructionExtensions.WithLabels(new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(CharacterAutoSaver), "TargetPlayer")), (IEnumerable<Label>)list) });
					num++;
				}
				AutoSaverMod.Instance.Logger.LogInfo((object)$"Patched {num} instances of Player._mainPlayer.");
				return val.InstructionEnumeration();
			}
		}

		private static string MarkSaveDone(string location)
		{
			SaveDone = true;
			return location;
		}
	}
	[HarmonyPatch(typeof(ProfileDataManager), "Save_ItemStorageData")]
	internal static class ItemBankAutoSaver
	{
		private static string SaveLocationOverride;

		private static string TempContents;

		private static int BanksDone = 0;

		private static int BanksMax = 0;

		internal static bool SaveDone { get; private set; } = true;


		public static void TrySaveCurrentProfileToLocation(string location)
		{
			if (SaveDone)
			{
				AutoSaverMod.Instance.Logger.LogInfo((object)"Triggering item bank save process...");
			}
			SaveLocationOverride = location;
			BanksDone = 0;
			SaveDone = false;
			SaveProfileData(ProfileDataManager._current);
		}

		[HarmonyReversePatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPriority(0)]
		private static void SaveProfileData(ProfileDataManager __instance)
		{
			Transpiler(null);
			throw new NotImplementedException("Stub method");
			static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> data)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Expected O, but got Unknown
				//IL_0076: Unknown result type (might be due to invalid IL or missing references)
				//IL_007c: Expected O, but got Unknown
				//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bd: Expected O, but got Unknown
				//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cb: Expected O, but got Unknown
				//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ec: Expected O, but got Unknown
				//IL_0130: Unknown result type (might be due to invalid IL or missing references)
				//IL_0136: Expected O, but got Unknown
				//IL_0151: Unknown result type (might be due to invalid IL or missing references)
				//IL_0157: Expected O, but got Unknown
				CodeMatcher val = new CodeMatcher(data, (ILGenerator)null);
				int num = 0;
				while (true)
				{
					val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
					{
						new CodeMatch((OpCode?)OpCodes.Call, (object)SymbolExtensions.GetMethodInfo((Expression<Action>)(() => File.WriteAllText(null, null))), (string)null)
					});
					if (val.IsInvalid)
					{
						break;
					}
					num++;
					val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[5]
					{
						new CodeInstruction(OpCodes.Stsfld, (object)AccessTools.Field(typeof(ItemBankAutoSaver), "TempContents")),
						new CodeInstruction(OpCodes.Pop, (object)null),
						new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(ItemBankAutoSaver), "SaveLocationOverride")),
						new CodeInstruction(OpCodes.Call, (object)SymbolExtensions.GetMethodInfo((Expression<Action>)(() => MarkSaveDone(null)))),
						new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(ItemBankAutoSaver), "TempContents"))
					});
					val.Advance(1);
				}
				if (num != 3)
				{
					AutoSaverMod.Instance.Logger.LogWarning((object)$"WARNING: Expected {3} patch locations, got {num}.");
					AutoSaverMod.Instance.Logger.LogWarning((object)"Either the vanilla code changed, or mods added extra stuff. This may or may not cause issues.");
				}
				BanksMax = 3;
				return val.InstructionEnumeration();
			}
		}

		private static string MarkSaveDone(string location)
		{
			BanksDone++;
			if (BanksDone >= BanksMax)
			{
				SaveDone = true;
			}
			return Path.Combine(location, $"itembank_{BanksDone - 1}");
		}

		public static void SaveModBankTabsToLocation(string location)
		{
			try
			{
				AutoSaverMod.Instance.Logger.LogInfo((object)"Attempting to save MoreBankTabs data...");
				BaseUnityPlugin instance = Chainloader.PluginInfos["com.16mb.morebanktabs"].Instance;
				object value = AccessTools.Field(((object)instance).GetType(), "_itemStorageProfile_03").GetValue(instance);
				object value2 = AccessTools.Field(((object)instance).GetType(), "_itemStorageProfile_04").GetValue(instance);
				object value3 = AccessTools.Field(((object)instance).GetType(), "_itemStorageProfile_05").GetValue(instance);
				object value4 = AccessTools.Field(((object)instance).GetType(), "_itemDatas_03").GetValue(instance);
				object value5 = AccessTools.Field(((object)instance).GetType(), "_itemDatas_04").GetValue(instance);
				object value6 = AccessTools.Field(((object)instance).GetType(), "_itemDatas_05").GetValue(instance);
				object value7 = AccessTools.Method(value4.GetType(), "ToArray", (Type[])null, (Type[])null).Invoke(value4, Array.Empty<object>());
				object value8 = AccessTools.Method(value5.GetType(), "ToArray", (Type[])null, (Type[])null).Invoke(value5, Array.Empty<object>());
				object value9 = AccessTools.Method(value6.GetType(), "ToArray", (Type[])null, (Type[])null).Invoke(value6, Array.Empty<object>());
				AccessTools.Field(value.GetType(), "_heldItemStorage").SetValue(value, value7);
				AccessTools.Field(value2.GetType(), "_heldItemStorage").SetValue(value2, value8);
				AccessTools.Field(value3.GetType(), "_heldItemStorage").SetValue(value3, value9);
				string contents = JsonUtility.ToJson(value, true);
				string contents2 = JsonUtility.ToJson(value2, true);
				string contents3 = JsonUtility.ToJson(value3, true);
				File.WriteAllText(Path.Combine(location, "MoreBankTabs_itemBank_03"), contents);
				File.WriteAllText(Path.Combine(location, "MoreBankTabs_itemBank_04"), contents2);
				File.WriteAllText(Path.Combine(location, "MoreBankTabs_itemBank_05"), contents3);
				AutoSaverMod.Instance.Logger.LogInfo((object)"MoreBankTabs slots saved.");
			}
			catch (Exception arg)
			{
				AutoSaverMod.Instance.Logger.LogError((object)"Failed to save MoreBankTabs info.");
				AutoSaverMod.Instance.Logger.LogError((object)$"Exception info: {arg}");
			}
		}
	}
}
namespace Marioalexsan.AutoSaver.HarmonyPatches
{
	[HarmonyPatch(typeof(InGameUI), "Init_SaveQuitGame")]
	internal static class InGameUI_Init_SaveQuitGame
	{
		private static void Prefix()
		{
			AutoSaverMod.Instance.GameExited();
		}
	}
	[HarmonyPatch(typeof(Player), "OnPlayerMapInstanceChange")]
	internal static class Player_OnPlayerMapInstanceChange
	{
		private static void Postfix(Player __instance, MapInstance _new)
		{
			if ((Object)(object)__instance == (Object)(object)Player._mainPlayer && (AutoSaverMod.Instance.SaveOnMapChange || !AutoSaverMod.Instance.CharacterActive))
			{
				AutoSaverMod.Instance.GameEntered();
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}