Decompiled source of NotCreative v1.0.0

NotCreative.dll

Decompiled 13 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HG;
using KinematicCharacterController;
using Microsoft.CodeAnalysis;
using MonoMod.RuntimeDetour;
using R2API;
using R2API.Utils;
using RoR2;
using RoR2.ExpansionManagement;
using RoR2.UI;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.AddressableAssets.ResourceLocators;
using UnityEngine.Networking;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("NotCreative")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("NotCreative")]
[assembly: AssemblyTitle("NotCreative")]
[assembly: AssemblyVersion("1.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 NotCreative
{
	internal class IconEntry
	{
		public string Name;

		public string Subtitle;

		public string Description;

		public Texture Icon;

		public Rect Uv = new Rect(0f, 0f, 1f, 1f);

		public Color Color = new Color(0.55f, 0.58f, 0.65f);

		public string Search;

		public void SetSprite(Sprite sprite)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)sprite) && Object.op_Implicit((Object)(object)sprite.texture))
			{
				Icon = (Texture)(object)sprite.texture;
				Uv = Helpers.SpriteUv(sprite);
			}
		}

		public void BuildSearch()
		{
			Search = (Name + " " + Subtitle).ToLowerInvariant();
		}
	}
	internal enum ItemCategory
	{
		Common,
		Uncommon,
		Legendary,
		Boss,
		Lunar,
		Void,
		Food,
		Other
	}
	internal enum EquipmentCategory
	{
		Normal,
		Lunar,
		Boss,
		Aspect
	}
	internal sealed class ItemEntry : IconEntry
	{
		public ItemIndex Index;

		public ItemCategory Category;

		public bool Hidden;
	}
	internal sealed class EquipmentEntry : IconEntry
	{
		public EquipmentIndex Index;

		public EquipmentCategory Category;
	}
	internal sealed class MonsterEntry : IconEntry
	{
		public CharacterMaster MasterPrefab;
	}
	internal sealed class SurvivorEntry : IconEntry
	{
		public SurvivorDef Def;
	}
	internal sealed class InteractableEntry : IconEntry
	{
		public string Key;

		public bool IsLegacyPath;

		public InteractableSpawnCard Card;
	}
	internal sealed class StageEntry : IconEntry
	{
		public SceneDef Def;
	}
	internal sealed class EliteEntry
	{
		public EliteDef Def;

		public string Name;
	}
	internal static class Catalogs
	{
		private const string LegacyIscPrefix = "SpawnCards/InteractableSpawnCard/";

		public static readonly List<ItemEntry> Items = new List<ItemEntry>();

		public static readonly List<EquipmentEntry> Equipment = new List<EquipmentEntry>();

		public static readonly List<MonsterEntry> Monsters = new List<MonsterEntry>();

		public static readonly List<SurvivorEntry> Survivors = new List<SurvivorEntry>();

		public static readonly List<StageEntry> Stages = new List<StageEntry>();

		public static readonly List<EliteEntry> Elites = new List<EliteEntry>();

		public static readonly List<InteractableEntry> Interactables = new List<InteractableEntry>();

		private static bool built;

		private static bool interactablesBuilt;

		public static void EnsureBuilt()
		{
			if (!built && ItemCatalog.itemCount != 0)
			{
				built = true;
				BuildItems();
				BuildEquipment();
				BuildMonsters();
				BuildSurvivors();
				BuildStages();
				BuildElites();
				NotCreativePlugin.Log.LogInfo((object)$"Catalogs: {Items.Count} items, {Equipment.Count} equipment, {Monsters.Count} monsters, {Survivors.Count} survivors, {Stages.Count} stages, {Elites.Count} elites.");
			}
		}

		private static void BuildItems()
		{
			//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_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
			Enumerator<ItemDef> enumerator = ItemCatalog.allItemDefs.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					ItemDef current = enumerator.Current;
					if (Object.op_Implicit((Object)(object)current))
					{
						ItemEntry itemEntry = new ItemEntry
						{
							Index = current.itemIndex,
							Category = CategoryOf(current.tier),
							Hidden = current.hidden,
							Name = Helpers.Lang(current.nameToken, ((Object)current).name),
							Subtitle = ((Object)current).name,
							Description = Helpers.StripTags(Helpers.Lang(current.pickupToken, ""))
						};
						ItemTierDef itemTierDef = ItemTierCatalog.GetItemTierDef(current.tier);
						if (Object.op_Implicit((Object)(object)itemTierDef))
						{
							itemEntry.Color = Color32.op_Implicit(ColorCatalog.GetColor(itemTierDef.colorIndex));
						}
						itemEntry.SetSprite(current.pickupIconSprite);
						itemEntry.BuildSearch();
						Items.Add(itemEntry);
					}
				}
			}
			finally
			{
				((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
			}
			Items.Sort((ItemEntry a, ItemEntry b) => (a.Category == b.Category) ? string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase) : a.Category.CompareTo(b.Category));
		}

		private static ItemCategory CategoryOf(ItemTier tier)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected I4, but got Unknown
			switch ((int)tier)
			{
			case 0:
				return ItemCategory.Common;
			case 1:
				return ItemCategory.Uncommon;
			case 2:
				return ItemCategory.Legendary;
			case 4:
				return ItemCategory.Boss;
			case 3:
				return ItemCategory.Lunar;
			case 6:
			case 7:
			case 8:
			case 9:
				return ItemCategory.Void;
			case 10:
				return ItemCategory.Food;
			default:
				return ItemCategory.Other;
			}
		}

		private static void BuildEquipment()
		{
			//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_00b1: 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_00bb: 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)
			for (int i = 0; i < EquipmentCatalog.equipmentCount; i++)
			{
				EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef((EquipmentIndex)i);
				if (Object.op_Implicit((Object)(object)equipmentDef))
				{
					string text = Helpers.Lang(equipmentDef.nameToken, null);
					if (text != null || Object.op_Implicit((Object)(object)equipmentDef.pickupIconSprite))
					{
						EquipmentEntry equipmentEntry = new EquipmentEntry
						{
							Index = equipmentDef.equipmentIndex,
							Category = (Object.op_Implicit((Object)(object)equipmentDef.passiveBuffDef) ? EquipmentCategory.Aspect : (equipmentDef.isLunar ? EquipmentCategory.Lunar : (equipmentDef.isBoss ? EquipmentCategory.Boss : EquipmentCategory.Normal))),
							Name = (text ?? ((Object)equipmentDef).name),
							Subtitle = ((Object)equipmentDef).name,
							Description = Helpers.StripTags(Helpers.Lang(equipmentDef.pickupToken, "")),
							Color = Color32.op_Implicit(ColorCatalog.GetColor(equipmentDef.colorIndex))
						};
						equipmentEntry.SetSprite(equipmentDef.pickupIconSprite);
						equipmentEntry.BuildSearch();
						Equipment.Add(equipmentEntry);
					}
				}
			}
			Equipment.Sort((EquipmentEntry a, EquipmentEntry b) => (a.Category == b.Category) ? string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase) : a.Category.CompareTo(b.Category));
		}

		private static void BuildMonsters()
		{
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			Color color = default(Color);
			((Color)(ref color))..ctor(0.93f, 0.8f, 0.3f);
			foreach (CharacterMaster allAiMaster in MasterCatalog.allAiMasters)
			{
				if (!Object.op_Implicit((Object)(object)allAiMaster) || !Object.op_Implicit((Object)(object)allAiMaster.bodyPrefab))
				{
					continue;
				}
				CharacterBody component = allAiMaster.bodyPrefab.GetComponent<CharacterBody>();
				if (Object.op_Implicit((Object)(object)component))
				{
					MonsterEntry monsterEntry = new MonsterEntry
					{
						MasterPrefab = allAiMaster,
						Name = Helpers.Lang(component.baseNameToken, ((Object)allAiMaster).name),
						Subtitle = ((Object)allAiMaster).name,
						Description = (component.isChampion ? "Boss" : ""),
						Icon = component.portraitIcon
					};
					if (component.isChampion)
					{
						monsterEntry.Color = color;
					}
					monsterEntry.BuildSearch();
					Monsters.Add(monsterEntry);
				}
			}
			Monsters.Sort((MonsterEntry a, MonsterEntry b) => string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase));
		}

		private static void BuildSurvivors()
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			foreach (SurvivorDef orderedSurvivorDef in SurvivorCatalog.orderedSurvivorDefs)
			{
				if (Object.op_Implicit((Object)(object)orderedSurvivorDef) && Object.op_Implicit((Object)(object)orderedSurvivorDef.bodyPrefab))
				{
					CharacterBody component = orderedSurvivorDef.bodyPrefab.GetComponent<CharacterBody>();
					SurvivorEntry survivorEntry = new SurvivorEntry
					{
						Def = orderedSurvivorDef,
						Name = Helpers.Lang(orderedSurvivorDef.displayNameToken, orderedSurvivorDef.cachedName),
						Subtitle = orderedSurvivorDef.cachedName,
						Description = "Respawns you as this survivor right where you stand. Items are kept.",
						Icon = (Object.op_Implicit((Object)(object)component) ? component.portraitIcon : null),
						Color = orderedSurvivorDef.primaryColor
					};
					survivorEntry.BuildSearch();
					Survivors.Add(survivorEntry);
				}
			}
		}

		private static void BuildStages()
		{
			//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_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Invalid comparison between Unknown and I4
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Invalid comparison between Unknown and I4
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Invalid comparison between Unknown and I4
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Invalid comparison between Unknown and I4
			Enumerator<SceneDef> enumerator = SceneCatalog.allSceneDefs.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					SceneDef current = enumerator.Current;
					if (Object.op_Implicit((Object)(object)current) && !current.isOfflineScene && ((int)current.sceneType == 1 || (int)current.sceneType == 5 || (int)current.sceneType == 2 || (int)current.sceneType == 4))
					{
						StageEntry stageEntry = new StageEntry
						{
							Def = current,
							Name = Helpers.Lang(current.nameToken, current.cachedName),
							Subtitle = current.cachedName,
							Description = Helpers.StripTags(Helpers.Lang(current.subtitleToken, ""))
						};
						stageEntry.BuildSearch();
						Stages.Add(stageEntry);
					}
				}
			}
			finally
			{
				((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
			}
			Stages.Sort(delegate(StageEntry a, StageEntry b)
			{
				int num = ((a.Def.stageOrder > 0) ? a.Def.stageOrder : int.MaxValue);
				int num2 = ((b.Def.stageOrder > 0) ? b.Def.stageOrder : int.MaxValue);
				return (num == num2) ? string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase) : num.CompareTo(num2);
			});
		}

		private static void BuildElites()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			HashSet<EquipmentDef> hashSet = new HashSet<EquipmentDef>();
			foreach (EliteIndex elite in EliteCatalog.eliteList)
			{
				EliteDef eliteDef = EliteCatalog.GetEliteDef(elite);
				if (Object.op_Implicit((Object)(object)eliteDef) && Object.op_Implicit((Object)(object)eliteDef.eliteEquipmentDef) && hashSet.Add(eliteDef.eliteEquipmentDef))
				{
					string name = Helpers.Lang(eliteDef.modifierToken, ((Object)eliteDef).name).Replace("{0}", "").Trim();
					Elites.Add(new EliteEntry
					{
						Def = eliteDef,
						Name = name
					});
				}
			}
			Elites.Sort((EliteEntry a, EliteEntry b) => string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase));
		}

		public static void EnsureInteractables()
		{
			if (interactablesBuilt)
			{
				return;
			}
			interactablesBuilt = true;
			Dictionary<string, InteractableEntry> dictionary = new Dictionary<string, InteractableEntry>(StringComparer.OrdinalIgnoreCase);
			try
			{
				foreach (IResourceLocator resourceLocator in Addressables.ResourceLocators)
				{
					foreach (object key2 in resourceLocator.Keys)
					{
						if (key2 is string text && text.EndsWith(".asset", StringComparison.Ordinal))
						{
							string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text);
							if (fileNameWithoutExtension.StartsWith("isc", StringComparison.Ordinal) && !dictionary.ContainsKey(fileNameWithoutExtension))
							{
								dictionary[fileNameWithoutExtension] = new InteractableEntry
								{
									Key = text
								};
							}
						}
					}
				}
			}
			catch (Exception ex)
			{
				NotCreativePlugin.Log.LogWarning((object)("Could not read the Addressables catalog: " + ex.Message));
			}
			List<string> list = new List<string>();
			LegacyResourcesAPI.GetAllPaths(list);
			foreach (string item in list)
			{
				if (item.StartsWith("SpawnCards/InteractableSpawnCard/", StringComparison.Ordinal))
				{
					string key = item.Substring("SpawnCards/InteractableSpawnCard/".Length);
					if (!dictionary.ContainsKey(key))
					{
						dictionary[key] = new InteractableEntry
						{
							Key = item,
							IsLegacyPath = true
						};
					}
				}
			}
			foreach (KeyValuePair<string, InteractableEntry> item2 in dictionary)
			{
				InteractableEntry value = item2.Value;
				value.Name = Helpers.Humanize(item2.Key.Substring(3));
				value.Subtitle = item2.Key;
				value.Description = value.Key;
				value.BuildSearch();
				Interactables.Add(value);
			}
			Interactables.Sort((InteractableEntry a, InteractableEntry b) => string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase));
			NotCreativePlugin.Log.LogInfo((object)$"Catalogs: {Interactables.Count} interactable spawn cards.");
		}

		public static InteractableSpawnCard LoadCard(InteractableEntry entry)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)entry.Card))
			{
				return entry.Card;
			}
			try
			{
				entry.Card = (entry.IsLegacyPath ? LegacyResourcesAPI.Load<InteractableSpawnCard>(entry.Key) : Addressables.LoadAssetAsync<InteractableSpawnCard>((object)entry.Key).WaitForCompletion());
			}
			catch (Exception ex)
			{
				NotCreativePlugin.Log.LogWarning((object)("Could not load " + entry.Key + ": " + ex.Message));
			}
			return entry.Card;
		}
	}
	internal sealed class CreativeMenu
	{
		private enum CellLayout
		{
			Icon,
			IconLabel,
			Text
		}

		private struct Cell
		{
			public IconEntry Entry;

			public string Badge;

			public bool Dim;

			public bool Selected;
		}

		private struct Click
		{
			public int Index;

			public int Button;

			public bool Shift;
		}

		private sealed class Grid
		{
			public Vector2 Scroll;

			public float ViewHeight;
		}

		private sealed class Filter<T> where T : IconEntry
		{
			private IList<T> source;

			private int sourceCount = -1;

			private string key;

			private readonly List<T> result = new List<T>();

			public List<T> Apply(IList<T> items, string search, int mode, Func<T, bool> predicate)
			{
				string text = (search ?? "").Trim().ToLowerInvariant();
				string text2 = mode + "\n" + text;
				if (items == source && items.Count == sourceCount && text2 == key)
				{
					return result;
				}
				source = items;
				sourceCount = items.Count;
				key = text2;
				result.Clear();
				foreach (T item in items)
				{
					if (predicate(item) && (text.Length == 0 || item.Search.Contains(text)))
					{
						result.Add(item);
					}
				}
				return result;
			}
		}

		private const int WindowId = 20035;

		private const float WindowWidth = 1080f;

		private const float WindowHeight = 720f;

		private const float ContentWidth = 1056f;

		private const float LeftColumnWidth = 420f;

		private const float RightColumnWidth = 596f;

		private const float ScrollbarWidth = 18f;

		private static readonly string[] TabNames = new string[5] { "Items", "Equipment", "Player", "Spawn", "World" };

		private static readonly string[] ItemFilterNames = new string[9] { "All", "Common", "Uncommon", "Legendary", "Boss", "Lunar", "Void", "Food", "Other" };

		private static readonly string[] EquipmentFilterNames = new string[5] { "All", "Normal", "Lunar", "Boss", "Elite aspects" };

		private static readonly string[] GiveModeNames = new string[2] { "Give", "Drop" };

		private static readonly string[] SpawnModeNames = new string[2] { "Monsters", "Interactables" };

		private static readonly string[] TeamNames = new string[2] { "Enemy", "Ally" };

		private static readonly int[] Amounts = new int[5] { 1, 5, 10, 50, 100 };

		private static readonly string[] AmountNames = new string[5] { "1", "5", "10", "50", "100" };

		private static readonly int[] SpawnCounts = new int[5] { 1, 3, 5, 10, 20 };

		private static readonly string[] SpawnCountNames = new string[5] { "1", "3", "5", "10", "20" };

		private static readonly uint[] MoneyAmounts = new uint[4] { 100u, 1000u, 10000u, 100000u };

		private static readonly uint[] CoinAmounts = new uint[3] { 1u, 10u, 100u };

		private static readonly uint[] LevelAmounts = new uint[4] { 1u, 5u, 10u, 50u };

		private readonly PlayerCheats cheats;

		private readonly List<MPEventSystem> cursorHolders = new List<MPEventSystem>();

		private readonly List<Action> queued = new List<Action>();

		private readonly List<Action> deferredUi = new List<Action>();

		private Rect windowRect;

		private Rect drawnWindowRect;

		private float guiScale = 1f;

		private bool positioned;

		private readonly List<Image> cursorImages = new List<Image>();

		private readonly Vector3[] cursorCorners = (Vector3[])(object)new Vector3[4];

		private int tab;

		private IconEntry hovered;

		private string itemSearch = "";

		private int itemFilter;

		private int itemAmount;

		private bool itemDrop;

		private bool showHidden;

		private readonly Grid itemGrid = new Grid();

		private readonly Filter<ItemEntry> itemView = new Filter<ItemEntry>();

		private string equipmentSearch = "";

		private int equipmentFilter;

		private bool equipmentDrop;

		private readonly Grid equipmentGrid = new Grid();

		private readonly Filter<EquipmentEntry> equipmentView = new Filter<EquipmentEntry>();

		private readonly Grid survivorGrid = new Grid();

		private int spawnMode;

		private int spawnCount;

		private int spawnTeam;

		private int spawnElite;

		private string[] eliteNames = new string[1] { "None" };

		private string monsterSearch = "";

		private string interactableSearch = "";

		private readonly Grid monsterGrid = new Grid();

		private readonly Grid interactableGrid = new Grid();

		private readonly Filter<MonsterEntry> monsterView = new Filter<MonsterEntry>();

		private readonly Filter<InteractableEntry> interactableView = new Filter<InteractableEntry>();

		private readonly Grid stageGrid = new Grid();

		private float timeScale = 1f;

		public static bool IsOpen { get; private set; }

		public CreativeMenu(PlayerCheats cheats)
		{
			this.cheats = cheats;
		}

		public void Toggle()
		{
			if (IsOpen)
			{
				Close();
			}
			else
			{
				Open();
			}
		}

		public void Open()
		{
			if (IsOpen)
			{
				return;
			}
			IsOpen = true;
			Catalogs.EnsureBuilt();
			if (MPEventSystem.readOnlyInstancesList == null)
			{
				return;
			}
			foreach (MPEventSystem readOnlyInstances in MPEventSystem.readOnlyInstancesList)
			{
				if (Object.op_Implicit((Object)(object)readOnlyInstances))
				{
					int cursorOpenerCount = readOnlyInstances.cursorOpenerCount;
					readOnlyInstances.cursorOpenerCount = cursorOpenerCount + 1;
					cursorHolders.Add(readOnlyInstances);
				}
			}
		}

		public void Close()
		{
			if (!IsOpen)
			{
				return;
			}
			IsOpen = false;
			foreach (MPEventSystem cursorHolder in cursorHolders)
			{
				if (Object.op_Implicit((Object)(object)cursorHolder))
				{
					int cursorOpenerCount = cursorHolder.cursorOpenerCount;
					cursorHolder.cursorOpenerCount = cursorOpenerCount - 1;
				}
			}
			cursorHolders.Clear();
		}

		public void Update()
		{
			if (queued.Count == 0)
			{
				return;
			}
			Action[] array = queued.ToArray();
			queued.Clear();
			Action[] array2 = array;
			foreach (Action action in array2)
			{
				try
				{
					action();
				}
				catch (Exception ex)
				{
					Notifier.Error("Something went wrong: " + ex.Message);
					NotCreativePlugin.Log.LogError((object)ex);
				}
			}
		}

		private void Queue(Action action)
		{
			queued.Add(action);
		}

		private void Defer(Action action)
		{
			deferredUi.Add(action);
		}

		public void OnGUI()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Invalid comparison between Unknown and I4
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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_00d0: 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_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Expected O, but got Unknown
			//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_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			if (!IsOpen)
			{
				return;
			}
			Styles.Init();
			if ((int)Event.current.type == 8 && deferredUi.Count > 0)
			{
				foreach (Action item in deferredUi)
				{
					item();
				}
				deferredUi.Clear();
			}
			float num = (float)Screen.height / 1080f * NotCreativePlugin.UiScale.Value;
			num = Mathf.Min(new float[3]
			{
				num,
				(float)Screen.width / 1100f,
				(float)Screen.height / 740f
			});
			num = Mathf.Max(num, 0.3f);
			Matrix4x4 matrix = GUI.matrix;
			GUISkin skin = GUI.skin;
			GUI.matrix = Matrix4x4.Scale(new Vector3(num, num, 1f));
			GUI.skin = Styles.Skin;
			float num2 = (float)Screen.width / num;
			float num3 = (float)Screen.height / num;
			if (!positioned)
			{
				windowRect = new Rect((num2 - 1080f) / 2f, (num3 - 720f) / 2f, 1080f, 720f);
				positioned = true;
			}
			guiScale = num;
			drawnWindowRect = windowRect;
			windowRect = GUI.Window(20035, windowRect, new WindowFunction(DrawWindow), GUIContent.none);
			((Rect)(ref windowRect)).x = Mathf.Clamp(((Rect)(ref windowRect)).x, 0f, Mathf.Max(0f, num2 - 1080f));
			((Rect)(ref windowRect)).y = Mathf.Clamp(((Rect)(ref windowRect)).y, 0f, Mathf.Max(0f, num3 - 720f));
			GUI.matrix = matrix;
			GUI.skin = skin;
		}

		private void DrawWindow(int id)
		{
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			hovered = null;
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("NotCreative", Styles.Title, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) });
			GUILayout.Space(8f);
			GUILayout.Label(HeaderInfo(), Styles.Dim, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) });
			GUILayout.FlexibleSpace();
			if (GUILayout.Button("X", Styles.Close, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(32f),
				GUILayout.Height(28f)
			}))
			{
				Queue(Close);
			}
			GUILayout.EndHorizontal();
			GUILayout.Space(4f);
			int newTab = GUILayout.Toolbar(tab, TabNames, Styles.Tab, Array.Empty<GUILayoutOption>());
			if (newTab != tab)
			{
				Defer(delegate
				{
					tab = newTab;
				});
			}
			GUILayout.Space(4f);
			string text = BannerText();
			if (text != null)
			{
				GUILayout.Label(text, Styles.Banner, Array.Empty<GUILayoutOption>());
			}
			switch (tab)
			{
			case 0:
				DrawItemsTab();
				break;
			case 1:
				DrawEquipmentTab();
				break;
			case 2:
				DrawPlayerTab();
				break;
			case 3:
				DrawSpawnTab();
				break;
			default:
				DrawWorldTab();
				break;
			}
			DrawFooter();
			DrawGameCursor();
			GUI.DragWindow(new Rect(0f, 0f, 1030f, 44f));
		}

		private void DrawGameCursor()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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_00de: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: 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)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			if ((int)Event.current.type != 7)
			{
				return;
			}
			Color color = GUI.color;
			foreach (MPEventSystem cursorHolder in cursorHolders)
			{
				if (!Object.op_Implicit((Object)(object)cursorHolder) || !cursorHolder.isCursorVisible)
				{
					continue;
				}
				CursorIndicatorController componentInChildren = ((Component)cursorHolder).GetComponentInChildren<CursorIndicatorController>();
				if (!Object.op_Implicit((Object)(object)componentInChildren))
				{
					continue;
				}
				((Component)componentInChildren).GetComponentsInChildren<Image>(false, cursorImages);
				foreach (Image cursorImage in cursorImages)
				{
					if (((Behaviour)cursorImage).enabled && Object.op_Implicit((Object)(object)cursorImage.sprite))
					{
						Canvas canvas = ((Graphic)cursorImage).canvas;
						Camera obj = ((Object.op_Implicit((Object)(object)canvas) && (int)canvas.renderMode != 0) ? canvas.worldCamera : null);
						((Graphic)cursorImage).rectTransform.GetWorldCorners(cursorCorners);
						Vector2 val = RectTransformUtility.WorldToScreenPoint(obj, cursorCorners[0]);
						Vector2 val2 = RectTransformUtility.WorldToScreenPoint(obj, cursorCorners[2]);
						Rect val3 = new Rect(val.x / guiScale - ((Rect)(ref drawnWindowRect)).x, ((float)Screen.height - val2.y) / guiScale - ((Rect)(ref drawnWindowRect)).y, (val2.x - val.x) / guiScale, (val2.y - val.y) / guiScale);
						GUI.color = ((Graphic)cursorImage).color;
						GUI.DrawTextureWithTexCoords(val3, (Texture)(object)cursorImage.sprite.texture, Helpers.SpriteUv(cursorImage.sprite), true);
					}
				}
			}
			GUI.color = color;
		}

		private static string HeaderInfo()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			string text = ((object)NotCreativePlugin.MenuKey.Value/*cast due to .constrained prefix*/).ToString();
			if (!Object.op_Implicit((Object)(object)Run.instance))
			{
				return text + " closes the menu";
			}
			string arg = (NetworkServer.active ? "Host" : "Client");
			return $"{arg}   |   Stage {Run.instance.stageClearCount + 1}   |   {text} closes the menu";
		}

		private static string BannerText()
		{
			if (!Object.op_Implicit((Object)(object)Run.instance))
			{
				return "No run is active. Start a run (single-player, or host a lobby) to use the menu.";
			}
			if (!NetworkServer.active)
			{
				return "You are a client in someone else's lobby. NotCreative only works for the host or in single-player.";
			}
			return null;
		}

		private void DrawFooter()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			string text;
			string text2;
			if (hovered != null)
			{
				text = "<color=#" + ColorUtility.ToHtmlStringRGB(hovered.Color) + ">" + hovered.Name + "</color>   <size=12><color=#7d8494>" + hovered.Subtitle + "</color></size>";
				text2 = (string.IsNullOrEmpty(hovered.Description) ? " " : hovered.Description);
			}
			else
			{
				text = "<color=#7d8494>Hover over something to see what it is.</color>";
				text2 = "Things you spawn appear where your crosshair was pointing when you opened the menu.";
			}
			string text3 = " ";
			if (Notifier.IsRecent)
			{
				text3 = (Notifier.IsError ? ("<color=#ff7869>" + Notifier.Message + "</color>") : ("<color=#9be37a>" + Notifier.Message + "</color>"));
			}
			GUILayout.BeginVertical(Styles.Panel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(64f) });
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label(text, Styles.FooterTitle, Array.Empty<GUILayoutOption>());
			GUILayout.FlexibleSpace();
			GUILayout.Label(text3, Styles.FooterTitle, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			GUILayout.Label(text2, Styles.FooterText, Array.Empty<GUILayoutOption>());
			GUILayout.EndVertical();
		}

		private void DrawItemsTab()
		{
			Inventory inventory = LocalInventory();
			int amount = Amounts[itemAmount];
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			itemSearch = SearchField(itemSearch, 260f);
			GUILayout.Space(14f);
			GUILayout.Label("Amount", Styles.Dim, Array.Empty<GUILayoutOption>());
			itemAmount = GUILayout.Toolbar(itemAmount, AmountNames, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(240f) });
			GUILayout.Space(14f);
			itemDrop = GUILayout.Toolbar(itemDrop ? 1 : 0, GiveModeNames, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) }) == 1;
			GUILayout.FlexibleSpace();
			showHidden = GUILayout.Toggle(showHidden, "Show hidden", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(130f) });
			GUILayout.EndHorizontal();
			itemFilter = GUILayout.Toolbar(itemFilter, ItemFilterNames, Array.Empty<GUILayoutOption>());
			int filter = itemFilter;
			bool hidden = showHidden;
			List<ItemEntry> items = itemView.Apply(Catalogs.Items, itemSearch, filter * 2 + (hidden ? 1 : 0), (ItemEntry e) => (hidden || !e.Hidden) && (filter == 0 || e.Category == (ItemCategory)(filter - 1)));
			if (DrawGrid(itemGrid, items.Count, (int i) => ItemCell(items[i], inventory), CellLayout.Icon, 66f, 66f, 1056f, out var click))
			{
				ItemEntry item = items[click.Index];
				bool drop = itemDrop;
				if (click.Button == 1)
				{
					int count = (click.Shift ? int.MaxValue : amount);
					Queue(delegate
					{
						GameActions.RemoveItem(item, count);
					});
				}
				else if (click.Button == 0)
				{
					Queue(delegate
					{
						//IL_000e: Unknown result type (might be due to invalid IL or missing references)
						//IL_0013: Unknown result type (might be due to invalid IL or missing references)
						if (drop)
						{
							GameActions.DropPickup(PickupCatalog.FindPickupIndex(item.Index), item.Name, amount);
						}
						else
						{
							GameActions.GiveItem(item, amount);
						}
					});
				}
			}
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Clear inventory", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) }))
			{
				Queue(GameActions.ClearInventory);
			}
			if (GUILayout.Button($"Give all shown  x{amount}", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(190f) }))
			{
				ItemEntry[] shown = items.ToArray();
				Queue(delegate
				{
					GameActions.GiveItems(shown, amount);
				});
			}
			GUILayout.FlexibleSpace();
			GUILayout.Label("Left click: give     Right click: remove     Shift + right click: remove all", Styles.Dim, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
		}

		private static Cell ItemCell(ItemEntry item, Inventory inventory)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			int num = (Object.op_Implicit((Object)(object)inventory) ? inventory.GetItemCountPermanent(item.Index) : 0);
			return new Cell
			{
				Entry = item,
				Badge = ((num > 0) ? num.ToString() : null),
				Dim = (Object.op_Implicit((Object)(object)Run.instance) && Run.instance.IsItemExpansionLocked(item.Index))
			};
		}

		private void DrawEquipmentTab()
		{
			//IL_0019: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			Inventory val = LocalInventory();
			EquipmentIndex current = (EquipmentIndex)((!Object.op_Implicit((Object)(object)val)) ? (-1) : ((int)val.currentEquipmentIndex));
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			equipmentSearch = SearchField(equipmentSearch, 260f);
			GUILayout.Space(14f);
			equipmentDrop = GUILayout.Toolbar(equipmentDrop ? 1 : 0, GiveModeNames, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) }) == 1;
			GUILayout.FlexibleSpace();
			GUILayout.Label("Current: " + EquipmentName(current), Styles.Dim, Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Remove", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) }))
			{
				Queue(GameActions.RemoveEquipment);
			}
			GUILayout.EndHorizontal();
			equipmentFilter = GUILayout.Toolbar(equipmentFilter, EquipmentFilterNames, Array.Empty<GUILayoutOption>());
			int filter = equipmentFilter;
			List<EquipmentEntry> list = equipmentView.Apply(Catalogs.Equipment, equipmentSearch, filter, (EquipmentEntry e) => filter == 0 || e.Category == (EquipmentCategory)(filter - 1));
			Func<int, Cell> cellAt = (int i) => new Cell
			{
				Entry = list[i],
				Selected = (list[i].Index == current),
				Dim = (Object.op_Implicit((Object)(object)Run.instance) && Run.instance.IsEquipmentExpansionLocked(list[i].Index))
			};
			if (DrawGrid(equipmentGrid, list.Count, cellAt, CellLayout.Icon, 66f, 66f, 1056f, out var click) && click.Button == 0)
			{
				EquipmentEntry equipment = list[click.Index];
				if (equipmentDrop)
				{
					Queue(delegate
					{
						//IL_0006: Unknown result type (might be due to invalid IL or missing references)
						//IL_000b: Unknown result type (might be due to invalid IL or missing references)
						GameActions.DropPickup(PickupCatalog.FindPickupIndex(equipment.Index), equipment.Name, 1);
					});
				}
				else
				{
					Queue(delegate
					{
						GameActions.SetEquipment(equipment);
					});
				}
			}
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.FlexibleSpace();
			GUILayout.Label("Left click: equip (replaces your current equipment)", Styles.Dim, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
		}

		private unsafe static string EquipmentName(EquipmentIndex index)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if ((int)index == -1)
			{
				return "none";
			}
			foreach (EquipmentEntry item in Catalogs.Equipment)
			{
				if (item.Index == index)
				{
					return item.Name;
				}
			}
			return ((object)(*(EquipmentIndex*)(&index))/*cast due to .constrained prefix*/).ToString();
		}

		private void DrawPlayerTab()
		{
			GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) });
			GUILayout.BeginVertical(Styles.Panel, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(420f),
				GUILayout.ExpandHeight(true)
			});
			GUILayout.Label("Cheats", Styles.Header, Array.Empty<GUILayoutOption>());
			cheats.GodMode = GUILayout.Toggle(cheats.GodMode, "God mode  -  you can't take damage", Array.Empty<GUILayoutOption>());
			cheats.NoCooldowns = GUILayout.Toggle(cheats.NoCooldowns, "No cooldowns  -  skills and equipment", Array.Empty<GUILayoutOption>());
			cheats.Fly = GUILayout.Toggle(cheats.Fly, "Fly  -  Jump = up, Left Ctrl = down", Array.Empty<GUILayoutOption>());
			cheats.Noclip = GUILayout.Toggle(cheats.Noclip, "Noclip  -  fly through walls", Array.Empty<GUILayoutOption>());
			cheats.FlySpeed = SliderRow("Fly speed", cheats.FlySpeed, 1f, 10f);
			GUILayout.Label("Stats", Styles.Header, Array.Empty<GUILayoutOption>());
			float num = SliderRow("Move speed", cheats.MoveSpeedMult, 1f, 10f);
			float num2 = SliderRow("Damage", cheats.DamageMult, 1f, 100f);
			float num3 = SliderRow("Attack speed", cheats.AttackSpeedMult, 1f, 10f);
			if (num != cheats.MoveSpeedMult || num2 != cheats.DamageMult || num3 != cheats.AttackSpeedMult)
			{
				cheats.MoveSpeedMult = num;
				cheats.DamageMult = num2;
				cheats.AttackSpeedMult = num3;
				cheats.MarkStatsDirty();
			}
			if (GUILayout.Button("Reset stats", Array.Empty<GUILayoutOption>()))
			{
				cheats.ResetStats();
			}
			GUILayout.FlexibleSpace();
			GUILayout.Label("Cheats only affect you, and only work as host / single-player.", Styles.Dim, Array.Empty<GUILayoutOption>());
			GUILayout.EndVertical();
			GUILayout.BeginVertical(Styles.Panel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) });
			GUILayout.Label("Resources", Styles.Header, Array.Empty<GUILayoutOption>());
			AmountButtons("Money", MoneyAmounts, "$", delegate(uint amount)
			{
				GameActions.GiveMoney(amount);
			});
			AmountButtons("Lunar coins", CoinAmounts, "", delegate(uint amount)
			{
				GameActions.GiveLunarCoins(amount);
			});
			uint num4 = (Object.op_Implicit((Object)(object)TeamManager.instance) ? TeamManager.instance.GetTeamLevel((TeamIndex)1) : 0u);
			AmountButtons($"Level ({num4})", LevelAmounts, "", delegate(uint amount)
			{
				GameActions.AddLevels(amount);
			});
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Space(116f);
			if (GUILayout.Button("Full heal", Array.Empty<GUILayoutOption>()))
			{
				Queue(GameActions.Heal);
			}
			if (GUILayout.Button("Revive", Array.Empty<GUILayoutOption>()))
			{
				Queue(GameActions.Revive);
			}
			GUILayout.EndHorizontal();
			GUILayout.Label("Change survivor", Styles.Header, Array.Empty<GUILayoutOption>());
			CharacterMaster localMaster = Helpers.LocalMaster;
			GameObject currentBody = (Object.op_Implicit((Object)(object)localMaster) ? localMaster.bodyPrefab : null);
			List<SurvivorEntry> survivors = Catalogs.Survivors;
			Func<int, Cell> cellAt = (int i) => new Cell
			{
				Entry = survivors[i],
				Selected = (Object.op_Implicit((Object)(object)currentBody) && (Object)(object)survivors[i].Def.bodyPrefab == (Object)(object)currentBody)
			};
			if (DrawGrid(survivorGrid, survivors.Count, cellAt, CellLayout.IconLabel, 96f, 100f, 596f, out var click) && click.Button == 0)
			{
				SurvivorEntry survivor = survivors[click.Index];
				Queue(delegate
				{
					GameActions.ChangeSurvivor(survivor);
				});
			}
			GUILayout.EndVertical();
			GUILayout.EndHorizontal();
		}

		private void AmountButtons(string label, uint[] amounts, string prefix, Action<uint> action)
		{
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label(label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(110f) });
			foreach (uint amount in amounts)
			{
				if (GUILayout.Button("+" + prefix + ShortNumber(amount), Array.Empty<GUILayoutOption>()))
				{
					Queue(delegate
					{
						action(amount);
					});
				}
			}
			GUILayout.EndHorizontal();
		}

		private static string ShortNumber(uint value)
		{
			if (value < 1000)
			{
				return value.ToString();
			}
			return value / 1000 + "k";
		}

		private static float SliderRow(string label, float value, float min, float max)
		{
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label(label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(110f) });
			float num = GUILayout.HorizontalSlider(value, min, max, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
			num = ((max > 20f) ? Mathf.Round(num) : (Mathf.Round(num * 10f) / 10f));
			GUILayout.Label("x" + num.ToString((max > 20f) ? "0" : "0.0"), Styles.Dim, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(48f) });
			GUILayout.EndHorizontal();
			return num;
		}

		private void DrawSpawnTab()
		{
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			int newMode = GUILayout.Toolbar(spawnMode, SpawnModeNames, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(300f) });
			if (newMode != spawnMode)
			{
				Defer(delegate
				{
					spawnMode = newMode;
				});
			}
			GUILayout.Space(14f);
			GUILayout.Label("Count", Styles.Dim, Array.Empty<GUILayoutOption>());
			spawnCount = GUILayout.Toolbar(spawnCount, SpawnCountNames, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(220f) });
			GUILayout.FlexibleSpace();
			if (GUILayout.Button("Kill all enemies", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) }))
			{
				Queue(GameActions.KillAllEnemies);
			}
			GUILayout.EndHorizontal();
			if (spawnMode == 0)
			{
				DrawMonsters();
			}
			else
			{
				DrawInteractables();
			}
		}

		private void DrawMonsters()
		{
			int count = SpawnCounts[spawnCount];
			if (eliteNames.Length != Catalogs.Elites.Count + 1)
			{
				eliteNames = new string[Catalogs.Elites.Count + 1];
				eliteNames[0] = "None";
				for (int i = 0; i < Catalogs.Elites.Count; i++)
				{
					eliteNames[i + 1] = Catalogs.Elites[i].Name;
				}
				spawnElite = 0;
			}
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			monsterSearch = SearchField(monsterSearch, 260f);
			GUILayout.Space(14f);
			GUILayout.Label("Team", Styles.Dim, Array.Empty<GUILayoutOption>());
			spawnTeam = GUILayout.Toolbar(spawnTeam, TeamNames, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(170f) });
			GUILayout.FlexibleSpace();
			GUILayout.Label("Allies follow you around.", Styles.Dim, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("Elite", Styles.Dim, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(44f) });
			spawnElite = GUILayout.SelectionGrid(spawnElite, eliteNames, Mathf.Clamp(eliteNames.Length, 1, 8), Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			List<MonsterEntry> list = monsterView.Apply(Catalogs.Monsters, monsterSearch, 0, (MonsterEntry _) => true);
			if (DrawGrid(monsterGrid, list.Count, (int index) => new Cell
			{
				Entry = list[index]
			}, CellLayout.IconLabel, 96f, 100f, 1056f, out var click) && click.Button == 0)
			{
				MonsterEntry monster = list[click.Index];
				bool ally = spawnTeam == 1;
				EliteDef elite = ((spawnElite > 0) ? Catalogs.Elites[spawnElite - 1].Def : null);
				Queue(delegate
				{
					GameActions.SpawnMonster(monster, count, ally, elite);
				});
			}
		}

		private void DrawInteractables()
		{
			Catalogs.EnsureInteractables();
			int count = SpawnCounts[spawnCount];
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			interactableSearch = SearchField(interactableSearch, 260f);
			GUILayout.FlexibleSpace();
			GUILayout.Label("Chests, shrines, printers, drones, portals...", Styles.Dim, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			List<InteractableEntry> list = interactableView.Apply(Catalogs.Interactables, interactableSearch, 0, (InteractableEntry _) => true);
			if (DrawGrid(interactableGrid, list.Count, (int i) => new Cell
			{
				Entry = list[i]
			}, CellLayout.Text, 208f, 38f, 1056f, out var click) && click.Button == 0)
			{
				InteractableEntry entry = list[click.Index];
				Queue(delegate
				{
					GameActions.SpawnInteractable(entry, count);
				});
			}
		}

		private void DrawWorldTab()
		{
			GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) });
			GUILayout.BeginVertical(Styles.Panel, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(420f),
				GUILayout.ExpandHeight(true)
			});
			GUILayout.Label("Enemies", Styles.Header, Array.Empty<GUILayoutOption>());
			bool spawnsDisabled = CombatDirector.cvDirectorCombatDisable.value;
			if (GUILayout.Toggle(spawnsDisabled, "Disable enemy spawns", Array.Empty<GUILayoutOption>()) != spawnsDisabled)
			{
				Queue(delegate
				{
					GameActions.SetEnemySpawning(spawnsDisabled);
				});
			}
			if (GUILayout.Button("Kill all enemies", Array.Empty<GUILayoutOption>()))
			{
				Queue(GameActions.KillAllEnemies);
			}
			GUILayout.Label("Teleporter", Styles.Header, Array.Empty<GUILayoutOption>());
			GUILayout.Label(TeleporterState(), Styles.Dim, Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Activate + fully charge", Array.Empty<GUILayoutOption>()))
			{
				Queue(GameActions.ChargeTeleporter);
			}
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Blue portal", Array.Empty<GUILayoutOption>()))
			{
				Queue(delegate
				{
					GameActions.RequestPortal("shop");
				});
			}
			if (GUILayout.Button("Gold portal", Array.Empty<GUILayoutOption>()))
			{
				Queue(delegate
				{
					GameActions.RequestPortal("gold");
				});
			}
			if (GUILayout.Button("Celestial portal", Array.Empty<GUILayoutOption>()))
			{
				Queue(delegate
				{
					GameActions.RequestPortal("celestial");
				});
			}
			GUILayout.EndHorizontal();
			GUILayout.Label("Time", Styles.Header, Array.Empty<GUILayoutOption>());
			float num = SliderRow("Game speed", timeScale, 0.1f, 4f);
			if (GUILayout.Button("Normal speed", Array.Empty<GUILayoutOption>()))
			{
				num = 1f;
			}
			if (num != timeScale)
			{
				timeScale = num;
				Time.timeScale = timeScale;
			}
			GUILayout.FlexibleSpace();
			GUILayout.EndVertical();
			GUILayout.BeginVertical(Styles.Panel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) });
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("Travel to stage", Styles.Header, Array.Empty<GUILayoutOption>());
			GUILayout.FlexibleSpace();
			if (GUILayout.Button("Next stage", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) }))
			{
				Queue(GameActions.NextStage);
			}
			GUILayout.EndHorizontal();
			SceneDef currentScene = SceneCatalog.GetSceneDefForCurrentScene();
			List<StageEntry> stages = Catalogs.Stages;
			Func<int, Cell> cellAt = (int i) => new Cell
			{
				Entry = stages[i],
				Selected = (Object.op_Implicit((Object)(object)currentScene) && (Object)(object)stages[i].Def == (Object)(object)currentScene),
				Dim = (Object.op_Implicit((Object)(object)Run.instance) && Object.op_Implicit((Object)(object)stages[i].Def.requiredExpansion) && !Run.instance.IsExpansionEnabled(stages[i].Def.requiredExpansion))
			};
			if (DrawGrid(stageGrid, stages.Count, cellAt, CellLayout.Text, 200f, 40f, 596f, out var click) && click.Button == 0)
			{
				StageEntry stage = stages[click.Index];
				Queue(delegate
				{
					GameActions.GoToStage(stage);
				});
			}
			GUILayout.EndVertical();
			GUILayout.EndHorizontal();
		}

		private static string TeleporterState()
		{
			TeleporterInteraction instance = TeleporterInteraction.instance;
			if (!Object.op_Implicit((Object)(object)instance))
			{
				return "No teleporter on this stage.";
			}
			if (instance.isCharged)
			{
				return "Charged.";
			}
			if (instance.isCharging && Object.op_Implicit((Object)(object)instance.holdoutZoneController))
			{
				return $"Charging: {Mathf.RoundToInt(instance.holdoutZoneController.charge * 100f)}%";
			}
			if (!instance.isIdle)
			{
				return "Starting...";
			}
			return "Not activated yet.";
		}

		private static Inventory LocalInventory()
		{
			CharacterMaster localMaster = Helpers.LocalMaster;
			if (!Object.op_Implicit((Object)(object)localMaster))
			{
				return null;
			}
			return localMaster.inventory;
		}

		private static string SearchField(string value, float width)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Invalid comparison between Unknown and I4
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			string text = GUILayout.TextField(value ?? "", 64, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(width) });
			if (string.IsNullOrEmpty(text) && (int)Event.current.type == 7)
			{
				Styles.Placeholder.Draw(GUILayoutUtility.GetLastRect(), "Search...", false, false, false, false);
			}
			return text;
		}

		private bool DrawGrid(Grid grid, int count, Func<int, Cell> cellAt, CellLayout layout, float cellWidth, float cellHeight, float width, out Click click)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: 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)
			//IL_020e: Invalid comparison between Unknown and I4
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Invalid comparison between Unknown and I4
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			click = new Click
			{
				Index = -1
			};
			Event current = Event.current;
			int num = Mathf.Max(1, Mathf.FloorToInt((width - 18f) / cellWidth));
			int num2 = (count + num - 1) / num;
			grid.Scroll = GUILayout.BeginScrollView(grid.Scroll, false, true, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) });
			Rect rect = GUILayoutUtility.GetRect((float)num * cellWidth, Mathf.Max((float)num2 * cellHeight, 1f), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
			float y = grid.Scroll.y;
			float num3 = grid.Scroll.y + ((grid.ViewHeight > 0f) ? grid.ViewHeight : 4000f);
			bool flag = current.mousePosition.y >= y && current.mousePosition.y <= num3;
			Rect rect2 = default(Rect);
			for (int i = 0; i < num2; i++)
			{
				float num4 = ((Rect)(ref rect)).y + (float)i * cellHeight;
				if (num4 + cellHeight < y || num4 > num3)
				{
					continue;
				}
				for (int j = 0; j < num; j++)
				{
					int num5 = i * num + j;
					if (num5 >= count)
					{
						break;
					}
					((Rect)(ref rect2))..ctor(((Rect)(ref rect)).x + (float)j * cellWidth + 2f, num4 + 2f, cellWidth - 4f, cellHeight - 4f);
					Cell cell = cellAt(num5);
					bool flag2 = flag && ((Rect)(ref rect2)).Contains(current.mousePosition);
					if (flag2)
					{
						hovered = cell.Entry;
						if ((int)current.type == 0)
						{
							click = new Click
							{
								Index = num5,
								Button = current.button,
								Shift = current.shift
							};
							current.Use();
						}
					}
					if ((int)current.type == 7)
					{
						DrawCell(rect2, cell, layout, flag2);
					}
				}
			}
			GUILayout.EndScrollView();
			if ((int)current.type == 7)
			{
				Rect lastRect = GUILayoutUtility.GetLastRect();
				grid.ViewHeight = ((Rect)(ref lastRect)).height;
			}
			return click.Index >= 0;
		}

		private static void DrawCell(Rect rect, Cell cell, CellLayout layout, bool hover)
		{
			//IL_000d: 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_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_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: 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_00ea: 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_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: 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_011f: 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_01e4: 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_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Expected O, but got Unknown
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: 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_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			IconEntry entry = cell.Entry;
			Texture2D whiteTexture = Texture2D.whiteTexture;
			Color color = GUI.color;
			Color color2 = entry.Color;
			GUI.color = (hover ? Styles.CellHover : Styles.CellBg);
			GUI.DrawTexture(rect, (Texture)(object)whiteTexture);
			GUI.color = new Color(color2.r, color2.g, color2.b, cell.Dim ? 0.05f : 0.15f);
			GUI.DrawTexture(rect, (Texture)(object)whiteTexture);
			GUI.color = new Color(color2.r, color2.g, color2.b, cell.Dim ? 0.3f : 1f);
			GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).yMax - 3f, ((Rect)(ref rect)).width, 3f), (Texture)(object)whiteTexture);
			GUI.color = (Color)(cell.Dim ? new Color(1f, 1f, 1f, 0.3f) : Color.white);
			switch (layout)
			{
			case CellLayout.Icon:
				if (Object.op_Implicit((Object)(object)entry.Icon))
				{
					GUI.DrawTextureWithTexCoords(Inset(rect, 5f), entry.Icon, entry.Uv, true);
				}
				else
				{
					GUI.Label(rect, entry.Name, Styles.CellText);
				}
				break;
			case CellLayout.IconLabel:
			{
				float num = Mathf.Min(((Rect)(ref rect)).width - 20f, ((Rect)(ref rect)).height - 36f);
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(((Rect)(ref rect)).center.x - num / 2f, ((Rect)(ref rect)).y + 5f, num, num);
				if (Object.op_Implicit((Object)(object)entry.Icon))
				{
					GUI.DrawTextureWithTexCoords(val, entry.Icon, entry.Uv, true);
				}
				GUI.Label(new Rect(((Rect)(ref rect)).x, ((Rect)(ref val)).yMax + 2f, ((Rect)(ref rect)).width, ((Rect)(ref rect)).yMax - ((Rect)(ref val)).yMax - 5f), entry.Name, Styles.CellLabel);
				break;
			}
			default:
				GUI.Label(rect, entry.Name, Styles.CellText);
				break;
			}
			if (!string.IsNullOrEmpty(cell.Badge))
			{
				GUIContent val2 = new GUIContent(cell.Badge);
				float x = Styles.Badge.CalcSize(val2).x;
				Rect val3 = new Rect(((Rect)(ref rect)).xMax - x - 2f, ((Rect)(ref rect)).y + 2f, x, 17f);
				GUI.color = new Color(0f, 0f, 0f, 0.75f);
				GUI.DrawTexture(val3, (Texture)(object)whiteTexture);
				GUI.color = Color.white;
				GUI.Label(val3, val2, Styles.Badge);
			}
			if (cell.Selected)
			{
				DrawBorder(rect, Styles.Accent, 2f);
			}
			else if (hover)
			{
				DrawBorder(rect, new Color(1f, 1f, 1f, 0.45f), 1f);
			}
			GUI.color = color;
		}

		private static Rect Inset(Rect rect, float amount)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			return new Rect(((Rect)(ref rect)).x + amount, ((Rect)(ref rect)).y + amount, ((Rect)(ref rect)).width - amount * 2f, ((Rect)(ref rect)).height - amount * 2f);
		}

		private static void DrawBorder(Rect rect, Color color, float thickness)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			Texture2D whiteTexture = Texture2D.whiteTexture;
			GUI.color = color;
			GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, thickness), (Texture)(object)whiteTexture);
			GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).yMax - thickness, ((Rect)(ref rect)).width, thickness), (Texture)(object)whiteTexture);
			GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, thickness, ((Rect)(ref rect)).height), (Texture)(object)whiteTexture);
			GUI.DrawTexture(new Rect(((Rect)(ref rect)).xMax - thickness, ((Rect)(ref rect)).y, thickness, ((Rect)(ref rect)).height), (Texture)(object)whiteTexture);
		}
	}
	internal static class GameActions
	{
		private const int MaxDroplets = 100;

		private static readonly Xoroshiro128Plus Rng = new Xoroshiro128Plus((ulong)DateTime.Now.Ticks);

		private static bool chargeTeleporterWhenReady;

		public static void Update()
		{
			if (chargeTeleporterWhenReady)
			{
				TeleporterInteraction instance = TeleporterInteraction.instance;
				if (!Object.op_Implicit((Object)(object)instance) || !Object.op_Implicit((Object)(object)Run.instance))
				{
					chargeTeleporterWhenReady = false;
				}
				else if (instance.isCharging)
				{
					instance.holdoutZoneController.FullyChargeHoldoutZone();
					chargeTeleporterWhenReady = false;
				}
			}
		}

		public static void GiveItem(ItemEntry item, int count)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			if (Helpers.CheckMaster(out var master))
			{
				if (Run.instance.IsItemExpansionLocked(item.Index))
				{
					Notifier.Error(item.Name + " needs a DLC that is turned off in this run.");
					return;
				}
				master.inventory.GiveItemPermanent(item.Index, count);
				Notifier.Info($"+{count} {item.Name}");
			}
		}

		public static void GiveItems(IList<ItemEntry> items, int count)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			if (!Helpers.CheckMaster(out var master))
			{
				return;
			}
			int num = 0;
			foreach (ItemEntry item in items)
			{
				if (!Run.instance.IsItemExpansionLocked(item.Index))
				{
					master.inventory.GiveItemPermanent(item.Index, count);
					num++;
				}
			}
			Notifier.Info($"Gave {count}x of {num} items.");
		}

		public static void RemoveItem(ItemEntry item, int count)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			if (Helpers.CheckMaster(out var master))
			{
				int itemCountPermanent = master.inventory.GetItemCountPermanent(item.Index);
				if (itemCountPermanent <= 0)
				{
					Notifier.Error("You don't have " + item.Name + ".");
					return;
				}
				int num = Math.Min(count, itemCountPermanent);
				master.inventory.RemoveItemPermanent(item.Index, num);
				Notifier.Info($"-{num} {item.Name}");
			}
		}

		public static void ClearInventory()
		{
			if (Helpers.CheckMaster(out var master))
			{
				master.inventory.CleanInventory();
				Notifier.Info("Inventory cleared.");
			}
		}

		public static void SetEquipment(EquipmentEntry equipment)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			if (Helpers.CheckMaster(out var master))
			{
				if (Run.instance.IsEquipmentExpansionLocked(equipment.Index))
				{
					Notifier.Error(equipment.Name + " needs a DLC that is turned off in this run.");
					return;
				}
				master.inventory.SetEquipmentIndex(equipment.Index, false);
				Notifier.Info("Equipment: " + equipment.Name);
			}
		}

		public static void RemoveEquipment()
		{
			if (Helpers.CheckMaster(out var master))
			{
				master.inventory.SetEquipmentIndex((EquipmentIndex)(-1), true);
				Notifier.Info("Equipment removed.");
			}
		}

		public static void DropPickup(PickupIndex pickup, string name, int count)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: 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_00b5: 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_00bb: 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_00d9: 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_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: 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_00f2: 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)
			if (!Helpers.CheckBody(out var body))
			{
				return;
			}
			if (pickup == PickupIndex.none)
			{
				Notifier.Error(name + " can't be dropped.");
				return;
			}
			count = Math.Min(count, 100);
			Vector3 val = (Object.op_Implicit((Object)(object)body.inputBank) ? body.inputBank.aimDirection : ((Component)body).transform.forward);
			val.y = 0f;
			val = ((((Vector3)(ref val)).sqrMagnitude > 0.001f) ? ((Vector3)(ref val)).normalized : Vector3.forward);
			Vector3 val2 = body.corePosition + Vector3.up * 1.5f;
			for (int i = 0; i < count; i++)
			{
				Vector3 val3 = Quaternion.AngleAxis(360f * (float)i / (float)count, Vector3.up) * val;
				float num = ((count > 1) ? (4f + (float)count * 0.15f) : 5f);
				PickupDropletController.CreatePickupDroplet(new UniquePickup(pickup), val2, Vector3.up * 20f + val3 * num, false);
			}
			Notifier.Info($"Dropped {count}x {name}");
		}

		public static void GiveMoney(uint amount)
		{
			if (Helpers.CheckMaster(out var master))
			{
				master.GiveMoney(amount);
				Notifier.Info($"+${amount}");
			}
		}

		public static void GiveLunarCoins(uint amount)
		{
			if (Helpers.CheckServer())
			{
				LocalUser localUser = Helpers.LocalUser;
				NetworkUser val = ((localUser != null) ? localUser.currentNetworkUser : null);
				if (!Object.op_Implicit((Object)(object)val))
				{
					Notifier.Error("No network user found.");
					return;
				}
				val.AwardLunarCoins(amount);
				Notifier.Info($"+{amount} lunar coins");
			}
		}

		public static void AddLevels(uint levels)
		{
			if (Helpers.CheckServer() && Object.op_Implicit((Object)(object)TeamManager.instance))
			{
				TeamManager instance = TeamManager.instance;
				ulong experienceForLevel = TeamManager.GetExperienceForLevel(instance.GetTeamLevel((TeamIndex)1) + levels);
				ulong teamExperience = instance.GetTeamExperience((TeamIndex)1);
				if (experienceForLevel > teamExperience)
				{
					instance.GiveTeamExperience((TeamIndex)1, experienceForLevel - teamExperience);
				}
				Notifier.Info($"Level {instance.GetTeamLevel((TeamIndex)1)}");
			}
		}

		public static void Heal()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (Helpers.CheckBody(out var body) && Object.op_Implicit((Object)(object)body.healthComponent))
			{
				body.healthComponent.HealFraction(1f, default(ProcChainMask));
				body.healthComponent.RechargeShieldFull();
				Notifier.Info("Fully healed.");
			}
		}

		public static void Revive()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			if (!Helpers.CheckMaster(out var master))
			{
				return;
			}
			CharacterBody body = master.GetBody();
			if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.healthComponent) && body.healthComponent.alive)
			{
				Notifier.Info("You're already alive.");
				return;
			}
			if (master.deathFootPosition != Vector3.zero)
			{
				master.Respawn(master.deathFootPosition, Quaternion.identity, false);
			}
			else if (Object.op_Implicit((Object)(object)Stage.instance))
			{
				Stage.instance.RespawnCharacter(master);
			}
			Notifier.Info("Revived.");
		}

		public static void ChangeSurvivor(SurvivorEntry survivor)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			if (Helpers.CheckMaster(out var master))
			{
				CharacterBody body = master.GetBody();
				master.bodyPrefab = survivor.Def.bodyPrefab;
				if (Object.op_Implicit((Object)(object)body))
				{
					master.Respawn(body.footPosition, ((Component)body).transform.rotation, false);
				}
				else if (Object.op_Implicit((Object)(object)Stage.instance))
				{
					Stage.instance.RespawnCharacter(master);
				}
				Notifier.Info("You are now " + survivor.Name + ".");
			}
		}

		public static void SpawnMonster(MonsterEntry monster, int count, bool ally, EliteDef elite)
		{
			//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_001a: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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_0083: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			if (!Helpers.CheckBody(out var body))
			{
				return;
			}
			Vector3 spawnPoint = Helpers.GetSpawnPoint(body);
			int num = 0;
			for (int i = 0; i < count; i++)
			{
				Vector3 val = spawnPoint;
				if (count > 1)
				{
					Vector2 val2 = Random.insideUnitCircle * (2f + (float)count * 0.4f);
					val += new Vector3(val2.x, 0f, val2.y);
				}
				CharacterMaster val3 = new MasterSummon
				{
					masterPrefab = ((Component)monster.MasterPrefab).gameObject,
					position = val,
					rotation = Helpers.FacePlayer(val, body),
					teamIndexOverride = (TeamIndex)(ally ? 1 : 2),
					summonerBodyObject = (ally ? ((Component)body).gameObject : null),
					ignoreTeamMemberLimit = true,
					useAmbientLevel = true
				}.Perform();
				if (Object.op_Implicit((Object)(object)val3))
				{
					num++;
					if (Object.op_Implicit((Object)(object)elite) && Object.op_Implicit((Object)(object)val3.inventory))
					{
						val3.inventory.SetEquipmentIndex(elite.eliteEquipmentDef.equipmentIndex, false);
						val3.inventory.GiveItemPermanent(Items.BoostHp, Mathf.RoundToInt((elite.healthBoostCoefficient - 1f) * 10f));
						val3.inventory.GiveItemPermanent(Items.BoostDamage, Mathf.RoundToInt((elite.damageBoostCoefficient - 1f) * 10f));
					}
				}
			}
			if (num == 0)
			{
				Notifier.Error("Could not spawn " + monster.Name + ".");
			}
			else
			{
				Notifier.Info($"Spawned {num}x {monster.Name}" + (ally ? " (ally)" : ""));
			}
		}

		public static void SpawnInteractable(InteractableEntry entry, int count)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Expected O, but got Unknown
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Expected O, but got Unknown
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: 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_006e: 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_007d: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//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_00c7: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
			if (!Helpers.CheckBody(out var body))
			{
				return;
			}
			InteractableSpawnCard val = Catalogs.LoadCard(entry);
			if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)((SpawnCard)val).prefab))
			{
				Notifier.Error("Could not load " + entry.Name + ".");
				return;
			}
			Vector3 spawnPoint = Helpers.GetSpawnPoint(body);
			int num = 0;
			RaycastHit val4 = default(RaycastHit);
			for (int i = 0; i < count; i++)
			{
				Vector3 val2 = spawnPoint;
				if (count > 1)
				{
					float num2 = 360f * (float)i / (float)count;
					val2 += Quaternion.AngleAxis(num2, Vector3.up) * Vector3.forward * (2.5f + (float)count * 0.5f);
					Vector3 val3 = val2 + Vector3.up * 5f;
					Vector3 down = Vector3.down;
					LayerIndex world = LayerIndex.world;
					if (Physics.Raycast(val3, down, ref val4, 50f, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask), (QueryTriggerInteraction)1))
					{
						val2 = ((RaycastHit)(ref val4)).point;
					}
				}
				DirectorPlacementRule val5 = new DirectorPlacementRule
				{
					placementMode = (PlacementMode)0,
					position = val2
				};
				DirectorSpawnRequest val6 = new DirectorSpawnRequest((SpawnCard)(object)val, val5, Rng);
				if (((SpawnCard)val).DoSpawn(val2, Helpers.FacePlayer(val2, body), val6).success)
				{
					num++;
				}
			}
			if (num == 0)
			{
				Notifier.Error("Could not spawn " + entry.Name + ".");
			}
			else
			{
				Notifier.Info($"Spawned {num}x {entry.Name}");
			}
		}

		public static void KillAllEnemies()
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			if (!Helpers.CheckServer())
			{
				return;
			}
			int num = 0;
			TeamIndex[] array = new TeamIndex[3];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			TeamIndex[] array2 = (TeamIndex[])(object)array;
			for (int i = 0; i < array2.Length; i++)
			{
				foreach (TeamComponent item in new List<TeamComponent>(TeamComponent.GetTeamMembers(array2[i])))
				{
					CharacterBody val = (Object.op_Implicit((Object)(object)item) ? item.body : null);
					if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.healthComponent) && val.healthComponent.alive)
					{
						val.healthComponent.Suicide((GameObject)null, (GameObject)null, default(DamageTypeCombo));
						num++;
					}
				}
			}
			Notifier.Info($"Killed {num} enemies.");
		}

		public static void ChargeTeleporter()
		{
			if (!Helpers.CheckBody(out var body))
			{
				return;
			}
			TeleporterInteraction instance = TeleporterInteraction.instance;
			if (!Object.op_Implicit((Object)(object)instance))
			{
				Notifier.Error("There's no teleporter on this stage.");
				return;
			}
			if (instance.isCharged)
			{
				Notifier.Info("The teleporter is already charged.");
				return;
			}
			if (instance.isIdle)
			{
				Interactor component = ((Component)body).GetComponent<Interactor>();
				instance.OnInteractionBegin(component);
			}
			chargeTeleporterWhenReady = true;
			Notifier.Info("Teleporter charged. Kill the boss to finish it.");
		}

		public static void RequestPortal(string portal)
		{
			if (!Helpers.CheckServer())
			{
				return;
			}
			TeleporterInteraction instance = TeleporterInteraction.instance;
			if (!Object.op_Implicit((Object)(object)instance))
			{
				Notifier.Error("There's no teleporter on this stage.");
				return;
			}
			switch (portal)
			{
			case "shop":
				instance.shouldAttemptToSpawnShopPortal = true;
				break;
			case "gold":
				instance.shouldAttemptToSpawnGoldshoresPortal = true;
				break;
			case "celestial":
				instance.shouldAttemptToSpawnMSPortal = true;
				break;
			}
			Notifier.Info("The portal will open when the teleporter finishes.");
		}

		public static void SetEnemySpawning(bool enabled)
		{
			CombatDirector.cvDirectorCombatDisable.SetBool(!enabled);
			Notifier.Info(enabled ? "Enemy spawns on." : "Enemy spawns off.");
		}

		public static void GoToStage(StageEntry stage)
		{
			if (Helpers.CheckServer())
			{
				ExpansionDef requiredExpansion = stage.Def.requiredExpansion;
				if (Object.op_Implicit((Object)(object)requiredExpansion) && !Run.instance.IsExpansionEnabled(requiredExpansion))
				{
					Notifier.Error(stage.Name + " needs a DLC that is turned off in this run.");
					return;
				}
				Run.instance.AdvanceStage(stage.Def);
				Notifier.Info("Travelling to " + stage.Name + "...");
			}
		}

		public static void NextStage()
		{
			if (Helpers.CheckServer())
			{
				SceneDef nextStageScene = Run.instance.nextStageScene;
				if (!Object.op_Implicit((Object)(object)nextStageScene))
				{
					Notifier.Error("The game hasn't picked a next stage.");
					return;
				}
				Run.instance.AdvanceStage(nextStageScene);
				Notifier.Info("Travelling to " + Helpers.Lang(nextStageScene.nameToken, nextStageScene.cachedName) + "...");
			}
		}
	}
	internal static class Helpers
	{
		private static readonly Regex TagRegex = new Regex("<[^>]*>", RegexOptions.Compiled);

		public static LocalUser LocalUser => LocalUserManager.GetFirstLocalUser();

		public static CharacterMaster LocalMaster
		{
			get
			{
				LocalUser localUser = LocalUser;
				if (localUser == null)
				{
					return null;
				}
				return localUser.cachedMaster;
			}
		}

		public static CharacterBody LocalBody
		{
			get
			{
				CharacterMaster localMaster = LocalMaster;
				if (!Object.op_Implicit((Object)(object)localMaster))
				{
					return null;
				}
				return localMaster.GetBody();
			}
		}

		public static bool CheckServer()
		{
			if (!Object.op_Implicit((Object)(object)Run.instance))
			{
				Notifier.Error("Start a run first.");
				return false;
			}
			if (!NetworkServer.active)
			{
				Notifier.Error("Only the host (or single-player) can do this.");
				return false;
			}
			return true;
		}

		public static bool CheckMaster(out CharacterMaster master)
		{
			master = null;
			if (!CheckServer())
			{
				return false;
			}
			master = LocalMaster;
			if (!Object.op_Implicit((Object)(object)master) || !Object.op_Implicit((Object)(object)master.inventory))
			{
				Notifier.Error("You don't have a character in this run.");
				return false;
			}
			return true;
		}

		public static bool CheckBody(out CharacterBody body)
		{
			body = null;
			if (!CheckServer())
			{
				return false;
			}
			body = LocalBody;
			if (!Object.op_Implicit((Object)(object)body))
			{
				Notifier.Error("You need to be alive for this.");
				return false;
			}
			return true;
		}

		public static Vector3 GetSpawnPoint(CharacterBody body)
		{
			//IL_002b: 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_0019: 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_0030: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			Ray val = (Ray)(Object.op_Implicit((Object)(object)body.inputBank) ? body.inputBank.GetAimRay() : new Ray(body.corePosition, ((Component)body).transform.forward));
			Ray val2 = val;
			LayerIndex world = LayerIndex.world;
			RaycastHit val4 = default(RaycastHit);
			Vector3 val3 = (Physics.Raycast(val2, ref val4, 1000f, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask), (QueryTriggerInteraction)1) ? (((RaycastHit)(ref val4)).point + ((RaycastHit)(ref val4)).normal * 0.5f) : ((Ray)(ref val)).GetPoint(20f));
			Vector3 val5 = val3 + Vector3.up;
			Vector3 down = Vector3.down;
			world = LayerIndex.world;
			RaycastHit val6 = default(RaycastHit);
			if (Physics.Raycast(val5, down, ref val6, 500f, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask), (QueryTriggerInteraction)1))
			{
				val3 = ((RaycastHit)(ref val6)).point;
			}
			return val3;
		}

		public static Quaternion FacePlayer(Vector3 from, CharacterBody body)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = body.footPosition - from;
			val.y = 0f;
			if (!(((Vector3)(ref val)).sqrMagnitude > 0.01f))
			{
				return Quaternion.identity;
			}
			return Quaternion.LookRotation(val);
		}

		public static string Lang(string token, string fallback)
		{
			if (string.IsNullOrEmpty(token))
			{
				return fallback;
			}
			string text = Language.GetString(token);
			if (!string.IsNullOrEmpty(text) && !(text == token))
			{
				return text;
			}
			return fallback;
		}

		public static Rect SpriteUv(Sprite sprite)
		{
			//IL_0067: 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_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			Texture texture = (Texture)(object)sprite.texture;
			try
			{
				Rect textureRect = sprite.textureRect;
				return new Rect(((Rect)(ref textureRect)).x / (float)texture.width, ((Rect)(ref textureRect)).y / (float)texture.height, ((Rect)(ref textureRect)).width / (float)texture.width, ((Rect)(ref textureRect)).height / (float)texture.height);
			}
			catch (Exception)
			{
				return new Rect(0f, 0f, 1f, 1f);
			}
		}

		public static string StripTags(string text)
		{
			if (!string.IsNullOrEmpty(text))
			{
				return TagRegex.Replace(text, "");
			}
			return text;
		}

		public static string Humanize(string name)
		{
			StringBuilder stringBuilder = new StringBuilder(name.Length + 8);
			for (int i = 0; i < name.Length; i++)
			{
				char c = name[i];
				if (i > 0)
				{
					char c2 = name[i - 1];
					bool num = char.IsUpper(c) && char.IsLower(c2);
					bool flag = char.IsDigit(c) && char.IsLetter(c2);
					if (num || flag)
					{
						stringBuilder.Append(' ');
					}
				}
				stringBuilder.Append(c);
			}
			return stringBuilder.ToString();
		}
	}
	internal static class Notifier
	{
		public static string Message { get; private set; }

		public static bool IsError { get; private set; }

		public static float ShownAt { get; private set; } = -100f;

		public static bool IsRecent
		{
			get
			{
				if (Message != null)
				{
					return Time.unscaledTime - ShownAt < 5f;
				}
				return false;
			}
		}

		public static void Info(string text)
		{
			Set(text, error: false);
			NotCreativePlugin.Log.LogInfo((object)text);
		}

		public static void Error(string text)
		{
			Set(text, error: true);
			NotCreativePlugin.Log.LogWarning((object)text);
		}

		private static void Set(string text, bool error)
		{
			Message = text;
			IsError = error;
			ShownAt = Time.unscaledTime;
		}
	}
	[BepInPlugin("Jirka.NotCreative", "NotCreative", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class NotCreativePlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "Jirka.NotCreative";

		public const string PluginName = "NotCreative";

		public const string PluginVersion = "1.0.0";

		internal static ManualLogSource Log;

		internal static ConfigEntry<KeyboardShortcut> MenuKey;

		internal static ConfigEntry<float> UiScale;

		private PlayerCheats cheats;

		private CreativeMenu menu;

		private Hook isUIFocusedHook;

		private void Awake()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected O, but got Unknown
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Expected O, but got Unknown
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			MenuKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "Menu key", new KeyboardShortcut((KeyCode)283, Array.Empty<KeyCode>()), "Opens and closes the NotCreative menu.");
			UiScale = ((BaseUnityPlugin)this).Config.Bind<float>("General", "UI scale", 1f, new ConfigDescription("Menu size. 1 = sized for 1080p and scaled with your resolution.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2.5f), Array.Empty<object>()));
			cheats = new PlayerCheats();
			menu = new CreativeMenu(cheats);
			isUIFocusedHook = new Hook((MethodBase)typeof(LocalUser).GetProperty("isUIFocused").GetGetMethod(), typeof(NotCreativePlugin).GetMethod("LocalUser_get_isUIFocused", BindingFlags.Static | BindingFlags.NonPublic));
			RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(cheats.OnGetStatCoefficients);
		}

		private void OnDestroy()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			Hook obj = isUIFocusedHook;
			if (obj != null)
			{
				obj.Dispose();
			}
			RecalculateStatsAPI.GetStatCoefficients -= new StatHookEventHandler(cheats.OnGetStatCoefficients);
			menu.Close();
			cheats.Disable();
		}

		private void Update()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			KeyboardShortcut value = MenuKey.Value;
			if (((KeyboardShortcut)(ref value)).IsDown())
			{
				menu.Toggle();
			}
			menu.Update();
			cheats.Update();
			GameActions.Update();
		}

		private void FixedUpdate()
		{
			cheats.FixedUpdate();
		}

		private void LateUpdate()
		{
			cheats.LateUpdate();
		}

		private void OnGUI()
		{
			menu.OnGUI();
		}

		private static bool LocalUser_get_isUIFocused(Func<LocalUser, bool> orig, LocalUser self)
		{
			if (!CreativeMenu.IsOpen)
			{
				return orig(self);
			}
			return true;
		}
	}
	internal sealed class PlayerCheats
	{
		public bool GodMode;

		public bool NoCooldowns;

		public bool Fly;

		public bool Noclip;

		public float FlySpeed = 2f;

		public float MoveSpeedMult = 1f;

		public float DamageMult = 1f;

		public float AttackSpeedMult = 1f;

		private CharacterBody godBody;

		private CharacterBody flyBody;

		private CharacterMotor flyMotor;

		private float savedAirControl;

		private bool noclipApplied;

		public void Update()
		{
			CharacterBody localBody = Helpers.LocalBody;
			UpdateGodMode(localBody);
			if (NoCooldowns && Object.op_Implicit((Object)(object)localBody))
			{
				RefreshCooldowns(localBody);
			}
			UpdateFlight(localBody);
		}

		public void FixedUpdate()
		{
			if (Object.op_Implicit((Object)(object)flyMotor) && Object.op_Implicit((Object)(object)flyBody))
			{
				flyMotor.jumpCount = flyBody.maxJumpCount;
			}
		}

		public void LateUpdate()
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)flyMotor) && Object.op_Implicit((Object)(object)flyBody) && Object.op_Implicit((Object)(object)flyBody.inputBank) && !CreativeMenu.IsOpen)
			{
				InputBankTest inputBank = flyBody.inputBank;
				float num = 0f;
				if (inputBank.jump.down)
				{
					num += 1f;
				}
				if (Input.GetKey((KeyCode)306))
				{
					num -= 1f;
				}
				Vector3 val = inputBank.moveVector + Vector3.up * num;
				if (((Vector3)(ref val)).sqrMagnitude > 1f)
				{
					((Vector3)(ref val)).Normalize();
				}
				inputBank.moveVector = val * FlySpeed;
			}
		}

		public void Disable()
		{
			GodMode = false;
			Fly = false;
			Noclip = false;
			UpdateGodMode(Helpers.LocalBody);
			RemoveFlight();
		}

		public void ResetStats()
		{
			MoveSpeedMult = 1f;
			DamageMult = 1f;
			AttackSpeedMult = 1f;
			MarkStatsDirty();
		}

		public void MarkStatsDirty()
		{
			CharacterBody localBody = Helpers.LocalBody;
			if (Object.op_Implicit((Object)(object)localBody))
			{
				localBody.MarkAllStatsDirty();
			}
		}

		public void OnGetStatCoefficients(CharacterBody body, StatHookEventArgs args)
		{
			if (Object.op_Implicit((Object)(object)body.master) && !((Object)(object)body.master != (Object)(object)Helpers.LocalMaster))
			{
				args.moveSpeedMultAdd += MoveSpeedMult - 1f;
				args.damageMultAdd += DamageMult - 1f;
				args.attackSpeedMultAdd += AttackSpeedMult - 1f;
			}
		}

		private void UpdateGodMode(CharacterBody body)
		{
			if (!NetworkServer.active)
			{
				return;
			}
			if (GodMode && Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.healthComponent))
			{
				body.healthComponent.godMode = true;
				godBody = body;
			}
			else if (Object.op_Implicit((Object)(object)godBody))
			{
				if (Object.op_Implicit((Object)(object)godBody.healthComponent))
				{
					godBody.healthComponent.godMode = false;
				}
				godBody = null;
			}
		}

		private static void RefreshCooldowns(CharacterBody body)
		{
			if (body.hasEffectiveAuthority && Object.op_Implicit((Object)(object)body.skillLocator))
			{
				GenericSkill[] allSkills = body.skillLocator.AllSkills;
				foreach (GenericSkill val in allSkills)
				{
					if (Object.op_Implicit((Object)(object)val) && val.stock < val.maxStock)
					{
						val.stock = val.maxStock;
						val.rechargeStopwatch = 0f;
					}
				}
			}
			if (NetworkServer.active && Object.op_Implicit((Object)(object)body.inventory) && Object.op_Implicit((Object)(object)body.equipmentSlot))
			{
				float cooldownTimer = body.equipmentSlot.cooldownTimer;
				if (cooldownTimer > 0.05f && !float.IsInfinity(cooldownTimer))
				{
					body.inventory.DeductActiveEquipmentCooldown(cooldownTimer + 1f);
				}
			}
		}

		private void UpdateFlight(CharacterBody body)
		{
			CharacterMotor val = ((Object.op_Implicit((Object)(object)body) && body.hasEffectiveAuthority) ? body.characterMotor : null);
			bool flag = (Fly || Noclip) && Object.op_Implicit((Object)(object)val);
			bool flag2 = flyMotor != null;
			if (flag2 && (!flag || (Object)(object)flyMotor != (Object)(object)val))
			{
				RemoveFlight();
				flag2 = false;
			}
			if (flag && !flag2)
			{
				ApplyFlight(body, val);
			}
			if (Object.op_Implicit((Object)(object)flyMotor))
			{
				SetNoclip(Noclip);
			}
		}

		private void ApplyFlight(CharacterBody body, CharacterMotor motor)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result ty