Decompiled source of EquipWheelRadial v1.0.0

EquipWheelRadial.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EquipWheel;
using HarmonyLib;
using UnityEngine;
using UnityEngine.UI;
using Valheim.UI;

[assembly: AssemblyTitle("EquipWheel")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("EquipWheel")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("9299ddd5-a76a-423e-b5ce-c053e68f6abf")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("1.0.0.0")]
namespace EquipWheel
{
	[BepInPlugin("EquipWheelRadial", "Equip Wheel Radial", "1.0.0")]
	public class EquipWheel : BaseUnityPlugin, WheelManager.IWheel
	{
		private static Harmony harmony;

		public static ManualLogSource MyLogger = Logger.CreateLogSource(typeof(EquipWheel).Namespace);

		public static ConfigEntry<KeyboardShortcut> Hotkey;

		public static ConfigEntry<WheelManager.DPadButton> HotkeyDPad;

		public static ConfigEntry<bool> UseSitButton;

		public static ConfigEntry<bool> EquipWhileRunning;

		public static ConfigEntry<bool> AutoEquipShield;

		public static ConfigEntry<bool> HideHotkeyBar;

		public static ConfigEntry<int> IgnoreJoyStickDuration;

		public static ConfigEntry<bool> UseRarityColoring;

		public static ConfigEntry<bool> TriggerOnRelease;

		public static ConfigEntry<bool> TriggerOnClick;

		public static ConfigEntry<bool> TriggerWithRT;

		public static ConfigEntry<float> IconScale;

		public static ConfigEntry<bool> MoveWhileOpen;

		public static ConfigEntry<bool> ToggleMenu;

		public static ConfigEntry<bool> ModEnabled;

		private const string DefaultHotkey = "H";

		private const int DefaultInventoryRow = 1;

		private const WheelManager.DPadButton DefaultDPad = WheelManager.DPadButton.None;

		private const bool DefaultUseSit = true;

		private const bool DefaultModEnabled = true;

		private const float DefaultIconScale = 1.688f;

		public static ConfigEntry<Color> HighlightColor;

		public static ConfigEntry<float> GuiScale;

		public static ConfigEntry<int> InventoryRow;

		public static ConfigEntry<bool> ItemFiltering;

		public static ConfigEntry<bool> UseAzuQuickSlots;

		public static ConfigEntry<int> AzuQuickSlotsFirst;

		public static ConfigEntry<int> AzuQuickSlotsLast;

		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 EquipRadialGui Gui;

		public static Color GetHighlightColor
		{
			[CompilerGenerated]
			get
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				return HighlightColor.Value;
			}
		}

		public static EquipWheel Instance => instance;

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

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

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

		public static bool IsShortcutDown
		{
			get
			{
				//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_0094: Unknown result type (might be due to invalid IL or missing references)
				//IL_0099: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
				if (ZInput.IsGamepadActive())
				{
					switch (HotkeyDPad.Value)
					{
					case WheelManager.DPadButton.None:
						if (UseSitButton.Value)
						{
							return ZInput.GetButtonDown("JoySit");
						}
						return ZInput.GetButtonDown("JoyUse");
					case WheelManager.DPadButton.Left:
						return DPadLeftDown();
					case WheelManager.DPadButton.Right:
						return DPadRightDown();
					case WheelManager.DPadButton.LeftOrRight:
						return DPadRightDown() || DPadLeftDown();
					default:
						return DPadRightDown() || DPadLeftDown();
					}
				}
				KeyboardShortcut value = Hotkey.Value;
				KeyCode mainKey = ((KeyboardShortcut)(ref value)).MainKey;
				KeyCode[] source = ((KeyboardShortcut)(ref value)).Modifiers.ToArray();
				return Input.GetKeyDown(mainKey) || ((IEnumerable<KeyCode>)source).Any((Func<KeyCode, bool>)Input.GetKeyDown);
			}
		}

		public static bool IsShortcutUp
		{
			get
			{
				//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_0094: Unknown result type (might be due to invalid IL or missing references)
				//IL_0099: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
				if (ZInput.IsGamepadActive())
				{
					switch (HotkeyDPad.Value)
					{
					case WheelManager.DPadButton.None:
						if (UseSitButton.Value)
						{
							return ZInput.GetButtonUp("JoySit");
						}
						return ZInput.GetButtonUp("JoyUse");
					case WheelManager.DPadButton.Left:
						return DPadLeftUp();
					case WheelManager.DPadButton.Right:
						return DPadRightUp();
					case WheelManager.DPadButton.LeftOrRight:
						return DPadRightUp() || DPadLeftUp();
					default:
						return DPadRightUp() || DPadLeftUp();
					}
				}
				KeyboardShortcut value = Hotkey.Value;
				KeyCode mainKey = ((KeyboardShortcut)(ref value)).MainKey;
				KeyCode[] source = ((KeyboardShortcut)(ref value)).Modifiers.ToArray();
				return Input.GetKeyUp(mainKey) || ((IEnumerable<KeyCode>)source).Any((Func<KeyCode, bool>)Input.GetKeyUp);
			}
		}

		public static bool IsShortcutPressed
		{
			get
			{
				//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_0094: Unknown result type (might be due to invalid IL or missing references)
				//IL_0099: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
				if (ZInput.IsGamepadActive())
				{
					switch (HotkeyDPad.Value)
					{
					case WheelManager.DPadButton.None:
						if (UseSitButton.Value)
						{
							return ZInput.GetButton("JoySit");
						}
						return ZInput.GetButton("JoyUse");
					case WheelManager.DPadButton.Left:
						return DPadLeftHeld();
					case WheelManager.DPadButton.Right:
						return DPadRightHeld();
					case WheelManager.DPadButton.LeftOrRight:
						return DPadRightHeld() || DPadLeftHeld();
					default:
						return DPadRightHeld() || DPadLeftHeld();
					}
				}
				KeyboardShortcut value = Hotkey.Value;
				KeyCode mainKey = ((KeyboardShortcut)(ref value)).MainKey;
				KeyCode[] source = ((KeyboardShortcut)(ref value)).Modifiers.ToArray();
				return Input.GetKey(mainKey) || ((IEnumerable<KeyCode>)source).Any((Func<KeyCode, bool>)Input.GetKey);
			}
		}

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

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

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

