Decompiled source of MoreEquipWheels v1.5.3

EquipWheelFour.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EquipWheel;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("EquipWheelFour")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("EquipWheelFour")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8283404d-c1d8-467a-b657-db0cb63c8949")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.5", FrameworkDisplayName = "")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace EquipWheelFour;

[BepInPlugin("virtuacode.valheim.equipwheelfour", "Equip Wheel Mod (EquipWheelFour)", "1.5.3")]
public class EquipWheel : BaseUnityPlugin, IWheel
{
	private static Harmony harmony;

	public static ManualLogSource MyLogger = Logger.CreateLogSource(Assembly.GetExecutingAssembly().GetName().Name);

	public static ConfigEntry<KeyboardShortcut> Hotkey;

	public static ConfigEntry<DPadButton> HotkeyDPad;

	public static ConfigEntry<bool> UseSitButton;

	public static ConfigEntry<bool> TriggerOnRelease;

	public static ConfigEntry<bool> TriggerOnClick;

	public static ConfigEntry<bool> ToggleMenu;

	public static ConfigEntry<bool> ModEnabled;

	public static ConfigEntry<Color> HighlightColor;

	public static ConfigEntry<float> GuiScale;

	public static ConfigEntry<int> InventoryRow;

	public static ConfigEntry<bool> ItemFiltering;

	public static ConfigEntry<ItemType> ItemType1;

	public static ConfigEntry<ItemType> ItemType2;

	public static ConfigEntry<ItemType> ItemType3;

	public static ConfigEntry<ItemType> ItemType4;

	public static ConfigEntry<ItemType> ItemType5;

	public static ConfigEntry<ItemType> ItemType6;

	public static ConfigEntry<string> ItemRegex;

	public static ConfigEntry<string> ItemRegexIgnore;

	public static ConfigEntry<bool> ItemRegexCaseSensitive;

	private static EquipWheel instance;

	public static KeyCode replacedKey = (KeyCode)0;

	public static List<string> replacedButtons = new List<string>();

	public static float JoyStickIgnoreTime = 0f;

	public static EquipGui Gui;

	public static Color GetHighlightColor => HighlightColor.Value;

	public static EquipWheel Instance => instance;

	public static bool CanOpenMenu
	{
		get
		{
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer == (Object)null) && !((Character)localPlayer).IsDead() && !((Character)localPlayer).InCutscene() && !((Character)localPlayer).IsTeleporting() && TakeInput(look: true) && !InInventoryEtc() && !WheelManager.inventoryVisible)
			{
				if (IsUsingUseButton())
				{
					return !WheelManager.pressedOnHovering;
				}
				return true;
			}
			return false;
		}
	}

	public static bool BestMatchPressed
	{
		get
		{
			if ((Object)(object)Instance == (Object)null)
			{
				return false;
			}
			return WheelManager.BestMatchPressed((IWheel)(object)Instance);
		}
	}

	public static bool BestMatchDown
	{
		get
		{
			if ((Object)(object)Instance == (Object)null)
			{
				return false;
			}
			return WheelManager.BestMatchDown((IWheel)(object)Instance);
		}
	}

	public static bool IsShortcutDown
	{
		get
		{
			//IL_009c: 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_00a4: 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_002b: Expected I4, but got Unknown
			if (ZInput.IsGamepadActive())
			{
				DPadButton value = HotkeyDPad.Value;
				switch ((int)value)
				{
				case 0:
					if (UseSitButton.Value)
					{
						return ZInput.GetButtonDown("JoySit");
					}
					return ZInput.GetButtonDown("JoyUse");
				case 1:
					return ZInput.GetButtonDown("JoyHotbarLeft");
				case 2:
					return ZInput.GetButtonDown("JoyHotbarRight");
				case 3:
					if (!ZInput.GetButtonDown("JoyHotbarRight"))
					{
						return ZInput.GetButtonDown("JoyHotbarLeft");
					}
					return true;
				default:
					if (!ZInput.GetButtonDown("JoyHotbarRight"))
					{
						return ZInput.GetButtonDown("JoyHotbarLeft");
					}
					return true;
				}
			}
			KeyboardShortcut value2 = Hotkey.Value;
			KeyCode mainKey = ((KeyboardShortcut)(ref value2)).MainKey;
			KeyCode[] source = ((KeyboardShortcut)(ref value2)).Modifiers.ToArray();
			if (!Input.GetKeyDown(mainKey))
			{
				return ((IEnumerable<KeyCode>)source).Any((Func<KeyCode, bool>)Input.GetKeyDown);
			}
			return true;
		}
	}

	public static bool IsShortcutUp
	{
		get
		{
			//IL_009c: 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_00a4: 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_002b: Expected I4, but got Unknown
			if (ZInput.IsGamepadActive())
			{
				DPadButton value = HotkeyDPad.Value;
				switch ((int)value)
				{
				case 0:
					if (UseSitButton.Value)
					{
						return ZInput.GetButtonUp("JoySit");
					}
					return ZInput.GetButtonUp("JoyUse");
				case 1:
					return ZInput.GetButtonUp("JoyHotbarLeft");
				case 2:
					return ZInput.GetButtonUp("JoyHotbarRight");
				case 3:
					if (!ZInput.GetButtonUp("JoyHotbarRight"))
					{
						return ZInput.GetButtonUp("JoyHotbarLeft");
					}
					return true;
				default:
					if (!ZInput.GetButtonUp("JoyHotbarRight"))
					{
						return ZInput.GetButtonUp("JoyHotbarLeft");
					}
					return true;
				}
			}
			KeyboardShortcut value2 = Hotkey.Value;
			KeyCode mainKey = ((KeyboardShortcut)(ref value2)).MainKey;
			KeyCode[] source = ((KeyboardShortcut)(ref value2)).Modifiers.ToArray();
			if (!Input.GetKeyUp(mainKey))
			{
				return ((IEnumerable<KeyCode>)source).Any((Func<KeyCode, bool>)Input.GetKeyUp);
			}
			return true;
		}
	}

	public static bool IsShortcutPressed
	{
		get
		{
			//IL_009c: 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_00a4: 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_002b: Expected I4, but got Unknown
			if (ZInput.IsGamepadActive())
			{
				DPadButton value = HotkeyDPad.Value;
				switch ((int)value)
				{
				case 0:
					if (UseSitButton.Value)
					{
						return ZInput.GetButton("JoySit");
					}
					return ZInput.GetButton("JoyUse");
				case 1:
					return ZInput.GetButton("JoyHotbarLeft");
				case 2:
					return ZInput.GetButton("JoyHotbarRight");
				case 3:
					if (!ZInput.GetButton("JoyHotbarRight"))
					{
						return ZInput.GetButton("JoyHotbarLeft");
					}
					return true;
				default:
					if (!ZInput.GetButton("JoyHotbarRight"))
					{
						return ZInput.GetButton("JoyHotbarLeft");
					}
					return true;
				}
			}
			KeyboardShortcut value2 = Hotkey.Value;
			KeyCode mainKey = ((KeyboardShortcut)(ref value2)).MainKey;
			KeyCode[] source = ((KeyboardShortcut)(ref value2)).Modifiers.ToArray();
			if (!Input.GetKey(mainKey))
			{
				return ((IEnumerable<KeyCode>)source).Any((Func<KeyCode, bool>)Input.GetKey);
			}
			return true;
		}
	}

	public static void Log(string msg)
	{
		ManualLogSource myLogger = MyLogger;
		if (myLogger != null)
		{
			myLogger.LogInfo((object)msg);
		}
	}

	public static void LogErr(string msg)
	{
		ManualLogSource myLogger = MyLogger;
		if (myLogger != null)
		{
			myLogger.LogError((object)msg);
		}
	}

	public static void LogWarn(string msg)
	{
		ManualLogSource myLogger = MyLogger;
		if (myLogger != null)
		{
			myLogger.LogWarning((object)msg);
		}
	}

	private static bool TakeInput(bool look = false)
	{
		if (!GameCamera.InFreeFly() && (!Object.op_Implicit((Object)(object)Chat.instance) || !Chat.instance.HasFocus()) && !Menu.IsVisible() && !Console.IsVisible() && !TextInput.IsVisible() && !Minimap.InTextInput() && (!ZInput.IsGamepadActive() || !Minimap.IsOpen()) && (!ZInput.IsGamepadActive() || !StoreGui.IsVisible()) && (!ZInput.IsGamepadActive() || !Hud.IsPieceSelectionVisible()) && (!PlayerCustomizaton.IsBarberGuiVisible() || look))
		{
			if (PlayerCustomizaton.BarberBlocksLook())
			{
				return !look;
			}
			return true;
		}
		return false;
	}

	private static bool InInventoryEtc()
	{
		if (!Minimap.IsOpen() && !StoreGui.IsVisible())
		{
			return Hud.IsPieceSelectionVisible();
		}
		return true;
	}

	public static bool IsDedicated()
	{
		MethodInfo method = typeof(ZNet).GetMethod("IsDedicated", BindingFlags.Instance | BindingFlags.Public);
		return ((Func<ZNet, bool>)Delegate.CreateDelegate(typeof(Func<ZNet, bool>), method))(null);
	}

	public static bool IsUsingUseButton()
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		if (ZInput.IsGamepadActive() && (int)HotkeyDPad.Value == 0)
		{
			return !UseSitButton.Value;
		}
		return false;
	}

	public void Awake()
	{
		//IL_003b: 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_0169: Unknown result type (might be due to invalid IL or missing references)
		//IL_0173: Expected O, but got Unknown
		instance = this;
		ModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ModEnabled", true, "Enable mod when value is true");
		Hotkey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Input", "Hotkey", KeyboardShortcut.Deserialize("G"), "Hotkey for opening equip wheel menu");
		HotkeyDPad = ((BaseUnityPlugin)this).Config.Bind<DPadButton>("Input", "HotkeyDPad", (DPadButton)0, "Hotkey on the D-Pad (None, Left, Right or LeftOrRight)");
		UseSitButton = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "UseSitButton", false, "When enabled use the sit button as hotkey (HotkeyDPad has to be set to None)");
		TriggerOnRelease = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "TriggerOnRelease", true, "Releasing the Hotkey will equip/use the selected item");
		TriggerOnClick = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "TriggerOnClick", false, "Click with left mouse button will equip/use the selected item");
		ToggleMenu = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "ToggleMenu", false, "When enabled the equip wheel will toggle between hidden/visible when the hotkey was pressed");
		HighlightColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Appereance", "HighlightColor", new Color(0.414f, 0.734f, 1f), "Color of the highlighted selection");
		GuiScale = ((BaseUnityPlugin)this).Config.Bind<float>("Appereance", "GuiScale", 0.5f, "Scale factor of the user interface");
		InventoryRow = ((BaseUnityPlugin)this).Config.Bind<int>("Misc", "InventoryRow", 1, new ConfigDescription("Row of the inventory that should be used for the equip wheel", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 4), new object[0]));
		ItemFiltering = ((BaseUnityPlugin)this).Config.Bind<bool>("Misc", "ItemFiltering", false, "Will scan the whole inventory for items of the specified item types and Regex and show them in the equip wheel");
		ItemType1 = ((BaseUnityPlugin)this).Config.Bind<ItemType>("Misc", "ItemType1", (ItemType)0, "Item type used for filtering items");
		ItemType2 = ((BaseUnityPlugin)this).Config.Bind<ItemType>("Misc", "ItemType2", (ItemType)0, "Item type used for filtering items");
		ItemType3 = ((BaseUnityPlugin)this).Config.Bind<ItemType>("Misc", "ItemType3", (ItemType)0, "Item type used for filtering items");
		ItemType4 = ((BaseUnityPlugin)this).Config.Bind<ItemType>("Misc", "ItemType4", (ItemType)0, "Item type used for filtering items");
		ItemType5 = ((BaseUnityPlugin)this).Config.Bind<ItemType>("Misc", "ItemType5", (ItemType)0, "Item type used for filtering items");
		ItemType6 = ((BaseUnityPlugin)this).Config.Bind<ItemType>("Misc", "ItemType6", (ItemType)0, "Item type used for filtering items");
		ItemRegex = ((BaseUnityPlugin)this).Config.Bind<string>("Misc", "ItemRegex", "", "Regex used for filtering items");
		ItemRegexIgnore = ((BaseUnityPlugin)this).Config.Bind<string>("Misc", "ItemRegexIgnore", "", "Regex used for ignoring items");
		ItemRegexCaseSensitive = ((BaseUnityPlugin)this).Config.Bind<bool>("Misc", "ItemRegexCaseSensitive", false, "When enabled the Regex will be case-sensitive");
		if (!ModEnabled.Value)
		{
			LogWarn("Mod not loaded because it was disabled via config.");
			return;
		}
		if (IsDedicated())
		{
			LogWarn("Mod not loaded because game instance is a dedicated server.");
			return;
		}
		harmony = Harmony.CreateAndPatchAll(typeof(Patcher), (string)null);
		WheelManager.AddWheel((IWheel)(object)this);
		Log(((object)this).GetType().Namespace + " Loaded!");
	}

	private void OnDestroy()
	{
		WheelManager.RemoveWheel((IWheel)(object)this);
		Harmony obj = harmony;
		if (obj != null)
		{
			obj.UnpatchAll((string)null);
		}
	}

	public static void TryHideHotkeyBar()
	{
	}

	public static void ParseNames(string value, ref string[] arr)
	{
		if ((Object)(object)ObjectDB.instance == (Object)null)
		{
			return;
		}
		string[] array = ParseTokens(value);
		List<string> list = new List<string>();
		string[] array2 = array;
		foreach (string text in array2)
		{
			GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(text);
			if ((Object)(object)itemPrefab != (Object)null)
			{
				ItemDrop component = itemPrefab.GetComponent<ItemDrop>();
				list.Add(component.m_itemData.m_shared.m_name);
			}
		}
		arr = list.Distinct().ToArray();
	}

	public static string[] ParseTokens(string value)
	{
		char[] separator = new char[5] { ' ', ',', '.', ':', '\t' };
		return value.Split(separator, StringSplitOptions.RemoveEmptyEntries);
	}

	public int GetKeyCount(bool pressed = false)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		int num = 0;
		KeyboardShortcut value = Hotkey.Value;
		KeyCode mainKey = ((KeyboardShortcut)(ref value)).MainKey;
		KeyCode[] source = ((KeyboardShortcut)(ref value)).Modifiers.ToArray();
		if ((int)mainKey == 0)
		{
			return num;
		}
		if (pressed ? Input.GetKey(mainKey) : Input.GetKeyDown(mainKey))
		{
			num++;
		}
		return num + ((IEnumerable<KeyCode>)source).Count((Func<KeyCode, bool>)Input.GetKey);
	}

	public int GetKeyCountDown()
	{
		return GetKeyCount();
	}

	public int GetKeyCountPressed()
	{
		return GetKeyCount(pressed: true);
	}

	public bool IsVisible()
	{
		return EquipGui.visible;
	}

	public void Hide()
	{
		if (!((Object)(object)Gui == (Object)null))
		{
			Gui.Hide();
		}
	}

	public string GetName()
	{
		return Assembly.GetExecutingAssembly().GetName().Name;
	}

	float IWheel.JoyStickIgnoreTime()
	{
		return JoyStickIgnoreTime;
	}
}
public class EquipGui : MonoBehaviour
{
	private EquipWheelUI ui;

	public AssetBundle assets;

	public static bool visible;

	public int toggleVisible;

	public static bool toggleDownWasPressed;

	private void Awake()
	{
		//IL_0031: 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)
		LoadAssets();
		GameObject obj = assets.LoadAsset<GameObject>("assets/selectionwheel/selectionwheel.prefab");
		RectTransform val = ((Component)this).gameObject.AddComponent<RectTransform>();
		GameObject val2 = Object.Instantiate<GameObject>(obj, new Vector3(0f, 0f, 0f), ((Component)this).transform.rotation, (Transform)(object)val);
		ui = val2.AddComponent<EquipWheelUI>();
		val2.SetActive(false);
		visible = false;
		assets.Unload(false);
	}

