Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of EquipWheel v1.5.7
EquipWheel.dll
Decompiled a week agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.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: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = "")] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("1.0.0.0")] namespace EquipWheel; public class EpicLootWrapper { private Assembly EpicLootAssembly; private Type ItemBackgroundHelper; private Type EpicLoot; private Type ItemDataExtensions; private MethodInfo CreateAndGetMagicItemBackgroundImage; private MethodInfo GetMagicItemBgSprite; private MethodInfo UseMagicBackground; private MethodInfo GetRarityColor; private MethodInfo GetDecoratedName; public static EpicLootWrapper instance; private EpicLootWrapper() { } public static EpicLootWrapper CreateInstance() { PluginInfo val; try { val = Chainloader.PluginInfos["randyknapp.mods.epicloot"]; } catch (KeyNotFoundException) { return null; } EpicLootWrapper epicLootWrapper = new EpicLootWrapper(); Assembly assembly = ((object)val.Instance).GetType().Assembly; if (assembly == null) { throw new Exception("Assembly for EpicLoot cannot be resolved"); } epicLootWrapper.EpicLootAssembly = assembly; Type[] exportedTypes = epicLootWrapper.EpicLootAssembly.GetExportedTypes(); Type[] array = exportedTypes; foreach (Type type in array) { if (type.FullName == "EpicLoot.ItemBackgroundHelper") { epicLootWrapper.ItemBackgroundHelper = type; } if (type.FullName == "EpicLoot.EpicLoot") { epicLootWrapper.EpicLoot = type; } if (type.FullName == "EpicLoot.ItemDataExtensions") { epicLootWrapper.ItemDataExtensions = type; } } if (epicLootWrapper.ItemBackgroundHelper == null) { throw new Exception("Type EpicLoot.ItemBackgroundHelper cannot be resolved"); } if (epicLootWrapper.EpicLoot == null) { throw new Exception("Type EpicLoot.EpicLoot cannot be resolved"); } if (epicLootWrapper.ItemDataExtensions == null) { throw new Exception("Type EpicLoot.ItemDataExtensions cannot be resolved"); } epicLootWrapper.CreateAndGetMagicItemBackgroundImage = epicLootWrapper.ItemBackgroundHelper.GetMethod("CreateAndGetMagicItemBackgroundImage", new Type[3] { typeof(GameObject), typeof(GameObject), typeof(bool) }); if (epicLootWrapper.CreateAndGetMagicItemBackgroundImage == null) { throw new Exception("Method CreateAndGetMagicItemBackgroundImage cannot be resolved"); } epicLootWrapper.GetMagicItemBgSprite = epicLootWrapper.EpicLoot.GetMethod("GetMagicItemBgSprite", new Type[0]); if (epicLootWrapper.GetMagicItemBgSprite == null) { throw new Exception("Method GetMagicItemBgSprite cannot be resolved"); } epicLootWrapper.UseMagicBackground = epicLootWrapper.ItemDataExtensions.GetMethod("UseMagicBackground", new Type[1] { typeof(ItemData) }); if (epicLootWrapper.UseMagicBackground == null) { throw new Exception("Method UseMagicBackground cannot be resolved"); } epicLootWrapper.GetRarityColor = epicLootWrapper.ItemDataExtensions.GetMethod("GetRarityColor", new Type[1] { typeof(ItemData) }); if (epicLootWrapper.GetRarityColor == null) { throw new Exception("Method GetRarityColor cannot be resolved"); } epicLootWrapper.GetDecoratedName = epicLootWrapper.ItemDataExtensions.GetMethod("GetDecoratedName", new Type[2] { typeof(ItemData), typeof(string) }); if (epicLootWrapper.GetDecoratedName == null) { throw new Exception("Method GetDecoratedName cannot be resolved"); } instance = epicLootWrapper; return epicLootWrapper; } public string GetItemName(ItemData item, Color color) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) return (string)GetDecoratedName.Invoke(null, new object[2] { item, "#" + ColorUtility.ToHtmlStringRGB(color) }); } public string GetItemName(ItemData item) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return GetItemName(item, EquipWheel.GetHighlightColor); } public Color GetItemColor(ItemData item) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) return (Color)GetRarityColor.Invoke(null, new object[1] { item }); } public void ModifyElement(EquipWheelUI.ElementData element, ItemData item) { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Expected O, but got Unknown //IL_011c: Unknown result type (might be due to invalid IL or missing references) if (element == null || item == null) { return; } Transform val = element.m_go.transform.Find("magicItem"); if ((Object)(object)val != (Object)null) { Image component = ((Component)val).GetComponent<Image>(); if ((Object)(object)component != (Object)null) { ((Behaviour)component).enabled = false; } } Transform val2 = element.m_go.transform.Find("setItem"); if ((Object)(object)val2 != (Object)null) { Image component2 = ((Component)val2).GetComponent<Image>(); if ((Object)(object)component2 != (Object)null) { ((Behaviour)component2).enabled = false; } } Image val3 = (Image)CreateAndGetMagicItemBackgroundImage.Invoke(null, new object[3] { element.m_go, element.m_equiped.gameObject, true }); if ((bool)UseMagicBackground.Invoke(null, new object[1] { item })) { ((Behaviour)val3).enabled = true; val3.sprite = (Sprite)GetMagicItemBgSprite.Invoke(null, new object[0]); ((Graphic)val3).color = (Color)GetRarityColor.Invoke(null, new object[1] { item }); } Transform val4 = element.m_go.transform.Find("setItem"); if ((Object)(object)val4 != (Object)null && !string.IsNullOrEmpty(item.m_shared.m_setName)) { Image component3 = ((Component)val4).GetComponent<Image>(); ((Behaviour)component3).enabled = true; } } } [BepInPlugin("virtuacode.valheim.equipwheel", "Equip Wheel Mod", "1.5.7")] public class EquipWheel : BaseUnityPlugin, WheelManager.IWheel { private static Harmony harmony; public static ManualLogSource MyLogger = Logger.CreateLogSource(Assembly.GetExecutingAssembly().GetName().Name); 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> ToggleMenu; public static ConfigEntry<bool> ModEnabled; public static ConfigEntry<Color> HighlightColor; public static ConfigEntry<float> GuiScale; public static ConfigEntry<int> InventoryRow; public static ConfigEntry<bool> ItemFiltering; public static ConfigEntry<ItemType> ItemType1; public static ConfigEntry<ItemType> ItemType2; public static ConfigEntry<ItemType> ItemType3; public static ConfigEntry<ItemType> ItemType4; public static ConfigEntry<ItemType> ItemType5; public static ConfigEntry<ItemType> ItemType6; public static ConfigEntry<string> ItemRegex; public static ConfigEntry<string> ItemRegexIgnore; public static ConfigEntry<bool> ItemRegexCaseSensitive; private static EquipWheel instance; public static KeyCode replacedKey = (KeyCode)0; public static List<string> replacedButtons = new List<string>(); public static float JoyStickIgnoreTime = 0f; public static EquipGui Gui; public static Color GetHighlightColor { [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 !((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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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 ZInput.GetButtonDown("JoyHotbarLeft"); case WheelManager.DPadButton.Right: return ZInput.GetButtonDown("JoyHotbarRight"); case WheelManager.DPadButton.LeftOrRight: return ZInput.GetButtonDown("JoyHotbarRight") || ZInput.GetButtonDown("JoyHotbarLeft"); default: return ZInput.GetButtonDown("JoyHotbarRight") || ZInput.GetButtonDown("JoyHotbarLeft"); } } 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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 ZInput.GetButtonUp("JoyHotbarLeft"); case WheelManager.DPadButton.Right: return ZInput.GetButtonUp("JoyHotbarRight"); case WheelManager.DPadButton.LeftOrRight: return ZInput.GetButtonUp("JoyHotbarRight") || ZInput.GetButtonUp("JoyHotbarLeft"); default: return ZInput.GetButtonUp("JoyHotbarRight") || ZInput.GetButtonUp("JoyHotbarLeft"); } } 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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 ZInput.GetButton("JoyHotbarLeft"); case WheelManager.DPadButton.Right: return ZInput.GetButton("JoyHotbarRight"); case WheelManager.DPadButton.LeftOrRight: return ZInput.GetButton("JoyHotbarRight") || ZInput.GetButton("JoyHotbarLeft"); default: return ZInput.GetButton("JoyHotbarRight") || ZInput.GetButton("JoyHotbarLeft"); } } 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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Expected O, but got Unknown //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Expected O, but got Unknown instance = this; ModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ModEnabled", true, "Enable mod when value is true"); Hotkey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Input", "Hotkey", KeyboardShortcut.Deserialize("G"), "Hotkey for opening equip wheel menu"); HotkeyDPad = ((BaseUnityPlugin)this).Config.Bind<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", false, "When enabled use the sit button as hotkey (HotkeyDPad has to be set to None)"); TriggerOnRelease = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "TriggerOnRelease", true, "Releasing the Hotkey will equip/use the selected item"); TriggerOnClick = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "TriggerOnClick", false, "Click with left mouse button will equip/use the selected item"); ToggleMenu = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "ToggleMenu", false, "When enabled the equip wheel will toggle between hidden/visible when the hotkey was pressed"); HighlightColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Appereance", "HighlightColor", new Color(0.414f, 0.734f, 1f), "Color of the highlighted selection"); GuiScale = ((BaseUnityPlugin)this).Config.Bind<float>("Appereance", "GuiScale", 0.5f, "Scale factor of the user interface"); 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", 500, 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>())); 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", string.Empty, "Regex used for filtering items"); ItemRegexIgnore = ((BaseUnityPlugin)this).Config.Bind<string>("Misc", "ItemRegexIgnore", string.Empty, "Regex used for ignoring items"); ItemRegexCaseSensitive = ((BaseUnityPlugin)this).Config.Bind<bool>("Misc", "ItemRegexCaseSensitive", false, "When enabled the Regex will be case-sensitive"); if (!ModEnabled.Value) { LogWarn("Mod not loaded because it was disabled via config."); return; } if (IsDedicated()) { LogWarn("Mod not loaded because game instance is a dedicated server."); return; } harmony = Harmony.CreateAndPatchAll(typeof(Patcher), (string)null); WheelManager.AddWheel(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.UnpatchAll((string)null); } } 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); } } 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 EquipGui.visible; } public void Hide() { if (!((Object)(object)Gui == (Object)null)) { Gui.Hide(); } } public string GetName() { return Assembly.GetExecutingAssembly().GetName().Name; } float WheelManager.IWheel.JoyStickIgnoreTime() { return JoyStickIgnoreTime; } } public class EquipGui : MonoBehaviour { private EquipWheelUI ui; public AssetBundle assets; public static bool visible; public int toggleVisible; public static bool toggleDownWasPressed; private void Awake() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) LoadAssets(); GameObject val = assets.LoadAsset<GameObject>("assets/selectionwheel/selectionwheel.prefab"); RectTransform val2 = ((Component)this).gameObject.AddComponent<RectTransform>(); GameObject val3 = Object.Instantiate<GameObject>(val, new Vector3(0f, 0f, 0f), ((Component)this).transform.rotation, (Transform)(object)val2); ui = val3.AddComponent<EquipWheelUI>(); val3.SetActive(false); visible = false; assets.Unload(false); } private void Start() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) RectTransform component = ((Component)this).gameObject.GetComponent<RectTransform>(); component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; component.anchorMax = new Vector2(1f, 1f); component.anchorMin = new Vector2(0f, 0f); component.anchoredPosition = new Vector2(0f, 0f); if (!((Object)(object)Hud.instance == (Object)null)) { EquipWheel.TryHideHotkeyBar(); } } private void LoadAssets() { Assembly assembly = Assembly.GetAssembly(typeof(EquipWheel)); Stream manifestResourceStream = assembly.GetManifestResourceStream("EquipWheel.res.selectionwheel"); using MemoryStream memoryStream = new MemoryStream(); manifestResourceStream.CopyTo(memoryStream); assets = AssetBundle.LoadFromMemory(memoryStream.ToArray()); } public void Hide() { ((Component)ui).gameObject.SetActive(false); visible = false; toggleVisible = 0; } private void Update() { if (EquipWheel.ToggleMenu.Value) { HandleToggleEnabled(); } else { HandleToggleDisabled(); } } private void ReduceJoyStickIgnoreTime() { if (EquipWheel.JoyStickIgnoreTime > 0f) { EquipWheel.JoyStickIgnoreTime -= Time.deltaTime; } } private void HandlePressedHovering() { if (WheelManager.pressedOnHovering && ZInput.GetButtonUp("JoyUse")) { WheelManager.pressedOnHovering = false; WheelManager.hoverTextVisible = false; } else if (EquipWheel.IsShortcutDown && EquipWheel.IsUsingUseButton()) { WheelManager.pressedOnHovering = WheelManager.pressedOnHovering || WheelManager.hoverTextVisible; } } private void HandleToggleEnabled() { ReduceJoyStickIgnoreTime(); HandlePressedHovering(); if (!EquipWheel.CanOpenMenu) { Hide(); return; } if (toggleDownWasPressed) { if (EquipWheel.IsShortcutUp) { Hide(); toggleDownWasPressed = false; } return; } if (EquipWheel.IsShortcutDown && toggleVisible < 2) { toggleVisible++; } bool flag = EquipWheel.IsShortcutDown && toggleVisible == 2; if (EquipWheel.TriggerOnRelease.Value && flag && WheelManager.IsActive(EquipWheel.Instance)) { UseCurrentItem(); toggleDownWasPressed = true; } else if (toggleVisible > 0 && !flag) { if (!visible) { ((Component)ui).gameObject.SetActive(true); visible = true; WheelManager.Activate(EquipWheel.Instance); } if (EquipWheel.TriggerOnClick.Value && (Input.GetMouseButtonDown(0) || Input.GetKeyDown((KeyCode)330))) { UseCurrentItem(flash: true); } } else { Hide(); } } private void UseCurrentItem(bool flash = false) { if (ui.CurrentItem != null) { if (flash) { ui.Flash(); } Player localPlayer = Player.m_localPlayer; ((Humanoid)localPlayer).UseItem((Inventory)null, ui.CurrentItem, false); EquipWheel.JoyStickIgnoreTime = (float)EquipWheel.IgnoreJoyStickDuration.Value / 1000f; } } private void HandleToggleDisabled() { ReduceJoyStickIgnoreTime(); HandlePressedHovering(); if (!EquipWheel.CanOpenMenu) { Hide(); } else if (EquipWheel.TriggerOnRelease.Value && EquipWheel.IsShortcutUp) { UseCurrentItem(); Hide(); } else if ((EquipWheel.IsShortcutPressed && ZInput.IsGamepadActive()) || (EquipWheel.IsShortcutPressed && (EquipWheel.BestMatchPressed || EquipWheel.BestMatchDown))) { if (!visible) { ((Component)ui).gameObject.SetActive(true); visible = true; WheelManager.Activate(EquipWheel.Instance); } if (EquipWheel.TriggerOnClick.Value && (Input.GetMouseButtonDown(0) || Input.GetKeyDown((KeyCode)330))) { UseCurrentItem(flash: true); } } else { Hide(); } } } public class EquipWheelUI : MonoBehaviour { public class ElementData { public bool m_used; public GameObject m_go; public Image m_icon; public GuiBar m_durability; public TextMeshProUGUI m_amount; public GameObject m_equiped; public GameObject m_queued; public GameObject m_selection; } public readonly float ANGLE_STEP = 45f; public readonly float ITEM_DISTANCE = 295f; public readonly float ITEM_SCALE = 2f; public readonly float INNER_DIAMETER = 340f; public readonly float LENGTH_THRESHOLD = 0.1f; private GameObject cursor; private Text text; private GameObject highlight; private readonly ItemData[] items = (ItemData[])(object)new ItemData[8]; private HotkeyBar hotKeyBar; private Transform itemsRoot; private bool addedListener; private readonly List<ElementData> m_elements = new List<ElementData>(); private GameObject m_elementPrefab; private int previous = -1; public int Current { get { if ((!ZInput.IsGamepadActive() && MouseInCenter) || JoyStickInCenter || (ZInput.IsGamepadActive() && Lenght < (double)LENGTH_THRESHOLD)) { return -1; } int num = Mod((int)Mathf.Round((0f - Angle) / ANGLE_STEP), 8); if (num >= items.Length) { return -1; } return num; } } public bool JoyStickInCenter { get { if (EquipWheel.HotkeyDPad.Value == WheelManager.DPadButton.None) { float joyLeftStickX = ZInput.GetJoyLeftStickX(); float joyLeftStickY = ZInput.GetJoyLeftStickY(); return ZInput.IsGamepadActive() && joyLeftStickX == 0f && joyLeftStickY == 0f; } float joyRightStickX = ZInput.GetJoyRightStickX(); float joyRightStickY = ZInput.GetJoyRightStickY(); return ZInput.IsGamepadActive() && joyRightStickX == 0f && joyRightStickY == 0f; } } public ItemData CurrentItem { get { if (Current < 0) { return null; } return items[Current]; } } public bool MouseInCenter { get { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) float num = INNER_DIAMETER / 2f * ((Component)this).gameObject.transform.lossyScale.x; Vector3 val = Input.mousePosition - cursor.transform.position; return ((Vector3)(ref val)).magnitude <= num; } } public double Lenght { get { if (EquipWheel.HotkeyDPad.Value == WheelManager.DPadButton.None) { float joyLeftStickX = ZInput.GetJoyLeftStickX(); float joyLeftStickY = ZInput.GetJoyLeftStickY(); return Math.Sqrt(Math.Pow(joyLeftStickX, 2.0) + Math.Pow(joyLeftStickY, 2.0)); } float joyRightStickX = ZInput.GetJoyRightStickX(); float joyRightStickY = ZInput.GetJoyRightStickY(); return Math.Sqrt(Math.Pow(joyRightStickX, 2.0) + Math.Pow(joyRightStickY, 2.0)); } } public float Angle { get { //IL_008c: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) if (ZInput.IsGamepadActive()) { if (EquipWheel.HotkeyDPad.Value == WheelManager.DPadButton.None) { float joyLeftStickX = ZInput.GetJoyLeftStickX(); float num = 0f - ZInput.GetJoyLeftStickY(); if (joyLeftStickX != 0f || num != 0f) { return Mathf.Atan2(num, joyLeftStickX) * 57.29578f - 90f; } } else { float joyRightStickX = ZInput.GetJoyRightStickX(); float num2 = 0f - ZInput.GetJoyRightStickY(); if (joyRightStickX != 0f || num2 != 0f) { return Mathf.Atan2(num2, joyRightStickX) * 57.29578f - 90f; } } } Vector3 val = Input.mousePosition - cursor.transform.position; return Mathf.Atan2(val.y, val.x) * 57.29578f - 90f; } } public IEnumerator FlashCoroutine(float aTime) { Color color = EquipWheel.GetHighlightColor; for (float t = 0f; t < 1f; t += Time.deltaTime / aTime) { ((Graphic)highlight.GetComponent<Image>()).color = Color.Lerp(Color.white, color, t); yield return null; } } private int Mod(int a, int b) { return (a % b + b) % b; } public void Flash() { ((MonoBehaviour)this).StartCoroutine(FlashCoroutine(0.4f)); } private void Awake() { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) cursor = ((Component)((Component)this).transform.Find("Cursor")).gameObject; highlight = ((Component)((Component)this).transform.Find("Highlight")).gameObject; hotKeyBar = ((Component)((Component)Hud.instance).transform.Find("hudroot/HotKeyBar")).gameObject.GetComponent<HotkeyBar>(); m_elementPrefab = hotKeyBar.m_elementPrefab; itemsRoot = ((Component)this).transform.Find("Items"); Material material = ((Graphic)highlight.GetComponent<Image>()).material; material.SetFloat("_Degree", ANGLE_STEP); GameObject val = new GameObject("Text"); RectTransform val2 = val.AddComponent<RectTransform>(); ((Transform)val2).SetParent(((Component)this).transform); val2.sizeDelta = new Vector2(1000f, 100f); val2.anchoredPosition = new Vector2(0f, 450f); text = val.AddComponent<Text>(); ((Graphic)text).color = EquipWheel.GetHighlightColor; EquipWheel.HighlightColor.SettingChanged += delegate { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Graphic)text).color = EquipWheel.GetHighlightColor; }; text.alignment = (TextAnchor)1; text.fontSize = 60; text.supportRichText = true; Font[] array = Resources.FindObjectsOfTypeAll<Font>(); foreach (Font val3 in array) { if (((Object)val3).name == "AveriaSerifLibre-Bold") { text.font = val3; break; } } Outline val4 = val.AddComponent<Outline>(); ((Shadow)val4).effectDistance = new Vector2(1f, -1f); ((Shadow)val4).effectColor = Color.black; val.SetActive(false); } private void Start() { if (!addedListener) { Player localPlayer = Player.m_localPlayer; Inventory inventory = ((Humanoid)localPlayer).GetInventory(); inventory.m_onChanged = (Action)Delegate.Combine(inventory.m_onChanged, new Action(OnInventoryChanged)); addedListener = true; } } public void OnInventoryChanged() { if (EquipGui.visible) { UpdateItems(); UpdateIcons(Player.m_localPlayer, forceUpdate: true); } } private void UpdateItems() { //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Expected I4, but got Unknown //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Expected I4, but got Unknown //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Expected I4, but got Unknown //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Expected I4, but got Unknown //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Expected I4, but got Unknown //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Expected I4, but got Unknown //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.m_localPlayer == (Object)null) { return; } Inventory inventory = ((Humanoid)Player.m_localPlayer).GetInventory(); if (inventory == null) { return; } if (EquipWheel.ItemFiltering.Value) { List<ItemData> list = new List<ItemData>(); List<ItemData> list2 = new List<ItemData>(); foreach (ItemData allItem in inventory.GetAllItems()) { if (EquipWheel.ItemRegexIgnore.Value.Length > 0) { Regex regex = new Regex(EquipWheel.ItemRegexIgnore.Value, (!EquipWheel.ItemRegexCaseSensitive.Value) ? RegexOptions.IgnoreCase : RegexOptions.None); string input; if (EpicLootWrapper.instance != null) { Color itemColor = EpicLootWrapper.instance.GetItemColor(allItem); input = Localization.instance.Localize(EpicLootWrapper.instance.GetItemName(allItem, itemColor)); } else { input = Localization.instance.Localize(allItem.m_shared.m_name); } if (regex.IsMatch(input)) { continue; } } if (EquipWheel.ItemRegex.Value.Length > 0) { Regex regex2 = new Regex(EquipWheel.ItemRegex.Value, (!EquipWheel.ItemRegexCaseSensitive.Value) ? RegexOptions.IgnoreCase : RegexOptions.None); string input2; if (EpicLootWrapper.instance != null) { Color itemColor2 = EpicLootWrapper.instance.GetItemColor(allItem); input2 = Localization.instance.Localize(EpicLootWrapper.instance.GetItemName(allItem, itemColor2)); } else { input2 = Localization.instance.Localize(allItem.m_shared.m_name); } if (regex2.IsMatch(input2)) { list.Add(allItem); continue; } } ItemType itemType = allItem.m_shared.m_itemType; if (itemType == EquipWheel.ItemType1.Value || itemType == EquipWheel.ItemType2.Value || itemType == EquipWheel.ItemType3.Value || itemType == EquipWheel.ItemType4.Value || itemType == EquipWheel.ItemType5.Value || itemType == EquipWheel.ItemType6.Value) { list2.Add(allItem); } } ItemType[] types = (ItemType[])(object)new ItemType[6] { (ItemType)(int)EquipWheel.ItemType1.Value, (ItemType)(int)EquipWheel.ItemType2.Value, (ItemType)(int)EquipWheel.ItemType3.Value, (ItemType)(int)EquipWheel.ItemType4.Value, (ItemType)(int)EquipWheel.ItemType5.Value, (ItemType)(int)EquipWheel.ItemType6.Value }; list2.Sort((ItemData a, ItemData b) => Array.IndexOf(types, a.m_shared.m_itemType).CompareTo(Array.IndexOf(types, b.m_shared.m_itemType))); for (int num = 0; num < 8; num++) { items[num] = null; if (list.Count > num) { items[num] = list[num]; } else if (list2.Count > num - list.Count) { items[num] = list2[num - list.Count]; } } return; } for (int num2 = 0; num2 < 8; num2++) { items[num2] = null; ItemData itemAt = inventory.GetItemAt(num2, EquipWheel.InventoryRow.Value - 1); if (itemAt != null) { items[num2] = itemAt; } } } private void OnEnable() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) ((Graphic)highlight.GetComponent<Image>()).color = EquipWheel.GetHighlightColor; float value = EquipWheel.GuiScale.Value; ((Transform)((Component)this).GetComponent<RectTransform>()).localScale = new Vector3(value, value, value); EquipWheel.JoyStickIgnoreTime = 0f; UpdateItems(); UpdateIcons(Player.m_localPlayer, forceUpdate: true); Update(); } private void OnDisable() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) highlight.SetActive(false); Image[] componentsInChildren = cursor.GetComponentsInChildren<Image>(true); Image[] array = componentsInChildren; foreach (Image val in array) { ((Graphic)val).color = new Color(0f, 0f, 0f, 0.5f); if (((Object)((Component)val).gameObject).name == "Image") { ((Component)val).gameObject.SetActive(false); } } } private void Update() { //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_0247: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) if (Current != previous) { if (CurrentItem != null) { InventoryGui.instance.m_moveItemEffects.Create(((Component)this).transform.position, Quaternion.identity, (Transform)null, 1f, -1, default(ZDOID)); ((Component)text).gameObject.SetActive(true); if (EpicLootWrapper.instance != null) { Color color = EpicLootWrapper.instance.GetItemColor(CurrentItem); if (((Color)(ref color)).Equals(Color.white) || !EquipWheel.UseRarityColoring.Value) { color = EquipWheel.GetHighlightColor; } text.text = Localization.instance.Localize(EpicLootWrapper.instance.GetItemName(CurrentItem, color)); } else { text.text = Localization.instance.Localize(CurrentItem.m_shared.m_name); } } else { ((Component)text).gameObject.SetActive(false); } previous = Current; } highlight.SetActive(CurrentItem != null); Color color2 = (Color)((CurrentItem != null) ? EquipWheel.GetHighlightColor : new Color(0f, 0f, 0f, 0.5f)); if (CurrentItem != null && EpicLootWrapper.instance != null) { Color itemColor = EpicLootWrapper.instance.GetItemColor(CurrentItem); if (!((Color)(ref itemColor)).Equals(Color.white) && EquipWheel.UseRarityColoring.Value) { color2 = itemColor; ((Graphic)highlight.GetComponent<Image>()).color = color2; } else { ((Graphic)highlight.GetComponent<Image>()).color = EquipWheel.GetHighlightColor; } } Image[] componentsInChildren = cursor.GetComponentsInChildren<Image>(true); Image[] array = componentsInChildren; foreach (Image val in array) { ((Graphic)val).color = color2; if (((Object)((Component)val).gameObject).name == "Image") { ((Component)val).gameObject.SetActive(CurrentItem != null); } } cursor.transform.rotation = Quaternion.AngleAxis(Angle, Vector3.forward); float num = (float)Current * ANGLE_STEP; highlight.transform.rotation = Quaternion.AngleAxis(0f - num, Vector3.forward); UpdateIcons(Player.m_localPlayer); } private int CountItems(ItemData[] items) { int num = 0; foreach (ItemData val in items) { if (val != null) { num++; } } return num; } private void UpdateIcons(Player player, bool forceUpdate = false) { //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Unknown result type (might be due to invalid IL or missing references) //IL_043d: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)player) || ((Character)player).IsDead()) { foreach (ElementData element in m_elements) { Object.Destroy((Object)(object)element.m_go); } m_elements.Clear(); return; } if (m_elements.Count != CountItems(items) || forceUpdate) { foreach (ElementData element2 in m_elements) { Object.Destroy((Object)(object)element2.m_go); } m_elements.Clear(); for (int i = 0; i < items.Length; i++) { if (items[i] != null) { ElementData elementData = new ElementData(); elementData.m_go = Object.Instantiate<GameObject>(m_elementPrefab, itemsRoot); elementData.m_go.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 0.5f); float num = Mathf.Sin((float)i * ANGLE_STEP * ((float)Math.PI / 180f)) * ITEM_DISTANCE; float num2 = Mathf.Cos((float)i * ANGLE_STEP * ((float)Math.PI / 180f)) * ITEM_DISTANCE; elementData.m_go.transform.localScale = new Vector3(ITEM_SCALE, ITEM_SCALE, ITEM_SCALE); elementData.m_go.transform.localPosition = new Vector3(num, num2, 0f); ((TMP_Text)((Component)elementData.m_go.transform.Find("binding")).GetComponent<TextMeshProUGUI>()).text = (i + 1).ToString(); elementData.m_icon = ((Component)((Component)elementData.m_go.transform).transform.Find("icon")).GetComponent<Image>(); elementData.m_durability = ((Component)elementData.m_go.transform.Find("durability")).GetComponent<GuiBar>(); elementData.m_amount = ((Component)elementData.m_go.transform.Find("amount")).GetComponent<TextMeshProUGUI>(); elementData.m_equiped = ((Component)elementData.m_go.transform.Find("equiped")).gameObject; elementData.m_queued = ((Component)elementData.m_go.transform.Find("queued")).gameObject; elementData.m_selection = ((Component)elementData.m_go.transform.Find("selected")).gameObject; elementData.m_selection.SetActive(false); if (EquipWheel.InventoryRow.Value > 1 || EquipWheel.ItemFiltering.Value) { ((Behaviour)((Component)elementData.m_go.transform.Find("binding")).GetComponent<TextMeshProUGUI>()).enabled = false; } m_elements.Add(elementData); } } } foreach (ElementData element3 in m_elements) { element3.m_used = false; } int num3 = 0; for (int j = 0; j < items.Length; j++) { if (items[j] == null) { continue; } ItemData val = items[j]; ElementData elementData2 = m_elements[num3]; elementData2.m_used = true; ((Component)elementData2.m_icon).gameObject.SetActive(true); elementData2.m_icon.sprite = val.GetIcon(); ((Component)elementData2.m_durability).gameObject.SetActive(val.m_shared.m_useDurability); if (val.m_shared.m_useDurability) { if (val.m_durability <= 0f) { elementData2.m_durability.SetValue(1f); elementData2.m_durability.SetColor((Color)((!(Mathf.Sin(Time.time * 10f) > 0f)) ? new Color(0f, 0f, 0f, 0f) : Color.red)); } else { elementData2.m_durability.SetValue(val.GetDurabilityPercentage()); elementData2.m_durability.ResetColor(); } } elementData2.m_equiped.SetActive(val.m_equipped); elementData2.m_queued.SetActive(player.IsEquipActionQueued(val)); if (val.m_shared.m_maxStackSize > 1) { ((Component)elementData2.m_amount).gameObject.SetActive(true); ((TMP_Text)elementData2.m_amount).text = val.m_stack + "/" + val.m_shared.m_maxStackSize; } else { ((Component)elementData2.m_amount).gameObject.SetActive(false); } if (EpicLootWrapper.instance != null) { EpicLootWrapper.instance.ModifyElement(elementData2, val); } num3++; } for (int k = 0; k < m_elements.Count; k++) { ElementData elementData3 = m_elements[k]; if (!elementData3.m_used) { ((Component)elementData3.m_icon).gameObject.SetActive(false); ((Component)elementData3.m_durability).gameObject.SetActive(false); elementData3.m_equiped.SetActive(false); elementData3.m_queued.SetActive(false); ((Component)elementData3.m_amount).gameObject.SetActive(false); } } } } 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 || 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 (" + Assembly.GetExecutingAssembly().GetName().Name + ")"; if (!Object.op_Implicit((Object)(object)GameObject.Find(text))) { GameObject val = new GameObject(text); EquipWheel.Gui = val.AddComponent<EquipGui>(); 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; } } public sealed class WheelManager { public enum DPadButton { None, Left, Right, LeftOrRight } public interface IWheel { int GetKeyCountDown(); int GetKeyCountPressed(); bool IsVisible(); void Hide(); string GetName(); float JoyStickIgnoreTime(); } private static readonly HashSet<IWheel> wheels = new HashSet<IWheel>(); private static IWheel activeWheel; public static bool inventoryVisible = false; public static bool hoverTextVisible = false; public static bool pressedOnHovering = false; public static bool AnyVisible => wheels.Any((IWheel w) => w.IsVisible()); public static void Activate(IWheel wheel) { if (!wheel.IsVisible()) { return; } foreach (IWheel wheel2 in wheels) { if (!wheel.Equals(wheel2)) { wheel2.Hide(); } } activeWheel = wheel; } public static bool IsActive(IWheel wheel) { return wheel.Equals(activeWheel); } public static bool AddWheel(IWheel wheel) { return wheels.Add(wheel); } public static bool RemoveWheel(IWheel wheel) { return wheels.Remove(wheel); } public static bool BestMatchDown(IWheel wheel) { if (!wheels.Contains(wheel)) { return false; } IWheel obj = wheels.OrderByDescending((IWheel w) => w.GetKeyCountDown()).FirstOrDefault(); return wheel.Equals(obj); } public static bool BestMatchPressed(IWheel wheel) { if (!wheels.Contains(wheel)) { return false; } IWheel obj = wheels.OrderByDescending((IWheel w) => w.GetKeyCountPressed()).FirstOrDefault(); return wheel.Equals(obj); } public static float GetJoyStickIgnoreTime() { float num = 0f; foreach (IWheel wheel in wheels) { num += wheel.JoyStickIgnoreTime(); } return num; } }