		private static bool TakeInput(bool look = false)
		{
			return !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) && (!PlayerCustomizaton.BarberBlocksLook() || !look);
		}

		private static bool InInventoryEtc()
		{
			return Minimap.IsOpen() || StoreGui.IsVisible() || Hud.IsPieceSelectionVisible();
		}

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

		public static bool IsUsingUseButton()
		{
			return ZInput.IsGamepadActive() && HotkeyDPad.Value == WheelManager.DPadButton.None && !UseSitButton.Value;
		}

		public void Awake()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Expected O, but got Unknown
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Expected O, but got Unknown
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Expected O, but got Unknown
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Expected O, but got Unknown
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: 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("H"), "Hotkey for opening equip wheel menu");
			HotkeyDPad = ((BaseUnityPlugin)this).Config.Bind<WheelManager.DPadButton>("Input", "HotkeyDPad", WheelManager.DPadButton.None, "Hotkey on the D-Pad (None, Left, Right or LeftOrRight)");
			UseSitButton = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "UseSitButton", true, "When enabled use the sit button as hotkey (HotkeyDPad has to be set to None)");
			TriggerOnRelease = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "TriggerOnRelease", false, "Releasing the Hotkey will equip/use the selected item");
			TriggerOnClick = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "TriggerOnClick", true, "Click with left mouse button will equip/use the selected item");
			IconScale = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "IconScale", 1.688f, new ConfigDescription("Size multiplier of ALL item icons in the wheel (1 = game default size, 1.5 = 50% bigger).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 3f), Array.Empty<object>()));
			TriggerWithRT = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "TriggerWithRT", true, "Gamepad: pressing RT (right trigger) equips/uses the selected item while the wheel is open");
			MoveWhileOpen = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "MoveWhileOpen", true, "The player can keep moving (left stick / WASD) while the wheel is open. On gamepad the wheel is then aimed with the right stick");
			ToggleMenu = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "ToggleMenu", true, "When enabled the equip wheel will toggle between hidden/visible when the hotkey was pressed");
			HighlightColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Appereance", "HighlightColor", Color32.op_Implicit(new Color32((byte)106, (byte)187, byte.MaxValue, byte.MaxValue)), "Color of the highlighted selection");
			GuiScale = ((BaseUnityPlugin)this).Config.Bind<float>("Appereance", "GuiScale", 0.6f, "Scale factor of the user interface");
			HideHotkeyBar = ((BaseUnityPlugin)this).Config.Bind<bool>("Appereance", "HideHotkeyBar", false, "Hides the top-left Hotkey Bar");
			EquipWhileRunning = ((BaseUnityPlugin)this).Config.Bind<bool>("Misc", "EquipWhileRunning", true, "Allow to equip weapons while running");
			AutoEquipShield = ((BaseUnityPlugin)this).Config.Bind<bool>("Misc", "AutoEquipShield", true, "Enable auto equip of shield when one-handed weapon was equipped");
			HideHotkeyBar.SettingChanged += delegate
			{
				if (!((Object)(object)Hud.instance == (Object)null))
				{
					HotkeyBar component = ((Component)((Component)Hud.instance).transform.Find("hudroot/HotKeyBar")).GetComponent<HotkeyBar>();
					if (!((Object)(object)component == (Object)null))
					{
						((Component)component).gameObject.SetActive(!HideHotkeyBar.Value);
					}
				}
			};
			IgnoreJoyStickDuration = ((BaseUnityPlugin)this).Config.Bind<int>("Input", "IgnoreJoyStickDuration", 0, new ConfigDescription("Duration in milliseconds for ignoring left joystick input after button release", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 2000), Array.Empty<object>()));
			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), Array.Empty<object>()));
			UseAzuQuickSlots = ((BaseUnityPlugin)this).Config.Bind<bool>("AzuEPI", "UseAzuQuickSlots", false, "Use the quick slots of the AzuEPI mod (Azu Extended Player Inventory, up to 8) as the content of this wheel. Takes priority over InventoryRow and ItemFiltering. Requires AzuEPI to be installed.");
			AzuQuickSlotsFirst = ((BaseUnityPlugin)this).Config.Bind<int>("AzuEPI", "FirstQuickSlot", 1, new ConfigDescription("First AzuEPI quick slot shown in this wheel (1-8). Lets you split the 8 quick slots between wheels, e.g. 1 to 4 here and 5 to 8 in another wheel.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 8), Array.Empty<object>()));
			AzuQuickSlotsLast = ((BaseUnityPlugin)this).Config.Bind<int>("AzuEPI", "LastQuickSlot", 8, new ConfigDescription("Last AzuEPI quick slot shown in this wheel (1-8).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 8), Array.Empty<object>()));
			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 (IsDedicated())
			{
				LogWarn("Mod not loaded because game instance is a dedicated server.");
				return;
			}
			harmony = Harmony.CreateAndPatchAll(typeof(Patcher), (string)null);
			harmony.PatchAll(typeof(RadialBase_Close_Patch));
			harmony.PatchAll(typeof(Player_SetControls_Patch));
			harmony.PatchAll(typeof(Player_CheckKeyboardRadialPressed_Patch));
			WheelManager.AddWheel(this);
			try
			{
				EpicLootWrapper.CreateInstance();
				UseRarityColoring = ((BaseUnityPlugin)this).Config.Bind<bool>("Appereance", "UseRarityColoring", true, "When enabled, the highlight color will be set to the rarity color of the selected item.");
				Log("Epicloot Mod installed. Applied compatibility patch.");
			}
			catch (Exception ex)
			{
				LogErr(ex.Message);
				LogErr("Failed to initialize EpicLootWrapper. Probably a compatibility issue. Please inform the mod creator of EquipWheel about this issue! (https://www.nexusmods.com/valheim/mods/536)");
			}
			Log(((object)this).GetType().Namespace + " Loaded!");
		}

		private void OnDestroy()
		{
			WheelManager.RemoveWheel(this);
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		public static void TryHideHotkeyBar()
		{
			HotkeyBar component = ((Component)((Component)Hud.instance).transform.Find("hudroot/HotKeyBar")).GetComponent<HotkeyBar>();
			if (!((Object)(object)component == (Object)null))
			{
				((Component)component).gameObject.SetActive(!HideHotkeyBar.Value);
			}
		}

		private static bool DPadLeftDown()
		{
			return ZInput.GetButtonDown("JoyHotbarLeft") || ZInput.GetButtonDown("JoyDPadLeft");
		}

		private static bool DPadRightDown()
		{
			return ZInput.GetButtonDown("JoyHotbarRight") || ZInput.GetButtonDown("JoyDPadRight");
		}

		private static bool DPadLeftUp()
		{
			return ZInput.GetButtonUp("JoyHotbarLeft") || ZInput.GetButtonUp("JoyDPadLeft");
		}

		private static bool DPadRightUp()
		{
			return ZInput.GetButtonUp("JoyHotbarRight") || ZInput.GetButtonUp("JoyDPadRight");
		}

		private static bool DPadLeftHeld()
		{
			return ZInput.GetButton("JoyHotbarLeft") || ZInput.GetButton("JoyDPadLeft");
		}

		private static bool DPadRightHeld()
		{
			return ZInput.GetButton("JoyHotbarRight") || ZInput.GetButton("JoyDPadRight");
		}

		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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			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.GetKeyDown(mainKey) : Input.GetKey(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 EquipRadialGui.visible;
		}

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

		public string GetName()
		{
			return typeof(EquipWheel).Namespace;
		}

		float WheelManager.IWheel.JoyStickIgnoreTime()
		{
			return JoyStickIgnoreTime;
		}
	}
	public class Patcher
	{
		public static readonly KeyCode[] NUMBERS;

		[HarmonyPatch(typeof(InventoryGui), "IsVisible")]
		[HarmonyPostfix]
		public static void IsVisible_Postfix(ref bool __result)
		{
			WheelManager.inventoryVisible = __result;
			__result = __result || (!EquipWheel.MoveWhileOpen.Value && WheelManager.AnyVisible);
		}

		[HarmonyPatch(typeof(Hud), "UpdateCrosshair")]
		[HarmonyPostfix]
		public static void IsVisible_Postfix(Hud __instance, Player player, float bowDrawPercentage)
		{
			GameObject hoverObject = ((Humanoid)player).GetHoverObject();
			Interactable val = ((!Object.op_Implicit((Object)(object)hoverObject)) ? null : hoverObject.GetComponentInParent<Interactable>());
			if (val != null && !TextViewer.instance.IsVisible())
			{
				WheelManager.hoverTextVisible = true;
			}
			else
			{
				WheelManager.hoverTextVisible = false;
			}
		}

		[HarmonyPatch(typeof(Humanoid), "UseItem")]
		[HarmonyPostfix]
		public static void UseItem_Postfix(Humanoid __instance, Inventory inventory, ItemData item, bool fromInventoryGui)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Invalid comparison between Unknown and I4
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Invalid comparison between Unknown and I4
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Invalid comparison between Unknown and I4
			if (!EquipWheel.AutoEquipShield.Value || ((object)__instance).GetType() != typeof(Player) || fromInventoryGui)
			{
				return;
			}
			MethodInfo method = typeof(Humanoid).GetMethod("GetLeftItem", BindingFlags.Instance | BindingFlags.NonPublic);
			ItemData val = (ItemData)method.Invoke(__instance, new object[0]);
			if ((val != null && (int)val.m_shared.m_itemType == 5) || !((Player)__instance).IsEquipActionQueued(item) || item.m_equipped || (int)item.m_shared.m_itemType != 3)
			{
				return;
			}
			List<ItemData> allItems = __instance.GetInventory().GetAllItems();
			int num = -1;
			int num2 = -1;
			ItemData val2 = null;
			foreach (ItemData item2 in allItems)
			{
				if (item2 != null && (int)item2.m_shared.m_itemType == 5 && (val2 == null || item2.m_gridPos.y < num2 || (item2.m_gridPos.y == num2 && item2.m_gridPos.x < num)))
				{
					val2 = item2;
					num = val2.m_gridPos.x;
					num2 = val2.m_gridPos.y;
				}
			}
			if (val2 != null)
			{
				__instance.UseItem((Inventory)null, val2, false);
			}
		}

		[HarmonyPatch(typeof(ZInput), "GetJoyRightStickX")]
		[HarmonyPostfix]
		public static void GetJoyRightStickX_Postfix(ref float __result)
		{
			if (WheelManager.GetJoyStickIgnoreTime() > 0f)
			{
				__result = 0f;
			}
		}

		[HarmonyPatch(typeof(ZInput), "GetJoyRightStickY")]
		[HarmonyPostfix]
		public static void GetJoyRightStickY_Postfix(ref float __result)
		{
			if (WheelManager.GetJoyStickIgnoreTime() > 0f)
			{
				__result = 0f;
			}
		}

		[HarmonyPatch(typeof(ZInput), "GetJoyLeftStickX")]
		[HarmonyPostfix]
		public static void GetJoyLeftStickX_Postfix(ref float __result)
		{
			if (WheelManager.GetJoyStickIgnoreTime() > 0f)
			{
				__result = 0f;
			}
		}

		[HarmonyPatch(typeof(ZInput), "GetJoyLeftStickY")]
		[HarmonyPostfix]
		public static void GetJoyLeftStickY_Postfix(ref float __result)
		{
			if (WheelManager.GetJoyStickIgnoreTime() > 0f)
			{
				__result = 0f;
			}
		}

		[HarmonyPatch(typeof(HotkeyBar), "Update")]
		[HarmonyPostfix]
		public static void Update_Postfix(HotkeyBar __instance)
		{
			if (EquipWheel.HideHotkeyBar.Value)
			{
				((Component)__instance).gameObject.SetActive(false);
			}
		}

		[HarmonyPatch(typeof(Player), "ClearActionQueue")]
		[HarmonyPrefix]
		public static bool Prefix(Player __instance)
		{
			return !(bool)typeof(Player).GetField("m_run", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance) || !EquipWheel.EquipWhileRunning.Value;
		}

		[HarmonyPatch(typeof(Hud), "Awake")]
		[HarmonyPostfix]
		public static void Hud_Awake_Postfix(Hud __instance)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			string text = "EquipGui (" + typeof(EquipWheel).Namespace + ")";
			if (!Object.op_Implicit((Object)(object)GameObject.Find(text)))
			{
				GameObject val = new GameObject(text);
				EquipWheel.Gui = val.AddComponent<EquipRadialGui>();
				val.transform.SetParent(((Component)__instance).transform, false);
				EquipWheel.Log("Spawned EquipGui under HUD!");
			}
		}

		[HarmonyPatch(typeof(HotkeyBar), "Update")]
		[HarmonyPrefix]
		public static bool Prefix(HotkeyBar __instance)
		{
			if ((Object)(object)EquipWheel.Instance == (Object)null)
			{
				return true;
			}
			if (EquipWheel.HotkeyDPad != null && EquipWheel.HotkeyDPad.Value == WheelManager.DPadButton.None)
			{
				return true;
			}
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer != (Object)null)
			{
				MethodInfo method = typeof(HotkeyBar).GetMethod("UpdateIcons", BindingFlags.Instance | BindingFlags.NonPublic);
				method.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 flag = Array.IndexOf(nUMBERS, ((KeyboardShortcut)(ref value)).MainKey) != index - 1;
			bool flag2 = !EquipWheel.IsShortcutDown;
			return flag || flag2 || !EquipWheel.CanOpenMenu || ZInput.IsGamepadActive();
		}

		[HarmonyPatch(typeof(Player), "Update")]
		[HarmonyPostfix]
		public static void Update()
		{
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer == (Object)null) && EquipWheel.UseSitButton.Value && EquipWheel.HotkeyDPad.Value == WheelManager.DPadButton.None && (ZInput.GetButtonDown("JoySit") || ZInput.GetButtonUp("JoySit")))
			{
				MethodInfo method = typeof(Player).GetMethod("StopEmote", BindingFlags.Instance | BindingFlags.NonPublic);
				method.Invoke(localPlayer, new object[0]);
			}
		}

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

		private static PropertyInfo gridPosProperty;

		private static bool missingLogged = false;

		private static bool Resolve()
		{
			if (getSnapshots != null)
			{
				return true;
			}
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly assembly in assemblies)
			{
				Type type = null;
				try
				{
					type = assembly.GetType("AzuEPI.API", throwOnError: false);
				}
				catch (Exception)
				{
				}
				if (type == null)
				{
					continue;
				}
				try
				{
					MethodInfo methodInfo = AccessTools.Method(type, "IsLoaded", (Type[])null, (Type[])null);
					if (methodInfo != null && !(bool)methodInfo.Invoke(null, null))
					{
						continue;
					}
				}
				catch (Exception)
				{
					continue;
				}
				getSnapshots = AccessTools.Method(type, "GetQuickSlotSnapshots", new Type[1] { typeof(Inventory) }, (Type[])null);
				if (!(getSnapshots != null))
				{
					continue;
				}
				break;
			}
			if (getSnapshots == null && !missingLogged)
			{
				missingLogged = true;
				EquipWheel.LogWarn("UseAzuQuickSlots is enabled but the AzuEPI API was not found (is AzuEPI installed and up to date?)");
			}
			return getSnapshots != null;
		}

		public static ItemData[] Collect(Inventory inventory, int max)
		{
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			ItemData[] array = (ItemData[])(object)new ItemData[max];
			if (inventory == null || !Resolve())
			{
				return array;
			}
			IEnumerable enumerable;
			try
			{
				enumerable = getSnapshots.Invoke(null, new object[1] { inventory }) as IEnumerable;
			}
			catch (Exception ex)
			{
				EquipWheel.LogErr("AzuEPI quick slots could not be read: " + ex.Message);
				return array;
			}
			if (enumerable == null)
			{
				return array;
			}
			int num = Mathf.Clamp(EquipWheel.AzuQuickSlotsFirst.Value, 1, max);
			int num2 = Mathf.Clamp(EquipWheel.AzuQuickSlotsLast.Value, 1, max);
			int num3 = 0;
			foreach (object item in enumerable)
			{
				num3++;
				if (num3 >= num && num3 <= num2 && num3 <= max)
				{
					if (gridPosProperty == null)
					{
						gridPosProperty = AccessTools.Property(item.GetType(), "GridPos");
					}
					if (!(gridPosProperty == null))
					{
						Vector2i val = (Vector2i)gridPosProperty.GetValue(item, null);
						array[num3 - 1] = inventory.GetItemAt(val.x, val.y);
					}
				}
			}
			return array;
		}
	}
	public static class WheelItems
	{
		public const int MaxItems = 8;

		public static ItemData[] Collect()
		{
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Expected I4, but got Unknown
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Expected I4, but got Unknown
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Expected I4, but got Unknown
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Expected I4, but got Unknown
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Expected I4, but got Unknown
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Expected I4, but got Unknown
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: 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_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			ItemData[] array = (ItemData[])(object)new ItemData[8];
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return array;
			}
			Inventory inventory = ((Humanoid)localPlayer).GetInventory();
			if (inventory == null)
			{
				return array;
			}
			if (EquipWheel.UseAzuQuickSlots.Value)
			{
				return AzuQuickSlots.Collect(inventory, 8);
			}
			if (EquipWheel.ItemFiltering.Value)
			{
				List<ItemData> list = new List<ItemData>();
				List<ItemData> list2 = new List<ItemData>();
				Regex regex = BuildRegex(EquipWheel.ItemRegexIgnore.Value);
				Regex regex2 = BuildRegex(EquipWheel.ItemRegex.Value);
				foreach (ItemData allItem in inventory.GetAllItems())
				{
					if (regex != null && regex.IsMatch(NameOf(allItem)))
					{
						continue;
					}
					if (regex2 != null && regex2.IsMatch(NameOf(allItem)))
					{
						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 num = 0; num < 8; num++)
				{
					if (list.Count > num)
					{
						array[num] = list[num];
					}
					else if (list2.Count > num - list.Count)
					{
						array[num] = list2[num - list.Count];
					}
				}
				return array;
			}
			for (int num2 = 0; num2 < 8; num2++)
			{
				array[num2] = inventory.GetItemAt(num2, EquipWheel.InventoryRow.Value - 1);
			}
			return array;
		}

		private static Regex BuildRegex(string pattern)
		{
			if (string.IsNullOrEmpty(pattern))
			{
				return null;
			}
			return new Regex(pattern, (!EquipWheel.ItemRegexCaseSensitive.Value) ? RegexOptions.IgnoreCase : RegexOptions.None);
		}

		private static string NameOf(ItemData item)
		{
			//IL_0010: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			if (EpicLootWrapper.instance != null)
			{
				Color itemColor = EpicLootWrapper.instance.GetItemColor(item);
				return Localization.instance.Localize(EpicLootWrapper.instance.GetItemName(item, itemColor));
			}
			return Localization.instance.Localize(item.m_shared.m_name);
		}
	}
	internal static class RadialAccess
	{
		private const BindingFlags Any = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

		private static readonly FieldInfo FLocalPlayerRef = AccessTools.Field(typeof(RadialBase), "m_localPlayerRef");

		private static readonly FieldInfo FElements = AccessTools.Field(typeof(RadialBase), "m_elements");

		private static readonly FieldInfo FElementInfo = AccessTools.Field(typeof(RadialBase), "m_elementInfo");

		private static readonly FieldInfo FSelected = AccessTools.Field(typeof(RadialBase), "m_selected");

		private static readonly MethodInfo MResetAll = AccessTools.Method(typeof(RadialBase), "ResetAllVariables", (Type[])null, (Type[])null);

		private static readonly MethodInfo MLoadSettings = AccessTools.Method(typeof(RadialBase), "LoadSettings", (Type[])null, (Type[])null);

		private static readonly MethodInfo MStartAnimIn = AccessTools.Method(typeof(RadialBase), "StartAnimatingIn", (Type[])null, (Type[])null);

		private static readonly MethodInfo MOnInteract = AccessTools.Method(typeof(RadialBase), "OnInteract", (Type[])null, (Type[])null);

		private static readonly MethodInfo MInstantClose = AccessTools.Method(typeof(RadialBase), "InstantClose", (Type[])null, (Type[])null);

		private static readonly MethodInfo MConstruct = AccessTools.Method(typeof(RadialBase), "ConstructRadial", (Type[])null, (Type[])null);

		private static readonly MethodInfo SetCurrentConfig = AccessTools.PropertySetter(typeof(RadialBase), "CurrentConfig");

		private static readonly MethodInfo SetActive = AccessTools.PropertySetter(typeof(RadialBase), "Active");

		private static readonly MethodInfo SetCanOpen = AccessTools.PropertySetter(typeof(RadialBase), "CanOpen");

		private static readonly MethodInfo SetShouldAnimateIn = AccessTools.PropertySetter(typeof(RadialBase), "ShouldAnimateIn");

		private static readonly MethodInfo SetSubTitle = AccessTools.PropertySetter(typeof(RadialMenuElement), "SubTitle");

		public static void Invoke(MethodInfo m, object target, params object[] args)
		{
			if (m == null)
			{
				EquipWheel.LogErr("Radial API member missing (game version changed?)");
			}
			else
			{
				m.Invoke(target, args);
			}
		}

		public static void SetLocalPlayer(RadialBase r, Player p)
		{
			if (FLocalPlayerRef != null)
			{
				FLocalPlayerRef.SetValue(r, p);
			}
		}

		public static void ResetAllVariables(RadialBase r)
		{
			Invoke(MResetAll, r);
		}

		public static void EnsureReady(RadialBase r)
		{
			if ((Object)(object)RadialData.SO == (Object)null)
			{
				MethodInfo methodInfo = AccessTools.Method(typeof(RadialData), "Init", (Type[])null, (Type[])null);
				RadialDataSO val = null;
				RadialDataInitializer[] array = Resources.FindObjectsOfTypeAll<RadialDataInitializer>();
				foreach (RadialDataInitializer val2 in array)
				{
					RadialDataSO value = Traverse.Create((object)val2).Field("_dataObject").GetValue<RadialDataSO>();
					if ((Object)(object)value != (Object)null)
					{
						val = value;
						break;
					}
				}
				if ((Object)(object)val == (Object)null)
				{
					RadialDataSO[] array2 = Resources.FindObjectsOfTypeAll<RadialDataSO>();
					int num = 0;
					if (num < array2.Length)
					{
						RadialDataSO val3 = array2[num];
						val = val3;
					}
				}
				if ((Object)(object)val != (Object)null && methodInfo != null)
				{
					methodInfo.Invoke(null, new object[1] { val });
				}
				else
				{
					EquipWheel.LogWarn("RadialData.SO is null and no RadialDataInitializer was found");
				}
			}
			string value2 = Traverse.Create((object)r).Field("m_cursorID").GetValue<string>();
			if (string.IsNullOrEmpty(value2) && (Object)(object)RadialData.SO != (Object)null && !((Component)r).gameObject.activeSelf)
			{
				((Component)r).gameObject.SetActive(true);
			}
		}

		public static void EndAnimations(RadialBase r)
		{
			FieldInfo fieldInfo = AccessTools.Field(typeof(RadialBase), "m_animationManager");
			object obj = ((!(fieldInfo != null)) ? null : fieldInfo.GetValue(r));
			if (obj == null)
			{
				return;
			}
			try
			{
				Traverse.Create(obj).Method("EndAll", Array.Empty<object>()).GetValue();
			}
			catch (Exception ex)
			{
				EquipWheel.LogWarn("EndAll failed: " + ex.Message);
			}
		}

		public static void LoadSettings(RadialBase r)
		{
			Invoke(MLoadSettings, r);
		}

		public static void StartAnimatingIn(RadialBase r)
		{
			Invoke(MStartAnimIn, r);
		}

		public static void OnInteract(RadialBase r)
		{
			Invoke(MOnInteract, r);
		}

		public static void InstantClose(RadialBase r)
		{
			Invoke(MInstantClose, r);
		}

		public static void ConstructRadial(RadialBase r, List<RadialMenuElement> list)
		{
			Invoke(MConstruct, r, list);
		}

		public static void SetConfig(RadialBase r, IRadialConfig c)
		{
			Invoke(SetCurrentConfig, r, c);
		}

		public static void SetIsActive(RadialBase r, bool v)
		{
			Invoke(SetActive, r, v);
		}

		public static void SetIsCanOpen(RadialBase r, bool v)
		{
			Invoke(SetCanOpen, r, v);
		}

		public static void SetIsShouldAnimateIn(RadialBase r, bool v)
		{
			Invoke(SetShouldAnimateIn, r, v);
		}

		public static void SetElementSubTitle(RadialMenuElement e, string v)
		{
			Invoke(SetSubTitle, e, v);
		}

		public static int ElementCount(RadialBase r)
		{
			return Elements(r).Count;
		}

		public static List<RadialMenuElement> Elements(RadialBase r)
		{
			List<RadialMenuElement> list = new List<RadialMenuElement>();
			object obj = ((!(FElements != null)) ? null : FElements.GetValue(r));
			if (obj == null)
			{
				return list;
			}
			Traverse val = Traverse.Create(obj);
			IEnumerable enumerable = null;
			try
			{
				enumerable = val.Property("GetAsList", (object[])null).GetValue() as IEnumerable;
			}
			catch (Exception)
			{
			}
			if (enumerable == null)
			{
				try
				{
					enumerable = val.Property("GetArray", (object[])null).GetValue() as IEnumerable;
				}
				catch (Exception)
				{
				}
			}
			if (enumerable == null)
			{
				return list;
			}
			foreach (object item in enumerable)
			{
				RadialMenuElement val2 = (RadialMenuElement)((item is RadialMenuElement) ? item : null);
				if ((Object)(object)val2 != (Object)null)
				{
					list.Add(val2);
				}
			}
			return list;
		}

		public static RadialMenuElement Selected(RadialBase r)
		{
			return (RadialMenuElement)((!(FSelected != null)) ? null : /*isinst with value type is only supported in some contexts*/);
		}

		public static void ShowElementInfoNoAnimation(RadialBase r)
		{
			object obj = ((!(FElementInfo != null)) ? null : FElementInfo.GetValue(r));
			if (obj != null)
			{
				Traverse val = Traverse.Create(obj);
				val.Property("Alpha", (object[])null).SetValue((object)1f);
				object value = val.Field("m_inventoryInfo").GetValue();
				if (value != null)
				{
					Traverse.Create(value).Method("SetAlpha", new object[1] { 1f }).GetValue();
				}
				val.Property("Radius", (object[])null).SetValue((object)RadialData.SO.ElementInfoRadius);
			}
		}
	}
	public class EquipWheelRadialConfig : ScriptableObject, IRadialConfig
	{
		public string LocalizedName => "Equip Wheel";

		public Sprite Sprite => null;

		public bool HasItems()
		{
			ItemData[] array = WheelItems.Collect();
			foreach (ItemData val in array)
			{
				if (val != null)
				{
					return true;
				}
			}
			return false;
		}

		public void InitRadialConfig(RadialBase radial)
		{
			List<RadialMenuElement> list = new List<RadialMenuElement>();
			ItemData[] array = WheelItems.Collect();
			for (int i = 0; i < array.Length; i++)
			{
				ItemData val = array[i];
				if (val != null)
				{
					ItemElement val2 = Object.Instantiate<ItemElement>(RadialData.SO.ItemElement);
					val2.Init(val);
					((RadialMenuElement)val2).CloseOnInteract = () => true;
					((RadialMenuElement)val2).AdvancedCloseOnInteract = null;
					RadialAccess.SetElementSubTitle((RadialMenuElement)(object)val2, (i + 1).ToString());
					list.Add((RadialMenuElement)(object)val2);
				}
			}
			if (list.Count == 0)
			{
				RadialData.SO.HotbarGroupConfig.InitRadialConfig(radial);
				RadialAccess.SetConfig(radial, (IRadialConfig)(object)RadialData.SO.HotbarGroupConfig);
			}
			else
			{
				RadialAccess.ConstructRadial(radial, list);
			}
		}
	}
	public class EquipRadialGui : MonoBehaviour
	{
		public static bool visible = false;

		public static bool toggleDownWasPressed = false;

		public int toggleVisible = 0;

		private static bool pcRadialOpen = false;

		private static EquipWheelRadialConfig activeConfig;

		private static bool closeRequested = false;

		private static Func<bool> originalGetClose;

		private static Func<bool> originalGetBack;

		private static Func<bool> originalGetConfirm;

		private static Func<Vector2> originalGetControllerDirection;

		private static bool rtWasDown = false;

		public static bool suppressAttack = false;

		private bool blockReopen = false;

		private bool scaleErrorLogged = false;

		private static float lastEmptyNotice = -10f;

		private static RadialBase Radial => (!((Object)(object)Hud.instance != (Object)null)) ? null : Hud.instance.m_radialMenu;

		private void Awake()
		{
			visible = false;
			toggleDownWasPressed = false;
		}

		private void Update()
		{
			RadialBase radial = Radial;
			if (visible && ((Object)(object)radial == (Object)null || !radial.Active || !pcRadialOpen))
			{
				visible = false;
				toggleVisible = 0;
				blockReopen = EquipWheel.IsShortcutPressed;
			}
			HandleRightTrigger();
			if (EquipWheel.ToggleMenu.Value)
			{
				HandleToggleEnabled();
			}
			else
			{
				HandleToggleDisabled();
			}
		}

		private void LateUpdate()
		{
			if (!visible || !pcRadialOpen)
			{
				return;
			}
			try
			{
				ApplyIconScale();
			}
			catch (Exception ex)
			{
				if (!scaleErrorLogged)
				{
					scaleErrorLogged = true;
					EquipWheel.LogErr("Icon scale failed: " + ex);
				}
			}
		}

		private void ApplyIconScale()
		{
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			RadialBase radial = Radial;
			if ((Object)(object)radial == (Object)null || !radial.Active)
			{
				return;
			}
			float num = ((EquipWheel.IconScale == null) ? 1f : EquipWheel.IconScale.Value);
			float num2 = 1f - Mathf.Exp(-14f * Time.unscaledDeltaTime);
			foreach (RadialMenuElement item in RadialAccess.Elements(radial))
			{
				if (!((Object)(object)item == (Object)null))
				{
					Image icon = item.Icon;
					if (!((Object)(object)icon == (Object)null))
					{
						RectTransform rectTransform = ((Graphic)icon).rectTransform;
						float x = ((Transform)rectTransform).localScale.x;
						float num3 = ((!(Mathf.Abs(x - num) < 0.002f)) ? Mathf.Lerp(x, num, num2) : num);
						((Transform)rectTransform).localScale = new Vector3(num3, num3, 1f);
					}
				}
			}
		}

		private static void NotifyEmpty()
		{
			if (Time.time - lastEmptyNotice < 2f)
			{
				return;
			}
			lastEmptyNotice = Time.time;
			string text = (EquipWheel.UseAzuQuickSlots.Value ? ("aucun quickslot AzuEPI rempli dans la plage " + EquipWheel.AzuQuickSlotsFirst.Value + "-" + EquipWheel.AzuQuickSlotsLast.Value + " (ou AzuEPI absent)") : ((!EquipWheel.ItemFiltering.Value) ? ("ligne " + EquipWheel.InventoryRow.Value + " de l'inventaire vide") : "aucun objet ne correspond au filtre (ItemType / ItemRegex)"));
			EquipWheel.Log("Wheel not opened: " + text);
			try
			{
				if ((Object)(object)MessageHud.instance != (Object)null)
				{
					MessageHud.instance.ShowMessage((MessageType)1, "EquipWheel (" + typeof(EquipWheel).Namespace + ") : roue vide - " + text, 0, (Sprite)null, false, true);
				}
			}
			catch (Exception)
			{
			}
		}

		private void Show()
		{
			try
			{
				ShowInternal();
			}
			catch (Exception ex)
			{
				visible = false;
				toggleVisible = 0;
				if ((Object)(object)Radial != (Object)null)
				{
					RestoreDelegatesOnly(Radial);
				}
				EquipWheel.LogErr("Failed to open the wheel: " + ex);
			}
		}

		private void ShowInternal()
		{
			RadialBase radial = Radial;
			if ((Object)(object)radial == (Object)null)
			{
				EquipWheel.LogWarn("Cannot open wheel: Hud.m_radialMenu is null");
			}
			else
			{
				if ((Object)(object)Player.m_localPlayer == (Object)null)
				{
					return;
				}
				EquipWheelRadialConfig equipWheelRadialConfig = ScriptableObject.CreateInstance<EquipWheelRadialConfig>();
				if (!equipWheelRadialConfig.HasItems())
				{
					if (EquipWheel.IsShortcutDown)
					{
						NotifyEmpty();
					}
					Object.Destroy((Object)(object)equipWheelRadialConfig);
					return;
				}
				if ((Object)(object)activeConfig != (Object)null)
				{
					Object.Destroy((Object)(object)activeConfig);
				}
				activeConfig = equipWheelRadialConfig;
				OpenPcRadial(radial, equipWheelRadialConfig);
				if (!pcRadialOpen)
				{
					EquipWheel.LogWarn("The game's radial did not open (Open returned without activating it)");
					Object.Destroy((Object)(object)equipWheelRadialConfig);
					activeConfig = null;
				}
				else
				{
					visible = true;
					WheelManager.Activate(EquipWheel.Instance);
				}
			}
		}

		public void Hide()
		{
			if (visible)
			{
				RadialBase radial = Radial;
				if ((Object)(object)radial != (Object)null && pcRadialOpen)
				{
					closeRequested = true;
					RadialAccess.InstantClose(radial);
					RestorePcRadial(radial);
				}
			}
			visible = false;
			toggleVisible = 0;
		}

		private static void OpenPcRadial(RadialBase radial, EquipWheelRadialConfig config)
		{
			RadialAccess.EnsureReady(radial);
			RadialAccess.SetLocalPlayer(radial, Player.m_localPlayer);
			RadialAccess.EndAnimations(radial);
			RadialAccess.ResetAllVariables(radial);
			RadialAccess.LoadSettings(radial);
			HijackDelegates(radial);
			RadialAccess.SetIsCanOpen(radial, v: true);
			RadialAccess.SetIsShouldAnimateIn(radial, v: true);
			radial.Open((IRadialConfig)(object)config, (IRadialConfig)null);
			if (!radial.Active)
			{
				config.InitRadialConfig(radial);
				RadialAccess.SetConfig(radial, (IRadialConfig)(object)config);
				RadialAccess.SetIsActive(radial, v: true);
				if (RadialData.SO.EnableToggleAnimation && RadialAccess.ElementCount(radial) > 0)
				{
					RadialAccess.StartAnimatingIn(radial);
				}
				else
				{
					RadialAccess.ShowElementInfoNoAnimation(radial);
				}
			}
			pcRadialOpen = radial.Active;
			if (!pcRadialOpen)
			{
				RestoreDelegatesOnly(radial);
			}
		}

		private static void HijackDelegates(RadialBase radial)
		{
			if (originalGetClose == null)
			{
				originalGetClose = radial.GetClose;
			}
			if (originalGetBack == null)
			{
				originalGetBack = radial.GetBack;
			}
			if (originalGetConfirm == null)
			{
				originalGetConfirm = radial.GetConfirm;
			}
			if (originalGetControllerDirection == null)
			{
				originalGetControllerDirection = radial.GetControllerDirection;
			}
			closeRequested = false;
			radial.GetClose = () => closeRequested;
			radial.GetBack = () => false;
			if (EquipWheel.MoveWhileOpen.Value)
			{
				radial.GetControllerDirection = () => new Vector2(ZInput.GetJoyRightStickX(), 0f - ZInput.GetJoyRightStickY());
			}
			radial.GetConfirm = () => EquipWheel.TriggerOnClick.Value && (Input.GetMouseButtonDown(0) || Input.GetKeyDown((KeyCode)330));
		}

		private static void RestoreDelegatesOnly(RadialBase radial)
		{
			if (originalGetClose != null)
			{
				radial.GetClose = originalGetClose;
			}
			if (originalGetBack != null)
			{
				radial.GetBack = originalGetBack;
			}
			if (originalGetConfirm != null)
			{
				radial.GetConfirm = originalGetConfirm;
			}
			if (originalGetControllerDirection != null)
			{
				radial.GetControllerDirection = originalGetControllerDirection;
			}
			originalGetControllerDirection = null;
			originalGetClose = null;
			originalGetBack = null;
			originalGetConfirm = null;
			closeRequested = false;
		}

		internal static void RestorePcRadial(RadialBase radial)
		{
			if (pcRadialOpen)
			{
				if ((Object)(object)activeConfig != (Object)null)
				{
					Object.Destroy((Object)(object)activeConfig);
					activeConfig = null;
				}
				if (originalGetClose != null)
				{
					radial.GetClose = originalGetClose;
				}
				if (originalGetBack != null)
				{
					radial.GetBack = originalGetBack;
				}
				if (originalGetConfirm != null)
				{
					radial.GetConfirm = originalGetConfirm;
				}
				if (originalGetControllerDirection != null)
				{
					radial.GetControllerDirection = originalGetControllerDirection;
				}
				originalGetControllerDirection = null;
				originalGetClose = null;
				originalGetBack = null;
				originalGetConfirm = null;
				closeRequested = false;
				pcRadialOpen = false;
				RadialAccess.SetConfig(radial, null);
				RadialAccess.SetIsCanOpen(radial, v: true);
				RadialAccess.SetIsShouldAnimateIn(radial, v: true);
				RadialAccess.SetIsActive(radial, v: false);
			}
		}

		private bool UseCurrentItem()
		{
			RadialBase radial = Radial;
			if ((Object)(object)radial == (Object)null || !pcRadialOpen)
			{
				return false;
			}
			if ((Object)(object)RadialAccess.Selected(radial) == (Object)null)
			{
				return false;
			}
			RadialAccess.OnInteract(radial);
			if (!EquipWheel.MoveWhileOpen.Value)
			{
				EquipWheel.JoyStickIgnoreTime = (float)EquipWheel.IgnoreJoyStickDuration.Value / 1000f;
			}
			return true;
		}

		private void HandleRightTrigger()
		{
			float num = ((!ZInput.IsGamepadActive()) ? 0f : ZInput.GetJoyRTrigger());
			bool flag = num > 0.5f;
			if (suppressAttack && num < 0.2f)
			{
				suppressAttack = false;
			}
			if (visible && flag && !rtWasDown && EquipWheel.TriggerWithRT.Value && UseCurrentItem())
			{
				suppressAttack = true;
			}
			rtWasDown = flag;
		}

		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(EquipWheel.Instance))
			{
				UseCurrentItem();
				toggleDownWasPressed = true;
			}
			else if (toggleVisible > 0 && !flag)
			{
				if (!visible)
				{
					Show();
				}
				if (visible && EquipWheel.TriggerOnClick.Value && (Input.GetMouseButtonDown(0) || Input.GetKeyDown((KeyCode)330)))
				{
					UseCurrentItem();
				}
			}
			else
			{
				Hide();
			}
		}

		private void HandleToggleDisabled()
		{
			ReduceJoyStickIgnoreTime();
			HandlePressedHovering();
			if (!EquipWheel.CanOpenMenu)
			{
				Hide();
				return;
			}
			if (EquipWheel.TriggerOnRelease.Value && EquipWheel.IsShortcutUp)
			{
				UseCurrentItem();
				Hide();
				return;
			}
			if (blockReopen)
			{
				if (EquipWheel.IsShortcutPressed)
				{
					return;
				}
				blockReopen = false;
			}
			if ((EquipWheel.IsShortcutPressed && ZInput.IsGamepadActive()) || (EquipWheel.IsShortcutPressed && (EquipWheel.BestMatchPressed || EquipWheel.BestMatchDown)))
			{
				if (!visible)
				{
					Show();
				}
				if (visible && EquipWheel.TriggerOnClick.Value && (Input.GetMouseButtonDown(0) || Input.GetKeyDown((KeyCode)330)))
				{
					UseCurrentItem();
				}
			}
			else
			{
				Hide();
			}
		}
	}
	[HarmonyPatch(typeof(Player), "CheckKeyboardRadialPressed")]
	public static class Player_CheckKeyboardRadialPressed_Patch
	{
		[HarmonyPostfix]
		public static void Postfix(ref bool __result)
		{
			if (__result && EquipWheel.ModEnabled != null && EquipWheel.ModEnabled.Value && !ZInput.IsGamepadActive() && (EquipWheel.IsShortcutDown || EquipWheel.IsShortcutPressed))
			{
				__result = false;
			}
		}
	}
	[HarmonyPatch(typeof(Player), "SetControls")]
	public static class Player_SetControls_Patch
	{
		[HarmonyPrefix]
		public static void Prefix(ref bool attack, ref bool attackHold)
		{
			if (EquipRadialGui.suppressAttack)
			{
				attack = false;
				attackHold = false;
			}
		}
	}
	[HarmonyPatch(typeof(RadialBase), "Close")]
	public static class RadialBase_Close_Patch
	{
		[HarmonyPostfix]
		public static void Postfix(RadialBase __instance)
		{
			if (!((Object)(object)Hud.instance == (Object)null) && !((Object)(object)__instance != (Object)(object)Hud.instance.m_radialMenu))
			{
				EquipRadialGui.RestorePcRadial(__instance);
			}
		}
	}
}
namespace EquipWheelTwo
{
	[BepInPlugin("EquipWheelRadial2", "Equip Wheel Radial 2", "1.0.0")]
	public class EquipWheel : BaseUnityPlugin, WheelManager.IWheel
	{
		private static Harmony harmony;