	private void Start()
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		RectTransform component = ((Component)this).gameObject.GetComponent<RectTransform>();
		component.offsetMin = Vector2.zero;
		component.offsetMax = Vector2.zero;
		component.anchorMax = new Vector2(1f, 1f);
		component.anchorMin = new Vector2(0f, 0f);
		component.anchoredPosition = new Vector2(0f, 0f);
		if (!((Object)(object)Hud.instance == (Object)null))
		{
			EquipWheel.TryHideHotkeyBar();
		}
	}

	private void LoadAssets()
	{
		Stream manifestResourceStream = Assembly.GetAssembly(typeof(EquipWheel)).GetManifestResourceStream("EquipWheel.res.selectionwheel");
		using MemoryStream memoryStream = new MemoryStream();
		manifestResourceStream.CopyTo(memoryStream);
		assets = AssetBundle.LoadFromMemory(memoryStream.ToArray());
	}

	public void Hide()
	{
		((Component)ui).gameObject.SetActive(false);
		visible = false;
		toggleVisible = 0;
	}

	private void Update()
	{
		if (EquipWheel.ToggleMenu.Value)
		{
			HandleToggleEnabled();
		}
		else
		{
			HandleToggleDisabled();
		}
	}

	private void ReduceJoyStickIgnoreTime()
	{
		if (EquipWheel.JoyStickIgnoreTime > 0f)
		{
			EquipWheel.JoyStickIgnoreTime -= Time.deltaTime;
		}
	}

	private void HandlePressedHovering()
	{
		if (WheelManager.pressedOnHovering && ZInput.GetButtonUp("JoyUse"))
		{
			WheelManager.pressedOnHovering = false;
			WheelManager.hoverTextVisible = false;
		}
		else if (EquipWheel.IsShortcutDown && EquipWheel.IsUsingUseButton())
		{
			WheelManager.pressedOnHovering = WheelManager.pressedOnHovering || WheelManager.hoverTextVisible;
		}
	}

	private void HandleToggleEnabled()
	{
		ReduceJoyStickIgnoreTime();
		HandlePressedHovering();
		if (!EquipWheel.CanOpenMenu)
		{
			Hide();
			return;
		}
		if (toggleDownWasPressed)
		{
			if (EquipWheel.IsShortcutUp)
			{
				Hide();
				toggleDownWasPressed = false;
			}
			return;
		}
		if (EquipWheel.IsShortcutDown && toggleVisible < 2)
		{
			toggleVisible++;
		}
		bool flag = EquipWheel.IsShortcutDown && toggleVisible == 2;
		if (EquipWheel.TriggerOnRelease.Value && flag && WheelManager.IsActive((IWheel)(object)EquipWheel.Instance))
		{
			UseCurrentItem();
			toggleDownWasPressed = true;
		}
		else if (toggleVisible > 0 && !flag)
		{
			if (!visible)
			{
				((Component)ui).gameObject.SetActive(true);
				visible = true;
				WheelManager.Activate((IWheel)(object)EquipWheel.Instance);
			}
			if (EquipWheel.TriggerOnClick.Value && (Input.GetMouseButtonDown(0) || Input.GetKeyDown((KeyCode)330)))
			{
				UseCurrentItem(flash: true);
			}
		}
		else
		{
			Hide();
		}
	}

	private void UseCurrentItem(bool flash = false)
	{
		if (ui.CurrentItem != null)
		{
			if (flash)
			{
				ui.Flash();
			}
			((Humanoid)Player.m_localPlayer).UseItem((Inventory)null, ui.CurrentItem, false);
			EquipWheel.JoyStickIgnoreTime = (float)EquipWheel.IgnoreJoyStickDuration.Value / 1000f;
		}
	}

	private void HandleToggleDisabled()
	{
		ReduceJoyStickIgnoreTime();
		HandlePressedHovering();
		if (!EquipWheel.CanOpenMenu)
		{
			Hide();
		}
		else if (EquipWheel.TriggerOnRelease.Value && EquipWheel.IsShortcutUp)
		{
			UseCurrentItem();
			Hide();
		}
		else if ((EquipWheel.IsShortcutPressed && ZInput.IsGamepadActive()) || (EquipWheel.IsShortcutPressed && (EquipWheel.BestMatchPressed || EquipWheel.BestMatchDown)))
		{
			if (!visible)
			{
				((Component)ui).gameObject.SetActive(true);
				visible = true;
				WheelManager.Activate((IWheel)(object)EquipWheel.Instance);
			}
			if (EquipWheel.TriggerOnClick.Value && (Input.GetMouseButtonDown(0) || Input.GetKeyDown((KeyCode)330)))
			{
				UseCurrentItem(flash: true);
			}
		}
		else
		{
			Hide();
		}
	}
}
public class EquipWheelUI : MonoBehaviour
{
	public readonly float ANGLE_STEP = 45f;

	public readonly float ITEM_DISTANCE = 295f;

	public readonly float ITEM_SCALE = 2f;

	public readonly float INNER_DIAMETER = 340f;

	public readonly float LENGTH_THRESHOLD = 0.1f;

	private GameObject cursor;

	private Text text;

	private GameObject highlight;

	private readonly ItemData[] items = (ItemData[])(object)new ItemData[8];

	private HotkeyBar hotKeyBar;

	private Transform itemsRoot;

	private bool addedListener;

	private readonly List<ElementData> m_elements = new List<ElementData>();

	private GameObject m_elementPrefab;

	private int previous = -1;

	public int Current
	{
		get
		{
			if ((!ZInput.IsGamepadActive() && MouseInCenter) || JoyStickInCenter || (ZInput.IsGamepadActive() && Lenght < (double)LENGTH_THRESHOLD))
			{
				return -1;
			}
			int num = Mod((int)Mathf.Round((0f - Angle) / ANGLE_STEP), 8);
			if (num >= items.Length)
			{
				return -1;
			}
			return num;
		}
	}

	public bool JoyStickInCenter
	{
		get
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			if ((int)EquipWheel.HotkeyDPad.Value == 0)
			{
				float joyLeftStickX = ZInput.GetJoyLeftStickX(false);
				float joyLeftStickY = ZInput.GetJoyLeftStickY(true);
				if (ZInput.IsGamepadActive() && joyLeftStickX == 0f)
				{
					return joyLeftStickY == 0f;
				}
				return false;
			}
			float joyRightStickX = ZInput.GetJoyRightStickX(true);
			float joyRightStickY = ZInput.GetJoyRightStickY(true);
			if (ZInput.IsGamepadActive() && joyRightStickX == 0f)
			{
				return joyRightStickY == 0f;
			}
			return false;
		}
	}

	public ItemData CurrentItem
	{
		get
		{
			if (Current < 0)
			{
				return null;
			}
			return items[Current];
		}
	}

	public bool MouseInCenter
	{
		get
		{
			//IL_0017: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			float num = INNER_DIAMETER / 2f * ((Component)this).gameObject.transform.lossyScale.x;
			Vector3 val = Input.mousePosition - cursor.transform.position;
			return ((Vector3)(ref val)).magnitude <= num;
		}
	}

	public double Lenght
	{
		get
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			if ((int)EquipWheel.HotkeyDPad.Value == 0)
			{
				float joyLeftStickX = ZInput.GetJoyLeftStickX(false);
				float joyLeftStickY = ZInput.GetJoyLeftStickY(true);
				return Math.Sqrt(Math.Pow(joyLeftStickX, 2.0) + Math.Pow(joyLeftStickY, 2.0));
			}
			float joyRightStickX = ZInput.GetJoyRightStickX(true);
			float joyRightStickY = ZInput.GetJoyRightStickY(true);
			return Math.Sqrt(Math.Pow(joyRightStickX, 2.0) + Math.Pow(joyRightStickY, 2.0));
		}
	}

	public float Angle
	{
		get
		{
			//IL_007c: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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)
			if (ZInput.IsGamepadActive())
			{
				if ((int)EquipWheel.HotkeyDPad.Value == 0)
				{
					float joyLeftStickX = ZInput.GetJoyLeftStickX(false);
					float num = 0f - ZInput.GetJoyLeftStickY(true);
					if (joyLeftStickX != 0f || num != 0f)
					{
						return Mathf.Atan2(num, joyLeftStickX) * 57.29578f - 90f;
					}
				}
				else
				{
					float joyRightStickX = ZInput.GetJoyRightStickX(true);
					float num2 = 0f - ZInput.GetJoyRightStickY(true);
					if (joyRightStickX != 0f || num2 != 0f)
					{
						return Mathf.Atan2(num2, joyRightStickX) * 57.29578f - 90f;
					}
				}
			}
			Vector3 val = Input.mousePosition - cursor.transform.position;
			return Mathf.Atan2(val.y, val.x) * 57.29578f - 90f;
		}
	}

	public IEnumerator FlashCoroutine(float aTime)
	{
		Color color = EquipWheel.GetHighlightColor;
		for (float t = 0f; t < 1f; t += Time.deltaTime / aTime)
		{
			((Graphic)highlight.GetComponent<Image>()).color = Color.Lerp(Color.white, color, t);
			yield return null;
		}
	}

	private int Mod(int a, int b)
	{
		return (a % b + b) % b;
	}

	public void Flash()
	{
		((MonoBehaviour)this).StartCoroutine(FlashCoroutine(0.4f));
	}

	private void Awake()
	{
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Expected O, but got Unknown
		//IL_00c9: 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_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0187: 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)
		cursor = ((Component)((Component)this).transform.Find("Cursor")).gameObject;
		highlight = ((Component)((Component)this).transform.Find("Highlight")).gameObject;
		hotKeyBar = ((Component)((Component)Hud.instance).transform.Find("hudroot/HotKeyBar")).gameObject.GetComponent<HotkeyBar>();
		m_elementPrefab = hotKeyBar.m_elementPrefab;
		itemsRoot = ((Component)this).transform.Find("Items");
		((Graphic)highlight.GetComponent<Image>()).material.SetFloat("_Degree", ANGLE_STEP);
		GameObject val = new GameObject("Text");
		RectTransform obj = val.AddComponent<RectTransform>();
		((Transform)obj).SetParent(((Component)this).transform);
		obj.sizeDelta = new Vector2(1000f, 100f);
		obj.anchoredPosition = new Vector2(0f, 450f);
		text = val.AddComponent<Text>();
		((Graphic)text).color = EquipWheel.GetHighlightColor;
		EquipWheel.HighlightColor.SettingChanged += delegate
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)text).color = EquipWheel.GetHighlightColor;
		};
		text.alignment = (TextAnchor)1;
		text.fontSize = 60;
		text.supportRichText = true;
		Font[] array = Resources.FindObjectsOfTypeAll<Font>();
		foreach (Font val2 in array)
		{
			if (((Object)val2).name == "AveriaSerifLibre-Bold")
			{
				text.font = val2;
				break;
			}
		}
		Outline obj2 = val.AddComponent<Outline>();
		((Shadow)obj2).effectDistance = new Vector2(1f, -1f);
		((Shadow)obj2).effectColor = Color.black;
		val.SetActive(false);
	}

	private void Start()
	{
		if (!addedListener)
		{
			Inventory inventory = ((Humanoid)Player.m_localPlayer).GetInventory();
			inventory.m_onChanged = (Action)Delegate.Combine(inventory.m_onChanged, new Action(OnInventoryChanged));
			addedListener = true;
		}
	}

	public void OnInventoryChanged()
	{
		if (EquipGui.visible)
		{
			UpdateItems();
			UpdateIcons(Player.m_localPlayer, forceUpdate: true);
		}
	}

	private void UpdateItems()
	{
		//IL_0200: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Expected I4, but got Unknown
		//IL_020d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0213: Expected I4, but got Unknown
		//IL_021a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0220: Expected I4, but got Unknown
		//IL_0227: Unknown result type (might be due to invalid IL or missing references)
		//IL_022d: Expected I4, but got Unknown
		//IL_0234: Unknown result type (might be due to invalid IL or missing references)
		//IL_023a: Expected I4, but got Unknown
		//IL_0241: Unknown result type (might be due to invalid IL or missing references)
		//IL_0247: Expected I4, but got Unknown
		//IL_0173: 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_017a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: 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_01a4: 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_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: 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_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Player.m_localPlayer == (Object)null)
		{
			return;
		}
		Inventory inventory = ((Humanoid)Player.m_localPlayer).GetInventory();
		if (inventory == null)
		{
			return;
		}
		if (EquipWheel.ItemFiltering.Value)
		{
			List<ItemData> list = new List<ItemData>();
			List<ItemData> list2 = new List<ItemData>();
			foreach (ItemData allItem in inventory.GetAllItems())
			{
				if (EquipWheel.ItemRegexIgnore.Value.Length > 0)
				{
					Regex regex = new Regex(EquipWheel.ItemRegexIgnore.Value, (!EquipWheel.ItemRegexCaseSensitive.Value) ? RegexOptions.IgnoreCase : RegexOptions.None);
					string input;
					if (EpicLootWrapper.instance != null)
					{
						Color itemColor = EpicLootWrapper.instance.GetItemColor(allItem);
						input = Localization.instance.Localize(EpicLootWrapper.instance.GetItemName(allItem, itemColor));
					}
					else
					{
						input = Localization.instance.Localize(allItem.m_shared.m_name);
					}
					if (regex.IsMatch(input))
					{
						continue;
					}
				}
				if (EquipWheel.ItemRegex.Value.Length > 0)
				{
					Regex regex2 = new Regex(EquipWheel.ItemRegex.Value, (!EquipWheel.ItemRegexCaseSensitive.Value) ? RegexOptions.IgnoreCase : RegexOptions.None);
					string input2;
					if (EpicLootWrapper.instance != null)
					{
						Color itemColor2 = EpicLootWrapper.instance.GetItemColor(allItem);
						input2 = Localization.instance.Localize(EpicLootWrapper.instance.GetItemName(allItem, itemColor2));
					}
					else
					{
						input2 = Localization.instance.Localize(allItem.m_shared.m_name);
					}
					if (regex2.IsMatch(input2))
					{
						list.Add(allItem);
						continue;
					}
				}
				ItemType itemType = allItem.m_shared.m_itemType;
				if (itemType == EquipWheel.ItemType1.Value || itemType == EquipWheel.ItemType2.Value || itemType == EquipWheel.ItemType3.Value || itemType == EquipWheel.ItemType4.Value || itemType == EquipWheel.ItemType5.Value || itemType == EquipWheel.ItemType6.Value)
				{
					list2.Add(allItem);
				}
			}
			ItemType[] types = (ItemType[])(object)new ItemType[6]
			{
				(ItemType)(int)EquipWheel.ItemType1.Value,
				(ItemType)(int)EquipWheel.ItemType2.Value,
				(ItemType)(int)EquipWheel.ItemType3.Value,
				(ItemType)(int)EquipWheel.ItemType4.Value,
				(ItemType)(int)EquipWheel.ItemType5.Value,
				(ItemType)(int)EquipWheel.ItemType6.Value
			};
			list2.Sort((ItemData a, ItemData b) => Array.IndexOf(types, a.m_shared.m_itemType).CompareTo(Array.IndexOf(types, b.m_shared.m_itemType)));
			for (int i = 0; i < 8; i++)
			{
				items[i] = null;
				if (list.Count > i)
				{
					items[i] = list[i];
				}
				else if (list2.Count > i - list.Count)
				{
					items[i] = list2[i - list.Count];
				}
			}
			return;
		}
		for (int j = 0; j < 8; j++)
		{
			items[j] = null;
			ItemData itemAt = inventory.GetItemAt(j, EquipWheel.InventoryRow.Value - 1);
			if (itemAt != null)
			{
				items[j] = itemAt;
			}
		}
	}

	private void OnEnable()
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		((Graphic)highlight.GetComponent<Image>()).color = EquipWheel.GetHighlightColor;
		float value = EquipWheel.GuiScale.Value;
		((Transform)((Component)this).GetComponent<RectTransform>()).localScale = new Vector3(value, value, value);
		EquipWheel.JoyStickIgnoreTime = 0f;
		UpdateItems();
		UpdateIcons(Player.m_localPlayer, forceUpdate: true);
		Update();
	}

	private void OnDisable()
	{
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		highlight.SetActive(false);
		Image[] componentsInChildren = cursor.GetComponentsInChildren<Image>(true);
		foreach (Image val in componentsInChildren)
		{
			((Graphic)val).color = new Color(0f, 0f, 0f, 0.5f);
			if (((Object)((Component)val).gameObject).name == "Image")
			{
				((Component)val).gameObject.SetActive(false);
			}
		}
	}

	private void Update()
	{
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0207: 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_0232: Unknown result type (might be due to invalid IL or missing references)
		//IL_0237: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: 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_017c: Unknown result type (might be due to invalid IL or missing references)
		if (Current != previous)
		{
			if (CurrentItem != null)
			{
				InventoryGui.instance.m_moveItemEffects.Create(((Component)this).transform.position, Quaternion.identity, (Transform)null, 1f, -1);
				((Component)text).gameObject.SetActive(true);
				if (EpicLootWrapper.instance != null)
				{
					Color val = EpicLootWrapper.instance.GetItemColor(CurrentItem);
					if (((Color)(ref val)).Equals(Color.white) || !EquipWheel.UseRarityColoring.Value)
					{
						val = EquipWheel.GetHighlightColor;
					}
					text.text = Localization.instance.Localize(EpicLootWrapper.instance.GetItemName(CurrentItem, val));
				}
				else
				{
					text.text = Localization.instance.Localize(CurrentItem.m_shared.m_name);
				}
			}
			else
			{
				((Component)text).gameObject.SetActive(false);
			}
			previous = Current;
		}
		highlight.SetActive(CurrentItem != null);
		Color color = (Color)((CurrentItem == null) ? new Color(0f, 0f, 0f, 0.5f) : EquipWheel.GetHighlightColor);
		if (CurrentItem != null && EpicLootWrapper.instance != null)
		{
			Color itemColor = EpicLootWrapper.instance.GetItemColor(CurrentItem);
			if (!((Color)(ref itemColor)).Equals(Color.white) && EquipWheel.UseRarityColoring.Value)
			{
				color = itemColor;
				((Graphic)highlight.GetComponent<Image>()).color = color;
			}
			else
			{
				((Graphic)highlight.GetComponent<Image>()).color = EquipWheel.GetHighlightColor;
			}
		}
		Image[] componentsInChildren = cursor.GetComponentsInChildren<Image>(true);
		foreach (Image val2 in componentsInChildren)
		{
			((Graphic)val2).color = color;
			if (((Object)((Component)val2).gameObject).name == "Image")
			{
				((Component)val2).gameObject.SetActive(CurrentItem != null);
			}
		}
		cursor.transform.rotation = Quaternion.AngleAxis(Angle, Vector3.forward);
		float num = (float)Current * ANGLE_STEP;
		highlight.transform.rotation = Quaternion.AngleAxis(0f - num, Vector3.forward);
		UpdateIcons(Player.m_localPlayer);
	}

	private int CountItems(ItemData[] items)
	{
		int num = 0;
		for (int i = 0; i < items.Length; i++)
		{
			if (items[i] != null)
			{
				num++;
			}
		}
		return num;
	}

	private void UpdateIcons(Player player, bool forceUpdate = false)
	{
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Expected O, but got Unknown
		//IL_0100: 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_017f: 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_03ed: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)player) || ((Character)player).IsDead())
		{
			foreach (ElementData element in m_elements)
			{
				Object.Destroy((Object)(object)element.m_go);
			}
			m_elements.Clear();
			return;
		}
		if (m_elements.Count != CountItems(items) || forceUpdate)
		{
			foreach (ElementData element2 in m_elements)
			{
				Object.Destroy((Object)(object)element2.m_go);
			}
			m_elements.Clear();
			for (int i = 0; i < items.Length; i++)
			{
				if (items[i] != null)
				{
					ElementData val = new ElementData();
					val.m_go = Object.Instantiate<GameObject>(m_elementPrefab, itemsRoot);
					val.m_go.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 0.5f);
					float num = Mathf.Sin((float)i * ANGLE_STEP * ((float)Math.PI / 180f)) * ITEM_DISTANCE;
					float num2 = Mathf.Cos((float)i * ANGLE_STEP * ((float)Math.PI / 180f)) * ITEM_DISTANCE;
					val.m_go.transform.localScale = new Vector3(ITEM_SCALE, ITEM_SCALE, ITEM_SCALE);
					val.m_go.transform.localPosition = new Vector3(num, num2, 0f);
					((TMP_Text)((Component)val.m_go.transform.Find("binding")).GetComponent<TextMeshProUGUI>()).text = (i + 1).ToString();
					val.m_icon = ((Component)((Component)val.m_go.transform).transform.Find("icon")).GetComponent<Image>();
					val.m_durability = ((Component)val.m_go.transform.Find("durability")).GetComponent<GuiBar>();
					val.m_amount = ((Component)val.m_go.transform.Find("amount")).GetComponent<TextMeshProUGUI>();
					val.m_equiped = ((Component)val.m_go.transform.Find("equiped")).gameObject;
					val.m_queued = ((Component)val.m_go.transform.Find("queued")).gameObject;
					val.m_selection = ((Component)val.m_go.transform.Find("selected")).gameObject;
					val.m_selection.SetActive(false);
					if (EquipWheel.InventoryRow.Value > 1 || EquipWheel.ItemFiltering.Value)
					{
						((Behaviour)((Component)val.m_go.transform.Find("binding")).GetComponent<TextMeshProUGUI>()).enabled = false;
					}
					m_elements.Add(val);
				}
			}
		}
		foreach (ElementData element3 in m_elements)
		{
			element3.m_used = false;
		}
		int num3 = 0;
		for (int j = 0; j < items.Length; j++)
		{
			if (items[j] == null)
			{
				continue;
			}
			ItemData val2 = items[j];
			ElementData val3 = m_elements[num3];
			val3.m_used = true;
			((Component)val3.m_icon).gameObject.SetActive(true);
			val3.m_icon.sprite = val2.GetIcon();
			((Component)val3.m_durability).gameObject.SetActive(val2.m_shared.m_useDurability);
			if (val2.m_shared.m_useDurability)
			{
				if (val2.m_durability <= 0f)
				{
					val3.m_durability.SetValue(1f);
					val3.m_durability.SetColor((Color)((Mathf.Sin(Time.time * 10f) > 0f) ? Color.red : new Color(0f, 0f, 0f, 0f)));
				}
				else
				{
					val3.m_durability.SetValue(val2.GetDurabilityPercentage());
					val3.m_durability.ResetColor();
				}
			}
			val3.m_equiped.SetActive(val2.m_equipped);
			val3.m_queued.SetActive(player.IsEquipActionQueued(val2));
			if (val2.m_shared.m_maxStackSize > 1)
			{
				((Component)val3.m_amount).gameObject.SetActive(true);
				((TMP_Text)val3.m_amount).text = val2.m_stack + "/" + val2.m_shared.m_maxStackSize;
			}
			else
			{
				((Component)val3.m_amount).gameObject.SetActive(false);
			}
			if (EpicLootWrapper.instance != null)
			{
				EpicLootWrapper.instance.ModifyElement(val3, val2);
			}
			num3++;
		}
		for (int k = 0; k < m_elements.Count; k++)
		{
			ElementData val4 = m_elements[k];
			if (!val4.m_used)
			{
				((Component)val4.m_icon).gameObject.SetActive(false);
				((Component)val4.m_durability).gameObject.SetActive(false);
				val4.m_equiped.SetActive(false);
				val4.m_queued.SetActive(false);
				((Component)val4.m_amount).gameObject.SetActive(false);
			}
		}
	}
}
public class Patcher
{
	public static readonly KeyCode[] NUMBERS;

