Decompiled source of Aurai Cheat Menu v1.8.13

plugins/EnchantedItemSpawner.dll

Decompiled 16 minutes 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.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using SideLoader.Helpers;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Rox.EnchantedItemSpawner
{
	[BepInPlugin("rox.outward.enchanteditemspawner", "Aurai Cheat Menu", "1.8.13")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(CharacterStats), "GetAmplifiedDamage")]
		private static class DamagePatch
		{
			private static void Postfix(Character ___m_character, ref DamageList _damages)
			{
				if (IsPlayer(___m_character) && _damages != null)
				{
					float value = Instance.damageMultiplier.Value;
					for (int i = 0; i < _damages.Count; i++)
					{
						DamageType obj = _damages[i];
						obj.Damage *= value;
					}
				}
			}
		}

		[HarmonyPatch]
		private static class InventoryWeightPatch
		{
			private static IEnumerable<MethodBase> TargetMethods()
			{
				string[] array = new string[8] { "TotalWeight", "EquipmentWeight", "PouchWeight", "BagContentWeight", "PouchWeightOver", "BagWeightOver", "PouchWeightCapacityRatio", "BagWeightCapacityRatio" };
				foreach (string text in array)
				{
					yield return AccessTools.PropertyGetter(typeof(CharacterInventory), text);
				}
			}

			private static void Postfix(CharacterInventory __instance, ref float __result)
			{
				Character val = SoloCharacter();
				if (Object.op_Implicit((Object)(object)val) && Instance.weightless.Value && (Object)(object)val.Inventory == (Object)(object)__instance)
				{
					__result = 0f;
				}
			}
		}

		[HarmonyPatch]
		private static class ContainerWeightPatch
		{
			private static IEnumerable<MethodBase> TargetMethods()
			{
				string[] array = new string[2] { "TotalContentWeight", "WeightCapacityRatio" };
				foreach (string text in array)
				{
					yield return AccessTools.PropertyGetter(typeof(ItemContainer), text);
				}
			}

			private static void Postfix(ItemContainer __instance, MethodBase __originalMethod, float ___m_contentWeight, float ___m_silverWeight, ref float __result)
			{
				if (__originalMethod.Name == "get_WeightCapacityRatio")
				{
					__result = ((__instance.ContainerCapacity > 0f) ? ((___m_contentWeight + ___m_silverWeight) / __instance.ContainerCapacity) : 0f);
				}
				Character val = SoloCharacter();
				if (Object.op_Implicit((Object)(object)val) && Instance.weightless.Value && ((Object)(object)__instance == (Object)(object)val.Inventory.Pouch || (Object.op_Implicit((Object)(object)val.Inventory.EquippedBag) && (Object)(object)__instance == (Object)(object)val.Inventory.EquippedBag.Container)))
				{
					__result = 0f;
				}
			}
		}

		[HarmonyPatch(typeof(CraftingMenu), "RefreshAutoIngredients")]
		private static class RecipeAvailabilityPatch
		{
			private static void Postfix(CraftingMenu __instance, Recipe _recipe, ref bool __result)
			{
				if (FreeRecipe(((UIElement)__instance).LocalCharacter, _recipe))
				{
					__result = true;
				}
			}
		}

		[HarmonyPatch(typeof(CraftingMenu), "CraftingDone")]
		private static class FreeCraftPatch
		{
			private static readonly MethodInfo Generate = AccessTools.Method(typeof(CraftingMenu), "GenerateResult", (Type[])null, (Type[])null);

			private static readonly MethodInfo Cancel = AccessTools.Method(typeof(CraftingMenu), "CancelCrafting", (Type[])null, (Type[])null);

			private static bool Prefix(CraftingMenu __instance, int ___m_lastRecipeIndex, List<KeyValuePair<int, Recipe>> ___m_complexeRecipes, ref IList<KeyValuePair<string, int>> ___lastConsumedIngredients)
			{
				//IL_0089: Unknown result type (might be due to invalid IL or missing references)
				if (___m_lastRecipeIndex < 0 || ___m_lastRecipeIndex >= ___m_complexeRecipes.Count)
				{
					return true;
				}
				Recipe value = ___m_complexeRecipes[___m_lastRecipeIndex].Value;
				if (!FreeRecipe(((UIElement)__instance).LocalCharacter, value))
				{
					return true;
				}
				try
				{
					___lastConsumedIngredients = null;
					ItemReferenceQuantity[] results = value.Results;
					foreach (ItemReferenceQuantity val in results)
					{
						if (val == null || !Object.op_Implicit((Object)(object)val.RefItem) || val.Quantity <= 0)
						{
							throw new InvalidOperationException("Recipe has an invalid result.");
						}
						Item refItem = val.RefItem;
						WaterItem val2 = (WaterItem)(object)((refItem is WaterItem) ? refItem : null);
						if (val2 != null && !Object.op_Implicit((Object)(object)((UIElement)__instance).LocalCharacter.Inventory.GetWaterSkinToFill(val2.WaterType, true)))
						{
							throw new InvalidOperationException("Water crafting needs a waterskin with space.");
						}
					}
					results = value.Results;
					foreach (ItemReferenceQuantity val3 in results)
					{
						Generate.Invoke(__instance, new object[2] { val3, 1 });
					}
					((BaseUnityPlugin)Instance).Logger.LogInfo((object)("Crafted known recipe without ingredients: " + value.Name));
					((UIElement)__instance).LocalCharacter.CharacterUI.ShowInfoNotification("Crafted: " + value.Name + " (no ingredients used)");
				}
				catch (Exception ex)
				{
					((BaseUnityPlugin)Instance).Logger.LogError((object)ex);
					((UIElement)__instance).LocalCharacter.CharacterUI.ShowInfoNotification("Free crafting failed: " + ex.GetBaseException().Message);
				}
				finally
				{
					Cancel.Invoke(__instance, null);
				}
				return false;
			}
		}

		[HarmonyPatch(typeof(LocalCharacterControl), "DetectMovementInputs")]
		private static class MenuMovementPatch
		{
			private static bool Prefix(Character ___m_character, ref Vector2 ___m_moveInput, ref Vector3 ___m_modifMoveInput, ref Vector3 ___m_inputMoveVector, ref bool ___m_autoRun)
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: 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_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				if (!MenuCaptures(___m_character))
				{
					return true;
				}
				___m_moveInput = Vector2.zero;
				___m_modifMoveInput = Vector2.op_Implicit(Vector2.zero);
				___m_inputMoveVector = Vector2.op_Implicit(Vector2.zero);
				___m_autoRun = false;
				if (___m_character.Sprinting)
				{
					___m_character.SprintInput(false);
				}
				return false;
			}
		}

		[HarmonyPatch]
		private static class MenuActionsPatch
		{
			private static IEnumerable<MethodBase> TargetMethods()
			{
				string[] array = new string[5] { "UpdateWeapon", "UpdateQuickSlots", "UpdateInteraction", "UpdateTargeting", "UpdateMenuInputs" };
				foreach (string text in array)
				{
					yield return AccessTools.Method(typeof(LocalCharacterControl), text, (Type[])null, (Type[])null);
				}
			}

			private static bool Prefix(Character ___m_character)
			{
				return !MenuCaptures(___m_character);
			}
		}

		[HarmonyPatch]
		private static class MenuCameraPatch
		{
			private static IEnumerable<MethodBase> TargetMethods()
			{
				yield return AccessTools.Method(typeof(ControlsInput), "RotateCameraHorizontal", (Type[])null, (Type[])null);
				yield return AccessTools.Method(typeof(ControlsInput), "RotateCameraVertical", (Type[])null, (Type[])null);
			}

			private static void Postfix(int _playerID, ref float __result)
			{
				Character val = SoloCharacter();
				if (Object.op_Implicit((Object)(object)val) && Instance.CapturesInput && Object.op_Implicit((Object)(object)val.OwnerPlayerSys) && val.OwnerPlayerSys.PlayerID == _playerID)
				{
					__result = 0f;
				}
			}
		}

		[HarmonyPatch(typeof(CharacterUI), "ShowInfoNotification", new Type[]
		{
			typeof(string),
			typeof(Sprite),
			typeof(bool)
		})]
		private static class BatchRecipeNotifications
		{
			private static bool Prefix(CharacterUI __instance)
			{
				if (Object.op_Implicit((Object)(object)Instance) && Instance.learningRecipes && Object.op_Implicit((Object)(object)Instance.owner))
				{
					return (Object)(object)__instance != (Object)(object)Instance.owner.CharacterUI;
				}
				return true;
			}
		}

		private sealed class EnchantChoice
		{
			public EnchantmentRecipe Recipe;

			public int Id;

			public string Label;
		}

		[HarmonyPatch]
		private static class KeepVitalsFull
		{
			private static IEnumerable<MethodBase> TargetMethods()
			{
				string[] array = new string[11]
				{
					"ReceiveDamage", "AffectHealth", "SetHealth", "set_CurrentHealth", "UseMana", "RestaureMana", "SetMana", "set_CurrentMana", "AffectStamina", "set_CurrentStamina",
					"UpdateVitalStats"
				};
				foreach (string text in array)
				{
					yield return AccessTools.Method(typeof(CharacterStats), text, (Type[])null, (Type[])null);
				}
				yield return AccessTools.Method(typeof(CharacterStats), "UseStamina", new Type[2]
				{
					typeof(float),
					typeof(float)
				}, (Type[])null);
			}

			private static void Prefix(Character ___m_character, out bool __state)
			{
				__state = IsPlayer(___m_character) && !___m_character.IsDead;
			}

			private static void Postfix(Character ___m_character, bool __state)
			{
				if (__state && IsPlayer(___m_character))
				{
					Instance.MaintainVitals(___m_character, wasAliveBeforeChange: true);
				}
			}
		}

		internal static Plugin Instance;

		private Harmony patches;

		private ConfigEntry<float> damageMultiplier;

		private ConfigEntry<bool> weightless;

		private ConfigEntry<bool> freeCraft;

		private string menuStatus = "";

		private string deleteText = "";

		private bool showSpawner;

		private bool confirmDestroy;

		private List<string> pendingDelete = new List<string>();

		private int pendingSilver;

		private bool confirmRespawn;

		private bool respawnBusy;

		private List<Character> pendingRespawn = new List<Character>();

		private float lastEnemyRespawn = -30f;

		private static readonly FieldInfo AiQuestGate = AccessTools.Field(typeof(CharacterAI), "m_aiActiveOnQuestEvent");

		private static readonly MethodInfo FindReserveSpawn = AccessTools.Method(typeof(AISquadManager), "FindSpawn", (Type[])null, (Type[])null);

		private GUISkin menuSkin;

		private Font menuFont;

		private readonly List<Texture2D> themeTextures = new List<Texture2D>();

		private GUIStyle heading;

		private GUIStyle caption;

		private GUIStyle rowLabel;

		private GUIStyle valueLabel;

		private GUIStyle smallLabel;

		private GUIStyle dangerButton;

		private GUIStyle listRow;

		private GUIStyle selectedListRow;

		private Texture2D panelTexture;

		private Texture2D rowTexture;

		private Texture2D goldTexture;

		private readonly Color gold = new Color(0.76f, 0.58f, 0.3f);

		private readonly Color ivory = new Color(0.92f, 0.88f, 0.78f);

		private bool ownsMenuFont;

		private Texture2D nativeCrown;

		private Texture2D nativeDeco;

		private readonly Dictionary<Rect, Texture2D> panelSlices = new Dictionary<Rect, Texture2D>();

		private RectOffset nativePanelBorder = new RectOffset(22, 22, 22, 22);

		private Vector2 cheatScroll;

		private bool learningRecipes;

		public const string Id = "rox.outward.enchanteditemspawner";

		private ConfigEntry<KeyCode> hotkey;

		private bool open;

		private bool cursorHeld;

		private int inputReleaseFrame;

		private Rect window = new Rect(80f, 60f, 820f, 560f);

		private Vector2 itemScroll;

		private Vector2 enchantScroll;

		private string itemQuery = "";

		private string enchantQuery = "";

		private string status = "Choose equipment and an enchantment.";

		private List<Item> items = new List<Item>();

		private List<Item> visibleItems = new List<Item>();

		private List<EnchantChoice> choices = new List<EnchantChoice>();

		private Item selected;

		private bool equipmentMode = true;

		private EnchantChoice enchant;

		private Character owner;

		private float lastSpawn = -10f;

		private int sleepDays = 1;

		private float lastSleep = -10f;

		private GUIStyle compactRow;

		private GUIStyle compactSelected;

		private GUIStyle compactText;

		private GUIStyle compactMeta;

		private ConfigEntry<bool> lockHealth;

		private ConfigEntry<bool> lockMana;

		private ConfigEntry<bool> lockStamina;

		private bool CapturesInput
		{
			get
			{
				if (!open)
				{
					return Time.frameCount <= inputReleaseFrame;
				}
				return true;
			}
		}

		private void InitializeCheats()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			Instance = this;
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = false;
			damageMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Cheats", "DamageMultiplier", 1f, new ConfigDescription("Outgoing player attack damage multiplier; solo only.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 99f), Array.Empty<object>()));
			weightless = ((BaseUnityPlugin)this).Config.Bind<bool>("Cheats", "Weightless", false, "Zero carried weight in solo play. Does not change item data.");
			freeCraft = ((BaseUnityPlugin)this).Config.Bind<bool>("Cheats", "FreeKnownRecipes", false, "Craft learned recipes without ingredients, at the usual crafting station.");
			InitializeVitalLocks();
			patches = new Harmony("rox.outward.enchanteditemspawner");
			try
			{
				patches.PatchAll(typeof(Plugin).Assembly);
			}
			catch
			{
				patches.UnpatchSelf();
				Instance = null;
				throw;
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Aurai Cheat Menu 1.8.13 loaded: enemy respawn, live menu, and cheats.");
		}

		private void ShutdownCheats()
		{
			if (patches != null)
			{
				patches.UnpatchSelf();
			}
			Instance = null;
			foreach (Texture2D themeTexture in themeTextures)
			{
				if (Object.op_Implicit((Object)(object)themeTexture))
				{
					Object.Destroy((Object)(object)themeTexture);
				}
			}
			if (Object.op_Implicit((Object)(object)menuSkin))
			{
				Object.Destroy((Object)(object)menuSkin);
			}
			if (Object.op_Implicit((Object)(object)menuFont) && ownsMenuFont)
			{
				Object.Destroy((Object)(object)menuFont);
			}
		}

		internal static Character SoloCharacter()
		{
			if (!Object.op_Implicit((Object)(object)Instance) || !((Behaviour)Instance).enabled)
			{
				return null;
			}
			if (!Instance.Ready(out var character))
			{
				return null;
			}
			return character;
		}

		internal static bool IsPlayer(Character character)
		{
			if (Object.op_Implicit((Object)(object)character))
			{
				return (Object)(object)character == (Object)(object)SoloCharacter();
			}
			return false;
		}

		private List<Item> InventorySnapshot(Character character)
		{
			Dictionary<string, Item> result = new Dictionary<string, Item>();
			Action<Item> add = null;
			add = delegate(Item item)
			{
				if (Object.op_Implicit((Object)(object)item) && !item.IsPendingDestroy && !result.ContainsKey(item.UID))
				{
					result.Add(item.UID, item);
					ItemContainer val2 = (ItemContainer)(object)((item is ItemContainer) ? item : null);
					if (Object.op_Implicit((Object)(object)val2))
					{
						Item[] array2 = val2.GetContainedItems().ToArray();
						foreach (Item obj2 in array2)
						{
							add(obj2);
						}
					}
					Bag val3 = (Bag)(object)((item is Bag) ? item : null);
					if (Object.op_Implicit((Object)(object)val3) && Object.op_Implicit((Object)(object)val3.Container))
					{
						Item[] array2 = ((ItemContainer)val3.Container).GetContainedItems().ToArray();
						foreach (Item obj3 in array2)
						{
							add(obj3);
						}
					}
				}
			};
			Item[] array = character.Inventory.Pouch.GetContainedItems().ToArray();
			foreach (Item obj in array)
			{
				add(obj);
			}
			if ((Object)(object)character.Inventory.Equipment != (Object)null)
			{
				EquipmentSlot[] equipmentSlots = character.Inventory.Equipment.EquipmentSlots;
				foreach (EquipmentSlot val in equipmentSlots)
				{
					if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.EquippedItem))
					{
						add((Item)(object)val.EquippedItem);
					}
				}
			}
			return result.Values.ToList();
		}

		private static bool KeepEquippedItem(Character character, Item item)
		{
			if (!Object.op_Implicit((Object)(object)item))
			{
				return true;
			}
			if (item.IsEquipped || (Object)(object)item == (Object)(object)character.Inventory.EquippedBag)
			{
				return true;
			}
			CharacterEquipment equipment = character.Inventory.Equipment;
			if ((Object)(object)equipment != (Object)null)
			{
				return equipment.EquipmentSlots.Any((EquipmentSlot slot) => Object.op_Implicit((Object)(object)slot) && (Object)(object)slot.EquippedItem == (Object)(object)item);
			}
			return false;
		}

		private void PrepareDestruction()
		{
			if (Ready(out var character) && !((Object)(object)character != (Object)(object)owner))
			{
				pendingDelete = (from x in InventorySnapshot(character)
					where !KeepEquippedItem(character, x)
					select x.UID).ToList();
				pendingSilver = character.Inventory.Pouch.ContainedSilver;
				if (Object.op_Implicit((Object)(object)character.Inventory.EquippedBag))
				{
					pendingSilver += ((ItemContainer)character.Inventory.EquippedBag.Container).ContainedSilver;
				}
				deleteText = "";
				confirmDestroy = true;
			}
		}

		private void DestroyInventory()
		{
			if (deleteText != "DELETE" || !Ready(out var character) || (Object)(object)character != (Object)(object)owner)
			{
				return;
			}
			List<Item> source = (from x in InventorySnapshot(character)
				where pendingDelete.Contains(x.UID) && !KeepEquippedItem(character, x)
				select x).ToList();
			int num = 0;
			try
			{
				character.Inventory.Pouch.ContainedSilver = 0;
				if (Object.op_Implicit((Object)(object)character.Inventory.EquippedBag))
				{
					((ItemContainer)character.Inventory.EquippedBag.Container).ContainedSilver = 0;
				}
				foreach (Item item in source.OrderBy((Item x) => (x is Bag || x is ItemContainer) ? 1 : 0))
				{
					if (Object.op_Implicit((Object)(object)item) && !item.IsPendingDestroy && !KeepEquippedItem(character, item))
					{
						ItemManager.Instance.DestroyItem(item.UID);
						num++;
					}
				}
				menuStatus = "Removed " + num + " loose items and carried silver. Equipped gear kept.";
				((BaseUnityPlugin)this).Logger.LogInfo((object)menuStatus);
			}
			catch (Exception ex)
			{
				menuStatus = "Stopped after " + num + " entries: " + ex.Message;
				((BaseUnityPlugin)this).Logger.LogError((object)ex);
			}
			finally
			{
				confirmDestroy = false;
				deleteText = "";
				pendingDelete.Clear();
			}
		}

		private static bool FreeRecipe(Character character, Recipe recipe)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			if (IsPlayer(character) && Instance.freeCraft.Value && Object.op_Implicit((Object)(object)recipe))
			{
				return character.Inventory.RecipeKnowledge.IsRecipeLearned(UID.op_Implicit(recipe.UID));
			}
			return false;
		}

		private static bool CanRespawnEnemy(Character enemy, Character player)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Invalid comparison between Unknown and I4
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)enemy) && Object.op_Implicit((Object)(object)player) && !((Object)(object)enemy == (Object)(object)player))
			{
				Scene scene = ((Component)enemy).gameObject.scene;
				if (((Scene)(ref scene)).IsValid())
				{
					scene = ((Component)enemy).gameObject.scene;
					if (((Scene)(ref scene)).isLoaded && enemy.Initialized && enemy.IsAI && enemy.IsDead && !((Object)(object)enemy.OwnerPlayerSys != (Object)null) && string.IsNullOrEmpty(enemy.SummonerUID) && (int)enemy.Faction != 1 && (int)enemy.Faction != 7 && (int)enemy.Faction != 0 && !enemy.HasEventOnDeath && !Object.op_Implicit((Object)(object)((Component)enemy).GetComponent<QuestEventOnDeath>()) && Object.op_Implicit((Object)(object)enemy.Inventory))
					{
						CharacterAI component = ((Component)enemy).GetComponent<CharacterAI>();
						if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)enemy.TargetingSystem) || !enemy.TargetingSystem.IsTargetable(player.Faction))
						{
							return false;
						}
						if (AiQuestGate == null)
						{
							return false;
						}
						if (!string.IsNullOrEmpty(((QuestEventReference)AiQuestGate.GetValue(component)).EventUID))
						{
							return false;
						}
						AISquadMember component2 = ((Component)enemy).GetComponent<AISquadMember>();
						if (Object.op_Implicit((Object)(object)component2) && Object.op_Implicit((Object)(object)component2.AISquad) && (int)component2.AISquad.CategoryID != 0)
						{
							return false;
						}
						if (!Object.op_Implicit((Object)(object)((Component)enemy).transform.parent) || ((Component)((Component)enemy).transform.parent).gameObject.activeInHierarchy)
						{
							return true;
						}
						if (Object.op_Implicit((Object)(object)component2) && Object.op_Implicit((Object)(object)component2.AISquad))
						{
							return component2.AISquad.FromSquadReserve;
						}
						return false;
					}
				}
			}
			return false;
		}

		private void PrepareEnemyRespawn()
		{
			if (!respawnBusy && Ready(out var player) && !((Object)(object)player != (Object)(object)owner))
			{
				pendingRespawn = (from c in Resources.FindObjectsOfTypeAll<Character>()
					where CanRespawnEnemy(c, player)
					select c).Distinct().ToList();
				confirmRespawn = true;
				showSpawner = false;
			}
		}

		private void BeginEnemyRespawn()
		{
			if (!respawnBusy && !(Time.realtimeSinceStartup - lastEnemyRespawn < 5f) && Ready(out var character) && !((Object)(object)character != (Object)(object)owner))
			{
				Character[] targets = pendingRespawn.ToArray();
				confirmRespawn = false;
				pendingRespawn.Clear();
				respawnBusy = true;
				lastEnemyRespawn = Time.realtimeSinceStartup;
				((MonoBehaviour)this).StartCoroutine(RespawnEnemies(targets, character));
			}
		}

		private IEnumerator RespawnEnemies(Character[] targets, Character player)
		{
			int restored = 0;
			int reserve = 0;
			int skipped = 0;
			int failed = 0;
			AISquadManager manager = AISquadManager.Instance;
			string sceneName = SceneManagerHelper.ActiveSceneName;
			try
			{
				foreach (Character val in targets)
				{
					if (!Ready(out var character) || (Object)(object)character != (Object)(object)player || SceneManagerHelper.ActiveSceneName != sceneName)
					{
						break;
					}
					if (!CanRespawnEnemy(val, player))
					{
						skipped++;
						continue;
					}
					try
					{
						CharacterAI component = ((Component)val).GetComponent<CharacterAI>();
						AISquadMember component2 = ((Component)val).GetComponent<AISquadMember>();
						AISquad val2 = (Object.op_Implicit((Object)(object)component2) ? component2.AISquad : null);
						bool flag = Object.op_Implicit((Object)(object)val2) && val2.FromSquadReserve && Object.op_Implicit((Object)(object)manager) && manager.SquadsInReserve.Contains(val2);
						((Component)val).gameObject.SetActive(true);
						val.Resurrect((PlayerSaveData)null, false);
						if (val.IsDead)
						{
							throw new InvalidOperationException("Enemy did not accept local resurrection.");
						}
						StartingEquipment component3 = ((Component)val).GetComponent<StartingEquipment>();
						if (Object.op_Implicit((Object)(object)component3))
						{
							component3.ResetRevive();
						}
						else
						{
							val.Inventory.Pouch.ClearPouch();
						}
						val.ForceCancel(true, true);
						if (Object.op_Implicit((Object)(object)val2))
						{
							((Component)val).transform.SetParent(((Component)val2).transform, true);
							component2.PositionForSpawn();
						}
						else
						{
							component.ReturnToStartPos();
							val.Internal_SendTeleport(((Component)val).transform.position, ((Component)val).transform.rotation);
						}
						((Behaviour)component).enabled = true;
						if (Object.op_Implicit((Object)(object)val.CharAIDisable))
						{
							val.CharAIDisable.AiLastCloseCheck = -100f;
						}
						NavMeshAgent component4 = ((Component)val).GetComponent<NavMeshAgent>();
						if (Object.op_Implicit((Object)(object)component4) && ((Component)val).gameObject.activeInHierarchy)
						{
							((Behaviour)component4).enabled = true;
						}
						if (Object.op_Implicit((Object)(object)val2))
						{
							val2.RefreshActiveMembers();
						}
						restored++;
						if (flag)
						{
							reserve++;
						}
						((BaseUnityPlugin)this).Logger.LogInfo((object)("Enemy respawned: " + ((Object)val).name + " [" + UID.op_Implicit(val.UID) + "]" + (flag ? " (reserve)" : "")));
					}
					catch (Exception ex)
					{
						failed++;
						((BaseUnityPlugin)this).Logger.LogError((object)("Enemy respawn failed: " + ex));
					}
					menuStatus = "Respawning enemies: " + restored + "/" + targets.Length;
					yield return null;
				}
				if (Object.op_Implicit((Object)(object)manager) && (Object)(object)manager == (Object)(object)AISquadManager.Instance && manager.RandomSpawnEnabled && FindReserveSpawn != null && Ready(out var character2) && (Object)(object)character2 == (Object)(object)player && SceneManagerHelper.ActiveSceneName == sceneName)
				{
					for (int j = 0; j < Mathf.Clamp(manager.MaxSquadCount, 1, 32); j++)
					{
						int count = manager.SquadsInReserve.Count;
						try
						{
							FindReserveSpawn.Invoke(manager, new object[1] { false });
						}
						catch (Exception ex2)
						{
							((BaseUnityPlugin)this).Logger.LogWarning((object)("Reserve spawn check: " + ex2.GetBaseException().Message));
							break;
						}
						if (manager.SquadsInReserve.Count >= count)
						{
							break;
						}
					}
				}
				menuStatus = "Restored " + restored + " enemies (" + reserve + " reserve)." + ((failed > 0) ? (" Failed: " + failed + ".") : "") + ((skipped > 0) ? (" Skipped: " + skipped + ".") : "");
				((BaseUnityPlugin)this).Logger.LogInfo((object)(menuStatus + " Area: " + sceneName + ". No calendar or environment reset."));
			}
			finally
			{
				respawnBusy = false;
			}
		}

		private void DrawRespawnConfirmation()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			GUI.Label(new Rect(25f, 125f, 284f, 40f), "Respawn enemies?", heading);
			GUI.Label(new Rect(28f, 180f, 278f, 45f), pendingRespawn.Count + " defeated enemies eligible", rowLabel);
			GUI.Label(new Rect(28f, 245f, 278f, 190f), "Restores ordinary enemies in this loaded map and refills defeated reserve squads.\n\nLoot corpses first: their remaining contents will be replaced.\n\nNo days pass. Living enemies and quest-linked enemies are excluded.", menuSkin.label);
			GUI.Label(new Rect(28f, 444f, 278f, 60f), "Reserve squads still use the map's normal spawn locations and population limits.", smallLabel);
			bool enabled = GUI.enabled;
			GUI.enabled = pendingRespawn.Count > 0 && !respawnBusy && Time.realtimeSinceStartup - lastEnemyRespawn >= 5f;
			if (GUI.Button(new Rect(18f, 525f, 298f, 44f), "Respawn Now"))
			{
				BeginEnemyRespawn();
			}
			GUI.enabled = enabled;
			if (GUI.Button(new Rect(18f, 586f, 298f, 44f), "Cancel"))
			{
				confirmRespawn = false;
				pendingRespawn.Clear();
			}
		}

		private static bool MenuCaptures(Character character)
		{
			if (Object.op_Implicit((Object)(object)Instance) && Instance.CapturesInput)
			{
				return IsPlayer(character);
			}
			return false;
		}

		private Texture2D FramedTexture(Color fill, Color edge, bool ornament)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(96, 96, (TextureFormat)4, false);
			((Object)val).name = "AuraiMenuFrame";
			((Object)val).hideFlags = (HideFlags)61;
			Color[] array = (Color[])(object)new Color[9216];
			Color val2 = default(Color);
			for (int i = 0; i < 96; i++)
			{
				for (int j = 0; j < 96; j++)
				{
					int num = Mathf.Min(Mathf.Min(j, 95 - j), Mathf.Min(i, 95 - i));
					int num2 = j * 374761393 + i * 668265263;
					float num3 = ((float)(uint)(((num2 ^ (num2 >>> 13)) * 1274126177) & 0xFF) / 255f - 0.5f) * 0.006f;
					((Color)(ref val2))..ctor(fill.r + num3, fill.g + num3, fill.b + num3, fill.a);
					if (num == 0 || num == 4)
					{
						val2 = edge * new Color(0.6f, 0.6f, 0.6f, 1f);
					}
					if (num == 1)
					{
						val2 = edge;
					}
					if (num == 2)
					{
						((Color)(ref val2))..ctor(0.08f, 0.065f, 0.04f, 1f);
					}
					int num4 = Mathf.Min(j, 95 - j);
					int num5 = Mathf.Min(i, 95 - i);
					if (ornament && num4 < 18 && num5 < 18 && (Mathf.Abs(num4 - 10) + Mathf.Abs(num5 - 10) == 6 || (num4 == 7 && num5 < 8) || (num5 == 7 && num4 < 8)))
					{
						val2 = edge;
					}
					array[i * 96 + j] = val2;
				}
			}
			val.SetPixels(array);
			val.Apply();
			themeTextures.Add(val);
			return val;
		}

		private void EnsureTheme()
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Expected O, but got Unknown
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Expected O, but got Unknown
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Expected O, but got Unknown
			//IL_01dd: Expected O, but got Unknown
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: 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_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Expected O, but got Unknown
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Expected O, but got Unknown
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Expected O, but got Unknown
			//IL_0303: Expected O, but got Unknown
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_0360: Expected O, but got Unknown
			//IL_038b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bf: Expected O, but got Unknown
			//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0403: Expected O, but got Unknown
			//IL_0403: Unknown result type (might be due to invalid IL or missing references)
			//IL_040c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0416: Expected O, but got Unknown
			//IL_0416: Unknown result type (might be due to invalid IL or missing references)
			//IL_0423: Expected O, but got Unknown
			//IL_046a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0485: Unknown result type (might be due to invalid IL or missing references)
			//IL_048a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0492: Unknown result type (might be due to invalid IL or missing references)
			//IL_0499: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a3: Expected O, but got Unknown
			//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b2: Expected O, but got Unknown
			//IL_04b7: Expected O, but got Unknown
			//IL_0508: Unknown result type (might be due to invalid IL or missing references)
			//IL_050d: Unknown result type (might be due to invalid IL or missing references)
			//IL_050e: 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_052b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0530: Unknown result type (might be due to invalid IL or missing references)
			//IL_053b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0540: Unknown result type (might be due to invalid IL or missing references)
			//IL_054a: Expected O, but got Unknown
			//IL_054a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0551: Unknown result type (might be due to invalid IL or missing references)
			//IL_055b: Expected O, but got Unknown
			//IL_0560: Expected O, but got Unknown
			//IL_0587: Unknown result type (might be due to invalid IL or missing references)
			//IL_058c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0597: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b1: Expected O, but got Unknown
			//IL_05b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c0: Expected O, but got Unknown
			//IL_05c5: Expected O, but got Unknown
			//IL_0620: Unknown result type (might be due to invalid IL or missing references)
			//IL_0625: Unknown result type (might be due to invalid IL or missing references)
			//IL_062d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0634: Unknown result type (might be due to invalid IL or missing references)
			//IL_0640: Expected O, but got Unknown
			//IL_064c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0662: Unknown result type (might be due to invalid IL or missing references)
			//IL_0667: Unknown result type (might be due to invalid IL or missing references)
			//IL_066f: Unknown result type (might be due to invalid IL or missing references)
			//IL_067b: Expected O, but got Unknown
			//IL_0695: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b0: 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_06c4: Expected O, but got Unknown
			//IL_06cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06de: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fc: Expected O, but got Unknown
			//IL_06fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0708: Expected O, but got Unknown
			//IL_0714: Unknown result type (might be due to invalid IL or missing references)
			//IL_072a: Unknown result type (might be due to invalid IL or missing references)
			//IL_072f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0737: Unknown result type (might be due to invalid IL or missing references)
			//IL_0743: Expected O, but got Unknown
			//IL_075d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0773: Unknown result type (might be due to invalid IL or missing references)
			//IL_077d: Expected O, but got Unknown
			//IL_0797: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)menuSkin))
			{
				return;
			}
			menuSkin = Object.Instantiate<GUISkin>(GUI.skin);
			((Object)menuSkin).hideFlags = (HideFlags)61;
			menuFont = Font.CreateDynamicFontFromOSFont(new string[3] { "Georgia", "Times New Roman", "Arial" }, 18);
			ownsMenuFont = true;
			menuSkin.font = menuFont;
			panelTexture = FramedTexture(new Color(0.065f, 0.071f, 0.08f, 0.98f), gold, ornament: true);
			rowTexture = FramedTexture(new Color(0.095f, 0.088f, 0.069f, 1f), gold, ornament: true);
			Texture2D background = FramedTexture(new Color(0.24f, 0.17f, 0.07f, 1f), new Color(0.95f, 0.73f, 0.38f), ornament: true);
			Texture2D val = FramedTexture(new Color(0.21f, 0.15f, 0.065f, 1f), gold, ornament: false);
			Texture2D val2 = FramedTexture(new Color(0.035f, 0.038f, 0.044f, 1f), gold * new Color(0.6f, 0.6f, 0.6f, 1f), ornament: false);
			goldTexture = FramedTexture(gold, gold, ornament: false);
			menuSkin.button = new GUIStyle(menuSkin.button)
			{
				fontSize = 17,
				alignment = (TextAnchor)4,
				border = new RectOffset(22, 22, 22, 22),
				padding = new RectOffset(10, 10, 3, 3),
				margin = new RectOffset(2, 2, 3, 3)
			};
			menuSkin.button.normal.background = rowTexture;
			menuSkin.button.hover.background = background;
			menuSkin.button.active.background = background;
			menuSkin.button.focused.background = background;
			GUIStyleState normal = menuSkin.button.normal;
			GUIStyleState hover = menuSkin.button.hover;
			GUIStyleState active = menuSkin.button.active;
			Color val3 = (menuSkin.button.focused.textColor = ivory);
			Color val5 = (active.textColor = val3);
			Color textColor = (hover.textColor = val5);
			normal.textColor = textColor;
			listRow = new GUIStyle(menuSkin.button)
			{
				fontSize = 14,
				alignment = (TextAnchor)3,
				clipping = (TextClipping)1,
				wordWrap = false,
				border = new RectOffset(6, 6, 6, 6),
				padding = new RectOffset(10, 10, 4, 4),
				margin = new RectOffset(1, 1, 2, 2)
			};
			listRow.normal.background = val2;
			GUIStyleState hover2 = listRow.hover;
			GUIStyleState active2 = listRow.active;
			Texture2D val8 = (listRow.focused.background = val);
			Texture2D background2 = (active2.background = val8);
			hover2.background = background2;
			selectedListRow = new GUIStyle(listRow);
			selectedListRow.normal.background = val;
			selectedListRow.normal.textColor = new Color(1f, 0.86f, 0.6f);
			menuSkin.label = new GUIStyle(menuSkin.label)
			{
				fontSize = 15,
				wordWrap = true
			};
			menuSkin.label.normal.textColor = ivory;
			menuSkin.window = new GUIStyle(menuSkin.window)
			{
				border = new RectOffset(24, 24, 24, 24),
				padding = new RectOffset(18, 18, 36, 16),
				fontSize = 18
			};
			menuSkin.window.normal.background = panelTexture;
			menuSkin.window.onNormal.background = panelTexture;
			menuSkin.window.normal.textColor = ivory;
			menuSkin.textField = new GUIStyle(menuSkin.textField)
			{
				fontSize = 16,
				padding = new RectOffset(10, 10, 7, 7),
				border = new RectOffset(8, 8, 8, 8)
			};
			GUIStyleState normal2 = menuSkin.textField.normal;
			background2 = (menuSkin.textField.focused.background = val2);
			normal2.background = background2;
			GUIStyleState normal3 = menuSkin.textField.normal;
			textColor = (menuSkin.textField.focused.textColor = ivory);
			normal3.textColor = textColor;
			menuSkin.horizontalSlider = new GUIStyle(menuSkin.horizontalSlider)
			{
				fixedHeight = 8f,
				border = new RectOffset(5, 5, 3, 3),
				margin = new RectOffset(0, 0, 10, 10)
			};
			menuSkin.horizontalSlider.normal.background = val2;
			menuSkin.horizontalSliderThumb = new GUIStyle(menuSkin.horizontalSliderThumb)
			{
				fixedWidth = 12f,
				fixedHeight = 18f,
				border = new RectOffset(4, 4, 4, 4),
				overflow = new RectOffset(0, 0, 5, 5)
			};
			GUIStyleState normal4 = menuSkin.horizontalSliderThumb.normal;
			GUIStyleState hover3 = menuSkin.horizontalSliderThumb.hover;
			val8 = (menuSkin.horizontalSliderThumb.active.background = goldTexture);
			background2 = (hover3.background = val8);
			normal4.background = background2;
			heading = new GUIStyle(menuSkin.label)
			{
				fontSize = 24,
				alignment = (TextAnchor)4,
				fontStyle = (FontStyle)1
			};
			heading.normal.textColor = gold;
			caption = new GUIStyle(menuSkin.label)
			{
				fontSize = 12,
				alignment = (TextAnchor)4
			};
			caption.normal.textColor = new Color(0.64f, 0.62f, 0.56f);
			rowLabel = new GUIStyle(menuSkin.label)
			{
				fontSize = 18,
				alignment = (TextAnchor)3
			};
			valueLabel = new GUIStyle(rowLabel)
			{
				alignment = (TextAnchor)5,
				fontStyle = (FontStyle)1,
				fontSize = 16,
				wordWrap = false,
				padding = new RectOffset(0, 0, 0, 0),
				clipping = (TextClipping)0
			};
			valueLabel.normal.textColor = gold;
			smallLabel = new GUIStyle(menuSkin.label)
			{
				fontSize = 13,
				alignment = (TextAnchor)0
			};
			smallLabel.normal.textColor = new Color(0.69f, 0.67f, 0.61f);
			dangerButton = new GUIStyle(menuSkin.button);
			dangerButton.normal.textColor = new Color(0.91f, 0.57f, 0.46f);
			try
			{
				UseNativeArtwork();
			}
			catch (Exception ex)
			{
				menuStatus = "Native artwork unavailable; see log.";
				((BaseUnityPlugin)this).Logger.LogError((object)ex);
			}
		}

		private void Frame(Rect rect, Texture2D texture)
		{
			//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)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			GUIStyle val = new GUIStyle
			{
				border = (RectOffset)(((Object)(object)texture == (Object)(object)panelTexture) ? ((object)nativePanelBorder) : ((object)new RectOffset(22, 22, 22, 22)))
			};
			val.normal.background = texture;
			GUI.Box(rect, GUIContent.none, val);
		}

		private bool ToggleRow(float y, string title, string subtitle, bool value)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			if (!GUI.Button(new Rect(23f, y, 264f, 38f), title + "  [" + (value ? "ON" : "OFF") + "]"))
			{
				return value;
			}
			return !value;
		}

		private void DrawCheatMenu()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0452: Unknown result type (might be due to invalid IL or missing references)
			//IL_047c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: Unknown result type (might be due to invalid IL or missing references)
			//IL_039f: Unknown result type (might be due to invalid IL or missing references)
			float num = 668f;
			GUI.BeginGroup(new Rect(24f, 24f, 334f, num));
			DrawCompactPanel(new Rect(0f, 0f, 334f, num));
			GUI.Label(new Rect(15f, 30f, 304f, 30f), "AURAI", heading);
			GUI.Label(new Rect(15f, 62f, 304f, 20f), "Cheat Menu", caption);
			if (confirmDestroy)
			{
				DrawDestroyConfirmation();
			}
			else if (confirmRespawn)
			{
				DrawRespawnConfirmation();
			}
			else
			{
				cheatScroll.x = 0f;
				cheatScroll = GUI.BeginScrollView(new Rect(12f, 98f, 310f, 466f), cheatScroll, new Rect(0f, 0f, 288f, 710f), false, true, GUIStyle.none, menuSkin.verticalScrollbar);
				GUI.Label(new Rect(33f, 3f, 192f, 24f), "Damage multiplier", rowLabel);
				GUI.Label(new Rect(225f, 3f, 62f, 24f), damageMultiplier.Value.ToString("0.0") + "×", valueLabel);
				float num2 = GUI.HorizontalSlider(new Rect(39f, 34f, 240f, 12f), damageMultiplier.Value, 1f, 99f);
				damageMultiplier.Value = Mathf.Round(num2 * 2f) / 2f;
				GUI.Label(new Rect(33f, 54f, 245f, 18f), "1× normal / 99× max", smallLabel);
				DrawSleepSection();
				weightless.Value = ToggleRow(180f, "Weightless", "Carried weight becomes 0", weightless.Value);
				bool value = freeCraft.Value;
				freeCraft.Value = ToggleRow(224f, "Free crafting", "Known recipes · no ingredients", freeCraft.Value);
				if (value != freeCraft.Value)
				{
					menuStatus = "Reopen crafting to refresh recipes.";
				}
				VitalToggle(268f, "Max Health", lockHealth, "Health Restored");
				VitalToggle(312f, "Max Mana", lockMana, "Mana Restored");
				VitalToggle(356f, "Max Stamina", lockStamina, "Stamina Restored");
				CommandButton(400f, "Heal All Statuses", HealStatuses);
				CommandButton(444f, "Learn All Recipes", LearnAllRecipes);
				CommandButton(488f, "Add 10,000 Silver", AddSilver);
				if (GUI.Button(new Rect(23f, 532f, 264f, 38f), "Equipments Spawner/Enchanter"))
				{
					OpenSpawner(equipment: true);
				}
				if (GUI.Button(new Rect(23f, 576f, 264f, 38f), "Item Spawner"))
				{
					OpenSpawner(equipment: false);
				}
				GUI.enabled = !respawnBusy;
				if (GUI.Button(new Rect(23f, 620f, 264f, 38f), respawnBusy ? "Respawning..." : "Respawn Enemies"))
				{
					try
					{
						PrepareEnemyRespawn();
					}
					catch (Exception ex)
					{
						menuStatus = ex.Message;
						((BaseUnityPlugin)this).Logger.LogError((object)ex);
					}
				}
				GUI.enabled = true;
				if (GUI.Button(new Rect(23f, 664f, 264f, 38f), "Destroy All Inventory Items", dangerButton))
				{
					try
					{
						PrepareDestruction();
					}
					catch (Exception ex2)
					{
						menuStatus = ex2.Message;
						((BaseUnityPlugin)this).Logger.LogError((object)ex2);
					}
				}
				GUI.EndScrollView();
				GUI.Label(new Rect(32f, 574f, 270f, 36f), menuStatus, smallLabel);
				if (GUI.Button(new Rect(111f, 615f, 112f, 30f), "Close"))
				{
					Close();
				}
			}
			GUI.EndGroup();
		}

		private void DrawDestroyConfirmation()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			GUI.Label(new Rect(25f, 140f, 284f, 32f), "Clear your inventory?", heading);
			GUI.Label(new Rect(28f, 189f, 278f, 70f), pendingDelete.Count + " item entries / stacks\n" + pendingSilver + " silver", rowLabel);
			GUI.Label(new Rect(28f, 273f, 278f, 130f), "Deletes unequipped pocket/backpack items, including quest items, and carried silver.\n\nEquipped weapons, armor and backpack are kept. Stashes and ground items are excluded. No undo.", menuSkin.label);
			GUI.Label(new Rect(28f, 424f, 278f, 26f), "Type DELETE to confirm", smallLabel);
			deleteText = GUI.TextField(new Rect(28f, 454f, 278f, 38f), deleteText);
			bool enabled = GUI.enabled;
			GUI.enabled = deleteText == "DELETE";
			if (GUI.Button(new Rect(18f, 516f, 298f, 48f), "Permanently Destroy", dangerButton))
			{
				DestroyInventory();
			}
			GUI.enabled = enabled;
			if (GUI.Button(new Rect(18f, 585f, 298f, 44f), "Cancel"))
			{
				confirmDestroy = false;
				deleteText = "";
			}
		}

		private Texture2D SpriteTexture(Sprite sprite)
		{
			//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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Invalid comparison between Unknown and I4
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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)
			//IL_00d2: Expected O, but got Unknown
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)sprite))
			{
				throw new InvalidOperationException("Native menu sprite is missing.");
			}
			Rect textureRect = sprite.textureRect;
			RenderTexture temporary = RenderTexture.GetTemporary((int)((Rect)(ref textureRect)).width, (int)((Rect)(ref textureRect)).height, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)2);
			RenderTexture active = RenderTexture.active;
			bool sRGBWrite = GL.sRGBWrite;
			try
			{
				GL.sRGBWrite = (int)QualitySettings.activeColorSpace == 1;
				Graphics.Blit((Texture)(object)sprite.texture, temporary, new Vector2(((Rect)(ref textureRect)).width / (float)((Texture)sprite.texture).width, ((Rect)(ref textureRect)).height / (float)((Texture)sprite.texture).height), new Vector2(((Rect)(ref textureRect)).x / (float)((Texture)sprite.texture).width, ((Rect)(ref textureRect)).y / (float)((Texture)sprite.texture).height));
				RenderTexture.active = temporary;
				Texture2D val = new Texture2D((int)((Rect)(ref textureRect)).width, (int)((Rect)(ref textureRect)).height, (TextureFormat)4, false, false);
				val.ReadPixels(new Rect(0f, 0f, ((Rect)(ref textureRect)).width, ((Rect)(ref textureRect)).height), 0, 0);
				val.Apply();
				((Texture)val).wrapMode = (TextureWrapMode)1;
				themeTextures.Add(val);
				return val;
			}
			finally
			{
				GL.sRGBWrite = sRGBWrite;
				RenderTexture.active = active;
				RenderTexture.ReleaseTemporary(temporary);
			}
		}

		private void UseNativeArtwork()
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: 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_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Expected O, but got Unknown
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Expected O, but got Unknown
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Expected O, but got Unknown
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Expected O, but got Unknown
			PauseMenu pauseMenu = owner.CharacterUI.PauseMenu;
			Transform val = ((Component)pauseMenu).transform.Find("Buttons");
			Image component = ((Component)val.Find("BG")).GetComponent<Image>();
			Button val2 = (Button)AccessTools.Field(typeof(PauseMenu), "m_btnTogglePause").GetValue(pauseMenu);
			Graphic targetGraphic = ((Selectable)val2).targetGraphic;
			Image val3 = (Image)(object)((targetGraphic is Image) ? targetGraphic : null);
			panelTexture = SpriteTexture(component.sprite);
			Vector4 border = component.sprite.border;
			nativePanelBorder = new RectOffset((int)border.x, (int)border.z, (int)border.w, (int)border.y);
			rowTexture = SpriteTexture(val3.sprite);
			SpriteState spriteState = ((Selectable)val2).spriteState;
			Texture2D obj;
			if (!Object.op_Implicit((Object)(object)((SpriteState)(ref spriteState)).highlightedSprite))
			{
				obj = rowTexture;
			}
			else
			{
				spriteState = ((Selectable)val2).spriteState;
				obj = SpriteTexture(((SpriteState)(ref spriteState)).highlightedSprite);
			}
			Texture2D val4 = obj;
			nativeCrown = SpriteTexture(((Component)val.Find("Crown")).GetComponent<Image>().sprite);
			nativeDeco = SpriteTexture(((Component)val.Find("Deco")).GetComponent<Image>().sprite);
			Font font = ((Component)val2).GetComponentInChildren<Text>(true).font;
			if (Object.op_Implicit((Object)(object)font))
			{
				if (ownsMenuFont)
				{
					Object.Destroy((Object)(object)menuFont);
				}
				menuFont = font;
				ownsMenuFont = false;
				menuSkin.font = font;
			}
			Vector4 border2 = val3.sprite.border;
			RectOffset border3 = new RectOffset((int)border2.x, (int)border2.z, (int)border2.w, (int)border2.y);
			GUIStyle[] array = (GUIStyle[])(object)new GUIStyle[4] { menuSkin.button, dangerButton, listRow, selectedListRow };
			Texture2D background;
			foreach (GUIStyle val5 in array)
			{
				val5.border = border3;
				val5.normal.background = rowTexture;
				GUIStyleState hover = val5.hover;
				GUIStyleState active = val5.active;
				Texture2D val6 = (val5.focused.background = val4);
				background = (active.background = val6);
				hover.background = background;
			}
			menuSkin.button.fontSize = 15;
			menuSkin.button.wordWrap = true;
			menuSkin.button.padding = new RectOffset(28, 28, 4, 4);
			dangerButton.fontSize = 15;
			dangerButton.wordWrap = true;
			dangerButton.padding = new RectOffset(28, 28, 4, 4);
			selectedListRow.normal.background = val4;
			UseNativeControls();
			menuSkin.window.border = nativePanelBorder;
			if (menuSkin.window.border.top < 48)
			{
				menuSkin.window.border = new RectOffset(80, 80, 100, 40);
			}
			menuSkin.window.fontSize = 17;
			GUIStyleState normal = menuSkin.window.normal;
			background = (menuSkin.window.onNormal.background = panelTexture);
			normal.background = background;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Aurai uses native PauseMenu BG, Crown, Deco, button sprites and font.");
		}

		private void ApplySpriteStyle(GUIStyle style, Sprite sprite)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			Texture2D background = SpriteTexture(sprite);
			Vector4 border = sprite.border;
			style.border = new RectOffset((int)border.x, (int)border.z, (int)border.w, (int)border.y);
			GUIStyleState[] array = (GUIStyleState[])(object)new GUIStyleState[8] { style.normal, style.hover, style.active, style.focused, style.onNormal, style.onHover, style.onActive, style.onFocused };
			for (int i = 0; i < array.Length; i++)
			{
				array[i].background = background;
			}
		}

		private void UseNativeControls()
		{
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Expected O, but got Unknown
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Expected O, but got Unknown
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Expected O, but got Unknown
			Scrollbar val = ((IEnumerable<Scrollbar>)((Component)owner.CharacterUI).GetComponentsInChildren<Scrollbar>(true)).FirstOrDefault((Func<Scrollbar, bool>)((Scrollbar x) => ((int)x.direction == 2 || (int)x.direction == 3) && Object.op_Implicit((Object)(object)((Component)x).GetComponent<Image>()) && Object.op_Implicit((Object)(object)((Component)x).GetComponent<Image>().sprite) && Object.op_Implicit((Object)(object)x.handleRect) && Object.op_Implicit((Object)(object)((Component)x.handleRect).GetComponent<Image>()) && Object.op_Implicit((Object)(object)((Component)x.handleRect).GetComponent<Image>().sprite)));
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = ((IEnumerable<Scrollbar>)Resources.FindObjectsOfTypeAll<Scrollbar>()).FirstOrDefault((Func<Scrollbar, bool>)((Scrollbar x) => ((int)x.direction == 2 || (int)x.direction == 3) && Object.op_Implicit((Object)(object)((Component)x).GetComponent<Image>()) && Object.op_Implicit((Object)(object)((Component)x).GetComponent<Image>().sprite) && Object.op_Implicit((Object)(object)x.handleRect) && Object.op_Implicit((Object)(object)((Component)x.handleRect).GetComponent<Image>()) && Object.op_Implicit((Object)(object)((Component)x.handleRect).GetComponent<Image>().sprite)));
			}
			if (Object.op_Implicit((Object)(object)val))
			{
				ApplySpriteStyle(menuSkin.verticalScrollbar, ((Component)val).GetComponent<Image>().sprite);
				ApplySpriteStyle(menuSkin.verticalScrollbarThumb, ((Component)val.handleRect).GetComponent<Image>().sprite);
				menuSkin.verticalScrollbar.fixedWidth = 18f;
				menuSkin.verticalScrollbarThumb.fixedWidth = 14f;
				menuSkin.verticalScrollbarThumb.fixedHeight = 0f;
				menuSkin.verticalScrollbarThumb.margin = new RectOffset(2, 2, 2, 2);
				menuSkin.verticalScrollbarUpButton = new GUIStyle
				{
					fixedHeight = 0f
				};
				menuSkin.verticalScrollbarDownButton = new GUIStyle
				{
					fixedHeight = 0f
				};
				((BaseUnityPlugin)this).Logger.LogInfo((object)("Native scrollbar loaded: " + ((Object)val).name));
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"Native vertical scrollbar not found.");
			}
			InputField val2 = ((IEnumerable<InputField>)((Component)owner.CharacterUI).GetComponentsInChildren<InputField>(true)).FirstOrDefault((Func<InputField, bool>)((InputField x) => Object.op_Implicit((Object)(object)((Component)x).GetComponent<Image>()) && Object.op_Implicit((Object)(object)((Component)x).GetComponent<Image>().sprite)));
			if (!Object.op_Implicit((Object)(object)val2))
			{
				val2 = ((IEnumerable<InputField>)Resources.FindObjectsOfTypeAll<InputField>()).FirstOrDefault((Func<InputField, bool>)((InputField x) => Object.op_Implicit((Object)(object)((Component)x).GetComponent<Image>()) && Object.op_Implicit((Object)(object)((Component)x).GetComponent<Image>().sprite)));
			}
			if (Object.op_Implicit((Object)(object)val2))
			{
				ApplySpriteStyle(menuSkin.textField, ((Component)val2).GetComponent<Image>().sprite);
			}
			Slider val3 = ((IEnumerable<Slider>)((Component)owner.CharacterUI).GetComponentsInChildren<Slider>(true)).FirstOrDefault((Func<Slider, bool>)((Slider x) => (int)x.direction == 0 && Object.op_Implicit((Object)(object)x.handleRect) && Object.op_Implicit((Object)(object)((Component)x.handleRect).GetComponent<Image>()) && Object.op_Implicit((Object)(object)((Component)x.handleRect).GetComponent<Image>().sprite)));
			if (!Object.op_Implicit((Object)(object)val3))
			{
				val3 = ((IEnumerable<Slider>)Resources.FindObjectsOfTypeAll<Slider>()).FirstOrDefault((Func<Slider, bool>)((Slider x) => (int)x.direction == 0 && Object.op_Implicit((Object)(object)x.handleRect) && Object.op_Implicit((Object)(object)((Component)x.handleRect).GetComponent<Image>()) && Object.op_Implicit((Object)(object)((Component)x.handleRect).GetComponent<Image>().sprite)));
			}
			if (Object.op_Implicit((Object)(object)val3))
			{
				Transform val4 = ((Component)val3).transform.Find("Background");
				Image val5 = (Object.op_Implicit((Object)(object)val4) ? ((Component)val4).GetComponent<Image>() : ((Component)val3).GetComponent<Image>());
				if (Object.op_Implicit((Object)(object)val5) && Object.op_Implicit((Object)(object)val5.sprite))
				{
					ApplySpriteStyle(menuSkin.horizontalSlider, val5.sprite);
				}
				ApplySpriteStyle(menuSkin.horizontalSliderThumb, ((Component)val3.handleRect).GetComponent<Image>().sprite);
				menuSkin.horizontalSliderThumb.fixedWidth = 18f;
				menuSkin.horizontalSliderThumb.fixedHeight = 22f;
			}
		}

		private void DrawCompactPanel(Rect rect)
		{
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)panelTexture))
			{
				return;
			}
			float num = ((Texture)panelTexture).width;
			float num2 = ((Texture)panelTexture).height;
			float num3 = Mathf.Max((float)nativePanelBorder.left, num * 0.28f);
			float num4 = Mathf.Max((float)nativePanelBorder.right, num * 0.28f);
			float num5 = Mathf.Max((float)nativePanelBorder.top, num2 * 0.3f);
			float num6 = Mathf.Max((float)nativePanelBorder.bottom, num2 * 0.06f);
			num3 = Mathf.Min(num3, num * 0.45f);
			num4 = Mathf.Min(num4, num * 0.45f);
			num5 = Mathf.Min(num5, num2 * 0.45f);
			num6 = Mathf.Min(num6, num2 * 0.2f);
			float num7 = Mathf.Min(((Rect)(ref rect)).width / num, 60f / Mathf.Max(num5, Mathf.Max(num3, num4)));
			float[] array = new float[4]
			{
				0f,
				num3 / num,
				1f - num4 / num,
				1f
			};
			float[] array2 = new float[4]
			{
				0f,
				num6 / num2,
				1f - num5 / num2,
				1f
			};
			float[] array3 = new float[4]
			{
				((Rect)(ref rect)).x,
				((Rect)(ref rect)).x + num3 * num7,
				((Rect)(ref rect)).xMax - num4 * num7,
				((Rect)(ref rect)).xMax
			};
			float[] array4 = new float[4]
			{
				((Rect)(ref rect)).y,
				((Rect)(ref rect)).y + num5 * num7,
				((Rect)(ref rect)).yMax - num6 * num7,
				((Rect)(ref rect)).yMax
			};
			for (int i = 0; i < 3; i++)
			{
				for (int j = 0; j < 3; j++)
				{
					int num8 = 2 - i;
					DrawTiledPanelSlice(new Rect(array3[j], array4[i], array3[j + 1] - array3[j], array4[i + 1] - array4[i]), new Rect(array[j], array2[num8], array[j + 1] - array[j], array2[num8 + 1] - array2[num8]), num7);
				}
			}
		}

		private void DrawTiledPanelSlice(Rect target, Rect uv, float scale)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			if (!panelSlices.TryGetValue(uv, out var value))
			{
				int num = Mathf.Clamp(Mathf.RoundToInt(((Rect)(ref uv)).x * (float)((Texture)panelTexture).width), 0, ((Texture)panelTexture).width - 1);
				int num2 = Mathf.Clamp(Mathf.RoundToInt(((Rect)(ref uv)).y * (float)((Texture)panelTexture).height), 0, ((Texture)panelTexture).height - 1);
				int num3 = Mathf.Clamp(Mathf.RoundToInt(((Rect)(ref uv)).width * (float)((Texture)panelTexture).width), 1, ((Texture)panelTexture).width - num);
				int num4 = Mathf.Clamp(Mathf.RoundToInt(((Rect)(ref uv)).height * (float)((Texture)panelTexture).height), 1, ((Texture)panelTexture).height - num2);
				value = new Texture2D(num3, num4, (TextureFormat)4, false, false);
				value.SetPixels(panelTexture.GetPixels(num, num2, num3, num4));
				value.Apply();
				((Texture)value).wrapMode = (TextureWrapMode)2;
				((Texture)value).filterMode = (FilterMode)1;
				panelSlices.Add(uv, value);
				themeTextures.Add(value);
			}
			float num5 = ((Rect)(ref target)).width / Mathf.Max(1f, (float)((Texture)value).width * scale);
			float num6 = ((Rect)(ref target)).height / Mathf.Max(1f, (float)((Texture)value).height * scale);
			GUI.DrawTextureWithTexCoords(target, (Texture)(object)value, new Rect(0f, 1f - num6, num5, num6), true);
		}

		private void DrawNativeDecorations()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)nativeCrown))
			{
				GUI.DrawTexture(new Rect(-8f, 0f, 350f, 55f), (Texture)(object)nativeCrown, (ScaleMode)2);
			}
			if (Object.op_Implicit((Object)(object)nativeDeco))
			{
				GUI.DrawTexture(new Rect(95f, 39f, 144f, 32f), (Texture)(object)nativeDeco, (ScaleMode)2);
			}
		}

		private void CommandButton(float y, string title, Action<Character> action)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			if (!GUI.Button(new Rect(23f, y, 264f, 38f), title) || !Ready(out var character) || (Object)(object)character != (Object)(object)owner || character.IsDead)
			{
				return;
			}
			try
			{
				action(character);
				((BaseUnityPlugin)this).Logger.LogInfo((object)menuStatus);
				character.CharacterUI.ShowInfoNotification(menuStatus);
			}
			catch (Exception ex)
			{
				menuStatus = "Command failed: " + ex.GetBaseException().Message;
				((BaseUnityPlugin)this).Logger.LogError((object)ex);
			}
		}

		private void HealStatuses(Character c)
		{
			CharacterStats stats = c.Stats;
			PlayerCharacterStats val = (PlayerCharacterStats)(object)((stats is PlayerCharacterStats) ? stats : null);
			if (!Object.op_Implicit((Object)(object)val))
			{
				throw new InvalidOperationException("Player survival stats unavailable.");
			}
			val.Food = val.MaxFood;
			val.Drink = val.MaxDrink;
			val.Sleep = val.MaxSleep;
			val.Temperature = 50f;
			val.AffectCorruptionLevel(0f - val.Corruption, false);
			AccessTools.Method(typeof(PlayerCharacterStats), "UpdateTresholds", (Type[])null, (Type[])null).Invoke(val, null);
			StatusEffect[] array = c.StatusEffectMngr.Statuses.ToArray();
			foreach (StatusEffect val2 in array)
			{
				if (Object.op_Implicit((Object)(object)val2) && val2.IsMalusEffect)
				{
					c.StatusEffectMngr.CleanseStatusEffect(val2);
				}
			}
			((CharacterStats)val).RestoreAllVitals();
			menuStatus = "Statuses Healed";
		}

		private void AddSilver(Character c)
		{
			c.Inventory.ReceiveMoneyReward(10000);
			menuStatus = "Added 10k Silver to Inventory";
		}

		private void LearnAllRecipes(Character c)
		{
			//IL_0061: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<string, Recipe> dictionary = (Dictionary<string, Recipe>)AccessTools.Field(typeof(RecipeManager), "m_recipes").GetValue(RecipeManager.Instance);
			int num = 0;
			learningRecipes = true;
			try
			{
				Recipe[] array = dictionary.Values.ToArray();
				foreach (Recipe val in array)
				{
					if (Object.op_Implicit((Object)(object)val) && val.IsFullySetup && !c.Inventory.RecipeKnowledge.IsRecipeLearned(UID.op_Implicit(val.UID)) && ((int)val.RequiredPType == 0 || (Object.op_Implicit((Object)(object)c.OwnerPlayerSys) && val.RequiredPType == c.OwnerPlayerSys.PlayerType)))
					{
						c.Inventory.RecipeKnowledge.LearnRecipe(val);
						num++;
					}
				}
			}
			finally
			{
				learningRecipes = false;
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Learned " + num + " new crafting recipes."));
			menuStatus = "All Recipes Learned";
		}

		private void Awake()
		{
			//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)
			hotkey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Menu", "ToggleKey", (KeyCode)289, "Open/close the spawner in solo play.");
			InitializeCheats();
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Enchanted Item Spawner ready. Load a solo character and press " + ((object)hotkey.Value/*cast due to .constrained prefix*/).ToString()));
		}

		private bool Ready(out Character character)
		{
			character = (Object.op_Implicit((Object)(object)CharacterManager.Instance) ? CharacterManager.Instance.GetFirstLocalCharacter() : null);
			if (Object.op_Implicit((Object)(object)character) && character.IsLocalPlayer && (Object)(object)character.Inventory != (Object)null && Object.op_Implicit((Object)(object)NetworkLevelLoader.Instance) && !NetworkLevelLoader.Instance.InLoading && (!PhotonNetwork.inRoom || PhotonNetwork.playerList.Length <= 1))
			{
				return !Object.op_Implicit((Object)(object)CharacterManager.Instance.GetSecondLocalCharacter());
			}
			return false;
		}

		private void Update()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			if (open && (!Ready(out var character) || (Object)(object)character != (Object)(object)owner))
			{
				Close();
			}
			if (Input.GetKeyDown(hotkey.Value))
			{
				if (open)
				{
					Close();
				}
				else if (Ready(out character))
				{
					Open(character);
				}
				else
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)"Spawner requires a loaded solo character (no co-op or loading screen).");
				}
			}
			if (open && Input.GetKeyDown((KeyCode)27))
			{
				Close();
			}
		}

		private void Open(Character character)
		{
			try
			{
				owner = character;
				showSpawner = false;
				confirmDestroy = false;
				menuStatus = "World stays live. Close the menu to move.";
				ForceUnlockCursor.AddUnlockSource();
				cursorHeld = true;
				open = true;
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)ex);
				Close();
			}
		}

		private void Close()
		{
			if (open)
			{
				inputReleaseFrame = Time.frameCount + 2;
			}
			open = false;
			confirmDestroy = false;
			confirmRespawn = false;
			pendingRespawn.Clear();
			deleteText = "";
			((BaseUnityPlugin)this).Config.Save();
			if (cursorHeld)
			{
				ForceUnlockCursor.RemoveUnlockSource();
				cursorHeld = false;
			}
			owner = null;
		}

		private void OnDisable()
		{
			Close();
		}

		private void OnDestroy()
		{
			Close();
			ShutdownCheats();
		}

		private void Reload()
		{
			items = (from x in ResourcesPrefabManager.Instance.EDITOR_GetSpawnableItemPrefabs(owner)
				where Object.op_Implicit((Object)(object)x) && !(x is Skill) && !(x is Quest) && x is Equipment == equipmentMode
				group x by x.ItemID into x
				select x.First()).OrderBy<Item, string>((Item x) => ItemLabel(x), StringComparer.OrdinalIgnoreCase).ToList();
			selected = null;
			enchant = null;
			choices.Clear();
			FilterItems();
			status = items.Count + " items available. Select one to spawn.";
		}

		private static bool Match(string value, string query)
		{
			return (value ?? "").IndexOf(query ?? "", StringComparison.OrdinalIgnoreCase) >= 0;
		}

		private static string ItemLabel(Item item)
		{
			string name = item.Name;
			if (string.IsNullOrWhiteSpace(name) || name.Trim() == "-")
			{
				name = ((Object)item).name;
			}
			return CleanItemLabel(name, item.ItemID);
		}

		internal static string CleanItemLabel(string label, int id)
		{
			label = (label ?? "").Replace("(Clone)", "").Trim();
			string text = Regex.Escape(id.ToString());
			label = Regex.Replace(label, "^" + text + "[\\s_\\-]*", "");
			label = Regex.Replace(label, "\\[" + text + "\\]", "");
			label = label.Replace('_', ' ');
			label = Regex.Replace(label, "([a-z])([A-Z])", "$1 $2");
			label = Regex.Replace(label, "\\s+", " ").Trim();
			if (!string.IsNullOrEmpty(label))
			{
				return label;
			}
			return "Unnamed item";
		}

		private void FilterItems()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			visibleItems = items.Where((Item x) => Match(ItemLabel(x), itemQuery) || Match(x.ItemID.ToString(), itemQuery)).ToList();
			itemScroll = Vector2.zero;
		}

		private void Select(Item item)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			selected = item;
			enchant = null;
			choices.Clear();
			enchantScroll = Vector2.zero;
			if (!(item is Equipment))
			{
				status = "Ready to spawn.";
				return;
			}
			foreach (EnchantmentRecipe enchantmentRecipe in RecipeManager.Instance.GetEnchantmentRecipes())
			{
				try
				{
					if (Object.op_Implicit((Object)(object)enchantmentRecipe) && ((EquipmentData)(ref enchantmentRecipe.CompatibleEquipments)).Match((Item)(Equipment)item))
					{
						Enchantment prefab = ResourcesPrefabManager.Instance.GetEnchantmentPrefab(enchantmentRecipe.RecipeID);
						if (Object.op_Implicit((Object)(object)prefab) && !choices.Any((EnchantChoice x) => x.Id == ((EffectPreset)prefab).PresetID))
						{
							choices.Add(new EnchantChoice
							{
								Recipe = enchantmentRecipe,
								Id = ((EffectPreset)prefab).PresetID,
								Label = (string.IsNullOrEmpty(prefab.Name) ? ((Object)enchantmentRecipe).name : prefab.Name)
							});
						}
					}
				}
				catch (Exception ex)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)("Skipping invalid enchantment recipe: " + ex.Message));
				}
			}
			choices = choices.OrderBy<EnchantChoice, string>((EnchantChoice x) => x.Label, StringComparer.OrdinalIgnoreCase).ToList();
			status = ((choices.Count == 0) ? "No compatible enchantments. You can spawn the base item." : "Select a compatible enchantment, or spawn without one.");
		}

		private void OnGUI()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Expected O, but got Unknown
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			if (open)
			{
				EnsureTheme();
				float num = Mathf.Min(1f, Mathf.Min((float)Screen.width / ((!showSpawner) ? 382f : (equipmentMode ? 768f : 468f)), (float)Screen.height / 720f));
				Matrix4x4 matrix = GUI.matrix;
				GUISkin skin = GUI.skin;
				Color color = GUI.color;
				Color backgroundColor = GUI.backgroundColor;
				Color contentColor = GUI.contentColor;
				GUI.color = (GUI.backgroundColor = (GUI.contentColor = Color.white));
				GUI.matrix = Matrix4x4.Scale(new Vector3(num, num, 1f));
				GUI.skin = menuSkin;
				GUI.depth = -1000;
				if (!showSpawner)
				{
					DrawCheatMenu();
				}
				if (showSpawner)
				{
					window = new Rect(24f, 24f, (float)(equipmentMode ? 720 : 420), 560f);
					window = GUI.Window(708193, window, new WindowFunction(DrawWindow), "");
				}
				GUI.color = color;
				GUI.backgroundColor = backgroundColor;
				GUI.contentColor = contentColor;
				GUI.skin = skin;
				GUI.matrix = matrix;
			}
		}

		private void Spawn()
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			if (!Ready(out var character) || (Object)(object)character != (Object)(object)owner || !Object.op_Implicit((Object)(object)selected))
			{
				status = "Load a solo character first.";
				return;
			}
			lastSpawn = Time.realtimeSinceStartup;
			Equipment val = null;
			try
			{
				if (enchant != null && !((EquipmentData)(ref enchant.Recipe.CompatibleEquipments)).Match((Item)(Equipment)selected))
				{
					throw new InvalidOperationException("Enchantment no longer matches the item. Refresh the menu.");
				}
				if (!(selected is Equipment))
				{
					character.Inventory.ReceiveItemReward(selected.ItemID, 1, false);
					status = "Added " + ItemLabel(selected) + " to Inventory";
					return;
				}
				Item val2 = ItemManager.Instance.GenerateItemNetwork(selected.ItemID);
				if (!Object.op_Implicit((Object)(object)val2))
				{
					throw new InvalidOperationException("Game could not generate this item.");
				}
				val = (Equipment)(object)((val2 is Equipment) ? val2 : null);
				if (!Object.op_Implicit((Object)(object)val))
				{
					ItemManager.Instance.DestroyItem(val2.UID);
					throw new InvalidOperationException("Generated item was not equipment.");
				}
				((Component)val).transform.position = character.CenterPosition;
				((Item)val).ForceStartInit();
				if (enchant != null)
				{
					val.AddEnchantment(enchant.Id, false);
					if (!val.ActiveEnchantmentIDs.Contains(enchant.Id))
					{
						throw new InvalidOperationException("Game did not apply the enchantment.");
					}
				}
				((Item)val).ApplyVisualModifications();
				character.Inventory.TakeItemToPouch((Item)(object)val);
				((Item)val).ForceUpdateParentChange();
				if (!character.Inventory.IsItemInPouch((Item)(object)val))
				{
					throw new InvalidOperationException("Item could not be placed in your pocket.");
				}
				status = "Spawned: " + ((Item)val).Name + ((enchant == null) ? "" : (" + " + enchant.Label)) + ".";
				((BaseUnityPlugin)this).Logger.LogInfo((object)(status + " Item ID: " + ((Item)val).ItemID));
			}
			catch (Exception ex)
			{
				if (Object.op_Implicit((Object)(object)val))
				{
					ItemManager.Instance.DestroyItem(((Item)val).UID);
				}
				Fail(ex);
			}
		}

		private void Fail(Exception ex)
		{
			status = "Failed: " + ex.Message;
			((BaseUnityPlugin)this).Logger.LogError((object)ex);
		}

		private void DrawSleepSection()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			GUI.Label(new Rect(33f, 82f, 165f, 24f), "Pass Time", rowLabel);
			GUI.Label(new Rect(191f, 82f, 96f, 24f), sleepDays + ((sleepDays == 1) ? " day" : " days"), valueLabel);
			sleepDays = Mathf.RoundToInt(GUI.HorizontalSlider(new Rect(39f, 113f, 240f, 12f), (float)sleepDays, 1f, 100f));
			GUI.Label(new Rect(33f, 139f, 150f, 20f), "1 - 100 days", smallLabel);
			GUI.enabled = Time.realtimeSinceStartup - lastSleep > 1f;
			if (GUI.Button(new Rect(165f, 137f, 122f, 32f), "Pass Time"))
			{
				SleepSelectedDays();
			}
			GUI.enabled = true;
		}

		private void SleepSelectedDays()
		{
			if (!Ready(out var character) || (Object)(object)character != (Object)(object)owner || !character.IsWorldHost || character.IsDead || character.PreparingToSleep || CharacterManager.Instance.IsSleepPending)
			{
				return;
			}
			if (SaveManager.Instance.SaveInProgress || SaveManager.Instance.SavesRestricted)
			{
				menuStatus = "Wait for saving to finish.";
				return;
			}
			CharacterStats stats = character.Stats;
			PlayerCharacterStats val = (PlayerCharacterStats)(object)((stats is PlayerCharacterStats) ? stats : null);
			EnvironmentConditions instance = EnvironmentConditions.Instance;
			if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)instance) || instance.NextTimeJump >= 0f)
			{
				menuStatus = "Wait for the current time change.";
				return;
			}
			try
			{
				MethodInfo methodInfo = AccessTools.Method(typeof(EnvironmentConditions), "UpdateTime", (Type[])null, (Type[])null);
				FieldInfo fieldInfo = AccessTools.Field(typeof(PlayerCharacterStats), "m_lastNeedsUpdateTime");
				FieldInfo fieldInfo2 = AccessTools.Field(typeof(PlayerCharacterStats), "m_lastColdCheckGameTime");
				FieldInfo perishClock = AccessTools.Field(typeof(Perishable), "m_lastGameTime");
				if (methodInfo == null || fieldInfo == null || fieldInfo2 == null || perishClock == null)
				{
					throw new InvalidOperationException("Rest API unavailable.");
				}
				Perishable[] array = (from i in InventorySnapshot(character)
					where Object.op_Implicit((Object)(object)i) && Object.op_Implicit((Object)(object)i.PerishScript)
					select i.PerishScript).Distinct().ToArray();
				float[] array2 = array.Select((Perishable p) => (float)perishClock.GetValue(p)).ToArray();
				float temperature = val.Temperature;
				double gameTime = EnvironmentConditions.GameTime;
				if (instance.GameTimeTODMultiplier <= 0f)
				{
					throw new InvalidOperationException("World clock is stopped.");
				}
				lastSleep = Time.realtimeSinceStartup;
				instance.TimeJump((float)Mathf.Clamp(sleepDays, 1, 100) * 24f / instance.GameTimeTODMultiplier);
				methodInfo.Invoke(instance, null);
				double num = EnvironmentConditions.GameTime - gameTime;
				fieldInfo.SetValue(val, EnvironmentConditions.GameTimeF);
				fieldInfo2.SetValue(val, EnvironmentConditions.GameTimeF);
				for (int num2 = 0; num2 < array.Length; num2++)
				{
					if (Object.op_Implicit((Object)(object)array[num2]))
					{
						perishClock.SetValue(array[num2], (array2[num2] < 0f) ? EnvironmentConditions.GameTimeF : (array2[num2] + (float)num));
					}
				}
				((CharacterStats)val).RestoreAllVitals();
				val.Food = val.MaxFood;
				val.Drink = val.MaxDrink;
				val.Sleep = val.MaxSleep;
				val.Temperature = temperature;
				menuStatus = "Passed " + sleepDays + ((sleepDays == 1) ? " day" : " days");
				character.CharacterUI.ShowInfoNotification(menuStatus);
				((BaseUnityPlugin)this).Logger.LogInfo((object)(menuStatus + "; advanced " + num + " game hours."));
			}
			catch (Exception ex)
			{
				menuStatus = "Time advance failed: " + ex.GetBaseException().Message;
				((BaseUnityPlugin)this).Logger.LogError((object)ex);
			}
		}

		private void OpenSpawner(bool equipment)
		{
			equipmentMode = equipment;
			itemQuery = "";
			enchantQuery = "";
			showSpawner = true;
			try
			{
				Reload();
			}
			catch (Exception ex)
			{
				Fail(ex);
			}
		}

		private static bool ClickRow(Rect rect, string text, GUIStyle style, bool insideViewport)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			Event current = Event.current;
			if ((int)current.type == 7)
			{
				style.Draw(rect, new GUIContent(text), false, false, false, false);
			}
			if (GUI.enabled && insideViewport && (int)current.type == 0 && current.button == 0 && ((Rect)(ref rect)).Contains(current.mousePosition))
			{
				GUI.FocusControl((string)null);
				current.Use();
				return true;
			}
			return false;
		}

		private void DrawWindow(int id)
		{
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Expected O, but got Unknown
			//IL_0196: 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)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Expected O, but got Unknown
			//IL_0126: Expected O, but got Unknown
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: 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_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Expected O, but got Unknown
			//IL_042c: Unknown result type (might be due to invalid IL or missing references)
			//IL_045a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0777: Unknown result type (might be due to invalid IL or missing references)
			//IL_077c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0783: Unknown result type (might be due to invalid IL or missing references)
			//IL_078d: Expected O, but got Unknown
			//IL_07a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0509: Unknown result type (might be due to invalid IL or missing references)
			//IL_0560: Unknown result type (might be due to invalid IL or missing references)
			//IL_0565: Unknown result type (might be due to invalid IL or missing references)
			//IL_056e: Unknown result type (might be due to invalid IL or missing references)
			//IL_058f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0595: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0600: Unknown result type (might be due to invalid IL or missing references)
			//IL_0609: Expected O, but got Unknown
			//IL_060f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0614: 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_0624: Expected O, but got Unknown
			//IL_0638: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: 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_034b: Unknown result type (might be due to invalid IL or missing references)
			//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_083a: Unknown result type (might be due to invalid IL or missing references)
			//IL_086d: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_071f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0757: Unknown result type (might be due to invalid IL or missing references)
			if (compactRow == null)
			{
				compactRow = new GUIStyle(menuSkin.textField)
				{
					padding = new RectOffset(10, 10, 3, 3),
					fontSize = 14
				};
				compactRow.hover.background = compactRow.normal.background;
				compactRow.active.background = compactRow.normal.background;
				compactRow.focused.background = compactRow.normal.background;
				compactSelected = new GUIStyle(compactRow);
				compactSelected.normal.background = menuSkin.button.hover.background;
				compactSelected.border = menuSkin.button.border;
				compactText = new GUIStyle(menuSkin.label)
				{
					fontSize = 14,
					wordWrap = false,
					clipping = (TextClipping)1,
					padding = new RectOffset(0, 0, 0, 0)
				};
				compactMeta = new GUIStyle(smallLabel)
				{
					fontSize = 11,
					wordWrap = false,
					alignment = (TextAnchor)5
				};
			}
			float width = ((Rect)(ref window)).width;
			GUIStyle val = new GUIStyle(menuSkin.label)
			{
				alignment = (TextAnchor)4,
				fontSize = 17,
				wordWrap = false
			};
			GUI.Label(new Rect(76f, 27f, width - 152f, 26f), equipmentMode ? "Equipments Spawner/Enchanter" : "Item Spawner", val);
			if (GUI.Button(new Rect(width - 94f, 72f, 70f, 28f), "Back", listRow))
			{
				showSpawner = false;
				return;
			}
			GUI.Label(new Rect(24f, 81f, 270f, 20f), "Search name or ID", smallLabel);
			string text = GUI.TextField(new Rect(24f, 104f, 294f, 29f), itemQuery);
			if (GUI.Button(new Rect(326f, 104f, 70f, 29f), "Clear", listRow))
			{
				text = "";
			}
			if (text != itemQuery)
			{
				itemQuery = text;
				FilterItems();
			}
			GUI.Label(new Rect(24f, 137f, 372f, 19f), visibleItems.Count + " results", smallLabel);
			itemScroll.x = 0f;
			Rect val2 = new Rect(24f, 161f, 350f, 288f);
			bool insideViewport = ((Rect)(ref val2)).Contains(Event.current.mousePosition);
			itemScroll = GUI.BeginScrollView(new Rect(24f, 161f, 372f, 288f), itemScroll, new Rect(0f, 0f, 348f, (float)Mathf.Max(288, visibleItems.Count * 34)), false, true, GUIStyle.none, menuSkin.verticalScrollbar);
			int num = Mathf.Max(0, (int)(itemScroll.y / 34f) - 1);
			int num2 = Mathf.Min(visibleItems.Count, num + 11);
			for (int i = num; i < num2; i++)
			{
				Item val3 = visibleItems[i];
				float num3 = i * 34;
				if (ClickRow(new Rect(0f, num3, 346f, 31f), "", ((Object)(object)selected == (Object)(object)val3) ? compactSelected : compactRow, insideViewport))
				{
					try
					{
						Select(val3);
					}
					catch (Exception ex)
					{
						Fail(ex);
					}
				}
				GUI.Label(new Rect(10f, num3 + 6f, 251f, 20f), ItemLabel(val3), compactText);
				GUI.Label(new Rect(267f, num3 + 3f, 69f, 24f), val3.ItemID.ToString(), compactMeta);
			}
			if (visibleItems.Count == 0)
			{
				GUI.Label(new Rect(8f, 10f, 325f, 40f), "No matching items.", smallLabel);
			}
			GUI.EndScrollView();
			if (equipmentMode)
			{
				GUI.Label(new Rect(416f, 81f,