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 MoreEquipWheels v1.5.7
EquipWheelFour.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.Configuration; using BepInEx.Logging; using EquipWheel; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: AssemblyTitle("EquipWheelFour")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("EquipWheelFour")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("8283404d-c1d8-467a-b657-db0cb63c8949")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = "")] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("1.0.0.0")] namespace EquipWheelFour; [BepInPlugin("virtuacode.valheim.equipwheelfour", "Equip Wheel Mod (EquipWheelFour)", "1.5.7")] public class EquipWheel : BaseUnityPlugin, IWheel { private static Harmony harmony; public static ManualLogSource MyLogger = Logger.CreateLogSource(Assembly.GetExecutingAssembly().GetName().Name); public static ConfigEntry<KeyboardShortcut> Hotkey; public static ConfigEntry<DPadButton> HotkeyDPad; public static ConfigEntry<bool> UseSitButton; public static ConfigEntry<bool> TriggerOnRelease; public static ConfigEntry<bool> TriggerOnClick; public static ConfigEntry<bool> ToggleMenu; public static ConfigEntry<bool> ModEnabled; public static ConfigEntry<Color> HighlightColor; public static ConfigEntry<float> GuiScale; public static ConfigEntry<int> InventoryRow; public static ConfigEntry<bool> ItemFiltering; public static ConfigEntry<ItemType> ItemType1; public static ConfigEntry<ItemType> ItemType2; public static ConfigEntry<ItemType> ItemType3; public static ConfigEntry<ItemType> ItemType4; public static ConfigEntry<ItemType> ItemType5; public static ConfigEntry<ItemType> ItemType6; public static ConfigEntry<string> ItemRegex; public static ConfigEntry<string> ItemRegexIgnore; public static ConfigEntry<bool> ItemRegexCaseSensitive; private static EquipWheel instance; public static KeyCode replacedKey = (KeyCode)0; public static List<string> replacedButtons = new List<string>(); public static float JoyStickIgnoreTime = 0f; public static EquipGui Gui; public static Color GetHighlightColor { [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((IWheel)(object)Instance); } } public static bool BestMatchDown { get { if ((Object)(object)Instance == (Object)null) { return false; } return WheelManager.BestMatchDown((IWheel)(object)Instance); } } public static bool IsShortcutDown { get { //IL_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) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected I4, but got Unknown if (ZInput.IsGamepadActive()) { DPadButton value = HotkeyDPad.Value; switch ((int)value) { case 0: if (UseSitButton.Value) { return ZInput.GetButtonDown("JoySit"); } return ZInput.GetButtonDown("JoyUse"); case 1: return ZInput.GetButtonDown("JoyHotbarLeft"); case 2: return ZInput.GetButtonDown("JoyHotbarRight"); case 3: return ZInput.GetButtonDown("JoyHotbarRight") || ZInput.GetButtonDown("JoyHotbarLeft"); default: return ZInput.GetButtonDown("JoyHotbarRight") || ZInput.GetButtonDown("JoyHotbarLeft"); } } KeyboardShortcut value2 = Hotkey.Value; KeyCode mainKey = ((KeyboardShortcut)(ref value2)).MainKey; KeyCode[] source = ((KeyboardShortcut)(ref value2)).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) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected I4, but got Unknown if (ZInput.IsGamepadActive()) { DPadButton value = HotkeyDPad.Value; switch ((int)value) { case 0: if (UseSitButton.Value) { return ZInput.GetButtonUp("JoySit"); } return ZInput.GetButtonUp("JoyUse"); case 1: return ZInput.GetButtonUp("JoyHotbarLeft"); case 2: return ZInput.GetButtonUp("JoyHotbarRight"); case 3: return ZInput.GetButtonUp("JoyHotbarRight") || ZInput.GetButtonUp("JoyHotbarLeft"); default: return ZInput.GetButtonUp("JoyHotbarRight") || ZInput.GetButtonUp("JoyHotbarLeft"); } } KeyboardShortcut value2 = Hotkey.Value; KeyCode mainKey = ((KeyboardShortcut)(ref value2)).MainKey; KeyCode[] source = ((KeyboardShortcut)(ref value2)).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) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected I4, but got Unknown if (ZInput.IsGamepadActive()) { DPadButton value = HotkeyDPad.Value; switch ((int)value) { case 0: if (UseSitButton.Value) { return ZInput.GetButton("JoySit"); } return ZInput.GetButton("JoyUse"); case 1: return ZInput.GetButton("JoyHotbarLeft"); case 2: return ZInput.GetButton("JoyHotbarRight"); case 3: return ZInput.GetButton("JoyHotbarRight") || ZInput.GetButton("JoyHotbarLeft"); default: return ZInput.GetButton("JoyHotbarRight") || ZInput.GetButton("JoyHotbarLeft"); } } KeyboardShortcut value2 = Hotkey.Value; KeyCode mainKey = ((KeyboardShortcut)(ref value2)).MainKey; KeyCode[] source = ((KeyboardShortcut)(ref value2)).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() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) return ZInput.IsGamepadActive() && (int)HotkeyDPad.Value == 0 && !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_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Expected O, but got Unknown instance = this; ModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ModEnabled", true, "Enable mod when value is true"); Hotkey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Input", "Hotkey", KeyboardShortcut.Deserialize("G"), "Hotkey for opening equip wheel menu"); HotkeyDPad = ((BaseUnityPlugin)this).Config.Bind<DPadButton>("Input", "HotkeyDPad", (DPadButton)0, "Hotkey on the D-Pad (None, Left, Right or LeftOrRight)"); UseSitButton = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "UseSitButton", false, "When enabled use the sit button as hotkey (HotkeyDPad has to be set to None)"); TriggerOnRelease = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "TriggerOnRelease", true, "Releasing the Hotkey will equip/use the selected item"); TriggerOnClick = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "TriggerOnClick", false, "Click with left mouse button will equip/use the selected item"); ToggleMenu = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "ToggleMenu", false, "When enabled the equip wheel will toggle between hidden/visible when the hotkey was pressed"); HighlightColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Appereance", "HighlightColor", new Color(0.414f, 0.734f, 1f), "Color of the highlighted selection"); GuiScale = ((BaseUnityPlugin)this).Config.Bind<float>("Appereance", "GuiScale", 0.5f, "Scale factor of the user interface"); InventoryRow = ((BaseUnityPlugin)this).Config.Bind<int>("Misc", "InventoryRow", 1, new ConfigDescription("Row of the inventory that should be used for the equip wheel", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 4), 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((IWheel)(object)this); Log(((object)this).GetType().Namespace + " Loaded!"); } private void OnDestroy() { WheelManager.RemoveWheel((IWheel)(object)this); if (harmony != null) { harmony.UnpatchAll((string)null); } } public static void TryHideHotkeyBar() { } public static void ParseNames(string value, ref string[] arr) { if ((Object)(object)ObjectDB.instance == (Object)null) { return; } string[] array = ParseTokens(value); List<string> list = new List<string>(); string[] array2 = array; foreach (string text in array2) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(text); if ((Object)(object)itemPrefab != (Object)null) { ItemDrop component = itemPrefab.GetComponent<ItemDrop>(); list.Add(component.m_itemData.m_shared.m_name); } } arr = list.Distinct().ToArray(); } public static string[] ParseTokens(string value) { char[] separator = new char[5] { ' ', ',', '.', ':', '\t' }; return value.Split(separator, StringSplitOptions.RemoveEmptyEntries); } public int GetKeyCount(bool pressed = false) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_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 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((IWheel)(object)EquipWheel.Instance)) { UseCurrentItem(); toggleDownWasPressed = true; } else if (toggleVisible > 0 && !flag) { if (!visible) { ((Component)ui).gameObject.SetActive(true); visible = true; WheelManager.Activate((IWheel)(object)EquipWheel.Instance); } if (EquipWheel.TriggerOnClick.Value && (Input.GetMouseButtonDown(0) || Input.GetKeyDown((KeyCode)330))) { UseCurrentItem(flash: true); } } else { Hide(); } } private void UseCurrentItem(bool flash = false) { if (ui.CurrentItem != null) { if (flash) { ui.Flash(); } 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((IWheel)(object)EquipWheel.Instance); } if (EquipWheel.TriggerOnClick.Value && (Input.GetMouseButtonDown(0) || Input.GetKeyDown((KeyCode)330))) { UseCurrentItem(flash: true); } } else { Hide(); } } } public class EquipWheelUI : MonoBehaviour { public readonly float ANGLE_STEP = 45f; public readonly float ITEM_DISTANCE = 295f; public readonly float ITEM_SCALE = 2f; public readonly float INNER_DIAMETER = 340f; public readonly float LENGTH_THRESHOLD = 0.1f; private GameObject cursor; private Text text; private GameObject highlight; private readonly ItemData[] items = (ItemData[])(object)new ItemData[8]; private HotkeyBar hotKeyBar; private Transform itemsRoot; private bool addedListener; private readonly List<ElementData> m_elements = new List<ElementData>(); private GameObject m_elementPrefab; private int previous = -1; public int Current { get { if ((!ZInput.IsGamepadActive() && MouseInCenter) || JoyStickInCenter || (ZInput.IsGamepadActive() && Lenght < (double)LENGTH_THRESHOLD)) { return -1; } int num = Mod((int)Mathf.Round((0f - Angle) / ANGLE_STEP), 8); if (num >= items.Length) { return -1; } return num; } } public bool JoyStickInCenter { get { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if ((int)EquipWheel.HotkeyDPad.Value == 0) { float joyLeftStickX = ZInput.GetJoyLeftStickX(); 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 { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if ((int)EquipWheel.HotkeyDPad.Value == 0) { 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) //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (ZInput.IsGamepadActive()) { if ((int)EquipWheel.HotkeyDPad.Value == 0) { float joyLeftStickX = ZInput.GetJoyLeftStickX(); 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 val = EpicLootWrapper.instance.GetItemColor(CurrentItem); if (((Color)(ref val)).Equals(Color.white) || !EquipWheel.UseRarityColoring.Value) { val = EquipWheel.GetHighlightColor; } text.text = Localization.instance.Localize(EpicLootWrapper.instance.GetItemName(CurrentItem, val)); } else { text.text = Localization.instance.Localize(CurrentItem.m_shared.m_name); } } else { ((Component)text).gameObject.SetActive(false); } previous = Current; } highlight.SetActive(CurrentItem != null); Color color = (Color)((CurrentItem != null) ? 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) { color = itemColor; ((Graphic)highlight.GetComponent<Image>()).color = color; } else { ((Graphic)highlight.GetComponent<Image>()).color = EquipWheel.GetHighlightColor; } } Image[] componentsInChildren = cursor.GetComponentsInChildren<Image>(true); Image[] array = componentsInChildren; foreach (Image val2 in array) { ((Graphic)val2).color = color; if (((Object)((Component)val2).gameObject).name == "Image") { ((Component)val2).gameObject.SetActive(CurrentItem != null); } } cursor.transform.rotation = Quaternion.AngleAxis(Angle, Vector3.forward); float num = (float)Current * ANGLE_STEP; highlight.transform.rotation = Quaternion.AngleAxis(0f - num, Vector3.forward); UpdateIcons(Player.m_localPlayer); } private int CountItems(ItemData[] items) { int num = 0; foreach (ItemData val in items) { if (val != null) { num++; } } return num; } private void UpdateIcons(Player player, bool forceUpdate = false) { //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown //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 val = new ElementData(); val.m_go = Object.Instantiate<GameObject>(m_elementPrefab, itemsRoot); val.m_go.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 0.5f); float num = Mathf.Sin((float)i * ANGLE_STEP * ((float)Math.PI / 180f)) * ITEM_DISTANCE; float num2 = Mathf.Cos((float)i * ANGLE_STEP * ((float)Math.PI / 180f)) * ITEM_DISTANCE; val.m_go.transform.localScale = new Vector3(ITEM_SCALE, ITEM_SCALE, ITEM_SCALE); val.m_go.transform.localPosition = new Vector3(num, num2, 0f); ((TMP_Text)((Component)val.m_go.transform.Find("binding")).GetComponent<TextMeshProUGUI>()).text = (i + 1).ToString(); val.m_icon = ((Component)((Component)val.m_go.transform).transform.Find("icon")).GetComponent<Image>(); val.m_durability = ((Component)val.m_go.transform.Find("durability")).GetComponent<GuiBar>(); val.m_amount = ((Component)val.m_go.transform.Find("amount")).GetComponent<TextMeshProUGUI>(); val.m_equiped = ((Component)val.m_go.transform.Find("equiped")).gameObject; val.m_queued = ((Component)val.m_go.transform.Find("queued")).gameObject; val.m_selection = ((Component)val.m_go.transform.Find("selected")).gameObject; val.m_selection.SetActive(false); if (EquipWheel.InventoryRow.Value > 1 || EquipWheel.ItemFiltering.Value) { ((Behaviour)((Component)val.m_go.transform.Find("binding")).GetComponent<TextMeshProUGUI>()).enabled = false; } m_elements.Add(val); } } } foreach (ElementData element3 in m_elements) { element3.m_used = false; } int num3 = 0; for (int j = 0; j < items.Length; j++) { if (items[j] == null) { continue; } ItemData val2 = items[j]; ElementData val3 = m_elements[num3]; val3.m_used = true; ((Component)val3.m_icon).gameObject.SetActive(true); val3.m_icon.sprite = val2.GetIcon(); ((Component)val3.m_durability).gameObject.SetActive(val2.m_shared.m_useDurability); if (val2.m_shared.m_useDurability) { if (val2.m_durability <= 0f) { val3.m_durability.SetValue(1f); val3.m_durability.SetColor((Color)((!(Mathf.Sin(Time.time * 10f) > 0f)) ? new Color(0f, 0f, 0f, 0f) : Color.red)); } else { val3.m_durability.SetValue(val2.GetDurabilityPercentage()); val3.m_durability.ResetColor(); } } val3.m_equiped.SetActive(val2.m_equipped); val3.m_queued.SetActive(player.IsEquipActionQueued(val2)); if (val2.m_shared.m_maxStackSize > 1) { ((Component)val3.m_amount).gameObject.SetActive(true); ((TMP_Text)val3.m_amount).text = val2.m_stack + "/" + val2.m_shared.m_maxStackSize; } else { ((Component)val3.m_amount).gameObject.SetActive(false); } if (EpicLootWrapper.instance != null) { EpicLootWrapper.instance.ModifyElement(val3, val2); } num3++; } for (int k = 0; k < m_elements.Count; k++) { ElementData val4 = m_elements[k]; if (!val4.m_used) { ((Component)val4.m_icon).gameObject.SetActive(false); ((Component)val4.m_durability).gameObject.SetActive(false); val4.m_equiped.SetActive(false); val4.m_queued.SetActive(false); ((Component)val4.m_amount).gameObject.SetActive(false); } } } } public class Patcher { public static readonly KeyCode[] NUMBERS; [HarmonyPatch(typeof(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) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)EquipWheel.Instance == (Object)null) { return true; } if (EquipWheel.HotkeyDPad != null && (int)EquipWheel.HotkeyDPad.Value == 0) { return true; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null) { 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() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && EquipWheel.UseSitButton.Value && (int)EquipWheel.HotkeyDPad.Value == 0 && (ZInput.GetButtonDown("JoySit") || ZInput.GetButtonUp("JoySit"))) { 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; } }
EquipWheelThree.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.Configuration; using BepInEx.Logging; using EquipWheel; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: AssemblyTitle("EquipWheelThree")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("EquipWheelThree")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("7a9092d4-c0ba-41d7-8ca0-71d3302f8469")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = "")] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("1.0.0.0")] namespace EquipWheelThree; [BepInPlugin("virtuacode.valheim.equipwheelthree", "Equip Wheel Mod (EquipWheelThree)", "1.5.7")] public class EquipWheel : BaseUnityPlugin, IWheel { private static Harmony harmony; public static ManualLogSource MyLogger = Logger.CreateLogSource(Assembly.GetExecutingAssembly().GetName().Name); public static ConfigEntry<KeyboardShortcut> Hotkey; public static ConfigEntry<DPadButton> HotkeyDPad; public static ConfigEntry<bool> UseSitButton; public static ConfigEntry<bool> TriggerOnRelease; public static ConfigEntry<bool> TriggerOnClick; public static ConfigEntry<bool> ToggleMenu; public static ConfigEntry<bool> ModEnabled; public static ConfigEntry<Color> HighlightColor; public static ConfigEntry<float> GuiScale; public static ConfigEntry<int> InventoryRow; public static ConfigEntry<bool> ItemFiltering; public static ConfigEntry<ItemType> ItemType1; public static ConfigEntry<ItemType> ItemType2; public static ConfigEntry<ItemType> ItemType3; public static ConfigEntry<ItemType> ItemType4; public static ConfigEntry<ItemType> ItemType5; public static ConfigEntry<ItemType> ItemType6; public static ConfigEntry<string> ItemRegex; public static ConfigEntry<string> ItemRegexIgnore; public static ConfigEntry<bool> ItemRegexCaseSensitive; private static EquipWheel instance; public static KeyCode replacedKey = (KeyCode)0; public static List<string> replacedButtons = new List<string>(); public static float JoyStickIgnoreTime = 0f; public static EquipGui Gui; public static Color GetHighlightColor { [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((IWheel)(object)Instance); } } public static bool BestMatchDown { get { if ((Object)(object)Instance == (Object)null) { return false; } return WheelManager.BestMatchDown((IWheel)(object)Instance); } } public static bool IsShortcutDown { get { //IL_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) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected I4, but got Unknown if (ZInput.IsGamepadActive()) { DPadButton value = HotkeyDPad.Value; switch ((int)value) { case 0: if (UseSitButton.Value) { return ZInput.GetButtonDown("JoySit"); } return ZInput.GetButtonDown("JoyUse"); case 1: return ZInput.GetButtonDown("JoyHotbarLeft"); case 2: return ZInput.GetButtonDown("JoyHotbarRight"); case 3: return ZInput.GetButtonDown("JoyHotbarRight") || ZInput.GetButtonDown("JoyHotbarLeft"); default: return ZInput.GetButtonDown("JoyHotbarRight") || ZInput.GetButtonDown("JoyHotbarLeft"); } } KeyboardShortcut value2 = Hotkey.Value; KeyCode mainKey = ((KeyboardShortcut)(ref value2)).MainKey; KeyCode[] source = ((KeyboardShortcut)(ref value2)).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) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected I4, but got Unknown if (ZInput.IsGamepadActive()) { DPadButton value = HotkeyDPad.Value; switch ((int)value) { case 0: if (UseSitButton.Value) { return ZInput.GetButtonUp("JoySit"); } return ZInput.GetButtonUp("JoyUse"); case 1: return ZInput.GetButtonUp("JoyHotbarLeft"); case 2: return ZInput.GetButtonUp("JoyHotbarRight"); case 3: return ZInput.GetButtonUp("JoyHotbarRight") || ZInput.GetButtonUp("JoyHotbarLeft"); default: return ZInput.GetButtonUp("JoyHotbarRight") || ZInput.GetButtonUp("JoyHotbarLeft"); } } KeyboardShortcut value2 = Hotkey.Value; KeyCode mainKey = ((KeyboardShortcut)(ref value2)).MainKey; KeyCode[] source = ((KeyboardShortcut)(ref value2)).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) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected I4, but got Unknown if (ZInput.IsGamepadActive()) { DPadButton value = HotkeyDPad.Value; switch ((int)value) { case 0: if (UseSitButton.Value) { return ZInput.GetButton("JoySit"); } return ZInput.GetButton("JoyUse"); case 1: return ZInput.GetButton("JoyHotbarLeft"); case 2: return ZInput.GetButton("JoyHotbarRight"); case 3: return ZInput.GetButton("JoyHotbarRight") || ZInput.GetButton("JoyHotbarLeft"); default: return ZInput.GetButton("JoyHotbarRight") || ZInput.GetButton("JoyHotbarLeft"); } } KeyboardShortcut value2 = Hotkey.Value; KeyCode mainKey = ((KeyboardShortcut)(ref value2)).MainKey; KeyCode[] source = ((KeyboardShortcut)(ref value2)).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() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) return ZInput.IsGamepadActive() && (int)HotkeyDPad.Value == 0 && !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_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Expected O, but got Unknown instance = this; ModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ModEnabled", true, "Enable mod when value is true"); Hotkey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Input", "Hotkey", KeyboardShortcut.Deserialize("G"), "Hotkey for opening equip wheel menu"); HotkeyDPad = ((BaseUnityPlugin)this).Config.Bind<DPadButton>("Input", "HotkeyDPad", (DPadButton)0, "Hotkey on the D-Pad (None, Left, Right or LeftOrRight)"); UseSitButton = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "UseSitButton", false, "When enabled use the sit button as hotkey (HotkeyDPad has to be set to None)"); TriggerOnRelease = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "TriggerOnRelease", true, "Releasing the Hotkey will equip/use the selected item"); TriggerOnClick = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "TriggerOnClick", false, "Click with left mouse button will equip/use the selected item"); ToggleMenu = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "ToggleMenu", false, "When enabled the equip wheel will toggle between hidden/visible when the hotkey was pressed"); HighlightColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Appereance", "HighlightColor", new Color(0.414f, 0.734f, 1f), "Color of the highlighted selection"); GuiScale = ((BaseUnityPlugin)this).Config.Bind<float>("Appereance", "GuiScale", 0.5f, "Scale factor of the user interface"); InventoryRow = ((BaseUnityPlugin)this).Config.Bind<int>("Misc", "InventoryRow", 1, new ConfigDescription("Row of the inventory that should be used for the equip wheel", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 4), 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((IWheel)(object)this); Log(((object)this).GetType().Namespace + " Loaded!"); } private void OnDestroy() { WheelManager.RemoveWheel((IWheel)(object)this); if (harmony != null) { harmony.UnpatchAll((string)null); } } public static void TryHideHotkeyBar() { } public static void ParseNames(string value, ref string[] arr) { if ((Object)(object)ObjectDB.instance == (Object)null) { return; } string[] array = ParseTokens(value); List<string> list = new List<string>(); string[] array2 = array; foreach (string text in array2) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(text); if ((Object)(object)itemPrefab != (Object)null) { ItemDrop component = itemPrefab.GetComponent<ItemDrop>(); list.Add(component.m_itemData.m_shared.m_name); } } arr = list.Distinct().ToArray(); } public static string[] ParseTokens(string value) { char[] separator = new char[5] { ' ', ',', '.', ':', '\t' }; return value.Split(separator, StringSplitOptions.RemoveEmptyEntries); } public int GetKeyCount(bool pressed = false) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_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 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((IWheel)(object)EquipWheel.Instance)) { UseCurrentItem(); toggleDownWasPressed = true; } else if (toggleVisible > 0 && !flag) { if (!visible) { ((Component)ui).gameObject.SetActive(true); visible = true; WheelManager.Activate((IWheel)(object)EquipWheel.Instance); } if (EquipWheel.TriggerOnClick.Value && (Input.GetMouseButtonDown(0) || Input.GetKeyDown((KeyCode)330))) { UseCurrentItem(flash: true); } } else { Hide(); } } private void UseCurrentItem(bool flash = false) { if (ui.CurrentItem != null) { if (flash) { ui.Flash(); } 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((IWheel)(object)EquipWheel.Instance); } if (EquipWheel.TriggerOnClick.Value && (Input.GetMouseButtonDown(0) || Input.GetKeyDown((KeyCode)330))) { UseCurrentItem(flash: true); } } else { Hide(); } } } public class EquipWheelUI : MonoBehaviour { public readonly float ANGLE_STEP = 45f; public readonly float ITEM_DISTANCE = 295f; public readonly float ITEM_SCALE = 2f; public readonly float INNER_DIAMETER = 340f; public readonly float LENGTH_THRESHOLD = 0.1f; private GameObject cursor; private Text text; private GameObject highlight; private readonly ItemData[] items = (ItemData[])(object)new ItemData[8]; private HotkeyBar hotKeyBar; private Transform itemsRoot; private bool addedListener; private readonly List<ElementData> m_elements = new List<ElementData>(); private GameObject m_elementPrefab; private int previous = -1; public int Current { get { if ((!ZInput.IsGamepadActive() && MouseInCenter) || JoyStickInCenter || (ZInput.IsGamepadActive() && Lenght < (double)LENGTH_THRESHOLD)) { return -1; } int num = Mod((int)Mathf.Round((0f - Angle) / ANGLE_STEP), 8); if (num >= items.Length) { return -1; } return num; } } public bool JoyStickInCenter { get { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if ((int)EquipWheel.HotkeyDPad.Value == 0) { float joyLeftStickX = ZInput.GetJoyLeftStickX(); 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 { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if ((int)EquipWheel.HotkeyDPad.Value == 0) { 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) //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (ZInput.IsGamepadActive()) { if ((int)EquipWheel.HotkeyDPad.Value == 0) { float joyLeftStickX = ZInput.GetJoyLeftStickX(); 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 val = EpicLootWrapper.instance.GetItemColor(CurrentItem); if (((Color)(ref val)).Equals(Color.white) || !EquipWheel.UseRarityColoring.Value) { val = EquipWheel.GetHighlightColor; } text.text = Localization.instance.Localize(EpicLootWrapper.instance.GetItemName(CurrentItem, val)); } else { text.text = Localization.instance.Localize(CurrentItem.m_shared.m_name); } } else { ((Component)text).gameObject.SetActive(false); } previous = Current; } highlight.SetActive(CurrentItem != null); Color color = (Color)((CurrentItem != null) ? 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) { color = itemColor; ((Graphic)highlight.GetComponent<Image>()).color = color; } else { ((Graphic)highlight.GetComponent<Image>()).color = EquipWheel.GetHighlightColor; } } Image[] componentsInChildren = cursor.GetComponentsInChildren<Image>(true); Image[] array = componentsInChildren; foreach (Image val2 in array) { ((Graphic)val2).color = color; if (((Object)((Component)val2).gameObject).name == "Image") { ((Component)val2).gameObject.SetActive(CurrentItem != null); } } cursor.transform.rotation = Quaternion.AngleAxis(Angle, Vector3.forward); float num = (float)Current * ANGLE_STEP; highlight.transform.rotation = Quaternion.AngleAxis(0f - num, Vector3.forward); UpdateIcons(Player.m_localPlayer); } private int CountItems(ItemData[] items) { int num = 0; foreach (ItemData val in items) { if (val != null) { num++; } } return num; } private void UpdateIcons(Player player, bool forceUpdate = false) { //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown //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 val = new ElementData(); val.m_go = Object.Instantiate<GameObject>(m_elementPrefab, itemsRoot); val.m_go.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 0.5f); float num = Mathf.Sin((float)i * ANGLE_STEP * ((float)Math.PI / 180f)) * ITEM_DISTANCE; float num2 = Mathf.Cos((float)i * ANGLE_STEP * ((float)Math.PI / 180f)) * ITEM_DISTANCE; val.m_go.transform.localScale = new Vector3(ITEM_SCALE, ITEM_SCALE, ITEM_SCALE); val.m_go.transform.localPosition = new Vector3(num, num2, 0f); ((TMP_Text)((Component)val.m_go.transform.Find("binding")).GetComponent<TextMeshProUGUI>()).text = (i + 1).ToString(); val.m_icon = ((Component)((Component)val.m_go.transform).transform.Find("icon")).GetComponent<Image>(); val.m_durability = ((Component)val.m_go.transform.Find("durability")).GetComponent<GuiBar>(); val.m_amount = ((Component)val.m_go.transform.Find("amount")).GetComponent<TextMeshProUGUI>(); val.m_equiped = ((Component)val.m_go.transform.Find("equiped")).gameObject; val.m_queued = ((Component)val.m_go.transform.Find("queued")).gameObject; val.m_selection = ((Component)val.m_go.transform.Find("selected")).gameObject; val.m_selection.SetActive(false); if (EquipWheel.InventoryRow.Value > 1 || EquipWheel.ItemFiltering.Value) { ((Behaviour)((Component)val.m_go.transform.Find("binding")).GetComponent<TextMeshProUGUI>()).enabled = false; } m_elements.Add(val); } } } foreach (ElementData element3 in m_elements) { element3.m_used = false; } int num3 = 0; for (int j = 0; j < items.Length; j++) { if (items[j] == null) { continue; } ItemData val2 = items[j]; ElementData val3 = m_elements[num3]; val3.m_used = true; ((Component)val3.m_icon).gameObject.SetActive(true); val3.m_icon.sprite = val2.GetIcon(); ((Component)val3.m_durability).gameObject.SetActive(val2.m_shared.m_useDurability); if (val2.m_shared.m_useDurability) { if (val2.m_durability <= 0f) { val3.m_durability.SetValue(1f); val3.m_durability.SetColor((Color)((!(Mathf.Sin(Time.time * 10f) > 0f)) ? new Color(0f, 0f, 0f, 0f) : Color.red)); } else { val3.m_durability.SetValue(val2.GetDurabilityPercentage()); val3.m_durability.ResetColor(); } } val3.m_equiped.SetActive(val2.m_equipped); val3.m_queued.SetActive(player.IsEquipActionQueued(val2)); if (val2.m_shared.m_maxStackSize > 1) { ((Component)val3.m_amount).gameObject.SetActive(true); ((TMP_Text)val3.m_amount).text = val2.m_stack + "/" + val2.m_shared.m_maxStackSize; } else { ((Component)val3.m_amount).gameObject.SetActive(false); } if (EpicLootWrapper.instance != null) { EpicLootWrapper.instance.ModifyElement(val3, val2); } num3++; } for (int k = 0; k < m_elements.Count; k++) { ElementData val4 = m_elements[k]; if (!val4.m_used) { ((Component)val4.m_icon).gameObject.SetActive(false); ((Component)val4.m_durability).gameObject.SetActive(false); val4.m_equiped.SetActive(false); val4.m_queued.SetActive(false); ((Component)val4.m_amount).gameObject.SetActive(false); } } } } public class Patcher { public static readonly KeyCode[] NUMBERS; [HarmonyPatch(typeof(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) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)EquipWheel.Instance == (Object)null) { return true; } if (EquipWheel.HotkeyDPad != null && (int)EquipWheel.HotkeyDPad.Value == 0) { return true; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null) { 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() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && EquipWheel.UseSitButton.Value && (int)EquipWheel.HotkeyDPad.Value == 0 && (ZInput.GetButtonDown("JoySit") || ZInput.GetButtonUp("JoySit"))) { 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; } }
EquipWheelTwo.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.Configuration; using BepInEx.Logging; using EquipWheel; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: AssemblyTitle("EquipWheelTwo")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("EquipWheelTwo")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("7a967d55-e853-4fc7-9040-7913122fb3b5")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = "")] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("1.0.0.0")] namespace EquipWheelTwo; [BepInPlugin("virtuacode.valheim.equipwheeltwo", "Equip Wheel Mod (EquipWheelTwo)", "1.5.7")] public class EquipWheel : BaseUnityPlugin, IWheel { private static Harmony harmony; public static ManualLogSource MyLogger = Logger.CreateLogSource(Assembly.GetExecutingAssembly().GetName().Name); public static ConfigEntry<KeyboardShortcut> Hotkey; public static ConfigEntry<DPadButton> HotkeyDPad; public static ConfigEntry<bool> UseSitButton; public static ConfigEntry<bool> TriggerOnRelease; public static ConfigEntry<bool> TriggerOnClick; public static ConfigEntry<bool> ToggleMenu; public static ConfigEntry<bool> ModEnabled; public static ConfigEntry<Color> HighlightColor; public static ConfigEntry<float> GuiScale; public static ConfigEntry<int> InventoryRow; public static ConfigEntry<bool> ItemFiltering; public static ConfigEntry<ItemType> ItemType1; public static ConfigEntry<ItemType> ItemType2; public static ConfigEntry<ItemType> ItemType3; public static ConfigEntry<ItemType> ItemType4; public static ConfigEntry<ItemType> ItemType5; public static ConfigEntry<ItemType> ItemType6; public static ConfigEntry<string> ItemRegex; public static ConfigEntry<string> ItemRegexIgnore; public static ConfigEntry<bool> ItemRegexCaseSensitive; private static EquipWheel instance; public static KeyCode replacedKey = (KeyCode)0; public static List<string> replacedButtons = new List<string>(); public static float JoyStickIgnoreTime = 0f; public static EquipGui Gui; public static Color GetHighlightColor { [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((IWheel)(object)Instance); } } public static bool BestMatchDown { get { if ((Object)(object)Instance == (Object)null) { return false; } return WheelManager.BestMatchDown((IWheel)(object)Instance); } } public static bool IsShortcutDown { get { //IL_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) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected I4, but got Unknown if (ZInput.IsGamepadActive()) { DPadButton value = HotkeyDPad.Value; switch ((int)value) { case 0: if (UseSitButton.Value) { return ZInput.GetButtonDown("JoySit"); } return ZInput.GetButtonDown("JoyUse"); case 1: return ZInput.GetButtonDown("JoyHotbarLeft"); case 2: return ZInput.GetButtonDown("JoyHotbarRight"); case 3: return ZInput.GetButtonDown("JoyHotbarRight") || ZInput.GetButtonDown("JoyHotbarLeft"); default: return ZInput.GetButtonDown("JoyHotbarRight") || ZInput.GetButtonDown("JoyHotbarLeft"); } } KeyboardShortcut value2 = Hotkey.Value; KeyCode mainKey = ((KeyboardShortcut)(ref value2)).MainKey; KeyCode[] source = ((KeyboardShortcut)(ref value2)).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) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected I4, but got Unknown if (ZInput.IsGamepadActive()) { DPadButton value = HotkeyDPad.Value; switch ((int)value) { case 0: if (UseSitButton.Value) { return ZInput.GetButtonUp("JoySit"); } return ZInput.GetButtonUp("JoyUse"); case 1: return ZInput.GetButtonUp("JoyHotbarLeft"); case 2: return ZInput.GetButtonUp("JoyHotbarRight"); case 3: return ZInput.GetButtonUp("JoyHotbarRight") || ZInput.GetButtonUp("JoyHotbarLeft"); default: return ZInput.GetButtonUp("JoyHotbarRight") || ZInput.GetButtonUp("JoyHotbarLeft"); } } KeyboardShortcut value2 = Hotkey.Value; KeyCode mainKey = ((KeyboardShortcut)(ref value2)).MainKey; KeyCode[] source = ((KeyboardShortcut)(ref value2)).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) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected I4, but got Unknown if (ZInput.IsGamepadActive()) { DPadButton value = HotkeyDPad.Value; switch ((int)value) { case 0: if (UseSitButton.Value) { return ZInput.GetButton("JoySit"); } return ZInput.GetButton("JoyUse"); case 1: return ZInput.GetButton("JoyHotbarLeft"); case 2: return ZInput.GetButton("JoyHotbarRight"); case 3: return ZInput.GetButton("JoyHotbarRight") || ZInput.GetButton("JoyHotbarLeft"); default: return ZInput.GetButton("JoyHotbarRight") || ZInput.GetButton("JoyHotbarLeft"); } } KeyboardShortcut value2 = Hotkey.Value; KeyCode mainKey = ((KeyboardShortcut)(ref value2)).MainKey; KeyCode[] source = ((KeyboardShortcut)(ref value2)).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() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) return ZInput.IsGamepadActive() && (int)HotkeyDPad.Value == 0 && !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_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Expected O, but got Unknown instance = this; ModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ModEnabled", true, "Enable mod when value is true"); Hotkey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Input", "Hotkey", KeyboardShortcut.Deserialize("G"), "Hotkey for opening equip wheel menu"); HotkeyDPad = ((BaseUnityPlugin)this).Config.Bind<DPadButton>("Input", "HotkeyDPad", (DPadButton)0, "Hotkey on the D-Pad (None, Left, Right or LeftOrRight)"); UseSitButton = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "UseSitButton", false, "When enabled use the sit button as hotkey (HotkeyDPad has to be set to None)"); TriggerOnRelease = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "TriggerOnRelease", true, "Releasing the Hotkey will equip/use the selected item"); TriggerOnClick = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "TriggerOnClick", false, "Click with left mouse button will equip/use the selected item"); ToggleMenu = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "ToggleMenu", false, "When enabled the equip wheel will toggle between hidden/visible when the hotkey was pressed"); HighlightColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Appereance", "HighlightColor", new Color(0.414f, 0.734f, 1f), "Color of the highlighted selection"); GuiScale = ((BaseUnityPlugin)this).Config.Bind<float>("Appereance", "GuiScale", 0.5f, "Scale factor of the user interface"); InventoryRow = ((BaseUnityPlugin)this).Config.Bind<int>("Misc", "InventoryRow", 1, new ConfigDescription("Row of the inventory that should be used for the equip wheel", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 4), 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((IWheel)(object)this); Log(((object)this).GetType().Namespace + " Loaded!"); } private void OnDestroy() { WheelManager.RemoveWheel((IWheel)(object)this); if (harmony != null) { harmony.UnpatchAll((string)null); } } public static void TryHideHotkeyBar() { } public static void ParseNames(string value, ref string[] arr) { if ((Object)(object)ObjectDB.instance == (Object)null) { return; } string[] array = ParseTokens(value); List<string> list = new List<string>(); string[] array2 = array; foreach (string text in array2) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(text); if ((Object)(object)itemPrefab != (Object)null) { ItemDrop component = itemPrefab.GetComponent<ItemDrop>(); list.Add(component.m_itemData.m_shared.m_name); } } arr = list.Distinct().ToArray(); } public static string[] ParseTokens(string value) { char[] separator = new char[5] { ' ', ',', '.', ':', '\t' }; return value.Split(separator, StringSplitOptions.RemoveEmptyEntries); } public int GetKeyCount(bool pressed = false) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_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 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((IWheel)(object)EquipWheel.Instance)) { UseCurrentItem(); toggleDownWasPressed = true; } else if (toggleVisible > 0 && !flag) { if (!visible) { ((Component)ui).gameObject.SetActive(true); visible = true; WheelManager.Activate((IWheel)(object)EquipWheel.Instance); } if (EquipWheel.TriggerOnClick.Value && (Input.GetMouseButtonDown(0) || Input.GetKeyDown((KeyCode)330))) { UseCurrentItem(flash: true); } } else { Hide(); } } private void UseCurrentItem(bool flash = false) { if (ui.CurrentItem != null) { if (flash) { ui.Flash(); } 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((IWheel)(object)EquipWheel.Instance); } if (EquipWheel.TriggerOnClick.Value && (Input.GetMouseButtonDown(0) || Input.GetKeyDown((KeyCode)330))) { UseCurrentItem(flash: true); } } else { Hide(); } } } public class EquipWheelUI : MonoBehaviour { public readonly float ANGLE_STEP = 45f; public readonly float ITEM_DISTANCE = 295f; public readonly float ITEM_SCALE = 2f; public readonly float INNER_DIAMETER = 340f; public readonly float LENGTH_THRESHOLD = 0.1f; private GameObject cursor; private Text text; private GameObject highlight; private readonly ItemData[] items = (ItemData[])(object)new ItemData[8]; private HotkeyBar hotKeyBar; private Transform itemsRoot; private bool addedListener; private readonly List<ElementData> m_elements = new List<ElementData>(); private GameObject m_elementPrefab; private int previous = -1; public int Current { get { if ((!ZInput.IsGamepadActive() && MouseInCenter) || JoyStickInCenter || (ZInput.IsGamepadActive() && Lenght < (double)LENGTH_THRESHOLD)) { return -1; } int num = Mod((int)Mathf.Round((0f - Angle) / ANGLE_STEP), 8); if (num >= items.Length) { return -1; } return num; } } public bool JoyStickInCenter { get { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if ((int)EquipWheel.HotkeyDPad.Value == 0) { float joyLeftStickX = ZInput.GetJoyLeftStickX(); 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 { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if ((int)EquipWheel.HotkeyDPad.Value == 0) { 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) //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (ZInput.IsGamepadActive()) { if ((int)EquipWheel.HotkeyDPad.Value == 0) { float joyLeftStickX = ZInput.GetJoyLeftStickX(); 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 val = EpicLootWrapper.instance.GetItemColor(CurrentItem); if (((Color)(ref val)).Equals(Color.white) || !EquipWheel.UseRarityColoring.Value) { val = EquipWheel.GetHighlightColor; } text.text = Localization.instance.Localize(EpicLootWrapper.instance.GetItemName(CurrentItem, val)); } else { text.text = Localization.instance.Localize(CurrentItem.m_shared.m_name); } } else { ((Component)text).gameObject.SetActive(false); } previous = Current; } highlight.SetActive(CurrentItem != null); Color color = (Color)((CurrentItem != null) ? 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) { color = itemColor; ((Graphic)highlight.GetComponent<Image>()).color = color; } else { ((Graphic)highlight.GetComponent<Image>()).color = EquipWheel.GetHighlightColor; } } Image[] componentsInChildren = cursor.GetComponentsInChildren<Image>(true); Image[] array = componentsInChildren; foreach (Image val2 in array) { ((Graphic)val2).color = color; if (((Object)((Component)val2).gameObject).name == "Image") { ((Component)val2).gameObject.SetActive(CurrentItem != null); } } cursor.transform.rotation = Quaternion.AngleAxis(Angle, Vector3.forward); float num = (float)Current * ANGLE_STEP; highlight.transform.rotation = Quaternion.AngleAxis(0f - num, Vector3.forward); UpdateIcons(Player.m_localPlayer); } private int CountItems(ItemData[] items) { int num = 0; foreach (ItemData val in items) { if (val != null) { num++; } } return num; } private void UpdateIcons(Player player, bool forceUpdate = false) { //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown //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 val = new ElementData(); val.m_go = Object.Instantiate<GameObject>(m_elementPrefab, itemsRoot); val.m_go.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 0.5f); float num = Mathf.Sin((float)i * ANGLE_STEP * ((float)Math.PI / 180f)) * ITEM_DISTANCE; float num2 = Mathf.Cos((float)i * ANGLE_STEP * ((float)Math.PI / 180f)) * ITEM_DISTANCE; val.m_go.transform.localScale = new Vector3(ITEM_SCALE, ITEM_SCALE, ITEM_SCALE); val.m_go.transform.localPosition = new Vector3(num, num2, 0f); ((TMP_Text)((Component)val.m_go.transform.Find("binding")).GetComponent<TextMeshProUGUI>()).text = (i + 1).ToString(); val.m_icon = ((Component)((Component)val.m_go.transform).transform.Find("icon")).GetComponent<Image>(); val.m_durability = ((Component)val.m_go.transform.Find("durability")).GetComponent<GuiBar>(); val.m_amount = ((Component)val.m_go.transform.Find("amount")).GetComponent<TextMeshProUGUI>(); val.m_equiped = ((Component)val.m_go.transform.Find("equiped")).gameObject; val.m_queued = ((Component)val.m_go.transform.Find("queued")).gameObject; val.m_selection = ((Component)val.m_go.transform.Find("selected")).gameObject; val.m_selection.SetActive(false); if (EquipWheel.InventoryRow.Value > 1 || EquipWheel.ItemFiltering.Value) { ((Behaviour)((Component)val.m_go.transform.Find("binding")).GetComponent<TextMeshProUGUI>()).enabled = false; } m_elements.Add(val); } } } foreach (ElementData element3 in m_elements) { element3.m_used = false; } int num3 = 0; for (int j = 0; j < items.Length; j++) { if (items[j] == null) { continue; } ItemData val2 = items[j]; ElementData val3 = m_elements[num3]; val3.m_used = true; ((Component)val3.m_icon).gameObject.SetActive(true); val3.m_icon.sprite = val2.GetIcon(); ((Component)val3.m_durability).gameObject.SetActive(val2.m_shared.m_useDurability); if (val2.m_shared.m_useDurability) { if (val2.m_durability <= 0f) { val3.m_durability.SetValue(1f); val3.m_durability.SetColor((Color)((!(Mathf.Sin(Time.time * 10f) > 0f)) ? new Color(0f, 0f, 0f, 0f) : Color.red)); } else { val3.m_durability.SetValue(val2.GetDurabilityPercentage()); val3.m_durability.ResetColor(); } } val3.m_equiped.SetActive(val2.m_equipped); val3.m_queued.SetActive(player.IsEquipActionQueued(val2)); if (val2.m_shared.m_maxStackSize > 1) { ((Component)val3.m_amount).gameObject.SetActive(true); ((TMP_Text)val3.m_amount).text = val2.m_stack + "/" + val2.m_shared.m_maxStackSize; } else { ((Component)val3.m_amount).gameObject.SetActive(false); } if (EpicLootWrapper.instance != null) { EpicLootWrapper.instance.ModifyElement(val3, val2); } num3++; } for (int k = 0; k < m_elements.Count; k++) { ElementData val4 = m_elements[k]; if (!val4.m_used) { ((Component)val4.m_icon).gameObject.SetActive(false); ((Component)val4.m_durability).gameObject.SetActive(false); val4.m_equiped.SetActive(false); val4.m_queued.SetActive(false); ((Component)val4.m_amount).gameObject.SetActive(false); } } } } public class Patcher { public static readonly KeyCode[] NUMBERS; [HarmonyPatch(typeof(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) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)EquipWheel.Instance == (Object)null) { return true; } if (EquipWheel.HotkeyDPad != null && (int)EquipWheel.HotkeyDPad.Value == 0) { return true; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null) { 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() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && EquipWheel.UseSitButton.Value && (int)EquipWheel.HotkeyDPad.Value == 0 && (ZInput.GetButtonDown("JoySit") || ZInput.GetButtonUp("JoySit"))) { 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; } }