	[HarmonyPatch(typeof(Player), "Awake")]
	[HarmonyPostfix]
	public static void Awake_Postfix()
	{
		//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)
		string text = "EquipGui (" + Assembly.GetExecutingAssembly().GetName().Name + ")";
		if (!((Object)(object)Menu.instance == (Object)null) && !Object.op_Implicit((Object)(object)GameObject.Find(text)))
		{
			GameObject val = new GameObject(text);
			EquipWheel.Gui = val.AddComponent<EquipGui>();
			val.transform.SetParent(((Component)Menu.instance).transform.parent, false);
			EquipWheel.Log("Spawned EquipGui!");
		}
	}

	[HarmonyPatch(typeof(HotkeyBar), "Update")]
	[HarmonyPrefix]
	public static bool Prefix(HotkeyBar __instance)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)EquipWheel.Instance == (Object)null)
		{
			return true;
		}
		if (EquipWheel.HotkeyDPad != null && (int)EquipWheel.HotkeyDPad.Value == 0)
		{
			return true;
		}
		Player localPlayer = Player.m_localPlayer;
		if ((Object)(object)localPlayer != (Object)null)
		{
			typeof(HotkeyBar).GetMethod("UpdateIcons", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[1] { localPlayer });
		}
		return false;
	}

	[HarmonyPatch(typeof(Player), "UseHotbarItem")]
	[HarmonyPrefix]
	public static bool UseHotbarItem(int index)
	{
		//IL_000a: 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_0012: Unknown result type (might be due to invalid IL or missing references)
		KeyCode[] nUMBERS = NUMBERS;
		KeyboardShortcut value = EquipWheel.Hotkey.Value;
		bool num = Array.IndexOf(nUMBERS, ((KeyboardShortcut)(ref value)).MainKey) != index - 1;
		bool flag = !EquipWheel.IsShortcutDown;
		if (!(num || flag) && EquipWheel.CanOpenMenu)
		{
			return ZInput.IsGamepadActive();
		}
		return true;
	}

	[HarmonyPatch(typeof(Player), "Update")]
	[HarmonyPostfix]
	public static void Update()
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		Player localPlayer = Player.m_localPlayer;
		if (!((Object)(object)localPlayer == (Object)null) && EquipWheel.UseSitButton.Value && (int)EquipWheel.HotkeyDPad.Value == 0 && (ZInput.GetButtonDown("JoySit") || ZInput.GetButtonUp("JoySit")))
		{
			typeof(Player).GetMethod("StopEmote", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(localPlayer, new object[0]);
		}
	}

	static Patcher()
	{
		KeyCode[] array = new KeyCode[8];
		RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
		NUMBERS = (KeyCode[])(object)array;
	}
}

EquipWheelThree.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EquipWheel;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("EquipWheelThree")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("EquipWheelThree")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7a9092d4-c0ba-41d7-8ca0-71d3302f8469")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.5", FrameworkDisplayName = "")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace EquipWheelThree;

[BepInPlugin("virtuacode.valheim.equipwheelthree", "Equip Wheel Mod (EquipWheelThree)", "1.5.3")]
public class EquipWheel : BaseUnityPlugin, IWheel
{
	private static Harmony harmony;

	public static ManualLogSource MyLogger = Logger.CreateLogSource(Assembly.GetExecutingAssembly().GetName().Name);

	public static ConfigEntry<KeyboardShortcut> Hotkey;

	public static ConfigEntry<DPadButton> HotkeyDPad;

	public static ConfigEntry<bool> UseSitButton;

	public static ConfigEntry<bool> TriggerOnRelease;

	public static ConfigEntry<bool> TriggerOnClick;

	public static ConfigEntry<bool> ToggleMenu;

	public static ConfigEntry<bool> ModEnabled;

	public static ConfigEntry<Color> HighlightColor;

	public static ConfigEntry<float> GuiScale;

	public static ConfigEntry<int> InventoryRow;

	public static ConfigEntry<bool> ItemFiltering;

	public static ConfigEntry<ItemType> ItemType1;

	public static ConfigEntry<ItemType> ItemType2;

	public static ConfigEntry<ItemType> ItemType3;

	public static ConfigEntry<ItemType> ItemType4;

	public static ConfigEntry<ItemType> ItemType5;

	public static ConfigEntry<ItemType> ItemType6;

	public static ConfigEntry<string> ItemRegex;

	public static ConfigEntry<string> ItemRegexIgnore;

	public static ConfigEntry<bool> ItemRegexCaseSensitive;

	private static EquipWheel instance;

	public static KeyCode replacedKey = (KeyCode)0;

	public static List<string> replacedButtons = new List<string>();

	public static float JoyStickIgnoreTime = 0f;

	public static EquipGui Gui;

	public static Color GetHighlightColor => HighlightColor.Value;

	public static EquipWheel Instance => instance;