		public static ManualLogSource MyLogger = Logger.CreateLogSource(typeof(EquipWheel).Namespace);

		public static ConfigEntry<KeyboardShortcut> Hotkey;

		public static ConfigEntry<WheelManager.DPadButton> HotkeyDPad;

		public static ConfigEntry<bool> UseSitButton;

		public static ConfigEntry<bool> TriggerOnRelease;

		public static ConfigEntry<bool> TriggerOnClick;

		public static ConfigEntry<bool> TriggerWithRT;

		public static ConfigEntry<float> IconScale;

		public static ConfigEntry<bool> MoveWhileOpen;

		public static ConfigEntry<bool> ToggleMenu;

		public static ConfigEntry<bool> ModEnabled;

		private const string DefaultHotkey = "J";

		private const int DefaultInventoryRow = 2;

		private const WheelManager.DPadButton DefaultDPad = WheelManager.DPadButton.LeftOrRight;

		private const bool DefaultUseSit = false;

		private const bool DefaultModEnabled = false;

		private const float DefaultIconScale = 1.669f;

		public static ConfigEntry<Color> HighlightColor;

		public static ConfigEntry<float> GuiScale;

		public static ConfigEntry<int> InventoryRow;

		public static ConfigEntry<bool> ItemFiltering;

		public static ConfigEntry<bool> UseAzuQuickSlots;

