Decompiled source of itemmenu v1.0.0

BepInEx/Plugins/itemmenu/ExamplePlugin.dll

Decompiled 16 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HG;
using Microsoft.CodeAnalysis;
using R2API.Networking;
using R2API.Networking.Interfaces;
using R2API.Utils;
using RoR2;
using RoR2.UI;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ExamplePlugin")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ExamplePlugin")]
[assembly: AssemblyTitle("ExamplePlugin")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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 ExamplePlugin
{
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
}
namespace ItemMenu
{
	[BepInPlugin("com.steepercreve.itemmenu", "Item Menu", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class ExamplePlugin : BaseUnityPlugin
	{
		private class ItemEntry
		{
			public string DisplayName;

			public ItemIndex ItemIndex;

			public EquipmentIndex EquipmentIndex;

			public bool IsEquipment;
		}

		private const KeyCode ToggleKey = (KeyCode)286;

		private bool menuOpen;

		private bool showingItems;

		private string selectedCategory = "";

		private GameObject menuRoot;

		private GameObject menuPanel;

		private GameObject itemContent;

		private ScrollRect itemScrollRect;

		private MPEventSystem cursorEventSystem;

		private bool cursorOpened;

		private HUD currentHud;

		private Font menuFont;

		private readonly Color backgroundColor = new Color(0.055f, 0.065f, 0.085f, 0.97f);

		private readonly Color panelColor = new Color(0.1f, 0.115f, 0.14f, 0.98f);

		private readonly Color buttonColor = new Color(0.15f, 0.17f, 0.2f, 1f);

		private readonly Color buttonHoverColor = new Color(0.24f, 0.29f, 0.35f, 1f);

		private readonly Color accentColor = new Color(0.78f, 0.66f, 0.34f, 1f);

		private void Awake()
		{
			NetworkingAPI.RegisterMessageType<GiveItemRequest>();
			menuFont = Resources.GetBuiltinResource<Font>("Arial.ttf");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Item Menu loaded. Press F5 to open.");
		}

		private void Update()
		{
			if (Input.GetKeyDown((KeyCode)286))
			{
				if (menuOpen)
				{
					CloseMenu();
				}
				else
				{
					OpenMenu();
				}
			}
			if (menuOpen && ((Object)(object)currentHud == (Object)null || (Object)(object)menuRoot == (Object)null))
			{
				DestroyMenuObjects();
				TryCreateMenu();
			}
		}

		private void OpenMenu()
		{
			if (!menuOpen)
			{
				menuOpen = true;
				showingItems = false;
				selectedCategory = "";
				TryCreateMenu();
				OpenGameCursor();
			}
		}

		private void CloseMenu()
		{
			menuOpen = false;
			showingItems = false;
			selectedCategory = "";
			DestroyMenuObjects();
			CloseGameCursor();
		}

		private void OpenGameCursor()
		{
			if (!cursorOpened)
			{
				cursorEventSystem = MPEventSystemManager.primaryEventSystem;
				if ((Object)(object)cursorEventSystem != (Object)null)
				{
					MPEventSystem obj = cursorEventSystem;
					int cursorOpenerCount = obj.cursorOpenerCount;
					obj.cursorOpenerCount = cursorOpenerCount + 1;
					MPEventSystem obj2 = cursorEventSystem;
					cursorOpenerCount = obj2.cursorOpenerForGamepadCount;
					obj2.cursorOpenerForGamepadCount = cursorOpenerCount + 1;
					cursorOpened = true;
				}
				Cursor.visible = true;
				Cursor.lockState = (CursorLockMode)0;
			}
		}

		private void CloseGameCursor()
		{
			if (cursorOpened && (Object)(object)cursorEventSystem != (Object)null)
			{
				cursorEventSystem.cursorOpenerCount = Mathf.Max(0, cursorEventSystem.cursorOpenerCount - 1);
				cursorEventSystem.cursorOpenerForGamepadCount = Mathf.Max(0, cursorEventSystem.cursorOpenerForGamepadCount - 1);
			}
			cursorOpened = false;
			cursorEventSystem = null;
		}

		private void OnDestroy()
		{
			CloseGameCursor();
			DestroyMenuObjects();
		}

		private void DestroyMenuObjects()
		{
			if ((Object)(object)menuRoot != (Object)null)
			{
				Object.Destroy((Object)(object)menuRoot);
			}
			menuRoot = null;
			menuPanel = null;
			itemContent = null;
			itemScrollRect = null;
			currentHud = null;
		}

		private void TryCreateMenu()
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_0090: 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_00a8: 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)
			if (!menuOpen)
			{
				return;
			}
			HUD val = Object.FindObjectOfType<HUD>();
			if (!((Object)(object)val == (Object)null) && !((Object)(object)val.mainContainer == (Object)null))
			{
				currentHud = val;
				menuRoot = new GameObject("ItemMenuRoot", new Type[1] { typeof(RectTransform) });
				menuRoot.transform.SetParent(val.mainContainer.transform, false);
				RectTransform component = menuRoot.GetComponent<RectTransform>();
				component.anchorMin = Vector2.zero;
				component.anchorMax = Vector2.one;
				component.offsetMin = Vector2.zero;
				component.offsetMax = Vector2.zero;
				CanvasGroup val2 = menuRoot.AddComponent<CanvasGroup>();
				val2.interactable = true;
				val2.blocksRaycasts = true;
				CreateMainPanel();
				if (showingItems)
				{
					ShowItemSelection();
				}
				else
				{
					ShowCategorySelection();
				}
			}
		}

		private GameObject CreateUIObject(string name, Transform parent, Vector2 anchorMin, Vector2 anchorMax, Vector2 size, Vector2 position)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent, false);
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = anchorMin;
			component.anchorMax = anchorMax;
			component.sizeDelta = size;
			component.anchoredPosition = position;
			return val;
		}

		private Image CreateImage(GameObject obj, Color color, Sprite sprite = null)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			Image val = obj.AddComponent<Image>();
			((Graphic)val).color = color;
			val.sprite = sprite;
			((Graphic)val).raycastTarget = true;
			return val;
		}

		private void CreateMainPanel()
		{
			//IL_001d: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			menuPanel = CreateUIObject("ItemMenuPanel", menuRoot.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(1050f, 700f), Vector2.zero);
			CreateImage(menuPanel, backgroundColor);
			Outline val = menuPanel.AddComponent<Outline>();
			((Shadow)val).effectColor = new Color(accentColor.r, accentColor.g, accentColor.b, 0.7f);
			((Shadow)val).effectDistance = new Vector2(2f, 2f);
			CreateHeader();
		}

		private void CreateHeader()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateUIObject("Header", menuPanel.transform, new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(0f, 85f), new Vector2(0f, -42f));
			CreateImage(val, panelColor);
			CreateText("ITEM MENU", val.transform, 26, (FontStyle)1, (TextAnchor)4, Color.white, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(600f, 60f), Vector2.zero);
			GameObject val2 = CreateButton("X", val.transform, new Vector2(1f, 0.5f), new Vector2(1f, 0.5f), new Vector2(55f, 55f), new Vector2(-43f, 0f), CloseMenu);
			((Graphic)val2.GetComponent<Image>()).color = new Color(0.45f, 0.13f, 0.13f, 1f);
			Text componentInChildren = val2.GetComponentInChildren<Text>();
			componentInChildren.fontSize = 24;
		}

		private Text CreateText(string text, Transform parent, int fontSize, FontStyle fontStyle, TextAnchor alignment, Color color, Vector2 anchorMin, Vector2 anchorMax, Vector2 size, Vector2 position)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateUIObject("Text", parent, anchorMin, anchorMax, size, position);
			Text val2 = val.AddComponent<Text>();
			val2.text = text;
			val2.font = menuFont;
			val2.fontSize = fontSize;
			val2.fontStyle = fontStyle;
			val2.alignment = alignment;
			((Graphic)val2).color = color;
			val2.horizontalOverflow = (HorizontalWrapMode)0;
			val2.verticalOverflow = (VerticalWrapMode)0;
			((Graphic)val2).raycastTarget = false;
			return val2;
		}

		private GameObject CreateButton(string text, Transform parent, Vector2 anchorMin, Vector2 anchorMax, Vector2 size, Vector2 position, Action onClick)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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_002c: 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_004d: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateUIObject("Button_" + text, parent, anchorMin, anchorMax, size, position);
			Image targetGraphic = CreateImage(val, buttonColor);
			Button val2 = val.AddComponent<Button>();
			((Selectable)val2).targetGraphic = (Graphic)(object)targetGraphic;
			ColorBlock colors = ((Selectable)val2).colors;
			((ColorBlock)(ref colors)).normalColor = buttonColor;
			((ColorBlock)(ref colors)).highlightedColor = buttonHoverColor;
			((ColorBlock)(ref colors)).pressedColor = accentColor;
			((ColorBlock)(ref colors)).selectedColor = buttonHoverColor;
			((ColorBlock)(ref colors)).fadeDuration = 0.12f;
			((Selectable)val2).colors = colors;
			((UnityEvent)val2.onClick).AddListener((UnityAction)delegate
			{
				onClick();
			});
			CreateText(text, val.transform, 19, (FontStyle)1, (TextAnchor)4, Color.white, Vector2.zero, Vector2.one, Vector2.zero, Vector2.zero);
			return val;
		}

		private void ClearPanelContent()
		{
			if ((Object)(object)menuPanel == (Object)null)
			{
				return;
			}
			for (int num = menuPanel.transform.childCount - 1; num >= 0; num--)
			{
				Transform child = menuPanel.transform.GetChild(num);
				if (((Object)child).name != "Header")
				{
					Object.Destroy((Object)(object)((Component)child).gameObject);
				}
			}
		}

		private void ShowCategorySelection()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: 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_0125: 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)
			ClearPanelContent();
			CreateText("SELECT AN ITEM CATEGORY", menuPanel.transform, 18, (FontStyle)1, (TextAnchor)4, accentColor, new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(0f, 45f), new Vector2(0f, -115f));
			string[] array = new string[6] { "White", "Green", "Red", "Yellow", "Lunar", "Void" };
			float num = -420f;
			float num2 = 168f;
			for (int i = 0; i < array.Length; i++)
			{
				string category = array[i];
				CreateCategoryButton(category, new Vector2(num + num2 * (float)i, 35f), new Vector2(150f, 180f));
			}
			CreateCategoryButton("Equipment", new Vector2(-170f, -185f), new Vector2(250f, 180f));
			CreateCategoryButton("Lunar Equipment", new Vector2(170f, -185f), new Vector2(250f, 180f));
		}

		private void CreateCategoryButton(string category, Vector2 position, Vector2 size)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateButton(category, menuPanel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), size, position, delegate
			{
				selectedCategory = category;
				showingItems = true;
				ShowItemSelection();
			});
			((Graphic)val.GetComponent<Image>()).color = GetCategoryColor(category);
			Text componentInChildren = val.GetComponentInChildren<Text>();
			componentInChildren.fontSize = 20;
		}

		private Color GetCategoryColor(string category)
		{
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: 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_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: 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_01d8: 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_01c1: 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_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			return (Color)(category switch
			{
				"White" => new Color(0.68f, 0.68f, 0.68f), 
				"Green" => new Color(0.22f, 0.52f, 0.28f), 
				"Red" => new Color(0.62f, 0.18f, 0.18f), 
				"Yellow" => new Color(0.67f, 0.52f, 0.15f), 
				"Lunar" => new Color(0.22f, 0.38f, 0.66f), 
				"Void" => new Color(0.4f, 0.18f, 0.56f), 
				"Equipment" => new Color(0.67f, 0.35f, 0.12f), 
				"Lunar Equipment" => new Color(0.22f, 0.38f, 0.66f), 
				_ => buttonColor, 
			});
		}

		private void ShowItemSelection()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			ClearPanelContent();
			List<ItemEntry> itemsForCategory = GetItemsForCategory(selectedCategory);
			CreateText(selectedCategory.ToUpperInvariant(), menuPanel.transform, 23, (FontStyle)1, (TextAnchor)4, accentColor, new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(0f, 45f), new Vector2(0f, -115f));
			CreateText(itemsForCategory.Count + " AVAILABLE ITEMS", menuPanel.transform, 13, (FontStyle)0, (TextAnchor)4, new Color(0.72f, 0.72f, 0.75f), new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(0f, 30f), new Vector2(0f, -150f));
			CreateItemScrollView(itemsForCategory);
			CreateButton("BACK", menuPanel.transform, new Vector2(1f, 0f), new Vector2(1f, 0f), new Vector2(130f, 45f), new Vector2(-90f, 40f), delegate
			{
				showingItems = false;
				selectedCategory = "";
				ShowCategorySelection();
			});
		}

		private void CreateItemScrollView(List<ItemEntry> entries)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: 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_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Expected O, but got Unknown
			GameObject val = CreateUIObject("ItemScrollView", menuPanel.transform, new Vector2(0f, 0f), new Vector2(1f, 1f), new Vector2(-45f, -245f), new Vector2(0f, -5f));
			CreateImage(val, new Color(0.035f, 0.04f, 0.055f, 0.8f));
			ScrollRect val2 = val.AddComponent<ScrollRect>();
			val2.horizontal = false;
			val2.vertical = true;
			val2.movementType = (MovementType)2;
			val2.scrollSensitivity = 35f;
			GameObject val3 = CreateUIObject("Viewport", val.transform, Vector2.zero, Vector2.one, Vector2.zero, Vector2.zero);
			CreateImage(val3, new Color(1f, 1f, 1f, 0.01f));
			Mask val4 = val3.AddComponent<Mask>();
			val4.showMaskGraphic = false;
			GameObject val5 = CreateUIObject("Content", val3.transform, new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(0f, 0f), Vector2.zero);
			GridLayoutGroup val6 = val5.AddComponent<GridLayoutGroup>();
			val6.cellSize = new Vector2(220f, 95f);
			val6.spacing = new Vector2(12f, 12f);
			((LayoutGroup)val6).padding = new RectOffset(12, 12, 12, 12);
			val6.constraint = (Constraint)1;
			val6.constraintCount = 4;
			val6.startCorner = (Corner)0;
			val6.startAxis = (Axis)0;
			((LayoutGroup)val6).childAlignment = (TextAnchor)1;
			ContentSizeFitter val7 = val5.AddComponent<ContentSizeFitter>();
			val7.verticalFit = (FitMode)2;
			val7.horizontalFit = (FitMode)0;
			val2.viewport = val3.GetComponent<RectTransform>();
			val2.content = val5.GetComponent<RectTransform>();
			itemScrollRect = val2;
			itemContent = val5;
			foreach (ItemEntry entry in entries)
			{
				CreateItemButton(entry);
			}
		}

		private void CreateItemButton(ItemEntry entry)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: 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_0103: Expected O, but got Unknown
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateUIObject("Item_" + entry.DisplayName, itemContent.transform, Vector2.zero, Vector2.zero, new Vector2(220f, 95f), Vector2.zero);
			Image targetGraphic = CreateImage(val, new Color(0.13f, 0.15f, 0.19f, 1f));
			Button val2 = val.AddComponent<Button>();
			((Selectable)val2).targetGraphic = (Graphic)(object)targetGraphic;
			ColorBlock colors = ((Selectable)val2).colors;
			((ColorBlock)(ref colors)).normalColor = new Color(1f, 1f, 1f, 1f);
			((ColorBlock)(ref colors)).highlightedColor = new Color(1.15f, 1.15f, 1.15f, 1f);
			((ColorBlock)(ref colors)).pressedColor = accentColor;
			((Selectable)val2).colors = colors;
			((UnityEvent)val2.onClick).AddListener((UnityAction)delegate
			{
				RequestGiveItem(entry);
			});
			CreateText(entry.DisplayName, val.transform, 14, (FontStyle)1, (TextAnchor)4, Color.white, Vector2.zero, Vector2.one, new Vector2(-16f, -12f), Vector2.zero);
		}

		private List<ItemEntry> GetItemsForCategory(string category)
		{
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Invalid comparison between Unknown and I4
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: 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_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			List<ItemEntry> list = new List<ItemEntry>();
			Run instance = Run.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return list;
			}
			if (category == "Equipment" || category == "Lunar Equipment")
			{
				EquipmentDef[] equipmentDefs = EquipmentCatalog.equipmentDefs;
				foreach (EquipmentDef val in equipmentDefs)
				{
					if (!((Object)(object)val == (Object)null))
					{
						EquipmentIndex equipmentIndex = val.equipmentIndex;
						if ((int)equipmentIndex != -1 && instance.IsEquipmentAvailable(equipmentIndex) && (!((Object)(object)val.requiredExpansion != (Object)null) || instance.IsExpansionEnabled(val.requiredExpansion)) && (!(category == "Lunar Equipment") || val.isLunar) && (!(category == "Equipment") || !val.isLunar))
						{
							list.Add(new ItemEntry
							{
								DisplayName = Language.GetString(val.nameToken),
								EquipmentIndex = equipmentIndex,
								IsEquipment = true
							});
						}
					}
				}
			}
			else
			{
				Enumerator<ItemDef> enumerator = ItemCatalog.allItemDefs.GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						ItemDef current = enumerator.Current;
						if (!((Object)(object)current == (Object)null) && !current.hidden)
						{
							ItemIndex itemIndex = current.itemIndex;
							if ((int)itemIndex != -1 && instance.IsItemAvailable(itemIndex) && (!((Object)(object)current.requiredExpansion != (Object)null) || instance.IsExpansionEnabled(current.requiredExpansion)) && IsInCategory(current.tier, category))
							{
								list.Add(new ItemEntry
								{
									DisplayName = Language.GetString(current.nameToken),
									ItemIndex = itemIndex,
									IsEquipment = false
								});
							}
						}
					}
				}
				finally
				{
					((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
				}
			}
			return list.OrderBy((ItemEntry entry) => entry.DisplayName).ToList();
		}

		private bool IsInCategory(ItemTier tier, string category)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Invalid comparison between Unknown and I4
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Invalid comparison between Unknown and I4
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Invalid comparison between Unknown and I4
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Invalid comparison between Unknown and I4
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Invalid comparison between Unknown and I4
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Invalid comparison between Unknown and I4
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Invalid comparison between Unknown and I4
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Invalid comparison between Unknown and I4
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Invalid comparison between Unknown and I4
			return category switch
			{
				"White" => (int)tier == 0, 
				"Green" => (int)tier == 1, 
				"Red" => (int)tier == 2, 
				"Yellow" => (int)tier == 4, 
				"Lunar" => (int)tier == 3, 
				"Void" => (int)tier == 6 || (int)tier == 7 || (int)tier == 8 || (int)tier == 9, 
				_ => false, 
			};
		}

		private void RequestGiveItem(ItemEntry entry)
		{
			//IL_006c: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected I4, but got Unknown
			if (entry == null)
			{
				return;
			}
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			if (firstLocalUser == null || (Object)(object)firstLocalUser.cachedBody == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"Cannot give item: no local player body.");
				return;
			}
			NetworkIdentity component = ((Component)firstLocalUser.cachedBody).GetComponent<NetworkIdentity>();
			if ((Object)(object)component == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"Cannot give item: no NetworkIdentity.");
			}
			else
			{
				NetMessageExtensions.Send((INetMessage)(object)new GiveItemRequest(component.netId, entry.IsEquipment, (int)(entry.IsEquipment ? entry.EquipmentIndex : entry.ItemIndex)), (NetworkDestination)2);
			}
		}
	}
	public class GiveItemRequest : INetMessage, ISerializableObject
	{
		private NetworkInstanceId bodyNetId;

		private bool isEquipment;

		private int itemIndex;

		public GiveItemRequest()
		{
		}

		public GiveItemRequest(NetworkInstanceId bodyNetId, bool isEquipment, int itemIndex)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			this.bodyNetId = bodyNetId;
			this.isEquipment = isEquipment;
			this.itemIndex = itemIndex;
		}

		public void Serialize(NetworkWriter writer)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			writer.Write(bodyNetId);
			writer.Write(isEquipment);
			writer.Write(itemIndex);
		}

		public void Deserialize(NetworkReader reader)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			bodyNetId = reader.ReadNetworkId();
			isEquipment = reader.ReadBoolean();
			itemIndex = reader.ReadInt32();
		}

		public void OnReceived()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Invalid comparison between Unknown and I4
			//IL_00bb: 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_00c0: Invalid comparison between Unknown and I4
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: 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_01c5: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				return;
			}
			GameObject val = NetworkServer.FindLocalObject(bodyNetId);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			CharacterBody component = val.GetComponent<CharacterBody>();
			if ((Object)(object)component == (Object)null || (Object)(object)component.master == (Object)null || (Object)(object)component.master.playerCharacterMasterController == (Object)null)
			{
				return;
			}
			Inventory inventory = component.inventory;
			if ((Object)(object)inventory == (Object)null || (Object)(object)Run.instance == (Object)null)
			{
				return;
			}
			if (isEquipment)
			{
				EquipmentIndex val2 = (EquipmentIndex)itemIndex;
				if ((int)val2 != -1)
				{
					EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(val2);
					if (!((Object)(object)equipmentDef == (Object)null) && Run.instance.IsEquipmentAvailable(val2) && (!((Object)(object)equipmentDef.requiredExpansion != (Object)null) || Run.instance.IsExpansionEnabled(equipmentDef.requiredExpansion)))
					{
						inventory.SetEquipmentIndex(val2, false);
					}
				}
				return;
			}
			ItemIndex val3 = (ItemIndex)itemIndex;
			if ((int)val3 != -1)
			{
				ItemDef itemDef = ItemCatalog.GetItemDef(val3);
				if (!((Object)(object)itemDef == (Object)null) && !itemDef.hidden && Run.instance.IsItemAvailable(val3) && (!((Object)(object)itemDef.requiredExpansion != (Object)null) || Run.instance.IsExpansionEnabled(itemDef.requiredExpansion)))
				{
					inventory.GiveItem(val3, 1);
				}
			}
		}
	}
}