	public static bool CanOpenMenu
	{
		get
		{
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer == (Object)null) && !((Character)localPlayer).IsDead() && !((Character)localPlayer).InCutscene() && !((Character)localPlayer).IsTeleporting() && TakeInput(look: true) && !InInventoryEtc() && !WheelManager.inventoryVisible)
			{
				if (IsUsingUseButton())
				{
					return !WheelManager.pressedOnHovering;
				}
				return true;
			}
			return false;
		}
	}

	public static bool BestMatchPressed
	{
		get
		{
			if ((Object)(object)Instance == (Object)null)
			{
				return false;
			}
			return WheelManager.BestMatchPressed((IWheel)(object)Instance);
		}
	}

	public static bool BestMatchDown
	{
		get
		{
			if ((Object)(object)Instance == (Object)null)
			{
				return false;
			}
			return WheelManager.BestMatchDown((IWheel)(object)Instance);
		}
	}

	public static bool IsShortcutDown
	{
		get
		{
			//IL_009c: 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_00a4: 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_002b: Expected I4, but got Unknown
			if (ZInput.IsGamepadActive())
			{
				DPadButton value = HotkeyDPad.Value;
				switch ((int)value)
				{
				case 0:
					if (UseSitButton.Value)
					{
						return ZInput.GetButtonDown("JoySit");
					}
					return ZInput.GetButtonDown("JoyUse");
				case 1:
					return ZInput.GetButtonDown("JoyHotbarLeft");
				case 2:
					return ZInput.GetButtonDown("JoyHotbarRight");
				case 3:
					if (!ZInput.GetButtonDown("JoyHotbarRight"))
					{
						return ZInput.GetButtonDown("JoyHotbarLeft");
					}
					return true;
				default:
					if (!ZInput.GetButtonDown("JoyHotbarRight"))
					{
						return ZInput.GetButtonDown("JoyHotbarLeft");
					}
					return true;
				}
			}
			KeyboardShortcut value2 = Hotkey.Value;
			KeyCode mainKey = ((KeyboardShortcut)(ref value2)).MainKey;
			KeyCode[] source = ((KeyboardShortcut)(ref value2)).Modifiers.ToArray();
			if (!Input.GetKeyDown(mainKey))
			{
				return ((IEnumerable<KeyCode>)source).Any((Func<KeyCode, bool>)Input.GetKeyDown);
			}
			return true;
		}
	}

	public static bool IsShortcutUp
	{
		get
		{
			//IL_009c: 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_00a4: 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_002b: Expected I4, but got Unknown
			if (ZInput.IsGamepadActive())
			{
				DPadButton value = HotkeyDPad.Value;
				switch ((int)value)
				{
				case 0:
					if (UseSitButton.Value)
					{
						return ZInput.GetButtonUp("JoySit");
					}
					return ZInput.GetButtonUp("JoyUse");
				case 1:
					return ZInput.GetButtonUp("JoyHotbarLeft");
				case 2:
					return ZInput.GetButtonUp("JoyHotbarRight");
				case 3:
					if (!ZInput.GetButtonUp("JoyHotbarRight"))
					{
						return ZInput.GetButtonUp("JoyHotbarLeft");
					}
					return true;
				default:
					if (!ZInput.GetButtonUp("JoyHotbarRight"))
					{
						return ZInput.GetButtonUp("JoyHotbarLeft");
					}
					return true;
				}
			}
			KeyboardShortcut value2 = Hotkey.Value;
			KeyCode mainKey = ((KeyboardShortcut)(ref value2)).MainKey;
			KeyCode[] source = ((KeyboardShortcut)(ref value2)).Modifiers.ToArray();
			if (!Input.GetKeyUp(mainKey))
			{
				return ((IEnumerable<KeyCode>)source).Any((Func<KeyCode, bool>)Input.GetKeyUp);
			}
			return true;
		}
	}

	public static bool IsShortcutPressed
	{
		get
		{
			//IL_009c: 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_00a4: 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_002b: Expected I4, but got Unknown
			if (ZInput.IsGamepadActive())
			{
				DPadButton value = HotkeyDPad.Value;
				switch ((int)value)
				{
				case 0:
					if (UseSitButton.Value)
					{
						return ZInput.GetButton("JoySit");
					}
					return ZInput.GetButton("JoyUse");
				case 1:
					return ZInput.GetButton("JoyHotbarLeft");
				case 2:
					return ZInput.GetButton("JoyHotbarRight");
				case 3:
					if (!ZInput.GetButton("JoyHotbarRight"))
					{
						return ZInput.GetButton("JoyHotbarLeft");
					}
					return true;
				default:
					if (!ZInput.GetButton("JoyHotbarRight"))
					{
						return ZInput.GetButton("JoyHotbarLeft");
					}
					return true;
				}
			}
			KeyboardShortcut value2 = Hotkey.Value;
			KeyCode mainKey = ((KeyboardShortcut)(ref value2)).MainKey;
			KeyCode[] source = ((KeyboardShortcut)(ref value2)).Modifiers.ToArray();
			if (!Input.GetKey(mainKey))
			{
				return ((IEnumerable<KeyCode>)source).Any((Func<KeyCode, bool>)Input.GetKey);
			}
			return true;
		}
	}

	public static void Log(string msg)
	{
		ManualLogSource myLogger = MyLogger;
		if (myLogger != null)
		{
			myLogger.LogInfo((object)msg);
		}
	}

	public static void LogErr(string msg)
	{
		ManualLogSource myLogger = MyLogger;
		if (myLogger != null)
		{
			myLogger.LogError((object)msg);
		}
	}

	public static void LogWarn(string msg)
	{
		ManualLogSource myLogger = MyLogger;
		if (myLogger != null)
		{
			myLogger.LogWarning((object)msg);
		}
	}

	private static bool TakeInput(bool look = false)
	{
		if (!GameCamera.InFreeFly() && (!Object.op_Implicit((Object)(object)Chat.instance) || !Chat.instance.HasFocus()) && !Menu.IsVisible() && !Console.IsVisible() && !TextInput.IsVisible() && !Minimap.InTextInput() && (!ZInput.IsGamepadActive() || !Minimap.IsOpen()) && (!ZInput.IsGamepadActive() || !StoreGui.IsVisible()) && (!ZInput.IsGamepadActive() || !Hud.IsPieceSelectionVisible()) && (!PlayerCustomizaton.IsBarberGuiVisible() || look))
		{
			if (PlayerCustomizaton.BarberBlocksLook())
			{
				return !look;
			}
			return true;
		}
		return false;
	}

	private static bool InInventoryEtc()
	{
		if (!Minimap.IsOpen() && !StoreGui.IsVisible())
		{
			return Hud.IsPieceSelectionVisible();
		}
		return true;
	}

	public static bool IsDedicated()
	{
		MethodInfo method = typeof(ZNet).GetMethod("IsDedicated", BindingFlags.Instance | BindingFlags.Public);
		return ((Func<ZNet, bool>)Delegate.CreateDelegate(typeof(Func<ZNet, bool>), method))(null);
	}

	public static bool IsUsingUseButton()
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		if (ZInput.IsGamepadActive() && (int)HotkeyDPad.Value == 0)
		{
			return !UseSitButton.Value;
		}
		return false;
	}

	public void Awake()
	{
		//IL_003b: 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_0169: Unknown result type (might be due to invalid IL or missing references)
		//IL_0173: Expected O, but got Unknown
		instance = this;
		ModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ModEnabled", true, "Enable mod when value is true");
		Hotkey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Input", "Hotkey", KeyboardShortcut.Deserialize("G"), "Hotkey for opening equip wheel menu");
		HotkeyDPad = ((BaseUnityPlugin)this).Config.Bind<DPadButton>("Input", "HotkeyDPad", (DPadButton)0, "Hotkey on the D-Pad (None, Left, Right or LeftOrRight)");
		UseSitButton = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "UseSitButton", false, "When enabled use the sit button as hotkey (HotkeyDPad has to be set to None)");
		TriggerOnRelease = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "TriggerOnRelease", true, "Releasing the Hotkey will equip/use the selected item");
		TriggerOnClick = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "TriggerOnClick", false, "Click with left mouse button will equip/use the selected item");
		ToggleMenu = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "ToggleMenu", false, "When enabled the equip wheel will toggle between hidden/visible when the hotkey was pressed");
		HighlightColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Appereance", "HighlightColor", new Color(0.414f, 0.734f, 1f), "Color of the highlighted selection");
		GuiScale = ((BaseUnityPlugin)this).Config.Bind<float>("Appereance", "GuiScale", 0.5f, "Scale factor of the user interface");
		InventoryRow = ((BaseUnityPlugin)this).Config.Bind<int>("Misc", "InventoryRow", 1, new ConfigDescription("Row of the inventory that should be used for the equip wheel", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 4), new object[0]));
		ItemFiltering = ((BaseUnityPlugin)this).Config.Bind<bool>("Misc", "ItemFiltering", false, "Will scan the whole inventory for items of the specified item types and Regex and show them in the equip wheel");
		ItemType1 = ((BaseUnityPlugin)this).Config.Bind<ItemType>("Misc", "ItemType1", (ItemType)0, "Item type used for filtering items");
		ItemType2 = ((BaseUnityPlugin)this).Config.Bind<ItemType>("Misc", "ItemType2", (ItemType)0, "Item type used for filtering items");
		ItemType3 = ((BaseUnityPlugin)this).Config.Bind<ItemType>("Misc", "ItemType3", (ItemType)0, "Item type used for filtering items");
		ItemType4 = ((BaseUnityPlugin)this).Config.Bind<ItemType>("Misc", "ItemType4", (ItemType)0, "Item type used for filtering items");
		ItemType5 = ((BaseUnityPlugin)this).Config.Bind<ItemType>("Misc", "ItemType5", (ItemType)0, "Item type used for filtering items");
		ItemType6 = ((BaseUnityPlugin)this).Config.Bind<ItemType>("Misc", "ItemType6", (ItemType)0, "Item type used for filtering items");
		ItemRegex = ((BaseUnityPlugin)this).Config.Bind<string>("Misc", "ItemRegex", "", "Regex used for filtering items");
		ItemRegexIgnore = ((BaseUnityPlugin)this).Config.Bind<string>("Misc", "ItemRegexIgnore", "", "Regex used for ignoring items");
		ItemRegexCaseSensitive = ((BaseUnityPlugin)this).Config.Bind<bool>("Misc", "ItemRegexCaseSensitive", false, "When enabled the Regex will be case-sensitive");
		if (!ModEnabled.Value)
		{
			LogWarn("Mod not loaded because it was disabled via config.");
			return;
		}
		if (IsDedicated())
		{
			LogWarn("Mod not loaded because game instance is a dedicated server.");
			return;
		}
		harmony = Harmony.CreateAndPatchAll(typeof(Patcher), (string)null);
		WheelManager.AddWheel((IWheel)(object)this);
		Log(((object)this).GetType().Namespace + " Loaded!");
	}

	private void OnDestroy()
	{
		WheelManager.RemoveWheel((IWheel)(object)this);
		Harmony obj = harmony;
		if (obj != null)
		{
			obj.UnpatchAll((string)null);
		}
	}

	public static void TryHideHotkeyBar()
	{
	}

	public static void ParseNames(string value, ref string[] arr)
	{
		if ((Object)(object)ObjectDB.instance == (Object)null)
		{
			return;
		}
		string[] array = ParseTokens(value);
		List<string> list = new List<string>();
		string[] array2 = array;
		foreach (string text in array2)
		{
			GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(text);
			if ((Object)(object)itemPrefab != (Object)null)
			{
				ItemDrop component = itemPrefab.GetComponent<ItemDrop>();
				list.Add(component.m_itemData.m_shared.m_name);
			}
		}
		arr = list.Distinct().ToArray();
	}

	public static string[] ParseTokens(string value)
	{
		char[] separator = new char[5] { ' ', ',', '.', ':', '\t' };
		return value.Split(separator, StringSplitOptions.RemoveEmptyEntries);
	}

	public int GetKeyCount(bool pressed = false)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		int num = 0;
		KeyboardShortcut value = Hotkey.Value;
		KeyCode mainKey = ((KeyboardShortcut)(ref value)).MainKey;
		KeyCode[] source = ((KeyboardShortcut)(ref value)).Modifiers.ToArray();
		if ((int)mainKey == 0)
		{
			return num;
		}
		if (pressed ? Input.GetKey(mainKey) : Input.GetKeyDown(mainKey))
		{
			num++;
		}
		return num + ((IEnumerable<KeyCode>)source).Count((Func<KeyCode, bool>)Input.GetKey);
	}

	public int GetKeyCountDown()
	{
		return GetKeyCount();
	}

	public int GetKeyCountPressed()
	{
		return GetKeyCount(pressed: true);
	}

	public bool IsVisible()
	{
		return EquipGui.visible;
	}

	public void Hide()
	{
		if (!((Object)(object)Gui == (Object)null))
		{
			Gui.Hide();
		}
	}

	public string GetName()
	{
		return Assembly.GetExecutingAssembly().GetName().Name;
	}

	float IWheel.JoyStickIgnoreTime()
	{
		return JoyStickIgnoreTime;
	}
}
public class EquipGui : MonoBehaviour
{
	private EquipWheelUI ui;

	public AssetBundle assets;

	public static bool visible;

	public int toggleVisible;

	public static bool toggleDownWasPressed;

	private void Awake()
	{
		//IL_0031: 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)
		LoadAssets();
		GameObject obj = assets.LoadAsset<GameObject>("assets/selectionwheel/selectionwheel.prefab");
		RectTransform val = ((Component)this).gameObject.AddComponent<RectTransform>();
		GameObject val2 = Object.Instantiate<GameObject>(obj, new Vector3(0f, 0f, 0f), ((Component)this).transform.rotation, (Transform)(object)val);
		ui = val2.AddComponent<EquipWheelUI>();
		val2.SetActive(false);
		visible = false;
		assets.Unload(false);
	}

	private void Start()
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		RectTransform component = ((Component)this).gameObject.GetComponent<RectTransform>();
		component.offsetMin = Vector2.zero;
		component.offsetMax = Vector2.zero;
		component.anchorMax = new Vector2(1f, 1f);
		component.anchorMin = new Vector2(0f, 0f);
		component.anchoredPosition = new Vector2(0f, 0f);
		if (!((Object)(object)Hud.instance == (Object)null))
		{
			EquipWheel.TryHideHotkeyBar();
		}
	}

	private void LoadAssets()
	{
		Stream manifestResourceStream = Assembly.GetAssembly(typeof(EquipWheel)).GetManifestResourceStream("EquipWheel.res.selectionwheel");
		using MemoryStream memoryStream = new MemoryStream();
		manifestResourceStream.CopyTo(memoryStream);
		assets = AssetBundle.LoadFromMemory(memoryStream.ToArray());
	}

	public void Hide()
	{
		((Component)ui).gameObject.SetActive(false);
		visible = false;
		toggleVisible = 0;
	}

	private void Update()
	{
		if (EquipWheel.ToggleMenu.Value)
		{
			HandleToggleEnabled();
		}
		else
		{
			HandleToggleDisabled();
		}
	}

	private void ReduceJoyStickIgnoreTime()
	{
		if (EquipWheel.JoyStickIgnoreTime > 0f)
		{
			EquipWheel.JoyStickIgnoreTime -= Time.deltaTime;
		}
	}

	private void HandlePressedHovering()
	{
		if (WheelManager.pressedOnHovering && ZInput.GetButtonUp("JoyUse"))
		{
			WheelManager.pressedOnHovering = false;
			WheelManager.hoverTextVisible = false;
		}
		else if (EquipWheel.IsShortcutDown && EquipWheel.IsUsingUseButton())
		{
			WheelManager.pressedOnHovering = WheelManager.pressedOnHovering || WheelManager.hoverTextVisible;
		}
	}

	private void HandleToggleEnabled()
	{
		ReduceJoyStickIgnoreTime();
		HandlePressedHovering();
		if (!EquipWheel.CanOpenMenu)
		{
			Hide();
			return;
		}
		if (toggleDownWasPressed)
		{
			if (EquipWheel.IsShortcutUp)
			{
				Hide();
				toggleDownWasPressed = false;
			}
			return;
		}
		if (EquipWheel.IsShortcutDown && toggleVisible < 2)
		{
			toggleVisible++;
		}
		bool flag = EquipWheel.IsShortcutDown && toggleVisible == 2;
		if (EquipWheel.TriggerOnRelease.Value && flag && WheelManager.IsActive((IWheel)(object)EquipWheel.Instance))
		{
			UseCurrentItem();
			toggleDownWasPressed = true;
		}
		else if (toggleVisible > 0 && !flag)
		{
			if (!visible)
			{
				((Component)ui).gameObject.SetActive(true);
				visible = true;
				WheelManager.Activate((IWheel)(object)EquipWheel.Instance);
			}
			if (EquipWheel.TriggerOnClick.Value && (Input.GetMouseButtonDown(0) || Input.GetKeyDown((KeyCode)330)))
			{
				UseCurrentItem(flash: true);
			}
		}
		else
		{
			Hide();
		}
	}

	private void UseCurrentItem(bool flash = false)
	{
		if (ui.CurrentItem != null)
		{
			if (flash)
			{
				ui.Flash();
			}
			((Humanoid)Player.m_localPlayer).UseItem((Inventory)null, ui.CurrentItem, false);
			EquipWheel.JoyStickIgnoreTime = (float)EquipWheel.IgnoreJoyStickDuration.Value / 1000f;
		}
	}

	private void HandleToggleDisabled()
	{
		ReduceJoyStickIgnoreTime();
		HandlePressedHovering();
		if (!EquipWheel.CanOpenMenu)
		{
			Hide();
		}
		else if (EquipWheel.TriggerOnRelease.Value && EquipWheel.IsShortcutUp)
		{
			UseCurrentItem();
			Hide();
		}
		else if ((EquipWheel.IsShortcutPressed && ZInput.IsGamepadActive()) || (EquipWheel.IsShortcutPressed && (EquipWheel.BestMatchPressed || EquipWheel.BestMatchDown)))
		{
			if (!visible)
			{
				((Component)ui).gameObject.SetActive(true);
				visible = true;
				WheelManager.Activate((IWheel)(object)EquipWheel.Instance);
			}
			if (EquipWheel.TriggerOnClick.Value && (Input.GetMouseButtonDown(0) || Input.GetKeyDown((KeyCode)330)))
			{
				UseCurrentItem(flash: true);
			}
		}
		else
		{
			Hide();
		}
	}
}
public class EquipWheelUI : MonoBehaviour
{
	public readonly float ANGLE_STEP = 45f;

	public readonly float ITEM_DISTANCE = 295f;

	public readonly float ITEM_SCALE = 2f;

	public readonly float INNER_DIAMETER = 340f;

	public readonly float LENGTH_THRESHOLD = 0.1f;

	private GameObject cursor;

	private Text text;

	private GameObject highlight;

	private readonly ItemData[] items = (ItemData[])(object)new ItemData[8];

	private HotkeyBar hotKeyBar;