		public static ConfigEntry<int> AzuQuickSlotsFirst;

		public static ConfigEntry<int> AzuQuickSlotsLast;

		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 EquipRadialGui Gui;

		public static Color GetHighlightColor
		{
			[CompilerGenerated]
			get
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				return HighlightColor.Value;
			}
		}

		public static EquipWheel Instance => instance;

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

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

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

		public static bool IsShortcutDown
		{
			get
			{
				//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_0094: Unknown result type (might be due to invalid IL or missing references)
				//IL_0099: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
				if (ZInput.IsGamepadActive())
				{
					switch (HotkeyDPad.Value)
					{
					case WheelManager.DPadButton.None:
						if (UseSitButton.Value)
						{
							return ZInput.GetButtonDown("JoySit");
						}
						return ZInput.GetButtonDown("JoyUse");
					case WheelManager.DPadButton.Left:
						return DPadLeftDown();
					case WheelManager.DPadButton.Right:
						return DPadRightDown();
					case WheelManager.DPadButton.LeftOrRight:
						return DPadRightDown() || DPadLeftDown();
					default:
						return DPadRightDown() || DPadLeftDown();
					}
				}
				KeyboardShortcut value = Hotkey.Value;
				KeyCode mainKey = ((KeyboardShortcut)(ref value)).MainKey;
				KeyCode[] source = ((KeyboardShortcut)(ref value)).Modifiers.ToArray();
				return Input.GetKeyDown(mainKey) || ((IEnumerable<KeyCode>)source).Any((Func<KeyCode, bool>)Input.GetKeyDown);
			}
		}

