Decompiled source of DebugMod v1.0.3

plugins/DebugMod.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using DebugMod.Helpers;
using DebugMod.Hitbox;
using DebugMod.Interop;
using DebugMod.MonoBehaviours;
using DebugMod.SaveStates;
using DebugMod.UI;
using DebugMod.UI.Canvas;
using GlobalEnums;
using GlobalSettings;
using HarmonyLib;
using HutongGames.PlayMaker;
using HutongGames.PlayMaker.Actions;
using InControl;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using TeamCherry.Localization;
using TeamCherry.NestedFadeGroup;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.ResourceManagement.ResourceProviders;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("DebugMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3+e4dfb8da539f865e993dac26a01aab31632e7645")]
[assembly: AssemblyProduct("DebugMod")]
[assembly: AssemblyTitle("DebugMod")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/hk-speedrunning/Silksong.DebugMod")]
[assembly: NeutralResourcesLanguage("EN")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.3.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace Microsoft.CodeAnalysis
{
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace DebugMod
{
	[HarmonyPatch]
	[HarmonyPatch]
	public static class BindableFunctions
	{
		[CompilerGenerated]
		private sealed class <AdvanceMyFrame>d__73 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <AdvanceMyFrame>d__73(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					TimeScale.Frozen = false;
					<>2__current = (object)new WaitForFixedUpdate();
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					TimeScale.Frozen = true;
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private static string saveLevelStateAction;

		internal static int frameCounter;

		[BindableMethod(name = "CHEATS_KILLALL", category = "CATEGORY_CHEATS")]
		public static void KillAll()
		{
			int num = 0;
			HealthManager[] array = Object.FindObjectsByType<HealthManager>((FindObjectsSortMode)0);
			foreach (HealthManager val in array)
			{
				if (!val.isDead)
				{
					val.Die((float?)null, (AttackTypes)1, true);
					num++;
				}
			}
			DebugMod.LogConsole($"Killing {num} HealthManagers in scene");
		}

		[BindableMethod(name = "CHEATS_INFINITEJUMP", category = "CATEGORY_CHEATS")]
		public static void ToggleInfiniteJump()
		{
			PlayerData.instance.infiniteAirJump = !PlayerData.instance.infiniteAirJump;
			DebugMod.LogConsole("Infinite Jump set to " + PlayerData.instance.infiniteAirJump.ToString().ToUpper());
		}

		[BindableMethod(name = "CHEATS_INFINITESILK", category = "CATEGORY_CHEATS")]
		public static void ToggleInfiniteSilk()
		{
			DebugMod.infiniteSilk = !DebugMod.infiniteSilk;
			DebugMod.LogConsole("Infinite Silk set to " + DebugMod.infiniteSilk.ToString().ToUpper());
		}

		[BindableMethod(name = "CHEATS_INFINITEHP", category = "CATEGORY_CHEATS")]
		public static void ToggleInfiniteHP()
		{
			DebugMod.infiniteHP = !DebugMod.infiniteHP;
			DebugMod.LogConsole("Infinite HP set to " + DebugMod.infiniteHP.ToString().ToUpper());
		}

		[BindableMethod(name = "CHEATS_INFINITETOOLS", category = "CATEGORY_CHEATS")]
		public static void ToggleInfiniteTools()
		{
			DebugMod.infiniteTools = !DebugMod.infiniteTools;
			DebugMod.LogConsole("Infinite Tools set to " + DebugMod.infiniteTools.ToString().ToUpper());
		}

		[BindableMethod(name = "CHEATS_INVINCIBILITY", category = "CATEGORY_CHEATS")]
		public static void ToggleInvincibility()
		{
			DebugMod.playerInvincible = !DebugMod.playerInvincible;
			DebugMod.LogConsole("Invincibility set to " + DebugMod.playerInvincible.ToString().ToUpper());
			PlayerData.instance.isInvincible = DebugMod.playerInvincible;
		}

		[BindableMethod(name = "CHEATS_NOCLIP", category = "CATEGORY_CHEATS")]
		public static void ToggleNoclip()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			DebugMod.noclip = !DebugMod.noclip;
			if (DebugMod.noclip)
			{
				DebugMod.LogConsole("Enabled noclip");
				DebugMod.noclipPos = DebugMod.RefKnight.transform.position;
			}
			else
			{
				DebugMod.LogConsole("Disabled noclip");
				Rigidbody2D component = DebugMod.RefKnight.GetComponent<Rigidbody2D>();
				component.constraints = (RigidbodyConstraints2D)(component.constraints & -4);
			}
		}

		[BindableMethod(name = "CHEATS_TOGGLEHEROCOLLIDER", category = "CATEGORY_CHEATS")]
		public static void ToggleHeroCollider()
		{
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			if (DebugMod.heroColliderDisabled)
			{
				DebugMod.heroColliderDisabled = false;
				((Behaviour)DebugMod.RefHeroCollider).enabled = true;
				HeroBox.Inactive = false;
				DebugMod.LogConsole("Enabled hero collider" + (DebugMod.noclip ? " and disabled noclip" : ""));
				DebugMod.noclip = false;
				Rigidbody2D component = DebugMod.RefKnight.GetComponent<Rigidbody2D>();
				component.constraints = (RigidbodyConstraints2D)(component.constraints & -4);
			}
			else
			{
				DebugMod.heroColliderDisabled = true;
				((Behaviour)DebugMod.RefHeroCollider).enabled = false;
				HeroBox.Inactive = true;
				DebugMod.LogConsole("Disabled hero collider" + (DebugMod.noclip ? "" : " and enabled noclip"));
				DebugMod.noclip = true;
				DebugMod.noclipPos = DebugMod.RefKnight.transform.position;
			}
		}

		[BindableMethod(name = "CONSUMABLES_GIVEROSARIES", category = "CATEGORY_CONSUMABLES")]
		public static void GiveRosaries()
		{
			HeroController.instance.AddGeo(1000);
			DebugMod.LogConsole("Giving player 1000 rosaries");
		}

		[BindableMethod(name = "CONSUMABLES_GIVESHELLSHARDS", category = "CATEGORY_CONSUMABLES")]
		public static void GiveShellShards()
		{
			HeroController.instance.AddShards(100);
			DebugMod.LogConsole("Giving player 100 shell shards");
		}

		[BindableMethod(name = "CONSUMABLES_GIVEQUESTITEMS", category = "CATEGORY_CONSUMABLES")]
		public static void GiveQuestItems()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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)
			bool flag = false;
			foreach (FullQuestBase activeQuest in QuestManager.GetActiveQuests())
			{
				foreach (QuestTarget target in activeQuest.Targets)
				{
					QuestTargetCounter counter = target.Counter;
					CollectableItem val = (CollectableItem)(object)((counter is CollectableItem) ? counter : null);
					if (val != null)
					{
						int num = target.Count - val.CollectedAmount;
						if (num > 0)
						{
							val.Collect(num, true);
							flag = true;
						}
					}
				}
			}
			if (flag)
			{
				DebugMod.LogConsole("Gave necessary items for all active quests");
			}
			else
			{
				DebugMod.LogConsole("No active quests that need items, doing nothing");
			}
		}

		[BindableMethod(name = "ENEMIES_TOGGLEHPBARS", category = "CATEGORY_ENEMIES")]
		public static void ToggleEnemyHPBars()
		{
			EnemiesPanel.hpBars = !EnemiesPanel.hpBars;
			if (EnemiesPanel.hpBars)
			{
				DebugMod.LogConsole("Enabled HP bars");
			}
			else
			{
				DebugMod.LogConsole("Disabled HP bars");
			}
		}

		[BindableMethod(name = "MASKSANDSPOOLS_GIVEMASK", category = "CATEGORY_MASKSANDSPOOLS")]
		public static void GiveMask()
		{
			if (PlayerData.instance.maxHealthBase < 10)
			{
				HeroController.instance.MaxHealth();
				HeroController.instance.AddToMaxHealth(1);
				HudHelper.RefreshMasks();
				DebugMod.LogConsole("Added mask");
			}
			else
			{
				DebugMod.LogConsole("You have the maximum number of masks");
			}
		}

		[BindableMethod(name = "MASKSANDSPOOLS_GIVESPOOL", category = "CATEGORY_MASKSANDSPOOLS")]
		public static void GiveSpool()
		{
			if (PlayerData.instance.silkMax < 18)
			{
				HeroController.instance.AddToMaxSilk(1);
				HudHelper.RefreshSpool();
				DebugMod.LogConsole("Added spool");
			}
			else
			{
				DebugMod.LogConsole("You have the maximum number of spools");
			}
			PlayerData.instance.IsSilkSpoolBroken = false;
			EventRegister.SendEvent("SPOOL UNBROKEN", (GameObject)null);
		}

		[BindableMethod(name = "MASKSANDSPOOLS_TAKEMASK", category = "CATEGORY_MASKSANDSPOOLS")]
		public static void TakeAwayMask()
		{
			if (PlayerData.instance.maxHealthBase > 1)
			{
				PlayerData instance = PlayerData.instance;
				instance.maxHealth--;
				PlayerData instance2 = PlayerData.instance;
				instance2.maxHealthBase--;
				PlayerData.instance.health = Math.Min(PlayerData.instance.health, PlayerData.instance.maxHealth);
				HudHelper.RefreshMasks();
				DebugMod.LogConsole("Removed mask");
			}
			else
			{
				DebugMod.LogConsole("You have the minimum number of masks");
			}
		}

		[BindableMethod(name = "MASKSANDSPOOLS_TAKESPOOL", category = "CATEGORY_MASKSANDSPOOLS")]
		public static void TakeAwaySpool()
		{
			if (PlayerData.instance.silkMax > 9)
			{
				PlayerData instance = PlayerData.instance;
				instance.silkMax--;
				PlayerData.instance.silk = Math.Min(PlayerData.instance.silk, PlayerData.instance.silkMax);
				HudHelper.RefreshSpool();
				DebugMod.LogConsole("Removed spool");
			}
			else
			{
				DebugMod.LogConsole("You have the minimum number of spools");
			}
		}

		private static bool CanModifyHealth(int health)
		{
			if (health <= 0)
			{
				DebugMod.LogConsole("Cannot add/take health: health <= 0");
				return false;
			}
			if (HeroController.instance.cState.dead)
			{
				DebugMod.LogConsole("Cannot add/take health: player is dead");
				return false;
			}
			if (!GameManager.instance.IsGameplayScene())
			{
				DebugMod.LogConsole("Cannot add/take health: not a gameplay scene");
				return false;
			}
			return true;
		}

		[BindableMethod(name = "MASKSANDSPOOLS_ADDHEALTH", category = "CATEGORY_MASKSANDSPOOLS")]
		public static void AddHealth()
		{
			if (CanModifyHealth(PlayerData.instance.health + 1))
			{
				HeroController.instance.AddHealth(1);
				HudHelper.RefreshMasks();
				DebugMod.LogConsole("Added health");
			}
		}

		[BindableMethod(name = "MASKSANDSPOOLS_TAKEHEALTH", category = "CATEGORY_MASKSANDSPOOLS")]
		public static void TakeHealth()
		{
			if (CanModifyHealth(PlayerData.instance.health - 1))
			{
				HeroController.instance.TakeHealth(1);
				HudHelper.RefreshMasks();
				DebugMod.LogConsole("Took health");
			}
		}

		[BindableMethod(name = "MASKSANDSPOOLS_ADDSILK", category = "CATEGORY_MASKSANDSPOOLS")]
		public static void AddSilk()
		{
			HeroController.instance.AddSilk(1, true);
			DebugMod.LogConsole("Added silk");
		}

		[BindableMethod(name = "MASKSANDSPOOLS_TAKESILK", category = "CATEGORY_MASKSANDSPOOLS")]
		public static void TakeSilk()
		{
			HeroController.instance.TakeSilk(1);
			DebugMod.LogConsole("Attempting to take silk");
		}

		[BindableMethod(name = "MASKSANDSPOOLS_ADDLIFEBLOOD", category = "CATEGORY_MASKSANDSPOOLS")]
		public static void Lifeblood()
		{
			bool isInLifebloodState = HeroController.instance.IsInLifebloodState;
			EventRegister.SendEvent("ADD BLUE HEALTH", (GameObject)null);
			if (!isInLifebloodState && HeroController.instance.IsInLifebloodState)
			{
				HeroController.instance.HitMaxBlueHealthBurst();
			}
			DebugMod.LogConsole("Attempting to add lifeblood");
		}

		[BindableMethod(name = "MISC_TOGGLEACT3", category = "CATEGORY_MISC")]
		public static void ToggleAct3()
		{
			PlayerData.instance.blackThreadWorld = !PlayerData.instance.blackThreadWorld;
			DebugMod.LogConsole("Act 3 world is now " + (PlayerData.instance.blackThreadWorld ? "enabled" : "disabled") + ", reload the scene to apply changes");
		}

		[BindableMethod(name = "MISC_SETHAZARDRESPAWN", category = "CATEGORY_MISC")]
		public static void SetHazardRespawn()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = DebugMod.RefKnight.transform.position;
			HeroController.instance.SetHazardRespawn(position, false);
			Vector3 val = position;
			DebugMod.LogConsole("Manual respawn point on this map set to" + ((object)(Vector3)(ref val)).ToString());
		}

		[BindableMethod(name = "MISC_HAZARDRESPAWN", category = "CATEGORY_MISC")]
		public static void Respawn()
		{
			if (GameManager.instance.IsGameplayScene() && !HeroController.instance.cState.dead && PlayerData.instance.health > 0)
			{
				if (((object)(UIState)(ref UIManager.instance.uiState)).ToString() == "PAUSED")
				{
					((MonoBehaviour)ManagerSingleton<InputHandler>.Instance).StartCoroutine(GameManager.instance.PauseGameToggle(false));
					GameManager.instance.HazardRespawn();
					DebugMod.LogConsole("Closing pause menu and respawning...");
				}
				else if (((object)(UIState)(ref UIManager.instance.uiState)).ToString() == "PLAYING")
				{
					HeroController.instance.RelinquishControl();
					GameManager.instance.HazardRespawn();
					HeroController.instance.RegainControl();
					DebugMod.LogConsole("Respawn signal sent");
				}
				else
				{
					DebugMod.LogConsole("How are you seeing this??? (please create a bug report)");
				}
			}
		}

		[BindableMethod(name = "MISC_DAMAGESELF", category = "CATEGORY_MISC")]
		public static void SelfDamage()
		{
			if (PlayerData.instance.health <= 0)
			{
				DebugMod.LogConsole("Cannot damage self: health <= 0");
				return;
			}
			if (HeroController.instance.cState.dead)
			{
				DebugMod.LogConsole("Cannot damage self: player is dead");
				return;
			}
			if (!GameManager.instance.IsGameplayScene())
			{
				DebugMod.LogConsole("Cannot damage self: not a gameplay scene");
				return;
			}
			if (HeroController.instance.cState.recoiling)
			{
				DebugMod.LogConsole("Cannot damage self: player is recoiling");
				return;
			}
			if (HeroController.instance.cState.invulnerable)
			{
				DebugMod.LogConsole("Cannot damage self: player is invulnerable");
				return;
			}
			HeroController.instance.DamageSelf(1);
			DebugMod.LogConsole("Attempting self damage");
		}

		[BindableMethod(name = "MISC_KILLSELF", category = "CATEGORY_MISC")]
		public static void KillSelf()
		{
			if (!HeroController.instance.cState.dead && !HeroController.instance.cState.transitioning)
			{
				((MonoBehaviour)HeroController.instance).StartCoroutine(HeroController.instance.Die(false, false));
				DebugMod.LogConsole("Killed player");
			}
		}

		[BindableMethod(name = "MISC_BREAKCOCOON", category = "CATEGORY_MISC")]
		public static void BreakCocoon()
		{
			HeroController instance = HeroController.instance;
			if (instance != null)
			{
				instance.CocoonBroken();
			}
			EventRegister.SendEvent("BREAK HERO CORPSE", (GameObject)null);
		}

		[BindableMethod(name = "MISC_RESETCURRENTSCENEDATA", category = "CATEGORY_MISC")]
		public static void ResetCurrentScene()
		{
			saveLevelStateAction = GameManager.instance.GetSceneNameString();
			DebugMod.LogConsole("Clearing scene data from this scene, reload the scene to apply changes");
		}

		[BindableMethod(name = "MISC_BLOCKSCENEDATACHANGES", category = "CATEGORY_MISC")]
		public static void BlockCurrentSceneChanges()
		{
			saveLevelStateAction = "block";
			DebugMod.LogConsole("Scene data changes made since entering this scene will not be saved");
		}

		[BindableMethod(name = "MISC_QUEUEWALLJUMPINTERRUPT", category = "CATEGORY_MISC")]
		public static void QueueWallJump()
		{
			HeroController.instance.queuedWallJumpInterrupt = true;
		}

		[HarmonyPatch(typeof(GameManager), "SaveLevelState")]
		[HarmonyPrefix]
		private static bool GameManager_SaveLevelState_Prefix()
		{
			if (saveLevelStateAction == "block")
			{
				saveLevelStateAction = null;
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(GameManager), "SaveLevelState")]
		[HarmonyPostfix]
		private static void GameManager_SaveLevelState_Postfix()
		{
			if (saveLevelStateAction != null && saveLevelStateAction != "block")
			{
				((PersistentItemDataCollection<bool, SerializableBoolData>)(object)SceneData.instance.persistentBools).scenes.Remove(saveLevelStateAction);
				((PersistentItemDataCollection<int, SerializableIntData>)(object)SceneData.instance.persistentInts).scenes.Remove(saveLevelStateAction);
				((PersistentItemDataCollection<int, SerializableIntData>)(object)SceneData.instance.geoRocks).scenes.Remove(saveLevelStateAction);
				saveLevelStateAction = null;
			}
		}

		[BindableMethod(name = "MISC_LOCKKEYBINDS", category = "CATEGORY_MISC")]
		public static void ToggleLockKeyBinds()
		{
			DebugMod.KeyBindLock = !DebugMod.KeyBindLock;
			DebugMod.LogConsole((DebugMod.KeyBindLock ? "Removing" : "Adding") + " the ability to use keybinds");
		}

		[BindableMethod(name = "MISC_RESETCHEATS", category = "CATEGORY_MISC")]
		public static void Reset()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			PlayerData instance = PlayerData.instance;
			_ = HeroController.instance;
			GameCameras instance2 = GameCameras.instance;
			DebugMod.extraNailDamage = 0;
			PlayerData.instance.nailUpgrades = 0;
			PlayMakerFSM.BroadcastEvent("UPDATE NAIL DAMAGE");
			GameObject gameObject = ((Component)DebugMod.RefKnight.transform.Find("HeroLight")).gameObject;
			Color color = gameObject.GetComponent<SpriteRenderer>().color;
			color.a = 0.7f;
			gameObject.GetComponent<SpriteRenderer>().color = color;
			tk2dSprite component = DebugMod.RefKnight.GetComponent<tk2dSprite>();
			color = ((tk2dBaseSprite)component).color;
			color.a = 1f;
			((tk2dBaseSprite)component).color = color;
			DebugMod.noclip = false;
			Rigidbody2D component2 = DebugMod.RefKnight.GetComponent<Rigidbody2D>();
			component2.constraints = (RigidbodyConstraints2D)(component2.constraints & -4);
			TimeScale.Reset();
			instance2.tk2dCam.ZoomFactor = 1f;
			VisualMaskHelper.vignetteDisabled = false;
			((Renderer)DebugMod.HC.vignette).enabled = true;
			EnemiesPanel.hpBars = false;
			instance.infiniteAirJump = false;
			DebugMod.infiniteSilk = false;
			DebugMod.infiniteHP = false;
			instance.isInvincible = false;
			DebugMod.LogConsole("Reset all gameplay toggles");
		}

		[BindableMethod(name = "MODUI_TOGGLEALLUI", category = "CATEGORY_MODUI", allowLock = false)]
		public static void ToggleAllPanels()
		{
			bool flag = !DebugMod.settings.InfoPanelVisible && !DebugMod.settings.EnemiesPanelVisible && !DebugMod.settings.MainPanelVisible && !DebugMod.settings.ConsoleVisible && !DebugMod.settings.SaveStatePanelVisible;
			DebugMod.settings.InfoPanelVisible = flag;
			DebugMod.settings.MainPanelVisible = flag;
			DebugMod.settings.EnemiesPanelVisible = flag;
			DebugMod.settings.ConsoleVisible = flag;
			DebugMod.settings.SaveStatePanelVisible = flag;
		}

		[BindableMethod(name = "MODUI_TOGGLEMAINPANEL", category = "CATEGORY_MODUI")]
		public static void ToggleMainPanel()
		{
			DebugMod.settings.MainPanelVisible = !DebugMod.settings.MainPanelVisible;
		}

		[BindableMethod(name = "MODUI_TOGGLEENEMIESPANEL", category = "CATEGORY_MODUI")]
		public static void ToggleEnemiesPanel()
		{
			DebugMod.settings.EnemiesPanelVisible = !DebugMod.settings.EnemiesPanelVisible;
		}

		[BindableMethod(name = "MODUI_TOGGLECONSOLEPANEL", category = "CATEGORY_MODUI")]
		public static void ToggleConsolePanel()
		{
			DebugMod.settings.ConsoleVisible = !DebugMod.settings.ConsoleVisible;
		}

		[BindableMethod(name = "MODUI_TOGGLEINFOPANEL", category = "CATEGORY_MODUI")]
		public static void ToggleInfoPanel()
		{
			DebugMod.settings.InfoPanelVisible = !DebugMod.settings.InfoPanelVisible;
		}

		[BindableMethod(name = "MODUI_TOGGLESAVESTATESPANEL", category = "CATEGORY_MODUI")]
		public static void ToggleSaveStatePanel()
		{
			DebugMod.settings.SaveStatePanelVisible = !DebugMod.settings.SaveStatePanelVisible;
			if (!DebugMod.settings.SaveStatePanelVisible)
			{
				SaveStatesPanel.Instance.CancelSelectState();
			}
		}

		[BindableMethod(name = "MODUI_EXPANDCOLLAPSESAVESTATES", category = "CATEGORY_MODUI")]
		public static void ToggleExpandedSaveStatePanel()
		{
			SaveStatesPanel.Instance.ToggleView();
		}

		[BindableMethod(name = "MODUI_ALWAYSSHOWCURSOR", category = "CATEGORY_MODUI")]
		public static void ToggleAlwaysShowCursor()
		{
			DebugMod.settings.ShowCursorWhileUnpaused = !DebugMod.settings.ShowCursorWhileUnpaused;
			if (DebugMod.settings.ShowCursorWhileUnpaused)
			{
				DebugMod.LogConsole("Showing cursor while unpaused");
			}
			else
			{
				DebugMod.LogConsole("Not showing cursor while unpaused");
			}
		}

		[BindableMethod(name = "SAVESTATES_QUICKSLOTSAVE", category = "CATEGORY_SAVESTATES")]
		public static void SaveState()
		{
			SaveStateManager.SetQuickState(SaveStateManager.SaveNewState());
		}

		[BindableMethod(name = "SAVESTATES_QUICKSLOTLOAD", category = "CATEGORY_SAVESTATES")]
		public static void LoadState()
		{
			SaveStateManager.LoadState(SaveStateManager.GetQuickState());
		}

		[BindableMethod(name = "SAVESTATES_QUICKSLOTTOFILE", category = "CATEGORY_SAVESTATES")]
		public static void CurrentSaveStateToFile()
		{
			SaveStatesPanel.Instance.EnterSelectState(SelectOperation.QuickslotToFile);
		}

		[BindableMethod(name = "SAVESTATES_FILETOQUICKSLOT", category = "CATEGORY_SAVESTATES")]
		public static void CurrentSlotToSaveMemory()
		{
			SaveStatesPanel.Instance.EnterSelectState(SelectOperation.FileToQuickslot);
		}

		[BindableMethod(name = "SAVESTATES_SAVETOFILE", category = "CATEGORY_SAVESTATES")]
		public static void NewSaveStateToFile()
		{
			SaveStatesPanel.Instance.EnterSelectState(SelectOperation.SaveToFile);
		}

		[BindableMethod(name = "SAVESTATES_LOADFROMFILE", category = "CATEGORY_SAVESTATES")]
		public static void LoadFromFile()
		{
			SaveStatesPanel.Instance.EnterSelectState(SelectOperation.LoadFromFile);
		}

		[BindableMethod(name = "SAVESTATES_NEXTSAVESTATEPAGE", category = "CATEGORY_SAVESTATES")]
		public static void NextStatePage()
		{
			SaveStatesPanel.Instance.NextPage();
		}

		[BindableMethod(name = "SAVESTATES_PREVSAVESTATEPAGE", category = "CATEGORY_SAVESTATES")]
		public static void PrevStatePage()
		{
			SaveStatesPanel.Instance.PrevPage();
		}

		[BindableMethod(name = "SAVESTATES_REFRESHFILESLOTS", category = "CATEGORY_SAVESTATES")]
		public static void RefreshFileSlots()
		{
			SaveStateManager.LoadFileStates();
			DebugMod.LogConsole("Reimporting file slots from disk");
		}

		[BindableMethod(name = "SAVESTATES_SAVESTATEONDEATH", category = "CATEGORY_SAVESTATES")]
		public static void LoadStateOnDeath()
		{
			DebugMod.stateOnDeath = !DebugMod.stateOnDeath;
			DebugMod.LogConsole("Quickslot savestate will now" + (DebugMod.stateOnDeath ? " be" : " no longer") + " loaded on death");
		}

		[BindableMethod(name = "SAVESTATES_OVERRIDELOADLOCKOUT", category = "CATEGORY_SAVESTATES")]
		public static void OverrideLoadLockout()
		{
			DebugMod.overrideLoadLockout = !DebugMod.overrideLoadLockout;
			DebugMod.LogConsole("Savestate lockout override set to " + DebugMod.overrideLoadLockout.ToString().ToUpper());
		}

		[BindableMethod(name = "SKILLS_GIVEALLSKILLS", category = "CATEGORY_SKILLS")]
		public static void GiveAllSkills()
		{
			PlayerData.instance.hasDash = true;
			PlayerData.instance.hasBrolly = true;
			PlayerData.instance.hasWalljump = true;
			PlayerData.instance.hasHarpoonDash = true;
			PlayerData.instance.hasDoubleJump = true;
			PlayerData.instance.hasSuperJump = true;
			PlayerData.instance.hasNeedolin = true;
			PlayerData.instance.UnlockedFastTravelTeleport = true;
			PlayerData.instance.hasNeedolinMemoryPowerup = true;
			PlayerData.instance.hasChargeSlash = true;
			PlayerData.instance.nailUpgrades = 4;
			PlayerData.instance.silkRegenMax = 3;
			PlayerData.instance.ToolKitUpgrades = 4;
			PlayerData.instance.ToolPouchUpgrades = 4;
			DebugMod.extraNailDamage = 0;
			DebugMod.LogConsole("Giving player all skills and upgrades");
		}

		[BindableMethod(name = "SKILLS_TOGGLESWIFTSTEP", category = "CATEGORY_SKILLS")]
		public static void ToggleSwiftStep()
		{
			if (!PlayerData.instance.hasDash)
			{
				PlayerData.instance.hasDash = true;
				DebugMod.LogConsole("Giving player Swift Step");
			}
			else
			{
				PlayerData.instance.hasDash = false;
				DebugMod.LogConsole("Taking away Swift Step");
			}
		}

		[BindableMethod(name = "SKILLS_TOGGLEDRIFTERSCLOAK", category = "CATEGORY_SKILLS")]
		public static void ToggleDriftersCloak()
		{
			if (!PlayerData.instance.hasBrolly)
			{
				PlayerData.instance.hasBrolly = true;
				DebugMod.LogConsole("Giving player Drifter's Cloak");
			}
			else
			{
				PlayerData.instance.hasBrolly = false;
				DebugMod.LogConsole("Taking away Drifter's Cloak");
			}
		}

		[BindableMethod(name = "SKILLS_TOGGLECLINGGRIP", category = "CATEGORY_SKILLS")]
		public static void ToggleClingGrip()
		{
			if (!PlayerData.instance.hasWalljump)
			{
				PlayerData.instance.hasWalljump = true;
				DebugMod.LogConsole("Giving player Cling Grip");
			}
			else
			{
				PlayerData.instance.hasWalljump = false;
				DebugMod.LogConsole("Taking away Cling Grip");
			}
		}

		[BindableMethod(name = "SKILLS_TOGGLENEEDOLIN", category = "CATEGORY_SKILLS")]
		public static void ToggleNeedolin()
		{
			if (!PlayerData.instance.hasNeedolin)
			{
				PlayerData.instance.hasNeedolin = true;
				DebugMod.LogConsole("Giving player Needolin");
				return;
			}
			PlayerData.instance.hasNeedolin = false;
			PlayerData.instance.UnlockedFastTravelTeleport = false;
			PlayerData.instance.hasNeedolinMemoryPowerup = false;
			DebugMod.LogConsole("Taking away Needolin and any upgrades");
		}

		[BindableMethod(name = "SKILLS_TOGGLECLAWLINE", category = "CATEGORY_SKILLS")]
		public static void ToggleClawline()
		{
			if (!PlayerData.instance.hasHarpoonDash)
			{
				PlayerData.instance.hasHarpoonDash = true;
				DebugMod.LogConsole("Giving player Clawline");
			}
			else
			{
				PlayerData.instance.hasHarpoonDash = false;
				DebugMod.LogConsole("Taking away Clawline");
			}
		}

		[BindableMethod(name = "SKILLS_TOGGLEFAYDOWNCLOAK", category = "CATEGORY_SKILLS")]
		public static void ToggleFaydownCloak()
		{
			if (!PlayerData.instance.hasDoubleJump)
			{
				PlayerData.instance.hasDoubleJump = true;
				DebugMod.LogConsole("Giving player Faydown Cloak");
			}
			else
			{
				PlayerData.instance.hasDoubleJump = false;
				DebugMod.LogConsole("Taking away Faydown Cloak");
			}
		}

		[BindableMethod(name = "SKILLS_TOGGLESILKSOAR", category = "CATEGORY_SKILLS")]
		public static void ToggleSilkSoar()
		{
			if (!PlayerData.instance.hasSuperJump)
			{
				PlayerData.instance.hasSuperJump = true;
				DebugMod.LogConsole("Giving player Silk Soar");
			}
			else
			{
				PlayerData.instance.hasSuperJump = false;
				DebugMod.LogConsole("Taking away Silk Soar");
			}
		}

		[BindableMethod(name = "SKILLS_TOGGLEBEASTLINGCALL", category = "CATEGORY_SKILLS")]
		public static void ToggleBeastlingCall()
		{
			if (!PlayerData.instance.hasNeedolin && !PlayerData.instance.UnlockedFastTravelTeleport)
			{
				PlayerData.instance.hasNeedolin = true;
				PlayerData.instance.UnlockedFastTravelTeleport = true;
				DebugMod.LogConsole("Giving player Needolin with Beastling Call");
			}
			else if (PlayerData.instance.hasNeedolin && !PlayerData.instance.UnlockedFastTravelTeleport)
			{
				PlayerData.instance.UnlockedFastTravelTeleport = true;
				DebugMod.LogConsole("Giving player Beastling Call");
			}
			else
			{
				PlayerData.instance.UnlockedFastTravelTeleport = false;
				DebugMod.LogConsole("Taking away Beastling Call");
			}
		}

		[BindableMethod(name = "SKILLS_TOGGLEELEGYOFTHEDEEP", category = "CATEGORY_SKILLS")]
		public static void ToggleElegyOfTheDeep()
		{
			if (!PlayerData.instance.hasNeedolin && !PlayerData.instance.hasNeedolinMemoryPowerup)
			{
				PlayerData.instance.hasNeedolin = true;
				PlayerData.instance.hasNeedolinMemoryPowerup = true;
				DebugMod.LogConsole("Giving player Needolin with Elegy of the Deep");
			}
			else if (PlayerData.instance.hasNeedolin && !PlayerData.instance.hasNeedolinMemoryPowerup)
			{
				PlayerData.instance.hasNeedolinMemoryPowerup = true;
				DebugMod.LogConsole("Giving player Elegy of the Deep");
			}
			else
			{
				PlayerData.instance.hasNeedolinMemoryPowerup = false;
				DebugMod.LogConsole("Taking away Elegy of the Deep");
			}
		}

		[BindableMethod(name = "SKILLS_TOGGLENEEDLESTRIKE", category = "CATEGORY_SKILLS")]
		public static void ToggleNeedleStrike()
		{
			if (!PlayerData.instance.hasChargeSlash)
			{
				PlayerData.instance.hasChargeSlash = true;
				DebugMod.LogConsole("Giving player Needle Strike");
			}
			else
			{
				PlayerData.instance.hasChargeSlash = false;
				DebugMod.LogConsole("Taking away Needle Strike");
			}
		}

		[BindableMethod(name = "TIME_INCREASETIMESCALE", category = "CATEGORY_TIME")]
		public static void TimescaleUp()
		{
			TimeScale.CustomTimeScale = Mathf.Round(TimeScale.CustomTimeScale * 10f + 1f) / 10f;
		}

		[BindableMethod(name = "TIME_DECREASETIMESCALE", category = "CATEGORY_TIME")]
		public static void TimescaleDown()
		{
			TimeScale.CustomTimeScale = Mathf.Round(TimeScale.CustomTimeScale * 10f - 1f) / 10f;
		}

		[BindableMethod(name = "TIME_RESETTIMESCALE", category = "CATEGORY_TIME")]
		public static void TimescaleReset()
		{
			TimeScale.CustomTimeScale = 1f;
		}

		[BindableMethod(name = "TIME_FREEZEGAME", category = "CATEGORY_TIME")]
		public static void PauseGameNoUI()
		{
			TimeScale.Frozen = !TimeScale.Frozen;
			if (TimeScale.Frozen)
			{
				frameCounter = 0;
				DebugMod.LogConsole("Game frozen");
			}
			else
			{
				DebugMod.LogConsole("Game unfrozen");
			}
		}

		[BindableMethod(name = "TIME_FORCEPAUSE", category = "CATEGORY_TIME")]
		public static void ForcePause()
		{
			try
			{
				if (PlayerData.instance.disablePause || GameManager.instance.TimeSlowed || (UIManager.instance.ignoreUnpause && DebugMod.GetSceneName() != "Menu_Title" && DebugMod.GM.IsGameplayScene()))
				{
					GameManager.instance.timeSlowedCount = 0;
					UIManager.instance.ignoreUnpause = false;
					PlayerData.instance.disablePause = false;
					UIManager.instance.TogglePauseGame();
					DebugMod.LogConsole("Forcing pause menu because pause is disabled");
				}
				else
				{
					DebugMod.LogConsole("Pausing game");
					UIManager.instance.TogglePauseGame();
				}
				DebugMod.forcePaused = !GameManager.instance.isPaused;
			}
			catch (Exception ex)
			{
				DebugMod.LogConsole("Error while attempting to pause, please create a bug report");
				DebugMod.Log("Error while attempting force pause:\n" + ex);
			}
		}

		[BindableMethod(name = "TIME_ADVANCEFRAME", category = "CATEGORY_TIME")]
		public static void AdvanceFrame()
		{
			if (!TimeScale.Frozen)
			{
				TimeScale.Frozen = true;
			}
			frameCounter++;
			((MonoBehaviour)GameManager.instance).StartCoroutine(AdvanceMyFrame());
		}

		[IteratorStateMachine(typeof(<AdvanceMyFrame>d__73))]
		private static IEnumerator AdvanceMyFrame()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <AdvanceMyFrame>d__73(0);
		}

		[BindableMethod(name = "TIME_RESETFRAMECOUNTER", category = "CATEGORY_TIME")]
		public static void ResetFrameCounter()
		{
			DebugMod.LogConsole($"Frame counter reset (was {frameCounter})");
			frameCounter = 0;
		}

		[BindableMethod(name = "TOOLS_UNLOCKALLTOOLS", category = "CATEGORY_TOOLS")]
		public static void UnlockAllTools()
		{
			HashSet<string> hashSet = new HashSet<string> { "Curve Claws Upgraded", "WebShot Architect", "WebShot Weaver", "Mosscreep Tool 2", "Dazzle Bind Upgraded", "Shell Satchel" };
			foreach (ToolItem allTool in ToolItemManager.GetAllTools())
			{
				if (!hashSet.Contains(allTool.name))
				{
					allTool.Unlock((Action)null, (PopupFlags)0);
				}
				else
				{
					allTool.Lock();
				}
			}
			DebugMod.LogConsole("Unlocked all tools");
		}

		[BindableMethod(name = "CRESTS_UNLOCKALLCRESTS", category = "CATEGORY_TOOLS")]
		public static void UnlockAllCrests()
		{
			ToolItemManager.UnlockAllCrests();
			DebugMod.LogConsole("Unlocked all crests");
		}

		[BindableMethod(name = "TOOLS_CRAFTTOOLS", category = "CATEGORY_TOOLS")]
		public static void CraftTools()
		{
			ToolItemManager.TryReplenishTools(true, (ReplenishMethod)0);
			DebugMod.LogConsole("Crafted new tools");
		}

		[BindableMethod(name = "CRESTS_TOGGLECURSED", category = "CATEGORY_TOOLS")]
		public static void ToggleCursed()
		{
			if (((ToolBase)Gameplay.CursedCrest).IsEquipped)
			{
				ToolItemManager.ResetPreviousCrest();
				PlayerData.instance.PreviousCrestID = "";
				Utils.AutoEquipCrest(null, removeTools: false);
				DebugMod.LogConsole("Disabled cursed state");
			}
			else
			{
				Utils.AutoEquipCrest(Gameplay.CursedCrest, removeTools: true);
				DebugMod.LogConsole("Enabled cursed state");
			}
			HeroController.instance.UpdateSilkCursed();
		}

		[BindableMethod(name = "CRESTS_TOGGLECLOAKLESS", category = "CATEGORY_TOOLS")]
		public static void ToggleCloakless()
		{
			if (((ToolBase)Gameplay.CloaklessCrest).IsEquipped)
			{
				ToolItemManager.ResetPreviousCrest();
				PlayerData.instance.PreviousCrestID = "";
				Utils.AutoEquipCrest(null, removeTools: false);
				DebugMod.LogConsole("Disabled cloakless state");
			}
			else
			{
				Utils.AutoEquipCrest(Gameplay.CloaklessCrest, removeTools: true);
				DebugMod.LogConsole("Enabled cloakless state");
			}
			if (PlayerData.instance.PreviousCrestID == "Cursed")
			{
				HeroController.instance.UpdateSilkCursed();
			}
			HeroController.instance.ResetAllCrestState();
			HeroController.instance.animCtrl.PlayFromFrame(HeroController.instance.animCtrl.animator.CurrentClip.name, HeroController.instance.animCtrl.animator.CurrentFrame, true);
		}

		[BindableMethod(name = "UPGRADES_INCREASENEEDLEDAMAGE", category = "CATEGORY_UPGRADES")]
		public static void IncreaseNeedleDamage()
		{
			if (PlayerData.instance.nailDamage == 0)
			{
				PlayerData.instance.nailUpgrades = 0;
				DebugMod.extraNailDamage = 0;
				DebugMod.LogConsole("Resetting needle damage to 5");
			}
			else if (PlayerData.instance.nailUpgrades == 4 || DebugMod.extraNailDamage < 0)
			{
				DebugMod.extraNailDamage += 4;
				DebugMod.LogConsole("Adding 4 extra needle damage");
			}
			else
			{
				PlayerData instance = PlayerData.instance;
				instance.nailUpgrades++;
				DebugMod.LogConsole("Adding needle upgrade");
			}
			PlayMakerFSM.BroadcastEvent("UPDATE NAIL DAMAGE");
		}

		[BindableMethod(name = "UPGRADES_DECREASENEEDLEDAMAGE", category = "CATEGORY_UPGRADES")]
		public static void DecreaseNeedleDamage()
		{
			if (PlayerData.instance.nailUpgrades == 0 || DebugMod.extraNailDamage > 0)
			{
				DebugMod.extraNailDamage -= 4;
				if (DebugMod.extraNailDamage < -5)
				{
					DebugMod.extraNailDamage = -5;
					DebugMod.LogConsole("Setting needle damage to 0");
				}
				else
				{
					DebugMod.LogConsole("Reducing needle damage by 4");
				}
			}
			else
			{
				PlayerData instance = PlayerData.instance;
				instance.nailUpgrades--;
				DebugMod.LogConsole("Removing needle upgrade");
			}
			PlayMakerFSM.BroadcastEvent("UPDATE NAIL DAMAGE");
		}

		[BindableMethod(name = "UPGRADES_INCREMENTCRAFTINGKIT", category = "CATEGORY_UPGRADES")]
		public static void IncrementKits()
		{
			if (PlayerData.instance.ToolKitUpgrades < 4)
			{
				PlayerData instance = PlayerData.instance;
				instance.ToolKitUpgrades++;
				DebugMod.LogConsole($"Increasing crafting kit level (now {PlayerData.instance.ToolKitUpgrades})");
			}
			else
			{
				DebugMod.LogConsole("Crafting kit already at max level");
			}
		}

		[BindableMethod(name = "UPGRADES_DECREMENTCRAFTINGKIT", category = "CATEGORY_UPGRADES")]
		public static void DecrementKits()
		{
			if (PlayerData.instance.ToolKitUpgrades > 0)
			{
				PlayerData instance = PlayerData.instance;
				instance.ToolKitUpgrades--;
				DebugMod.LogConsole($"Decreasing crafting kit level (now {PlayerData.instance.ToolKitUpgrades})");
			}
			else
			{
				DebugMod.LogConsole("Crafting kit already at base level");
			}
		}

		[BindableMethod(name = "UPGRADES_INCREMENTTOOLPOUCH", category = "CATEGORY_UPGRADES")]
		public static void IncrementPouches()
		{
			if (PlayerData.instance.ToolPouchUpgrades < 4)
			{
				PlayerData instance = PlayerData.instance;
				instance.ToolPouchUpgrades++;
				DebugMod.LogConsole($"Increasing tool pouch level (now {PlayerData.instance.ToolPouchUpgrades})");
			}
			else
			{
				DebugMod.LogConsole("Tool pouch already at max level");
			}
		}

		[BindableMethod(name = "UPGRADES_DECREMENTTOOLPOUCH", category = "CATEGORY_UPGRADES")]
		public static void DecrementPouches()
		{
			if (PlayerData.instance.ToolPouchUpgrades > 0)
			{
				PlayerData instance = PlayerData.instance;
				instance.ToolPouchUpgrades--;
				DebugMod.LogConsole($"Decreasing tool pouch level (now {PlayerData.instance.ToolPouchUpgrades})");
			}
			else
			{
				DebugMod.LogConsole("Tool pouch already at base level");
			}
		}

		[BindableMethod(name = "UPGRADES_INCREMENTSILKHEARTS", category = "CATEGORY_UPGRADES")]
		public static void IncrementSilkHeart()
		{
			PlayerData instance = PlayerData.instance;
			instance.silkRegenMax++;
			DebugMod.LogConsole($"Incremented silk hearts (now {PlayerData.instance.silkRegenMax})");
		}

		[BindableMethod(name = "UPGRADES_DECREMENTSILKHEARTS", category = "CATEGORY_UPGRADES")]
		public static void DecrementSilkHeart()
		{
			if (PlayerData.instance.silkRegenMax > 0)
			{
				PlayerData instance = PlayerData.instance;
				instance.silkRegenMax--;
				DebugMod.LogConsole($"Decremented silk hearts (now {PlayerData.instance.silkRegenMax})");
			}
			else
			{
				DebugMod.LogConsole("Already at 0 silk hearts");
			}
		}

		[BindableMethod(name = "UPGRADES_ALLMAPS", category = "CATEGORY_UPGRADES")]
		public static void UnlockAllMaps()
		{
			if (PlayerData.instance.HasAllMaps)
			{
				PlayerData.instance.HasAbyssMap = false;
				PlayerData.instance.HasAqueductMap = false;
				PlayerData.instance.HasArboriumMap = false;
				PlayerData.instance.HasBellhartMap = false;
				PlayerData.instance.HasBoneforestMap = false;
				PlayerData.instance.HasCitadelUnderstoreMap = false;
				PlayerData.instance.HasCloverMap = false;
				PlayerData.instance.HasCogMap = false;
				PlayerData.instance.HasCoralMap = false;
				PlayerData.instance.HasCradleMap = false;
				PlayerData.instance.HasCrawlMap = false;
				PlayerData.instance.HasDocksMap = false;
				PlayerData.instance.HasDustpensMap = false;
				PlayerData.instance.HasGreymoorMap = false;
				PlayerData.instance.HasHallsMap = false;
				PlayerData.instance.HasHangMap = false;
				PlayerData.instance.HasHuntersNestMap = false;
				PlayerData.instance.HasJudgeStepsMap = false;
				PlayerData.instance.HasLibraryMap = false;
				PlayerData.instance.HasMossGrottoMap = false;
				PlayerData.instance.HasPeakMap = false;
				PlayerData.instance.HasShellwoodMap = false;
				PlayerData.instance.HasSlabMap = false;
				PlayerData.instance.HasSongGateMap = false;
				PlayerData.instance.HasSwampMap = false;
				PlayerData.instance.HasWardMap = false;
				PlayerData.instance.HasWeavehomeMap = false;
				PlayerData.instance.HasWildsMap = false;
				PlayerData.instance.hasQuill = false;
				CollectableItemManager.IncrementVersion();
				DebugMod.LogConsole("Removed all maps");
				return;
			}
			PlayerData.instance.HasAbyssMap = true;
			PlayerData.instance.HasAqueductMap = true;
			PlayerData.instance.HasArboriumMap = true;
			PlayerData.instance.HasBellhartMap = true;
			PlayerData.instance.HasBoneforestMap = true;
			PlayerData.instance.HasCitadelUnderstoreMap = true;
			PlayerData.instance.HasCloverMap = true;
			PlayerData.instance.HasCogMap = true;
			PlayerData.instance.HasCoralMap = true;
			PlayerData.instance.HasCradleMap = true;
			PlayerData.instance.HasCrawlMap = true;
			PlayerData.instance.HasDocksMap = true;
			PlayerData.instance.HasDustpensMap = true;
			PlayerData.instance.HasGreymoorMap = true;
			PlayerData.instance.HasHallsMap = true;
			PlayerData.instance.HasHangMap = true;
			PlayerData.instance.HasHuntersNestMap = true;
			PlayerData.instance.HasJudgeStepsMap = true;
			PlayerData.instance.HasLibraryMap = true;
			PlayerData.instance.HasMossGrottoMap = true;
			PlayerData.instance.HasPeakMap = true;
			PlayerData.instance.HasShellwoodMap = true;
			PlayerData.instance.HasSlabMap = true;
			PlayerData.instance.HasSongGateMap = true;
			PlayerData.instance.HasSwampMap = true;
			PlayerData.instance.HasWardMap = true;
			PlayerData.instance.HasWeavehomeMap = true;
			PlayerData.instance.HasWildsMap = true;
			PlayerData.instance.hasQuill = true;
			PlayerData.instance.QuillState = 1;
			CollectableItemManager.IncrementVersion();
			ZoneInfo[] mapZoneInfo = GameManager.instance.gameMap.mapZoneInfo;
			for (int i = 0; i < mapZoneInfo.Length; i++)
			{
				ParentInfo[] parents = mapZoneInfo[i].Parents;
				for (int j = 0; j < parents.Length; j++)
				{
					foreach (MapCache map in parents[j].Maps)
					{
						string sceneName = map.sceneName;
						if (!string.IsNullOrEmpty(sceneName))
						{
							PlayerData.instance.scenesVisited.Add(sceneName);
							PlayerData.instance.scenesMapped.Add(sceneName);
						}
					}
				}
			}
			GameManager.instance.gameMap.SetupMap(false);
			DebugMod.LogConsole("Unlocked all maps");
		}

		[BindableMethod(name = "UPGRADES_ALLFASTTRAVEL", category = "CATEGORY_UPGRADES")]
		public static void UnlockAllFastTravel()
		{
			if (PlayerData.instance.UnlockedAqueductStation && PlayerData.instance.UnlockedBelltownStation && PlayerData.instance.UnlockedBoneforestEastStation && PlayerData.instance.UnlockedCityStation && PlayerData.instance.UnlockedCoralTowerStation && PlayerData.instance.UnlockedDocksStation && PlayerData.instance.UnlockedGreymoorStation && PlayerData.instance.UnlockedPeakStation && PlayerData.instance.UnlockedShadowStation && PlayerData.instance.UnlockedShellwoodStation && PlayerData.instance.UnlockedArboriumTube && PlayerData.instance.UnlockedCityBellwayTube && PlayerData.instance.UnlockedEnclaveTube && PlayerData.instance.UnlockedHangTube && PlayerData.instance.UnlockedSongTube && PlayerData.instance.UnlockedUnderTube)
			{
				PlayerData.instance.UnlockedAqueductStation = false;
				PlayerData.instance.UnlockedBelltownStation = false;
				PlayerData.instance.UnlockedBoneforestEastStation = false;
				PlayerData.instance.UnlockedCityStation = false;
				PlayerData.instance.UnlockedCoralTowerStation = false;
				PlayerData.instance.UnlockedDocksStation = false;
				PlayerData.instance.UnlockedGreymoorStation = false;
				PlayerData.instance.UnlockedPeakStation = false;
				PlayerData.instance.UnlockedShadowStation = false;
				PlayerData.instance.UnlockedShellwoodStation = false;
				PlayerData.instance.UnlockedArboriumTube = false;
				PlayerData.instance.UnlockedCityBellwayTube = false;
				PlayerData.instance.UnlockedEnclaveTube = false;
				PlayerData.instance.UnlockedHangTube = false;
				PlayerData.instance.UnlockedSongTube = false;
				PlayerData.instance.UnlockedUnderTube = false;
				DebugMod.LogConsole("Removed all fast travel");
			}
			else
			{
				PlayerData.instance.UnlockedAqueductStation = true;
				PlayerData.instance.UnlockedBelltownStation = true;
				PlayerData.instance.UnlockedBoneforestEastStation = true;
				PlayerData.instance.UnlockedCityStation = true;
				PlayerData.instance.UnlockedCoralTowerStation = true;
				PlayerData.instance.UnlockedDocksStation = true;
				PlayerData.instance.UnlockedGreymoorStation = true;
				PlayerData.instance.UnlockedPeakStation = true;
				PlayerData.instance.UnlockedShadowStation = true;
				PlayerData.instance.UnlockedShellwoodStation = true;
				PlayerData.instance.UnlockedArboriumTube = true;
				PlayerData.instance.UnlockedCityBellwayTube = true;
				PlayerData.instance.UnlockedEnclaveTube = true;
				PlayerData.instance.UnlockedHangTube = true;
				PlayerData.instance.UnlockedSongTube = true;
				PlayerData.instance.UnlockedUnderTube = true;
				DebugMod.LogConsole("Unlocked all fast travel");
			}
		}

		[BindableMethod(name = "VISUAL_TOGGLEHITBOXES", category = "CATEGORY_VISUAL")]
		public static void ShowHitboxes()
		{
			if (++DebugMod.settings.ShowHitBoxes > 2)
			{
				DebugMod.settings.ShowHitBoxes = 0;
			}
			switch (DebugMod.settings.ShowHitBoxes)
			{
			case 0:
				DebugMod.LogConsole("Not showing hitboxes");
				break;
			case 1:
				DebugMod.LogConsole("Showing hitboxes");
				break;
			case 2:
				DebugMod.LogConsole("Showing all hitboxes");
				break;
			}
		}

		[BindableMethod(name = "VISUAL_FORCECAMERAFOLLOW", category = "CATEGORY_VISUAL")]
		public static void ForceCameraFollow()
		{
			if (!DebugMod.cameraFollow)
			{
				DebugMod.LogConsole("Forcing camera follow");
				DebugMod.cameraFollow = true;
			}
			else
			{
				DebugMod.cameraFollow = false;
				DebugMod.RefCamera.isGameplayScene = true;
				DebugMod.LogConsole("Returning camera to normal settings");
			}
		}

		[BindableMethod(name = "VISUAL_PREVIEWCOCOONPOSITION", category = "CATEGORY_VISUAL")]
		public static void PreviewCocoonPosition()
		{
			CocoonPreviewer cocoonPreviewer = ((Component)GameManager.instance).GetComponent<CocoonPreviewer>() ?? ((Component)GameManager.instance).gameObject.AddComponent<CocoonPreviewer>();
			if (!cocoonPreviewer.previewEnabled)
			{
				cocoonPreviewer.previewEnabled = true;
				DebugMod.LogConsole("Enabled cocoon spawn point preview");
			}
			else
			{
				cocoonPreviewer.previewEnabled = false;
				DebugMod.LogConsole("Disabled cocoon spawn point preview");
			}
		}

		[BindableMethod(name = "VISUAL_TOGGLEVIGNETTE", category = "CATEGORY_VISUAL")]
		public static void ToggleVignette()
		{
			VisualMaskHelper.ToggleVignette();
		}

		[BindableMethod(name = "VISUAL_DEACTIVATEVISUALMASKS", category = "CATEGORY_VISUAL")]
		public static void DoDeactivateVisualMasks()
		{
			VisualMaskHelper.ToggleAllMasks();
		}

		[BindableMethod(name = "VISUAL_TOGGLEHEROLIGHT", category = "CATEGORY_VISUAL")]
		public static void ToggleHeroLight()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			GameObject gameObject = ((Component)DebugMod.RefKnight.transform.Find("HeroLight")).gameObject;
			Color color = gameObject.GetComponent<SpriteRenderer>().color;
			if (Math.Abs(color.a) > 0f)
			{
				color.a = 0f;
				gameObject.GetComponent<SpriteRenderer>().color = color;
				DebugMod.LogConsole("Making hero light invisible");
			}
			else
			{
				color.a = 0.7f;
				gameObject.GetComponent<SpriteRenderer>().color = color;
				DebugMod.LogConsole("Making hero light visible");
			}
		}

		[BindableMethod(name = "VISUAL_TOGGLEHUD", category = "CATEGORY_VISUAL")]
		public static void ToggleHUD()
		{
			if (((Component)GameCameras.instance.hudCanvasSlideOut).gameObject.activeInHierarchy)
			{
				((Component)GameCameras.instance.hudCanvasSlideOut).gameObject.SetActive(false);
				DebugMod.LogConsole("Disabling HUD");
			}
			else
			{
				((Component)GameCameras.instance.hudCanvasSlideOut).gameObject.SetActive(true);
				HudHelper.RefreshSpool();
				DebugMod.LogConsole("Enabling HUD");
			}
		}

		[HarmonyPatch(typeof(SilkSpool), "ChangeSilk")]
		[HarmonyPrefix]
		private static bool SilkSpool_ChangeSilk()
		{
			return ((Component)GameCameras.instance.hudCanvasSlideOut).gameObject.activeInHierarchy;
		}

		[BindableMethod(name = "VISUAL_ZOOMIN", category = "CATEGORY_VISUAL")]
		public static void ZoomIn()
		{
			tk2dCamera tk2dCam = GameCameras.instance.tk2dCam;
			tk2dCam.zoomFactor *= 1.1f;
			ZoomHelper.UpdateCameraFOV();
			DebugMod.LogConsole($"Zoom level increased to {GameCameras.instance.tk2dCam.ZoomFactor}");
		}

		[BindableMethod(name = "VISUAL_ZOOMOUT", category = "CATEGORY_VISUAL")]
		public static void ZoomOut()
		{
			tk2dCamera tk2dCam = GameCameras.instance.tk2dCam;
			tk2dCam.zoomFactor *= 0.9f;
			ZoomHelper.UpdateCameraFOV();
			DebugMod.LogConsole($"Zoom level increased to {GameCameras.instance.tk2dCam.ZoomFactor}");
		}

		[BindableMethod(name = "VISUAL_RESETZOOM", category = "CATEGORY_VISUAL")]
		public static void ResetZoom()
		{
			GameCameras.instance.tk2dCam.ZoomFactor = 1f;
			ZoomHelper.UpdateCameraFOV();
			DebugMod.LogConsole("Zoom level was reset");
		}

		[BindableMethod(name = "VISUAL_HIDEHERO", category = "CATEGORY_VISUAL")]
		public static void HideHero()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			tk2dSprite component = DebugMod.RefKnight.GetComponent<tk2dSprite>();
			Color color = ((tk2dBaseSprite)component).color;
			if (Math.Abs(color.a) > 0f)
			{
				color.a = 0f;
				((tk2dBaseSprite)component).color = color;
				DebugMod.LogConsole("Making hero sprite invisible");
			}
			else
			{
				color.a = 1f;
				((tk2dBaseSprite)component).color = color;
				DebugMod.LogConsole("Making hero sprite visible");
			}
		}

		[BindableMethod(name = "VISUAL_TOGGLECAMERASHAKE", category = "CATEGORY_VISUAL")]
		public static void ToggleCameraShake()
		{
			bool flag = !((Behaviour)GameCameras.instance.cameraShakeFSM).enabled;
			((Behaviour)GameCameras.instance.cameraShakeFSM).enabled = flag;
			DebugMod.LogConsole((flag ? "Enabling" : "Disabling") + " camera shake");
		}
	}
	[AttributeUsage(AttributeTargets.Method, Inherited = false)]
	public class BindableMethod : Attribute
	{
		public string name;

		public string category;

		public bool allowLock = true;
	}
	public class BindAction
	{
		public string Name { get; }

		public string Category { get; }

		public bool AllowLock { get; }

		public Action Action { get; }

		public BindAction(string name, string category, bool allowLock, Action action)
		{
			Name = name;
			Category = category;
			AllowLock = allowLock;
			Action = action;
		}

		public BindAction(BindableMethod attribute, MethodInfo method)
		{
			Name = attribute.name;
			Category = attribute.category;
			AllowLock = attribute.allowLock;
			Action = (Action)Delegate.CreateDelegate(typeof(Action), method);
		}
	}
	[BepInDependency("org.silksong-modding.modlist", "0.2.0")]
	[HarmonyPatch]
	[BepInPlugin("io.github.hk-speedrunning.debugmod", "DebugMod", "1.0.3")]
	public class DebugMod : BaseUnityPlugin
	{
		[PublicAPI]
		public enum InfoPanelColumn
		{
			LEFT,
			RIGHT
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Func<ILogSource, bool> <>9__55_0;

			public static LogCallback <>9__55_1;

			public static Action <>9__55_2;

			public static Func<KeyValuePair<string, KeyCode>, string> <>9__61_0;

			internal bool <Awake>b__55_0(ILogSource x)
			{
				return x is UnityLogSource;
			}

			internal void <Awake>b__55_1(string condition, string stackTrace, LogType type)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_0005: Invalid comparison between Unknown and I4
				bool flag = (((int)type == 0 || (int)type == 4) ? true : false);
				if (flag && condition.Contains("Exception"))
				{
					LogError(("[UNITY] " + condition + "\n" + stackTrace).Trim());
				}
			}

			internal void <Awake>b__55_2()
			{
				UICommon.LoadResources();
				GUIController.Instance.BuildMenus();
				SceneWatcher.Init();
			}

			internal string <SaveSettings>b__61_0(KeyValuePair<string, KeyCode> pair)
			{
				return pair.Key;
			}
		}

		private static GameManager _gm;

		private static InputHandler _ih;

		private static HeroController _hc;

		private static GameObject _refKnight;

		private static CameraController _refCamera;

		private static Collider2D _refHeroCollider;

		private static LightBlurredBackground _lbb;

		internal static IEnumerator CurrentHazardCoro;

		internal static IEnumerator CurrentInvulnCoro;

		public static DebugMod instance;

		public static readonly string ModBaseDirectory = Path.Combine(Application.persistentDataPath, "DebugModData");

		private static float _loadTime;

		private static float _unloadTime;

		private static bool _loadingChar;

		internal static HitInstance? lastHit;

		internal static int lastDamage;

		[CanBeNull]
		internal static DamageScalingConfig lastScaling;

		internal static int lastScaleLevel;

		public static bool stateOnDeath;

		public static bool infiniteHP;

		public static bool infiniteSilk;

		public static bool infiniteTools;

		public static bool playerInvincible;

		public static bool noclip;

		internal static Vector3 noclipPos;

		public static bool heroColliderDisabled;

		public static bool cameraFollow;

		public static bool KeyBindLock;

		public static bool overrideLoadLockout = false;

		public static int extraNailDamage;

		public static bool forcePaused;

		public static readonly Dictionary<string, BindAction> bindActions = new Dictionary<string, BindAction>();

		internal static readonly Dictionary<MethodInfo, BindAction> bindsByMethod = new Dictionary<MethodInfo, BindAction>();

		public static readonly Dictionary<KeyCode, int> alphaKeyDict = new Dictionary<KeyCode, int>();

		public const string Id = "io.github.hk-speedrunning.debugmod";

		internal static GameManager GM
		{
			get
			{
				if (!((Object)(object)_gm != (Object)null))
				{
					return _gm = GameManager.SilentInstance;
				}
				return _gm;
			}
		}

		internal static InputHandler IH
		{
			get
			{
				if (!((Object)(object)_ih != (Object)null))
				{
					return _ih = GM.inputHandler;
				}
				return _ih;
			}
		}

		internal static HeroController HC
		{
			get
			{
				if (!((Object)(object)_hc != (Object)null))
				{
					return _hc = HeroController.instance;
				}
				return _hc;
			}
		}

		internal static GameObject RefKnight
		{
			get
			{
				if (!((Object)(object)_refKnight != (Object)null))
				{
					return _refKnight = ((Component)HC).gameObject;
				}
				return _refKnight;
			}
		}

		internal static CameraController RefCamera
		{
			get
			{
				if (!((Object)(object)_refCamera != (Object)null))
				{
					return _refCamera = GM.cameraCtrl;
				}
				return _refCamera;
			}
		}

		internal static Collider2D RefHeroCollider
		{
			get
			{
				if (!((Object)(object)_refHeroCollider != (Object)null))
				{
					return _refHeroCollider = RefKnight.GetComponent<Collider2D>();
				}
				return _refHeroCollider;
			}
		}

		internal static LightBlurredBackground LBB
		{
			get
			{
				if (!((Object)(object)_lbb != (Object)null))
				{
					return _lbb = Object.FindFirstObjectByType<LightBlurredBackground>();
				}
				return _lbb;
			}
		}

		public static Settings settings { get; set; } = new Settings();


		public static string Name => "DebugMod";

		public static string Version => "1.0.3";

		public static event Action<string, KeyCode?> bindUpdated;

		public void Awake()
		{
			//IL_0051: 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)
			//IL_005c: Expected O, but got Unknown
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			LoadSettings();
			if (settings.LogUnityExceptions && !Logger.Sources.Any((ILogSource x) => x is UnityLogSource))
			{
				object obj = <>c.<>9__55_1;
				if (obj == null)
				{
					LogCallback val = delegate(string condition, string stackTrace, LogType type)
					{
						//IL_0000: Unknown result type (might be due to invalid IL or missing references)
						//IL_0003: Unknown result type (might be due to invalid IL or missing references)
						//IL_0005: Invalid comparison between Unknown and I4
						bool flag = (((int)type == 0 || (int)type == 4) ? true : false);
						if (flag && condition.Contains("Exception"))
						{
							LogError(("[UNITY] " + condition + "\n" + stackTrace).Trim());
						}
					};
					<>c.<>9__55_1 = val;
					obj = (object)val;
				}
				Application.logMessageReceived += (LogCallback)obj;
			}
			settings.InitMenu(((BaseUnityPlugin)this).Config);
			bindActions.Clear();
			MethodInfo[] methods = typeof(BindableFunctions).GetMethods(BindingFlags.Static | BindingFlags.Public);
			foreach (MethodInfo methodInfo in methods)
			{
				object[] customAttributes = methodInfo.GetCustomAttributes(typeof(BindableMethod), inherit: false);
				if (customAttributes.Any())
				{
					BindAction bindAction = new BindAction((BindableMethod)customAttributes[0], methodInfo);
					bindActions.Add(bindAction.Name, bindAction);
					bindsByMethod.Add(methodInfo, bindAction);
				}
			}
			if (settings.FirstRun || settings.binds == null)
			{
				LogWarn("First run detected, setting default binds");
				settings.FirstRun = false;
				settings.binds = new Dictionary<string, KeyCode>();
				settings.binds.Add("MODUI_TOGGLEALLUI", (KeyCode)283);
			}
			foreach (BindAction value2 in bindActions.Values)
			{
				string valueOrDefault = Localization.FallbackSheet.GetValueOrDefault(value2.Name);
				if (valueOrDefault != null && settings.binds.TryGetValue(valueOrDefault, out var value))
				{
					settings.binds.TryAdd(value2.Name, value);
					settings.binds.Remove(valueOrDefault);
				}
			}
			if (!settings.binds.ContainsKey("MODUI_TOGGLEALLUI"))
			{
				LogWarn("Toggle All UI was unset, resetting to the default value");
				settings.binds.Add("MODUI_TOGGLEALLUI", (KeyCode)283);
			}
			int num = (settings.NumPadForSaveStates ? 256 : 48);
			alphaKeyDict.Clear();
			for (int j = 0; j < 10; j++)
			{
				alphaKeyDict.Add((KeyCode)(num + j), j);
			}
			SaveStateManager.Initialize();
			TimeScale.Initialize();
			new Harmony("io.github.hk-speedrunning.debugmod").PatchAll();
			SceneManager.activeSceneChanged += LevelActivated;
			ModHooks.AfterSavegameLoadHook += LoadCharacter;
			ModHooks.NewGameHook += NewCharacter;
			ModHooks.BeforeSceneLoadHook += OnLevelUnload;
			ModHooks.TakeHealthHook += PlayerDamaged;
			ModHooks.ApplicationQuitHook += SaveSettings;
			ModHooks.FinishedLoadingModsHook += delegate
			{
				UICommon.LoadResources();
				GUIController.Instance.BuildMenus();
				SceneWatcher.Init();
			};
			KeyBindLock = false;
			Log("Initialized");
		}

		private void OnEnable()
		{
			TimeScale.Initialize();
		}

		private void OnDisable()
		{
			TimeScale.Reset();
		}

		private void OnDestroy()
		{
			TimeScale.Release();
		}

		public DebugMod()
		{
			instance = this;
		}

		private void LoadSettings()
		{
			try
			{
				if (!Directory.Exists(ModBaseDirectory))
				{
					Directory.CreateDirectory(ModBaseDirectory);
				}
				string path = Path.Combine(ModBaseDirectory, "Settings.json");
				if (File.Exists(path))
				{
					settings = JsonConvert.DeserializeObject<Settings>(File.ReadAllText(path));
					if (settings == null)
					{
						settings = new Settings();
					}
					Log("Loaded settings");
				}
			}
			catch (Exception arg)
			{
				LogError($"Error loading settings: {arg}");
			}
		}

		private void SaveSettings()
		{
			settings.binds = new Dictionary<string, KeyCode>(settings.binds.OrderBy((KeyValuePair<string, KeyCode> pair) => pair.Key));
			try
			{
				File.WriteAllText(Path.Combine(ModBaseDirectory, "Settings.json"), JsonConvert.SerializeObject((object)settings, (Formatting)1));
				Log("Saved settings");
			}
			catch (Exception arg)
			{
				LogError($"Error saving settings: {arg}");
			}
		}

		public static void UpdateBind(string name, KeyCode? key)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if (key.HasValue)
			{
				settings.binds[name] = key.Value;
			}
			else
			{
				settings.binds.Remove(name);
			}
			DebugMod.bindUpdated?.Invoke(name, key);
		}

		private int PlayerDamaged(int damageAmount)
		{
			int num = ((!infiniteHP) ? damageAmount : 0);
			if (stateOnDeath && SaveState.loadingSavestate == null && PlayerData.instance.health - num <= 0)
			{
				SaveStateManager.LoadState(SaveStateManager.GetQuickState());
				LogConsole("Lethal damage prevented, savestate loading");
				return 0;
			}
			return num;
		}

		[HarmonyPatch(typeof(HeroController), "HazardRespawn")]
		[HarmonyPostfix]
		private static void OnHazardRespawn(HeroController __instance, IEnumerator __result)
		{
			CurrentHazardCoro = __result;
		}

		[HarmonyPatch(typeof(HeroController), "Invulnerable")]
		[HarmonyPostfix]
		private static void OnInvulnerable(HeroController __instance, IEnumerator __result)
		{
			CurrentInvulnCoro = __result;
		}

		private void NewCharacter()
		{
			LoadCharacter(null);
		}

		private void LoadCharacter(SaveGameData saveGameData)
		{
			ConsolePanel.Instance?.Reset();
			playerInvincible = false;
			infiniteHP = false;
			infiniteSilk = false;
			noclip = false;
			extraNailDamage = 0;
			lastHit = null;
			lastDamage = 0;
			lastScaling = null;
			lastScaleLevel = 0;
			_loadingChar = true;
		}

		private void LevelActivated(Scene sceneFrom, Scene sceneTo)
		{
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			string name = ((Scene)(ref sceneTo)).name;
			if (_loadingChar)
			{
				string text = TimeSpan.FromSeconds(PlayerData.instance.playTime).ToString("hh\\:mm\\:ss");
				LogConsole("DebugMod " + Version + " on Silksong " + Constants.GetConstantValue<string>("GAME_VERSION"));
				LogConsole($"\tSave slot: {PlayerData.instance.profileID}");
				LogConsole("\tProfile playtime: " + text);
				LogConsole($"\tCompletion: {PlayerData.instance.completionPercentage}%");
				GUIController.Instance.respawnSceneWatch = PlayerData.instance.respawnScene;
				_loadingChar = false;
			}
			if (Object.op_Implicit((Object)(object)GM) && GM.IsGameplayScene())
			{
				_loadTime = Time.realtimeSinceStartup;
				LogConsole("New scene loaded: " + name);
				PlayerDeathWatcher.Reset();
				VisualMaskHelper.OnSceneChange(sceneTo);
			}
		}

		private string OnLevelUnload(string toScene)
		{
			_unloadTime = Time.realtimeSinceStartup;
			return toScene;
		}

		public static string GetSceneName()
		{
			if ((Object)(object)GM == (Object)null)
			{
				LogWarn("GameManager reference is null in GetSceneName");
				return "";
			}
			return GM.GetSceneNameString();
		}

		public static float GetLoadTime()
		{
			return (float)Math.Round(_loadTime - _unloadTime, 2);
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPostfix]
		private static int Get_NailDamage(int nailDamage)
		{
			return nailDamage + extraNailDamage;
		}

		[HarmonyPatch(typeof(HealthManager), "TakeDamage")]
		[HarmonyPrefix]
		private static void TakeDamage(HealthManager __instance, HitInstance hitInstance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Invalid comparison between Unknown and I4
			HitInstance val = __instance.ApplyDamageScaling(hitInstance);
			lastHit = val;
			lastDamage = (__instance.damageOverride ? 1 : Mathf.RoundToInt((float)val.DamageDealt * val.Multiplier));
			lastScaling = __instance.damageScaling;
			int num = hitInstance.DamageScalingLevel - 1;
			if (hitInstance.IsUsingNeedleDamageMult)
			{
				num = PlayerData.instance.nailUpgrades;
			}
			else if (Object.op_Implicit((Object)(object)hitInstance.RepresentingTool) && (int)hitInstance.RepresentingTool.Type != 3)
			{
				num = PlayerData.instance.ToolKitUpgrades;
			}
			lastScaleLevel = num;
		}

		[HarmonyPatch(typeof(SurfaceWaterRegion), "OnTriggerEnter2D")]
		[HarmonyPrefix]
		private static void OnTriggerEnter2D_Prefix(Collider2D collision)
		{
			if (Object.op_Implicit((Object)(object)((Component)collision).gameObject.GetComponent<HeroController>()) && playerInvincible)
			{
				PlayerData.instance.isInvincible = false;
			}
		}

		[HarmonyPatch(typeof(SurfaceWaterRegion), "OnTriggerEnter2D")]
		[HarmonyPostfix]
		private static void OnTriggerEnter2D_Postfix()
		{
			if (playerInvincible)
			{
				PlayerData.instance.isInvincible = true;
			}
		}

		[HarmonyPatch(typeof(HeroWaterController), "TumbleOut")]
		[HarmonyPrefix]
		private static bool HeroWaterController_TumbleOut_Prefix(HeroWaterController __instance)
		{
			if (SaveState.loadingSavestate == null)
			{
				return true;
			}
			__instance.ExitedWater(true);
			return false;
		}

		[HarmonyPatch(typeof(HeroController), "TakeDamage")]
		[HarmonyPrefix]
		private static bool HeroController_TakeDamage(GameObject go, HazardType hazardType)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Invalid comparison between Unknown and I4
			if (playerInvincible && !noclip && (int)hazardType == 4 && ((Object)go).name.Contains("Lava Box"))
			{
				HeroController.instance.ShroomBounce();
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(HeroController), "TakeSilk", new Type[]
		{
			typeof(int),
			typeof(SilkTakeSource)
		})]
		[HarmonyPrefix]
		private static void TakeSilk(ref int amount)
		{
			if (infiniteSilk)
			{
				amount = 0;
			}
		}

		[HarmonyPatch(typeof(HeroController), "DoSpecialDamage")]
		[HarmonyPrefix]
		private static bool HeroController_DoSpecialDamage()
		{
			return !playerInvincible;
		}

		[HarmonyPatch(typeof(HeroController), "CanBeBarnacleGrabbed")]
		[HarmonyPrefix]
		private static bool HeroController_CanBeBarnacleGrabbed(ref bool __result)
		{
			if (playerInvincible)
			{
				__result = false;
				return false;
			}
			return true;
		}

		[PublicAPI]
		public static void AddToKeyBindList(Type BindableFunctionsClass)
		{
			MethodInfo[] methods = BindableFunctionsClass.GetMethods(BindingFlags.Static | BindingFlags.Public);
			foreach (MethodInfo methodInfo in methods)
			{
				BindableMethod customAttribute = methodInfo.GetCustomAttribute<BindableMethod>(inherit: false);
				if (customAttribute != null)
				{
					Log("Adding new keybind: " + customAttribute.name + " (from " + BindableFunctionsClass.Name + ")");
					BindAction bindAction = new BindAction(customAttribute, methodInfo);
					bindActions.Add(bindAction.Name, bindAction);
					bindsByMethod.Add(methodInfo, bindAction);
				}
			}
		}

		[PublicAPI]
		public static void AddActionToKeyBindList(Action method, string name, string category)
		{
			AddActionToKeyBindList(method, name, category, allowLock: true);
		}

		[PublicAPI]
		public static void AddActionToKeyBindList(Action method, string name, string category, bool allowLock)
		{
			Log("Adding new keybind: " + name);
			BindAction bindAction = new BindAction(name, category, allowLock, method);
			bindActions.Add(bindAction.Name, bindAction);
			bindsByMethod.Add(method.Method, bindAction);
		}

		[PublicAPI]
		public static void AddTextToInfoPanel(string label, Func<string> dataGenerator, InfoPanelColumn column = InfoPanelColumn.LEFT)
		{
			((column == InfoPanelColumn.LEFT) ? InfoPanel.LeftColumnInjects : InfoPanel.RightColumnInjects).Add(new InfoPanel.InjectedInfo(label, dataGenerator));
		}

		[PublicAPI]
		public static void AddTranslationSheet(string sheet)
		{
			Localization.AddSheet(sheet);
		}

		public static void LogDebug(string message)
		{
			((BaseUnityPlugin)instance).Logger.LogDebug((object)message);
		}

		public static void Log(string message)
		{
			((BaseUnityPlugin)instance).Logger.LogInfo((object)message);
		}

		public static void LogWarn(string message)
		{
			((BaseUnityPlugin)instance).Logger.LogWarning((object)message);
		}

		public static void LogError(string message)
		{
			((BaseUnityPlugin)instance).Logger.LogError((object)message);
		}

		public static void LogConsole(string message)
		{
			ConsolePanel.Log(message);
		}
	}
	[HarmonyPatch]
	public class GUIController : MonoBehaviour
	{
		public Vector3 hazardLocation;

		public string respawnSceneWatch;

		private static readonly HitboxViewer hitboxes = new HitboxViewer();

		private KeyCode keyWarning;

		private Size resolution;

		internal LanguageCode language;

		private bool benchwarpShifted;

		private float? lastRescale;

		private const float RebuildDelay = 0.1f;

		internal float? savestatePageUpdateTime;

		private const float SavestatePageUpdateDelay = 2f;

		public GameObject canvas;

		private readonly Array allKeyCodes = Enum.GetValues(typeof(KeyCode));

		private readonly List<KeyCode> UnbindableKeys = new List<KeyCode> { (KeyCode)323 };

		[CompilerGenerated]
		private static GUIController <Instance>k__BackingField;

		public static GUIController Instance
		{
			get
			{
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Expected O, but got Unknown
				if (!Object.op_Implicit((Object)(object)<Instance>k__BackingField))
				{
					DebugMod.Log("Creating new GUIController");
					GameObject val = new GameObject("GUIController");
					<Instance>k__BackingField = val.AddComponent<GUIController>();
					Object.DontDestroyOnLoad((Object)val);
				}
				return <Instance>k__BackingField;
			}
		}

		public static bool ForceHideUI()
		{
			if (DebugMod.GM.IsNonGameplayScene())
			{
				return true;
			}
			if (SaveState.loadingSavestate != null)
			{
				return true;
			}
			return false;
		}

		public void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			hazardLocation = PlayerData.instance.hazardRespawnLocation;
			respawnSceneWatch = PlayerData.instance.respawnScene;
		}

		public void BuildMenus()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (Object.op_Implicit((Object)(object)canvas))
				{
					foreach (EnemyHandle item in EnemiesPanel.enemyPool)
					{
						item.DestroyUI();
					}
					Object.Destroy((Object)(object)canvas);
					CanvasNode.allNodes.Clear();
				}
				canvas = new GameObject("DebugModCanvas");
				canvas.SetActive(false);
				canvas.AddComponent<Canvas>().renderMode = (RenderMode)0;
				canvas.AddComponent<GraphicRaycaster>();
				RectTransform component = canvas.GetComponent<RectTransform>();
				Vector2 anchorMin = (component.anchorMax = Vector2.zero);
				component.anchorMin = anchorMin;
				component.pivot = Vector2.zero;
				component.sizeDelta = new Vector2((float)Screen.width, (float)Screen.height);
				Object.DontDestroyOnLoad((Object)(object)canvas);
				MainPanel.BuildPanel();
				EnemiesPanel.BuildPanel();
				ConsolePanel.BuildPanel();
				InfoPanel.BuildPanel();
				SaveStatesPanel.BuildPanel();
				CanvasButton.BuildHoverBorder();
				KeybindDialog.BuildPanel();
				ConfirmDialog.BuildPanel();
				resolution = new Size(Screen.width, Screen.height);
				language = GetLanguage();
				benchwarpShifted = false;
				DebugMod.LogDebug("UI built");
			}
			catch (Exception arg)
			{
				DebugMod.LogError($"Error building UI: {arg}");
			}
		}

		private LanguageCode GetLanguage()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			if (InteropHelper.IsModInstalled(InteropHelper.I18NModId, "1.1.0"))
			{
				return I18NInterop.GetLanguage();
			}
			return Language.CurrentLanguage();
		}

		public void Update()
		{
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0695: Unknown result type (might be due to invalid IL or missing references)
			//IL_069b: Unknown result type (might be due to invalid IL or missing references)
			//IL_066d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0681: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_052c: Unknown result type (might be due to invalid IL or missing references)
			//IL_052e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0535: Unknown result type (might be due to invalid IL or missing references)
			//IL_053a: Unknown result type (might be due to invalid IL or missing references)
			//IL_053f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0557: Unknown result type (might be due to invalid IL or missing references)
			//IL_0559: Unknown result type (might be due to invalid IL or missing references)
			//IL_0560: Unknown result type (might be due to invalid IL or missing references)
			//IL_0565: Unknown result type (might be due to invalid IL or missing references)
			//IL_056a: Unknown result type (might be due to invalid IL or missing references)
			//IL_045a: Unknown result type (might be due to invalid IL or missing references)
			//IL_045f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0461: 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_0582: Unknown result type (might be due to invalid IL or missing references)
			//IL_0584: Unknown result type (might be due to invalid IL or missing references)
			//IL_058b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0590: Unknown result type (might be due to invalid IL or missing references)
			//IL_0595: Unknown result type (might be due to invalid IL or missing references)
			//IL_0495: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_05af: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_061d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0622: Unknown result type (might be due to invalid IL or missing references)
			//IL_0632: Unknown result type (might be due to invalid IL or missing references)
			//IL_0639: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0605: Unknown result type (might be due to invalid IL or missing references)
			//IL_060b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)DebugMod.GM == (Object)null)
			{
				return;
			}
			Profiler.NewFrame();
			if (!resolution.IsEmpty && (resolution.Width != Screen.width || resolution.Height != Screen.height))
			{
				resolution = new Size(Screen.width, Screen.height);
				lastRescale = Time.realtimeSinceStartup;
			}
			if (lastRescale.HasValue && Time.realtimeSinceStartup > lastRescale + 0.1f)
			{
				DebugMod.LogDebug($"Resize complete, rebuilding for new resolution ({Screen.width}, {Screen.height})");
				lastRescale = null;
				BuildMenus();
			}
			if (InteropHelper.IsModInstalled(InteropHelper.BenchwarpModId))
			{
				bool flag = GameManager.instance.IsGamePaused() && !GameManager.instance.IsNonGameplayScene();
				if (flag != benchwarpShifted)
				{
					benchwarpShifted = flag;
					int num = UICommon.ScaleHeight(50);
					if (benchwarpShifted)
					{
						MainPanel.Instance.LayoutTabsSide(num);
						SaveStatesPanel instance = SaveStatesPanel.Instance;
						instance.LocalPosition += new Vector2(0f, (float)num);
					}
					else
					{
						MainPanel.Instance.LayoutTabsNormal();
						SaveStatesPanel instance2 = SaveStatesPanel.Instance;
						instance2.LocalPosition -= new Vector2(0f, (float)num);
					}
				}
			}
			if (ForceHideUI())
			{
				canvas.SetActive(false);
			}
			else
			{
				canvas.SetActive(true);
				MainPanel instance3 = MainPanel.Instance;
				if (instance3 != null)
				{
					instance3.ActiveSelf = DebugMod.settings.MainPanelVisible;
				}
				EnemiesPanel instance4 = EnemiesPanel.Instance;
				if (instance4 != null)
				{
					instance4.ActiveSelf = DebugMod.settings.EnemiesPanelVisible;
				}
				ConsolePanel instance5 = ConsolePanel.Instance;
				if (instance5 != null)
				{
					instance5.ActiveSelf = DebugMod.settings.ConsoleVisible;
				}
				InfoPanel instance6 = InfoPanel.Instance;
				if (instance6 != null)
				{
					instance6.ActiveSelf = DebugMod.settings.InfoPanelVisible;
				}
				SaveStatesPanel instance7 = SaveStatesPanel.Instance;
				if (instance7 != null)
				{
					instance7.ActiveSelf = SaveStatesPanel.ShouldBeVisible;
				}
				int num2 = 0;
				while (num2 < CanvasNode.allNodes.Count)
				{
					CanvasNode canvasNode = CanvasNode.allNodes[num2];
					if (canvasNode.ActiveSelf)
					{
						canvasNode.Update();
						num2++;
					}
					else
					{
						num2 += canvasNode.childCount;
					}
				}
			}
			GameObject currentSelectedGameObject = EventSystem.current.currentSelectedGameObject;
			if (Object.op_Implicit((Object)(object)currentSelectedGameObject) && Object.op_Implicit((Object)(object)currentSelectedGameObject.GetComponent<NodeRef>()) && !Object.op_Implicit((Object)(object)currentSelectedGameObject.GetComponent<InputField>()))
			{
				EventSystem.current.SetSelectedGameObject((GameObject)null);
			}
			if (DebugMod.GetSceneName() == "Menu_Title")
			{
				return;
			}
			LanguageCode val = GetLanguage();
			if (language != val)
			{
				DebugMod.LogDebug($"Detected language change from {language} to {val}, rebuilding UI");
				BuildMenus();
			}
			if (!CanvasTextField.AnyFieldFocused)
			{
				HandleKeybinds();
			}
			if (savestatePageUpdateTime.HasValue && Time.realtimeSinceStartup > savestatePageUpdateTime + 2f)
			{
				savestatePageUpdateTime = null;
				SaveStateManager.LoadFileStates();
				SaveStatesPanel.Instance?.PageCountChanged();
			}
			if (DebugMod.infiniteSilk && PlayerData.instance.silk < PlayerData.instance.silkMax && PlayerData.instance.health > 0 && (Object)(object)HeroController.instance != (Object)null && !HeroController.instance.cState.dead && GameManager.instance.IsGameplayScene())
			{
				PlayerData.instance.silk = PlayerData.instance.silkMax;
				HeroController.instance.AddSilk(1, false);
			}
			if (DebugMod.infiniteTools && Object.op_Implicit((Object)(object)ManagerSingleton<ToolItemManager>.Instance) && Object.op_Implicit((Object)(object)ManagerSingleton<ToolItemManager>.Instance.toolItems))
			{
				foreach (ToolItem item in (NamedScriptableObjectList<ToolItem>)(object)ManagerSingleton<ToolItemManager>.Instance.toolItems)
				{
					if (Object.op_Implicit((Object)(object)item))
					{
						Data savedData = item.SavedData;
						int amountLeft = savedData.AmountLeft;
						savedData.AmountLeft = ToolItemManager.GetToolStorageAmount(item);
						item.SavedData = savedData;
						AttackToolBinding? attackToolBinding = ToolItemManager.GetAttackToolBinding(item);
						if (attackToolBinding.HasValue && amountLeft != savedData.AmountLeft)
						{
							ToolItemManager.ReportBoundAttackToolUpdated(attackToolBinding.Value);
						}
					}
				}
			}
			if (DebugMod.playerInvincible && PlayerData.instance != null)
			{
				PlayerData.instance.isInvincible = true;
			}
			if (DebugMod.noclip)
			{
				Vector3 val2 = Vector3.zero;
				float num3 = (Input.GetKey((KeyCode)304) ? 40f : 20f) * DebugMod.settings.NoClipSpeedModifier * Time.deltaTime;
				if (((OneAxisInputControl)DebugMod.IH.inputActions.Left).IsPressed)
				{
					val2 += Vector3.left * num3;
				}
				if (((OneAxisInputControl)DebugMod.IH.inputActions.Right).IsPressed)
				{
					val2 += Vector3.right * num3;
				}
				if (((OneAxisInputControl)DebugMod.IH.inputActions.Up).IsPressed)
				{
					val2 += Vector3.up * num3;
				}
				if (((OneAxisInputControl)DebugMod.IH.inputActions.Down).IsPressed)
				{
					val2 += Vector3.down * num3;
				}
				DebugMod.noclipPos += val2;
				if ((int)HeroController.instance.transitionState == 0 && SaveState.loadingSavestate == null)
				{
					DebugMod.RefKnight.transform.position = DebugMod.noclipPos;
					Rigidbody2D component = DebugMod.RefKnight.GetComponent<Rigidbody2D>();
					component.constraints = (RigidbodyConstraints2D)(component.constraints | 3);
				}
				else
				{
					DebugMod.noclipPos = DebugMod.RefKnight.transform.position;
					Rigidbody2D component2 = DebugMod.RefKnight.GetComponent<Rigidbody2D>();
					component2.constraints = (RigidbodyConstraints2D)(component2.constraints & -4);
				}
			}
			if (DebugMod.heroColliderDisabled)
			{
				HeroBox.Inactive = true;
			}
			if (DebugMod.cameraFollow)
			{
				DebugMod.RefCamera.isGameplayScene = false;
				DebugMod.RefCamera.SnapTo(DebugMod.RefKnight.transform.position.x, DebugMod.RefKnight.transform.position.y);
			}
			if (PlayerData.instance.hazardRespawnLocation != hazardLocation)
			{
				hazardLocation = PlayerData.instance.hazardRespawnLocation;
				DebugMod.LogConsole($"Hazard respawn location updated: {hazardLocation}");
			}
			if (respawnSceneWatch != PlayerData.instance.respawnScene)
			{
				respawnSceneWatch = PlayerData.instance.respawnScene;
				DebugMod.LogConsole("Save respawn updated:");
				DebugMod.LogConsole("\tNew Scene: " + PlayerData.instance.respawnScene);
				DebugMod.LogConsole("\tMap zone: " + GameManager.instance.GetCurrentMapZone());
				DebugMod.LogConsole("\tRespawn marker: " + PlayerData.instance.respawnMarkerName);
			}
			if (HitboxViewer.State != DebugMod.settings.ShowHitBoxes)
			{
				if (DebugMod.settings.ShowHitBoxes != 0)
				{
					hitboxes.Load();
				}
				else if (HitboxViewer.State != 0 && DebugMod.settings.ShowHitBoxes == 0)
				{
					hitboxes.Unload();
				}
			}
		}

		private void HandleKeybinds()
		{
			//IL_0022: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Invalid comparison between Unknown and I4
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Invalid comparison between Unknown and I4
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < DebugMod.settings.binds.Count; i++)
			{
				KeyValuePair<string, KeyCode> keyValuePair = DebugMod.settings.binds.ElementAt(i);
				string key = keyValuePair.Key;
				KeyCode value = keyValuePair.Value;
				if (!DebugMod.bindActions.ContainsKey(key))
				{
					continue;
				}
				if ((int)value == 0)
				{
					foreach (KeyCode allKeyCode in allKeyCodes)
					{
						if (!Input.GetKeyDown(allKeyCode) || UnbindableKeys.Contains(allKeyCode))
						{
							continue;
						}
						if (keyWarning != allKeyCode)
						{
							foreach (string key2 in DebugMod.bindActions.Keys)
							{
								if (DebugMod.settings.binds.TryGetValue(key2, out var value2) && value2 == allKeyCode)
								{
									DebugMod.LogConsole($"{(object)allKeyCode} already bound to {key2}, press again to confirm");
									keyWarning = allKeyCode;
								}
							}
							if (keyWarning == allKeyCode)
							{
								break;
							}
						}
						keyWarning = (KeyCode)0;
						if ((int)allKeyCode == 27)
						{
							DebugMod.UpdateBind(key, null);
							i--;
							DebugMod.LogWarn("The key " + Enum.GetName(typeof(KeyCode), (object)allKeyCode) + " has been unbound from " + key);
						}
						else if ((int)allKeyCode != 27)
						{
							DebugMod.UpdateBind(key, (KeyCode?)allKeyCode);
						}
						break;
					}
				}
				else
				{
					if (!Input.GetKeyDown(value))
					{
						continue;
					}
					try
					{
						if (DebugMod.bindActions.TryGetValue(key, out var value3) && (!DebugMod.KeyBindLock || (DebugMod.KeyBindLock && !value3.AllowLock)))
						{
							value3.Action();
						}
					}
					catch (Exception ex)
					{
						DebugMod.LogError("Error running keybind method " + key + ":\n" + ex.ToString());
					}
				}
			}
		}

		[HarmonyPatch(typeof(InputHandler), "SetCursorVisible")]
		[HarmonyPrefix]
		private static void SetCursorVisible(ref bool value)
		{
			if (DebugMod.settings.ShowCursorWhileUnpaused)
			{
				UIManager.instance.inputModule.allowMouseInput = true;
				value = true;
			}
		}
	}
	[HarmonyPatch]
	internal static class ModHooks
	{
		[CompilerGenerated]
		private sealed class <GameManager_LoadFirstScene>d__37 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public IEnumerator orig;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <GameManager_LoadFirstScene>d__37(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = orig;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					ModHooks.NewGameHook?.Invoke();
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private static bool finishedLoadingModsInvoked;

		public static event Action<SaveGameData> AfterSavegameLoadHook;

		public static event Action ApplicationQuitHook;

		public static event Action BeforePlayerDeadHook;

		public static event Func<string, string> BeforeSceneLoadHook;

		public static event Action<GameObject> ColliderCreateHook;

		public static event Action CursorHook;

		private static event Action finishedLoadingModsHook;

		public static event Action FinishedLoadingModsHook
		{
			add
			{
				finishedLoadingModsHook += value;
				if (finishedLoadingModsInvoked)
				{
					value();
				}
			}
			remove
			{
				finishedLoadingModsHook -= value;
			}
		}

		public static event Action NewGameHook;

		public static event Func<int, int> TakeHealthHook;

		[HarmonyPatch(typeof(GameManager), "SetLoadedGameData", new Type[]
		{
			typeof(SaveGameData),
			typeof(int)
		})]
		[HarmonyPostfix]
		private static void GameManager_SetLoadedGameData(SaveGameData saveGameData)
		{
			ModHooks.AfterSavegameLoadHook?.Invoke(saveGameData);
		}

		[HarmonyPatch(typeof(GameManager), "OnApplicationQuit")]
		[HarmonyPostfix]
		private static void GameManager_OnApplicationQuit()
		{
			ModHooks.ApplicationQuitHook?.Invoke();
		}

		[HarmonyPatch(typeof(GameManager), "PlayerDead")]
		[HarmonyPrefix]
		private static void GameManager_PlayerDead()
		{
			ModHooks.BeforePlayerDeadHook?.Invoke();
		}

		[HarmonyPatch(typeof(GameManager), "BeginSceneTransition")]
		[HarmonyPrefix]
		private static void GameManager_BeginSceneTransition(SceneLoadInfo info)
		{
			if (ModHooks.BeforeSceneLoadHook != null)
			{
				info.SceneName = ModHooks.BeforeSceneLoadHook(info.SceneName);
			}
		}

		[HarmonyPatch(typeof(GameManager), "LoadScene")]
		[HarmonyPrefix]
		private static void GameManager_LoadScene(ref string destScene)
		{
			if (ModHooks.BeforeSceneLoadHook != null)
			{
				destScene = ModHooks.BeforeSceneLoadHook(destScene);
			}
		}

		[HarmonyPatch(typeof(GameManager), "LoadSceneAdditive")]
		[HarmonyPrefix]
		private static void GameManager_LoadSceneAdditive(ref string destScene)
		{
			if (ModHooks.BeforeSceneLoadHook != null)
			{
				destScene = ModHooks.BeforeSceneLoadHook(destScene);
			}
		}

		[HarmonyPatch(typeof(PlayMakerUnity2DProxy), "Start")]
		[HarmonyPostfix]
		private static void PlayMakerUnity2DProxy_Start(PlayMakerUnity2DProxy __instance)
		{
			ModHooks.ColliderCreateHook?.Invoke(((Component)__instance).gameObject);
		}

		[HarmonyPatch(typeof(InputHandler), "Update")]
		[HarmonyPostfix]
		private static void InputHandler_Update()
		{
			ModHooks.CursorHook?.Invoke();
		}

		[HarmonyPatch(typeof(OnScreenDebugInfo), "Awake")]
		[HarmonyPrefix]
		private static void OnScreenDebugInfo_Awake()
		{
			if (!finishedLoadingModsInvoked)
			{
				finishedLoadingModsInvoked = true;
				ModHooks.finishedLoadingModsHook?.Invoke();
			}
		}

		[IteratorStateMachine(typeof(<GameManager_LoadFirstScene>d__37))]
		[HarmonyPatch(typeof(GameManager), "LoadFirstScene")]
		[HarmonyPostfix]
		private static IEnumerator GameManager_LoadFirstScene(IEnumerator orig)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <GameManager_LoadFirstScene>d__37(0)
			{
				orig = orig
			};
		}

		[HarmonyPatch(typeof(GameManager), "OnWillActivateFirstLevel")]
		[HarmonyPostfix]
		private static void GameManager_OnWillActivateFirstLevel()
		{
			ModHooks.NewGameHook?.Invoke();
		}

		[HarmonyPatch(typeof(PlayerData), "TakeHealth")]
		[HarmonyPrefix]
		private static void PlayerData_TakeHealth(ref int amount)
		{
			if (ModHooks.TakeHealthHook != null)
			{
				amount = ModHooks.TakeHealthHook(amount);
			}
		}
	}
	public static class PlayerDeathWatcher
	{
		public static bool playerDead;

		static PlayerDeathWatcher()
		{
			ModHooks.BeforePlayerDeadHook += SetPlayerDead;
		}

		private static void SetPlayerDead()
		{
			playerDead = true;
			LogDeathDetails();
		}

		public static void Reset()
		{
			playerDead = false;
		}

		public static void LogDeathDetails()
		{
			DebugMod.LogConsole("Hero death detected");
			DebugMod.LogConsole($"\tGame playtime: {PlayerData.instance.playTime}");
			DebugMod.LogConsole("\tRespawn scene: " + PlayerData.instance.respawnScene);
			DebugMod.LogConsole("\tCocoon scene: " + PlayerData.instance.HeroCorpseScene);
			DebugMod.LogConsole($"\tCocoon rosaries: {PlayerData.instance.HeroCorpseMoneyPool}");
		}
	}
	public class Settings
	{
		private static ConfigEntry<KeyCode> toggleAllUI;

		private static ConfigEntry<float> noclipSpeedModifier;

		private static ConfigEntry<bool> altInfoPanel;

		private static ConfigEntry<bool> expandedInfoPanel;

		private static ConfigEntry<int> maxSavestatePages;

		private static ConfigEntry<bool> numpadForSavestates;

		private static ConfigEntry<bool> safeSavestateLoading;

		[JsonProperty(ItemConverterType = typeof(StringEnumConverter))]
		public Dictionary<string, KeyCode> binds = new Dictionary<string, KeyCode>();

		public bool FirstRun = true;

		public bool MainPanelVisible = true;

		public string MainPanelCurrentTab;

		public bool EnemiesPanelVisible = true;

		public bool ConsoleVisible = true;

		public bool InfoPanelVisible = true;

		public bool SaveStatePanelVisible = true;

		public bool SaveStatePanelExpanded;

		public bool NumPadForSaveStates;

		public int ShowHitBoxes;

		public int MaxSavePages = 10;

		public float NoClipSpeedModifier = 1f;

		public bool ShowCursorWhileUnpaused;

		public bool SafeSaveStateLoading;

		public bool LogUnityExceptions = true;

		pu