	private Transform itemsRoot;

	private bool addedListener;

	private readonly List<ElementData> m_elements = new List<ElementData>();

	private GameObject m_elementPrefab;

	private int previous = -1;

	public int Current
	{
		get
		{
			if ((!ZInput.IsGamepadActive() && MouseInCenter) || JoyStickInCenter || (ZInput.IsGamepadActive() && Lenght < (double)LENGTH_THRESHOLD))
			{
				return -1;
			}
			int num = Mod((int)Mathf.Round((0f - Angle) / ANGLE_STEP), 8);
			if (num >= items.Length)
			{
				return -1;
			}
			return num;
		}
	}

	public bool JoyStickInCenter
	{
		get
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			if ((int)EquipWheel.HotkeyDPad.Value == 0)
			{
				float joyLeftStickX = ZInput.GetJoyLeftStickX(false);
				float joyLeftStickY = ZInput.GetJoyLeftStickY(true);
				if (ZInput.IsGamepadActive() && joyLeftStickX == 0f)
				{
					return joyLeftStickY == 0f;
				}
				return false;
			}
			float joyRightStickX = ZInput.GetJoyRightStickX(true);
			float joyRightStickY = ZInput.GetJoyRightStickY(true);
			if (ZInput.IsGamepadActive() && joyRightStickX == 0f)
			{
				return joyRightStickY == 0f;
			}
			return false;
		}
	}

	public ItemData CurrentItem
	{
		get
		{
			if (Current < 0)
			{
				return null;
			}
			return items[Current];
		}
	}

	public bool MouseInCenter
	{
		get
		{
			//IL_0017: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			float num = INNER_DIAMETER / 2f * ((Component)this).gameObject.transform.lossyScale.x;
			Vector3 val = Input.mousePosition - cursor.transform.position;
			return ((Vector3)(ref val)).magnitude <= num;
		}
	}

	public double Lenght
	{
		get
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			if ((int)EquipWheel.HotkeyDPad.Value == 0)
			{
				float joyLeftStickX = ZInput.GetJoyLeftStickX(false);
				float joyLeftStickY = ZInput.GetJoyLeftStickY(true);
				return Math.Sqrt(Math.Pow(joyLeftStickX, 2.0) + Math.Pow(joyLeftStickY, 2.0));
			}
			float joyRightStickX = ZInput.GetJoyRightStickX(true);
			float joyRightStickY = ZInput.GetJoyRightStickY(true);
			return Math.Sqrt(Math.Pow(joyRightStickX, 2.0) + Math.Pow(joyRightStickY, 2.0));
		}
	}

	public float Angle
	{
		get
		{
			//IL_007c: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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)
			if (ZInput.IsGamepadActive())
			{
				if ((int)EquipWheel.HotkeyDPad.Value == 0)
				{
					float joyLeftStickX = ZInput.GetJoyLeftStickX(false);
					float num = 0f - ZInput.GetJoyLeftStickY(true);
					if (joyLeftStickX != 0f || num != 0f)
					{
						return Mathf.Atan2(num, joyLeftStickX) * 57.29578f - 90f;
					}
				}
				else
				{
					float joyRightStickX = ZInput.GetJoyRightStickX(true);
					float num2 = 0f - ZInput.GetJoyRightStickY(true);
					if (joyRightStickX != 0f || num2 != 0f)
					{
						return Mathf.Atan2(num2, joyRightStickX) * 57.29578f - 90f;
					}
				}
			}
			Vector3 val = Input.mousePosition - cursor.transform.position;
			return Mathf.Atan2(val.y, val.x) * 57.29578f - 90f;
		}
	}

	public IEnumerator FlashCoroutine(float aTime)
	{
		Color color = EquipWheel.GetHighlightColor;
		for (float t = 0f; t < 1f; t += Time.deltaTime / aTime)
		{
			((Graphic)highlight.GetComponent<Image>()).color = Color.Lerp(Color.white, color, t);
			yield return null;
		}
	}

	private int Mod(int a, int b)
	{
		return (a % b + b) % b;
	}

	public void Flash()
	{
		((MonoBehaviour)this).StartCoroutine(FlashCoroutine(0.4f));
	}

	private void Awake()
	{
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Expected O, but got Unknown
		//IL_00c9: 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_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0187: 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)
		cursor = ((Component)((Component)this).transform.Find("Cursor")).gameObject;
		highlight = ((Component)((Component)this).transform.Find("Highlight")).gameObject;
		hotKeyBar = ((Component)((Component)Hud.instance).transform.Find("hudroot/HotKeyBar")).gameObject.GetComponent<HotkeyBar>();
		m_elementPrefab = hotKeyBar.m_elementPrefab;
		itemsRoot = ((Component)this).transform.Find("Items");
		((Graphic)highlight.GetComponent<Image>()).material.SetFloat("_Degree", ANGLE_STEP);
		GameObject val = new GameObject("Text");
		RectTransform obj = val.AddComponent<RectTransform>();
		((Transform)obj).SetParent(((Component)this).transform);
		obj.sizeDelta = new Vector2(1000f, 100f);
		obj.anchoredPosition = new Vector2(0f, 450f);
		text = val.AddComponent<Text>();
		((Graphic)text).color = EquipWheel.GetHighlightColor;
		EquipWheel.HighlightColor.SettingChanged += delegate
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)text).color = EquipWheel.GetHighlightColor;
		};
		text.alignment = (TextAnchor)1;
		text.fontSize = 60;
		text.supportRichText = true;
		Font[] array = Resources.FindObjectsOfTypeAll<Font>();
		foreach (Font val2 in array)
		{
			if (((Object)val2).name == "AveriaSerifLibre-Bold")
			{
				text.font = val2;
				break;
			}
		}
		Outline obj2 = val.AddComponent<Outline>();
		((Shadow)obj2).effectDistance = new Vector2(1f, -1f);
		((Shadow)obj2).effectColor = Color.black;
		val.SetActive(false);
	}

	private void Start()
	{
		if (!addedListener)
		{
			Inventory inventory = ((Humanoid)Player.m_localPlayer).GetInventory();
			inventory.m_onChanged = (Action)Delegate.Combine(inventory.m_onChanged, new Action(OnInventoryChanged));
			addedListener = true;
		}
	}

	public void OnInventoryChanged()
	{
		if (EquipGui.visible)
		{
			UpdateItems();
			UpdateIcons(Player.m_localPlayer, forceUpdate: true);
		}
	}

	private void UpdateItems()
	{
		//IL_0200: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Expected I4, but got Unknown
		//IL_020d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0213: Expected I4, but got Unknown
		//IL_021a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0220: Expected I4, but got Unknown
		//IL_0227: Unknown result type (might be due to invalid IL or missing references)
		//IL_022d: Expected I4, but got Unknown
		//IL_0234: Unknown result type (might be due to invalid IL or missing references)
		//IL_023a: Expected I4, but got Unknown
		//IL_0241: Unknown result type (might be due to invalid IL or missing references)
		//IL_0247: Expected I4, but got Unknown
		//IL_0173: 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_017a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: 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_01a4: 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_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: 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_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Player.m_localPlayer == (Object)null)
		{
			return;
		}
		Inventory inventory = ((Humanoid)Player.m_localPlayer).GetInventory();
		if (inventory == null)
		{
			return;
		}
		if (EquipWheel.ItemFiltering.Value)
		{
			List<ItemData> list = new List<ItemData>();
			List<ItemData> list2 = new List<ItemData>();
			foreach (ItemData allItem in inventory.GetAllItems())
			{
				if (EquipWheel.ItemRegexIgnore.Value.Length > 0)
				{
					Regex regex = new Regex(EquipWheel.ItemRegexIgnore.Value, (!EquipWheel.ItemRegexCaseSensitive.Value) ? RegexOptions.IgnoreCase : RegexOptions.None);
					string input;
					if (EpicLootWrapper.instance != null)
					{
						Color itemColor = EpicLootWrapper.instance.GetItemColor(allItem);
						input = Localization.instance.Localize(EpicLootWrapper.instance.GetItemName(allItem, itemColor));
					}
					else
					{
						input = Localization.instance.Localize(allItem.m_shared.m_name);
					}
					if (regex.IsMatch(input))
					{
						continue;
					}
				}
				if (EquipWheel.ItemRegex.Value.Length > 0)
				{
					Regex regex2 = new Regex(EquipWheel.ItemRegex.Value, (!EquipWheel.ItemRegexCaseSensitive.Value) ? RegexOptions.IgnoreCase : RegexOptions.None);
					string input2;
					if (EpicLootWrapper.instance != null)
					{
						Color itemColor2 = EpicLootWrapper.instance.GetItemColor(allItem);
						input2 = Localization.instance.Localize(EpicLootWrapper.instance.GetItemName(allItem, itemColor2));
					}
					else
					{
						input2 = Localization.instance.Localize(allItem.m_shared.m_name);
					}
					if (regex2.IsMatch(input2))
					{
						list.Add(allItem);
						continue;
					}
				}
				ItemType itemType = allItem.m_shared.m_itemType;
				if (itemType == EquipWheel.ItemType1.Value || itemType == EquipWheel.ItemType2.Value || itemType == EquipWheel.ItemType3.Value || itemType == EquipWheel.ItemType4.Value || itemType == EquipWheel.ItemType5.Value || itemType == EquipWheel.ItemType6.Value)
				{
					list2.Add(allItem);
				}
			}
			ItemType[] types = (ItemType[])(object)new ItemType[6]
			{
				(ItemType)(int)EquipWheel.ItemType1.Value,
				(ItemType)(int)EquipWheel.ItemType2.Value,
				(ItemType)(int)EquipWheel.ItemType3.Value,
				(ItemType)(int)EquipWheel.ItemType4.Value,
				(ItemType)(int)EquipWheel.ItemType5.Value,
				(ItemType)(int)EquipWheel.ItemType6.Value
			};
			list2.Sort((ItemData a, ItemData b) => Array.IndexOf(types, a.m_shared.m_itemType).CompareTo(Array.IndexOf(types, b.m_shared.m_itemType)));
			for (int i = 0; i < 8; i++)
			{
				items[i] = null;
				if (list.Count > i)
				{
					items[i] = list[i];
				}
				else if (list2.Count > i - list.Count)
				{
					items[i] = list2[i - list.Count];
				}
			}
			return;
		}
		for (int j = 0; j < 8; j++)
		{
			items[j] = null;
			ItemData itemAt = inventory.GetItemAt(j, EquipWheel.InventoryRow.Value - 1);
			if (itemAt != null)
			{
				items[j] = itemAt;
			}
		}
	}

	private void OnEnable()
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		((Graphic)highlight.GetComponent<Image>()).color = EquipWheel.GetHighlightColor;
		float value = EquipWheel.GuiScale.Value;
		((Transform)((Component)this).GetComponent<RectTransform>()).localScale = new Vector3(value, value, value);
		EquipWheel.JoyStickIgnoreTime = 0f;
		UpdateItems();
		UpdateIcons(Player.m_localPlayer, forceUpdate: true);
		Update();
	}

	private void OnDisable()
	{
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		highlight.SetActive(false);
		Image[] componentsInChildren = cursor.GetComponentsInChildren<Image>(true);
		foreach (Image val in componentsInChildren)
		{
			((Graphic)val).color = new Color(0f, 0f, 0f, 0.5f);
			if (((Object)((Component)val).gameObject).name == "Image")
			{
				((Component)val).gameObject.SetActive(false);
			}
		}
	}

	private void Update()
	{
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0207: 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_0232: Unknown result type (might be due to invalid IL or missing references)
		//IL_0237: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: 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_017c: Unknown result type (might be due to invalid IL or missing references)
		if (Current != previous)
		{
			if (CurrentItem != null)
			{
				InventoryGui.instance.m_moveItemEffects.Create(((Component)this).transform.position, Quaternion.identity, (Transform)null, 1f, -1);
				((Component)text).gameObject.SetActive(true);
				if (EpicLootWrapper.instance != null)
				{
					Color val = EpicLootWrapper.instance.GetItemColor(CurrentItem);
					if (((Color)(ref val)).Equals(Color.white) || !EquipWheel.UseRarityColoring.Value)
					{
						val = EquipWheel.GetHighlightColor;
					}
					text.text = Localization.instance.Localize(EpicLootWrapper.instance.GetItemName(CurrentItem, val));
				}
				else
				{
					text.text = Localization.instance.Localize(CurrentItem.m_shared.m_name);
				}
			}
			else
			{
				((Component)text).gameObject.SetActive(false);
			}
			previous = Current;
		}
		highlight.SetActive(CurrentItem != null);
		Color color = (Color)((CurrentItem == null) ? new Color(0f, 0f, 0f, 0.5f) : EquipWheel.GetHighlightColor);
		if (CurrentItem != null && EpicLootWrapper.instance != null)
		{
			Color itemColor = EpicLootWrapper.instance.GetItemColor(CurrentItem);
			if (!((Color)(ref itemColor)).Equals(Color.white) && EquipWheel.UseRarityColoring.Value)
			{
				color = itemColor;
				((Graphic)highlight.GetComponent<Image>()).color = color;
			}
			else
			{
				((Graphic)highlight.GetComponent<Image>()).color = EquipWheel.GetHighlightColor;
			}
		}
		Image[] componentsInChildren = cursor.GetComponentsInChildren<Image>(true);
		foreach (Image val2 in componentsInChildren)
		{
			((Graphic)val2).color = color;
			if (((Object)((Component)val2).gameObject).name == "Image")
			{
				((Component)val2).gameObject.SetActive(CurrentItem != null);
			}
		}
		cursor.transform.rotation = Quaternion.AngleAxis(Angle, Vector3.forward);
		float num = (float)Current * ANGLE_STEP;
		highlight.transform.rotation = Quaternion.AngleAxis(0f - num, Vector3.forward);
		UpdateIcons(Player.m_localPlayer);
	}

	private int CountItems(ItemData[] items)
	{
		int num = 0;
		for (int i = 0; i < items.Length; i++)
		{
			if (items[i] != null)
			{
				num++;
			}
		}
		return num;
	}

	private void UpdateIcons(Player player, bool forceUpdate = false)
	{
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Expected O, but got Unknown
		//IL_0100: 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_017f: 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_03ed: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)player) || ((Character)player).IsDead())
		{
			foreach (ElementData element in m_elements)
			{
				Object.Destroy((Object)(object)element.m_go);
			}
			m_elements.Clear();
			return;
		}
		if (m_elements.Count != CountItems(items) || forceUpdate)
		{
			foreach (ElementData element2 in m_elements)
			{
				Object.Destroy((Object)(object)element2.m_go);
			}
			m_elements.Clear();
			for (int i = 0; i < items.Length; i++)
			{
				if (items[i] != null)
				{
					ElementData val = new ElementData();
					val.m_go = Object.Instantiate<GameObject>(m_elementPrefab, itemsRoot);
					val.m_go.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 0.5f);
					float num = Mathf.Sin((float)i * ANGLE_STEP * ((float)Math.PI / 180f)) * ITEM_DISTANCE;
					float num2 = Mathf.Cos((float)i * ANGLE_STEP * ((float)Math.PI / 180f)) * ITEM_DISTANCE;
					val.m_go.transform.localScale = new Vector3(ITEM_SCALE, ITEM_SCALE, ITEM_SCALE);
					val.m_go.transform.localPosition = new Vector3(num, num2, 0f);
					((TMP_Text)((Component)val.m_go.transform.Find("binding")).GetComponent<TextMeshProUGUI>()).text = (i + 1).ToString();
					val.m_icon = ((Component)((Component)val.m_go.transform).transform.Find("icon")).GetComponent<Image>();
					val.m_durability = ((Component)val.m_go.transform.Find("durability")).GetComponent<GuiBar>();
					val.m_amount = ((Component)val.m_go.transform.Find("amount")).GetComponent<TextMeshProUGUI>();
					val.m_equiped = ((Component)val.m_go.transform.Find("equiped")).gameObject;
					val.m_queued = ((Component)val.m_go.transform.Find("queued")).gameObject;
					val.m_selection = ((Component)val.m_go.transform.Find("selected")).gameObject;
					val.m_selection.SetActive(false);
					if (EquipWheel.InventoryRow.Value > 1 || EquipWheel.ItemFiltering.Value)
					{
						((Behaviour)((Component)val.m_go.transform.Find("binding")).GetComponent<TextMeshProUGUI>()).enabled = false;
					}
					m_elements.Add(val);
				}
			}
		}
		foreach (ElementData element3 in m_elements)
		{
			element3.m_used = false;
		}
		int num3 = 0;
		for (int j = 0; j < items.Length; j++)
		{
			if (items[j] == null)
			{
				continue;
			}
			ItemData val2 = items[j];
			ElementData val3 = m_elements[num3];
			val3.m_used = true;
			((Component)val3.m_icon).gameObject.SetActive(true);
			val3.m_icon.sprite = val2.GetIcon();
			((Component)val3.m_durability).gameObject.SetActive(val2.m_shared.m_useDurability);
			if (val2.m_shared.m_useDurability)
			{
				if (val2.m_durability <= 0f)
				{
					val3.m_durability.SetValue(1f);
					val3.m_durability.SetColor((Color)((Mathf.Sin(Time.time * 10f) > 0f) ? Color.red : new Color(0f, 0f, 0f, 0f)));
				}
				else
				{
					val3.m_durability.SetValue(val2.GetDurabilityPercentage());
					val3.m_durability.ResetColor();
				}
			}
			val3.m_equiped.SetActive(val2.m_equipped);
			val3.m_queued.SetActive(player.IsEquipActionQueued(val2));
			if (val2.m_shared.m_maxStackSize > 1)
			{
				((Component)val3.m_amount).gameObject.SetActive(true);
				((TMP_Text)val3.m_amount).text = val2.m_stack + "/" + val2.m_shared.m_maxStackSize;
			}
			else
			{
				((Component)val3.m_amount).gameObject.SetActive(false);
			}
			if (EpicLootWrapper.instance != null)
			{
				EpicLootWrapper.instance.ModifyElement(val3, val2);
			}
			num3++;
		}
		for (int k = 0; k < m_elements.Count; k++)
		{
			ElementData val4 = m_elements[k];
			if (!val4.m_used)
			{
				((Component)val4.m_icon).gameObject.SetActive(false);
				((Component)val4.m_durability).gameObject.SetActive(false);
				val4.m_equiped.SetActive(false);
				val4.m_queued.SetActive(false);
				((Component)val4.m_amount).gameObject.SetActive(false);
			}
		}
	}
}
public class Patcher
{
	public static readonly KeyCode[] NUMBERS;