		public static bool IsShortcutUp
		{
			get
			{
				//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_0094: Unknown result type (might be due to invalid IL or missing references)
				//IL_0099: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
				if (ZInput.IsGamepadActive())
				{
					switch (HotkeyDPad.Value)
					{
					case WheelManager.DPadButton.None:
						if (UseSitButton.Value)
						{
							return ZInput.GetButtonUp("JoySit");
						}
						return ZInput.GetButtonUp("JoyUse");
					case WheelManager.DPadButton.Left:
						return DPadLeftUp();
					case WheelManager.DPadButton.Right:
						return DPadRightUp();
					case WheelManager.DPadButton.LeftOrRight:
						return DPadRightUp() || DPadLeftUp();
					default:
						return DPadRightUp() || DPadLeftUp();
					}
				}
				KeyboardShortcut value = Hotkey.Value;
				KeyCode mainKey = ((KeyboardShortcut)(ref value)).MainKey;
				KeyCode[] source = ((KeyboardShortcut)(ref value)).Modifiers.ToArray();
				return Input.GetKeyUp(mainKey) || ((IEnumerable<KeyCode>)source).Any((Func<KeyCode, bool>)Input.GetKeyUp);
			}
		}

		public static bool IsShortcutPressed
		{
			get
			{
				//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_0094: Unknown result type (might be due to invalid IL or missing references)
				//IL_0099: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
				if (ZInput.IsGamepadActive())
				{
					switch (HotkeyDPad.Value)
					{
					case WheelManager.DPadButton.None:
						if (UseSitButton.Value)
						{
							return ZInput.GetButton("JoySit");
						}
						return ZInput.GetButton("JoyUse");
					case WheelManager.DPadButton.Left:
						return DPadLeftHeld();
					case WheelManager.DPadButton.Right:
						return DPadRightHeld();
					case WheelManager.DPadButton.LeftOrRight:
						return DPadRightHeld() || DPadLeftHeld();
					default:
						return DPadRightHeld() || DPadLeftHeld();
					}
				}
				KeyboardShortcut value = Hotkey.Value;
				KeyCode mainKey = ((KeyboardShortcut)(ref value)).MainKey;
				KeyCode[] source = ((KeyboardShortcut)(ref value)).Modifiers.ToArray();
				return Input.GetKey(mainKey) || ((IEnumerable<KeyCode>)source).Any((Func<KeyCode, bool>)Input.GetKey);
			}
		}

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

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

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

