Decompiled source of Starting Items v0.4.0

plugins/StartingItems/StartingItems.dll

Decompiled 7 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using ItemStringParser;
using Microsoft.CodeAnalysis;
using R2API.Utils;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
using RoR2.UI;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("StartingItems")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.4.0.0")]
[assembly: AssemblyInformationalVersion("0.4.0")]
[assembly: AssemblyProduct("StartingItems")]
[assembly: AssemblyTitle("StartingItems")]
[assembly: AssemblyVersion("0.4.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 StartingItems
{
	[BepInPlugin("local.ror2.startingitems", "Starting Items", "0.4.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public sealed class Plugin : BaseUnityPlugin
	{
		private sealed class EditorEntry
		{
			public string Name;

			public string InternalName;

			public string Tier;

			public string Description;

			public int TierOrder;

			public bool Equipment;

			public bool Curio;

			public Sprite Icon;

			public PickupIndex Pickup;

			public ConfigEntry<int> Count;
		}

		private readonly List<EditorEntry> editorEntries = new List<EditorEntry>();

		private readonly List<AsyncOperationHandle<Sprite>> iconHandles = new List<AsyncOperationHandle<Sprite>>();

		private ConfigEntry<KeyboardShortcut> editorKey;

		private ConfigEntry<bool> migrated;

		private bool editorOpen;

		private bool dirty;

		private bool previousSave;

		private bool pauseOwned;

		private float saveAt;

		private float priorTimeScale;

		private string search = "";

		private string tierFilter = "All rarities";

		private string status = "";

		private string goldDraft = "";

		private int browserTab;

		private int sortMode;

		private string category = "All items";

		private string stepDraft = "1";

		private int quantityStep = 1;

		private bool showDetails;

		private EditorEntry quantityDraftEntry;

		private string quantityDraft = "";

		private bool descending;

		private bool selectedOnly;

		private bool confirmClear;

		private Vector2 browserScroll;

		private EditorEntry detail;

		private Dictionary<ConfigEntryBase, object> undo;

		private List<EditorEntry> visibleEntries = new List<EditorEntry>();

		private EditorEntry[] selectedEntries = Array.Empty<EditorEntry>();

		private bool refreshList = true;

		private GUIStyle windowStyle;

		private GUIStyle titleStyle;

		private GUIStyle noteStyle;

		private GUIStyle nameStyle;

		private GUIStyle buttonStyle;

		private GUIStyle fieldStyle;

		private Texture2D windowPixel;

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

		private GUIStyle selectedButton;

		private GUIStyle centeredName;

		private GUIStyle centeredTier;

		private GUIStyle quantityStyle;

		private GUIStyle scrollStyle;

		private GUIStyle thumbStyle;

		private Vector2 detailScroll;

		private static readonly Color Accent = new Color(0.66f, 0.83f, 0.77f);

		private static readonly Color Muted = new Color(0.62f, 0.67f, 0.72f);

		private static readonly Color CardColor = new Color(0.12f, 0.145f, 0.17f);

		private static readonly string[] Categories = new string[15]
		{
			"All items", "White", "Green", "Red", "Boss", "Lunar", "Void", "Meals", "Hallowed", "Hexes",
			"Pages", "Other", "Equipment", "Curios", "Random tiers"
		};

		private MPEventSystem cursorSystem;

		private bool priorNavigation;

		private GameObject priorSelection;

		private CanvasGroup softwareCursor;

		private bool addedCursorGroup;

		private float priorCursorAlpha;

		private GameObject inputShield;

		private int editorClosedFrame = -1;

		private static readonly Color TextColor = new Color(0.9f, 0.92f, 0.94f);

		public const string Id = "local.ror2.startingitems";

		private static Plugin instance;

		private ConfigEntry<bool> modEnabled;

		private ConfigEntry<bool> simple;

		private ConfigEntry<bool> advanced;

		private ConfigEntry<bool> cashEnabled;

		private ConfigEntry<int> cash;

		private ConfigEntry<string> advancedList;

		private ConfigEntryBase equipment;

		private readonly Dictionary<ItemTier, ConfigEntryBase> selections = new Dictionary<ItemTier, ConfigEntryBase>();

		private readonly Dictionary<ItemTier, Dictionary<int, int>> catalogIndices = new Dictionary<ItemTier, Dictionary<int, int>>();

		private Dictionary<int, int> equipmentIndices;

		private readonly Dictionary<ItemTier, ConfigEntry<int>> amounts = new Dictionary<ItemTier, ConfigEntry<int>>();

		private readonly HashSet<CharacterMaster> granted = new HashSet<CharacterMaster>();

		private Harmony hooks;

		private bool ready;

		private void InitializeEditor()
		{
			//IL_001b: 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_0060: Expected O, but got Unknown
			editorKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("00 Start here", "Editor shortcut", new KeyboardShortcut((KeyCode)287, Array.Empty<KeyCode>()), "Open or close the visual loadout editor.");
			migrated = ((BaseUnityPlugin)this).Config.Bind<bool>("Internal", "Visual editor migration complete", false, "Preserve the older tier selectors as individual item quantities once.");
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(editorKey));
			previousSave = ((BaseUnityPlugin)this).Config.SaveOnConfigSet;
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = false;
			((BaseUnityPlugin)this).Config.SettingChanged += EditorConfigChanged;
			SceneManager.activeSceneChanged += EditorSceneChanged;
		}

		private void EditorConfigChanged(object sender, SettingChangedEventArgs args)
		{
			dirty = true;
			saveAt = Time.unscaledTime + 0.5f;
			refreshList = true;
		}

		private void SaveEditor()
		{
			try
			{
				((BaseUnityPlugin)this).Config.Save();
				dirty = false;
			}
			catch (Exception ex)
			{
				status = "Could not save; retrying.";
				((BaseUnityPlugin)this).Logger.LogWarning((object)ex.Message);
				saveAt = Time.unscaledTime + 5f;
			}
		}

		private static string Plain(string text)
		{
			return Regex.Replace(text ?? "", "<[^>]*>", "");
		}

		private void BuildEditorCatalog()
		{
			//IL_0000: 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_0070: 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_0080: Expected I4, but got Unknown
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			foreach (ItemDef item in ((IEnumerable<ItemDef>)(object)ItemCatalog.allItemDefs).Where(IsSelectableItem))
			{
				AddEntry(((Object)item).name, EditorItemName(item), FriendlyTier(item.tier), (int)item.tier, isEquipment: false, item.GetIcon(), item.GetIconReference(), Language.GetString(item.descriptionToken), PickupCatalog.FindPickupIndex(item.itemIndex));
			}
			foreach (EquipmentDef item2 in ((IEnumerable<EquipmentIndex>)(object)EquipmentCatalog.allEquipment).Select((Func<EquipmentIndex, EquipmentDef>)EquipmentCatalog.GetEquipmentDef).Where(IsSelectableEquipment))
			{
				AddEntry(((Object)item2).name, Name(item2.nameToken, ((Object)item2).name), item2.isLunar ? "Lunar equipment" : "Equipment", 100, isEquipment: true, item2.GetIcon(), item2.GetIconReference(), Language.GetString(item2.descriptionToken), PickupCatalog.FindPickupIndex(item2.equipmentIndex));
			}
			foreach (KeyItemDef item3 in KeyItemCatalog.allKeyItemDefs.Where((KeyItemDef d) => Object.op_Implicit((Object)(object)d) && !d.hidden && PickupCatalog.FindPickupIndex(d.keyItemIndex) != PickupIndex.none))
			{
				AddEntry(((Object)item3).name, Name(item3.nameToken, ((Object)item3).name), "Curio", 2000, isEquipment: false, item3.GetIcon(), item3.GetIconReference(), Language.GetString(item3.descriptionToken), PickupCatalog.FindPickupIndex(item3.keyItemIndex), isCurio: true);
			}
			if (!migrated.Value)
			{
				foreach (KeyValuePair<ItemTier, ConfigEntryBase> selection in selections)
				{
					int index = catalogIndices[selection.Key][Convert.ToInt32(selection.Value.BoxedValue)];
					if (index >= 0)
					{
						EditorEntry editorEntry = editorEntries.FirstOrDefault((EditorEntry e) => !e.Equipment && e.Pickup == PickupCatalog.FindPickupIndex((ItemIndex)index));
						if (editorEntry != null)
						{
							editorEntry.Count.Value = Mathf.Clamp(editorEntry.Count.Value + amounts[selection.Key].Value, 0, 1000);
							selection.Value.BoxedValue = Enum.ToObject(selection.Value.SettingType, 0);
						}
					}
				}
				int indexEquip = equipmentIndices[Convert.ToInt32(equipment.BoxedValue)];
				if (indexEquip >= 0)
				{
					EditorEntry editorEntry2 = editorEntries.FirstOrDefault((EditorEntry e) => e.Equipment && e.Pickup == PickupCatalog.FindPickupIndex((EquipmentIndex)indexEquip));
					if (editorEntry2 != null)
					{
						editorEntry2.Count.Value = Math.Max(1, editorEntry2.Count.Value);
						equipment.BoxedValue = Enum.ToObject(equipment.SettingType, 0);
					}
				}
				migrated.Value = true;
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Visual editor catalog: " + editorEntries.Count + " items and equipment."));
		}

		private static string EditorItemName(ItemDef definition)
		{
			string text = Name(definition.nameToken, ((Object)definition).name);
			if (!definition.isConsumed || text.IndexOf("consumed", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("broken", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				return text;
			}
			return text + " (Consumed)";
		}

		private void AddEntry(string internalName, string name, string tier, int order, bool isEquipment, Sprite icon, AssetReferenceT<Sprite> iconReference, string description, PickupIndex pickup, bool isCurio = false)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: 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)
			EditorEntry entry = new EditorEntry
			{
				InternalName = internalName,
				Name = name,
				Tier = tier,
				TierOrder = order,
				Equipment = isEquipment,
				Curio = isCurio,
				Icon = icon,
				Description = Plain(description),
				Pickup = pickup,
				Count = ((BaseUnityPlugin)this).Config.Bind<int>(isCurio ? "32 Visual curios" : (isEquipment ? "31 Visual equipment" : "30 Visual items"), internalName, 0, new ConfigDescription("Starting copies of " + name + ". Stable internal item name; 0 disables.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, isCurio ? 1 : 1000), Array.Empty<object>()))
			};
			editorEntries.Add(entry);
			if (Object.op_Implicit((Object)(object)icon) || iconReference == null || !((AssetReference)iconReference).RuntimeKeyIsValid())
			{
				return;
			}
			AsyncOperationHandle<Sprite> item = Addressables.LoadAssetAsync<Sprite>(((AssetReference)iconReference).RuntimeKey);
			iconHandles.Add(item);
			item.Completed += delegate(AsyncOperationHandle<Sprite> result)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Invalid comparison between Unknown and I4
				if ((int)result.Status == 1)
				{
					entry.Icon = result.Result;
				}
			};
		}

		private List<EditorEntry> FilterEntries()
		{
			IEnumerable<EditorEntry> source = editorEntries.Where((EditorEntry e) => (browserTab != 3) ? ((browserTab != 1) ? (!e.Equipment && !e.Curio) : e.Equipment) : e.Curio);
			if (browserTab == 0 && category != "All items")
			{
				source = source.Where((EditorEntry e) => CategoryMatches(e.Tier, category));
			}
			if (tierFilter != "All rarities")
			{
				source = source.Where((EditorEntry e) => e.Tier == tierFilter);
			}
			if (selectedOnly)
			{
				source = source.Where((EditorEntry e) => e.Count.Value > 0);
			}
			string term = search.Trim();
			if (term.Length > 0)
			{
				source = source.Where((EditorEntry e) => e.Name.IndexOf(term, StringComparison.OrdinalIgnoreCase) >= 0 || e.InternalName.IndexOf(term, StringComparison.OrdinalIgnoreCase) >= 0 || e.Description.IndexOf(term, StringComparison.OrdinalIgnoreCase) >= 0);
			}
			return (sortMode switch
			{
				1 => descending ? source.OrderByDescending((EditorEntry e) => e.TierOrder) : source.OrderBy((EditorEntry e) => e.TierOrder), 
				2 => descending ? source.OrderByDescending((EditorEntry e) => e.Count.Value) : source.OrderBy((EditorEntry e) => e.Count.Value), 
				_ => descending ? source.OrderByDescending<EditorEntry, string>((EditorEntry e) => e.Name, StringComparer.OrdinalIgnoreCase) : source.OrderBy<EditorEntry, string>((EditorEntry e) => e.Name, StringComparer.OrdinalIgnoreCase), 
			}).ThenBy<EditorEntry, string>((EditorEntry e) => e.Name, StringComparer.OrdinalIgnoreCase).ToList();
		}

		private void ChangeCount(EditorEntry entry, int delta)
		{
			entry.Count.Value = Mathf.Clamp(entry.Count.Value + delta, 0, entry.Curio ? 1 : 1000);
			if (entry.Curio && entry.Count.Value > 0)
			{
				foreach (EditorEntry item in editorEntries.Where((EditorEntry e) => e.Curio && e != entry))
				{
					item.Count.Value = 0;
				}
			}
			if (delta > 0)
			{
				modEnabled.Value = true;
				simple.Value = true;
			}
			detail = entry;
			if (quantityDraftEntry == entry)
			{
				quantityDraft = entry.Count.Value.ToString();
			}
		}

		private static bool CategoryMatches(string tier, string choice)
		{
			return choice switch
			{
				"White" => tier == "White (common)", 
				"Green" => tier == "Green (uncommon)", 
				"Red" => tier == "Red (legendary)", 
				"Boss" => tier == "Yellow (boss)", 
				"Lunar" => tier == "Blue (lunar)", 
				"Void" => tier.StartsWith("Void", StringComparison.Ordinal), 
				"Meals" => tier == "Meal", 
				"Hallowed" => tier == "Hallowed", 
				"Pages" => tier == "Page", 
				"Hexes" => tier == "Hex", 
				"Other" => !new string[9] { "White (common)", "Green (uncommon)", "Red (legendary)", "Yellow (boss)", "Blue (lunar)", "Meal", "Hallowed", "Page", "Hex" }.Contains(tier) && !tier.StartsWith("Void", StringComparison.Ordinal), 
				_ => true, 
			};
		}

		private void SelectCategory(string choice)
		{
			//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)
			category = choice;
			browserTab = choice switch
			{
				"Curios" => 3, 
				"Random tiers" => 2, 
				"Equipment" => 1, 
				_ => 0, 
			};
			tierFilter = "All rarities";
			browserScroll = Vector2.zero;
			refreshList = true;
			GUI.FocusControl((string)null);
		}

		private void AdjustStep(int delta)
		{
			quantityStep = Mathf.Clamp(quantityStep + delta, 1, 1000);
			stepDraft = quantityStep.ToString();
		}

		private int ClickStep()
		{
			if (!Event.current.control)
			{
				if (!Event.current.shift)
				{
					return quantityStep;
				}
				return 5;
			}
			return 10;
		}

		private void RememberUndo()
		{
			undo = ((IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)((BaseUnityPlugin)this).Config).ToDictionary((KeyValuePair<ConfigDefinition, ConfigEntryBase> pair) => pair.Value, (KeyValuePair<ConfigDefinition, ConfigEntryBase> pair) => pair.Value.BoxedValue);
		}

		private void UndoEdit()
		{
			if (undo == null)
			{
				return;
			}
			foreach (KeyValuePair<ConfigEntryBase, object> item in undo)
			{
				item.Key.BoxedValue = item.Value;
			}
			goldDraft = cash.Value.ToString();
			undo = null;
			confirmClear = false;
			status = "Previous loadout restored.";
		}

		private void EditorSceneChanged(Scene oldScene, Scene newScene)
		{
			if (editorOpen)
			{
				SetEditor(open: false);
			}
		}

		private void Update()
		{
			//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)
			KeyboardShortcut value = editorKey.Value;
			if (((KeyboardShortcut)(ref value)).IsDown())
			{
				SetEditor(!editorOpen);
			}
			if (editorOpen && Input.GetKeyDown((KeyCode)27))
			{
				SetEditor(open: false);
			}
			if (editorOpen)
			{
				SyncEditorInput();
				AcquireEditorPause();
			}
			if (dirty && Time.unscaledTime >= saveAt)
			{
				SaveEditor();
			}
		}

		private void LateUpdate()
		{
			if (editorOpen)
			{
				if (pauseOwned && (!Object.op_Implicit((Object)(object)Run.instance) || !RoR2Application.isInSinglePlayer))
				{
					ReleaseEditorPause();
				}
				Cursor.visible = true;
				Cursor.lockState = (CursorLockMode)2;
			}
		}

		private void SetEditor(bool open)
		{
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Expected O, but got Unknown
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Expected O, but got Unknown
			//IL_009d: 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_00d0: Expected O, but got Unknown
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Expected O, but got Unknown
			if (editorOpen == open)
			{
				return;
			}
			editorOpen = open;
			if (open)
			{
				goldDraft = cash?.Value.ToString() ?? "0";
				confirmClear = false;
				refreshList = true;
				if (!Harmony.HasAnyPatches("local.ror2.startingitems.editor"))
				{
					Harmony val = new Harmony("local.ror2.startingitems.editor");
					val.Patch((MethodBase)AccessTools.Method(typeof(MPEventSystemManager), "Update", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "EditorCursorPatch", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null);
					val.Patch((MethodBase)AccessTools.PropertyGetter(typeof(LocalUser), "isUIFocused"), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "EditorInputFocus", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					val.Patch((MethodBase)AccessTools.Method(typeof(PauseManager), "TogglePauseScreen", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "EditorPauseScreen", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
				inputShield = new GameObject("Starting Items input shield", new Type[3]
				{
					typeof(RectTransform),
					typeof(Canvas),
					typeof(GraphicRaycaster)
				});
				Object.DontDestroyOnLoad((Object)(object)inputShield);
				Canvas component = inputShield.GetComponent<Canvas>();
				component.renderMode = (RenderMode)0;
				component.sortingOrder = 32760;
				GameObject val2 = new GameObject("Block menu clicks", new Type[2]
				{
					typeof(RectTransform),
					typeof(Image)
				});
				val2.transform.SetParent(inputShield.transform, false);
				RectTransform component2 = val2.GetComponent<RectTransform>();
				component2.anchorMin = Vector2.zero;
				component2.anchorMax = Vector2.one;
				Vector2 offsetMin = (component2.offsetMax = Vector2.zero);
				component2.offsetMin = offsetMin;
				((Graphic)val2.GetComponent<Image>()).color = Color.clear;
				SyncEditorInput();
				AcquireEditorPause();
			}
			else
			{
				editorClosedFrame = Time.frameCount;
				ReleaseEditorInput();
				ReleaseEditorPause();
				if (Object.op_Implicit((Object)(object)inputShield))
				{
					Object.Destroy((Object)(object)inputShield);
				}
				inputShield = null;
				if (dirty)
				{
					SaveEditor();
				}
			}
		}

		private void AcquireEditorPause()
		{
			if (!pauseOwned && Object.op_Implicit((Object)(object)Run.instance) && RoR2Application.isInSinglePlayer && !(Time.timeScale <= 0f))
			{
				priorTimeScale = Time.timeScale;
				pauseOwned = true;
				Time.timeScale = 0f;
			}
		}

		private void ReleaseEditorPause()
		{
			if (pauseOwned)
			{
				pauseOwned = false;
				if (Time.timeScale == 0f)
				{
					Time.timeScale = priorTimeScale;
				}
			}
		}

		private void SyncEditorInput()
		{
			MPEventSystem val = MPEventSystemManager.primaryEventSystem;
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = MPEventSystemManager.kbmEventSystem;
			}
			if (!Object.op_Implicit((Object)(object)val) || (Object)(object)cursorSystem == (Object)(object)val)
			{
				return;
			}
			ReleaseEditorInput();
			cursorSystem = val;
			priorNavigation = ((EventSystem)val).sendNavigationEvents;
			priorSelection = ((EventSystem)val).currentSelectedGameObject;
			((EventSystem)val).sendNavigationEvents = false;
			((EventSystem)val).SetSelectedGameObject((GameObject)null);
			MPEventSystem obj = val;
			int cursorOpenerCount = obj.cursorOpenerCount;
			obj.cursorOpenerCount = cursorOpenerCount + 1;
			MPEventSystem obj2 = val;
			cursorOpenerCount = obj2.cursorOpenerForGamepadCount;
			obj2.cursorOpenerForGamepadCount = cursorOpenerCount + 1;
			object? obj3 = AccessTools.Field(typeof(MPEventSystem), "cursorIndicatorController")?.GetValue(val);
			Component val2 = (Component)((obj3 is Component) ? obj3 : null);
			if (Object.op_Implicit((Object)(object)val2))
			{
				softwareCursor = val2.GetComponent<CanvasGroup>();
				addedCursorGroup = !Object.op_Implicit((Object)(object)softwareCursor);
				if (!Object.op_Implicit((Object)(object)softwareCursor))
				{
					softwareCursor = val2.gameObject.AddComponent<CanvasGroup>();
				}
				priorCursorAlpha = softwareCursor.alpha;
				softwareCursor.alpha = 0f;
			}
		}

		private void ReleaseEditorInput()
		{
			if (Object.op_Implicit((Object)(object)cursorSystem))
			{
				MPEventSystem obj = cursorSystem;
				int cursorOpenerCount = obj.cursorOpenerCount;
				obj.cursorOpenerCount = cursorOpenerCount - 1;
				MPEventSystem obj2 = cursorSystem;
				cursorOpenerCount = obj2.cursorOpenerForGamepadCount;
				obj2.cursorOpenerForGamepadCount = cursorOpenerCount - 1;
				((EventSystem)cursorSystem).sendNavigationEvents = priorNavigation;
				if (Object.op_Implicit((Object)(object)priorSelection) && priorSelection.activeInHierarchy)
				{
					((EventSystem)cursorSystem).SetSelectedGameObject(priorSelection);
				}
			}
			cursorSystem = null;
			priorSelection = null;
			if (Object.op_Implicit((Object)(object)softwareCursor))
			{
				softwareCursor.alpha = priorCursorAlpha;
				if (addedCursorGroup)
				{
					Object.Destroy((Object)(object)softwareCursor);
				}
			}
			softwareCursor = null;
		}

		private static void EditorInputFocus(LocalUser __instance, ref bool __result)
		{
			if (Object.op_Implicit((Object)(object)instance) && instance.editorOpen && __instance == LocalUserManager.GetFirstLocalUser())
			{
				__result = true;
			}
		}

		private static bool EditorPauseScreen()
		{
			if (Object.op_Implicit((Object)(object)instance))
			{
				if (!instance.editorOpen)
				{
					return instance.editorClosedFrame != Time.frameCount;
				}
				return false;
			}
			return true;
		}

		private static void EnforceEditorCursor()
		{
			if (Object.op_Implicit((Object)(object)instance) && instance.editorOpen)
			{
				Cursor.visible = true;
				Cursor.lockState = (CursorLockMode)2;
			}
		}

		private static IEnumerable<CodeInstruction> EditorCursorPatch(IEnumerable<CodeInstruction> instructions)
		{
			foreach (CodeInstruction instruction in instructions)
			{
				bool setter = CodeInstructionExtensions.Calls(instruction, AccessTools.PropertySetter(typeof(Cursor), "visible")) || CodeInstructionExtensions.Calls(instruction, AccessTools.PropertySetter(typeof(Cursor), "lockState"));
				if (instruction.operand is MethodInfo methodInfo && methodInfo.DeclaringType?.FullName == "LocationMarkers.Plugin" && (methodInfo.Name == "SetGameCursorVisibility" || methodInfo.Name == "SetGameCursorLock"))
				{
					setter = true;
				}
				yield return instruction;
				if (setter)
				{
					yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Plugin), "EnforceEditorCursor", (Type[])null, (Type[])null));
				}
			}
		}

		private void OnDisable()
		{
			SetEditor(open: false);
		}

		private void DestroyEditor()
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			SetEditor(open: false);
			ReleaseEditorInput();
			ReleaseEditorPause();
			SceneManager.activeSceneChanged -= EditorSceneChanged;
			((BaseUnityPlugin)this).Config.SettingChanged -= EditorConfigChanged;
			if (dirty)
			{
				SaveEditor();
			}
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = previousSave;
			new Harmony("local.ror2.startingitems.editor").UnpatchSelf();
			foreach (AsyncOperationHandle<Sprite> iconHandle in iconHandles)
			{
				if (iconHandle.IsValid())
				{
					Addressables.Release<Sprite>(iconHandle);
				}
			}
			iconHandles.Clear();
			foreach (Texture2D editorTexture in editorTextures)
			{
				if (Object.op_Implicit((Object)(object)editorTexture))
				{
					Object.Destroy((Object)(object)editorTexture);
				}
			}
			editorTextures.Clear();
		}

		private Texture2D Pixel(Color color)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(1, 1)
			{
				hideFlags = (HideFlags)61
			};
			val.SetPixel(0, 0, color);
			val.Apply();
			editorTextures.Add(val);
			return val;
		}

		private void CreateStyles()
		{
			//IL_001a: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//IL_005c: Expected O, but got Unknown
			//IL_00e8: 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_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Expected O, but got Unknown
			//IL_0135: 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_0142: 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_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Expected O, but got Unknown
			//IL_0164: Expected O, but got Unknown
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Expected O, but got Unknown
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: 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_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Expected O, but got Unknown
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Expected O, but got Unknown
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Expected O, but got Unknown
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Expected O, but got Unknown
			//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0408: Unknown result type (might be due to invalid IL or missing references)
			//IL_040d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0415: Unknown result type (might be due to invalid IL or missing references)
			//IL_041d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0427: Expected O, but got Unknown
			//IL_0427: Unknown result type (might be due to invalid IL or missing references)
			//IL_042c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0436: Expected O, but got Unknown
			//IL_0436: Unknown result type (might be due to invalid IL or missing references)
			//IL_0442: Expected O, but got Unknown
			//IL_0491: Unknown result type (might be due to invalid IL or missing references)
			//IL_04af: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d2: Expected O, but got Unknown
			//IL_04d7: Expected O, but got Unknown
			//IL_04de: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f7: Expected O, but got Unknown
			//IL_04fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0503: Unknown result type (might be due to invalid IL or missing references)
			//IL_050b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0517: Expected O, but got Unknown
			//IL_0522: Unknown result type (might be due to invalid IL or missing references)
			//IL_0527: Unknown result type (might be due to invalid IL or missing references)
			//IL_0532: Unknown result type (might be due to invalid IL or missing references)
			//IL_0537: Unknown result type (might be due to invalid IL or missing references)
			//IL_0541: Expected O, but got Unknown
			//IL_0541: Unknown result type (might be due to invalid IL or missing references)
			//IL_0546: Unknown result type (might be due to invalid IL or missing references)
			//IL_0550: Expected O, but got Unknown
			//IL_0555: Expected O, but got Unknown
			//IL_0570: Unknown result type (might be due to invalid IL or missing references)
			//IL_058a: Unknown result type (might be due to invalid IL or missing references)
			//IL_058f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0594: Unknown result type (might be due to invalid IL or missing references)
			//IL_059e: Expected O, but got Unknown
			//IL_05a3: Expected O, but got Unknown
			//IL_05ed: Unknown result type (might be due to invalid IL or missing references)
			if (windowStyle == null)
			{
				windowPixel = Pixel(new Color(0.075f, 0.09f, 0.11f));
				windowStyle = new GUIStyle(GUI.skin.window)
				{
					padding = new RectOffset(0, 0, 0, 0),
					border = new RectOffset(0, 0, 0, 0)
				};
				GUIStyleState[] array = (GUIStyleState[])(object)new GUIStyleState[8] { windowStyle.normal, windowStyle.hover, windowStyle.active, windowStyle.focused, windowStyle.onNormal, windowStyle.onHover, windowStyle.onActive, windowStyle.onFocused };
				foreach (GUIStyleState obj in array)
				{
					obj.background = windowPixel;
					obj.textColor = TextColor;
				}
				titleStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 27,
					fontStyle = (FontStyle)1,
					richText = false
				};
				noteStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 13,
					wordWrap = true,
					richText = false,
					padding = new RectOffset(0, 0, 0, 0)
				};
				nameStyle = new GUIStyle(noteStyle)
				{
					fontSize = 16,
					fontStyle = (FontStyle)1
				};
				GUIStyleState normal = titleStyle.normal;
				Color textColor = (nameStyle.normal.textColor = TextColor);
				normal.textColor = textColor;
				noteStyle.normal.textColor = Muted;
				buttonStyle = new GUIStyle(GUI.skin.button)
				{
					fontSize = 14,
					fontStyle = (FontStyle)0,
					alignment = (TextAnchor)4,
					border = new RectOffset(0, 0, 0, 0),
					padding = new RectOffset(8, 8, 4, 4),
					richText = false
				};
				Texture2D background = Pixel(new Color(0.16f, 0.19f, 0.22f));
				Texture2D background2 = Pixel(new Color(0.22f, 0.27f, 0.3f));
				Texture2D background3 = Pixel(new Color(0.3f, 0.36f, 0.39f));
				array = (GUIStyleState[])(object)new GUIStyleState[4] { buttonStyle.normal, buttonStyle.focused, buttonStyle.onNormal, buttonStyle.onFocused };
				foreach (GUIStyleState obj2 in array)
				{
					obj2.background = background;
					obj2.textColor = TextColor;
				}
				array = (GUIStyleState[])(object)new GUIStyleState[2] { buttonStyle.hover, buttonStyle.onHover };
				foreach (GUIStyleState obj3 in array)
				{
					obj3.background = background2;
					obj3.textColor = Color.white;
				}
				array = (GUIStyleState[])(object)new GUIStyleState[2] { buttonStyle.active, buttonStyle.onActive };
				foreach (GUIStyleState obj4 in array)
				{
					obj4.background = background3;
					obj4.textColor = Color.white;
				}
				selectedButton = new GUIStyle(buttonStyle);
				array = (GUIStyleState[])(object)new GUIStyleState[4] { selectedButton.normal, selectedButton.hover, selectedButton.active, selectedButton.focused };
				foreach (GUIStyleState obj5 in array)
				{
					obj5.background = Pixel(Accent * new Color(0.28f, 0.28f, 0.28f, 1f));
					obj5.textColor = Accent;
				}
				fieldStyle = new GUIStyle(GUI.skin.textField)
				{
					fontSize = 16,
					padding = new RectOffset(12, 12, 9, 5),
					border = new RectOffset(1, 1, 1, 1),
					richText = false
				};
				array = (GUIStyleState[])(object)new GUIStyleState[4] { fieldStyle.normal, fieldStyle.hover, fieldStyle.active, fieldStyle.focused };
				foreach (GUIStyleState obj6 in array)
				{
					obj6.background = background;
					obj6.textColor = TextColor;
				}
				centeredName = new GUIStyle(nameStyle)
				{
					fontSize = 14,
					alignment = (TextAnchor)1,
					padding = new RectOffset(0, 0, 0, 0)
				};
				centeredTier = new GUIStyle(noteStyle)
				{
					fontSize = 11,
					alignment = (TextAnchor)4
				};
				quantityStyle = new GUIStyle(nameStyle)
				{
					fontSize = 17,
					alignment = (TextAnchor)4
				};
				scrollStyle = new GUIStyle(GUI.skin.verticalScrollbar)
				{
					fixedWidth = 12f,
					margin = new RectOffset(4, 0, 0, 0),
					border = new RectOffset(0, 0, 0, 0)
				};
				scrollStyle.normal.background = Pixel(new Color(0.1f, 0.12f, 0.14f));
				thumbStyle = new GUIStyle(GUI.skin.verticalScrollbarThumb)
				{
					border = new RectOffset(0, 0, 0, 0)
				};
				array = (GUIStyleState[])(object)new GUIStyleState[3] { thumbStyle.normal, thumbStyle.hover, thumbStyle.active };
				for (int i = 0; i < array.Length; i++)
				{
					array[i].background = Pixel(new Color(0.35f, 0.42f, 0.46f));
				}
			}
		}

		private static void Fill(Rect rect, Color color)
		{
			//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_000b: Unknown result type (might be due to invalid IL or missing references)
			Color color2 = GUI.color;
			GUI.color = color;
			GUI.DrawTexture(rect, (Texture)(object)Texture2D.whiteTexture);
			GUI.color = color2;
		}

		private static void Outline(Rect rect, Color color)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			Fill(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, 1f), color);
			Fill(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).yMax - 1f, ((Rect)(ref rect)).width, 1f), color);
			Fill(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, 1f, ((Rect)(ref rect)).height), color);
			Fill(new Rect(((Rect)(ref rect)).xMax - 1f, ((Rect)(ref rect)).y, 1f, ((Rect)(ref rect)).height), color);
		}

		private bool Button(Rect rect, string label, bool selected = false, string help = "")
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			return GUI.Button(rect, new GUIContent(label, help), selected ? selectedButton : buttonStyle);
		}

		private void OnGUI()
		{
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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_0020: 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_0026: 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_006f: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Expected O, but got Unknown
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			if (!editorOpen)
			{
				return;
			}
			CreateStyles();
			Matrix4x4 matrix = GUI.matrix;
			Color color = GUI.color;
			Color backgroundColor = GUI.backgroundColor;
			Color contentColor = GUI.contentColor;
			int depth = GUI.depth;
			float num = Mathf.Max(0.25f, Mathf.Min(1.35f, Mathf.Min((float)Screen.width / 1260f, (float)Screen.height / 860f)));
			GUI.matrix = Matrix4x4.Scale(new Vector3(num, num, 1f));
			GUI.depth = -1000;
			GUI.color = (GUI.backgroundColor = (GUI.contentColor = Color.white));
			float num2 = (float)Screen.width / num;
			float num3 = (float)Screen.height / num;
			try
			{
				Fill(new Rect(0f, 0f, num2, num3), new Color(0.015f, 0.02f, 0.025f, 0.94f));
				GUI.ModalWindow(731882, new Rect((num2 - 1220f) / 2f, (num3 - 820f) / 2f, 1220f, 820f), new WindowFunction(DrawEditor), "", windowStyle);
			}
			finally
			{
				GUI.matrix = matrix;
				GUI.color = color;
				GUI.backgroundColor = backgroundColor;
				GUI.contentColor = contentColor;
				GUI.depth = depth;
			}
		}

		private void DrawEditor(int id)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Invalid comparison between Unknown and I4
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: 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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Invalid comparison between Unknown and I4
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: 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_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0374: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0405: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: Unknown result type (might be due to invalid IL or missing references)
			//IL_0496: Unknown result type (might be due to invalid IL or missing references)
			//IL_049b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0522: Unknown result type (might be due to invalid IL or missing references)
			//IL_0577: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0603: Unknown result type (might be due to invalid IL or missing references)
			//IL_0645: Unknown result type (might be due to invalid IL or missing references)
			//IL_064a: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_072a: Unknown result type (might be due to invalid IL or missing references)
			//IL_070b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0710: Unknown result type (might be due to invalid IL or missing references)
			//IL_0671: Unknown result type (might be due to invalid IL or missing references)
			//IL_0676: Unknown result type (might be due to invalid IL or missing references)
			//IL_091f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0915: Unknown result type (might be due to invalid IL or missing references)
			//IL_0786: Unknown result type (might be due to invalid IL or missing references)
			//IL_0767: Unknown result type (might be due to invalid IL or missing references)
			//IL_076c: Unknown result type (might be due to invalid IL or missing references)
			//IL_094c: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_07cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_082f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0872: Unknown result type (might be due to invalid IL or missing references)
			if ((int)Event.current.type == 4 && Event.current.control && (int)Event.current.keyCode == 102)
			{
				GUI.FocusControl("itemSearch");
				Event.current.Use();
			}
			if ((int)Event.current.type == 8)
			{
				selectedEntries = (from e in editorEntries
					where e.Count.Value > 0
					orderby e.Equipment, e.TierOrder, e.Name
					select e).ToArray();
				if (refreshList)
				{
					visibleEntries = FilterEntries();
					refreshList = false;
				}
			}
			GUI.Label(new Rect(24f, 18f, 580f, 36f), "Starting Items", titleStyle);
			GUI.Label(new Rect(24f, 58f, 900f, 22f), "Build your loadout · Saved automatically · Applies to the next first spawn · Host controls bonuses", noteStyle);
			if (Button(new Rect(960f, 22f, 106f, 34f), modEnabled.Value ? "● Enabled" : "Disabled", modEnabled.Value, "Enable or disable all starting bonuses"))
			{
				modEnabled.Value = !modEnabled.Value;
			}
			if (Button(new Rect(1080f, 22f, 116f, 34f), "Close  /  Esc"))
			{
				SetEditor(open: false);
			}
			if (!ready)
			{
				GUI.Label(new Rect(24f, 110f, 800f, 40f), "Loading the game's item catalog…", nameStyle);
				return;
			}
			GUI.Label(new Rect(24f, 96f, 340f, 20f), "SEARCH ITEMS", noteStyle);
			GUI.SetNextControlName("itemSearch");
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(24f, 121f, (float)((search.Length > 0) ? 400 : 440), 38f);
			string text = GUI.TextField(val, search, fieldStyle);
			if (GUI.GetNameOfFocusedControl() == "itemSearch")
			{
				Outline(val, Accent);
			}
			if (text != search)
			{
				search = text;
				refreshList = true;
				browserScroll = Vector2.zero;
			}
			if (search.Length == 0 && GUI.GetNameOfFocusedControl() != "itemSearch")
			{
				GUI.Label(new Rect(37f, 131f, 390f, 22f), "Search names or effects…", noteStyle);
			}
			if (search.Length > 0 && Button(new Rect(428f, 124f, 32f, 32f), "×", selected: false, "Clear search"))
			{
				search = "";
				refreshList = true;
				browserScroll = Vector2.zero;
				GUI.FocusControl((string)null);
			}
			int result;
			bool flag = !int.TryParse(stepDraft, out result) || result < 1 || result > 1000;
			GUI.Label(new Rect(550f, 96f, 560f, 20f), flag ? "QUANTITY STEP  ·  Enter a whole number from 1 to 1000" : "QUANTITY STEP  ·  Amount added or removed with each click", noteStyle);
			int[] array = new int[6] { -100, -10, -1, 1, 10, 100 };
			for (int num = 0; num < 3; num++)
			{
				if (Button(new Rect((float)(550 + num * 58), 121f, 52f, 38f), array[num].ToString()))
				{
					AdjustStep(array[num]);
				}
			}
			GUI.SetNextControlName("quantityStep");
			string text2 = GUI.TextField(new Rect(730f, 121f, 94f, 38f), stepDraft, fieldStyle);
			if (GUI.GetNameOfFocusedControl() == "quantityStep")
			{
				Outline(new Rect(730f, 121f, 94f, 38f), Accent);
			}
			if (text2 != stepDraft)
			{
				stepDraft = text2;
				if (int.TryParse(text2, out var result2) && result2 >= 1 && result2 <= 1000)
				{
					quantityStep = result2;
				}
			}
			if (GUI.GetNameOfFocusedControl() != "quantityStep")
			{
				stepDraft = quantityStep.ToString();
			}
			for (int num2 = 3; num2 < 6; num2++)
			{
				if (Button(new Rect((float)(830 + (num2 - 3) * 58), 121f, 52f, 38f), "+" + array[num2]))
				{
					AdjustStep(array[num2]);
				}
			}
			if (Button(new Rect(1014f, 121f, 182f, 38f), "Reset step to 1", selected: false, "Each item's + / − uses this step. Shift: 5, Ctrl: 10."))
			{
				quantityStep = 1;
				stepDraft = "1";
			}
			GUI.Label(new Rect(24f, 179f, 400f, 20f), "ITEM CATEGORIES", noteStyle);
			for (int num3 = 0; num3 < Categories.Length; num3++)
			{
				float num4 = 24f + (float)(num3 % 8) * 147.5f;
				float num5 = 204 + num3 / 8 * 42;
				if (Button(new Rect(num4, num5, 139.5f, 34f), Categories[num3], category == Categories[num3]))
				{
					SelectCategory(Categories[num3]);
				}
				Color color = CategoryColor(Categories[num3]);
				if (num3 > 0 && num3 < 11)
				{
					Fill(new Rect(num4 + 8f, num5 + 29f, 123.5f, 2f), color);
				}
			}
			if (browserTab != 2)
			{
				if (Button(new Rect(24f, 294f, 147f, 32f), "Sort: " + (new string[3] { "Name", "Rarity", "Quantity" })[sortMode]))
				{
					sortMode = (sortMode + 1) % 3;
					refreshList = true;
					browserScroll = Vector2.zero;
				}
				if (Button(new Rect(179f, 294f, 120f, 32f), descending ? "↓ Descending" : "↑ Ascending"))
				{
					descending = !descending;
					refreshList = true;
					browserScroll = Vector2.zero;
				}
				if (Button(new Rect(311f, 294f, 152f, 32f), selectedOnly ? "✓ Selected only" : "Selected only", selectedOnly))
				{
					selectedOnly = !selectedOnly;
					refreshList = true;
					browserScroll = Vector2.zero;
				}
				if (Button(new Rect(475f, 294f, 110f, 32f), "Reset filters"))
				{
					search = "";
					selectedOnly = false;
					SelectCategory("All items");
				}
				GUI.Label(new Rect(603f, 301f, 435f, 20f), visibleEntries.Count + " results · Click an item to read its effects", noteStyle);
				if (Button(new Rect(1058f, 294f, 138f, 32f), showDetails ? "Hide details" : "Show details", showDetails))
				{
					showDetails = !showDetails;
				}
			}
			else
			{
				GUI.Label(new Rect(24f, 299f, 1080f, 28f), "Random extras choose one available item per tier, then grant the selected number of copies.", noteStyle);
			}
			Rect rect = default(Rect);
			((Rect)(ref rect))..ctor(24f, 342f, (float)((showDetails && browserTab != 2) ? 864 : 1172), 355f);
			if (browserTab == 2)
			{
				DrawRandomGrid(rect);
			}
			else
			{
				DrawItemGrid(rect);
			}
			if (showDetails && browserTab != 2)
			{
				DrawDetails(new Rect(904f, 342f, 292f, 355f));
			}
			DrawFooter();
			DrawTooltip();
		}

		private static Color CategoryColor(string value)
		{
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: 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_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: 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)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: 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_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			return (Color)(value switch
			{
				"White" => new Color(0.83f, 0.86f, 0.9f), 
				"Green" => new Color(0.53f, 0.76f, 0.56f), 
				"Red" => new Color(0.9f, 0.48f, 0.46f), 
				"Boss" => new Color(0.83f, 0.72f, 0.42f), 
				"Lunar" => new Color(0.46f, 0.65f, 0.84f), 
				"Void" => new Color(0.72f, 0.57f, 0.85f), 
				"Meals" => new Color(0.8f, 0.63f, 0.42f), 
				"Hallowed" => new Color(0.85f, 0.65f, 0.79f), 
				"Hexes" => new Color(0.71f, 0.59f, 0.51f), 
				"Pages" => new Color(0.57f, 0.7f, 0.8f), 
				_ => Muted, 
			});
		}

		private static Color TierColor(string tier)
		{
			//IL_003a: 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_0074: 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)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			string[] array = new string[4] { "Void", "White", "Green", "Red" };
			foreach (string value in array)
			{
				if (tier.StartsWith(value, StringComparison.Ordinal))
				{
					return CategoryColor(value);
				}
			}
			object value2;
			switch (tier)
			{
			case "Meal":
				return CategoryColor("Meals");
			case "Hallowed":
				return CategoryColor("Hallowed");
			case "Page":
				return CategoryColor("Pages");
			case "Hex":
				return CategoryColor("Hexes");
			default:
				value2 = ((tier.Contains("lunar") || tier == "Lunar equipment") ? "Lunar" : "Equipment");
				break;
			case "Yellow (boss)":
				value2 = "Boss";
				break;
			}
			return CategoryColor((string)value2);
		}

		private void BeginGrid(Rect rect, float contentHeight)
		{
			//IL_0000: 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_002a: 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_006d: 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_00a3: 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)
			Fill(rect, new Color(0.055f, 0.07f, 0.085f));
			Outline(rect, new Color(0.19f, 0.23f, 0.27f));
			GUIStyle verticalScrollbar = GUI.skin.verticalScrollbar;
			GUIStyle verticalScrollbarThumb = GUI.skin.verticalScrollbarThumb;
			GUI.skin.verticalScrollbar = scrollStyle;
			GUI.skin.verticalScrollbarThumb = thumbStyle;
			browserScroll = GUI.BeginScrollView(rect, browserScroll, new Rect(0f, 0f, ((Rect)(ref rect)).width - 20f, Math.Max(((Rect)(ref rect)).height - 1f, contentHeight)), false, true);
			GUI.skin.verticalScrollbar = verticalScrollbar;
			GUI.skin.verticalScrollbarThumb = verticalScrollbarThumb;
		}

		private void DrawItemGrid(Rect rect)
		{
			//IL_0056: 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_0165: 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)
			float num = ((Rect)(ref rect)).width - 44f;
			int num2 = Math.Max(1, (int)((num + 12f) / 185f));
			float num3 = (num - 12f * (float)(num2 - 1)) / (float)num2;
			int num4 = (visibleEntries.Count + num2 - 1) / num2;
			float contentHeight = 24f + (float)num4 * 172f;
			BeginGrid(rect, contentHeight);
			int num5 = Math.Max(0, (int)((browserScroll.y - 12f) / 172f));
			int num6 = Math.Min(num4, num5 + (int)Math.Ceiling(((Rect)(ref rect)).height / 172f) + 2);
			for (int i = num5; i < num6; i++)
			{
				for (int j = 0; j < num2; j++)
				{
					int num7 = i * num2 + j;
					if (num7 < visibleEntries.Count)
					{
						DrawCard(visibleEntries[num7], new Rect(12f + (float)j * (num3 + 12f), 12f + (float)i * 172f, num3, 160f));
					}
				}
			}
			if (visibleEntries.Count == 0)
			{
				GUI.Label(new Rect(28f, 40f, num - 30f, 32f), "No items match these filters", nameStyle);
				GUI.Label(new Rect(28f, 82f, num - 30f, 50f), selectedOnly ? "Your selection is empty in this category. Turn off Selected only or choose another category." : "Try another name or effect, or reset the filters.", noteStyle);
			}
			GUI.EndScrollView();
		}

		private void DrawCard(EditorEntry entry, Rect rect)
		{
			//IL_0024: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Expected O, but got Unknown
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			bool flag = entry.Count.Value > 0;
			bool flag2 = showDetails && detail == entry;
			Fill(rect, (Color)(flag2 ? new Color(0.16f, 0.2f, 0.23f) : CardColor));
			Outline(rect, (Color)((flag || flag2) ? (Accent * new Color(0.65f, 0.65f, 0.65f, 1f)) : new Color(0.22f, 0.26f, 0.3f)));
			Fill(new Rect(((Rect)(ref rect)).x + 1f, ((Rect)(ref rect)).y + 1f, ((Rect)(ref rect)).width - 2f, 3f), TierColor(entry.Tier));
			if (GUI.Button(new Rect(((Rect)(ref rect)).x + 8f, ((Rect)(ref rect)).y + 8f, ((Rect)(ref rect)).width - 16f, 112f), new GUIContent("", entry.Name + " · " + entry.Tier + "\nClick for item details"), GUIStyle.none))
			{
				detail = entry;
				detailScroll = Vector2.zero;
				showDetails = true;
			}
			DrawIcon(entry.Icon, new Rect(((Rect)(ref rect)).center.x - 25f, ((Rect)(ref rect)).y + 11f, 50f, 50f));
			GUI.Label(new Rect(((Rect)(ref rect)).x + 10f, ((Rect)(ref rect)).y + 67f, ((Rect)(ref rect)).width - 20f, 38f), entry.Name, centeredName);
			GUI.Label(new Rect(((Rect)(ref rect)).x + 10f, ((Rect)(ref rect)).y + 105f, ((Rect)(ref rect)).width - 20f, 18f), entry.Tier, centeredTier);
			bool enabled = GUI.enabled;
			GUI.enabled = enabled && entry.Count.Value > 0;
			if (Button(new Rect(((Rect)(ref rect)).x + 12f, ((Rect)(ref rect)).y + 125f, 34f, 30f), "−", selected: false, "Remove " + ClickStep() + " copies"))
			{
				ChangeCount(entry, -ClickStep());
			}
			GUI.enabled = enabled;
			GUI.Label(new Rect(((Rect)(ref rect)).x + 49f, ((Rect)(ref rect)).y + 127f, ((Rect)(ref rect)).width - 98f, 28f), entry.Count.Value.ToString(), quantityStyle);
			GUI.enabled = enabled && entry.Count.Value < (entry.Curio ? 1 : 1000);
			if (Button(new Rect(((Rect)(ref rect)).xMax - 46f, ((Rect)(ref rect)).y + 125f, 34f, 30f), "+", selected: false, "Add " + ClickStep() + " copies"))
			{
				ChangeCount(entry, ClickStep());
			}
			GUI.enabled = enabled;
		}

		private static void DrawIcon(Sprite sprite, Rect rect)
		{
			//IL_0015: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)sprite) || !Object.op_Implicit((Object)(object)sprite.texture))
			{
				GUI.Box(rect, "…");
				return;
			}
			Rect textureRect = sprite.textureRect;
			Texture2D texture = sprite.texture;
			GUI.DrawTextureWithTexCoords(rect, (Texture)(object)texture, new Rect(((Rect)(ref textureRect)).x / (float)((Texture)texture).width, ((Rect)(ref textureRect)).y / (float)((Texture)texture).height, ((Rect)(ref textureRect)).width / (float)((Texture)texture).width, ((Rect)(ref textureRect)).height / (float)((Texture)texture).height));
		}

		private void DrawDetails(Rect rect)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: 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_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Expected O, but got Unknown
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0467: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_055e: Unknown result type (might be due to invalid IL or missing references)
			Fill(rect, CardColor);
			Outline(rect, new Color(0.22f, 0.26f, 0.3f));
			GUI.Label(new Rect(((Rect)(ref rect)).x + 16f, ((Rect)(ref rect)).y + 16f, ((Rect)(ref rect)).width - 60f, 24f), "ITEM DETAILS", noteStyle);
			if (Button(new Rect(((Rect)(ref rect)).xMax - 42f, ((Rect)(ref rect)).y + 10f, 30f, 28f), "×"))
			{
				showDetails = false;
			}
			if (detail == null)
			{
				GUI.Label(new Rect(((Rect)(ref rect)).x + 16f, ((Rect)(ref rect)).y + 65f, ((Rect)(ref rect)).width - 32f, 90f), "Click an item card to read its effects and adjust its starting quantity.", noteStyle);
				return;
			}
			if (quantityDraftEntry != detail)
			{
				quantityDraftEntry = detail;
				quantityDraft = detail.Count.Value.ToString();
			}
			DrawIcon(detail.Icon, new Rect(((Rect)(ref rect)).x + 16f, ((Rect)(ref rect)).y + 53f, 56f, 56f));
			GUI.Label(new Rect(((Rect)(ref rect)).x + 84f, ((Rect)(ref rect)).y + 54f, ((Rect)(ref rect)).width - 100f, 43f), detail.Name, nameStyle);
			GUI.Label(new Rect(((Rect)(ref rect)).x + 84f, ((Rect)(ref rect)).y + 102f, ((Rect)(ref rect)).width - 100f, 35f), detail.Tier, noteStyle);
			string text = (detail.Curio ? "\n\nOne curio per survivor. Selecting another replaces it." : ((detail.Tier == "Page") ? "\n\nPages include the N'Tormat automatically when the curio slot is empty." : ""));
			string text2 = detail.Description + text;
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(((Rect)(ref rect)).x + 16f, ((Rect)(ref rect)).y + 145f, ((Rect)(ref rect)).width - 32f, Math.Max(50f, ((Rect)(ref rect)).height - 247f));
			float num = noteStyle.CalcHeight(new GUIContent(text2), ((Rect)(ref val)).width - 20f);
			detailScroll = GUI.BeginScrollView(val, detailScroll, new Rect(0f, 0f, ((Rect)(ref val)).width - 20f, Math.Max(((Rect)(ref val)).height - 1f, num)));
			GUI.Label(new Rect(0f, 0f, ((Rect)(ref val)).width - 20f, num), text2, noteStyle);
			GUI.EndScrollView();
			int num2 = (detail.Curio ? 1 : 1000);
			int result;
			bool flag = !int.TryParse(quantityDraft, out result) || result < 0 || result > num2;
			GUI.Label(new Rect(((Rect)(ref rect)).x + 16f, ((Rect)(ref rect)).yMax - 85f, ((Rect)(ref rect)).width - 32f, 20f), flag ? ("ENTER A WHOLE NUMBER: 0–" + num2) : (detail.Curio ? "CURIO SLOT (0 OR 1)" : "STARTING QUANTITY"), noteStyle);
			bool enabled = GUI.enabled;
			GUI.enabled = enabled && detail.Count.Value > 0;
			if (Button(new Rect(((Rect)(ref rect)).x + 16f, ((Rect)(ref rect)).yMax - 55f, 40f, 34f), "−"))
			{
				ChangeCount(detail, -ClickStep());
			}
			GUI.enabled = enabled;
			GUI.SetNextControlName("detailQuantity");
			Rect val2 = default(Rect);
			((Rect)(ref val2))..ctor(((Rect)(ref rect)).x + 64f, ((Rect)(ref rect)).yMax - 55f, ((Rect)(ref rect)).width - 128f, 34f);
			string text3 = GUI.TextField(val2, quantityDraft, fieldStyle);
			if (text3 != quantityDraft)
			{
				quantityDraft = text3;
				if (int.TryParse(text3, out var result2) && result2 >= 0 && result2 <= num2 && result2 != detail.Count.Value)
				{
					ChangeCount(detail, result2 - detail.Count.Value);
				}
			}
			if (GUI.GetNameOfFocusedControl() == "detailQuantity")
			{
				Outline(val2, Accent);
			}
			else
			{
				quantityDraft = detail.Count.Value.ToString();
			}
			GUI.enabled = enabled && detail.Count.Value < num2;
			if (Button(new Rect(((Rect)(ref rect)).xMax - 56f, ((Rect)(ref rect)).yMax - 55f, 40f, 34f), "+"))
			{
				ChangeCount(detail, ClickStep());
			}
			GUI.enabled = enabled;
		}

		private void DrawRandomGrid(Rect rect)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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_008d: 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_00b4: 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_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			BeginGrid(rect, 36 + selections.Count * 66);
			int num = 0;
			foreach (KeyValuePair<ItemTier, ConfigEntryBase> selection in selections)
			{
				float num2 = 12 + num++ * 66;
				float num3 = ((Rect)(ref rect)).width - 44f;
				Fill(new Rect(12f, num2, num3, 56f), CardColor);
				Fill(new Rect(12f, num2, 3f, 56f), TierColor(FriendlyTier(selection.Key)));
				GUI.Label(new Rect(28f, num2 + 16f, 250f, 24f), FriendlyTier(selection.Key), nameStyle);
				bool flag = Convert.ToInt32(selection.Value.BoxedValue) == 1;
				if (Button(new Rect(300f, num2 + 10f, 130f, 36f), flag ? "✓ Random" : "Enable random", flag))
				{
					selection.Value.BoxedValue = Enum.ToObject(selection.Value.SettingType, (!flag) ? 1 : 0);
					if (!flag)
					{
						simple.Value = true;
						modEnabled.Value = true;
					}
				}
				if (Button(new Rect(num3 - 238f, num2 + 10f, 40f, 36f), "−"))
				{
					amounts[selection.Key].Value = Mathf.Clamp(amounts[selection.Key].Value - ClickStep(), 0, 1000);
				}
				GUI.Label(new Rect(num3 - 188f, num2 + 10f, 85f, 36f), amounts[selection.Key].Value.ToString(), quantityStyle);
				if (Button(new Rect(num3 - 92f, num2 + 10f, 40f, 36f), "+"))
				{
					amounts[selection.Key].Value = Mathf.Clamp(amounts[selection.Key].Value + ClickStep(), 0, 1000);
				}
			}
			GUI.EndScrollView();
		}

		private void DrawFooter()
		{
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0472: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0566: Unknown result type (might be due to invalid IL or missing references)
			int num = selectedEntries.Where((EditorEntry e) => !e.Equipment && !e.Curio).Sum((EditorEntry e) => e.Count.Value);
			int num2 = selections.Where((KeyValuePair<ItemTier, ConfigEntryBase> p) => Convert.ToInt32(p.Value.BoxedValue) == 1).Sum((KeyValuePair<ItemTier, ConfigEntryBase> p) => amounts[p.Key].Value);
			GUI.Label(new Rect(24f, 711f, 910f, 23f), "YOUR LOADOUT   " + num + " item copies · " + selectedEntries.Count((EditorEntry e) => e.Equipment) + " equipment · " + selectedEntries.Count((EditorEntry e) => e.Curio) + " curio · " + num2 + " random", noteStyle);
			if (Button(new Rect(1007f, 707f, 189f, 30f), simple.Value ? "✓ Visual loadout on" : "Visual loadout off", simple.Value))
			{
				simple.Value = !simple.Value;
			}
			if (Button(new Rect(24f, 747f, 135f, 34f), "Starter preset"))
			{
				RememberUndo();
				Starter();
				status = "Starter preset applied. Undo restores your previous loadout.";
			}
			if (Button(new Rect(169f, 747f, 135f, 34f), confirmClear ? "Confirm clear" : "Clear loadout"))
			{
				if (confirmClear)
				{
					RememberUndo();
					ClearSelections();
					confirmClear = false;
					status = "Loadout cleared. Undo restores it.";
				}
				else
				{
					confirmClear = true;
				}
			}
			if (confirmClear && Button(new Rect(314f, 747f, 80f, 34f), "Cancel"))
			{
				confirmClear = false;
			}
			bool enabled = GUI.enabled;
			GUI.enabled = enabled && undo != null;
			if (Button(new Rect((float)(confirmClear ? 404 : 314), 747f, 80f, 34f), "Undo"))
			{
				UndoEdit();
			}
			GUI.enabled = enabled;
			if (Button(new Rect(705f, 747f, 190f, 34f), cashEnabled.Value ? "✓ Starting gold override" : "Starting gold override", cashEnabled.Value, "Scaled by difficulty; off preserves normal starting gold."))
			{
				cashEnabled.Value = !cashEnabled.Value;
			}
			GUI.enabled = enabled && cashEnabled.Value;
			GUI.SetNextControlName("startingGold");
			string text = GUI.TextField(new Rect(905f, 747f, 110f, 34f), goldDraft, fieldStyle);
			if (cashEnabled.Value && GUI.GetNameOfFocusedControl() == "startingGold")
			{
				Outline(new Rect(905f, 747f, 110f, 34f), Accent);
			}
			if (text != goldDraft)
			{
				goldDraft = text;
				if (int.TryParse(text, out var result) && result >= 0 && result <= 1000000)
				{
					cash.Value = result;
				}
			}
			GUI.enabled = enabled;
			int result2;
			bool flag = !int.TryParse(goldDraft, out result2) || result2 < 0 || result2 > 1000000;
			GUI.Label(new Rect(1028f, 755f, 168f, 22f), flag ? "Use 0–1,000,000" : "Difficulty scaled", noteStyle);
			string text2 = ((!modEnabled.Value || !simple.Value) ? "Bonuses disabled. Enable the mod and visual loadout above." : (advanced.Value ? "Advanced text loadout also adds bonuses." : status));
			GUI.Label(new Rect(24f, 794f, 945f, 20f), (dirty ? "Saving…" : "Saved") + " · Step " + quantityStep + " · Shift ±5 / Ctrl ±10" + ((text2.Length > 0) ? (" · " + text2) : ""), noteStyle);
			GUI.Label(new Rect(1010f, 794f, 186f, 20f), pauseOwned ? "Single-player paused" : "F6 opens / closes", noteStyle);
		}

		private void DrawTooltip()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Invalid comparison between Unknown and I4
			//IL_001f: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: 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_00ab: 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_00ed: Unknown result type (might be due to invalid IL or missing references)
			if (!string.IsNullOrEmpty(GUI.tooltip) && (int)Event.current.type == 7)
			{
				Vector2 mousePosition = Event.current.mousePosition;
				float num = 270f;
				float num2 = noteStyle.CalcHeight(new GUIContent(GUI.tooltip), num - 24f) + 20f;
				Rect rect = default(Rect);
				((Rect)(ref rect))..ctor(Mathf.Clamp(mousePosition.x + 16f, 24f, 1196f - num), Mathf.Clamp(mousePosition.y + 18f, 24f, 790f - num2), num, num2);
				Fill(rect, new Color(0.055f, 0.07f, 0.085f));
				Outline(rect, new Color(0.35f, 0.42f, 0.46f));
				GUI.Label(new Rect(((Rect)(ref rect)).x + 12f, ((Rect)(ref rect)).y + 10f, num - 24f, num2 - 20f), GUI.tooltip, noteStyle);
			}
		}

		private void Awake()
		{
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Expected O, but got Unknown
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Expected O, but got Unknown
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Expected O, but got Unknown
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Expected O, but got Unknown
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Expected O, but got Unknown
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Expected O, but got Unknown
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Expected O, but got Unknown
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Expected O, but got Unknown
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Expected O, but got Unknown
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Expected O, but got Unknown
			instance = this;
			InitializeEditor();
			modEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("00 Start here", "modEnabled", true, "The host gives the configured loadout once per player per run, including late joiners. Respawning does not grant it again.");
			simple = ((BaseUnityPlugin)this).Config.Bind<bool>("00 Start here", "Use item selectors", true, "Select an item and quantity in each tier section. None gives nothing. Random uses the current run's available items.");
			cashEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("01 Starting gold", "Override starting gold", false, "Replace the normal starting gold on a player's first spawn. Off preserves vanilla starting gold.");
			cash = ((BaseUnityPlugin)this).Config.Bind<int>("01 Starting gold", "Starting gold", 0, new ConfigDescription("Starting gold, scaled by the run difficulty. Applies to the next player's first spawn, never retroactively.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000000), Array.Empty<object>()));
			advanced = ((BaseUnityPlugin)this).Config.Bind<bool>("90 Advanced loadout", "Enable advanced loadout", false, "Optional extra loadout in addition to the selectors. Uses Def's ItemStringParser. Equipment is limited by the survivor's usable equipment slots.");
			advancedList = ((BaseUnityPlugin)this).Config.Bind<string>("90 Advanced loadout", "Loadout", "", "Optional syntax: 2xSyringe & Tier2. Internal names, random tiers, and drop tables are supported by ItemStringParser. Disable the selectors if you only want this list.");
			ModSettingsManager.SetModDescription("Starting Items — open the visual loadout editor below, or press F6. Browse game icons, search, filter by rarity, and add multiple items with + / − controls. Changes are saved automatically and apply to future first spawns. Only the host grants items. Disable StartBonusMod to avoid duplicate bonuses.");
			ModSettingsManager.AddOption((BaseOption)new GenericButtonOption("Visual loadout editor", "00 Start here", "Item icons, search, rarity filters, sorting and quantity controls. F6 also opens the editor. Single-player pauses while editing.", "Open editor", (UnityAction)delegate
			{
				SetEditor(open: true);
			}));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(modEnabled));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(simple));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(cashEnabled));
			ModSettingsManager.AddOption((BaseOption)new IntFieldOption(cash));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(advanced));
			ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(advancedList));
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(ConfigureCatalog));
			Run.onRunStartGlobal += ClearRun;
			Run.onRunDestroyGlobal += ClearRun;
			hooks = new Harmony("local.ror2.startingitems");
			hooks.Patch((MethodBase)AccessTools.Method(typeof(Run), "OnServerCharacterBodySpawned", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "Spawned", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		private void ClearRun(Run run)
		{
			granted.Clear();
		}

		private void ConfigureCatalog()
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Expected I4, but got Unknown
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Expected O, but got Unknown
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Expected O, but got Unknown
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Expected O, but got Unknown
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Expected O, but got Unknown
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Expected O, but got Unknown
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Expected O, but got Unknown
			if (ready)
			{
				return;
			}
			foreach (IGrouping<ItemTier, ItemDef> item in from d in ((IEnumerable<ItemDef>)(object)ItemCatalog.allItemDefs).Where(IsSelectableItem)
				group d by d.tier into g
				orderby (int)g.Key
				select g)
			{
				string text = "10 Items — " + FriendlyTier(item.Key);
				selections[item.Key] = CatalogChoice(text, "Item", "Choose a starting item. Random picks from this tier's available drops; None disables this tier.", item.Select((ItemDef d) => ((int)d.itemIndex, Name(d.nameToken, ((Object)d).name))), "Tier" + (int)item.Key, out var indices);
				catalogIndices[item.Key] = indices;
				amounts[item.Key] = ((BaseUnityPlugin)this).Config.Bind<int>(text, "Quantity", 1, new ConfigDescription("Number of copies of this tier's selected item. Zero gives nothing. Random selects once, then grants this many copies.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), Array.Empty<object>()));
				ModSettingsManager.AddOption((BaseOption)new IntFieldOption(amounts[item.Key]));
			}
			equipment = CatalogChoice("20 Equipment", "Starting equipment", "Choose starting equipment. None preserves survivor equipment. Random uses available equipment drops.", from d in ((IEnumerable<EquipmentIndex>)(object)EquipmentCatalog.allEquipment).Select((Func<EquipmentIndex, EquipmentDef>)EquipmentCatalog.GetEquipmentDef).Where(IsSelectableEquipment)
				select ((int)d.equipmentIndex, Name(d.nameToken, ((Object)d).name)), "Equipment", out equipmentIndices);
			ModSettingsManager.AddOption((BaseOption)new GenericButtonOption("Starter preset", "00 Start here", "Clear selected bonuses, then choose 2 random white items and 1 random green item. Advanced loadout and gold override are disabled.", "Apply", new UnityAction(Starter)));
			ModSettingsManager.AddOption((BaseOption)new GenericButtonOption("No starting bonuses", "00 Start here", "Clear selected items, equipment, advanced loadout and gold override. Does not remove items from an existing run.", "Clear", new UnityAction(ClearSelections)));
			BuildEditorCatalog();
			ready = true;
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Starting Items ready: " + selections.Count + " tiers. Configure in Options > Mod Options > Starting Items."));
		}

		private static string Name(string token, string fallback)
		{
			string text = Language.GetString(token, "en");
			if (!string.IsNullOrWhiteSpace(text) && !(text == token))
			{
				return text;
			}
			return fallback;
		}

		private static bool SameTier(ItemTier tier, ItemTier nativeTier, ItemDef example)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: 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_000e: Unknown result type (might be due to invalid IL or missing references)
			if (tier != nativeTier)
			{
				if (Object.op_Implicit((Object)(object)example))
				{
					return tier == example.tier;
				}
				return false;
			}
			return true;
		}

		private static string FriendlyTier(ItemTier tier)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected I4, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			if (SameTier(tier, (ItemTier)10, Items.CookedSteak))
			{
				return "Meal";
			}
			if (SameTier(tier, (ItemTier)11, Items.GhostBlades))
			{
				return "Hallowed";
			}
			if (SameTier(tier, (ItemTier)12, Items.PageDie))
			{
				return "Page";
			}
			if (SameTier(tier, (ItemTier)13, Items.HexCurse))
			{
				return "Hex";
			}
			return (int)tier switch
			{
				0 => "White (common)", 
				1 => "Green (uncommon)", 
				2 => "Red (legendary)", 
				4 => "Yellow (boss)", 
				3 => "Blue (lunar)", 
				6 => "Void white", 
				7 => "Void green", 
				8 => "Void red", 
				9 => "Void boss", 
				10 => "Meal", 
				11 => "Hallowed", 
				12 => "Page", 
				13 => "Hex", 
				5 => "Other (no rarity)", 
				_ => CustomTierName(tier), 
			};
		}

		private static bool HasDisplayName(string token)
		{
			string text = Language.GetString(token, "en");
			if (!string.IsNullOrWhiteSpace(text))
			{
				return text != token;
			}
			return false;
		}

		private static bool IsSelectableItem(ItemDef definition)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Invalid comparison between Unknown and I4
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)definition) && !definition.hidden && ((int)definition.tier != 5 || HasDisplayName(definition.nameToken)))
			{
				return PickupCatalog.FindPickupIndex(definition.itemIndex) != PickupIndex.none;
			}
			return false;
		}

		private static bool IsSelectableEquipment(EquipmentDef definition)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)definition) && (definition.canDrop || HasDisplayName(definition.nameToken)))
			{
				return PickupCatalog.FindPickupIndex(definition.equipmentIndex) != PickupIndex.none;
			}
			return false;
		}

		private static bool CanGrantItem(Run run, ItemIndex index)
		{
			//IL_0000: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			ItemDef itemDef = ItemCatalog.GetItemDef(index);
			if (Object.op_Implicit((Object)(object)itemDef) && !run.IsItemExpansionLocked(index) && (!Object.op_Implicit((Object)(object)itemDef.requiredExpansion) || run.IsExpansionEnabled(itemDef.requiredExpansion)))
			{
				if (!run.IsItemAvailable(index))
				{
					return RuleCatalog.FindRuleDef("Items." + ((Object)itemDef).name) == null;
				}
				return true;
			}
			return false;
		}

		private static bool CanGrantEquipment(Run run, EquipmentIndex index)
		{
			//IL_0000: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(index);
			if (Object.op_Implicit((Object)(object)equipmentDef) && !run.IsEquipmentExpansionLocked(index) && (!Object.op_Implicit((Object)(object)equipmentDef.requiredExpansion) || run.IsExpansionEnabled(equipmentDef.requiredExpansion)))
			{
				if (!run.IsEquipmentAvailable(index))
				{
					return RuleCatalog.FindRuleDef("Equipment." + ((Object)equipmentDef).name) == null;
				}
				return true;
			}
			return false;
		}

		private unsafe static string CustomTierName(ItemTier tier)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			ItemTierDef itemTierDef = ItemTierCatalog.GetItemTierDef(tier);
			if (!Object.op_Implicit((Object)(object)itemTierDef))
			{
				return ((object)(*(ItemTier*)(&tier))/*cast due to .constrained prefix*/).ToString();
			}
			return ((Object)itemTierDef).name.Replace("TierDef", "").Replace("Def", "").Replace("Tier", "");
		}

		private ConfigEntryBase CatalogChoice(string section, string key, string help, IEnumerable<(int index, string name)> entries, string suffix, out Dictionary<int, int> indices)
		{
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Expected O, but got Unknown
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Expected O, but got Unknown
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Expected O, but got Unknown
			//IL_01d9: Expected O, but got Unknown
			EnumBuilder enumBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("local.ror2.startingitems" + suffix), AssemblyBuilderAccess.Run).DefineDynamicModule("Catalog").DefineEnum("StartingItems.Catalog" + suffix, TypeAttributes.Public, typeof(int));
			enumBuilder.DefineLiteral("None", 0);
			enumBuilder.DefineLiteral("Random", 1);
			indices = new Dictionary<int, int>
			{
				[0] = -1,
				[1] = -2
			};
			int num = 2;
			HashSet<string> hashSet = new HashSet<string> { "None", "Random" };
			foreach (var item in entries.OrderBy(((int index, string name) e) => e.name))
			{
				string text = item.name;
				if (!hashSet.Add(text))
				{
					text = text + " [" + item.index + "]";
					hashSet.Add(text);
				}
				enumBuilder.DefineLiteral(text, num);
				(indices[num++], _) = item;
			}
			Type type = enumBuilder.CreateTypeInfo().AsType();
			ConfigEntryBase val = (ConfigEntryBase)typeof(ConfigFile).GetMethods().Single((MethodInfo m) => m.Name == "Bind" && m.IsGenericMethodDefinition && m.GetParameters().Length == 4 && m.GetParameters()[0].ParameterType == typeof(string) && m.GetParameters()[3].ParameterType == typeof(ConfigDescription)).MakeGenericMethod(type)
				.Invoke(((BaseUnityPlugin)this).Config, new object[4]
				{
					section,
					key,
					Enum.ToObject(type, 0),
					(object)new ConfigDescription(help, (AcceptableValueBase)null, Array.Empty<object>())
				});
			ModSettingsManager.AddOption((BaseOption)new ChoiceOption(val));
			return val;
		}

		private void ClearSelections()
		{
			foreach (EditorEntry editorEntry in editorEntries)
			{
				editorEntry.Count.Value = 0;
			}
			foreach (ConfigEntryBase value in selections.Values)
			{
				value.BoxedValue = Enum.ToObject(value.SettingType, 0);
			}
			if (equipment != null)
			{
				equipment.BoxedValue = Enum.ToObject(equipment.SettingType, 0);
			}
			advanced.Value = false;
			cashEnabled.Value = false;
		}

		private void Starter()
		{
			//IL_0030: 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)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			ClearSelections();
			modEnabled.Value = true;
			simple.Value = true;
			ItemTier[] array = (ItemTier[])(object)new ItemTier[2]
			{
				default(ItemTier),
				(ItemTier)1
			};
			foreach (ItemTier val in array)
			{
				if (selections.TryGetValue(val, out var value))
				{
					value.BoxedValue = Enum.ToObject(value.SettingType, 1);
					amounts[val].Value = (((int)val != 0) ? 1 : 2);
				}
			}
		}

		private static void Spawned(Run __instance, CharacterBody characterBody)
		{
			if (Object.op_Implicit((Object)(object)instance))
			{
				instance.Grant(__instance, characterBody);
			}
		}

		private unsafe void Grant(Run run, CharacterBody body)
		{
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_039b: Invalid comparison between Unknown and I4
			//IL_0388: 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_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_041e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: 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_0430: Unknown result type (might be due to invalid IL or missing references)
			//IL_0436: Invalid comparison between Unknown and I4
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0440: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_044f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active || !ready || !modEnabled.Value || !Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.master) || !Object.op_Implicit((Object)(object)body.master.playerCharacterMasterController))
			{
				return;
			}
			CharacterMaster master = body.master;
			if (granted.Contains(master) || !Object.op_Implicit((Object)(object)master.inventory))
			{
				return;
			}
			Inventory inventory = master.inventory;
			Dictionary<PickupIndex, int> dictionary = new Dictionary<PickupIndex, int>();
			try
			{
				if (simple.Value)
				{
					foreach (EditorEntry editorEntry in editorEntries)
					{
						if (editorEntry.Count.Value > 0)
						{
							Add(dictionary, editorEntry.Pickup, editorEntry.Count.Value);
						}
					}
					foreach (KeyValuePair<ItemTier, ConfigEntryBase> pair in selections)
					{
						int num = catalogIndices[pair.Key][Convert.ToInt32(pair.Value.BoxedValue)];
						int value = amounts[pair.Key].Value;
						if (value <= 0 || num == -1)
						{
							continue;
						}
						ItemIndex val = (ItemIndex)num;
						if (num == -2)
						{
							Item