	[HarmonyPatch(typeof(Player), "Awake")]
	[HarmonyPostfix]
	public static void Awake_Postfix()
	{
		//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)
		string text = "EquipGui (" + Assembly.GetExecutingAssembly().GetName().Name + ")";
		if (!((Object)(object)Menu.instance == (Object)null) && !Object.op_Implicit((Object)(object)GameObject.Find(text)))
		{
			GameObject val = new GameObject(text);
			EquipWheel.Gui = val.AddComponent<EquipGui>();
			val.transform.SetParent(((Component)Menu.instance).transform.parent, false);
			EquipWheel.Log("Spawned EquipGui!");
		}
	}

	[HarmonyPatch(typeof(HotkeyBar), "Update")]
	[HarmonyPrefix]
	public static bool Prefix(HotkeyBar __instance)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)EquipWheel.Instance == (Object)null)
		{
			return true;
		}
		if (EquipWheel.HotkeyDPad != null && (int)EquipWheel.HotkeyDPad.Value == 0)
		{
			return true;
		}
		Player localPlayer = Player.m_localPlayer;
		if ((Object)(object)localPlayer != (Object)null)
		{
			typeof(HotkeyBar).GetMethod("UpdateIcons", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[1] { localPlayer });
		}
		return false;
	}

	[HarmonyPatch(typeof(Player), "UseHotbarItem")]
	[HarmonyPrefix]
	public static bool UseHotbarItem(int index)
	{
		//IL_000a: 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_0012: Unknown result type (might be due to invalid IL or missing references)
		KeyCode[] nUMBERS = NUMBERS;
		KeyboardShortcut value = EquipWheel.Hotkey.Value;
		bool num = Array.IndexOf(nUMBERS, ((KeyboardShortcut)(ref value)).MainKey) != index - 1;
		bool flag = !EquipWheel.IsShortcutDown;
		if (!(num || flag) && EquipWheel.CanOpenMenu)
		{
			return ZInput.IsGamepadActive();
		}
		return true;
	}

	[HarmonyPatch(typeof(Player), "Update")]
	[HarmonyPostfix]
	public static void Update()
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		Player localPlayer = Player.m_localPlayer;
		if (!((Object)(object)localPlayer == (Object)null) && EquipWheel.UseSitButton.Value && (int)EquipWheel.HotkeyDPad.Value == 0 && (ZInput.GetButtonDown("JoySit") || ZInput.GetButtonUp("JoySit")))
		{
			typeof(Player).GetMethod("StopEmote", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(localPlayer, new object[0]);
		}
	}

	static Patcher()
	{
		KeyCode[] array = new KeyCode[8];
		RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
		NUMBERS = (KeyCode[])(object)array;
	}
}

EquipWheelTwo.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EquipWheel;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("EquipWheelTwo")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("EquipWheelTwo")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7a967d55-e853-4fc7-9040-7913122fb3b5")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.5", FrameworkDisplayName = "")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace EquipWheelTwo;

[BepInPlugin("virtuacode.valheim.equipwheeltwo", "Equip Wheel Mod (EquipWheelTwo)", "1.5.3")]
public class EquipWheel : BaseUnityPlugin, IWheel
{
	private static Harmony harmony;

	public static ManualLogSource MyLogger = Logger.CreateLogSource(Assembly.GetExecutingAssembly().GetName().Name);

	public static ConfigEntry<KeyboardShortcut> Hotkey;

	public static ConfigEntry<DPadButton> HotkeyDPad;

	public static ConfigEntry<bool> UseSitButton;

	public static ConfigEntry<bool> TriggerOnRelease;

	public static ConfigEntry<bool> TriggerOnClick;

	public static ConfigEntry<bool> ToggleMenu;

	public static ConfigEntry<bool> ModEnabled;

	public static ConfigEntry<Color> HighlightColor;

	public static ConfigEntry<float> GuiScale;

	public static ConfigEntry<int> InventoryRow;

	public static ConfigEntry<bool> ItemFiltering;

	public static ConfigEntry<ItemType> ItemType1;

	public static ConfigEntry<ItemType> ItemType2;

	public static ConfigEntry<ItemType> ItemType3;

	public static ConfigEntry<ItemType> ItemType4;

	public static ConfigEntry<ItemType> ItemType5;

	public static ConfigEntry<ItemType> ItemType6;

	public static ConfigEntry<string> ItemRegex;

	public static ConfigEntry<string> ItemRegexIgnore;

	public static ConfigEntry<bool> ItemRegexCaseSensitive;

	private static EquipWheel instance;

	public static KeyCode replacedKey = (KeyCode)0;

	public static List<string> replacedButtons = new List<string>();

	public static float JoyStickIgnoreTime = 0f;

	public static EquipGui Gui;

	public static Color GetHighlightColor => HighlightColor.Value;

	public static EquipWheel Instance => instance;

	public static bool CanOpenMenu
	{
		get
		{
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer == (Object)null) && !((Character)localPlayer).IsDead() && !((Character)localPlayer).InCutscene() && !((Character)localPlayer).IsTeleporting() && TakeInput(look: true) && !InInventoryEtc() && !WheelManager.inventoryVisible)
			{
				if (IsUsingUseButton())
				{
					return !WheelManager.pressedOnHovering;
				}
				return true;
			}
			return false;
		}
	}

	public static bool BestMatchPressed
	{
		get
		{
			if ((Object)(object)Instance == (Object)null)
			{
				return false;
			}
			return WheelManager.BestMatchPressed((IWheel)(object)Instance);
		}
	}

	public static bool BestMatchDown
	{
		get
		{
			if ((Object)(object)Instance == (Object)null)
			{
				return false;
			}
			return WheelManager.BestMatchDown((IWheel)(object)Instance);
		}
	}

	public static bool IsShortcutDown
	{
		get
		{
			//IL_009c: 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_00a4: 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_002b: Expected I4, but got Unknown
			if (ZInput.IsGamepadActive())
			{
				DPadButton value = HotkeyDPad.Value;
				switch ((int)value)
				{
				case 0:
					if (UseSitButton.Value)
					{
						return ZInput.GetButtonDown("JoySit");
					}
					return ZInput.GetButtonDown("JoyUse");
				case 1:
					return ZInput.GetButtonDown("JoyHotbarLeft");
				case 2:
					return ZInput.GetButtonDown("JoyHotbarRight");
				case 3:
					if (!ZInput.GetButtonDown("JoyHotbarRight"))
					{
						return ZInput.GetButtonDown("JoyHotbarLeft");
					}
					return true;
				default:
					if (!ZInput.GetButtonDown("JoyHotbarRight"))
					{
						return ZInput.GetButtonDown("JoyHotbarLeft");
					}
					return true;
				}
			}
			KeyboardShortcut value2 = Hotkey.Value;
			KeyCode mainKey = ((KeyboardShortcut)(ref value2)).MainKey;
			KeyCode[] source = ((KeyboardShortcut)(ref value2)).Modifiers.ToArray();
			if (!Input.GetKeyDown(mainKey))
			{
				return ((IEnumerable<KeyCode>)source).Any((Func<KeyCode, bool>)Input.GetKeyDown);
			}
			return true;
		}
	}

	public static bool IsShortcutUp
	{
		get
		{
			//IL_009c: 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_00a4: 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_002b: Expected I4, but got Unknown
			if (ZInput.IsGamepadActive())
			{
				DPadButton value = HotkeyDPad.Value;
				switch ((int)value)
				{
				case 0:
					if (UseSitButton.Value)
					{
						return ZInput.GetButtonUp("JoySit");
					}
					return ZInput.GetButtonUp("JoyUse");
				case 1:
					return ZInput.GetButtonUp("JoyHotbarLeft");
				case 2:
					return ZInput.GetButtonUp("JoyHotbarRight");
				case 3:
					if (!ZInput.GetButtonUp("JoyHotbarRight"))
					{
						return ZInput.GetButtonUp("JoyHotbarLeft");
					}
					return true;
				default:
					if (!ZInput.GetButtonUp("JoyHotbarRight"))
					{
						return ZInput.GetButtonUp("JoyHotbarLeft");
					}
					return true;
				}
			}
			KeyboardShortcut value2 = Hotkey.Value;
			KeyCode mainKey = ((KeyboardShortcut)(ref value2)).MainKey;
			KeyCode[] source = ((KeyboardShortcut)(ref value2)).Modifiers.ToArray();
			if (!Input.GetKeyUp(mainKey))
			{
				return ((IEnumerable<KeyCode>)source).Any((Func<KeyCode, bool>)Input.GetKeyUp);
			}
			return true;
		}
	}

	public static bool IsShortcutPressed
	{
		get
		{
			//IL_009c: 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_00a4: 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_002b: Expected I4, but got Unknown
			if (ZInput.IsGamepadActive())
			{
				DPadButton value = HotkeyDPad.Value;
				switch ((int)value)
				{
				case 0:
					if (UseSitButton.Value)
					{
						return ZInput.GetButton("JoySit");
					}
					return ZInput.GetButton("JoyUse");
				case 1:
					return ZInput.GetButton("JoyHotbarLeft");
				case 2:
					return ZInput.GetButton("JoyHotbarRight");
				case 3:
					if (!ZInput.GetButton("JoyHotbarRight"))
					{
						return ZInput.GetButton("JoyHotbarLeft");
					}
					return true;
				default:
					if (!ZInput.GetButton("JoyHotbarRight"))
					{
						return ZInput.GetButton("JoyHotbarLeft");
					}
					return true;
				}
			}
			KeyboardShortcut value2 = Hotkey.Value;
			KeyCode mainKey = ((KeyboardShortcut)(ref value2)).MainKey;
			KeyCode[] source = ((KeyboardShortcut)(ref value2)).Modifiers.ToArray();
			if (!Input.GetKey(mainKey))
			{
				return ((IEnumerable<KeyCode>)source).Any((Func<KeyCode, bool>)Input.GetKey);
			}
			return true;
		}
	}

	public static void Log(string msg)
	{
		ManualLogSource myLogger = MyLogger;
		if (myLogger != null)
		{
			myLogger.LogInfo((object)msg);
		}
	}

	public static void LogErr(string msg)
	{
		ManualLogSource myLogger = MyLogger;
		if (myLogger != null)
		{
			myLogger.LogError((object)msg);
		}
	}

	public static void LogWarn(string msg)
	{
		ManualLogSource myLogger = MyLogger;
		if (myLogger != null)
		{
			myLogger.LogWarning((object)msg);
		}
	}

	private static bool TakeInput(bool look = false)
	{
		if (!GameCamera.InFreeFly() && (!Object.op_Implicit((Object)(object)Chat.instance) || !Chat.instance.HasFocus()) && !Menu.IsVisible() && !Console.IsVisible() && !TextInput.IsVisible() && !Minimap.InTextInput() && (!ZInput.IsGamepadActive() || !Minimap.IsOpen()) && (!ZInput.IsGamepadActive() || !StoreGui.IsVisible()) && (!ZInput.IsGamepadActive() || !Hud.IsPieceSelectionVisible()) && (!PlayerCustomizaton.IsBarberGuiVisible() || look))
		{
			if (PlayerCustomizaton.BarberBlocksLook())
			{
				return !look;
			}
			return true;
		}
		return false;
	}

	private static bool InInventoryEtc()
	{
		if (!Minimap.IsOpen() && !StoreGui.IsVisible())
		{
			return Hud.IsPieceSelectionVisible();
		}
		return true;
	}

	public static bool IsDedicated()
	{
		MethodInfo method = typeof(ZNet).GetMethod("IsDedicated", BindingFlags.Instance | BindingFlags.Public);
		return ((Func<ZNet, bool>)Delegate.CreateDelegate(typeof(Func<ZNet, bool>), method))(null);
	}

	public static bool IsUsingUseButton()
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		if (ZInput.IsGamepadActive() && (int)HotkeyDPad.Value == 0)
		{
			return !UseSitButton.Value;
		}
		return false;
	}

	public void Awake()
	{
		//IL_003b: 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_0169: Unknown result type (might be due to invalid IL or missing references)
		//IL_0173: Expected O, but got Unknown
		instance = this;
		ModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ModEnabled", true, "Enable mod when value is true");
		Hotkey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Input", "Hotkey", KeyboardShortcut.Deserialize("G"), "Hotkey for opening equip wheel menu");
		HotkeyDPad = ((BaseUnityPlugin)this).Config.Bind<DPadButton>("Input", "HotkeyDPad", (DPadButton)0, "Hotkey on the D-Pad (None, Left, Right or LeftOrRight)");
		UseSitButton = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "UseSitButton", false, "When enabled use the sit button as hotkey (HotkeyDPad has to be set to None)");
		TriggerOnRelease = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "TriggerOnRelease", true, "Releasing the Hotkey will equip/use the selected item");
		TriggerOnClick = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "TriggerOnClick", false, "Click with left mouse button will equip/use the selected item");
		ToggleMenu = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "ToggleMenu", false, "When enabled the equip wheel will toggle between hidden/visible when the hotkey was pressed");
		HighlightColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Appereance", "HighlightColor", new Color(0.414f, 0.734f, 1f), "Color of the highlighted selection");
		GuiScale = ((BaseUnityPlugin)this).Config.Bind<float>("Appereance", "GuiScale", 0.5f, "Scale factor of the user interface");
		InventoryRow = ((BaseUnityPlugin)this).Config.Bind<int>("Misc", "InventoryRow", 1, new ConfigDescription("Row of the inventory that should be used for the equip wheel", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 4), new object[0]));
		ItemFiltering = ((BaseUnityPlugin)this).Config.Bind<bool>("Misc", "ItemFiltering", false, "Will scan the whole inventory for items of the specified item types and Regex and show them in the equip wheel");
		ItemType1 = ((BaseUnityPlugin)this).Config.Bind<ItemType>("Misc", "ItemType1", (ItemType)0, "Item type used for filtering items");
		ItemType2 = ((BaseUnityPlugin)this).Config.Bind<ItemType>("Misc", "ItemType2", (ItemType)0, "Item type used for filtering items");
		ItemType3 = ((BaseUnityPlugin)this).Config.Bind<ItemType>("Misc", "ItemType3", (ItemType)0, "Item type used for filtering items");
		ItemType4 = ((BaseUnityPlugin)this).Config.Bind<ItemType>("Misc", "ItemType4", (ItemType)0, "Item type used for filtering items");
		ItemType5 = ((BaseUnityPlugin)this).Config.Bind<ItemType>("Misc", "ItemType5", (ItemType)0, "Item type used for filtering items");
		ItemType6 = ((BaseUnityPlugin)this).Config.Bind<ItemType>("Misc", "ItemType6", (ItemType)0, "Item type used for filtering items");
		ItemRegex = ((BaseUnityPlugin)this).Config.Bind<string>("Misc", "ItemRegex", "", "Regex used for filtering items");
		ItemRegexIgnore = ((BaseUnityPlugin)this).Config.Bind<string>("Misc", "ItemRegexIgnore", "", "Regex used for ignoring items");
		ItemRegexCaseSensitive = ((BaseUnityPlugin)this).Config.Bind<bool>("Misc", "ItemRegexCaseSensitive", false, "When enabled the Regex will be case-sensitive");
		if (!ModEnabled.Value)
		{
			LogWarn("Mod not loaded because it was disabled via config.");
			return;
		}
		if (IsDedicated())
		{
			LogWarn("Mod not loaded because game instance is a dedicated server.");
			return;
		}
		harmony = Harmony.CreateAndPatchAll(typeof(Patcher), (string)null);
		WheelManager.AddWheel((IWheel)(object)this);
		Log(((object)this).GetType().Namespace + " Loaded!");
	}

	private void OnDestroy()
	{
		WheelManager.RemoveWheel((IWheel)(object)this);
		Harmony obj = harmony;
		if (obj != null)
		{
			obj.UnpatchAll((string)null);
		}
	}

	public static void TryHideHotkeyBar()
	{
	}

	public static void ParseNames(string value, ref string[] arr)
	{
		if ((Object)(object)ObjectDB.instance == (Object)null)
		{
			return;
		}
		string[] array = ParseTokens(value);
		List<string> list = new List<string>();
		string[] array2 = array;
		foreach (string text in array2)
		{
			GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(text);
			if ((Object)(object)itemPrefab != (Object)null)
			{
				ItemDrop component = itemPrefab.GetComponent<ItemDrop>();
				list.Add(component.m_itemData.m_shared.m_name);
			}
		}
		arr = list.Distinct().ToArray();
	}

	public static string[] ParseTokens(string value)
	{
		char[] separator = new char[5] { ' ', ',', '.', ':', '\t' };
		return value.Split(separator, StringSplitOptions.RemoveEmptyEntries);
	}

	public int GetKeyCount(bool pressed = false)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		int num = 0;
		KeyboardShortcut value = Hotkey.Value;
		KeyCode mainKey = ((KeyboardShortcut)(ref value)).MainKey;
		KeyCode[] source = ((KeyboardShortcut)(ref value)).Modifiers.ToArray();
		if ((int)mainKey == 0)
		{
			return num;
		}
		if (pressed ? Input.GetKey(mainKey) : Input.GetKeyDown(mainKey))
		{
			num++;
		}
		return num + ((IEnumerable<KeyCode>)source).Count((Func<KeyCode, bool>)Input.GetKey);
	}

	public int GetKeyCountDown()
	{
		return GetKeyCount();
	}

	public int GetKeyCountPressed()
	{
		return GetKeyCount(pressed: true);
	}

	public bool IsVisible()
	{
		return EquipGui.visible;
	}

	public void Hide()
	{
		if (!((Object)(object)Gui == (Object)null))
		{
			Gui.Hide();
		}
	}

	public string GetName()
	{
		return Assembly.GetExecutingAssembly().GetName().Name;
	}

	float IWheel.JoyStickIgnoreTime()
	{
		return JoyStickIgnoreTime;
	}
}
public class EquipGui : MonoBehaviour
{
	private EquipWheelUI ui;

