Decompiled source of LooneysMenu v2.0.3

LooneysMod.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using FishNet.Connection;
using FishNet.Managing;
using FishNet.Object;
using HarmonyLib;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("LooneysMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LooneysMod")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("fa90dcd6-b7f1-493c-915f-61cb5fb3f492")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.looney.overpower", "Little Looney's Advanced Item Management Suite", "2.0.3")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class LooneyPlugin : BaseUnityPlugin
{
	public class ItemInfo
	{
		public int Id;

		public string Name;

		public string Description;

		public ItemCategory Category;

		public ItemInfo(int id, string name, string description, ItemCategory category)
		{
			Id = id;
			Name = name;
			Description = description;
			Category = category;
		}

		public override string ToString()
		{
			return $"{Name} (ID: {Id})";
		}
	}

	public enum ItemCategory
	{
		All,
		Resources,
		Tools,
		Weapons,
		Magic,
		Consumables,
		SpellPages,
		Special
	}

	public class InventoryBackup
	{
		public string Name;

		public DateTime Created;

		public Dictionary<int, int> ItemData;

		public int EquippedIndex;

		public InventoryBackup(string name, PlayerInventory inventory)
		{
			Name = name;
			Created = DateTime.Now;
			EquippedIndex = GetEquippedIndex(inventory);
			ItemData = new Dictionary<int, int>();
			GameObject[] equippedItems = GetEquippedItems(inventory);
			if (equippedItems == null)
			{
				return;
			}
			for (int i = 0; i < equippedItems.Length; i++)
			{
				if ((Object)(object)equippedItems[i] != (Object)null)
				{
					IItemInteraction component = equippedItems[i].GetComponent<IItemInteraction>();
					if (component != null)
					{
						ItemData[i] = component.GetItemID();
					}
				}
			}
		}
	}

	private static class Cheats
	{
		public static bool godMode = false;

		public static bool noclip = false;

		public static bool flight = false;

		public static bool infStamina = false;

		public static bool speedBoost = false;

		public static bool noCooldowns = false;

		public static bool multiCast = false;

		public static bool rapidFire = false;

		public static bool noRecoil = false;

		public static bool instantRespawn = false;

		public static bool infItems = false;

		public static bool noDrop = false;

		public static bool inventoryLock = false;

		public static bool preventCrafting = false;

		public static bool preventTrading = false;

		public static bool itemDuplication = false;

		public static bool massSpawning = false;

		public static bool chams = false;

		public static bool noFog = false;

		public static bool fullbright = false;

		public static float xpMultiplier = 10f;

		public static float speedMultiplier = 2f;

		public static int duplicateAmount = 1;

		public static bool smartDuplication = true;
	}

	[HarmonyPatch(typeof(PlayerMovement), "UpdateMovement")]
	private class Patch_UpdateMovement
	{
		private static bool Prefix(PlayerMovement __instance)
		{
			//IL_046c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0471: Unknown result type (might be due to invalid IL or missing references)
			//IL_0479: Unknown result type (might be due to invalid IL or missing references)
			//IL_047f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0484: Unknown result type (might be due to invalid IL or missing references)
			//IL_0487: Unknown result type (might be due to invalid IL or missing references)
			//IL_048c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0491: 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_04b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_051d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0522: Unknown result type (might be due to invalid IL or missing references)
			//IL_0524: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0500: Unknown result type (might be due to invalid IL or missing references)
			//IL_050a: Unknown result type (might be due to invalid IL or missing references)
			//IL_050f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0514: Unknown result type (might be due to invalid IL or missing references)
			//IL_0596: Unknown result type (might be due to invalid IL or missing references)
			//IL_059b: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05aa: 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_05b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0619: Unknown result type (might be due to invalid IL or missing references)
			//IL_061b: 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_0629: Unknown result type (might be due to invalid IL or missing references)
			//IL_0633: Unknown result type (might be due to invalid IL or missing references)
			//IL_0638: Unknown result type (might be due to invalid IL or missing references)
			//IL_063d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0641: Unknown result type (might be due to invalid IL or missing references)
			//IL_0643: Unknown result type (might be due to invalid IL or missing references)
			//IL_064a: Unknown result type (might be due to invalid IL or missing references)
			//IL_064f: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown((KeyCode)282))
			{
				Cheats.godMode = !Cheats.godMode;
				Debug.Log((object)("[Looney] God mode " + (Cheats.godMode ? "ENABLED" : "disabled") + "."));
				if (!Cheats.godMode && fi_playerHealth != null)
				{
					fi_playerHealth.SetValue(__instance, 100f);
					Debug.Log((object)"[Looney] Health reset to 100.");
				}
			}
			if (Input.GetKeyDown((KeyCode)283))
			{
				Cheats.noclip = !Cheats.noclip;
				CharacterController component = ((Component)__instance).GetComponent<CharacterController>();
				if ((Object)(object)component != (Object)null)
				{
					((Collider)component).enabled = !Cheats.noclip;
				}
				Debug.Log((object)("[Looney] Noclip " + (Cheats.noclip ? "ENABLED" : "disabled") + "."));
				if (!Cheats.noclip)
				{
					__instance.velocity.y = -1f;
				}
			}
			if (Input.GetKeyDown((KeyCode)284))
			{
				Cheats.flight = !Cheats.flight;
				Debug.Log((object)("[Looney] Flight mode " + (Cheats.flight ? "ENABLED" : "disabled") + "."));
				if (!Cheats.flight)
				{
					__instance.velocity.y = -1f;
					Debug.Log((object)"[Looney] Gravity restored.");
				}
			}
			if (Input.GetKeyDown((KeyCode)285))
			{
				Cheats.infStamina = !Cheats.infStamina;
				Debug.Log((object)("[Looney] Infinite stamina " + (Cheats.infStamina ? "ENABLED" : "disabled") + "."));
				if (!Cheats.infStamina && fi_stamina != null)
				{
					fi_stamina.SetValue(__instance, 10f);
				}
			}
			if (Input.GetKeyDown((KeyCode)286))
			{
				Cheats.speedBoost = !Cheats.speedBoost;
				Debug.Log((object)("[Looney] Speed boost " + (Cheats.speedBoost ? "ENABLED" : "disabled") + "."));
			}
			if (Input.GetKeyDown((KeyCode)287))
			{
				float xpMultiplier = Cheats.xpMultiplier;
				if (xpMultiplier < 50f)
				{
					Cheats.xpMultiplier = 50f;
					Debug.Log((object)"[Looney] XP multiplier set to 50x.");
				}
				else if (Mathf.Approximately(xpMultiplier, 50f))
				{
					Cheats.xpMultiplier = 150f;
					Debug.Log((object)"[Looney] XP multiplier set to 150x.");
				}
				else if (Mathf.Approximately(xpMultiplier, 150f))
				{
					Cheats.xpMultiplier = 500f;
					Debug.Log((object)"[Looney] XP multiplier set to 500x.");
				}
				else
				{
					Cheats.xpMultiplier = 10f;
					Debug.Log((object)"[Looney] XP multiplier reset to normal.");
				}
			}
			if (Input.GetKeyDown((KeyCode)288))
			{
				Cheats.noCooldowns = !Cheats.noCooldowns;
				Debug.Log((object)("[Looney] No spell cooldowns " + (Cheats.noCooldowns ? "ENABLED" : "disabled") + "."));
			}
			if (Input.GetKeyDown((KeyCode)289))
			{
				Cheats.multiCast = !Cheats.multiCast;
				Debug.Log((object)("[Looney] Multi-cast " + (Cheats.multiCast ? "ENABLED" : "disabled") + "."));
			}
			if (Input.GetKeyDown((KeyCode)290))
			{
				Cheats.infItems = !Cheats.infItems;
				Debug.Log((object)("[Looney] Infinite item usage " + (Cheats.infItems ? "ENABLED" : "disabled") + "."));
			}
			if (Input.GetKeyDown((KeyCode)291))
			{
				Cheats.instantRespawn = !Cheats.instantRespawn;
				Debug.Log((object)("[Looney] Instant respawn " + (Cheats.instantRespawn ? "ENABLED" : "disabled") + "."));
			}
			if (Input.GetKeyDown((KeyCode)292))
			{
				Cheats.noDrop = !Cheats.noDrop;
				Debug.Log((object)("[Looney] No item-drop on death " + (Cheats.noDrop ? "ENABLED" : "disabled") + "."));
			}
			if (Input.GetKeyDown((KeyCode)293))
			{
				Cheats.noFog = !Cheats.noFog;
				ApplyFogSettings();
				Debug.Log((object)("[Looney] No fog " + (Cheats.noFog ? "ENABLED" : "disabled") + "."));
			}
			if (Input.GetKeyDown((KeyCode)277))
			{
				Cheats.fullbright = !Cheats.fullbright;
				ApplyLightingSettings();
				Debug.Log((object)("[Looney] Fullbright " + (Cheats.fullbright ? "ENABLED" : "disabled") + "."));
			}
			Vector3 val;
			if (Cheats.noclip)
			{
				float axis = Input.GetAxis("Horizontal");
				float axis2 = Input.GetAxis("Vertical");
				Vector3 forward = ((Component)__instance).transform.forward;
				val = ((Component)__instance).transform.right * axis + forward * axis2;
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				float num = __instance.runningSpeed * 3f * Cheats.speedMultiplier;
				Vector3 val2 = normalized * num * Time.deltaTime;
				if (Input.GetKey((KeyCode)32))
				{
					val2 += Vector3.up * num * Time.deltaTime;
				}
				else if (Input.GetKey((KeyCode)306))
				{
					val2 += Vector3.down * num * Time.deltaTime;
				}
				Transform transform = ((Component)__instance).transform;
				transform.position += val2;
				if (fi_stamina != null)
				{
					fi_stamina.SetValue(__instance, float.MaxValue);
				}
				return false;
			}
			if (Cheats.flight)
			{
				CharacterController component2 = ((Component)__instance).GetComponent<CharacterController>();
				if (!__instance.canMove || (Object)(object)component2 == (Object)null)
				{
					return true;
				}
				float axis3 = Input.GetAxis("Horizontal");
				float axis4 = Input.GetAxis("Vertical");
				Vector3 forward2 = ((Component)__instance).transform.forward;
				val = ((Component)__instance).transform.right * axis3 + forward2 * axis4;
				Vector3 normalized2 = ((Vector3)(ref val)).normalized;
				float num2 = __instance.runningSpeed * 3f * Cheats.speedMultiplier;
				Vector3 val3 = normalized2 * num2 * Time.deltaTime;
				float num3 = 0f;
				if (Input.GetKey((KeyCode)32))
				{
					num3 = 1f;
				}
				else if (Input.GetKey((KeyCode)306))
				{
					num3 = -1f;
				}
				val3 += Vector3.up * num2 * num3 * Time.deltaTime;
				component2.Move(val3);
				__instance.velocity = Vector3.zero;
				if (fi_stamina != null)
				{
					fi_stamina.SetValue(__instance, 10f);
				}
				return false;
			}
			return true;
		}

		private static void Postfix(PlayerMovement __instance)
		{
			if (Cheats.speedBoost)
			{
				__instance.velocity.x *= Cheats.speedMultiplier;
				__instance.velocity.z *= Cheats.speedMultiplier;
			}
		}
	}

	[HarmonyPatch(typeof(PlayerMovement), "Update")]
	private class Patch_PlayerUpdate
	{
		private static void Prefix(PlayerMovement __instance)
		{
			if (Cheats.godMode && fi_playerHealth != null)
			{
				fi_playerHealth.SetValue(__instance, float.MaxValue);
			}
			if (Cheats.infStamina && fi_stamina != null)
			{
				fi_stamina.SetValue(__instance, 10f);
			}
		}
	}

	[HarmonyPatch(typeof(PlayerMovement), "XPupdate")]
	private class Patch_XPupdate
	{
		private static bool Prefix(PlayerMovement __instance)
		{
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			__instance.xp += 1f * Cheats.xpMultiplier;
			Debug.Log((object)$"[Looney] XP added: {Cheats.xpMultiplier}, total XP now {__instance.xp:F2}");
			float num = 3f * (float)Mathf.Clamp(__instance.level, 0, 2);
			if (__instance.xp >= num)
			{
				__instance.portalSource.PlayOneShot(__instance.levelup);
				__instance.level++;
				PlayerInteract component = ((Component)Camera.main).GetComponent<PlayerInteract>();
				if ((Object)(object)component != (Object)null)
				{
					component.leveluptxt("Your spells grow stronger...");
					component.SetLevelNum(__instance.level);
				}
				Debug.Log((object)("[Looney] Leveled up! New level = " + __instance.level));
				__instance.xp = 0.001f;
			}
			if ((Object)(object)__instance.xpbar != (Object)null)
			{
				__instance.xpbar.ResizeAroundPivot(new Vector3(__instance.xp / (3f * (float)Mathf.Clamp(__instance.level, 0, 2)) * 0.124f, 0.009f, 0.01f));
			}
			return false;
		}
	}

	[HarmonyPatch(typeof(PlayerInventory), "Update")]
	private class Patch_PlayerInventoryUpdate
	{
		private static void Postfix(PlayerInventory __instance)
		{
			if (Cheats.noCooldowns)
			{
				if (fi_fbcd != null)
				{
					fi_fbcd.SetValue(__instance, Time.time - 999f);
				}
				if (fi_frostcd != null)
				{
					fi_frostcd.SetValue(__instance, Time.time - 999f);
				}
				if (fi_wormcd != null)
				{
					fi_wormcd.SetValue(__instance, Time.time - 999f);
				}
				if (fi_holecd != null)
				{
					fi_holecd.SetValue(__instance, Time.time - 999f);
				}
				if (fi_wardcd != null)
				{
					fi_wardcd.SetValue(__instance, Time.time - 999f);
				}
			}
			if (!Cheats.rapidFire || !Input.GetKey((KeyCode)323) || Input.GetKeyDown((KeyCode)323) || !(Time.time - lastRapidFireTime > 0.1f))
			{
				return;
			}
			lastRapidFireTime = Time.time;
			GameObject[] array = (GameObject[])GetField(fi_equippedItems, __instance);
			int num = ((fi_equippedIndex != null) ? ((int)fi_equippedIndex.GetValue(__instance)) : 0);
			if (array == null || num < 0 || num >= array.Length)
			{
				return;
			}
			GameObject val = array[num];
			if ((Object)(object)val != (Object)null)
			{
				Component component = val.GetComponent("IItemInteraction");
				if ((Object)(object)component != (Object)null)
				{
					((object)component).GetType().GetMethod("Interaction", BindingFlags.Instance | BindingFlags.Public)?.Invoke(component, new object[1] { ((Component)__instance).gameObject });
				}
			}
		}
	}

	[HarmonyPatch(typeof(PlayerInventory), "destroyHandItem")]
	private class Patch_DestroyHandItem
	{
		private static bool Prefix(PlayerInventory __instance)
		{
			if (Cheats.infItems)
			{
				Debug.Log((object)"[Looney] Prevented item destruction via destroyHandItem (infinite items).");
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(PlayerInventory), "clearHandItem")]
	private class Patch_ClearHandItem
	{
		private static bool Prefix(PlayerInventory __instance)
		{
			if (Cheats.infItems || Cheats.inventoryLock)
			{
				Debug.Log((object)"[Looney] Prevented item clearing (infinite items/inventory lock).");
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(PlayerInventory), "Drop")]
	private class Patch_Drop
	{
		private static bool Prefix(PlayerInventory __instance)
		{
			if (Cheats.noDrop || Cheats.inventoryLock)
			{
				Debug.Log((object)"[Looney] Prevented manual item drop (no drop/inventory lock).");
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(PlayerInventory), "DropAllItems")]
	private class Patch_DropAllItems
	{
		private static bool Prefix(PlayerInventory __instance)
		{
			if (Cheats.noDrop || Cheats.inventoryLock)
			{
				Debug.Log((object)"[Looney] Prevented mass item drop (no drop/inventory lock).");
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(PlayerInventory), "PlaceOnCraftingTable")]
	private class Patch_PlaceOnCraftingTable
	{
		private static bool Prefix(PlayerInventory __instance)
		{
			if (Cheats.infItems || Cheats.preventCrafting)
			{
				Debug.Log((object)"[Looney] Prevented crafting item consumption (infinite items/prevent crafting).");
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(PlayerInventory), "GiveDuendeItem")]
	private class Patch_GiveDuendeItem
	{
		private static bool Prefix(PlayerInventory __instance)
		{
			if (Cheats.infItems || Cheats.preventTrading)
			{
				Debug.Log((object)"[Looney] Prevented NPC item giving (infinite items/prevent trading).");
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(CrystalSoup), "DrinkStewServer")]
	private class Patch_DrinkStewServer
	{
		private static bool Prefix(CrystalSoup __instance)
		{
			if (Cheats.infItems)
			{
				Debug.Log((object)"[Looney] Prevented soup consumption (infinite items).");
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(PlayerInventory), "PlayerDied")]
	private class Patch_PlayerDied
	{
		private static bool Prefix(PlayerInventory __instance)
		{
			if (!Cheats.noDrop)
			{
				return true;
			}
			__instance.canUseItem = false;
			__instance.canSwapItem = false;
			bool flag = false;
			GameObject[] array = (GameObject[])GetField(fi_equippedItems, __instance);
			int num = ((fi_equippedIndex != null) ? ((int)fi_equippedIndex.GetValue(__instance)) : 0);
			if (array != null)
			{
				GameObject[] array2 = array;
				foreach (GameObject val in array2)
				{
					if ((Object)(object)val == (Object)null)
					{
						continue;
					}
					Component component = val.GetComponent("IItemInteraction");
					if ((Object)(object)component != (Object)null)
					{
						MethodInfo method = ((object)component).GetType().GetMethod("GetItemID", BindingFlags.Instance | BindingFlags.Public);
						if (method != null && (int)method.Invoke(component, null) == 24)
						{
							flag = true;
						}
					}
				}
				GameObject val2 = array[num];
				if ((Object)(object)val2 != (Object)null && mi_hideObject != null)
				{
					mi_hideObject.Invoke(__instance, new object[1] { val2 });
				}
			}
			if (!flag && mi_delaySpellbookRespawn != null)
			{
				IEnumerator enumerator = (IEnumerator)mi_delaySpellbookRespawn.Invoke(__instance, null);
				if (enumerator != null)
				{
					((MonoBehaviour)__instance).StartCoroutine(enumerator);
				}
			}
			Debug.Log((object)"[Looney] No items dropped on death.");
			return false;
		}
	}

	[HarmonyPatch(typeof(PlayerRespawnManager), "RespawnRoutine")]
	private class Patch_RespawnRoutine
	{
		private static void Prefix(PlayerRespawnManager __instance)
		{
			if (Cheats.instantRespawn)
			{
				((object)__instance).GetType().GetField("CanRespawn", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(__instance, true);
				((object)__instance).GetType().GetField("RespawnTimer", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(__instance, ((object)__instance).GetType().GetField("Respawntime", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(__instance));
				Debug.Log((object)"[Looney] Instant respawn triggered.");
			}
		}
	}

	[HarmonyPatch(typeof(MageBookController), "Fireball")]
	private class Patch_Fireball
	{
		private static void Postfix(MageBookController __instance, GameObject ownerobj, int level)
		{
			if (Cheats.multiCast)
			{
				Cheats.multiCast = false;
				__instance.Fireball(ownerobj, level);
				__instance.Fireball(ownerobj, level);
				Cheats.multiCast = true;
			}
		}
	}

	[HarmonyPatch(typeof(MageBookController), "Frostbolt")]
	private class Patch_Frostbolt
	{
		private static void Postfix(MageBookController __instance, GameObject ownerobj, int level)
		{
			if (Cheats.multiCast)
			{
				Cheats.multiCast = false;
				__instance.Frostbolt(ownerobj, level);
				__instance.Frostbolt(ownerobj, level);
				Cheats.multiCast = true;
			}
		}
	}

	[HarmonyPatch(typeof(MageBookController), "Castworm")]
	private class Patch_Castworm
	{
		private static void Postfix(MageBookController __instance, int level, Vector3 pos)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (Cheats.multiCast)
			{
				Cheats.multiCast = false;
				__instance.Castworm(level, pos);
				__instance.Castworm(level, pos);
				Cheats.multiCast = true;
			}
		}
	}

	[HarmonyPatch(typeof(MageBookController), "Casthole")]
	private class Patch_Casthole
	{
		private static void Postfix(MageBookController __instance, int level, Vector3 pos)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (Cheats.multiCast)
			{
				Cheats.multiCast = false;
				__instance.Casthole(level, pos);
				__instance.Casthole(level, pos);
				Cheats.multiCast = true;
			}
		}
	}

	[HarmonyPatch(typeof(MageBookController), "CastWard")]
	private class Patch_CastWard
	{
		private static void Postfix(MageBookController __instance, GameObject ownerobj, int level)
		{
			if (Cheats.multiCast)
			{
				Cheats.multiCast = false;
				__instance.CastWard(ownerobj, level);
				__instance.CastWard(ownerobj, level);
				Cheats.multiCast = true;
			}
		}
	}

	[HarmonyPatch(typeof(PlayerMovement), "UpdateGravity")]
	private class Patch_UpdateGravity
	{
		private static bool Prefix()
		{
			if (Cheats.flight || Cheats.noclip)
			{
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(PlayerMovement), "applyrecoil")]
	private class Patch_ApplyRecoil
	{
		private static bool Prefix()
		{
			return !Cheats.noRecoil;
		}
	}

	public static string modsync = "all";

	private Harmony _harmony;

	private static bool dependencyValidated = false;

	private static float lastSystemCheck = 0f;

	private static FieldInfo fi_playerHealth;

	private static FieldInfo fi_stamina;

	private static FieldInfo fi_fbcd;

	private static FieldInfo fi_frostcd;

	private static FieldInfo fi_wormcd;

	private static FieldInfo fi_holecd;

	private static FieldInfo fi_wardcd;

	private static FieldInfo fi_equippedItems;

	private static FieldInfo fi_equippedIndex;

	private static MethodInfo mi_hideObject;

	private static MethodInfo mi_layerMaskSwapZero;

	private static MethodInfo mi_delaySpellbookRespawn;

	private static bool initializedReflection = false;

	private static Material redChamsMaterial;

	private static Material blueChamsMaterial;

	private static Dictionary<Renderer, Material[]> originalMaterials = new Dictionary<Renderer, Material[]>();

	private Rect modWindowRect = new Rect(20f, 20f, 550f, 800f);

	private Rect itemSpawnerRect = new Rect(600f, 20f, 400f, 600f);

	private Rect inventoryManagerRect = new Rect(1020f, 20f, 350f, 500f);

	private Rect spellItemGiverRect = new Rect(100f, 100f, 500f, 700f);

	private static float lastRapidFireTime = 0f;

	private bool menuVisible;

	private Vector2 scrollPosition = Vector2.zero;

	private Vector2 itemScrollPosition = Vector2.zero;

	private Vector2 inventoryScrollPosition = Vector2.zero;

	private Vector2 giverScrollPosition = Vector2.zero;

	private GUIStyle boxStyle;

	private GUIStyle buttonStyle;

	private GUIStyle toggleStyle;

	private GUIStyle labelStyle;

	private GUIStyle headerStyle;

	private bool stylesInitialized;

	private bool _isCasting;

	private float _waitTime = 0.5f;

	private PlayerInventory inv;

	private PlayerMovement pm;

	private MageBookController mbc;

	private static bool _isHost = false;

	private static bool _networkingChecked = false;

	private static string _networkStatusMessage = "";

	private static bool _showSpellPageGUI = false;

	private static List<GameObject> _spellPages = new List<GameObject>();

	private static string[] _spellPageNames = new string[0];

	private static int _selectedSpellPageIndex = 0;

	private static bool _showItemSpawner = false;

	private static bool _showInventoryManager = false;

	private static bool _showSpellItemGiver = false;

	private static string _itemSearchFilter = "";

	private static string _giverSearchFilter = "";

	private static int _selectedItemCategory = 0;

	private static int _spawnQuantity = 1;

	private static int _giverTab = 0;

	private static int _selectedGiverCategory = 0;

	private static readonly Dictionary<int, ItemInfo> ItemDatabase = new Dictionary<int, ItemInfo>
	{
		{
			0,
			new ItemInfo(0, "Log", "Basic crafting material", ItemCategory.Resources)
		},
		{
			1,
			new ItemInfo(1, "Rock", "Stone material for crafting", ItemCategory.Resources)
		},
		{
			2,
			new ItemInfo(2, "Crystal Shard", "Magical crystal fragment", ItemCategory.Resources)
		},
		{
			3,
			new ItemInfo(3, "Frog", "Amphibious creature", ItemCategory.Resources)
		},
		{
			4,
			new ItemInfo(4, "Bounce Mushroom", "Springy magical mushroom", ItemCategory.Resources)
		},
		{
			5,
			new ItemInfo(5, "Sword", "Basic melee weapon", ItemCategory.Weapons)
		},
		{
			6,
			new ItemInfo(6, "Axe", "Woodcutting tool", ItemCategory.Tools)
		},
		{
			7,
			new ItemInfo(7, "Mushroom Man", "Living mushroom companion", ItemCategory.Special)
		},
		{
			8,
			new ItemInfo(8, "Excalibur Hilt", "Legendary sword hilt", ItemCategory.Weapons)
		},
		{
			9,
			new ItemInfo(9, "Excalibur Blade", "Legendary sword blade", ItemCategory.Weapons)
		},
		{
			10,
			new ItemInfo(10, "Complete Excalibur", "Legendary complete sword", ItemCategory.Weapons)
		},
		{
			11,
			new ItemInfo(11, "Magic Wand", "Basic spell focus", ItemCategory.Magic)
		},
		{
			12,
			new ItemInfo(12, "Walking Stick", "Support staff", ItemCategory.Tools)
		},
		{
			13,
			new ItemInfo(13, "Pickaxe", "Mining tool", ItemCategory.Tools)
		},
		{
			14,
			new ItemInfo(14, "Shrink Ray", "Size-altering device", ItemCategory.Magic)
		},
		{
			15,
			new ItemInfo(15, "Grappling Hook", "Traversal tool", ItemCategory.Tools)
		},
		{
			16,
			new ItemInfo(16, "Teleport Orb", "Instant travel device", ItemCategory.Magic)
		},
		{
			17,
			new ItemInfo(17, "Invisibility Cloak", "Stealth garment", ItemCategory.Magic)
		},
		{
			18,
			new ItemInfo(18, "Shield", "Defensive equipment", ItemCategory.Weapons)
		},
		{
			19,
			new ItemInfo(19, "Dart Gun", "Ranged weapon", ItemCategory.Weapons)
		},
		{
			20,
			new ItemInfo(20, "Bow", "Ranged weapon", ItemCategory.Weapons)
		},
		{
			21,
			new ItemInfo(21, "Health Potion", "Healing consumable", ItemCategory.Consumables)
		},
		{
			22,
			new ItemInfo(22, "Mana Potion", "Magic restoration", ItemCategory.Consumables)
		},
		{
			23,
			new ItemInfo(23, "Speed Potion", "Movement enhancement", ItemCategory.Consumables)
		},
		{
			24,
			new ItemInfo(24, "Spellbook", "Magic spell container", ItemCategory.Magic)
		},
		{
			25,
			new ItemInfo(25, "Craft Hammer", "Special crafting tool", ItemCategory.Tools)
		},
		{
			26,
			new ItemInfo(26, "Portal Stone", "Teleportation device", ItemCategory.Magic)
		},
		{
			27,
			new ItemInfo(27, "Crystal Soup", "Magical food", ItemCategory.Consumables)
		},
		{
			28,
			new ItemInfo(28, "Log Soup", "Hearty meal", ItemCategory.Consumables)
		},
		{
			29,
			new ItemInfo(29, "Rock Soup", "Stone-based meal", ItemCategory.Consumables)
		},
		{
			30,
			new ItemInfo(30, "Frog Soup", "Amphibian delicacy", ItemCategory.Consumables)
		},
		{
			31,
			new ItemInfo(31, "Mushroom Soup", "Fungal feast", ItemCategory.Consumables)
		},
		{
			32,
			new ItemInfo(32, "Empty Bowl", "Used food container", ItemCategory.Consumables)
		},
		{
			33,
			new ItemInfo(33, "Lightning Bolt Page", "Lightning spell", ItemCategory.SpellPages)
		},
		{
			34,
			new ItemInfo(34, "Poof Spell Page", "Teleport spell", ItemCategory.SpellPages)
		},
		{
			35,
			new ItemInfo(35, "Holy Light Page", "Divine magic", ItemCategory.SpellPages)
		},
		{
			36,
			new ItemInfo(36, "Heal Spell Page", "Restoration magic", ItemCategory.SpellPages)
		},
		{
			37,
			new ItemInfo(37, "Dark Blast Page", "Shadow magic", ItemCategory.SpellPages)
		},
		{
			38,
			new ItemInfo(38, "Wisp Page", "Spirit magic", ItemCategory.SpellPages)
		},
		{
			39,
			new ItemInfo(39, "Fire Storm Page", "Destructive magic", ItemCategory.SpellPages)
		},
		{
			40,
			new ItemInfo(40, "Ice Wall Page", "Defensive magic", ItemCategory.SpellPages)
		}
	};

	private static List<InventoryBackup> _inventoryBackups = new List<InventoryBackup>();

	private static int _maxBackups = 5;

	private static string[] _backupNames = new string[0];

	private static HashSet<int> _protectedItemIds = new HashSet<int>();

	private static bool _autoBackupEnabled = true;

	private static float _lastPlayerSearchTime = 0f;

	private static float _playerSearchCooldown = 2f;

	private static bool _hasLoggedSearchFailure = false;

	private float physicsTimer;

	private Vector3 lastPlayerPos = Vector3.zero;

	private static int frameValidation = 0;

	private static bool systemReadiness = true;

	private void Awake()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Expected O, but got Unknown
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: Unknown result type (might be due to invalid IL or missing references)
		_harmony = new Harmony("com.looney.overpower");
		_harmony.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"[Looney] Enhanced Plugin loaded v2.1.0 – Working movement system + Enhanced multi-cast + Spell giving");
		if (!initializedReflection)
		{
			Type typeFromHandle = typeof(PlayerMovement);
			fi_playerHealth = typeFromHandle.GetField("playerHealth", BindingFlags.Instance | BindingFlags.NonPublic);
			fi_stamina = typeFromHandle.GetField("stamina", BindingFlags.Instance | BindingFlags.NonPublic);
			Type typeFromHandle2 = typeof(PlayerInventory);
			fi_fbcd = typeFromHandle2.GetField("fbcd", BindingFlags.Instance | BindingFlags.NonPublic);
			fi_frostcd = typeFromHandle2.GetField("frostcd", BindingFlags.Instance | BindingFlags.NonPublic);
			fi_wormcd = typeFromHandle2.GetField("wormcd", BindingFlags.Instance | BindingFlags.NonPublic);
			fi_holecd = typeFromHandle2.GetField("holecd", BindingFlags.Instance | BindingFlags.NonPublic);
			fi_wardcd = typeFromHandle2.GetField("wardcd", BindingFlags.Instance | BindingFlags.NonPublic);
			fi_equippedItems = typeFromHandle2.GetField("equippedItems", BindingFlags.Instance | BindingFlags.NonPublic);
			fi_equippedIndex = typeFromHandle2.GetField("equippedIndex", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			mi_hideObject = typeFromHandle2.GetMethod("HideObject", BindingFlags.Instance | BindingFlags.NonPublic);
			mi_layerMaskSwapZero = typeFromHandle2.GetMethod("LayerMaskSwapZero", BindingFlags.Instance | BindingFlags.NonPublic);
			mi_delaySpellbookRespawn = typeFromHandle2.GetMethod("DelaySpellbookRespawn", BindingFlags.Instance | BindingFlags.NonPublic);
			initializedReflection = true;
		}
		TryIncreaseFogLimit();
		redChamsMaterial = CreateChamsMaterial(new Color(1f, 0f, 0f, 0.3f));
		blueChamsMaterial = CreateChamsMaterial(new Color(0f, 0f, 1f, 0.3f));
		((MonoBehaviour)this).StartCoroutine(WaitForPlayerSetup());
	}

	private void TryIncreaseFogLimit()
	{
		try
		{
			RenderPipelineAsset renderPipelineAsset = GraphicsSettings.renderPipelineAsset;
			HDRenderPipelineAsset val = (HDRenderPipelineAsset)(object)((renderPipelineAsset is HDRenderPipelineAsset) ? renderPipelineAsset : null);
			if ((Object)(object)val == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"[Looney] HDRP asset not found.");
				return;
			}
			object obj = typeof(HDRenderPipelineAsset).GetField("m_RenderPipelineSettings", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(val);
			if (obj != null)
			{
				FieldInfo field = obj.GetType().GetField("maxLocalVolumetricFogCount", BindingFlags.Instance | BindingFlags.NonPublic);
				if (field != null)
				{
					field.SetValue(obj, 512);
					((BaseUnityPlugin)this).Logger.LogInfo((object)"[Looney] Increased local volumetric fog limit to 512.");
				}
			}
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)("[Looney] Failed to increase fog limit: " + ex.Message));
		}
	}

	private IEnumerator WaitForPlayerSetup()
	{
		yield return (object)new WaitForSeconds(2f);
		RefreshSpellList();
		CheckNetworkingAuthority();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"[Looney] Plugin setup complete - will find local player dynamically.");
	}

	private void FindLocalPlayer()
	{
		if ((Object)(object)inv != (Object)null && (Object)(object)pm != (Object)null)
		{
			if ((Object)(object)((Component)inv).gameObject != (Object)null && (Object)(object)((Component)pm).gameObject != (Object)null)
			{
				return;
			}
			Debug.Log((object)"[Looney] Cached players destroyed, clearing cache...");
			inv = null;
			pm = null;
			mbc = null;
			_hasLoggedSearchFailure = false;
		}
		if (Time.time - _lastPlayerSearchTime < _playerSearchCooldown && _hasLoggedSearchFailure)
		{
			return;
		}
		_lastPlayerSearchTime = Time.time;
		PlayerInventory val = Object.FindFirstObjectByType<PlayerInventory>();
		if ((Object)(object)val != (Object)null)
		{
			inv = val;
			pm = ((Component)val).GetComponent<PlayerMovement>();
			mbc = ((Component)val).GetComponentInChildren<MageBookController>();
			if ((Object)(object)pm != (Object)null)
			{
				Debug.Log((object)"[Looney] ✅ SUCCESS: Found local player using Give Items.txt method!");
				Debug.Log((object)$"[Looney] Player ready: inv={(Object)(object)inv != (Object)null}, pm={(Object)(object)pm != (Object)null}, mbc={(Object)(object)mbc != (Object)null}");
				_hasLoggedSearchFailure = false;
				_playerSearchCooldown = 2f;
				return;
			}
			Debug.LogWarning((object)"[Looney] Found PlayerInventory but missing PlayerMovement component!");
			inv = null;
		}
		PlayerMovement[] array = Object.FindObjectsByType<PlayerMovement>((FindObjectsSortMode)0);
		if (array.Length != 0)
		{
			Debug.Log((object)$"[Looney] Fallback search: Found {array.Length} PlayerMovement objects");
			PlayerMovement[] array2 = array;
			foreach (PlayerMovement val2 in array2)
			{
				if (((NetworkBehaviour)val2).IsOwner)
				{
					pm = val2;
					inv = ((Component)val2).GetComponent<PlayerInventory>();
					mbc = ((Component)val2).GetComponentInChildren<MageBookController>();
					if ((Object)(object)inv != (Object)null && (Object)(object)pm != (Object)null)
					{
						Debug.Log((object)"[Looney] ✅ SUCCESS: Found local player with IsOwner fallback!");
						Debug.Log((object)$"[Looney] Player ready: inv={(Object)(object)inv != (Object)null}, pm={(Object)(object)pm != (Object)null}, mbc={(Object)(object)mbc != (Object)null}");
						_hasLoggedSearchFailure = false;
						_playerSearchCooldown = 2f;
						return;
					}
				}
			}
		}
		if (!_hasLoggedSearchFailure)
		{
			string text = DetermineGameState();
			switch (text)
			{
			case "lobby":
			case "menu":
				Debug.Log((object)("[Looney] \ud83d\udccb No players found - appears to be in " + text + ". Item/spell features will activate in-game."));
				break;
			case "loading":
				Debug.Log((object)"[Looney] \ud83d\udd04 No players found - game still loading. Will retry when ready.");
				break;
			default:
				Debug.LogWarning((object)"[Looney] ❌ No local player found in game. Item/spell features unavailable.");
				break;
			}
			_hasLoggedSearchFailure = true;
			_playerSearchCooldown = 5f;
		}
		if (_hasLoggedSearchFailure && _playerSearchCooldown < 10f)
		{
			_playerSearchCooldown = Mathf.Min(_playerSearchCooldown + 1f, 10f);
		}
	}

	private string DetermineGameState()
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			Scene activeScene = SceneManager.GetActiveScene();
			string text = ((Scene)(ref activeScene)).name.ToLower();
			if (text.Contains("lobby") || text.Contains("menu") || text.Contains("main"))
			{
				return "lobby";
			}
			if (text.Contains("loading"))
			{
				return "loading";
			}
			if ((Object)(object)Object.FindFirstObjectByType<Button>() != (Object)null)
			{
				return "lobby";
			}
			return Object.FindObjectsByType<GameObject>((FindObjectsSortMode)0).Any((GameObject go) => ((Object)go).name.ToLower().Contains("arena") || ((Object)go).name.ToLower().Contains("map") || ((Object)go).name.ToLower().Contains("spawn")) ? "game" : "unknown";
		}
		catch
		{
			return "unknown";
		}
	}

	private static void CheckNetworkingAuthority()
	{
		try
		{
			NetworkManager val = Object.FindFirstObjectByType<NetworkManager>();
			if ((Object)(object)val == (Object)null)
			{
				_isHost = true;
				_networkStatusMessage = "\ud83d\udfe2 Single Player - All features available";
				Debug.Log((object)"[Looney] Single player mode detected - all features available.");
			}
			else
			{
				bool isServerStarted = val.IsServerStarted;
				bool isHostStarted = val.IsHostStarted;
				bool isClientStarted = val.IsClientStarted;
				_isHost = isServerStarted || isHostStarted;
				if (_isHost)
				{
					_networkStatusMessage = "\ud83d\udfe2 Host/Server - All features available";
					Debug.Log((object)"[Looney] Host/Server detected - all features available.");
				}
				else if (isClientStarted)
				{
					_networkStatusMessage = "\ud83d\udfe1 Client - Limited features (Movement, Visual, Spells only)";
					Debug.Log((object)"[Looney] Client detected - advanced item features disabled.");
				}
				else
				{
					_networkStatusMessage = "\ud83d\udd34 Network status unknown";
					_isHost = false;
				}
			}
			_networkingChecked = true;
		}
		catch (Exception ex)
		{
			Debug.LogWarning((object)("[Looney] Could not determine networking status: " + ex.Message));
			_networkStatusMessage = "⚠\ufe0f Network status check failed - assuming client mode";
			_isHost = false;
			_networkingChecked = true;
		}
	}

	private static bool CanUseAdvancedFeatures()
	{
		if (!_networkingChecked)
		{
			CheckNetworkingAuthority();
		}
		return _isHost;
	}

	private static string GetAdvancedFeatureMessage()
	{
		return "⚠\ufe0f This feature requires host privileges in multiplayer games.\nAdvanced item management only works for the host/server player.\nMovement, visual, and spell features work for all players.";
	}

	private void OnDestroy()
	{
		Harmony harmony = _harmony;
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
		((BaseUnityPlugin)this).Logger.LogInfo((object)"[Looney] Plugin unloaded.");
	}

	private void Update()
	{
		if (Time.time - lastSystemCheck > 30f)
		{
			lastSystemCheck = Time.time;
			if (!dependencyValidated)
			{
				dependencyValidated = typeof(LooneyPlugin).GetCustomAttributes(typeof(BepInDependency), inherit: false).Length != 0;
			}
		}
		PerformPhysicsCalculation();
		if (Input.GetKeyDown((KeyCode)102))
		{
			menuVisible = !menuVisible;
			Cursor.lockState = (CursorLockMode)((!menuVisible) ? 1 : 0);
			Cursor.visible = menuVisible;
			Debug.Log((object)("[Looney] Mod menu " + (menuVisible ? "OPENED" : "closed") + "."));
		}
		if (Input.GetKeyDown((KeyCode)105) && (Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305)))
		{
			_showItemSpawner = !_showItemSpawner;
			Cursor.lockState = (CursorLockMode)((!_showItemSpawner) ? 1 : 0);
			Cursor.visible = _showItemSpawner;
			Debug.Log((object)("[Looney] Item spawner " + (_showItemSpawner ? "OPENED" : "closed") + "."));
		}
		if (Input.GetKeyDown((KeyCode)109) && (Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305)))
		{
			_showInventoryManager = !_showInventoryManager;
			Cursor.lockState = (CursorLockMode)((!_showInventoryManager) ? 1 : 0);
			Cursor.visible = _showInventoryManager;
			Debug.Log((object)("[Looney] Inventory manager " + (_showInventoryManager ? "OPENED" : "closed") + "."));
		}
		if (Input.GetKeyDown((KeyCode)115) && (Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305)))
		{
			_showSpellItemGiver = !_showSpellItemGiver;
			if (_showSpellItemGiver)
			{
				RefreshSpellList();
			}
			Cursor.lockState = (CursorLockMode)((!_showSpellItemGiver) ? 1 : 0);
			Cursor.visible = _showSpellItemGiver;
			Debug.Log((object)("[Looney] Advanced Spell & Item Giver " + (_showSpellItemGiver ? "OPENED" : "closed") + "."));
		}
		if (Input.GetKeyDown((KeyCode)100) && (Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305)))
		{
			DuplicateHeldItem();
		}
		if (Input.GetKeyDown((KeyCode)108) && (Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305)))
		{
			Cheats.inventoryLock = !Cheats.inventoryLock;
			Debug.Log((object)("[Looney] Inventory lock " + (Cheats.inventoryLock ? "ENABLED" : "disabled") + "."));
		}
		if (Input.GetKeyDown((KeyCode)98) && (Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305)))
		{
			CreateInventoryBackup("Manual_" + DateTime.Now.ToString("HH-mm-ss"));
		}
		if (Input.GetKeyDown((KeyCode)114) && (Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305)) && _inventoryBackups.Count > 0)
		{
			RestoreInventoryBackup(_inventoryBackups.Count - 1);
		}
		if (Cheats.multiCast && Input.GetKey((KeyCode)323) && !_isCasting && (Object)(object)inv != (Object)null)
		{
			((MonoBehaviour)this).StartCoroutine(MultiCastRoutine());
		}
		if (Input.GetKeyDown((KeyCode)289))
		{
			Debug.Log((object)"[Looney] ========== F8 PRESSED - GIVE ALL SPELLS ==========");
			Debug.Log((object)$"[Looney] Current player status: inv={(Object)(object)inv != (Object)null}, pm={(Object)(object)pm != (Object)null}");
			Debug.Log((object)$"[Looney] Available spell pages: {_spellPages.Count}");
			GiveAllSpells();
			Debug.Log((object)"[Looney] ========== GIVE ALL SPELLS COMPLETED ==========");
		}
		if (Input.GetKeyDown((KeyCode)288) && (Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303)))
		{
			Debug.Log((object)"[Looney] ========== SHIFT+F7 - DIAGNOSTIC ITEM TEST ==========");
			TestSimpleItemGiving();
			Debug.Log((object)"[Looney] ========== DIAGNOSTIC ITEM TEST COMPLETED ==========");
		}
	}

	private IEnumerator MultiCastRoutine()
	{
		if ((Object)(object)inv == (Object)null || (Object)(object)pm == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)"[Looney] Cannot cast spells: inventory or player movement is null.");
			yield break;
		}
		_isCasting = true;
		float num = Time.time - 100f;
		fi_fbcd?.SetValue(inv, num);
		fi_frostcd?.SetValue(inv, num);
		fi_wormcd?.SetValue(inv, num);
		fi_holecd?.SetValue(inv, num);
		fi_wardcd?.SetValue(inv, num);
		GameObject[] array = fi_equippedItems?.GetValue(inv) as GameObject[];
		int num2 = -1;
		for (int i = 0; i < array?.Length; i++)
		{
			if ((Object)(object)array[i] != (Object)null && (Object)(object)array[i].GetComponent<MageBookController>() != (Object)null)
			{
				num2 = i;
				break;
			}
		}
		if (num2 != -1)
		{
			fi_equippedIndex?.SetValue(inv, num2);
			MageBookController component = array[num2].GetComponent<MageBookController>();
			if ((Object)(object)component != (Object)null)
			{
				switch (component.LastPressedPage)
				{
				case 1:
					inv.cFireball();
					((BaseUnityPlugin)this).Logger.LogInfo((object)"[Looney] Spellbook casted: Fireball");
					break;
				case 2:
					inv.cFrostbolt();
					((BaseUnityPlugin)this).Logger.LogInfo((object)"[Looney] Spellbook casted: Frostbolt");
					break;
				case 3:
					inv.cCastworm();
					inv.cCasthole();
					((BaseUnityPlugin)this).Logger.LogInfo((object)"[Looney] Spellbook casted: Worm & Hole");
					break;
				case 4:
					inv.cCastWard();
					((BaseUnityPlugin)this).Logger.LogInfo((object)"[Looney] Spellbook casted: Ward");
					break;
				}
			}
		}
		PageController[] componentsInChildren = ((Component)inv).GetComponentsInChildren<PageController>(true);
		foreach (PageController val in componentsInChildren)
		{
			if (!((Object)(object)val?.spellprefab == (Object)null) && ((Component)val).gameObject.activeInHierarchy)
			{
				NetworkObject component2 = Object.Instantiate<GameObject>(val.spellprefab, ((Component)pm).transform.position + ((Component)pm).transform.forward * 2f, Quaternion.identity).GetComponent<NetworkObject>();
				if ((Object)(object)component2 != (Object)null)
				{
					Object.Destroy((Object)(object)component2);
				}
				try
				{
					val.CastSpell(((Component)pm).gameObject, pm.level);
					((BaseUnityPlugin)this).Logger.LogInfo((object)("[Looney] Casted local page: " + ((Object)val).name));
				}
				catch (Exception ex)
				{
					((BaseUnityPlugin)this).Logger.LogError((object)("[Looney] Error casting " + ((Object)val).name + ": " + ex.Message));
				}
				yield return (object)new WaitForSeconds(_waitTime);
			}
		}
		_isCasting = false;
	}

	private static void RefreshSpellList()
	{
		Debug.Log((object)"[Looney] STARTING RefreshSpellList...");
		_spellPages.Clear();
		PageLootTable[] array = Object.FindObjectsByType<PageLootTable>((FindObjectsSortMode)0);
		Debug.Log((object)$"[Looney] Found {array.Length} PageLootTable objects");
		PageLootTable[] array2 = array;
		foreach (PageLootTable val in array2)
		{
			string name = ((Object)val).name;
			GameObject[] pages = val.Pages;
			Debug.Log((object)$"[Looney] Processing PageLootTable: {name}, Pages count: {((pages != null) ? pages.Length : 0)}");
			if (val.Pages != null)
			{
				GameObject[] pages2 = val.Pages;
				foreach (GameObject val2 in pages2)
				{
					if ((Object)(object)val2 != (Object)null)
					{
						if (!_spellPages.Contains(val2))
						{
							_spellPages.Add(val2);
							Debug.Log((object)("[Looney] Added spell page: " + ((Object)val2).name));
						}
						else
						{
							Debug.Log((object)("[Looney] Duplicate spell page skipped: " + ((Object)val2).name));
						}
					}
					else
					{
						Debug.Log((object)"[Looney] NULL page found in PageLootTable");
					}
				}
			}
			else
			{
				Debug.Log((object)("[Looney] PageLootTable " + ((Object)val).name + " has null Pages array!"));
			}
		}
		_spellPageNames = _spellPages.Select(delegate(GameObject p)
		{
			PageController component = p.GetComponent<PageController>();
			object obj;
			if (component == null)
			{
				obj = null;
			}
			else
			{
				GameObject spellprefab = component.spellprefab;
				obj = ((spellprefab != null) ? ((Object)spellprefab).name : null);
			}
			if (obj == null)
			{
				obj = "Unknown";
			}
			string text = (string)obj;
			Debug.Log((object)("[Looney] Spell page: " + ((Object)p).name + " → " + text));
			return ((Object)p).name + " → " + text;
		}).ToArray();
		Debug.Log((object)$"[Looney] COMPLETED RefreshSpellList: {_spellPages.Count} spell pages total");
		if (_spellPages.Count == 0)
		{
			Debug.LogWarning((object)"[Looney] WARNING: No spell pages found! This could mean:");
			Debug.LogWarning((object)"[Looney] - PageLootTable objects aren't loaded yet");
			Debug.LogWarning((object)"[Looney] - Player isn't in a game world");
			Debug.LogWarning((object)"[Looney] - Spell system has changed");
		}
	}

	private void GiveAllSpells()
	{
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		PlayerInventory val = null;
		if ((Object)(object)inv != (Object)null)
		{
			val = inv;
			Debug.Log((object)"[Looney] Using cached PlayerInventory for GiveAllSpells.");
		}
		else
		{
			val = Object.FindFirstObjectByType<PlayerInventory>();
			if ((Object)(object)val != (Object)null)
			{
				Debug.Log((object)"[Looney] Found PlayerInventory via fallback search for GiveAllSpells.");
			}
		}
		if ((Object)(object)val == (Object)null)
		{
			Debug.LogWarning((object)"[Looney] PlayerInventory not found - cannot give spells.");
			return;
		}
		int num = 0;
		int num2 = 0;
		foreach (GameObject spellPage in _spellPages)
		{
			if ((Object)(object)spellPage == (Object)null)
			{
				num2++;
				continue;
			}
			try
			{
				GameObject val2 = Object.Instantiate<GameObject>(spellPage);
				NetworkObject component = val2.GetComponent<NetworkObject>();
				NetworkObject component2 = ((Component)val).GetComponent<NetworkObject>();
				if ((Object)(object)component != (Object)null && (Object)(object)component2 != (Object)null && component2.IsServer)
				{
					component2.NetworkManager.ServerManager.Spawn(val2, (NetworkConnection)null, default(Scene));
					Debug.Log((object)("[Looney] Spawned spell page '" + ((Object)spellPage).name + "' on network (server mode)."));
				}
				val.Pickup(val2);
				num++;
				PageController component3 = spellPage.GetComponent<PageController>();
				object obj;
				if (component3 == null)
				{
					obj = null;
				}
				else
				{
					GameObject spellprefab = component3.spellprefab;
					obj = ((spellprefab != null) ? ((Object)spellprefab).name : null);
				}
				if (obj == null)
				{
					obj = "Unknown Spell";
				}
				string text = (string)obj;
				((BaseUnityPlugin)this).Logger.LogInfo((object)("[Looney] Gave player spell page: " + ((Object)spellPage).name + " → " + text));
				Debug.Log((object)("[Looney] SUCCESS: Gave spell page '" + ((Object)spellPage).name + "' (was " + (spellPage.activeInHierarchy ? "active" : "inactive") + " template)"));
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[Looney] Failed to give spell page '" + ((Object)spellPage).name + "': " + ex.Message));
				num2++;
			}
		}
		Debug.Log((object)$"[Looney] GiveAllSpells completed: {num} given, {num2} skipped, {_spellPages.Count} total");
		((BaseUnityPlugin)this).Logger.LogInfo((object)$"[Looney] Successfully gave {num} spell pages to player (skipped {num2})");
	}

	private void TestSimpleItemGiving()
	{
		Debug.Log((object)"[Looney] === DIAGNOSTIC TEST: Simple Item Giving ===");
		Debug.Log((object)"[Looney] TEST 1: Player Detection");
		Debug.Log((object)$"[Looney] Cached inv: {(Object)(object)inv != (Object)null}");
		Debug.Log((object)$"[Looney] Cached pm: {(Object)(object)pm != (Object)null}");
		PlayerInventory val = Object.FindFirstObjectByType<PlayerInventory>();
		Debug.Log((object)$"[Looney] Direct PlayerInventory search result: {(Object)(object)val != (Object)null}");
		if ((Object)(object)val != (Object)null)
		{
			Debug.Log((object)("[Looney] Direct inventory name: " + ((Object)val).name));
			PlayerMovement component = ((Component)val).GetComponent<PlayerMovement>();
			Debug.Log((object)$"[Looney] Direct PlayerMovement found: {(Object)(object)component != (Object)null}");
			if ((Object)(object)component != (Object)null)
			{
				Debug.Log((object)$"[Looney] Direct PlayerMovement IsOwner: {((NetworkBehaviour)component).IsOwner}");
			}
		}
		Debug.Log((object)"[Looney] TEST 2: Spell Page Availability");
		Debug.Log((object)$"[Looney] Total spell pages found: {_spellPages.Count}");
		if (_spellPages.Count > 0)
		{
			GameObject val2 = _spellPages[0];
			Debug.Log((object)("[Looney] Test page name: " + ((Object)val2).name));
			Debug.Log((object)$"[Looney] Test page active: {val2.activeInHierarchy}");
			Debug.Log((object)$"[Looney] Test page null: {(Object)(object)val2 == (Object)null}");
		}
		Debug.Log((object)"[Looney] TEST 3: Item Database");
		Debug.Log((object)$"[Looney] ItemDatabase count: {ItemDatabase.Count}");
		if (ItemDatabase.ContainsKey(5))
		{
			Debug.Log((object)("[Looney] Test item (Sword): " + ItemDatabase[5].Name));
		}
		Debug.Log((object)"[Looney] TEST 4: Simple Give Attempt");
		if (_spellPages.Count > 0 && ((Object)(object)inv != (Object)null || (Object)(object)val != (Object)null))
		{
			PlayerInventory val3 = inv ?? val;
			GameObject val4 = _spellPages[0];
			Debug.Log((object)("[Looney] Attempting to give: " + ((Object)val4).name));
			Debug.Log((object)("[Looney] Using inventory: " + ((Object)val3).name));
			try
			{
				GameObject val5 = Object.Instantiate<GameObject>(val4);
				Debug.Log((object)"[Looney] Clone created successfully");
				NetworkObject component2 = val5.GetComponent<NetworkObject>();
				Debug.Log((object)$"[Looney] NetworkObject found: {(Object)(object)component2 != (Object)null}");
				if ((Object)(object)component2 != (Object)null)
				{
					Object.Destroy((Object)(object)component2);
				}
				Debug.Log((object)"[Looney] About to call Pickup...");
				val3.Pickup(val5);
				Debug.Log((object)"[Looney] ✅ DIAGNOSTIC SUCCESS: Item pickup completed!");
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[Looney] ❌ DIAGNOSTIC FAILURE: " + ex.Message));
				Debug.LogError((object)("[Looney] Stack trace: " + ex.StackTrace));
			}
		}
		else
		{
			Debug.LogError((object)"[Looney] ❌ Cannot test - no spell pages or no inventory found");
		}
		Debug.Log((object)"[Looney] === DIAGNOSTIC TEST COMPLETED ===");
	}

	private static void TryGiveSpellPageToPlayer(int index)
	{
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		if (index < 0 || index >= _spellPages.Count)
		{
			Debug.LogWarning((object)$"[Looney] Invalid spell page index: {index} (Available: {_spellPages.Count})");
			return;
		}
		PlayerInventory val = null;
		LooneyPlugin looneyPlugin = Object.FindFirstObjectByType<LooneyPlugin>();
		if ((Object)(object)looneyPlugin?.inv != (Object)null)
		{
			val = looneyPlugin.inv;
			Debug.Log((object)"[Looney] Using cached PlayerInventory from plugin instance.");
		}
		else
		{
			val = Object.FindFirstObjectByType<PlayerInventory>();
			if ((Object)(object)val != (Object)null)
			{
				Debug.Log((object)"[Looney] Found PlayerInventory via fallback search.");
			}
		}
		if ((Object)(object)val == (Object)null)
		{
			Debug.LogWarning((object)"[Looney] PlayerInventory not found - cannot give spell page.");
			return;
		}
		GameObject val2 = _spellPages[index];
		if ((Object)(object)val2 == (Object)null)
		{
			Debug.LogWarning((object)$"[Looney] Spell page at index {index} is null.");
			return;
		}
		try
		{
			GameObject val3 = Object.Instantiate<GameObject>(val2);
			NetworkObject component = val3.GetComponent<NetworkObject>();
			NetworkObject component2 = ((Component)val).GetComponent<NetworkObject>();
			if ((Object)(object)component != (Object)null && (Object)(object)component2 != (Object)null && component2.IsServer)
			{
				component2.NetworkManager.ServerManager.Spawn(val3, (NetworkConnection)null, default(Scene));
				Debug.Log((object)("[Looney] Spawned spell page '" + ((Object)val2).name + "' on network (server mode)."));
			}
			val.Pickup(val3);
			PageController component3 = val2.GetComponent<PageController>();
			object obj;
			if (component3 == null)
			{
				obj = null;
			}
			else
			{
				GameObject spellprefab = component3.spellprefab;
				obj = ((spellprefab != null) ? ((Object)spellprefab).name : null);
			}
			if (obj == null)
			{
				obj = "Unknown Spell";
			}
			string text = (string)obj;
			Debug.Log((object)("[Looney] Successfully gave spell page: '" + ((Object)val2).name + "' → " + text + " (was " + (val2.activeInHierarchy ? "active" : "inactive") + " template)"));
		}
		catch (Exception ex)
		{
			Debug.LogError((object)("[Looney] Failed to give spell page '" + ((Object)val2).name + "': " + ex.Message));
		}
	}

	private static void SetField(FieldInfo fi, object instance, object value)
	{
		if (fi != null)
		{
			fi.SetValue(instance, value);
		}
	}

	private static object GetField(FieldInfo fi, object instance)
	{
		if (!(fi != null))
		{
			return null;
		}
		return fi.GetValue(instance);
	}

	private void DuplicateHeldItem()
	{
		if ((Object)(object)inv == (Object)null)
		{
			return;
		}
		GameObject[] equippedItems = GetEquippedItems(inv);
		int equippedIndex = GetEquippedIndex(inv);
		if (equippedItems == null || equippedIndex < 0 || equippedIndex >= equippedItems.Length || !((Object)(object)equippedItems[equippedIndex] != (Object)null))
		{
			return;
		}
		IItemInteraction component = equippedItems[equippedIndex].GetComponent<IItemInteraction>();
		if (component != null)
		{
			int itemID = component.GetItemID();
			if (Cheats.smartDuplication && (itemID == 24 || itemID == 26))
			{
				Debug.Log((object)"[Looney] Smart duplication prevented quest item duplication.");
				return;
			}
			SpawnItemById(itemID, Cheats.duplicateAmount);
			Debug.Log((object)$"[Looney] Duplicated held item: {itemID} x{Cheats.duplicateAmount}");
		}
	}

	private void SpawnItemById(int itemId, int quantity = 1)
	{
		if (!ItemDatabase.ContainsKey(itemId))
		{
			Debug.LogWarning((object)$"[Looney] Unknown item ID: {itemId}");
			return;
		}
		if ((Object)(object)inv == (Object)null)
		{
			Debug.LogWarning((object)"[Looney] PlayerInventory not available for item spawning.");
			return;
		}
		for (int i = 0; i < quantity; i++)
		{
			GameObject val = FindItemPrefabById(itemId);
			if ((Object)(object)val != (Object)null)
			{
				GameObject val2 = Object.Instantiate<GameObject>(val);
				NavMeshAgent component = val2.GetComponent<NavMeshAgent>();
				if ((Object)(object)component != (Object)null)
				{
					((Behaviour)component).enabled = false;
					Debug.Log((object)("[Looney] Disabled NavMesh agent for item: " + ItemDatabase[itemId].Name));
				}
				MonoBehaviour component2 = val2.GetComponent<MonoBehaviour>();
				if ((Object)(object)component2 != (Object)null && ((object)component2).GetType().Name.Contains("AI"))
				{
					((Behaviour)component2).enabled = false;
				}
				NetworkObject component3 = val2.GetComponent<NetworkObject>();
				if ((Object)(object)component3 != (Object)null)
				{
					Object.Destroy((Object)(object)component3);
				}
				inv.Pickup(val2);
				Debug.Log((object)$"[Looney] Successfully spawned: {ItemDatabase[itemId].Name} (ID: {itemId})");
			}
			else
			{
				Debug.LogWarning((object)$"[Looney] Could not find prefab for item ID {itemId}: {ItemDatabase[itemId].Name}");
			}
		}
	}

	private GameObject FindItemPrefabById(int itemId)
	{
		GameObject[] array = Object.FindObjectsByType<GameObject>((FindObjectsInactive)1, (FindObjectsSortMode)0);
		foreach (GameObject val in array)
		{
			IItemInteraction component = val.GetComponent<IItemInteraction>();
			if (component == null)
			{
				continue;
			}
			try
			{
				if (component.GetItemID() == itemId && !val.activeInHierarchy)
				{
					return val;
				}
			}
			catch (Exception)
			{
			}
		}
		MonoBehaviour[] array2 = (from mb in Object.FindObjectsByType<MonoBehaviour>((FindObjectsSortMode)0)
			where ((object)mb).GetType().Name.Contains("Loot") || ((object)mb).GetType().Name.Contains("Item")
			select mb).ToArray();
		foreach (MonoBehaviour val2 in array2)
		{
			FieldInfo[] fields = ((object)val2).GetType().GetFields();
			foreach (FieldInfo fieldInfo in fields)
			{
				if (!(fieldInfo.FieldType == typeof(GameObject[])) || !(fieldInfo.GetValue(val2) is GameObject[] array3))
				{
					continue;
				}
				array = array3;
				foreach (GameObject val3 in array)
				{
					if (!((Object)(object)val3 != (Object)null))
					{
						continue;
					}
					IItemInteraction component2 = val3.GetComponent<IItemInteraction>();
					if (component2 == null)
					{
						continue;
					}
					try
					{
						if (component2.GetItemID() == itemId)
						{
							return val3;
						}
					}
					catch
					{
					}
				}
			}
		}
		return null;
	}

	private static void CreateInventoryBackup(string backupName)
	{
		PlayerInventory val = Object.FindFirstObjectByType<PlayerInventory>();
		if (!((Object)(object)val == (Object)null))
		{
			InventoryBackup item = new InventoryBackup(backupName, val);
			_inventoryBackups.Add(item);
			while (_inventoryBackups.Count > _maxBackups)
			{
				_inventoryBackups.RemoveAt(0);
			}
			UpdateBackupNames();
			Debug.Log((object)("[Looney] Created inventory backup: " + backupName));
		}
	}

	private static void RestoreInventoryBackup(int backupIndex)
	{
		if (backupIndex < 0 || backupIndex >= _inventoryBackups.Count)
		{
			return;
		}
		InventoryBackup inventoryBackup = _inventoryBackups[backupIndex];
		LooneyPlugin looneyPlugin = Object.FindFirstObjectByType<LooneyPlugin>();
		if ((Object)(object)looneyPlugin?.inv == (Object)null)
		{
			Debug.LogWarning((object)"[Looney] PlayerInventory not available for backup restoration.");
			return;
		}
		GameObject[] equippedItems = GetEquippedItems(looneyPlugin.inv);
		if (equippedItems != null)
		{
			for (int i = 0; i < equippedItems.Length; i++)
			{
				if ((Object)(object)equippedItems[i] != (Object)null)
				{
					Object.Destroy((Object)(object)equippedItems[i]);
					equippedItems[i] = null;
				}
			}
		}
		foreach (KeyValuePair<int, int> itemDatum in inventoryBackup.ItemData)
		{
			int key = itemDatum.Key;
			int value = itemDatum.Value;
			GameObject val = looneyPlugin.FindItemPrefabById(value);
			if ((Object)(object)val != (Object)null && equippedItems != null && key < equippedItems.Length)
			{
				GameObject val2 = Object.Instantiate<GameObject>(val);
				NetworkObject component = val2.GetComponent<NetworkObject>();
				if ((Object)(object)component != (Object)null)
				{
					Object.Destroy((Object)(object)component);
				}
				equippedItems[key] = val2;
				val2.SetActive(false);
			}
		}
		fi_equippedIndex?.SetValue(looneyPlugin.inv, inventoryBackup.EquippedIndex);
		if (equippedItems != null && inventoryBackup.EquippedIndex < equippedItems.Length && (Object)(object)equippedItems[inventoryBackup.EquippedIndex] != (Object)null)
		{
			IItemInteraction component2 = equippedItems[inventoryBackup.EquippedIndex].GetComponent<IItemInteraction>();
			if (component2 != null)
			{
				component2.ItemInit();
				looneyPlugin.inv.SwapItemImg(inventoryBackup.EquippedIndex, component2.GetItemID());
			}
		}
		Debug.Log((object)$"[Looney] Successfully restored inventory backup: {inventoryBackup.Name} ({inventoryBackup.ItemData.Count} items)");
	}

	private static void UpdateBackupNames()
	{
		_backupNames = _inventoryBackups.Select((InventoryBackup b) => $"{b.Name} ({b.Created:HH:mm:ss})").ToArray();
	}

	private static GameObject[] GetEquippedItems(PlayerInventory inventory)
	{
		return fi_equippedItems?.GetValue(inventory) as GameObject[];
	}

	private static int GetEquippedIndex(PlayerInventory inventory)
	{
		if (!(fi_equippedIndex != null))
		{
			return 0;
		}
		return (int)fi_equippedIndex.GetValue(inventory);
	}

	private void OnGUI()
	{
		//IL_0021: 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)
		//IL_0041: Expected O, but got Unknown
		//IL_003c: 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_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Expected O, but got Unknown
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Expected O, but got Unknown
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Expected O, but got Unknown
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Unknown result type (might be due to invalid IL or missing references)
		InitializeGUIStyles();
		FindLocalPlayer();
		HandleChams();
		if (menuVisible)
		{
			modWindowRect = GUILayout.Window(123456, modWindowRect, new WindowFunction(DrawModWindow), "\ud83d\ude80 Little Looney's Full Advanced Item Management Suite v3.0.0", Array.Empty<GUILayoutOption>());
		}
		if (_showItemSpawner)
		{
			itemSpawnerRect = GUILayout.Window(123457, itemSpawnerRect, new WindowFunction(DrawItemSpawnerWindow), "\ud83d\udce6 Advanced Item Spawner", Array.Empty<GUILayoutOption>());
		}
		if (_showInventoryManager)
		{
			inventoryManagerRect = GUILayout.Window(123458, inventoryManagerRect, new WindowFunction(DrawInventoryManagerWindow), "\ud83d\udcbc Inventory Manager", Array.Empty<GUILayoutOption>());
		}
		if (_showSpellItemGiver)
		{
			spellItemGiverRect = GUILayout.Window(123459, spellItemGiverRect, new WindowFunction(DrawAdvancedSpellItemGiverWindow), "\ud83d\udcdc Advanced Spell & Item Giver", Array.Empty<GUILayoutOption>());
		}
		if (_showSpellPageGUI)
		{
			DrawSpellPageGUI();
		}
	}

	private void DrawModWindow(int windowID)
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: 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_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Expected O, but got Unknown
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Expected O, but got Unknown
		//IL_005a: 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_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_021f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0224: Unknown result type (might be due to invalid IL or missing references)
		//IL_0235: Expected O, but got Unknown
		//IL_0319: Unknown result type (might be due to invalid IL or missing references)
		//IL_031e: Unknown result type (might be due to invalid IL or missing references)
		//IL_032f: Expected O, but got Unknown
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0460: Unknown result type (might be due to invalid IL or missing references)
		//IL_0465: Unknown result type (might be due to invalid IL or missing references)
		//IL_046c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0472: Unknown result type (might be due to invalid IL or missing references)
		//IL_0486: Expected O, but got Unknown
		//IL_0490: 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_049b: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ae: Expected O, but got Unknown
		//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_04bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_04cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d6: Expected O, but got Unknown
		//IL_0086: Expected O, but got Unknown
		//IL_0594: Unknown result type (might be due to invalid IL or missing references)
		//IL_0599: Unknown result type (might be due to invalid IL or missing references)
		//IL_05a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_05a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ba: Expected O, but got Unknown
		//IL_06b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_06b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_06c9: Expected O, but got Unknown
		GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
		GUIStyle val = new GUIStyle(GUI.skin.label)
		{
			fontSize = 16,
			fontStyle = (FontStyle)1
		};
		val.normal.textColor = Color.cyan;
		GUIStyle val2 = val;
		GUILayout.Label("\ud83e\uddd9\u200d♂\ufe0f Little Looney's Enhanced Mod Menu", val2, Array.Empty<GUILayoutOption>());
		if (_networkingChecked)
		{
			GUIStyle val3 = new GUIStyle(GUI.skin.label)
			{
				fontSize = 11
			};
			val3.normal.textColor = (_isHost ? Color.green : Color.yellow);
			GUIStyle val4 = val3;
			GUILayout.Label(_networkStatusMessage, val4, Array.Empty<GUILayoutOption>());
		}
		GUILayout.Space(10f);
		scrollPosition = GUILayout.BeginScrollView(scrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(550f) });
		GUILayout.BeginVertical(GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>());
		GUILayout.Label("⚡ Movement Cheats:", new GUIStyle(GUI.skin.label)
		{
			fontStyle = (FontStyle)1
		}, Array.Empty<GUILayoutOption>());
		Cheats.godMode = GUILayout.Toggle(Cheats.godMode, "\ud83d\udee1\ufe0f God Mode (F1) - Invincible to all damage", Array.Empty<GUILayoutOption>());
		Cheats.noclip = GUILayout.Toggle(Cheats.noclip, "\ud83d\udc7b Noclip (F2) - Walk through walls", Array.Empty<GUILayoutOption>());
		Cheats.flight = GUILayout.Toggle(Cheats.flight, "\ud83d\ude80 Flight (F3) - Fly freely with collisions", Array.Empty<GUILayoutOption>());
		Cheats.infStamina = GUILayout.Toggle(Cheats.infStamina, "\ud83d\udca8 Infinite Stamina (F4) - Never get tired", Array.Empty<GUILayoutOption>());
		Cheats.speedBoost = GUILayout.Toggle(Cheats.speedBoost, "⚡ Speed Boost (F5) - Enhanced movement speed", Array.Empty<GUILayoutOption>());
		if (Cheats.speedBoost)
		{
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("Speed Multiplier:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) });
			Cheats.speedMultiplier = GUILayout.HorizontalSlider(Cheats.speedMultiplier, 1f, 10f, Array.Empty<GUILayoutOption>());
			GUILayout.Label($"{Cheats.speedMultiplier:F1}x", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(40f) });
			GUILayout.EndHorizontal();
		}
		GUILayout.EndVertical();
		GUILayout.BeginVertical(GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>());
		GUILayout.Label("\ud83d\udd2e Spell Cheats:", new GUIStyle(GUI.skin.label)
		{
			fontStyle = (FontStyle)1
		}, Array.Empty<GUILayoutOption>());
		Cheats.noCooldowns = GUILayout.Toggle(Cheats.noCooldowns, "❄\ufe0f No Cooldowns (F7) - Instant spell casting", Array.Empty<GUILayoutOption>());
		Cheats.multiCast = GUILayout.Toggle(Cheats.multiCast, "\ud83d\udd25 Enhanced Multi-Cast (F8) - Cast all spells at once", Array.Empty<GUILayoutOption>());
		Cheats.rapidFire = GUILayout.Toggle(Cheats.rapidFire, "⚡ Rapid Fire (F9) - Extremely fast spell casting", Array.Empty<GUILayoutOption>());
		Cheats.noRecoil = GUILayout.Toggle(Cheats.noRecoil, "\ud83c\udfaf No Recoil - Eliminates spell recoil effects", Array.Empty<GUILayoutOption>());
		GUILayout.Space(10f);
		GUILayout.Label($"Multi-Cast Wait Time: {_waitTime:F1}s", Array.Empty<GUILayoutOption>());
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		_waitTime = GUILayout.HorizontalSlider(_waitTime, 0.1f, 2f, Array.Empty<GUILayoutOption>());
		GUILayout.EndHorizontal();
		GUILayout.EndVertical();
		GUILayout.BeginVertical(GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>());
		GUILayout.Label("\ud83d\udd27 Misc Cheats:", new GUIStyle(GUI.skin.label)
		{
			fontStyle = (FontStyle)1
		}, Array.Empty<GUILayoutOption>());
		Cheats.infItems = GUILayout.Toggle(Cheats.infItems, "\ud83d\udce6 Infinite Items - Items never get consumed", Array.Empty<GUILayoutOption>());
		Cheats.noDrop = GUILayout.Toggle(Cheats.noDrop, "\ud83d\udc8e No Item Drop (F11) - Keep items when you die", Array.Empty<GUILayoutOption>());
		Cheats.instantRespawn = GUILayout.Toggle(Cheats.instantRespawn, "⚡ Instant Respawn (F10) - Respawn immediately", Array.Empty<GUILayoutOption>());
		GUILayout.Space(10f);
		GUILayout.Label($"XP Multiplier: {Cheats.xpMultiplier:F0}x (F6 to cycle)", Array.Empty<GUILayoutOption>());
		if (GUILayout.Button("Cycle XP Multiplier", Array.Empty<GUILayoutOption>()))
		{
			float xpMultiplier = Cheats.xpMultiplier;
			if (xpMultiplier < 50f)
			{
				Cheats.xpMultiplier = 50f;
				Debug.Log((object)"[Looney] XP multiplier set to 50x.");
			}
			else if (Mathf.Approximately(xpMultiplier, 50f))
			{
				Cheats.xpMultiplier = 150f;
				Debug.Log((object)"[Looney] XP multiplier set to 150x.");
			}
			else if (Mathf.Approximately(xpMultiplier, 150f))
			{
				Cheats.xpMultiplier = 500f;
				Debug.Log((object)"[Looney] XP multiplier set to 500x.");
			}
			else
			{
				Cheats.xpMultiplier = 10f;
				Debug.Log((object)"[Looney] XP multiplier reset to normal.");
			}
		}
		GUILayout.EndVertical();
		GUILayout.BeginVertical(GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>());
		GUIStyle val5 = new GUIStyle(GUI.skin.label)
		{
			fontStyle = (FontStyle)1
		};
		val5.normal.textColor = Color.yellow;
		GUILayout.Label("\ud83d\udc41\ufe0f Visual Cheats:", val5, Array.Empty<GUILayoutOption>());
		GUIStyle val6 = new GUIStyle(GUI.skin.toggle);
		val6.normal.textColor = Color.green;
		val6.fontSize = 11;
		GUIStyle val7 = val6;
		GUIStyle val8 = new GUIStyle(GUI.skin.toggle);
		val8.normal.textColor = Color.white;
		val8.fontSize = 11;
		GUIStyle val9 = val8;
		Cheats.chams = GUILayout.Toggle(Cheats.chams, Cheats.chams ? "\ud83c\udf08 Player Chams - ACTIVE" : "\ud83c\udf08 Player Chams - See players through walls", Cheats.chams ? val7 : val9, Array.Empty<GUILayoutOption>());
		Cheats.noFog = GUILayout.Toggle(Cheats.noFog, Cheats.noFog ? "\ud83c\udf2b\ufe0f No Fog (F12) - ACTIVE" : "\ud83c\udf2b\ufe0f No Fog (F12) - Remove all fog effects", Cheats.noFog ? val7 : val9, Array.Empty<GUILayoutOption>());
		Cheats.fullbright = GUILayout.Toggle(Cheats.fullbright, Cheats.fullbright ? "\ud83d\udca1 Fullbright (Insert) - ACTIVE" : "\ud83d\udca1 Fullbright (Insert) - Maximum brightness everywhere", Cheats.fullbright ? val7 : val9, Array.Empty<GUILayoutOption>());
		GUILayout.EndVertical();
		GUILayout.BeginVertical(GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>());
		GUIStyle val10 = new GUIStyle(GUI.skin.label)
		{
			fontStyle = (FontStyle)1
		};
		val10.normal.textColor = Color.cyan;
		GUILayout.Label("\ud83d\udd27 Advanced Management Windows:", val10, Array.Empty<GUILayoutOption>());
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		if (GUILayout.Button("\ud83d\udce6 Item Spawner (Ctrl+I)", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
		{
			_showItemSpawner = !_showItemSpawner;
			if (_showItemSpawner)
			{
				Cursor.lockState = (CursorLockMode)0;
				Cursor.visible = true;
			}
		}
		if (GUILayout.Button("\ud83d\udcbc Inventory Manager (Ctrl+M)", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
		{
			_showInventoryManager = !_showInventoryManager;
			if (_showInventoryManager)
			{
				Cursor.lockState = (CursorLockMode)0;
				Cursor.visible = true;
			}
		}
		GUILayout.EndHorizontal();
		if (GUILayout.Button("\ud83d\udcdc Advanced Spell & Item Giver (RMB/Ctrl+S)", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
		{
			_showSpellItemGiver = !_showSpellItemGiver;
			if (_showSpellItemGiver)
			{
				RefreshSpellList();
				Cursor.lockState = (CursorLockMode)0;
				Cursor.visible = true;
			}
		}
		GUILayout.EndVertical();
		GUILayout.BeginVertical(GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>());
		GUILayout.Label("\ud83d\udcdc Quick Spell Actions:", new GUIStyle(GUI.skin.label)
		{
			fontStyle = (FontStyle)1
		}, Array.Empty<GUILayoutOption>());
		GUILayout.Label($"Available Spell Pages: {_spellPages.Count}", Array.Empty<GUILayoutOption>());
		if (GUILayout.Button("\ud83c\udf81 Give All Spells (F8)", Array.Empty<GUILayoutOption>()))
		{
			GiveAllSpells();
		}
		if (GUILayout.Button("\ud83d\udd04 Refresh Spell List", Array.Empty<GUILayoutOption>()))
		{
			RefreshSpellList();
		}
		GUILayout.EndVertical();
		GUILayout.EndScrollView();
		GUILayout.Space(10f);
		GUILayout.Label("\ud83c\udfae Controls: F - Menu | RMB - Spell Giver | F8 - All Spells", GUI.skin.box, Array.Empty<GUILayoutOption>());
		GUILayout.EndVertical();
		GUI.DragWindow();
	}

	private void DrawItemSpawnerWindow(int windowID)
	{
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0195: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0290: Unknown result type (might be due to invalid IL or missing references)
		//IL_0295: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a6: Expected O, but got Unknown
		//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e7: Expected O, but got Unknown
		//IL_0306: Unknown result type (might be due to invalid IL or missing references)
		//IL_030b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0313: Unknown result type (might be due to invalid IL or missing references)
		//IL_0319: Unknown result type (might be due to invalid IL or missing references)
		//IL_032d: Expected O, but got Unknown
		GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("\ud83d\udd0d Search:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) });
		_itemSearchFilter = GUILayout.TextField(_itemSearchFilter, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) });
		if (GUILayout.Button("Clear", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }))
		{
			_itemSearchFilter = "";
		}
		GUILayout.EndHorizontal();
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("\ud83d\udcc2 Category:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) });
		string[] names = Enum.GetNames(typeof(ItemCategory));
		_selectedItemCategory = GUILayout.SelectionGrid(_selectedItemCategory, names, 4, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(40f) });
		GUILayout.EndHorizontal();
		GUILayout.Space(10f);
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("\ud83d\udcca Quantity:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) });
		_spawnQuantity = (int)GUILayout.HorizontalSlider((float)_spawnQuantity, 1f, 64f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) });
		GUILayout.Label($"{_spawnQuantity}", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) });
		GUILayout.EndHorizontal();
		GUILayout.Space(5f);
		itemScrollPosition = GUILayout.BeginScrollView(itemScrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(350f) });
		IOrderedEnumerable<ItemInfo> orderedEnumerable = from item in ItemDatabase.Values
			where _selectedItemCategory == 0 || item.Category == (ItemCategory)_selectedItemCategory
			where string.IsNullOrEmpty(_itemSearchFilter) || item.Name.ToLower().Contains(_itemSearchFilter.ToLower()) || item.Description.ToLower().Contains(_itemSearchFilter.ToLower()) || item.Id.ToString().Contains(_itemSearchFilter)
			orderby item.Category, item.Name
			select item;
		foreach (ItemInfo item in orderedEnumerable)
		{
			GUILayout.BeginHorizontal(GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>());
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			GUILayout.Label($"\ud83c\udfaf {item.Name} (ID: {item.Id})", new GUIStyle(GUI.skin.label)
			{
				fontStyle = (FontStyle)1
			}, Array.Empty<GUILayoutOption>());
			string text = "\ud83d\udcdd " + item.Description;
			GUIStyle val = new GUIStyle(GUI.skin.label)
			{
				fontSize = 10
			};
			val.normal.textColor = Color.gray;
			GUILayout.Label(text, val, Array.Empty<GUILayoutOption>());
			string text2 = $"\ud83d\udcc2 {item.Category}";
			GUIStyle val2 = new GUIStyle(GUI.skin.label)
			{
				fontSize = 10
			};
			val2.normal.textColor = Color.yellow;
			GUILayout.Label(text2, val2, Array.Empty<GUILayoutOption>());
			GUILayout.EndVertical();
			GUILayout.FlexibleSpace();
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			if (GUILayout.Button($"Spawn {_spawnQuantity}x", (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(80f),
				GUILayout.Height(25f)
			}))
			{
				SpawnItemById(item.Id, _spawnQuantity);
			}
			if (GUILayout.Button("Spawn 1x", (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(80f),
				GUILayout.Height(20f)
			}))
			{
				SpawnItemById(item.Id);
			}
			GUILayout.EndVertical();
			GUILayout.EndHorizontal();
		}
		GUILayout.EndScrollView();
		GUILayout.BeginHorizontal(GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>());
		GUILayout.Label("⚡ Quick Spawn:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) });
		if (GUILayout.Button("All Weapons", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) }))
		{
			foreach (ItemInfo item2 in ItemDatabase.Values.Where((ItemInfo i) => i.Category == ItemCategory.Weapons))
			{
				SpawnItemById(item2.Id);
			}
		}
		if (GUILayout.Button("All Tools", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) }))
		{
			foreach (ItemInfo item3 in ItemDatabase.Values.Where((ItemInfo i) => i.Category == ItemCategory.Tools))
			{
				SpawnItemById(item3.Id);
			}
		}
		if (GUILayout.Button("All Magic", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) }))
		{
			foreach (ItemInfo item4 in ItemDatabase.Values.Where((ItemInfo i) => i.Category == ItemCategory.Magic))
			{
				SpawnItemById(item4.Id);
			}
		}
		GUILayout.EndHorizontal();
		GUILayout.Space(5f);
		GUILayout.Label($"\ud83d\udcca Total Items: {ItemDatabase.Count} | Filtered: {orderedEnumerable.Count()}", GUI.skin.box, Array.Empty<GUILayoutOption>());
		GUILayout.EndVertical();
		GUI.DragWindow();
	}

	private void DrawInventoryManagerWindow(int windowID)
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Expected O, but got Unknown
		//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01da: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ee: Expected O, but got Unknown
		//IL_0220: Unknown result type (might be due to invalid IL or missing references)
		//IL_0225: Unknown result type (might be due to invalid IL or missing references)
		//IL_0236: Expected O, but got Unknown
		//IL_0362: Unknown result type (might be due to invalid IL or missing references)
		//IL_0367: Unknown result type (might be due to invalid IL or missing references)
		//IL_0378: Expected O, but got Unknown
		//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0400: Unknown result type (might be due to invalid IL or missing references)
		//IL_0420: Unknown result type (might be due to invalid IL or missing references)
		//IL_0425: Unknown result type (might be due to invalid IL or missing references)
		//IL_042b: Unknown result type (might be due to invalid IL or missing references)
		//IL_043f: Expected O, but got Unknown
		//IL_0493: Unknown result type (might be due to invalid IL or missing references)
		//IL_0498: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a9: Expected O, but got Unknown
		//IL_04c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e0: Expected O, but got Unknown
		//IL_0505: Unknown result type (might be due to invalid IL or missing references)
		//IL_050a: Unknown result type (might be due to invalid IL or missing references)
		//IL_051c: Expected O, but got Unknown
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ac: Expected O, but got Unknown
		//IL_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0135: Unknown result type (might be due to invalid IL or missing references)
		GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
		GUILayout.BeginVertical(GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>());
		GUILayout.Label("\ud83d\udce6 Current Inventory:", new GUIStyle(GUI.skin.label)
		{
			fontStyle = (FontStyle)1
		}, Array.Empty<GUILayoutOption>());
		if ((Object)(object)inv != (Object)null)
		{
			GameObject[] equippedItems = GetEquippedItems(inv);
			int equippedIndex = GetEquippedIndex(inv);
			if (equippedItems != null)
			{
				for (int i = 0; i < equippedItems.Length; i++)
				{
					GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
					string text = ((i == equippedIndex) ? "➤ " : "   ");
					if ((Object)(object)equippedItems[i] != (Object)null)
					{
						IItemInteraction component = equippedItems[i].GetComponent<IItemInteraction>();
						if (component != null)
						{
							int itemID = component.GetItemID();
							string text2 = (ItemDatabase.ContainsKey(itemID) ? ItemDatabase[itemID].Name : "Unknown");
							object obj = $"{text}Slot {i}: {text2} (ID: {itemID})";
							if (i != equippedIndex)
							{
								obj = GUI.skin.label;
							}
							else
							{
								GUIStyle val = new GUIStyle(GUI.skin.label);
								val.normal.textColor = Color.green;
								obj = (object)val;
							}
							GUILayout.Label((string)obj, (GUIStyle)obj, Array.Empty<GUILayoutOption>());
						}
						else
						{
							GUILayout.Label($"{text}Slot {i}: Unknown Item", GUI.skin.label, Array.Empty<GUILayoutOption>());
						}
					}
					else
					{
						string text3 = $"{text}Slot {i}: Empty";
						GUIStyle val2 = new GUIStyle(GUI.skin.label);
						val2.normal.textColor = Color.gray;
						GUILayout.Label(text3, val2, Array.Empty<GUILayoutOption>());
					}
					GUILayout.EndHorizontal();
				}
			}
		}
		else
		{
			GUIStyle val3 = new GUIStyle(GUI.skin.label);
			val3.normal.textColor = Color.red;
			GUILayout.Label("❌ PlayerInventory not found", val3, Array.Empty<GUILayoutOption>());
		}
		GUILayout.EndVertical();
		GUILayout.Space(10f);
		GUILayout.BeginVertical(GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>());
		GUILayout.Label("\ud83d\udd27 Inventory Controls:", new GUIStyle(GUI.skin.label)
		{
			fontStyle = (FontStyle)1
		}, Array.Empty<GUILayoutOption>());
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		Cheats.inventoryLock = GUILayout.Toggle(Cheats.inventoryLock, "\ud83d\udd12 Lock Inventory", Array.Empty<GUILayoutOption>());
		Cheats.preventCrafting = GUILayout.Toggle(Cheats.preventCrafting, "\ud83d\udeab Block Crafting", Array.Empty<GUILayoutOption>());
		GUILayout.EndHorizontal();
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		Cheats.preventTrading = GUILayout.Toggle(Cheats.preventTrading, "\ud83d\udeab Block Trading", Array.Empty<GUILayoutOption>());
		Cheats.smartDuplication = GUILayout.Toggle(Cheats.smartDuplication, "\ud83e\udde0 Smart Duplication", Array.Empty<GUILayoutOption>());
		GUILayout.EndHorizontal();
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("\ud83d\udccb Duplicate Amount:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) });
		Cheats.duplicateAmount = (int)GUILayout.HorizontalSlider((float)Cheats.duplicateAmount, 1f, 10f, Array.Empty<GUILayoutOption>());
		GUILayout.Label($"{Cheats.duplicateAmount}x", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) });
		GUILayout.EndHorizontal();
		GUILayout.EndVertical();
		GUILayout.Space(10f);
		GUILayout.BeginVertical(GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>());
		GUILayout.Label("\ud83d\udcbe Backup Management:", new GUIStyle(GUI.skin.label)
		{
			fontStyle = (FontStyle)1
		}, Array.Empty<GUILayoutOption>());
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		_autoBackupEnabled = GUILayout.Toggle(_autoBackupEnabled, "\ud83d\udd04 Auto-Backup", Array.Empty<GUILayoutOption>());
		if (GUILayout.Button("\ud83d\udcc4 Create Backup", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) }))
		{
			CreateInventoryBackup("Manual_" + DateTime.Now.ToString("HH-mm-ss"));
		}
		GUILayout.EndHorizontal();
		inventoryScrollPosition = GUILayout.BeginScrollView(inventoryScrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(120f) });
		if (_inventoryBackups.Count == 0)
		{
			GUIStyle val4 = new GUIStyle(GUI.skin.label);
			val4.normal.textColor = Color.gray;
			GUILayout.Label("\ud83d\udced No backups available", val4, Array.Empty<GUILayoutOption>());
		}
		else
		{
			for (int j = 0; j < _inventoryBackups.Count; j++)
			{
				InventoryBackup inventoryBackup = _inventoryBackups[j];
				GUILayout.BeginHorizontal(GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>());
				GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
				GUILayout.Label("\ud83d\udce6 " + inventoryBackup.Name, new GUIStyle(GUI.skin.label)
				{
					fontStyle = (FontStyle)1
				}, Array.Empty<GUILayoutOption>());
				GUILayout.Label($"\ud83d\udd52 {inventoryBackup.Created:yyyy-MM-dd HH:mm:ss}", new GUIStyle(GUI.skin.label)
				{
					fontSize = 10
				}, Array.Empty<GUILayoutOption>());
				GUILayout.Label($"\ud83d\udcca {inventoryBackup.ItemData.Count} items", new GUIStyle(GUI.skin.label)
				{
					fontSize = 10
				}, Array.Empty<GUILayoutOption>());
				GUILayout.EndVertical();
				GUILayout.FlexibleSpace();
				GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
				if (GUILayout.Button("\ud83d\udce5 Restore", (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Width(60f),
					GUILayout.Height(20f)
				}))
				{
					RestoreInventoryBackup(j);
				}
				if (GUILayout.Button("\ud83d\uddd1\ufe0f Delete", (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Width(60f),
					GUILayout.Height(20f)
				}))
				{
					_inventoryBackups.RemoveAt(j);
					UpdateBackupNames();
				}
				GUILayout.EndVertical();
				GUILayout.EndHorizontal();
			}
		}
		GUILayout.EndScrollView();
		GUILayout.EndVertical();
		GUILayout.EndVertical();
		GUI.DragWindow();
	}

	private void DrawAdvancedSpellItemGiverWindow(int windowID)
	{
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_013f: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0190: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a1: Expected O, but got Unknown
		GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("\ud83d\udccb Mode:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) });
		string[] array = new string[2] { "\ud83d\udcdc Spells", "\ud83d\udce6 Items" };
		_giverTab = GUILayout.SelectionGrid(_giverTab, array, 2, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) });
		GUILayout.EndHorizontal();
		GUILayout.Space(5f);
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("\ud83d\udd0d Search:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) });
		_giverSearchFilter = GUILayout.TextField(_giverSearchFilter, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(200f) });
		if (GUILayout.Button("Clear", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }))
		{
			_giverSearchFilter = "";
		}
		if (GUILayout.Button("\ud83d\udd04 Refresh", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) }))
		{
			RefreshSpellList();
		}
		GUILayout.EndHorizontal();
		GUILayout.Space(10f);
		giverScrollPosition = GUILayout.BeginScrollView(giverScrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(450f) });
		if (_giverTab == 0)
		{
			DrawSpellsTab();
		}
		else
		{
			DrawItemsTab();
		}
		GUILayout.EndScrollView();
		GUILayout.Space(10f);
		GUILayout.BeginVertical(GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>());
		GUILayout.Label("⚡ Quick Actions:", new GUIStyle(GUI.skin.label)
		{
			fontStyle = (FontStyle)1
		}, Array.Empty<GUILayoutOption>());
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		if (_giverTab == 0)
		{
			if (GUILayout.Button("\ud83c\udf81 Give All Spells", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
			{
				GiveAllSpells();
			}
			if (GUILayout.Button("\ud83d\udd2e Give Combat Spells", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
			{
				GiveCombatSpells();
			}
		}
		else
		{
			if (GUILayout.Button("⚒\ufe0f Give All Tools", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
			{
				GiveItemsByCategory(ItemCategory.Tools);
			}
			if (GUILayout.Button("⚔\ufe0f Give All Weapons", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
			{
				GiveItemsByCategory(ItemCategory.Weapons);
			}
		}
		GUILayout.EndHorizontal();
		GUILayout.EndVertical();
		GUILayout.Space(5f);
		if (_giverTab == 0)
		{
			GUILayout.Label($"\ud83d\udcca Available Spells: {_spellPages.Count}", GUI.skin.box, Array.Empty<GUILayoutOption>());
		}
		else
		{
			GUILayout.Label($"\ud83d\udcca Total Items: {ItemDatabase.Count}", GUI.skin.box, Array.Empty<GUILayoutOption>());
		}
		GUILayout.EndVertical();
		GUI.DragWindow();
	}

	private void DrawSpellsTab()
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: 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_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Expected O, but got Unknown
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Expected O, but got Unknown
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Expected O, but got Unknown
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		//IL_0199: Unknown result type (might be due to invalid IL or missing references)
		//IL_01aa: Expected O, but got Unknown
		//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e7: Expected O, but got Unknown
		//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0202: Unknown result type (might be due to invalid IL or missing references)
		//IL_020a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0210: Unknown result type (might be due to invalid IL or missing references)
		//IL_0224: Expected O, but got Unknown
		//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d7: Expected O, but got Unknown
		GUIStyle val = new GUIStyle(GUI.skin.label)
		{
			fontStyle = (FontStyle)1
		};
		val.normal.textColor = Color.cyan;
		GUILayout.Label("\ud83d\udcdc Spell Pages Available:", val, Array.Empty<GUILayoutOption>());
		if (_spellPages.Count == 0)
		{
			GUILayout.BeginVertical(GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>());
			GUIStyle val2 = new GUIStyle(GUI.skin.label);
			val2.normal.textColor = Color.red;
			GUILayout.Label("❌ No spell pages found", val2, Array.Empty<GUILayoutOption>());
			GUILayout.Label("Try refreshing the list or entering a game world.", new GUIStyle(GUI.skin.label)
			{
				fontSize = 10
			}, Array.Empty<GUILayoutOption>());
			GUILayout.EndVertical();
			return;
		}
		List<GameObject> list = _spellPages.Where((GameObject spell, int index) => string.IsNullOrEmpty(_giverSearchFilter) || _spellPageNames[index].ToLower().Contains(_giverSearchFilter.ToLower()) || ((Object)spell).name.ToLower().Contains(_giverSearchFilter.ToLower())).ToList();
		list.Select(delegate(GameObject spell)
		{
			int num = _spellPages.IndexOf(spell);
			return _spellPageNames[num];
		}).ToArray();
		foreach (GameObject item in list)
		{
			int index2 = _spellPages.IndexOf(item);
			GUILayout.BeginHorizontal(GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>());
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			PageController component = item.GetComponent<PageController>();
			object obj;
			if (component == null)
			{
				obj = null;
			}
			else
			{
				GameObject spellprefab = component.spellprefab;
				obj = ((spellprefab != null) ? ((Object)spellprefab).name : null);
			}
			if (obj == null)
			{
				obj = "Unknown Spell";
			}
			string text = (string)obj;
			string spellDescription = GetSpellDescription(text);
			GUILayout.Label("\ud83d\udcdc " + ((Object)item).name, new GUIStyle(GUI.skin.label)
			{
				fontStyle = (FontStyle)1
			}, Array.Empty<GUILayoutOption>());
			string text2 = "⚡ Effect: " + text;
			GUIStyle val3 = new GUIStyle(GUI.skin.label)
			{
				fontSize = 10
			};
			val3.normal.textColor = Color.yellow;
			GUILayout.Label(text2, val3, Array.Empty<GUILayoutOption>());
			string text3 = "\ud83d\udcdd " + spellDescription;
			GUIStyle val4 = new GUIStyle(GUI.skin.label)
			{
				fontSize = 9
			};
			val4.normal.textColor = Color.gray;
			GUILayout.Label(text3, val4, Array.Empty<GUILayoutOption>());