Decompiled source of SimpleModMenu v1.6.7

SimpleModMenu.dll

Decompiled 3 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
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: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("SimpleModMenu")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+63d9f7622c9c45c27fa586f12627e4964b54170e")]
[assembly: AssemblyProduct("SimpleModMenu")]
[assembly: AssemblyTitle("SimpleModMenu")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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 SimpleModMenu
{
	[BepInPlugin("com.cellinside.SimpleModMenu", "SimpleModMenu", "1.6.3")]
	public class Core : BasePlugin
	{
		public const string PluginGuid = "com.cellinside.SimpleModMenu";

		public const string PluginName = "SimpleModMenu";

		public const string PluginVersion = "1.6.3";

		internal Harmony _harmony;

		private bool _patched;

		private ConfigEntry<bool> _aggressiveMode;

		private ConfigEntry<bool> _debugLogging;

		private ConfigEntry<bool> _enableInfinite;

		private ConfigEntry<int> _forcedRefreshConfig;

		private ConfigEntry<bool> _enableInfiniteBanishes;

		private ConfigEntry<bool> _enableInfiniteSkips;

		internal static readonly List<string> PatchedMethodNames = new List<string>();

		private const string EShopItemFullName = "Assets.Scripts._Data.ShopItems.EShopItem";

		private Type _eShopItemType;

		private const string PlayerInventoryTypeName = "PlayerInventory";

		public static int ForcedRefreshValue = 9999;

		private MethodInfo _miChangeGold;

		private MethodInfo _miAddXp;

		private FieldInfo _fiPlayerHealth;

		private object _cachedPlayerHealth;

		private MemberInfo _miHealthValue;

		private MemberInfo _miMaxHealthValue;

		private MethodInfo _miHealLike;

		internal static Core Instance { get; private set; }

		internal bool AggressiveMode
		{
			get
			{
				return _aggressiveMode.Value;
			}
			set
			{
				if (_aggressiveMode.Value != value)
				{
					_aggressiveMode.Value = value;
					((BasePlugin)this).Config.Save();
				}
			}
		}

		internal bool DebugLogging
		{
			get
			{
				return _debugLogging.Value;
			}
			set
			{
				if (_debugLogging.Value != value)
				{
					_debugLogging.Value = value;
					((BasePlugin)this).Config.Save();
				}
			}
		}

		internal bool EnableInfinite
		{
			get
			{
				return _enableInfinite.Value;
			}
			set
			{
				if (_enableInfinite.Value != value)
				{
					_enableInfinite.Value = value;
					((BasePlugin)this).Config.Save();
				}
			}
		}

		internal bool EnableInfiniteBanishes
		{
			get
			{
				return _enableInfiniteBanishes?.Value ?? false;
			}
			set
			{
				if (_enableInfiniteBanishes != null && _enableInfiniteBanishes.Value != value)
				{
					_enableInfiniteBanishes.Value = value;
					((BasePlugin)this).Config.Save();
				}
			}
		}

		internal bool EnableInfiniteSkips
		{
			get
			{
				return _enableInfiniteSkips?.Value ?? false;
			}
			set
			{
				if (_enableInfiniteSkips != null && _enableInfiniteSkips.Value != value)
				{
					_enableInfiniteSkips.Value = value;
					((BasePlugin)this).Config.Save();
				}
			}
		}

		internal int GenericPatchCount { get; private set; }

		internal int EShopItemPatchCount { get; private set; }

		internal int PlayerInventoryPatchCount { get; private set; }

		internal void SetForcedRefreshValue(int value)
		{
			if (value < 1)
			{
				value = 1;
			}
			if (value > 1000000)
			{
				value = 1000000;
			}
			ForcedRefreshValue = value;
			if (_forcedRefreshConfig.Value != value)
			{
				_forcedRefreshConfig.Value = value;
				((BasePlugin)this).Config.Save();
			}
		}

		public override void Load()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			Instance = this;
			_harmony = new Harmony("com.cellinside.SimpleModMenu");
			BindConfig();
			ForcedRefreshValue = _forcedRefreshConfig.Value;
			TryApplyPatches();
			if (!_patched)
			{
				AppDomain.CurrentDomain.AssemblyLoad += OnAssemblyLoad;
				((BasePlugin)this).Log.LogInfo((object)"SimpleModMenu waiting for Assembly-Csharp to load...");
			}
			((BasePlugin)this).Log.LogInfo((object)"SimpleModMenu initialized.");
			try
			{
				if (!ClassInjector.IsTypeRegisteredInIl2Cpp(typeof(GuiController)))
				{
					ClassInjector.RegisterTypeInIl2Cpp<GuiController>();
					((BasePlugin)this).Log.LogInfo((object)"Registered GuiController in Il2Cpp domain.");
				}
				GameObject val = new GameObject("SimpleModMenuGUI");
				((Object)val).hideFlags = (HideFlags)61;
				val.AddComponent<GuiController>();
				Object.DontDestroyOnLoad((Object)(object)val);
				((BasePlugin)this).Log.LogInfo((object)"GuiController GameObject created. Press F6 (or F7) to toggle panel.");
			}
			catch (Exception ex)
			{
				ManualLogSource log = ((BasePlugin)this).Log;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(33, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to create GUI GameObject: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
				}
				log.LogWarning(val2);
			}
		}

		public override bool Unload()
		{
			AppDomain.CurrentDomain.AssemblyLoad -= OnAssemblyLoad;
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			return ((BasePlugin)this).Unload();
		}

		private void BindConfig()
		{
			_enableInfinite = ((BasePlugin)this).Config.Bind<bool>("General", "EnableInfinite", true, "Master toggle for forcing infinite refreshes.");
			_enableInfiniteBanishes = ((BasePlugin)this).Config.Bind<bool>("General", "EnableInfiniteBanishes", true, "Toggle for infinite banishes.");
			_enableInfiniteSkips = ((BasePlugin)this).Config.Bind<bool>("General", "EnableInfiniteSkips", true, "Toggle for infinite skips.");
			_forcedRefreshConfig = ((BasePlugin)this).Config.Bind<int>("General", "ForcedRefreshValue", 9999, "Forced refresh/banish/skip count value when infinite enabled.");
			_aggressiveMode = ((BasePlugin)this).Config.Bind<bool>("General", "AggressiveMode", true, "If true, patch ALL methods with EShopItem param to force infinite Refresh (may be overkill). If false, only name-matched consumption methods are skipped.");
			_debugLogging = ((BasePlugin)this).Config.Bind<bool>("General", "DebugLogging", false, "Enable verbose logging of patch decisions and runtime interceptions.");
		}

		private void OnAssemblyLoad(object sender, AssemblyLoadEventArgs e)
		{
			if (!_patched && e.LoadedAssembly?.GetName().Name == "Assembly-CSharp")
			{
				TryApplyPatches();
			}
		}

		private Assembly GetGameAssembly()
		{
			return AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly a) => a.GetName().Name == "Assembly-CSharp");
		}

		internal void ReapplyPatches()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			try
			{
				Harmony harmony = _harmony;
				if (harmony != null)
				{
					harmony.UnpatchSelf();
				}
				_patched = false;
				int num2 = (PlayerInventoryPatchCount = 0);
				int genericPatchCount = (EShopItemPatchCount = num2);
				GenericPatchCount = genericPatchCount;
				TryApplyPatches();
			}
			catch (Exception ex)
			{
				ManualLogSource log = ((BasePlugin)this).Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(23, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("ReapplyPatches failed: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				log.LogError(val);
			}
		}

		private void TryApplyPatches()
		{
			//IL_08b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_08bd: Expected O, but got Unknown
			//IL_09d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_09dd: Expected O, but got Unknown
			//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dd: Expected O, but got Unknown
			//IL_06aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b1: Expected O, but got Unknown
			//IL_090b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0912: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Expected O, but got Unknown
			//IL_07a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ae: Expected O, but got Unknown
			//IL_0800: Unknown result type (might be due to invalid IL or missing references)
			//IL_080d: Expected O, but got Unknown
			//IL_085f: Unknown result type (might be due to invalid IL or missing references)
			//IL_086c: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				Assembly gameAssembly = GetGameAssembly();
				if (gameAssembly == null)
				{
					if (_debugLogging.Value)
					{
						((BasePlugin)this).Log.LogDebug((object)"Assembly-Csharp not loaded yet.");
					}
					return;
				}
				Type type = gameAssembly.GetTypes().FirstOrDefault((Type t) => t.Name == "PlayerInventory" || t.FullName == "PlayerInventory");
				_eShopItemType = gameAssembly.GetType("Assets.Scripts._Data.ShopItems.EShopItem");
				if (_eShopItemType == null)
				{
					ManualLogSource log = ((BasePlugin)this).Log;
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(62, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Could not locate enum type ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Assets.Scripts._Data.ShopItems.EShopItem");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(". Will still apply generic patches.");
					}
					log.LogWarning(val);
				}
				else if (!_eShopItemType.IsEnum)
				{
					ManualLogSource log2 = ((BasePlugin)this).Log;
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(31, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Type ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Assets.Scripts._Data.ShopItems.EShopItem");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" found but is not an enum.");
					}
					log2.LogWarning(val);
					_eShopItemType = null;
				}
				int num = 0;
				int num2 = 0;
				int num3 = 0;
				PatchedMethodNames.Clear();
				Type[] types = gameAssembly.GetTypes();
				foreach (Type type2 in types)
				{
					MethodInfo[] methods;
					try
					{
						methods = type2.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
					}
					catch
					{
						continue;
					}
					MethodInfo[] array = methods;
					foreach (MethodInfo methodInfo in array)
					{
						try
						{
							if (methodInfo.DeclaringType == type)
							{
								continue;
							}
							if (methodInfo.ReturnType == typeof(bool) && methodInfo.GetParameters().Length == 0)
							{
								string text = methodInfo.Name.ToLowerInvariant();
								if (text.Contains("canrefresh") || text.Contains("hasrefresh") || text == "canrefresh")
								{
									PatchOnce(methodInfo, null, null, typeof(AlwaysTruePatch), "Postfix");
									num++;
									PatchedMethodNames.Add($"TRUE  {methodInfo.DeclaringType?.Name}.{methodInfo.Name}()");
								}
							}
							if (methodInfo.ReturnType == typeof(void) && methodInfo.GetParameters().Length == 0)
							{
								string text2 = methodInfo.Name.ToLowerInvariant();
								if (text2.Contains("userefresh") || text2.Contains("consumerefresh") || text2.Contains("spendrefresh"))
								{
									PatchOnce(methodInfo, typeof(SkipMethodPatch), "Prefix");
									num++;
									PatchedMethodNames.Add($"SKIP  {methodInfo.DeclaringType?.Name}.{methodInfo.Name}()");
								}
							}
							goto IL_044e;
						}
						catch (Exception ex)
						{
							if (_debugLogging.Value)
							{
								ManualLogSource log3 = ((BasePlugin)this).Log;
								BepInExDebugLogInterpolatedStringHandler val2 = new BepInExDebugLogInterpolatedStringHandler(36, 3, ref flag);
								if (flag)
								{
									((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Generic patch attempt failed for ");
									((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(methodInfo.DeclaringType?.FullName);
									((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(".");
									((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(methodInfo.Name);
									((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": ");
									((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
								}
								log3.LogDebug(val2);
							}
							goto IL_044e;
						}
						IL_044e:
						if (!(_eShopItemType != null))
						{
							continue;
						}
						ParameterInfo[] parameters = methodInfo.GetParameters();
						if (parameters.Length == 0 || !parameters.Any((ParameterInfo p) => p.ParameterType == _eShopItemType))
						{
							continue;
						}
						try
						{
							if (methodInfo.ReturnType == typeof(int))
							{
								PatchOnce(methodInfo, null, null, typeof(EShopItemIntResultPatch), "Postfix");
								num2++;
								PatchedMethodNames.Add("ESHOP->INT " + methodInfo.DeclaringType?.Name + "." + methodInfo.Name);
							}
							else if (methodInfo.ReturnType == typeof(bool))
							{
								PatchOnce(methodInfo, null, null, typeof(EShopItemBoolResultPatch), "Postfix");
								num2++;
								PatchedMethodNames.Add("ESHOP->BOOL " + methodInfo.DeclaringType?.Name + "." + methodInfo.Name);
							}
							else
							{
								if (!(methodInfo.ReturnType == typeof(void)))
								{
									continue;
								}
								bool flag2 = _aggressiveMode.Value;
								if (!flag2)
								{
									string text3 = methodInfo.Name.ToLowerInvariant();
									if (text3.Contains("use") || text3.Contains("consume") || text3.Contains("spend") || text3.Contains("take") || text3.Contains("apply") || text3.Contains("add"))
									{
										flag2 = true;
									}
								}
								if (flag2)
								{
									PatchOnce(methodInfo, typeof(EShopItemUsePatch), "Prefix");
									num2++;
									PatchedMethodNames.Add("ESHOP->SKIP " + methodInfo.DeclaringType?.Name + "." + methodInfo.Name);
								}
								continue;
							}
						}
						catch (Exception ex2)
						{
							if (_debugLogging.Value)
							{
								ManualLogSource log4 = ((BasePlugin)this).Log;
								BepInExDebugLogInterpolatedStringHandler val2 = new BepInExDebugLogInterpolatedStringHandler(38, 3, ref flag);
								if (flag)
								{
									((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("EShopItem patch attempt failed for ");
									((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(methodInfo.DeclaringType?.FullName);
									((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(".");
									((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(methodInfo.Name);
									((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": ");
									((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex2.Message);
								}
								log4.LogDebug(val2);
							}
						}
					}
				}
				if (type != null)
				{
					try
					{
						PlayerInventoryForcePatches.Init(type, ((BasePlugin)this).Log);
						bool flag3 = false;
						MethodInfo methodInfo2 = AccessTools.Method(type, "get_refreshes", (Type[])null, (Type[])null);
						if (methodInfo2 != null)
						{
							_harmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(typeof(PlayerInventoryForcePatches), "GetRefreshesPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
							num3++;
							PatchedMethodNames.Add("PINV get_refreshes");
							flag3 = true;
						}
						MethodInfo methodInfo3 = AccessTools.Method(type, "get_refreshesUsed", (Type[])null, (Type[])null);
						if (methodInfo3 != null)
						{
							_harmony.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, new HarmonyMethod(typeof(PlayerInventoryForcePatches), "GetRefreshesUsedPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
							num3++;
							PatchedMethodNames.Add("PINV get_refreshesUsed");
							flag3 = true;
						}
						MethodInfo methodInfo4 = AccessTools.Method(type, "Update", (Type[])null, (Type[])null);
						if (methodInfo4 != null)
						{
							_harmony.Patch((MethodBase)methodInfo4, (HarmonyMethod)null, new HarmonyMethod(typeof(PlayerInventoryForcePatches), "UpdatePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
							num3++;
							PatchedMethodNames.Add("PINV Update");
							flag3 = true;
						}
						if (!flag3)
						{
							((BasePlugin)this).Log.LogWarning((object)"PlayerInventory found but expected methods (get_refreshes / get_refreshesUsed / Update) missing.");
						}
					}
					catch (Exception ex3)
					{
						ManualLogSource log5 = ((BasePlugin)this).Log;
						BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(38, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed PlayerInventory force patches: ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex3.Message);
						}
						log5.LogWarning(val);
					}
				}
				else
				{
					((BasePlugin)this).Log.LogWarning((object)"PlayerInventory type not found. Provide fully qualified name if namespaced.");
				}
				ManualLogSource log6 = ((BasePlugin)this).Log;
				BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(104, 4, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("SimpleModMenu: Applied ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(num);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" generic, ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(num2);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" EShopItem-targeted, ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(num3);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" PlayerInventory-specific patches. AggressiveMode=");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<bool>(_aggressiveMode.Value);
				}
				log6.LogInfo(val3);
				_patched = true;
				GenericPatchCount = num;
				EShopItemPatchCount = num2;
				PlayerInventoryPatchCount = num3;
				if (num + num2 + num3 == 0)
				{
					((BasePlugin)this).Log.LogWarning((object)"SimpleModMenu: No candidate methods found. Need concrete method names.");
				}
			}
			catch (Exception ex4)
			{
				ManualLogSource log7 = ((BasePlugin)this).Log;
				BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(31, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("SimpleModMenu patching failed: ");
					((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<Exception>(ex4);
				}
				log7.LogError(val4);
			}
		}

		private void PatchOnce(MethodInfo target, Type prefix = null, string prefixName = null, Type postfix = null, string postfixName = null)
		{
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Expected O, but got Unknown
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				HarmonyMethod val = ((!(prefix != null)) ? ((HarmonyMethod)null) : new HarmonyMethod(prefix.GetMethod(prefixName, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)));
				HarmonyMethod val2 = ((!(postfix != null)) ? ((HarmonyMethod)null) : new HarmonyMethod(postfix.GetMethod(postfixName, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)));
				_harmony.Patch((MethodBase)target, val, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				if (_debugLogging.Value)
				{
					ManualLogSource log = ((BasePlugin)this).Log;
					BepInExDebugLogInterpolatedStringHandler val3 = new BepInExDebugLogInterpolatedStringHandler(23, 4, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Patched ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(target.DeclaringType?.FullName);
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(".");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(target.Name);
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" (pre=");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<bool>(val != null);
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(", post=");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<bool>(val2 != null);
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(")");
					}
					log.LogDebug(val3);
				}
			}
			catch (Exception ex)
			{
				if (_debugLogging.Value)
				{
					ManualLogSource log2 = ((BasePlugin)this).Log;
					BepInExDebugLogInterpolatedStringHandler val3 = new BepInExDebugLogInterpolatedStringHandler(19, 3, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Failed to patch ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(target.DeclaringType?.FullName);
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(".");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(target.Name);
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
					}
					log2.LogDebug(val3);
				}
			}
		}

		internal static bool ArgIsRefresh(object arg)
		{
			if (arg == null)
			{
				return false;
			}
			Type type = arg.GetType();
			if (!type.IsEnum)
			{
				return false;
			}
			if (type.FullName != "Assets.Scripts._Data.ShopItems.EShopItem")
			{
				return false;
			}
			try
			{
				return Convert.ToInt32(arg) == 0;
			}
			catch
			{
				return false;
			}
		}

		internal static void DebugLogInvoke(string where, object[] args)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			ManualLogSource val = Logger.CreateLogSource("SimpleModMenu");
			try
			{
				if (args != null && args.Any(ArgIsRefresh))
				{
					ManualLogSource val2 = val;
					bool flag = default(bool);
					BepInExDebugLogInterpolatedStringHandler val3 = new BepInExDebugLogInterpolatedStringHandler(22, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(where);
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": invoked with Refresh");
					}
					val2.LogDebug(val3);
				}
			}
			catch
			{
			}
		}

		private object GetPlayerInventoryInstance()
		{
			return PlayerInventoryForcePatches.LastInstance;
		}

		internal bool TryAddGold(int amount)
		{
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			try
			{
				object playerInventoryInstance = GetPlayerInventoryInstance();
				if (playerInventoryInstance == null)
				{
					return false;
				}
				if ((object)_miChangeGold == null)
				{
					_miChangeGold = playerInventoryInstance.GetType().GetMethod("ChangeGold", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(int) }, null);
				}
				if (_miChangeGold == null)
				{
					return false;
				}
				_miChangeGold.Invoke(playerInventoryInstance, new object[1] { amount });
				return true;
			}
			catch (Exception ex)
			{
				ConfigEntry<bool> debugLogging = _debugLogging;
				if (debugLogging != null && debugLogging.Value)
				{
					ManualLogSource log = ((BasePlugin)this).Log;
					bool flag = default(bool);
					BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(16, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AddGold failed: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
					}
					log.LogDebug(val);
				}
				return false;
			}
		}

		internal bool TryAddXp(int amount)
		{
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			try
			{
				object playerInventoryInstance = GetPlayerInventoryInstance();
				if (playerInventoryInstance == null)
				{
					return false;
				}
				if ((object)_miAddXp == null)
				{
					_miAddXp = playerInventoryInstance.GetType().GetMethod("AddXp", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(int) }, null);
				}
				if (_miAddXp == null)
				{
					return false;
				}
				_miAddXp.Invoke(playerInventoryInstance, new object[1] { amount });
				return true;
			}
			catch (Exception ex)
			{
				ConfigEntry<bool> debugLogging = _debugLogging;
				if (debugLogging != null && debugLogging.Value)
				{
					ManualLogSource log = ((BasePlugin)this).Log;
					bool flag = default(bool);
					BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(14, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AddXp failed: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
					}
					log.LogDebug(val);
				}
				return false;
			}
		}

		internal bool TryAddHealth(int amount)
		{
			//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Expected O, but got Unknown
			try
			{
				object playerInventoryInstance = GetPlayerInventoryInstance();
				if (playerInventoryInstance == null)
				{
					return false;
				}
				if ((object)_fiPlayerHealth == null)
				{
					_fiPlayerHealth = playerInventoryInstance.GetType().GetField("playerHealth", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				}
				if (_fiPlayerHealth == null)
				{
					return false;
				}
				_cachedPlayerHealth = _fiPlayerHealth.GetValue(playerInventoryInstance);
				if (_cachedPlayerHealth == null)
				{
					return false;
				}
				if (_miHealthValue == null)
				{
					Type type = _cachedPlayerHealth.GetType();
					string[] array = new string[5] { "health", "currentHealth", "_health", "hp", "_hp" };
					string[] array2 = array;
					foreach (string name in array2)
					{
						FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						if (field != null && (field.FieldType == typeof(int) || field.FieldType == typeof(float)))
						{
							_miHealthValue = field;
							break;
						}
						PropertyInfo property = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						if (property != null && property.CanRead && property.CanWrite && (property.PropertyType == typeof(int) || property.PropertyType == typeof(float)))
						{
							_miHealthValue = property;
							break;
						}
					}
					string[] array3 = new string[4] { "maxHealth", "_maxHealth", "healthMax", "maxHP" };
					string[] array4 = array3;
					foreach (string name2 in array4)
					{
						FieldInfo field2 = type.GetField(name2, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						if (field2 != null && (field2.FieldType == typeof(int) || field2.FieldType == typeof(float)))
						{
							_miMaxHealthValue = field2;
							break;
						}
						PropertyInfo property2 = type.GetProperty(name2, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						if (property2 != null && property2.CanRead && (property2.PropertyType == typeof(int) || property2.PropertyType == typeof(float)))
						{
							_miMaxHealthValue = property2;
							break;
						}
					}
					_miHealLike = type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((MethodInfo m) => m.ReturnType == typeof(void) && m.GetParameters().Length == 1 && m.GetParameters()[0].ParameterType == typeof(int) && (m.Name.IndexOf("heal", StringComparison.OrdinalIgnoreCase) >= 0 || m.Name.IndexOf("addhealth", StringComparison.OrdinalIgnoreCase) >= 0));
				}
				if (_miHealLike != null)
				{
					_miHealLike.Invoke(_cachedPlayerHealth, new object[1] { amount });
					return true;
				}
				if (_miHealthValue != null)
				{
					float numeric = GetNumeric(_miHealthValue, _cachedPlayerHealth);
					float num = ((_miMaxHealthValue != null) ? GetNumeric(_miMaxHealthValue, _cachedPlayerHealth) : float.MaxValue);
					float num2 = numeric + (float)amount;
					if (num2 > num)
					{
						num2 = num;
					}
					SetNumeric(_miHealthValue, _cachedPlayerHealth, num2);
					return true;
				}
				return false;
			}
			catch (Exception ex)
			{
				ConfigEntry<bool> debugLogging = _debugLogging;
				if (debugLogging != null && debugLogging.Value)
				{
					ManualLogSource log = ((BasePlugin)this).Log;
					bool flag = default(bool);
					BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(18, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AddHealth failed: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
					}
					log.LogDebug(val);
				}
				return false;
			}
		}

		private static float GetNumeric(MemberInfo mi, object obj)
		{
			if (1 == 0)
			{
			}
			float result;
			if (!(mi is FieldInfo fieldInfo))
			{
				if (!(mi is PropertyInfo propertyInfo))
				{
					goto IL_00d0;
				}
				if (propertyInfo.PropertyType == typeof(int))
				{
					result = (int)propertyInfo.GetValue(obj);
				}
				else
				{
					PropertyInfo propertyInfo2 = propertyInfo;
					if (!(propertyInfo2.PropertyType == typeof(float)))
					{
						goto IL_00d0;
					}
					result = (float)propertyInfo2.GetValue(obj);
				}
			}
			else if (fieldInfo.FieldType == typeof(int))
			{
				result = (int)fieldInfo.GetValue(obj);
			}
			else
			{
				FieldInfo fieldInfo2 = fieldInfo;
				if (!(fieldInfo2.FieldType == typeof(float)))
				{
					goto IL_00d0;
				}
				result = (float)fieldInfo2.GetValue(obj);
			}
			goto IL_00d9;
			IL_00d9:
			if (1 == 0)
			{
			}
			return result;
			IL_00d0:
			result = 0f;
			goto IL_00d9;
		}

		private static void SetNumeric(MemberInfo mi, object obj, float value)
		{
			if (!(mi is FieldInfo fieldInfo))
			{
				if (!(mi is PropertyInfo propertyInfo))
				{
					return;
				}
				if (propertyInfo.PropertyType == typeof(int))
				{
					propertyInfo.SetValue(obj, (int)value);
					return;
				}
				PropertyInfo propertyInfo2 = propertyInfo;
				if (propertyInfo2.PropertyType == typeof(float))
				{
					propertyInfo2.SetValue(obj, value);
				}
			}
			else if (fieldInfo.FieldType == typeof(int))
			{
				fieldInfo.SetValue(obj, (int)value);
			}
			else
			{
				FieldInfo fieldInfo2 = fieldInfo;
				if (fieldInfo2.FieldType == typeof(float))
				{
					fieldInfo2.SetValue(obj, value);
				}
			}
		}
	}
	internal static class AlwaysTruePatch
	{
		public static void Postfix(ref bool __result)
		{
			Core instance = Core.Instance;
			if (instance != null && instance.EnableInfinite)
			{
				__result = true;
			}
		}
	}
	internal static class SkipMethodPatch
	{
		public static bool Prefix()
		{
			Core instance = Core.Instance;
			return instance == null || !instance.EnableInfinite;
		}
	}
	internal static class EShopItemIntResultPatch
	{
		public static void Postfix(object[] __args, ref int __result)
		{
			Core instance = Core.Instance;
			if (instance != null && instance.EnableInfinite && __args != null && __args.Any(Core.ArgIsRefresh))
			{
				__result = Core.ForcedRefreshValue;
			}
		}
	}
	internal static class EShopItemBoolResultPatch
	{
		public static void Postfix(object[] __args, ref bool __result)
		{
			Core instance = Core.Instance;
			if (instance != null && instance.EnableInfinite && __args != null && __args.Any(Core.ArgIsRefresh))
			{
				__result = true;
			}
		}
	}
	internal static class EShopItemUsePatch
	{
		public static bool Prefix(object[] __args)
		{
			Core instance = Core.Instance;
			if (instance == null || !instance.EnableInfinite)
			{
				return true;
			}
			if (__args == null)
			{
				return true;
			}
			if (__args.Any(Core.ArgIsRefresh))
			{
				return false;
			}
			return true;
		}
	}
	internal static class PlayerInventoryForcePatches
	{
		private class SavedCounts
		{
			public int refreshes;

			public int refreshesUsed;

			public int banishes;

			public int banishesUsed;

			public int skips;

			public int skipsUsed;

			public bool captured;
		}

		private static MethodInfo _setRefreshes;

		private static MethodInfo _setRefreshesUsed;

		private static MethodInfo _setBanishes;

		private static MethodInfo _setBanishesUsed;

		private static MethodInfo _setSkips;

		private static MethodInfo _setSkipsUsed;

		private static MethodInfo _getRefreshes;

		private static MethodInfo _getRefreshesUsed;

		private static MethodInfo _getBanishes;

		private static MethodInfo _getBanishesUsed;

		private static MethodInfo _getSkips;

		private static MethodInfo _getSkipsUsed;

		private static FieldInfo _fieldRefreshes;

		private static FieldInfo _fieldRefreshesUsed;

		private static FieldInfo _fieldBanishes;

		private static FieldInfo _fieldBanishesUsed;

		private static FieldInfo _fieldSkips;

		private static FieldInfo _fieldSkipsUsed;

		private static bool _initialized;

		private static ManualLogSource _log;

		private static readonly Dictionary<IntPtr, SavedCounts> _original = new Dictionary<IntPtr, SavedCounts>();

		private static bool _lastRefresh;

		private static bool _lastBanish;

		private static bool _lastSkip;

		private static bool EnabledRefresh => Core.Instance != null && Core.Instance.EnableInfinite;

		private static bool EnabledBanish => Core.Instance != null && Core.Instance.EnableInfiniteBanishes;

		private static bool EnabledSkip => Core.Instance != null && Core.Instance.EnableInfiniteSkips;

		internal static object LastInstance { get; private set; }

		internal static void Init(Type playerInventoryType, ManualLogSource log)
		{
			if (!_initialized)
			{
				_log = log;
				_setRefreshes = AccessTools.Method(playerInventoryType, "set_refreshes", (Type[])null, (Type[])null);
				_setRefreshesUsed = AccessTools.Method(playerInventoryType, "set_refreshesUsed", (Type[])null, (Type[])null);
				_setBanishes = AccessTools.Method(playerInventoryType, "set_banishes", (Type[])null, (Type[])null);
				_setBanishesUsed = AccessTools.Method(playerInventoryType, "set_banishesUsed", (Type[])null, (Type[])null);
				_setSkips = AccessTools.Method(playerInventoryType, "set_skips", (Type[])null, (Type[])null);
				_setSkipsUsed = AccessTools.Method(playerInventoryType, "set_skipsUsed", (Type[])null, (Type[])null);
				_getRefreshes = AccessTools.Method(playerInventoryType, "get_refreshes", (Type[])null, (Type[])null);
				_getRefreshesUsed = AccessTools.Method(playerInventoryType, "get_refreshesUsed", (Type[])null, (Type[])null);
				_getBanishes = AccessTools.Method(playerInventoryType, "get_banishes", (Type[])null, (Type[])null);
				_getBanishesUsed = AccessTools.Method(playerInventoryType, "get_banishesUsed", (Type[])null, (Type[])null);
				_getSkips = AccessTools.Method(playerInventoryType, "get_skips", (Type[])null, (Type[])null);
				_getSkipsUsed = AccessTools.Method(playerInventoryType, "get_skipsUsed", (Type[])null, (Type[])null);
				_fieldRefreshes = playerInventoryType.GetField("refreshes", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				_fieldRefreshesUsed = playerInventoryType.GetField("refreshesUsed", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				_fieldBanishes = playerInventoryType.GetField("banishes", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				_fieldBanishesUsed = playerInventoryType.GetField("banishesUsed", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				_fieldSkips = playerInventoryType.GetField("skips", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				_fieldSkipsUsed = playerInventoryType.GetField("skipsUsed", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				_initialized = true;
			}
		}

		public static void GetRefreshesPostfix(object __instance, ref int __result)
		{
			if (EnabledRefresh && __result < Core.ForcedRefreshValue)
			{
				ForceSet(__instance, Core.ForcedRefreshValue, 0);
				__result = Core.ForcedRefreshValue;
			}
		}

		public static void GetRefreshesUsedPostfix(object __instance, ref int __result)
		{
			if (EnabledRefresh && __result != 0)
			{
				ForceSet(__instance, Core.ForcedRefreshValue, 0);
				__result = 0;
			}
		}

		public static void UpdatePostfix(object __instance)
		{
			if (__instance == null)
			{
				return;
			}
			LastInstance = __instance;
			IntPtr intPtr;
			try
			{
				intPtr = (IntPtr)((dynamic)__instance).Pointer;
				if (intPtr == IntPtr.Zero)
				{
					intPtr = (IntPtr)__instance.GetHashCode();
				}
			}
			catch
			{
				intPtr = (IntPtr)__instance.GetHashCode();
			}
			if (!_original.TryGetValue(intPtr, out var value) || !value.captured)
			{
				value = new SavedCounts
				{
					refreshes = SafeGet(_getRefreshes, __instance),
					refreshesUsed = SafeGet(_getRefreshesUsed, __instance),
					banishes = SafeGet(_getBanishes, __instance),
					banishesUsed = SafeGet(_getBanishesUsed, __instance),
					skips = SafeGet(_getSkips, __instance),
					skipsUsed = SafeGet(_getSkipsUsed, __instance),
					captured = true
				};
				_original[intPtr] = value;
			}
			if (_lastRefresh && !EnabledRefresh)
			{
				ForceSet(__instance, value.refreshes, value.refreshesUsed);
			}
			if (_lastBanish && !EnabledBanish)
			{
				ForceSetBanishes(__instance, value.banishes, value.banishesUsed);
			}
			if (_lastSkip && !EnabledSkip)
			{
				ForceSetSkips(__instance, value.skips, value.skipsUsed);
			}
			if (EnabledRefresh)
			{
				ForceSet(__instance, Core.ForcedRefreshValue, 0);
			}
			if (EnabledBanish)
			{
				ForceSetBanishes(__instance, Core.ForcedRefreshValue, 0);
			}
			if (EnabledSkip)
			{
				ForceSetSkips(__instance, Core.ForcedRefreshValue, 0);
			}
			_lastRefresh = EnabledRefresh;
			_lastBanish = EnabledBanish;
			_lastSkip = EnabledSkip;
		}

		private static int SafeGet(MethodInfo mi, object inst)
		{
			if (mi == null)
			{
				return 0;
			}
			try
			{
				object obj = mi.Invoke(inst, null);
				if (obj is int)
				{
					int result = (int)obj;
					if (true)
					{
						return result;
					}
				}
			}
			catch
			{
			}
			return 0;
		}

		private static void ForceSet(object instance, int refreshes, int refreshesUsed)
		{
			try
			{
				bool flag = false;
				if (_setRefreshes != null)
				{
					_setRefreshes.Invoke(instance, new object[1] { refreshes });
					flag = true;
				}
				if (_setRefreshesUsed != null)
				{
					_setRefreshesUsed.Invoke(instance, new object[1] { refreshesUsed });
					flag = true;
				}
				if (!flag)
				{
					_fieldRefreshes?.SetValue(instance, refreshes);
					_fieldRefreshesUsed?.SetValue(instance, refreshesUsed);
				}
			}
			catch
			{
			}
		}

		private static void ForceSetBanishes(object instance, int value, int used)
		{
			try
			{
				bool flag = false;
				if (_setBanishes != null)
				{
					_setBanishes.Invoke(instance, new object[1] { value });
					flag = true;
				}
				if (_setBanishesUsed != null)
				{
					_setBanishesUsed.Invoke(instance, new object[1] { used });
					flag = true;
				}
				if (!flag)
				{
					_fieldBanishes?.SetValue(instance, value);
					_fieldBanishesUsed?.SetValue(instance, used);
				}
			}
			catch
			{
			}
		}

		private static void ForceSetSkips(object instance, int value, int used)
		{
			try
			{
				bool flag = false;
				if (_setSkips != null)
				{
					_setSkips.Invoke(instance, new object[1] { value });
					flag = true;
				}
				if (_setSkipsUsed != null)
				{
					_setSkipsUsed.Invoke(instance, new object[1] { used });
					flag = true;
				}
				if (!flag)
				{
					_fieldSkips?.SetValue(instance, value);
					_fieldSkipsUsed?.SetValue(instance, used);
				}
			}
			catch
			{
			}
		}
	}
	public class GuiController : MonoBehaviour
	{
		private static GuiController _instance;

		private bool _show;

		private Rect _panelRect = new Rect(60f, 60f, 600f, 340f);

		private readonly ManualLogSource _log = Logger.CreateLogSource("SimpleModMenu.GUI");

		private bool _dragging;

		private Vector2 _dragOffset;

		private Vector2 _scrollPos;

		private bool _expandList;

		private const float LineH = 20f;

		private const float Pad = 6f;

		private GUIStyle _sectionHeader;

		private void Awake()
		{
			if ((Object)(object)_instance != (Object)null && (Object)(object)_instance != (Object)(object)this)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			_instance = this;
			_log.LogInfo((object)"GuiController ready (F6/F7 toggle).");
		}

		private void Update()
		{
			if (Input.GetKeyDown((KeyCode)287) || Input.GetKeyDown((KeyCode)288))
			{
				_show = !_show;
			}
		}

		private void EnsureStyles()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			if (_sectionHeader == null)
			{
				_sectionHeader = new GUIStyle(GUI.skin.label)
				{
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)3
				};
			}
		}

		private void OnGUI()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Expected O, but got Unknown
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_0379: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0423: Unknown result type (might be due to invalid IL or missing references)
			//IL_044e: Unknown result type (might be due to invalid IL or missing references)
			//IL_047a: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0602: Unknown result type (might be due to invalid IL or missing references)
			//IL_0607: Unknown result type (might be due to invalid IL or missing references)
			//IL_0609: Unknown result type (might be due to invalid IL or missing references)
			//IL_060e: Unknown result type (might be due to invalid IL or missing references)
			//IL_064c: Unknown result type (might be due to invalid IL or missing references)
			if (!_show || Core.Instance == null)
			{
				return;
			}
			EnsureStyles();
			GUI.BeginGroup(_panelRect, GUI.skin.box);
			DrawTitleBar();
			float y = 28f;
			Core instance = Core.Instance;
			y = SectionHeader("Infinite Features", y);
			float num = 6f;
			instance.EnableInfinite = GUI.Toggle(new Rect(num, y, 150f, 20f), instance.EnableInfinite, "Infinite Refreshes");
			num += 150f;
			instance.EnableInfiniteBanishes = GUI.Toggle(new Rect(num, y, 150f, 20f), instance.EnableInfiniteBanishes, "Infinite Banishes");
			num += 150f;
			instance.EnableInfiniteSkips = GUI.Toggle(new Rect(num, y, 140f, 20f), instance.EnableInfiniteSkips, "Infinite Skips");
			y += 24f;
			y = SectionHeader("Forced Value", y);
			GUI.Label(new Rect(6f, y, 90f, 20f), "Count:");
			GUI.Label(new Rect(56f, y, 90f, 20f), Core.ForcedRefreshValue.ToString());
			int[] array = new int[8] { -1000, -100, -10, -1, 1, 10, 100, 1000 };
			float num2 = 126f;
			int[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				int num3 = array2[i];
				if (GUI.Button(new Rect(num2, y, 48f, 20f), (num3 > 0) ? ("+" + num3) : num3.ToString()))
				{
					instance.SetForcedRefreshValue(Core.ForcedRefreshValue + num3);
				}
				num2 += 50f;
			}
			if (GUI.Button(new Rect(num2, y, 50f, 20f), "Log"))
			{
				ManualLogSource log = _log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(23, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Forced refresh value = ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(Core.ForcedRefreshValue);
				}
				log.LogInfo(val);
			}
			y += 26f;
			y = SectionHeader("Resources", y);
			float num4 = 6f;
			if (GUI.Button(new Rect(num4, y, 80f, 20f), "+1k Gold"))
			{
				instance.TryAddGold(1000);
			}
			num4 += 82f;
			if (GUI.Button(new Rect(num4, y, 80f, 20f), "+10k"))
			{
				instance.TryAddGold(10000);
			}
			num4 += 82f;
			if (GUI.Button(new Rect(num4, y, 80f, 20f), "+100k"))
			{
				instance.TryAddGold(100000);
			}
			num4 += 82f;
			if (GUI.Button(new Rect(num4, y, 80f, 20f), "+1M"))
			{
				instance.TryAddGold(1000000);
			}
			num4 += 82f;
			if (GUI.Button(new Rect(num4, y, 60f, 20f), "+XP"))
			{
				instance.TryAddXp(500);
			}
			num4 += 62f;
			if (GUI.Button(new Rect(num4, y, 70f, 20f), "+5kXP"))
			{
				instance.TryAddXp(5000);
			}
			num4 += 72f;
			if (GUI.Button(new Rect(num4, y, 50f, 20f), "+HP"))
			{
				instance.TryAddHealth(25);
			}
			y += 26f;
			y = SectionHeader("Patching & Debug", y);
			instance.AggressiveMode = GUI.Toggle(new Rect(6f, y, 120f, 20f), instance.AggressiveMode, "Aggressive");
			instance.DebugLogging = GUI.Toggle(new Rect(136f, y, 120f, 20f), instance.DebugLogging, "Debug Log");
			if (GUI.Button(new Rect(266f, y, 80f, 20f), "Reapply"))
			{
				instance.ReapplyPatches();
			}
			GUI.Label(new Rect(356f, y, 230f, 20f), $"Forced: {Core.ForcedRefreshValue}");
			y += 22f;
			GUI.Label(new Rect(6f, y, 560f, 20f), $"Patched -> Generic:{instance.GenericPatchCount} EShop:{instance.EShopItemPatchCount} Inv:{instance.PlayerInventoryPatchCount}");
			y += 26f;
			y = SectionHeader("Patched Methods" + (_expandList ? " (click to collapse)" : " (click to expand)"), y, clickable: true, delegate
			{
				_expandList = !_expandList;
			});
			if (_expandList)
			{
				float num5 = y;
				float num6 = ((Rect)(ref _panelRect)).height - num5 - 6f;
				if (num6 > 60f)
				{
					Rect val2 = default(Rect);
					((Rect)(ref val2))..ctor(0f, 0f, ((Rect)(ref _panelRect)).width - 32f, (float)(Core.PatchedMethodNames.Count * 18 + 4));
					Rect val3 = default(Rect);
					((Rect)(ref val3))..ctor(6f, num5, ((Rect)(ref _panelRect)).width - 12f, num6);
					_scrollPos = GUI.BeginScrollView(val3, _scrollPos, val2);
					float num7 = 2f;
					foreach (string patchedMethodName in Core.PatchedMethodNames)
					{
						GUI.Label(new Rect(0f, num7, ((Rect)(ref val2)).width - 4f, 18f), patchedMethodName);
						num7 += 18f;
					}
					GUI.EndScrollView();
				}
			}
			GUI.EndGroup();
		}

		private float SectionHeader(string title, float y, bool clickable = false, Action toggleAction = null)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(6f, y, ((Rect)(ref _panelRect)).width - 12f, 20f);
			if (clickable && GUI.Button(val, title, _sectionHeader))
			{
				toggleAction?.Invoke();
			}
			else if (!clickable)
			{
				GUI.Label(val, title, _sectionHeader);
			}
			return y + 20f + 2f;
		}

		private void DrawTitleBar()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(0f, 0f, ((Rect)(ref _panelRect)).width, 24f);
			GUI.Box(val, "");
			GUI.Label(new Rect(8f, 2f, ((Rect)(ref _panelRect)).width - 80f, 20f), "Mod Menu", GUI.skin.label);
			if (GUI.Button(new Rect(((Rect)(ref _panelRect)).width - 60f, 2f, 24f, 20f), _expandList ? "-" : "+"))
			{
				_expandList = !_expandList;
			}
			if (GUI.Button(new Rect(((Rect)(ref _panelRect)).width - 32f, 2f, 24f, 20f), "X"))
			{
				_show = false;
			}
			HandleDrag(val);
		}

		private void HandleDrag(Rect localDragRect)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Invalid comparison between Unknown and I4
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Invalid comparison between Unknown and I4
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			Event current = Event.current;
			if ((int)current.type == 0 && current.button == 0 && ((Rect)(ref localDragRect)).Contains(current.mousePosition))
			{
				_dragging = true;
				_dragOffset = current.mousePosition;
				current.Use();
			}
			else if ((int)current.type == 3 && _dragging)
			{
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor(current.mousePosition.x + ((Rect)(ref _panelRect)).x, current.mousePosition.y + ((Rect)(ref _panelRect)).y);
				((Rect)(ref _panelRect)).x = Mathf.Clamp(val.x - _dragOffset.x, 0f, (float)Screen.width - ((Rect)(ref _panelRect)).width);
				((Rect)(ref _panelRect)).y = Mathf.Clamp(val.y - _dragOffset.y, 0f, (float)Screen.height - ((Rect)(ref _panelRect)).height);
				current.Use();
			}
			else if ((int)current.type == 1 && current.button == 0)
			{
				_dragging = false;
			}
		}
	}
}