	public AssetBundle assets;

	public static bool visible;

	public int toggleVisible;

	public static bool toggleDownWasPressed;

	private void Awake()
	{
		//IL_0031: 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)
		LoadAssets();
		GameObject obj = assets.LoadAsset<GameObject>("assets/selectionwheel/selectionwheel.prefab");
		RectTransform val = ((Component)this).gameObject.AddComponent<RectTransform>();
		GameObject val2 = Object.Instantiate<GameObject>(obj, new Vector3(0f, 0f, 0f), ((Component)this).transform.rotation, (Transform)(object)val);
		ui = val2.AddComponent<EquipWheelUI>();
		val2.SetActive(false);
		visible = false;
		assets.Unload(false);
	}

	private void Start()
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		RectTransform component = ((Component)this).gameObject.GetComponent<RectTransform>();
		component.offsetMin = Vector2.zero;
		component.offsetMax = Vector2.zero;
		component.anchorMax = new Vector2(1f, 1f);
		component.anchorMin = new Vector2(0f, 0f);
		component.anchoredPosition = new Vector2(0f, 0f);
		if (!((Object)(object)Hud.instance == (Object)null))
		{
			EquipWheel.TryHideHotkeyBar();
		}
	}

	private void LoadAssets()
	{
		Stream manifestResourceStream = Assembly.GetAssembly(typeof(EquipWheel)).GetManifestResourceStream("EquipWheel.res.selectionwheel");
		using MemoryStream memoryStream = new MemoryStream();
		manifestResourceStream.CopyTo(memoryStream);
		assets = AssetBundle.LoadFromMemory(memoryStream.ToArray());
	}

	public void Hide()
	{
		((Component)ui).gameObject.SetActive(false);
		visible = false;
		toggleVisible = 0;
	}

	private void Update()
	{
		if (EquipWheel.ToggleMenu.Value)
		{
			HandleToggleEnabled();
		}
		else
		{
			HandleToggleDisabled();
		}
	}

	private void ReduceJoyStickIgnoreTime()
	{
		if (EquipWheel.JoyStickIgnoreTime > 0f)
		{
			EquipWheel.JoyStickIgnoreTime -= Time.deltaTime;
		}
	}

	private void HandlePressedHovering()
	{
		if (WheelManager.pressedOnHovering && ZInput.GetButtonUp("JoyUse"))
		{
			WheelManager.pressedOnHovering = false;
			WheelManager.hoverTextVisible = false;
		}
		else if (EquipWheel.IsShortcutDown && EquipWheel.IsUsingUseButton())
		{
			WheelManager.pressedOnHovering = WheelManager.pressedOnHovering || WheelManager.hoverTextVisible;
		}
	}

	private void HandleToggleEnabled()
	{
		ReduceJoyStickIgnoreTime();
		HandlePressedHovering();
		if (!EquipWheel.CanOpenMenu)
		{
			Hide();
			return;
		}
		if (toggleDownWasPressed)
		{
			if (EquipWheel.IsShortcutUp)
			{
				Hide();
				toggleDownWasPressed = false;
			}
			return;
		}
		if (EquipWheel.IsShortcutDown && toggleVisible < 2)
		{
			toggleVisible++;
		}
		bool flag = EquipWheel.IsShortcutDown && toggleVisible == 2;
		if (EquipWheel.TriggerOnRelease.Value && flag && WheelManager.IsActive((IWheel)(object)EquipWheel.Instance))
		{
			UseCurrentItem();
			toggleDownWasPressed = true;
		}
		else if (toggleVisible > 0 && !flag)
		{
			if (!visible)
			{
				((Component)ui).gameObject.SetActive(true);
				visible = true;
				WheelManager.Activate((IWheel)(object)EquipWheel.Instance);
			}
			if (EquipWheel.TriggerOnClick.Value && (Input.GetMouseButtonDown(0) || Input.GetKeyDown((KeyCode)330)))
			{
				UseCurrentItem(flash: true);
			}
		}
		else
		{
			Hide();
		}
	}

	private void UseCurrentItem(bool flash = false)
	{
		if (ui.CurrentItem != null)
		{
			if (flash)
			{
				ui.Flash();
			}
			((Humanoid)Player.m_localPlayer).UseItem((Inventory)null, ui.CurrentItem, false);
			EquipWheel.JoyStickIgnoreTime = (float)EquipWheel.IgnoreJoyStickDuration.Value / 1000f;
		}
	}

	private void HandleToggleDisabled()
	{
		ReduceJoyStickIgnoreTime();
		HandlePressedHovering();
		if (!EquipWheel.CanOpenMenu)
		{
			Hide();
		}
		else if (EquipWheel.TriggerOnRelease.Value && EquipWheel.IsShortcutUp)
		{
			UseCurrentItem();
			Hide();
		}
		else if ((EquipWheel.IsShortcutPressed && ZInput.IsGamepadActive()) || (EquipWheel.IsShortcutPressed && (EquipWheel.BestMatchPressed || EquipWheel.BestMatchDown)))
		{
			if (!visible)
			{
				((Component)ui).gameObject.SetActive(true);
				visible = true;
				WheelManager.Activate((IWheel)(object)EquipWheel.Instance);
			}
			if (EquipWheel.TriggerOnClick.Value && (Input.GetMouseButtonDown(0) || Input.GetKeyDown((KeyCode)330)))
			{
				UseCurrentItem(flash: true);
			}
		}
		else
		{
			Hide();
		}
	}
}
public class EquipWheelUI : MonoBehaviour
{
	public readonly float ANGLE_STEP = 45f;

	public readonly float ITEM_DISTANCE = 295f;

	public readonly float ITEM_SCALE = 2f;

	public readonly float INNER_DIAMETER = 340f;

	public readonly float LENGTH_THRESHOLD = 0.1f;

	private GameObject cursor;

	private Text text;

	private GameObject highlight;

	private readonly ItemData[] items = (ItemData[])(object)new ItemData[8];

	private HotkeyBar hotKeyBar;

	private Transform itemsRoot;

	private bool addedListener;

	private readonly List<ElementData> m_elements = new List<ElementData>();

	private GameObject m_elementPrefab;

	private int previous = -1;

	public int Current
	{
		get
		{
			if ((!ZInput.IsGamepadActive() && MouseInCenter) || JoyStickInCenter || (ZInput.IsGamepadActive() && Lenght < (double)LENGTH_THRESHOLD))
			{
				return -1;
			}
			int num = Mod((int)Mathf.Round((0f - Angle) / ANGLE_STEP), 8);
			if (num >= items.Length)
			{
				return -1;
			}
			return num;
		}
	}