		private static bool TakeInput(bool look = false)
		{
			return !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) && (!PlayerCustomizaton.BarberBlocksLook() || !look);
		}

		private static bool InInventoryEtc()
		{
			return Minimap.IsOpen() || StoreGui.IsVisible() || Hud.IsPieceSelectionVisible();
		}

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

		public static bool IsUsingUseButton()
		{
			return ZInput.IsGamepadActive() && HotkeyDPad.Value == WheelManager.DPadButton.None && !UseSitButton.Value;
		}

		public void Awake()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Expected O, but got Unknown
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Expected O, but got Unknown
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Expected O, but got Unknown
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Expected O, but got Unknown
			instance = this;
			ModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ModEnabled", false, "Enable mod when value is true");
			Hotkey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Input", "Hotkey", KeyboardShortcut.Deserialize("J"), "Hotkey for opening equip wheel menu");
			HotkeyDPad = ((BaseUnityPlugin)this).Config.Bind<WheelManager.DPadButton>("Input", "HotkeyDPad", WheelManager.DPadButton.LeftOrRight, "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", false, "Releasing the Hotkey will equip/use the selected item");
			TriggerOnClick = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "TriggerOnClick", true, "Click with left mouse button will equip/use the selected item");
			IconScale = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "IconScale", 1.669f, new ConfigDescription("Size multiplier of ALL item icons in the wheel (1 = game default size, 1.5 = 50% bigger).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 3f), Array.Empty<object>()));
			TriggerWithRT = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "TriggerWithRT", true, "Gamepad: pressing RT (right trigger) equips/uses the selected item while the wheel is open");
			MoveWhileOpen = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "MoveWhileOpen", true, "The player can keep moving (left stick / WASD) while the wheel is open. On gamepad the wheel is then aimed with the right stick");
			ToggleMenu = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "ToggleMenu", true, "When enabled the equip wheel will toggle between hidden/visible when the hotkey was pressed");
			HighlightColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Appereance", "HighlightColor", Color32.op_Implicit(new Color32((byte)106, (byte)187, byte.MaxValue, byte.MaxValue)), "Color of the highlighted selection");
			GuiScale = ((BaseUnityPlugin)this).Config.Bind<float>("Appereance", "GuiScale", 0.6f, "Scale factor of the user interface");
			InventoryRow = ((BaseUnityPlugin)this).Config.Bind<int>("Misc", "InventoryRow", 2, new ConfigDescription("Row of the inventory that should be used for the equip wheel", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 4), Array.Empty<object>()));
			UseAzuQuickSlots = ((BaseUnityPlugin)this).Config.Bind<bool>("AzuEPI", "UseAzuQuickSlots", false, "Use the quick slots of the AzuEPI mod (Azu Extended Player Inventory, up to 8) as the content of this wheel. Takes priority over InventoryRow and ItemFiltering. Requires AzuEPI to be installed.");
			AzuQuickSlotsFirst = ((BaseUnityPlugin)this).Config.Bind<int>("AzuEPI", "FirstQuickSlot", 1, new ConfigDescription("First AzuEPI quick slot shown in this wheel (1-8). Lets you split the 8 quick slots between wheels, e.g. 1 to 4 here and 5 to 8 in another wheel.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 8), Array.Empty<object>()));
			AzuQuickSlotsLast = ((BaseUnityPlugin)this).Config.Bind<int>("AzuEPI", "LastQuickSlot", 8, new ConfigDescription("Last AzuEPI quick slot shown in this wheel (1-8).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 8), Array.Empty<object>()));
			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 (IsDedicated())
			{
				LogWarn("Mod not loaded because game instance is a dedicated server.");
				return;
			}
			harmony = Harmony.CreateAndPatchAll(typeof(Patcher), (string)null);
			harmony.PatchAll(typeof(RadialBase_Close_Patch));
			harmony.PatchAll(typeof(Player_SetControls_Patch));
			harmony.PatchAll(typeof(Player_CheckKeyboardRadialPressed_Patch));
			WheelManager.AddWheel(this);
			Log(((object)this).GetType().Namespace + " Loaded!");
		}

		private void OnDestroy()
		{
			WheelManager.RemoveWheel(this);
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		public static void TryHideHotkeyBar()
		{
		}

		private static bool DPadLeftDown()
		{
			return ZInput.GetButtonDown("JoyHotbarLeft") || ZInput.GetButtonDown("JoyDPadLeft");
		}

		private static bool DPadRightDown()
		{
			return ZInput.GetButtonDown("JoyHotbarRight") || ZInput.GetButtonDown("JoyDPadRight");
		}

		private static bool DPadLeftUp()
		{
			return ZInput.GetButtonUp("JoyHotbarLeft") || ZInput.GetButtonUp("JoyDPadLeft");
		}

		private static bool DPadRightUp()
		{
			return ZInput.GetButtonUp("JoyHotbarRight") || ZInput.GetButtonUp("JoyDPadRight");
		}

		private static bool DPadLeftHeld()
		{
			return ZInput.GetButton("JoyHotbarLeft") || ZInput.GetButton("JoyDPadLeft");
		}

		private static bool DPadRightHeld()
		{
			return ZInput.GetButton("JoyHotbarRight") || ZInput.GetButton("JoyDPadRight");
		}

		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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			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.GetKeyDown(mainKey) : Input.GetKey(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 EquipRadialGui.visible;
		}

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

		public string GetName()
		{
			return typeof(EquipWheel).Namespace;
		}

		float WheelManager.IWheel.JoyStickIgnoreTime()
		{
			return JoyStickIgnoreTime;
		}
	}
	public class Patcher
	{
		public static readonly KeyCode[] NUMBERS;

		[HarmonyPatch(typeof(Hud), "Awake")]
		[HarmonyPostfix]
		public static void Hud_Awake_Postfix(Hud __instance)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			string text = "EquipGui (" + typeof(EquipWheel).Namespace + ")";
			if (!Object.op_Implicit((Object)(object)GameObject.Find(text)))
			{
				GameObject val = new GameObject(text);
				EquipWheel.Gui = val.AddComponent<EquipRadialGui>();
				val.transform.SetParent(((Component)__instance).transform, false);
				EquipWheel.Log("Spawned EquipGui under HUD!");
			}
		}

		[HarmonyPatch(typeof(HotkeyBar), "Update")]
		[HarmonyPrefix]
		public static bool Prefix(HotkeyBar __instance)
		{
			if ((Object)(object)EquipWheel.Instance == (Object)null)
			{
				return true;
			}
			if (EquipWheel.HotkeyDPad != null && EquipWheel.HotkeyDPad.Value == WheelManager.DPadButton.None)
			{
				return true;
			}
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer != (Object)null)
			{
				MethodInfo method = typeof(HotkeyBar).GetMethod("UpdateIcons", BindingFlags.Instance | BindingFlags.NonPublic);
				method.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 flag = Array.IndexOf(nUMBERS, ((KeyboardShortcut)(ref value)).MainKey) != index - 1;
			bool flag2 = !EquipWheel.IsShortcutDown;
			return flag || flag2 || !EquipWheel.CanOpenMenu || ZInput.IsGamepadActive();
		}

		[HarmonyPatch(typeof(Player), "Update")]
		[HarmonyPostfix]
		public static void Update()
		{
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer == (Object)null) && EquipWheel.UseSitButton.Value && EquipWheel.HotkeyDPad.Value == WheelManager.DPadButton.None && (ZInput.GetButtonDown("JoySit") || ZInput.GetButtonUp("JoySit")))
			{
				MethodInfo method = typeof(Player).GetMethod("StopEmote", BindingFlags.Instance | BindingFlags.NonPublic);
				method.Invoke(localPlayer, new object[0]);
			}
		}

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

		private static PropertyInfo gridPosProperty;

		private static bool missingLogged = false;

		private static bool Resolve()
		{
			if (getSnapshots != null)
			{
				return true;
			}
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly assembly in assemblies)
			{
				Type type = null;
				try
				{
					type = assembly.GetType("AzuEPI.API", throwOnError: false);
				}
				catch (Exception)
				{
				}
				if (type == null)
				{
					continue;
				}
				try
				{
					MethodInfo methodInfo = AccessTools.Method(type, "IsLoaded", (Type[])null, (Type[])null);
					if (methodInfo != null && !(bool)methodInfo.Invoke(null, null))
					{
						continue;
					}
				}
				catch (Exception)
				{
					continue;
				}
				getSnapshots = AccessTools.Method(type, "GetQuickSlotSnapshots", new Type[1] { typeof(Inventory) }, (Type[])null);
				if (!(getSnapshots != null))
				{
					continue;
				}
				break;
			}
			if (getSnapshots == null && !missingLogged)
			{
				missingLogged = true;
				EquipWheel.LogWarn("UseAzuQuickSlots is enabled but the AzuEPI API was not found (is AzuEPI installed and up to date?)");
			}
			return getSnapshots != null;
		}

		public static ItemData[] Collect(Inventory inventory, int max)
		{
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			ItemData[] array = (ItemData[])(object)new ItemData[max];
			if (inventory == null || !Resolve())
			{
				return array;
			}
			IEnumerable enumerable;
			try
			{
				enumerable = getSnapshots.Invoke(null, new object[1] { inventory }) as IEnumerable;
			}
			catch (Exception ex)
			{
				EquipWheel.LogErr("AzuEPI quick slots could not be read: " + ex.Message);
				return array;
			}
			if (enumerable == null)
			{
				return array;
			}
			int num = Mathf.Clamp(EquipWheel.AzuQuickSlotsFirst.Value, 1, max);
			int num2 = Mathf.Clamp(EquipWheel.AzuQuickSlotsLast.Value, 1, max);
			int num3 = 0;
			foreach (object item in enumerable)
			{
				num3++;
				if (num3 >= num && num3 <= num2 && num3 <= max)
				{
					if (gridPosProperty == null)
					{
						gridPosProperty = AccessTools.Property(item.GetType(), "GridPos");
					}
					if (!(gridPosProperty == null))
					{
						Vector2i val = (Vector2i)gridPosProperty.GetValue(item, null);
						array[num3 - 1] = inventory.GetItemAt(val.x, val.y);
					}
				}
			}
			return array;
		}
	}
	public static class WheelItems
	{
		public const int MaxItems = 8;

		public static ItemData[] Collect()
		{
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Expected I4, but got Unknown
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Expected I4, but got Unknown
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Expected I4, but got Unknown
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Expected I4, but got Unknown
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Expected I4, but got Unknown
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Expected I4, but got Unknown
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: 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_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			ItemData[] array = (ItemData[])(object)new ItemData[8];
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return array;
			}
			Inventory inventory = ((Humanoid)localPlayer).GetInventory();
			if (inventory == null)
			{
				return array;
			}
			if (EquipWheel.UseAzuQuickSlots.Value)
			{
				return AzuQuickSlots.Collect(inventory, 8);
			}
			if (EquipWheel.ItemFiltering.Value)
			{
				List<ItemData> list = new List<ItemData>();
				List<ItemData> list2 = new List<ItemData>();
				Regex regex = BuildRegex(EquipWheel.ItemRegexIgnore.Value);
				Regex regex2 = BuildRegex(EquipWheel.ItemRegex.Value);
				foreach (ItemData allItem in inventory.GetAllItems())
				{
					if (regex != null && regex.IsMatch(NameOf(allItem)))
					{
						continue;
					}
					if (regex2 != null && regex2.IsMatch(NameOf(allItem)))
					{
						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 num = 0; num < 8; num++)
				{
					if (list.Count > num)
					{
						array[num] = list[num];
					}
					else if (list2.Count > num - list.Count)
					{
						array[num] = list2[num - list.Count];
					}
				}
				return array;
			}
			for (int num2 = 0; num2 < 8; num2++)
			{
				array[num2] = inventory.GetItemAt(num2, EquipWheel.InventoryRow.Value - 1);
			}
			return array;
		}

		private static Regex BuildRegex(string pattern)
		{
			if (string.IsNullOrEmpty(pattern))
			{
				return null;
			}
			return new Regex(pattern, (!EquipWheel.ItemRegexCaseSensitive.Value) ? RegexOptions.IgnoreCase : RegexOptions.None);
		}

		private static string NameOf(ItemData item)
		{
			//IL_0010: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			if (EpicLootWrapper.instance != null)
			{
				Color itemColor = EpicLootWrapper.instance.GetItemColor(item);
				return Localization.instance.Localize(EpicLootWrapper.instance.GetItemName(item, itemColor));
			}
			return Localization.instance.Localize(item.m_shared.m_name);
		}
	}
	internal static class RadialAccess
	{
		private const BindingFlags Any = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

		private static readonly FieldInfo FLocalPlayerRef = AccessTools.Field(typeof(RadialBase), "m_localPlayerRef");

		private static readonly FieldInfo FElements = AccessTools.Field(typeof(RadialBase), "m_elements");

		private static readonly FieldInfo FElementInfo = AccessTools.Field(typeof(RadialBase), "m_elementInfo");

		private static readonly FieldInfo FSelected = AccessTools.Field(typeof(RadialBase), "m_selected");

		private static readonly MethodInfo MResetAll = AccessTools.Method(typeof(RadialBase), "ResetAllVariables", (Type[])null, (Type[])null);

		private static readonly MethodInfo MLoadSettings = AccessTools.Method(typeof(RadialBase), "LoadSettings", (Type[])null, (Type[])null);

		private static readonly MethodInfo MStartAnimIn = AccessTools.Method(typeof(RadialBase), "StartAnimatingIn", (Type[])null, (Type[])null);

		private static readonly MethodInfo MOnInteract = AccessTools.Method(typeof(RadialBase), "OnInteract", (Type[])null, (Type[])null);

		private static readonly MethodInfo MInstantClose = AccessTools.Method(typeof(RadialBase), "InstantClose", (Type[])null, (Type[])null);

		private static readonly MethodInfo MConstruct = AccessTools.Method(typeof(RadialBase), "ConstructRadial", (Type[])null, (Type[])null);

		private static readonly MethodInfo SetCurrentConfig = AccessTools.PropertySetter(typeof(RadialBase), "CurrentConfig");

		private static readonly MethodInfo SetActive = AccessTools.PropertySetter(typeof(RadialBase), "Active");

		private static readonly MethodInfo SetCanOpen = AccessTools.PropertySetter(typeof(RadialBase), "CanOpen");

		private static readonly MethodInfo SetShouldAnimateIn = AccessTools.PropertySetter(typeof(RadialBase), "ShouldAnimateIn");

		private static readonly MethodInfo SetSubTitle = AccessTools.PropertySetter(typeof(RadialMenuElement), "SubTitle");

		public static void Invoke(MethodInfo m, object target, params object[] args)
		{
			if (m == null)
			{
				EquipWheel.LogErr("Radial API member missing (game version changed?)");
			}
			else
			{
				m.Invoke(target, args);
			}
		}

		public static void SetLocalPlayer(RadialBase r, Player p)
		{
			if (FLocalPlayerRef != null)
			{
				FLocalPlayerRef.SetValue(r, p);
			}
		}

		public static void ResetAllVariables(RadialBase r)
		{
			Invoke(MResetAll, r);
		}

		public static void EnsureReady(RadialBase r)
		{
			if ((Object)(object)RadialData.SO == (Object)null)
			{
				MethodInfo methodInfo = AccessTools.Method(typeof(RadialData), "Init", (Type[])null, (Type[])null);
				RadialDataSO val = null;
				RadialDataInitializer[] array = Resources.FindObjectsOfTypeAll<RadialDataInitializer>();
				foreach (RadialDataInitializer val2 in array)
				{
					RadialDataSO value = Traverse.Create((object)val2).Field("_dataObject").GetValue<RadialDataSO>();
					if ((Object)(object)value != (Object)null)
					{
						val = value;
						break;
					}
				}
				if ((Object)(object)val == (Object)null)
				{
					RadialDataSO[] array2 = Resources.FindObjectsOfTypeAll<RadialDataSO>();
					int num = 0;
					if (num < array2.Length)
					{
						RadialDataSO val3 = array2[num];
						val = val3;
					}
				}
				if ((Object)(object)val != (Object)null && methodInfo != null)
				{
					methodInfo.Invoke(null, new object[1] { val });
				}
				else
				{
					EquipWheel.LogWarn("RadialData.SO is null and no RadialDataInitializer was found");
				}
			}
			string value2 = Traverse.Create((object)r).Field("m_cursorID").GetValue<string>();
			if (string.IsNullOrEmpty(value2) && (Object)(object)RadialData.SO != (Object)null && !((Component)r).gameObject.activeSelf)
			{
				((Component)r).gameObject.SetActive(true);
			}
		}

		public static void EndAnimations(RadialBase r)
		{
			FieldInfo fieldInfo = AccessTools.Field(typeof(RadialBase), "m_animationManager");
			object obj = ((!(fieldInfo != null)) ? null : fieldInfo.GetValue(r));
			if (obj == null)
			{
				return;
			}
			try
			{
				Traverse.Create(obj).Method("EndAll", Array.Empty<object>()).GetValue();
			}
			catch (Exception ex)
			{
				EquipWheel.LogWarn("EndAll failed: " + ex.Message);
			}
		}

		public static void LoadSettings(RadialBase r)
		{
			Invoke(MLoadSettings, r);
		}

		public static void StartAnimatingIn(RadialBase r)
		{
			Invoke(MStartAnimIn, r);
		}

		public static void OnInteract(RadialBase r)
		{
			Invoke(MOnInteract, r);
		}

		public static void InstantClose(RadialBase r)
		{
			Invoke(MInstantClose, r);
		}

		public static void ConstructRadial(RadialBase r, List<RadialMenuElement> list)
		{
			Invoke(MConstruct, r, list);
		}

		public static void SetConfig(RadialBase r, IRadialConfig c)
		{
			Invoke(SetCurrentConfig, r, c);
		}

		public static void SetIsActive(RadialBase r, bool v)
		{
			Invoke(SetActive, r, v);
		}

		public static void SetIsCanOpen(RadialBase r, bool v)
		{
			Invoke(SetCanOpen, r, v);
		}

		public static void SetIsShouldAnimateIn(RadialBase r, bool v)
		{
			Invoke(SetShouldAnimateIn, r, v);
		}

		public static void SetElementSubTitle(RadialMenuElement e, string v)
		{
			Invoke(SetSubTitle, e, v);
		}

		public static int ElementCount(RadialBase r)
		{
			return Elements(r).Count;
		}

		public static List<RadialMenuElement> Elements(RadialBase r)
		{
			List<RadialMenuElement> list = new List<RadialMenuElement>();
			object obj = ((!(FElements != null)) ? null : FElements.GetValue(r));
			if (obj == null)
			{
				return list;
			}
			Traverse val = Traverse.Create(obj);
			IEnumerable enumerable = null;
			try
			{
				enumerable = val.Property("GetAsList", (object[])null).GetValue() as IEnumerable;
			}
			catch (Exception)
			{
			}
			if (enumerable == null)
			{
				try
				{
					enumerable = val.Property("GetArray", (object[])null).GetValue() as IEnumerable;
				}
				catch (Exception)
				{
				}
			}
			if (enumerable == null)
			{
				return list;
			}
			foreach (object item in enumerable)
			{
				RadialMenuElement val2 = (RadialMenuElement)((item is RadialMenuElement) ? item : null);
				if ((Object)(object)val2 != (Object)null)
				{
					list.Add(val2);
				}
			}
			return list;
		}

		public static RadialMenuElement Selected(RadialBase r)
		{
			return (RadialMenuElement)((!(FSelected != null)) ? null : /*isinst with value type is only supported in some contexts*/);
		}

		public static void ShowElementInfoNoAnimation(RadialBase r)
		{
			object obj = ((!(FElementInfo != null)) ? null : FElementInfo.GetValue(r));
			if (obj != null)
			{
				Traverse val = Traverse.Create(obj);
				val.Property("Alpha", (object[])null).SetValue((object)1f);
				object value = val.Field("m_inventoryInfo").GetValue();
				if (value != null)
				{
					Traverse.Create(value).Method("SetAlpha", new object[1] { 1f }).GetValue();
				}
				val.Property("Radius", (object[])null).SetValue((object)RadialData.SO.ElementInfoRadius);
			}
		}
	}
	public class EquipWheelRadialConfig : ScriptableObject, IRadialConfig
	{
		public string LocalizedName => "Equip Wheel";

		public Sprite Sprite => null;

		public bool HasItems()
		{
			ItemData[] array = WheelItems.Collect();
			foreach (ItemData val in array)
			{
				if (val != null)
				{
					return true;
				}
			}
			return false;
		}

		public void InitRadialConfig(RadialBase radial)
		{
			List<RadialMenuElement> list = new List<RadialMenuElement>();
			ItemData[] array = WheelItems.Collect();
			for (int i = 0; i < array.Length; i++)
			{
				ItemData val = array[i];
				if (val != null)
				{
					ItemElement val2 = Object.Instantiate<ItemElement>(RadialData.SO.ItemElement);
					val2.Init(val);
					((RadialMenuElement)val2).CloseOnInteract = () => true;
					((RadialMenuElement)val2).AdvancedCloseOnInteract = null;
					RadialAccess.SetElementSubTitle((RadialMenuElement)(object)val2, (i + 1).ToString());
					list.Add((RadialMenuElement)(object)val2);
				}
			}
			if (list.Count == 0)
			{
				RadialData.SO.HotbarGroupConfig.InitRadialConfig(radial);
				RadialAccess.SetConfig(radial, (IRadialConfig)(object)RadialData.SO.HotbarGroupConfig);
			}
			else
			{
				RadialAccess.ConstructRadial(radial, list);
			}
		}
	}
	public class EquipRadialGui : MonoBehaviour
	{
		public static bool visible = false;

		public static bool toggleDownWasPressed = false;

		public int toggleVisible = 0;

		private static bool pcRadialOpen = false;

		private static EquipWheelRadialConfig activeConfig;

		private static bool closeRequested = false;

		private static Func<bool> originalGetClose;

		private static Func<bool> originalGetBack;

		private static Func<bool> originalGetConfirm;

		private static Func<Vector2> originalGetControllerDirection;

		private static bool rtWasDown = false;

		public static bool suppressAttack = false;

		private bool blockReopen = false;

		private bool scaleErrorLogged = false;

		private static float lastEmptyNotice = -10f;

		private static RadialBase Radial => (!((Object)(object)Hud.instance != (Object)null)) ? null : Hud.instance.m_radialMenu;

		private void Awake()
		{
			visible = false;
			toggleDownWasPressed = false;
		}

		private void Update()
		{
			RadialBase radial = Radial;
			if (visible && ((Object)(object)radial == (Object)null || !radial.Active || !pcRadialOpen))
			{
				visible = false;
				toggleVisible = 0;
				blockReopen = EquipWheel.IsShortcutPressed;
			}
			HandleRightTrigger();
			if (EquipWheel.ToggleMenu.Value)
			{
				HandleToggleEnabled();
			}
			else
			{
				HandleToggleDisabled();
			}
		}

		private void LateUpdate()
		{
			if (!visible || !pcRadialOpen)
			{
				return;
			}
			try
			{
				ApplyIconScale();
			}
			catch (Exception ex)
			{
				if (!scaleErrorLogged)
				{
					scaleErrorLogged = true;
					EquipWheel.LogErr("Icon scale failed: " + ex);
				}
			}
		}

		private void ApplyIconScale()
		{
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			RadialBase radial = Radial;
			if ((Object)(object)radial == (Object)null || !radial.Active)
			{
				return;
			}
			float num = ((EquipWheel.IconScale == null) ? 1f : EquipWheel.IconScale.Value);
			float num2 = 1f - Mathf.Exp(-14f * Time.unscaledDeltaTime);
			foreach (RadialMenuElement item in RadialAccess.Elements(radial))
			{
				if (!((Object)(object)item == (Object)null))
				{
					Image icon = item.Icon;
					if (!((Object)(object)icon == (Object)null))
					{
						RectTransform rectTransform = ((Graphic)icon).rectTransform;
						float x = ((Transform)rectTransform).localScale.x;
						float num3 = ((!(Mathf.Abs(x - num) < 0.002f)) ? Mathf.Lerp(x, num, num2) : num);
						((Transform)rectTransform).localScale = new Vector3(num3, num3, 1f);
					}
				}
			}
		}

		private static void NotifyEmpty()
		{
			if (Time.time - lastEmptyNotice < 2f)
			{
				return;
			}
			lastEmptyNotice = Time.time;
			string text = (EquipWheel.UseAzuQuickSlots.Value ? ("aucun quickslot AzuEPI rempli dans la plage " + EquipWheel.AzuQuickSlotsFirst.Value + "-" + EquipWheel.AzuQuickSlotsLast.Value + " (ou AzuEPI absent)") : ((!EquipWheel.ItemFiltering.Value) ? ("ligne " + EquipWheel.InventoryRow.Value + " de l'inventaire vide") : "aucun objet ne correspond au filtre (ItemType / ItemRegex)"));
			EquipWheel.Log("Wheel not opened: " + text);
			try
			{
				if ((Object)(object)MessageHud.instance != (Object)null)
				{
					MessageHud.instance.ShowMessage((MessageType)1, "EquipWheel (" + typeof(EquipWheel).Namespace + ") : roue vide - " + text, 0, (Sprite)null, false, true);
				}
			}
			catch (Exception)
			{
			}
		}

		private void Show()
		{
			try
			{
				ShowInternal();
			}
			catch (Exception ex)
			{
				visible = false;
				toggleVisible = 0;
				if ((Object)(object)Radial != (Object)null)
				{
					RestoreDelegatesOnly(Radial);
				}
				EquipWheel.LogErr("Failed to open the wheel: " + ex);
			}
		}

		private void ShowInternal()
		{
			RadialBase radial = Radial;
			if ((Object)(object)radial == (Object)null)
			{
				EquipWheel.LogWarn("Cannot open wheel: Hud.m_radialMenu is null");
			}
			else
			{
				if ((Object)(object)Player.m_localPlayer == (Object)null)
				{
					return;
				}
				EquipWheelRadialConfig equipWheelRadialConfig = ScriptableObject.CreateInstance<EquipWheelRadialConfig>();
				if (!equipWheelRadialConfig.HasItems())
				{
					if (EquipWheel.IsShortcutDown)
					{
						NotifyEmpty();
					}
					Object.Destroy((Object)(object)equipWheelRadialConfig);
					return;
				}
				if ((Object)(object)activeConfig != (Object)null)
				{
					Object.Destroy((Object)(object)activeConfig);
				}
				activeConfig = equipWheelRadialConfig;
				OpenPcRadial(radial, equipWheelRadialConfig);
				if (!pcRadialOpen)
				{
					EquipWheel.LogWarn("The game's radial did not open (Open returned without activating it)");
					Object.Destroy((Object)(object)equipWheelRadialConfig);
					activeConfig = null;
				}
				else
				{
					visible = true;
					WheelManager.Activate(EquipWheel.Instance);
				}
			}
		}

		public void Hide()
		{
			if (visible)
			{
				RadialBase radial = Radial;
				if ((Object)(object)radial != (Object)null && pcRadialOpen)
				{
					closeRequested = true;
					RadialAccess.InstantClose(radial);
					RestorePcRadial(radial);
				}
			}
			visible = false;
			toggleVisible = 0;
		}

		private static void OpenPcRadial(RadialBase radial, EquipWheelRadialConfig config)
		{
			RadialAccess.EnsureReady(radial);
			RadialAccess.SetLocalPlayer(radial, Player.m_localPlayer);
			RadialAccess.EndAnimations(radial);
			RadialAccess.ResetAllVariables(radial);
			RadialAccess.LoadSettings(radial);
			HijackDelegates(radial);
			RadialAccess.SetIsCanOpen(radial, v: true);
			RadialAccess.SetIsShouldAnimateIn(radial, v: true);
			radial.Open((IRadialConfig)(object)config, (IRadialConfig)null);
			if (!radial.Active)
			{
				config.InitRadialConfig(radial);
				RadialAccess.SetConfig(radial, (IRadialConfig)(object)config);
				RadialAccess.SetIsActive(radial, v: true);
				if (RadialData.SO.EnableToggleAnimation && RadialAccess.ElementCount(radial) > 0)
				{
					RadialAccess.StartAnimatingIn(radial);
				}
				else
				{
					RadialAccess.ShowElementInfoNoAnimation(radial);
				}
			}
			pcRadialOpen = radial.Active;
			if (!pcRadialOpen)
			{
				RestoreDelegatesOnly(radial);
			}
		}

		private static void HijackDelegates(RadialBase radial)
		{
			if (originalGetClose == null)
			{
				originalGetClose = radial.GetClose;
			}
			if (originalGetBack == null)
			{
				originalGetBack = radial.GetBack;
			}
			if (originalGetConfirm == null)
			{
				originalGetConfirm = radial.GetConfirm;
			}
			if (originalGetControllerDirection == null)
			{
				originalGetControllerDirection = radial.GetControllerDirection;
			}
			closeRequested = false;
			radial.GetClose = () => closeRequested;
			radial.GetBack = () => false;
			if (EquipWheel.MoveWhileOpen.Value)
			{
				radial.GetControllerDirection = () => new Vector2(ZInput.GetJoyRightStickX(), 0f - ZInput.GetJoyRightStickY());
			}
			radial.GetConfirm = () => EquipWheel.TriggerOnClick.Value && (Input.GetMouseButtonDown(0) || Input.GetKeyDown((KeyCode)330));
		}

		private static void RestoreDelegatesOnly(RadialBase radial)
		{
			if (originalGetClose != null)
			{
				radial.GetClose = originalGetClose;
			}
			if (originalGetBack != null)
			{
				radial.GetBack = originalGetBack;
			}
			if (originalGetConfirm != null)
			{
				radial.GetConfirm = originalGetConfirm;
			}
			if (originalGetControllerDirection != null)
			{
				radial.GetControllerDirection = originalGetControllerDirection;
			}
			originalGetControllerDirection = null;
			originalGetClose = null;
			originalGetBack = null;
			originalGetConfirm = null;
			closeRequested = false;
		}

		internal static void RestorePcRadial(RadialBase radial)
		{
			if (pcRadialOpen)
			{
				if ((Object)(object)activeConfig != (Object)null)
				{
					Object.Destroy((Object)(object)activeConfig);
					activeConfig = null;
				}
				if (originalGetClose != null)
				{
					radial.GetClose = originalGetClose;
				}
				if (originalGetBack != null)
				{
					radial.GetBack = originalGetBack;
				}
				if (originalGetConfirm != null)
				{
					radial.GetConfirm = originalGetConfirm;
				}
				if (originalGetControl