	public bool JoyStickInCenter
	{
		get
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			if ((int)EquipWheel.HotkeyDPad.Value == 0)
			{
				float joyLeftStickX = ZInput.GetJoyLeftStickX(false);
				float joyLeftStickY = ZInput.GetJoyLeftStickY(true);
				if (ZInput.IsGamepadActive() && joyLeftStickX == 0f)
				{
					return joyLeftStickY == 0f;
				}
				return false;
			}
			float joyRightStickX = ZInput.GetJoyRightStickX(true);
			float joyRightStickY = ZInput.GetJoyRightStickY(true);
			if (ZInput.IsGamepadActive() && joyRightStickX == 0f)
			{
				return joyRightStickY == 0f;
			}
			return false;
		}
	}

	public ItemData CurrentItem
	{
		get
		{
			if (Current < 0)
			{
				return null;
			}
			return items[Current];
		}
	}

	public bool MouseInCenter
	{
		get
		{
			//IL_0017: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			float num = INNER_DIAMETER / 2f * ((Component)this).gameObject.transform.lossyScale.x;
			Vector3 val = Input.mousePosition - cursor.transform.position;
			return ((Vector3)(ref val)).magnitude <= num;
		}
	}

	public double Lenght
	{
		get
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			if ((int)EquipWheel.HotkeyDPad.Value == 0)
			{
				float joyLeftStickX = ZInput.GetJoyLeftStickX(false);
				float joyLeftStickY = ZInput.GetJoyLeftStickY(true);
				return Math.Sqrt(Math.Pow(joyLeftStickX, 2.0) + Math.Pow(joyLeftStickY, 2.0));
			}
			float joyRightStickX = ZInput.GetJoyRightStickX(true);
			float joyRightStickY = ZInput.GetJoyRightStickY(true);
			return Math.Sqrt(Math.Pow(joyRightStickX, 2.0) + Math.Pow(joyRightStickY, 2.0));
		}
	}

	public float Angle
	{
		get
		{
			//IL_007c: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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)
			if (ZInput.IsGamepadActive())
			{
				if ((int)EquipWheel.HotkeyDPad.Value == 0)
				{
					float joyLeftStickX = ZInput.GetJoyLeftStickX(false);
					float num = 0f - ZInput.GetJoyLeftStickY(true);
					if (joyLeftStickX != 0f || num != 0f)
					{
						return Mathf.Atan2(num, joyLeftStickX) * 57.29578f - 90f;
					}
				}
				else
				{
					float joyRightStickX = ZInput.GetJoyRightStickX(true);
					float num2 = 0f - ZInput.GetJoyRightStickY(true);
					if (joyRightStickX != 0f || num2 != 0f)
					{
						return Mathf.Atan2(num2, joyRightStickX) * 57.29578f - 90f;
					}
				}
			}
			Vector3 val = Input.mousePosition - cursor.transform.position;
			return Mathf.Atan2(val.y, val.x) * 57.29578f - 90f;
		}
	}

	public IEnumerator FlashCoroutine(float aTime)
	{
		Color color = EquipWheel.GetHighlightColor;
		for (float t = 0f; t < 1f; t += Time.deltaTime / aTime)
		{
			((Graphic)highlight.GetComponent<Image>()).color = Color.Lerp(Color.white, color, t);
			yield return null;
		}
	}

	private int Mod(int a, int b)
	{
		return (a % b + b) % b;
	}

	public void Flash()
	{
		((MonoBehaviour)this).StartCoroutine(FlashCoroutine(0.4f));
	}

	private void Awake()
	{
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Expected O, but got Unknown
		//IL_00c9: 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_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0187: 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)
		cursor = ((Component)((Component)this).transform.Find("Cursor")).gameObject;
		highlight = ((Component)((Component)this).transform.Find("Highlight")).gameObject;
		hotKeyBar = ((Component)((Component)Hud.instance).transform.Find("hudroot/HotKeyBar")).gameObject.GetComponent<HotkeyBar>();
		m_elementPrefab = hotKeyBar.m_elementPrefab;
		itemsRoot = ((Component)this).transform.Find("Items");
		((Graphic)highlight.GetComponent<Image>()).material.SetFloat("_Degree", ANGLE_STEP);
		GameObject val = new GameObject("Text");
		RectTransform obj = val.AddComponent<RectTransform>();
		((Transform)obj).SetParent(((Component)this).transform);
		obj.sizeDelta = new Vector2(1000f, 100f);
		obj.anchoredPosition = new Vector2(0f, 450f);
		text = val.AddComponent<Text>();
		((Graphic)text).color = EquipWheel.GetHighlightColor;
		EquipWheel.HighlightColor.SettingChanged += delegate
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)text).color = EquipWheel.GetHighlightColor;
		};
		text.alignment = (TextAnchor)1;
		text.fontSize = 60;
		text.supportRichText = true;
		Font[] array = Resources.FindObjectsOfTypeAll<Font>();
		foreach (Font val2 in array)
		{
			if (((Object)val2).name == "AveriaSerifLibre-Bold")
			{
				text.font = val2;
				break;
			}
		}
		Outline obj2 = val.AddComponent<Outline>();
		((Shadow)obj2).effectDistance = new Vector2(1f, -1f);
		((Shadow)obj2).effectColor = Color.black;
		val.SetActive(false);
	}

	private void Start()
	{
		if (!addedListener)
		{
			Inventory inventory = ((Humanoid)Player.m_localPlayer).GetInventory();
			inventory.m_onChanged = (Action)Delegate.Combine(inventory.m_onChanged, new Action(OnInventoryChanged));
			addedListener = true;
		}
	}

	public void OnInventoryChanged()
	{
		if (EquipGui.visible)
		{
			UpdateItems();
			UpdateIcons(Player.m_localPlayer, forceUpdate: true);
		}
	}

	private void UpdateItems()
	{
		//IL_0200: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Expected I4, but got Unknown
		//IL_020d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0213: Expected I4, but got Unknown
		//IL_021a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0220: Expected I4, but got Unknown
		//IL_0227: Unknown result type (might be due to invalid IL or missing references)
		//IL_022d: Expected I4, but got Unknown
		//IL_0234: Unknown result type (might be due to invalid IL or missing references)
		//IL_023a: Expected I4, but got Unknown
		//IL_0241: Unknown result type (might be due to invalid IL or missing references)
		//IL_0247: Expected I4, but got Unknown
		//IL_0173: 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_017a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: 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_01a4: 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_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: 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_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Player.m_localPlayer == (Object)null)
		{
			return;
		}
		Inventory inventory = ((Humanoid)Player.m_localPlayer).GetInventory();
		if (inventory == null)
		{
			return;
		}
		if (EquipWheel.ItemFiltering.Value)
		{
			List<ItemData> list = new List<ItemData>();
			List<ItemData> list2 = new List<ItemData>();
			foreach (ItemData allItem in inventory.GetAllItems())
			{
				if (EquipWheel.ItemRegexIgnore.Value.Length > 0)
				{
					Regex regex = new Regex(EquipWheel.ItemRegexIgnore.Value, (!EquipWheel.ItemRegexCaseSensitive.Value) ? RegexOptions.IgnoreCase : RegexOptions.None);
					string input;
					if (EpicLootWrapper.instance != null)
					{
						Color itemColor = EpicLootWrapper.instance.GetItemColor(allItem);
						input = Localization.instance.Localize(EpicLootWrapper.instance.GetItemName(allItem, itemColor));
					}
					else
					{
						input = Localization.instance.Localize(allItem.m_shared.m_name);
					}
					if (regex.IsMatch(input))
					{
						continue;
					}
				}
				if (EquipWheel.ItemRegex.Value.Length > 0)
				{
					Regex regex2 = new Regex(EquipWheel.ItemRegex.Value, (!EquipWheel.ItemRegexCaseSensitive.Value) ? RegexOptions.IgnoreCase : RegexOptions.None);
					string input2;
					if (EpicLootWrapper.instance != null)
					{
						Color itemColor2 = EpicLootWrapper.instance.GetItemColor(allItem);
						input2 = Localization.instance.Localize(EpicLootWrapper.instance.GetItemName(allItem, itemColor2));
					}
					else
					{
						input2 = Localization.instance.Localize(allItem.m_shared.m_name);
					}
					if (regex2.IsMatch(input2))
					{
						list.Add(allItem);
						continue;
					}
				}
				ItemType itemType = allItem.m_shared.m_itemType;
				if (itemType == EquipWheel.ItemType1.Value || itemType == EquipWheel.ItemType2.Value || itemType == EquipWheel.ItemType3.Value || itemType == EquipWheel.ItemType4.Value || itemType == EquipWheel.ItemType5.Value || itemType == EquipWheel.ItemType6.Value)
				{
					list2.Add(allItem);
				}
			}
			ItemType[] types = (ItemType[])(object)new ItemType[6]
			{
				(ItemType)(int)EquipWheel.ItemType1.Value,
				(ItemType)(int)EquipWheel.ItemType2.Value,
				(ItemType)(int)EquipWheel.ItemType3.Value,
				(ItemType)(int)EquipWheel.ItemType4.Value,
				(ItemType)(int)EquipWheel.ItemType5.Value,
				(ItemType)(int)EquipWheel.ItemType6.Value
			};
			list2.Sort((ItemData a, ItemData b) => Array.IndexOf(types, a.m_shared.m_itemType).CompareTo(Array.IndexOf(types, b.m_shared.m_itemType)));
			for (int i = 0; i < 8; i++)
			{
				items[i] = null;
				if (list.Count > i)
				{
					items[i] = list[i];
				}
				else if (list2.Count > i - list.Count)
				{
					items[i] = list2[i - list.Count];
				}
			}
			return;
		}
		for (int j = 0; j < 8; j++)
		{
			items[j] = null;
			ItemData itemAt = inventory.GetItemAt(j, EquipWheel.InventoryRow.Value - 1);
			if (itemAt != null)
			{
				items[j] = itemAt;
			}
		}
	}

	private void OnEnable()
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		((Graphic)highlight.GetComponent<Image>()).color = EquipWheel.GetHighlightColor;
		float value = EquipWheel.GuiScale.Value;
		((Transform)((Component)this).GetComponent<RectTransform>()).localScale = new Vector3(value, value, value);
		EquipWheel.JoyStickIgnoreTime = 0f;
		UpdateItems();
		UpdateIcons(Player.m_localPlayer, forceUpdate: true);
		Update();
	}

	private void OnDisable()
	{
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		highlight.SetActive(false);
		Image[] componentsInChildren = cursor.GetComponentsInChildren<Image>(true);
		foreach (Image val in componentsInChildren)
		{
			((Graphic)val).color = new Color(0f, 0f, 0f, 0.5f);
			if (((Object)((Component)val).gameObject).name == "Image")
			{
				((Component)val).gameObject.SetActive(false);
			}
		}
	}

	private void Update()
	{
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0207: 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_0232: Unknown result type (might be due to invalid IL or missing references)
		//IL_0237: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: 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_017c: Unknown result type (might be due to invalid IL or missing references)
		if (Current != previous)
		{
			if (CurrentItem != null)
			{
				InventoryGui.instance.m_moveItemEffects.Create(((Component)this).transform.position, Quaternion.identity, (Transform)null, 1f, -1);
				((Component)text).gameObject.SetActive(true);
				if (EpicLootWrapper.instance != null)
				{
					Color val = EpicLootWrapper.instance.GetItemColor(CurrentItem);
					if (((Color)(ref val)).Equals(Color.white) || !EquipWheel.UseRarityColoring.Value)
					{
						val = EquipWheel.GetHighlightColor;
					}
					text.text = Localization.instance.Localize(EpicLootWrapper.instance.GetItemName(CurrentItem, val));
				}
				else
				{
					text.text = Localization.instance.Localize(CurrentItem.m_shared.m_name);
				}
			}
			else
			{
				((Component)text).gameObject.SetActive(false);
			}
			previous = Current;
		}
		highlight.SetActive(CurrentItem != null);
		Color color = (Color)((CurrentItem == null) ? new Color(0f, 0f, 0f, 0.5f) : EquipWheel.GetHighlightColor);
		if (CurrentItem != null && EpicLootWrapper.instance != null)
		{
			Color itemColor = EpicLootWrapper.instance.GetItemColor(CurrentItem);
			if (!((Color)(ref itemColor)).Equals(Color.white) && EquipWheel.UseRarityColoring.Value)
			{
				color = itemColor;
				((Graphic)highlight.GetComponent<Image>()).color = color;
			}
			else
			{
				((Graphic)highlight.GetComponent<Image>()).color = EquipWheel.GetHighlightColor;
			}
		}
		Image[] componentsInChildren = cursor.GetComponentsInChildren<Image>(true);
		foreach (Image val2 in componentsInChildren)
		{
			((Graphic)val2).color = color;
			if (((Object)((Component)val2).gameObject).name == "Image")
			{
				((Component)val2).gameObject.SetActive(CurrentItem != null);
			}
		}
		cursor.transform.rotation = Quaternion.AngleAxis(Angle, Vector3.forward);
		float num = (float)Current * ANGLE_STEP;
		highlight.transform.rotation = Quaternion.AngleAxis(0f - num, Vector3.forward);
		UpdateIcons(Player.m_localPlayer);
	}

	private int CountItems(ItemData[] items)
	{
		int num = 0;
		for (int i = 0; i < items.Length; i++)
		{
			if (items[i] != null)
			{
				num++;
			}
		}
		return num;
	}

	private void UpdateIcons(Player player, bool forceUpdate = false)
	{
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Expected O, but got Unknown
		//IL_0100: 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_017f: 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_03ed: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)player) || ((Character)player).IsDead())
		{
			foreach (ElementData element in m_elements)
			{
				Object.Destroy((Object)(object)element.m_go);
			}
			m_elements.Clear();
			return;
		}
		if (m_elements.Count != CountItems(items) || forceUpdate)
		{
			foreach (ElementData element2 in m_elements)
			{
				Object.Destroy((Object)(object)element2.m_go);
			}
			m_elements.Clear();
			for (int i = 0; i < items.Length; i++)
			{
				if (items[i] != null)
				{
					ElementData val = new ElementData();
					val.m_go = Object.Instantiate<GameObject>(m_elementPrefab, itemsRoot);
					val.m_go.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 0.5f);
					float num = Mathf.Sin((float)i * ANGLE_STEP * ((float)Math.PI / 180f)) * ITEM_DISTANCE;
					float num2 = Mathf.Cos((float)i * ANGLE_STEP * ((float)Math.PI / 180f)) * ITEM_DISTANCE;
					val.m_go.transform.localScale = new Vector3(ITEM_SCALE, ITEM_SCALE, ITEM_SCALE);
					val.m_go.transform.localPosition = new Vector3(num, num2, 0f);
					((TMP_Text)((Component)val.m_go.transform.Find("binding")).GetComponent<TextMeshProUGUI>()).text = (i + 1).ToString();
					val.m_icon = ((Component)((Component)val.m_go.transform).transform.Find("icon")).GetComponent<Image>();
					val.m_durability = ((Component)val.m_go.transform.Find("durability")).GetComponent<GuiBar>();
					val.m_amount = ((Component)val.m_go.transform.Find("amount")).GetComponent<TextMeshProUGUI>();
					val.m_equiped = ((Component)val.m_go.transform.Find("equiped")).gameObject;
					val.m_queued = ((Component)val.m_go.transform.Find("queued")).gameObject;
					val.m_selection = ((Component)val.m_go.transform.Find("selected")).gameObject;
					val.m_selection.SetActive(false);
					if (EquipWheel.InventoryRow.Value > 1 || EquipWheel.ItemFiltering.Value)
					{
						((Behaviour)((Component)val.m_go.transform.Find("binding")).GetComponent<TextMeshProUGUI>()).enabled = false;
					}
					m_elements.Add(val);
				}
			}
		}
		foreach (ElementData element3 in m_elements)
		{
			element3.m_used = false;
		}
		int num3 = 0;
		for (int j = 0; j < items.Length; j++)
		{
			if (items[j] == null)
			{
				continue;
			}
			ItemData val2 = items[j];
			ElementData val3 = m_elements[num3];
			val3.m_used = true;
			((Component)val3.m_icon).gameObject.SetActive(true);
			val3.m_icon.sprite = val2.GetIcon();
			((Component)val3.m_durability).gameObject.SetActive(val2.m_shared.m_useDurability);
			if (val2.m_shared.m_useDurability)
			{
				if (val2.m_durability <= 0f)
				{
					val3.m_durability.SetValue(1f);
					val3.m_durability.SetColor((Color)((Mathf.Sin(Time.time * 10f) > 0f) ? Color.red : new Color(0f, 0f, 0f, 0f)));
				}
				else
				{
					val3.m_durability.SetValue(val2.GetDurabilityPercentage());
					val3.m_durability.ResetColor();
				}
			}
			val3.m_equiped.SetActive(val2.m_equipped);
			val3.m_queued.SetActive(player.IsEquipActionQueued(val2));
			if (val2.m_shared.m_maxStackSize > 1)
			{
				((Component)val3.m_amount).gameObject.SetActive(true);
				((TMP_Text)val3.m_amount).text = val2.m_stack + "/" + val2.m_shared.m_maxStackSize;
			}
			else
			{
				((Component)val3.m_amount).gameObject.SetActive(false);
			}
			if (EpicLootWrapper.instance != null)
			{
				EpicLootWrapper.instance.ModifyElement(val3, val2);
			}
			num3++;
		}
		for (int k = 0; k < m_elements.Count; k++)
		{
			ElementData val4 = m_elements[k];
			if (!val4.m_used)
			{
				((Component)val4.m_icon).gameObject.SetActive(false);
				((Component)val4.m_durability).gameObject.SetActive(false);
				val4.m_equiped.SetActive(false);
				val4.m_queued.SetActive(false);
				((Component)val4.m_amount).gameObject.SetActive(false);
			}
		}
	}
}
public class Patcher
{
	public static readonly KeyCode[] NUMBERS;

	[HarmonyPatch(typeof(Player), "Awake")]
	[HarmonyPostfix]
	public static void Awake_Postfix()
	{
		//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)
		string text = "EquipGui (" + Assembly.GetExecutingAssembly().GetName().Name + ")";
		if (!((Object)(object)Menu.instance == (Object)null) && !Object.op_Implicit((Object)(object)GameObject.Find(text)))
		{
			GameObject val = new GameObject(text);
			EquipWheel.Gui = val.AddComponent<EquipGui>();
			val.transform.SetParent(((Component)Menu.instance).transform.parent, false);
			EquipWheel.Log("Spawned EquipGui!");
		}
	}

	[HarmonyPatch(typeof(HotkeyBar), "Update")]
	[HarmonyPrefix]
	public static bool Prefix(HotkeyBar __instance)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)EquipWheel.Instance == (Object)null)
		{
			return true;
		}
		if (EquipWheel.HotkeyDPad != null && (int)EquipWheel.HotkeyDPad.Value == 0)
		{
			return true;
		}
		Player localPlayer = Player.m_localPlayer;
		if ((Object)(object)localPlayer != (Object)null)
		{
			typeof(HotkeyBar).GetMethod("UpdateIcons", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[1] { localPlayer });
		}
		return false;
	}

	[HarmonyPatch(typeof(Player), "UseHotbarItem")]
	[HarmonyPrefix]
	public static bool UseHotbarItem(int index)
	{
		//IL_000a: 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_0012: Unknown result type (might be due to invalid IL or missing references)
		KeyCode[] nUMBERS = NUMBERS;
		KeyboardShortcut value = EquipWheel.Hotkey.Value;
		bool num = Array.IndexOf(nUMBERS, ((KeyboardShortcut)(ref value)).MainKey) != index - 1;
		bool flag = !EquipWheel.IsShortcutDown;
		if (!(num || flag) && EquipWheel.CanOpenMenu)
		{
			return ZInput.IsGamepadActive();
		}
		return true;
	}

	[HarmonyPatch(typeof(Player), "Update")]
	[HarmonyPostfix]
	public static void Update()
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		Player localPlayer = Player.m_localPlayer;
		if (!((Object)(object)localPlayer == (Object)null) && EquipWheel.UseSitButton.Value && (int)EquipWheel.HotkeyDPad.Value == 0 && (ZInput.GetButtonDown("JoySit") || ZInput.GetButtonUp("JoySit")))
		{
			typeof(Player).GetMethod("StopEmote", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(localPlayer, new object[0]);
		}
	}

	static Patcher()
	{
		KeyCode[] array = new KeyCode[8];
		RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
		NUMBERS = (KeyCode[])(object)array;
	}
}