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 Build Hotbar v0.9.1
plugins/BuildHotbar/BuildHotbar.dll
Decompiled a week ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("BuildHotbar")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.9.1.0")] [assembly: AssemblyInformationalVersion("0.9.1")] [assembly: AssemblyProduct("BuildHotbar")] [assembly: AssemblyTitle("BuildHotbar")] [assembly: AssemblyVersion("0.9.1.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Kakimaki.BuildHotbar { [BepInPlugin("ValheimEnthusiestKakimaki.BuildHotbar", "Build Hotbar", "0.9.1")] public sealed class BuildHotbarPlugin : BaseUnityPlugin { [HarmonyPatch(typeof(ZInput), "GetMouseScrollWheel")] private static class RowScrollPatch { [HarmonyPostfix] private static void Postfix(ref float __result) { BuildHotbarPlugin instance = _instance; Player localPlayer = Player.m_localPlayer; if ((Object)(object)instance == (Object)null || __result == 0f || !Active(localPlayer) || instance._rows.Value <= 1 || !instance.ScrollKeyHeld() || !(bool)TakeInput.Invoke(localPlayer, null)) { return; } float num = __result; __result = 0f; if (instance._lastScrollFrame != Time.frameCount) { instance._lastScrollFrame = Time.frameCount; int num2 = ((num < 0f) ? 1 : (-1)); if (instance._reverseScroll.Value) { num2 = -num2; } instance._activeRow.Value = HotbarRows.Step(instance.CurrentRow, instance._rows.Value, num2); instance._nextRefresh = 0f; } } } [HarmonyPatch(typeof(Player), "UseHotbarItem")] private static class UseHotbarItemPatch { [HarmonyPrefix] [HarmonyPriority(800)] private static bool Prefix(Player __instance, int index) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) if (!Eligible(__instance) || index < 1 || index > 8) { return true; } if (_instance.SettingsOpen) { return false; } if (!Active(__instance)) { return true; } if (!(bool)TakeInput.Invoke(__instance, null)) { return true; } KeyCode val = (KeyCode)(49 + index - 1); if (!Input.GetKeyDown(val)) { return true; } for (int i = 0; i < _instance._count.Value; i++) { if (_instance._slotKeys[i].Value == val) { _instance.TriggerSlot(__instance, i); return false; } } return true; } } private sealed class SlotView { public readonly Image Background; public readonly Image Icon; public readonly TMP_Text Label; public readonly TMP_Text Key; public SlotView(Image background, Image icon, TMP_Text label, TMP_Text key) { Background = background; Icon = icon; Label = label; Key = key; } } [HarmonyPatch] private static class WheelUiNavigationPatch { private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.Method(AccessTools.TypeByName("UnityEngine.InputSystem.UI.InputSystemUIInputModule"), "ProcessNavigation", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(BuildUi), "NavigationUpdate", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(BuildUi), "UpdateTriggerNavigation", (Type[])null, (Type[])null); } [HarmonyPrefix] [HarmonyPriority(800)] private static bool Prefix() { BuildHotbarPlugin instance = _instance; if ((Object)(object)instance == (Object)null) { return true; } instance.PollWheel(); if (!instance.WheelConsumesInput) { return !instance._uiNavigationWaitForCentre; } return false; } } [HarmonyPatch(typeof(KeyHints), "UpdateHints")] private static class AppendBuildHotbarHintsPatch { [HarmonyPrefix] private static void Prefix() { _instance?.RestoreVanillaControlHints(); } [HarmonyPostfix] private static void Postfix(KeyHints __instance) { if (!((Object)(object)_instance == (Object)null)) { _instance._nativeKeyHints = __instance; _instance.RenderControllerEntryHint(); } } } [HarmonyPatch] private static class WheelButtonsPatch { private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.Method(typeof(ZInput), "GetButton", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(ZInput), "GetButtonDown", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(ZInput), "GetButtonUp", (Type[])null, (Type[])null); } [HarmonyPrefix] [HarmonyPriority(800)] private static bool Prefix(ref bool __result) { BuildHotbarPlugin instance = _instance; if ((Object)(object)instance == (Object)null || instance._readingWheel) { return true; } instance.PollWheel(); if (!instance.WheelConsumesInput) { return true; } __result = false; return false; } } [HarmonyPatch] private static class WheelLookPatch { private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.Method(typeof(ZInput), "GetJoyRightStickX", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(ZInput), "GetJoyRightStickY", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(ZInput), "GetJoyLeftStickX", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(ZInput), "GetJoyLeftStickY", (Type[])null, (Type[])null); } [HarmonyPrefix] [HarmonyPriority(800)] private static bool Prefix(ref float __result) { BuildHotbarPlugin instance = _instance; if ((Object)(object)instance == (Object)null || instance._readingWheel) { return true; } instance.PollWheel(); if (!instance.WheelConsumesInput) { return true; } __result = 0f; return false; } } [HarmonyPatch(typeof(Player), "TakeInput")] private static class SettingsInputPatch { [HarmonyPostfix] private static void Postfix(Player __instance, ref bool __result) { if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer && (Object)(object)_instance != (Object)null && _instance.SettingsOpen) { __result = false; } } } public const string Guid = "ValheimEnthusiestKakimaki.BuildHotbar"; private static BuildHotbarPlugin? _instance; private readonly Harmony _harmony = new Harmony("ValheimEnthusiestKakimaki.BuildHotbar"); private readonly Dictionary<string, ConfigEntry<string>[]> _toolSlots = new Dictionary<string, ConfigEntry<string>[]>(); private ConfigEntry<bool> _enabled; private ConfigEntry<bool> _autoActivate; private ConfigEntry<KeyCode> _toggleKey; private PieceTable? _activationTool; private bool _hotbarActive; private int _toggleFrame = -1; private GameObject? _toggleButton; private TMP_Text? _toggleText; private ConfigEntry<int> _count; private ConfigEntry<int> _rows; private ConfigEntry<int> _activeRow; private ConfigEntry<bool> _reverseScroll; private int _lastScrollFrame = -1; private static readonly MethodInfo TakeInput = AccessTools.Method(typeof(Player), "TakeInput", (Type[])null, (Type[])null); private ConfigEntry<Vector2> _position; private static readonly FieldRef<Hud, Piece> HoveredPiece = AccessTools.FieldRefAccess<Hud, Piece>("m_hoveredPiece"); private Image? _dragImage; private TMP_Text? _dragLabel; private bool _dragging; private Vector2 _dragStartPointer; private Vector2 _dragStartPosition; private GameObject? _panel; private RectTransform? _panelRect; private TMP_Text? _hint; private readonly List<SlotView> _views = new List<SlotView>(); private float _nextRefresh; private static readonly Color Background = new Color(0.09f, 0.08f, 0.06f, 0.94f); private static readonly Color Selected = new Color(0.42f, 0.29f, 0.1f, 0.98f); private GameObject? _controllerSettingsRoot; private readonly List<Button> _controllerSettingRows = new List<Button>(); private TMP_Text? _controllerSettingsHelp; private int _controllerSettingIndex; private int _settingsHeldMask; private int _controllerCapture = -1; private readonly ControllerChordCapture _controllerChord = new ControllerChordCapture(); private string _controllerSettingsMessage = "Changes save immediately."; private readonly List<TMP_Text> _nativeControlHints = new List<TMP_Text>(); private KeyHints? _nativeKeyHints; private Transform? _nativeHintParent; private bool _hintLayoutWarning; private bool _uiNavigationWaitForCentre; private readonly List<GameObject> _hiddenVanillaHints = new List<GameObject>(); private ConfigEntry<bool> _wheelEnabled; private ConfigEntry<bool> _wheelToggle; private ConfigEntry<float> _wheelDeadzone; private ConfigEntry<WheelButtons> _wheelShortcut; private ConfigEntry<WheelButtons> _wheelSaveShortcut; private bool _shortcutWasHeld; private bool _saveWasHeld; private bool _settingsOpenWasHeld; private bool _rightTriggerWasHeld; private bool _leftTriggerWasHeld; private bool _leftClickWasHeld; private bool _wheelAssigning; private int _wheelOpenedFrame = -1; private readonly WheelGesture _wheelGesture = new WheelGesture(); private readonly WheelPaging _wheelPaging = new WheelPaging(); private bool _wheelOpen; private bool _readingWheel; private bool _wheelWaitRelease; private int _wheelFrame = -1; private int _wheelConsumedFrame = -1; private int _wheelSlot = -1; private PieceTable? _wheelTool; private Piece? _wheelSource; private GameObject? _wheelRoot; private TMP_Text? _wheelTitle; private readonly List<SlotView> _wheelViews = new List<SlotView>(); private ConfigEntry<KeyCode> _scrollKey; private ConfigEntry<KeyCode> _saveKey; private ConfigEntry<KeyCode> _clearKey; private readonly ConfigEntry<KeyCode>[] _slotKeys = new ConfigEntry<KeyCode>[8]; private readonly int[] _slotFrames = new int[8] { -1, -1, -1, -1, -1, -1, -1, -1 }; private ConfigEntry<bool> _collapsed; private ConfigEntry<KeyCode>? _capture; private int _captureFrame; private string _bindingMessage = "Click a binding, then press a key. Esc cancels; Backspace unbinds."; private TMP_Text? _bindingHelp; private readonly List<Tuple<ConfigEntry<KeyCode>, TMP_Text>> _bindingLabels = new List<Tuple<ConfigEntry<KeyCode>, TMP_Text>>(); private GameObject? _collapseButton; private TMP_Text? _collapseText; private RectTransform? _handleRect; private static readonly KeyCode[] CaptureKeys = (KeyCode[])Enum.GetValues(typeof(KeyCode)); private ConfigEntry<float> _horizontalScale; private ConfigEntry<float> _radialScale; private TMP_Text? _horizontalScaleValue; private TMP_Text? _radialScaleValue; private GameObject? _settingsRoot; private GameObject? _settingsButton; private TMP_Text? _slotsValue; private TMP_Text? _rowsValue; private TMP_Text? _reverseValue; private TMP_Text? _autoValue; private Button? _slotsLess; private Button? _slotsMore; private Button? _rowsLess; private Button? _rowsMore; private static readonly Color HotbarBackground = new Color(0.035f, 0.035f, 0.03f, 0.5f); private static readonly Color HotbarHighlight = new Color(0.24f, 0.19f, 0.1f, 0.6f); private static readonly string[] WheelButtonActions = new string[10] { "JoyButtonA", "JoyButtonB", "JoyButtonX", "JoyButtonY", "JoyLBumper", "JoyRBumper", "JoyLTrigger", "JoyRTrigger", "JoyLStick", "JoyRStick" }; private int CurrentRow => Mathf.Clamp(_activeRow.Value, 1, _rows.Value); private bool ControllerSettingsOpen { get { if (Object.op_Implicit((Object)(object)_controllerSettingsRoot)) { return _controllerSettingsRoot.activeInHierarchy; } return false; } } private bool WheelConsumesInput { get { if (!ControllerSettingsOpen && !_wheelOpen) { return _wheelConsumedFrame == Time.frameCount; } return true; } } private bool ShowControllerHotbar { get { if (!_wheelOpen) { return ZInput.IsGamepadActive(); } return true; } } private bool SettingsOpen { get { if (!ControllerSettingsOpen) { if (Object.op_Implicit((Object)(object)_settingsRoot)) { return _settingsRoot.activeInHierarchy; } return false; } return true; } } private void Awake() { //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Expected O, but got Unknown //IL_0141: Unknown result type (might be due to invalid IL or missing references) _instance = this; _enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Show and use the building hotbar while a building tool is equipped."); _autoActivate = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Auto activate", true, "Activate when equipping a building tool. Otherwise use the toggle key or Enable button. Putting the tool away resets activation."); _toggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Key bindings", "Toggle key", (KeyCode)287, "Toggle between build and inventory hotbar shortcuts while holding a building tool."); _count = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Slot count", 8, new ConfigDescription("Slots per hotbar row. Remaining number keys use the inventory hotbar.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 8), Array.Empty<object>())); _rows = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Row count", 3, new ConfigDescription("Number of saved hotbar rows. One row is displayed at a time; modifier+wheel switches rows. Reducing this does not erase hidden rows.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 12), Array.Empty<object>())); _activeRow = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Active row", 1, new ConfigDescription("Current row, also updated by scrolling.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 12), Array.Empty<object>())); _reverseScroll = ((BaseUnityPlugin)this).Config.Bind<bool>("Controls", "Reverse row scrolling", false, "Reverse the direction used to cycle rows. Normally wheel down selects the next row."); _position = ((BaseUnityPlugin)this).Config.Bind<Vector2>("Display", "Position", new Vector2(0f, -24f), "Offset from top centre in canvas units. Drag the title while the build menu is open. Reset to (0, -24) for the default position."); InitializeBindings(); InitializeScale(); InitializeWheel(); _harmony.PatchAll(typeof(BuildHotbarPlugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Build hotbar ready: number selects, Shift+number saves, Alt+number clears."); } private bool ScrollKeyHeld() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return Held(_scrollKey.Value); } private void Update() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) RefreshActivation(Player.m_localPlayer); PollWheel(); if (WheelConsumesInput) { return; } if (SettingsOpen) { CaptureBinding(); return; } if (Active(Player.m_localPlayer) && (bool)TakeInput.Invoke(Player.m_localPlayer, null)) { for (int i = 0; i < _count.Value; i++) { if ((int)_slotKeys[i].Value != 0 && Input.GetKeyDown(_slotKeys[i].Value)) { TriggerSlot(Player.m_localPlayer, i); } } } if (Active(Player.m_localPlayer) && _rows.Value > 1 && ScrollKeyHeld()) { ZInput.GetMouseScrollWheel(); } } private static bool Eligible(Player player) { if ((Object)(object)_instance != (Object)null && _instance._enabled.Value && Object.op_Implicit((Object)(object)player) && (Object)(object)player == (Object)(object)Player.m_localPlayer && !((Character)player).IsDead() && !((Character)player).InCutscene() && !((Character)player).IsTeleporting()) { return Object.op_Implicit((Object)(object)player.GetBuildTool()); } return false; } private void RefreshActivation(Player player) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) PieceTable val = (Eligible(player) ? player.GetBuildTool() : null); if ((Object)(object)_activationTool != (Object)(object)val) { _activationTool = val; _hotbarActive = Object.op_Implicit((Object)(object)val) && _autoActivate.Value; } if (!Object.op_Implicit((Object)(object)val)) { _hotbarActive = false; } else if (!SettingsOpen && _toggleFrame != Time.frameCount && (int)_toggleKey.Value != 0 && Input.GetKeyDown(_toggleKey.Value) && (bool)TakeInput.Invoke(player, null)) { _toggleFrame = Time.frameCount; ToggleActivation(); } } private void ToggleActivation() { _hotbarActive = !_hotbarActive; EndDrag(); _nextRefresh = 0f; if (Object.op_Implicit((Object)(object)_panel)) { ApplyCollapsed(); } } private static bool Active(Player player) { if ((Object)(object)_instance == (Object)null) { return false; } _instance.RefreshActivation(player); if (Eligible(player)) { return _instance._hotbarActive; } return false; } private ConfigEntry<string>[] Slots(PieceTable tool) { string name = ((Object)tool).name; int currentRow = CurrentRow; string key = name + "|" + currentRow; if (_toolSlots.TryGetValue(key, out ConfigEntry<string>[] value)) { return value; } string text = "Tool " + BitConverter.ToString(Encoding.UTF8.GetBytes(name)).Replace("-", ""); text = text + " Row " + currentRow; value = new ConfigEntry<string>[8]; for (int i = 0; i < value.Length; i++) { value[i] = ((BaseUnityPlugin)this).Config.Bind<string>(text, "Slot " + (i + 1), "", "Saved piece prefab name for " + name + ". Set in game with Shift+number."); } _toolSlots.Add(key, value); return value; } private static Piece? Resolve(PieceTable tool, string prefab) { if (string.IsNullOrEmpty(prefab)) { return null; } foreach (GameObject piece in tool.m_pieces) { if (Object.op_Implicit((Object)(object)piece) && ((Object)piece).name == prefab) { return piece.GetComponent<Piece>(); } } return null; } private void HandleSlot(Player player, int slot) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0185: 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) PieceTable buildTool = player.GetBuildTool(); ConfigEntry<string> val = Slots(buildTool)[slot]; bool num = Held(_clearKey.Value); bool flag = Held(_saveKey.Value); if (num) { val.Value = ""; Notify(player, "Row " + CurrentRow + ", slot " + (slot + 1) + " cleared."); } else if (flag) { Piece val2 = ((Object.op_Implicit((Object)(object)Hud.instance) && Hud.IsPieceSelectionVisible()) ? HoveredPiece.Invoke(Hud.instance) : null); if (!Object.op_Implicit((Object)(object)val2)) { val2 = player.GetSelectedPiece(); } if (!Object.op_Implicit((Object)(object)val2) || !player.IsPieceAvailable(val2)) { Notify(player, "Hover over or select an available building piece first."); return; } val.Value = ((Object)((Component)val2).gameObject).name; Notify(player, "Row " + CurrentRow + ", slot " + (slot + 1) + ": " + Label(val2)); } else { Piece val3 = Resolve(buildTool, val.Value); if (string.IsNullOrEmpty(val.Value)) { Notify(player, "Empty slot. Hover over or select a piece, then use " + KeyName(_saveKey.Value) + "+" + KeyName(_slotKeys[slot].Value) + " to save it."); } else if (!Object.op_Implicit((Object)(object)val3) || !player.IsPieceAvailable(val3) || !player.SetSelectedPiece(val3)) { Notify(player, "That piece is unavailable with this tool or is not unlocked."); } } _nextRefresh = 0f; } private static string Label(Piece piece) { return Localization.instance.Localize(piece.m_name); } private static void Notify(Player player, string message) { ((Character)player).Message((MessageType)1, message, 0, (Sprite)null, false); } private void LateUpdate() { //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Expected O, but got Unknown //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_04d2: Unknown result type (might be due to invalid IL or missing references) //IL_04ed: Unknown result type (might be due to invalid IL or missing references) //IL_0516: Unknown result type (might be due to invalid IL or missing references) //IL_052f: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_0436: Unknown result type (might be due to invalid IL or missing references) //IL_042f: Unknown result type (might be due to invalid IL or missing references) //IL_049c: Unknown result type (might be due to invalid IL or missing references) //IL_0495: Unknown result type (might be due to invalid IL or missing references) RenderWheel(); RenderControllerEntryHint(); Player localPlayer = Player.m_localPlayer; Hud instance = Hud.instance; RefreshActivation(localPlayer); if (!Eligible(localPlayer) || !Object.op_Implicit((Object)(object)instance) || !Object.op_Implicit((Object)(object)instance.m_rootObject) || !instance.m_rootObject.activeInHierarchy || Hud.IsUserHidden()) { CloseSettings(); EndDrag(); if (Object.op_Implicit((Object)(object)_panel)) { _panel.SetActive(false); } return; } if (!Object.op_Implicit((Object)(object)_panel) || _views.Count != _count.Value) { DestroyPanel(); if (!CreatePanel(instance)) { return; } } _panel.SetActive(!ShowControllerHotbar); ApplyCollapsed(); RectTransform val = (RectTransform)((Transform)_panelRect).parent; RectTransform? panelRect = _panelRect; Vector3 one = Vector3.one; float value = _horizontalScale.Value; Rect rect = _panelRect.rect; float width = ((Rect)(ref rect)).width; rect = _panelRect.rect; float height = ((Rect)(ref rect)).height; rect = val.rect; float availableWidth = ((Rect)(ref rect)).width - 24f; rect = val.rect; ((Transform)panelRect).localScale = one * HotbarScale.Fit(value, width, height, availableWidth, ((Rect)(ref rect)).height - 24f); bool flag = Hud.IsPieceSelectionVisible(); if (!flag && !ControllerSettingsOpen) { CloseSettings(); } if (Object.op_Implicit((Object)(object)_settingsButton)) { _settingsButton.SetActive(flag); } if (Object.op_Implicit((Object)(object)_collapseButton)) { _collapseButton.SetActive(flag); } if (Object.op_Implicit((Object)(object)_toggleButton)) { _toggleButton.SetActive(flag); } if (!flag) { EndDrag(); } ((Graphic)_dragImage).raycastTarget = flag; string text = "BUILD HOTBAR " + (_hotbarActive ? (CurrentRow + " / " + _rows.Value) : "OFF"); _dragLabel.text = (flag ? (text + " · drag") : text); _dragLabel.rectTransform.anchoredPosition = new Vector2((float)(flag ? (-104) : 0), 14f); _dragLabel.rectTransform.sizeDelta = new Vector2(_panelRect.sizeDelta.x - (float)(flag ? 208 : 16), 28f); _dragLabel.alignment = (TextAlignmentOptions)(flag ? 4097 : 514); if (flag) { _panel.transform.SetAsLastSibling(); } if (Object.op_Implicit((Object)(object)_settingsRoot)) { _settingsRoot.transform.SetAsLastSibling(); RefreshSettings(); } if (ControllerSettingsOpen) { _controllerSettingsRoot.transform.SetAsLastSibling(); } if (!_dragging) { _panelRect.anchoredPosition = ClampPosition(_position.Value); } if (!(Time.unscaledTime < _nextRefresh)) { _nextRefresh = Time.unscaledTime + 0.1f; PieceTable buildTool = localPlayer.GetBuildTool(); ConfigEntry<string>[] array = Slots(buildTool); Piece selectedPiece = localPlayer.GetSelectedPiece(); for (int i = 0; i < _views.Count; i++) { SlotView slotView = _views[i]; slotView.Key.text = KeyName(_slotKeys[i].Value); Piece val2 = Resolve(buildTool, array[i].Value); bool flag2 = Object.op_Implicit((Object)(object)val2) && localPlayer.IsPieceAvailable(val2); bool selected = Object.op_Implicit((Object)(object)val2) && (Object)(object)val2 == (Object)(object)selectedPiece; ((Graphic)slotView.Background).color = HotbarFill(selected); slotView.Icon.sprite = (Object.op_Implicit((Object)(object)val2) ? val2.m_icon : null); ((Behaviour)slotView.Icon).enabled = (Object)(object)slotView.Icon.sprite != (Object)null; ((Graphic)slotView.Icon).color = (Color)(flag2 ? Color.white : new Color(1f, 1f, 1f, 0.3f)); slotView.Label.text = (Object.op_Implicit((Object)(object)val2) ? Label(val2) : (string.IsNullOrEmpty(array[i].Value) ? "Empty" : "Missing piece")); ((Graphic)slotView.Label).color = (Color)(flag2 ? Color.white : new Color(0.7f, 0.7f, 0.7f)); } _hint.text = KeyName(_saveKey.Value) + "+slot save • " + KeyName(_clearKey.Value) + "+slot clear" + ((_rows.Value > 1 && (int)_scrollKey.Value != 0) ? (" • " + KeyName(_scrollKey.Value) + "+wheel row") : ""); } } private bool CreatePanel(Hud hud) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_00a8: 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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Expected O, but got Unknown //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Expected O, but got Unknown //IL_01f0: 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_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Expected O, but got Unknown //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Expected O, but got Unknown //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Expected O, but got Unknown //IL_03f7: Unknown result type (might be due to invalid IL or missing references) //IL_0432: 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) //IL_0452: Unknown result type (might be due to invalid IL or missing references) //IL_0468: Unknown result type (might be due to invalid IL or missing references) //IL_0472: Expected O, but got Unknown //IL_0489: Unknown result type (might be due to invalid IL or missing references) //IL_04a4: Unknown result type (might be due to invalid IL or missing references) //IL_04b3: Unknown result type (might be due to invalid IL or missing references) //IL_04bf: Unknown result type (might be due to invalid IL or missing references) //IL_04c9: Expected O, but got Unknown //IL_0508: Unknown result type (might be due to invalid IL or missing references) //IL_0523: Unknown result type (might be due to invalid IL or missing references) //IL_0532: Unknown result type (might be due to invalid IL or missing references) //IL_053e: Unknown result type (might be due to invalid IL or missing references) //IL_0548: Expected O, but got Unknown //IL_057a: Unknown result type (might be due to invalid IL or missing references) //IL_0595: Unknown result type (might be due to invalid IL or missing references) //IL_05a4: Unknown result type (might be due to invalid IL or missing references) //IL_05b0: Unknown result type (might be due to invalid IL or missing references) //IL_05ba: Expected O, but got Unknown MessageHud instance = MessageHud.instance; if (!Object.op_Implicit((Object)(object)instance) || !Object.op_Implicit((Object)(object)instance.m_messageText) || !Object.op_Implicit((Object)(object)instance.m_messageText.font)) { return false; } TMP_Text messageText = instance.m_messageText; _panel = new GameObject("Kakimaki_BuildHotbar", new Type[1] { typeof(RectTransform) }); _panel.transform.SetParent(hud.m_rootObject.transform, false); _panelRect = (RectTransform)_panel.transform; RectTransform? panelRect = _panelRect; RectTransform? panelRect2 = _panelRect; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0.5f, 1f); panelRect2.anchorMax = val; panelRect.anchorMin = val; _panelRect.pivot = new Vector2(0.5f, 1f); float num = (float)_count.Value * 88f; _panelRect.sizeDelta = new Vector2(Math.Max(num, 480f), 126f); for (int i = 0; i < _count.Value; i++) { GameObject val2 = new GameObject("Slot" + (i + 1), new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }); val2.transform.SetParent(_panel.transform, false); Position((RectTransform)val2.transform, new Vector2((0f - num) / 2f + 44f + (float)(i * 88), 47f), new Vector2(80f, 94f)); Image component = val2.GetComponent<Image>(); ((Graphic)component).raycastTarget = false; GameObject val3 = new GameObject("Icon", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }); val3.transform.SetParent(val2.transform, false); Position((RectTransform)val3.transform, new Vector2(0f, 52f), new Vector2(52f, 52f)); Image component2 = val3.GetComponent<Image>(); component2.preserveAspect = true; ((Graphic)component2).raycastTarget = false; TMP_Text val4 = Text(val2.transform, "Key", messageText, 11, new Vector2(0f, 86f), new Vector2(74f, 16f)); val4.text = KeyName(_slotKeys[i].Value); ((Graphic)val4).color = new Color(1f, 0.8f, 0.4f); TMP_Text label = Text(val2.transform, "Name", messageText, 12, new Vector2(0f, 14f), new Vector2(72f, 24f)); _views.Add(new SlotView(component, component2, label, val4)); } _hint = Text(_panel.transform, "Instructions", messageText, 13, new Vector2(0f, 114f), new Vector2(Math.Max(num, 480f), 24f)); GameObject val5 = new GameObject("DragHandle", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }); val5.transform.SetParent(_panel.transform, false); Position((RectTransform)val5.transform, new Vector2(0f, 112f), new Vector2(_panelRect.sizeDelta.x, 28f)); _dragImage = val5.GetComponent<Image>(); ((Graphic)_dragImage).color = HotbarFill(selected: false); ((Graphic)_dragImage).raycastTarget = false; val5.AddComponent<HotbarDragHandle>().Owner = this; _dragLabel = Text(val5.transform, "Title", messageText, 14, new Vector2(-104f, 14f), new Vector2(_panelRect.sizeDelta.x - 208f, 28f)); _handleRect = (RectTransform)val5.transform; Button val6 = MakeButton(_panel.transform, "Enable", messageText, new Vector2(_panelRect.sizeDelta.x / 2f - 170f, 112f), new Vector2(64f, 28f), new UnityAction(ToggleActivation)); _toggleButton = ((Component)val6).gameObject; _toggleText = ((Component)val6).GetComponentInChildren<TMP_Text>(); _toggleButton.SetActive(false); Button val7 = MakeButton(_panel.transform, "Settings", messageText, new Vector2(_panelRect.sizeDelta.x / 2f - 94f, 112f), new Vector2(84f, 28f), new UnityAction(OpenSettings)); _settingsButton = ((Component)val7).gameObject; _settingsButton.SetActive(false); Button val8 = MakeButton(_panel.transform, "−", messageText, new Vector2(_panelRect.sizeDelta.x / 2f - 24f, 112f), new Vector2(44f, 28f), (UnityAction)delegate { EndDrag(); _collapsed.Value = !_collapsed.Value; ApplyCollapsed(); }); _collapseButton = ((Component)val8).gameObject; _collapseText = ((Component)val8).GetComponentInChildren<TMP_Text>(); _collapseButton.SetActive(false); ApplyCollapsed(); _nextRefresh = 0f; return true; } private static void Position(RectTransform rect, Vector2 position, Vector2 size) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0.5f, 0f); rect.anchorMax = val; rect.anchorMin = val; rect.pivot = new Vector2(0.5f, 0.5f); rect.anchoredPosition = position; rect.sizeDelta = size; } private static TMP_Text Text(Transform parent, string name, TMP_Text source, int size, Vector2 position, Vector2 dimensions) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown GameObject val = new GameObject(name, new Type[2] { typeof(RectTransform), typeof(CanvasRenderer) }); val.SetActive(false); val.transform.SetParent(parent, false); TextMeshProUGUI obj = val.AddComponent<TextMeshProUGUI>(); ((TMP_Text)obj).font = source.font; ((TMP_Text)obj).fontSharedMaterial = source.fontSharedMaterial; ((TMP_Text)obj).fontSize = size; ((TMP_Text)obj).alignment = (TextAlignmentOptions)514; ((TMP_Text)obj).overflowMode = (TextOverflowModes)1; ((Graphic)obj).raycastTarget = false; ((TMP_Text)obj).richText = false; Position((RectTransform)val.transform, position, dimensions); val.SetActive(true); return (TMP_Text)(object)obj; } private void DestroyPanel() { EndDrag(); if (Object.op_Implicit((Object)(object)_panel)) { Object.Destroy((Object)(object)_panel); } _panel = null; _panelRect = null; _hint = null; _dragImage = null; _dragLabel = null; _settingsButton = null; _collapseButton = null; _collapseText = null; _toggleButton = null; _toggleText = null; _handleRect = null; _views.Clear(); } private Vector2 ClampPosition(Vector2 position) { //IL_0021: 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) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)_panelRect)) { Transform parent = ((Transform)_panelRect).parent; RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null); if (val != null) { Rect rect = val.rect; float width = ((Rect)(ref rect)).width; rect = _panelRect.rect; float num = Mathf.Max(0f, (width - ((Rect)(ref rect)).width * ((Transform)_panelRect).localScale.x) / 2f); rect = _panelRect.rect; float num2 = ((Rect)(ref rect)).height * ((Transform)_panelRect).localScale.y; rect = val.rect; float num3 = Mathf.Min(0f, num2 - ((Rect)(ref rect)).height); return new Vector2(Mathf.Clamp(position.x, 0f - num, num), Mathf.Clamp(position.y, num3, 0f)); } } return position; } internal void BeginDrag(PointerEventData data) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) if ((int)data.button == 0 && Hud.IsPieceSelectionVisible() && Object.op_Implicit((Object)(object)_panelRect) && RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)((Transform)_panelRect).parent, data.position, data.pressEventCamera, ref _dragStartPointer)) { _dragStartPosition = _panelRect.anchoredPosition; _dragging = true; } } internal void Drag(PointerEventData data) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) if (_dragging && Object.op_Implicit((Object)(object)_panelRect)) { Vector2 val = default(Vector2); if (!Hud.IsPieceSelectionVisible()) { EndDrag(); } else if (RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)((Transform)_panelRect).parent, data.position, data.pressEventCamera, ref val)) { _panelRect.anchoredPosition = ClampPosition(_dragStartPosition + val - _dragStartPointer); } } } internal void EndDrag() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (_dragging) { _dragging = false; if (Object.op_Implicit((Object)(object)_panelRect)) { _position.Value = ClampPosition(_panelRect.anchoredPosition); } } } private void OnDestroy() { DestroyNativeControlHints(); DestroyWheel(); _harmony.UnpatchSelf(); CloseSettings(); DestroyPanel(); if ((Object)(object)_instance == (Object)(object)this) { _instance = null; } } private int ControllerMenuMask() { string[] array = new string[7] { "JoyDPadUp", "JoyDPadDown", "JoyDPadLeft", "JoyDPadRight", "JoyButtonA", "JoyButtonB", "JoyStart" }; int num = 0; for (int i = 0; i < array.Length; i++) { if (ZInput.GetButton(array[i])) { num |= 1 << i; } } return num; } private void OpenControllerSettings() { //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Expected O, but got Unknown //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: 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_01ba: 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: Expected O, but got Unknown //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Expected O, but got Unknown //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) if (ControllerSettingsOpen) { return; } MessageHud instance = MessageHud.instance; if (!Object.op_Implicit((Object)(object)instance) || !Object.op_Implicit((Object)(object)instance.m_messageText) || !Object.op_Implicit((Object)(object)instance.m_messageText.font) || !Object.op_Implicit((Object)(object)Hud.instance)) { return; } _wheelConsumedFrame = Time.frameCount; _controllerCapture = -1; _controllerSettingIndex = 0; _settingsHeldMask = ControllerMenuMask(); _controllerSettingsMessage = "Changes save immediately."; TMP_Text messageText = instance.m_messageText; _controllerSettingsRoot = new GameObject("ControllerHotbarSettings", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }); RectTransform val = (RectTransform)_controllerSettingsRoot.transform; ((Transform)val).SetParent(Hud.instance.m_rootObject.transform, false); val.anchorMin = Vector2.zero; val.anchorMax = Vector2.one; Vector2 offsetMin = (val.offsetMax = Vector2.zero); val.offsetMin = offsetMin; ((Graphic)_controllerSettingsRoot.GetComponent<Image>()).color = new Color(0f, 0f, 0f, 0.7f); GameObject val2 = new GameObject("Panel", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }); val2.transform.SetParent((Transform)(object)val, false); RectTransform val3 = (RectTransform)val2.transform; Vector2 val4 = default(Vector2); ((Vector2)(ref val4))..ctor(0.5f, 0.5f); val3.pivot = val4; offsetMin = (val3.anchorMax = val4); val3.anchorMin = offsetMin; val3.sizeDelta = new Vector2(650f, 780f); RectTransform val6 = (RectTransform)Hud.instance.m_rootObject.transform; Rect rect = val6.rect; float num = (((Rect)(ref rect)).width - 24f) / 650f; rect = val6.rect; float num2 = Mathf.Clamp(Mathf.Min(num, (((Rect)(ref rect)).height - 24f) / 780f), 0.1f, 1f); ((Transform)val3).localScale = Vector3.one * num2; ((Graphic)val2.GetComponent<Image>()).color = Background; Text((Transform)(object)val3, "Title", messageText, 24, new Vector2(0f, 744f), new Vector2(610f, 38f)).text = "BUILD HOTBAR SETTINGS"; NativeHint(Text((Transform)(object)val3, "Navigation", messageText, 15, new Vector2(0f, 709f), new Vector2(610f, 30f)), Glyph("JoyDPadUp") + "/" + Glyph("JoyDPadDown") + " Navigate " + Glyph("JoyDPadLeft") + "/" + Glyph("JoyDPadRight") + " Adjust " + Glyph("JoyButtonA") + " Edit " + Glyph("JoyButtonB") + " Back"); _controllerSettingRows.Clear(); for (int i = 0; i < 16; i++) { int row = i; Button item = MakeButton((Transform)(object)val3, "", messageText, new Vector2(0f, (float)(664 - i * 34)), new Vector2(590f, 30f), (UnityAction)delegate { _controllerSettingIndex = row; AdjustControllerSetting(1); }); _controllerSettingRows.Add(item); } _controllerSettingsHelp = Text((Transform)(object)val3, "Help", messageText, 15, new Vector2(0f, 73f), new Vector2(590f, 88f)); RefreshControllerSettings(); } private void PollControllerSettings() { int num = ControllerMenuMask(); int num2 = num & ~_settingsHeldMask; _settingsHeldMask = num; if (_controllerCapture >= 0) { if ((num2 & 0x40) != 0 || Input.GetKeyDown((KeyCode)27)) { _controllerCapture = -1; _controllerSettingsMessage = "Binding cancelled."; } else { WheelButtons held = ReadControllerButtons(); if (_controllerChord.Sample((int)held)) { WheelButtons buttons = (WheelButtons)_controllerChord.Buttons; bool flag = _controllerCapture == 9; if ((flag && (buttons & (WheelButtons.Cross_A | WheelButtons.Circle_B)) != WheelButtons.None) || buttons == (flag ? _wheelShortcut.Value : _wheelSaveShortcut.Value)) { _controllerSettingsMessage = "Conflict: use distinct shortcuts; save cannot contain Cross/A or Circle/B."; } else { if (flag) { _wheelSaveShortcut.Value = buttons; } else { _wheelShortcut.Value = buttons; } _controllerSettingsMessage = "Saved: " + buttons; } _controllerCapture = -1; } } RefreshControllerSettings(); } else if ((num2 & 0x60) != 0 || Input.GetKeyDown((KeyCode)27)) { CloseControllerSettings(); } else { if ((num2 & 3) == 1) { _controllerSettingIndex = (_controllerSettingIndex + _controllerSettingRows.Count - 1) % _controllerSettingRows.Count; } if ((num2 & 3) == 2) { _controllerSettingIndex = (_controllerSettingIndex + 1) % _controllerSettingRows.Count; } if ((num2 & 0xC) == 4) { AdjustControllerSetting(-1); } else if ((num2 & 0xC) == 8 || (num2 & 0x10) != 0) { AdjustControllerSetting(1); } RefreshControllerSettings(); } } private static WheelButtons ReadControllerButtons() { int num = 0; for (int i = 0; i < WheelButtonActions.Length; i++) { if (ZInput.GetButton(WheelButtonActions[i])) { num |= 1 << i; } } return (WheelButtons)num; } private void AdjustControllerSetting(int direction) { //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) if (_controllerCapture < 0) { switch (_controllerSettingIndex) { case 0: _wheelEnabled.Value = !_wheelEnabled.Value; break; case 1: _wheelToggle.Value = !_wheelToggle.Value; break; case 2: ChangeSlots(direction); break; case 3: ChangeRows(direction); break; case 4: _autoActivate.Value = !_autoActivate.Value; break; case 5: _collapsed.Value = !_collapsed.Value; break; case 6: _reverseScroll.Value = !_reverseScroll.Value; break; case 7: _wheelDeadzone.Value = Mathf.Clamp(Mathf.Round((_wheelDeadzone.Value + (float)direction * 0.05f) * 100f) / 100f, 0.15f, 0.8f); break; case 8: case 9: _controllerCapture = _controllerSettingIndex; _controllerChord.Reset(); break; case 10: { ConfigEntry<Vector2> position2 = _position; position2.Value += new Vector2((float)(direction * 10), 0f); break; } case 11: { ConfigEntry<Vector2> position = _position; position.Value += new Vector2(0f, (float)(direction * 10)); break; } case 12: ChangeScale(radial: false, direction); break; case 13: ChangeScale(radial: true, direction); break; case 14: _position.Value = new Vector2(0f, -24f); break; case 15: CloseControllerSettings(); return; } _nextRefresh = 0f; RefreshControllerSettings(); } } private void RefreshControllerSettings() { //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: 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_0276: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) if (ControllerSettingsOpen) { string[] array = new string[16] { "Controller wheel: " + (_wheelEnabled.Value ? "On" : "Off"), "Confirm selection: " + (_wheelToggle.Value ? Glyph("JoyButtonA") : "Release opening shortcut"), "Slots per row: " + _count.Value, "Saved rows: " + _rows.Value, "Auto activate on equip: " + (_autoActivate.Value ? "On" : "Off"), "Collapse horizontal hotbar: " + (_collapsed.Value ? "On" : "Off"), "Reverse mouse-wheel paging: " + (_reverseScroll.Value ? "On" : "Off"), "Stick deadzone: " + _wheelDeadzone.Value.ToString("0.00"), "Open wheel: " + ChordGlyphs(_wheelShortcut.Value), "Additional save shortcut: " + ChordGlyphs(_wheelSaveShortcut.Value), "Hotbar horizontal position: " + _position.Value.x.ToString("0"), "Hotbar vertical position: " + _position.Value.y.ToString("0"), "Horizontal hotbar size: " + ScaleLabel(_horizontalScale.Value), "Radial menu size: " + ScaleLabel(_radialScale.Value), "Reset hotbar position", "Done" }; for (int i = 0; i < array.Length; i++) { NativeHint(((Component)_controllerSettingRows[i]).GetComponentInChildren<TMP_Text>(), ((i == _controllerSettingIndex) ? "> " : "") + array[i]); ((Graphic)((Component)_controllerSettingRows[i]).GetComponent<Image>()).color = ((i == _controllerSettingIndex) ? Selected : Background); } NativeHint(_controllerSettingsHelp, (_controllerCapture >= 0) ? ("Release all buttons, then hold your new combination together.\nRelease all buttons to save. " + Glyph("JoyStart") + " cancels.\n" + ChordGlyphs((WheelButtons)_controllerChord.Buttons)) : (_controllerSettingsMessage + "\nAlso accessible from the build menu: " + Glyph("JoyStart"))); } } private void CloseControllerSettings() { if (Object.op_Implicit((Object)(object)_controllerSettingsRoot)) { _controllerSettingsRoot.SetActive(false); Object.Destroy((Object)(object)_controllerSettingsRoot); _controllerSettingsRoot = null; _controllerSettingRows.Clear(); _controllerCapture = -1; _wheelConsumedFrame = Time.frameCount; _wheelWaitRelease = true; } } private static string Glyph(string action) { ZInput instance = ZInput.instance; if (instance == null) { return action; } string boundKeyString = instance.GetBoundKeyString(action, true); if (!string.IsNullOrEmpty(boundKeyString)) { return boundKeyString; } return action; } private static string ChordGlyphs(WheelButtons buttons) { List<string> list = new List<string>(); for (int i = 0; i < WheelButtonActions.Length; i++) { if (((uint)buttons & (uint)(1 << i)) != 0) { list.Add(Glyph(WheelButtonActions[i])); } } if (list.Count != 0) { return string.Join(" + ", list); } return "Unbound"; } private static void NativeHint(TMP_Text text, string caption) { text.richText = true; text.text = caption; } private List<string> ControllerHintLines() { if (!ShowControllerHotbar) { return KeyboardHintLines(); } string item = "Page " + Glyph("JoyDPadLeft") + " / " + Glyph("JoyDPadRight"); if (_wheelOpen) { if (_wheelAssigning) { return new List<string> { "Aim / click to deselect " + Glyph("JoyLStick"), item, "Save " + Glyph("JoyRTrigger") + " (release)", "Cancel " + Glyph("JoyButtonB") }; } return new List<string> { "Save piece " + Glyph("JoyRTrigger"), "Clear slot " + Glyph("JoyLTrigger"), item, "Hotbar settings " + Glyph("JoyDPadDown"), "Select " + (_wheelToggle.Value ? Glyph("JoyButtonA") : (ChordGlyphs(_wheelShortcut.Value) + " (release)")), "Cancel " + Glyph("JoyButtonB") }; } if (Hud.IsPieceSelectionVisible()) { return new List<string> { "Assign build shortcut " + Glyph("JoyRTrigger") + " (hold)", "Hotbar settings " + Glyph("JoyStart") }; } if (!_wheelEnabled.Value) { return new List<string>(); } return new List<string> { "Build shortcuts " + ChordGlyphs(_wheelShortcut.Value) + " (hold)" }; } private void RenderControllerEntryHint() { //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Expected O, but got Unknown KeyHints nativeKeyHints = _nativeKeyHints; if (!Object.op_Implicit((Object)(object)nativeKeyHints) || !Object.op_Implicit((Object)(object)nativeKeyHints.m_buildHints) || !nativeKeyHints.m_buildHints.activeInHierarchy || !Eligible(Player.m_localPlayer) || Hud.IsUserHidden() || SettingsOpen) { RestoreVanillaControlHints(); foreach (TMP_Text nativeControlHint in _nativeControlHints) { if (Object.op_Implicit((Object)(object)nativeControlHint)) { ((Component)nativeControlHint).gameObject.SetActive(false); } } if (Object.op_Implicit((Object)(object)nativeKeyHints) && Object.op_Implicit((Object)(object)nativeKeyHints.m_buildHints) && nativeKeyHints.m_buildHints.activeInHierarchy && Eligible(Player.m_localPlayer) && Hud.IsPieceSelectionVisible() && !SettingsOpen) { HidePlacementHintsInMenu(nativeKeyHints); } return; } TMP_Text val = (TMP_Text)(object)nativeKeyHints.m_buildMenuKey; if (!ShowControllerHotbar) { TMP_Text[] componentsInChildren = nativeKeyHints.m_buildHints.GetComponentsInChildren<TMP_Text>(); foreach (TMP_Text val2 in componentsInChildren) { if (!_nativeControlHints.Contains(val2)) { val = val2; break; } } } if (!Object.op_Implicit((Object)(object)val)) { return; } Transform val3 = null; Transform parent = val.transform.parent; while (Object.op_Implicit((Object)(object)parent) && parent.IsChildOf(nativeKeyHints.m_buildHints.transform)) { if (Object.op_Implicit((Object)(object)((Component)parent).GetComponent<LayoutGroup>())) { val3 = parent; break; } parent = parent.parent; } if (!Object.op_Implicit((Object)(object)val3)) { if (!_hintLayoutWarning) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Build Hotbar: native build-hint layout was not found; no floating hints will be drawn."); } _hintLayoutWarning = true; return; } if ((Object)(object)_nativeHintParent != (Object)(object)val3 || (_nativeControlHints.Count > 0 && !Object.op_Implicit((Object)(object)_nativeControlHints[0]))) { DestroyNativeControlHints(); _nativeHintParent = val3; } List<string> list = ControllerHintLines(); while (_nativeControlHints.Count < list.Count) { TMP_Text val4 = Text(val3, "BuildHotbarNativeHint" + _nativeControlHints.Count, val, Mathf.RoundToInt(val.fontSize), Vector2.zero, val.rectTransform.sizeDelta); val4.alignment = val.alignment; ((Graphic)val4).color = ((Graphic)val).color; val4.fontStyle = val.fontStyle; val4.spriteAsset = val.spriteAsset; val4.margin = val.margin; val4.textWrappingMode = val.textWrappingMode; val4.overflowMode = val.overflowMode; ((Transform)val4.rectTransform).localScale = ((Transform)val.rectTransform).localScale; LayoutElement val5 = ((Component)val4).gameObject.AddComponent<LayoutElement>(); LayoutElement component = ((Component)val).GetComponent<LayoutElement>(); if (Object.op_Implicit((Object)(object)component)) { val5.minWidth = component.minWidth; val5.minHeight = component.minHeight; val5.preferredWidth = component.preferredWidth; val5.preferredHeight = component.preferredHeight; val5.flexibleWidth = component.flexibleWidth; val5.flexibleHeight = component.flexibleHeight; } else { Rect rect = val.rectTransform.rect; val5.minHeight = Mathf.Max(((Rect)(ref rect)).height, val.fontSize + 4f); } _nativeControlHints.Add(val4); } bool flag = false; for (int j = 0; j < _nativeControlHints.Count; j++) { TMP_Text val6 = _nativeControlHints[j]; bool flag2 = j < list.Count; if (((Component)val6).gameObject.activeSelf != flag2) { ((Component)val6).gameObject.SetActive(flag2); flag = true; } if (flag2 && val6.text != list[j]) { NativeHint(val6, list[j]); flag = true; } } if (flag) { LayoutRebuilder.MarkLayoutForRebuild((RectTransform)val3); } if (_wheelOpen) { HideVanillaControlHints(nativeKeyHints.m_buildHints.transform); } else if (Hud.IsPieceSelectionVisible()) { HidePlacementHintsInMenu(nativeKeyHints); } else { RestoreVanillaControlHints(); } } private void HidePlacementHintsInMenu(KeyHints hints) { List<Transform> list = new List<Transform>(); GameObject[] buildMenuHintsGP = hints.m_buildMenuHintsGP; foreach (GameObject val in buildMenuHintsGP) { if (Object.op_Implicit((Object)(object)val)) { list.Add(val.transform); } } buildMenuHintsGP = hints.m_buildMenuHintsKB; foreach (GameObject val2 in buildMenuHintsGP) { if (Object.op_Implicit((Object)(object)val2)) { list.Add(val2.transform); } } foreach (TMP_Text nativeControlHint in _nativeControlHints) { if (Object.op_Implicit((Object)(object)nativeControlHint)) { list.Add(nativeControlHint.transform); } } FilterBuildHintBranches(hints.m_buildHints.transform, list); } private void FilterBuildHintBranches(Transform parent, List<Transform> keep) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown foreach (Transform item in parent) { Transform child = item; if (!keep.Contains(child)) { if (keep.Exists((Transform row) => row.IsChildOf(child))) { FilterBuildHintBranches(child, keep); } else { HideVanillaHint(((Component)child).gameObject); } } } } private void HideVanillaControlHints(Transform buildHints) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)_nativeHintParent)) { return; } Transform val = _nativeHintParent; foreach (Transform item in val) { Transform child = item; if (!_nativeControlHints.Exists((TMP_Text row) => Object.op_Implicit((Object)(object)row) && (Object)(object)row.transform == (Object)(object)child)) { HideVanillaHint(((Component)child).gameObject); } } while ((Object)(object)val != (Object)(object)buildHints && Object.op_Implicit((Object)(object)val.parent) && val.IsChildOf(buildHints)) { Transform parent = val.parent; foreach (Transform item2 in parent) { Transform val2 = item2; if ((Object)(object)val2 != (Object)(object)val) { HideVanillaHint(((Component)val2).gameObject); } } val = parent; } Transform? nativeHintParent = _nativeHintParent; RectTransform val3 = (RectTransform)(object)((nativeHintParent is RectTransform) ? nativeHintParent : null); if (val3 != null) { LayoutRebuilder.MarkLayoutForRebuild(val3); } } private void HideVanillaHint(GameObject hint) { if (hint.activeSelf) { if (!_hiddenVanillaHints.Contains(hint)) { _hiddenVanillaHints.Add(hint); } hint.SetActive(false); } } private void RestoreVanillaControlHints() { if (_hiddenVanillaHints.Count == 0) { return; } foreach (GameObject hiddenVanillaHint in _hiddenVanillaHints) { if (Object.op_Implicit((Object)(object)hiddenVanillaHint)) { hiddenVanillaHint.SetActive(true); } } _hiddenVanillaHints.Clear(); Transform? nativeHintParent = _nativeHintParent; RectTransform val = (RectTransform)(object)((nativeHintParent is RectTransform) ? nativeHintParent : null); if (val != null && Object.op_Implicit((Object)(object)val)) { LayoutRebuilder.MarkLayoutForRebuild(val); } } private void DestroyNativeControlHints() { RestoreVanillaControlHints(); foreach (TMP_Text nativeControlHint in _nativeControlHints) { if (Object.op_Implicit((Object)(object)nativeControlHint)) { ((Component)nativeControlHint).gameObject.SetActive(false); Object.Destroy((Object)(object)((Component)nativeControlHint).gameObject); } } _nativeControlHints.Clear(); _nativeHintParent = null; } private void InitializeWheel() { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown _wheelEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Controller", "Paged wheel", true, "Enable building shortcuts using the configured controller combination."); _wheelShortcut = ((BaseUnityPlugin)this).Config.Bind<WheelButtons>("Controller", "Wheel shortcut", WheelButtons.Square_X, "Buttons held together to open. Combine names with commas, e.g. LeftBumper, Square_X. None disables opening. Stick clicks retain vanilla snapping unless explicitly bound here."); _wheelSaveShortcut = ((BaseUnityPlugin)this).Config.Bind<WheelButtons>("Controller", "Save shortcut", WheelButtons.RightTrigger, "Additional save combination while the normal wheel is open. Right trigger always saves; left trigger clears. Use a different combination from Wheel shortcut."); _wheelToggle = ((BaseUnityPlugin)this).Config.Bind<bool>("Controller", "Toggle wheel", false, "If enabled, A/Cross confirms explicitly. Otherwise hold the shortcut, aim with the LEFT stick, and release the shortcut to select. The last highlight stays selected when the stick returns to centre."); _wheelDeadzone = ((BaseUnityPlugin)this).Config.Bind<float>("Controller", "Wheel deadzone", 0.35f, new ConfigDescription("Left-stick selection threshold. Returning to centre retains the highlight without confirming. Independent of camera inversion.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.15f, 0.8f), Array.Empty<object>())); } private void PollWheel() { if (_readingWheel || _wheelFrame == Time.frameCount) { return; } _wheelFrame = Time.frameCount; _readingWheel = true; try { Player localPlayer = Player.m_localPlayer; if (_uiNavigationWaitForCentre) { float joyLeftStickX = ZInput.GetJoyLeftStickX(); float joyLeftStickY = ZInput.GetJoyLeftStickY(); if (!Hud.IsPieceSelectionVisible() || joyLeftStickX * joyLeftStickX + joyLeftStickY * joyLeftStickY <= _wheelDeadzone.Value * _wheelDeadzone.Value) { _uiNavigationWaitForCentre = false; } } bool button = ZInput.GetButton("JoyRTrigger"); bool flag = button && !_rightTriggerWasHeld; _rightTriggerWasHeld = button; bool button2 = ZInput.GetButton("JoyLTrigger"); bool flag2 = button2 && !_leftTriggerWasHeld; _leftTriggerWasHeld = button2; bool button3 = ZInput.GetButton("JoyLStick"); bool flag3 = button3 && !_leftClickWasHeld; _leftClickWasHeld = button3; bool button4 = ZInput.GetButton("JoyStart"); bool flag4 = button4 && !_settingsOpenWasHeld; _settingsOpenWasHeld = button4; if (ControllerSettingsOpen) { _wheelConsumedFrame = Time.frameCount; if (!Eligible(localPlayer) || !Application.isFocused || !Object.op_Implicit((Object)(object)Hud.instance) || Hud.IsUserHidden()) { CloseControllerSettings(); } else { PollControllerSettings(); } return; } if (Eligible(localPlayer) && !SettingsOpen && Hud.IsPieceSelectionVisible() && flag4) { if (_wheelOpen) { CloseWheel(button || button2 || ShortcutHeld(_wheelShortcut.Value)); } OpenControllerSettings(); return; } bool flag5 = ShortcutHeld(_wheelShortcut.Value); bool flag6 = flag5 && !_shortcutWasHeld; _shortcutWasHeld = flag5; bool flag7 = ShortcutHeld(_wheelSaveShortcut.Value); bool flag8 = flag7 && !_saveWasHeld; _saveWasHeld = flag7; bool flag9 = Hud.IsPieceSelectionVisible(); bool flag10 = (_wheelAssigning ? button : flag5); bool flag11 = flag5 || button || button2; if (_wheelWaitRelease) { _wheelConsumedFrame = Time.frameCount; if (!flag11) { _wheelWaitRelease = false; } } if (!_wheelEnabled.Value || !Eligible(localPlayer) || SettingsOpen || !Object.op_Implicit((Object)(object)Hud.instance) || !Hud.instance.m_rootObject.activeInHierarchy || Hud.IsUserHidden() || !ShowControllerHotbar || !Application.isFocused || !(bool)TakeInput.Invoke(localPlayer, null) || (_wheelOpen && ((Object)(object)localPlayer.GetBuildTool() != (Object)(object)_wheelTool || flag9 != _wheelAssigning))) { if (_wheelOpen) { CloseWheel(flag11); } return; } if (!_wheelOpen) { if (_wheelWaitRelease || !(flag9 ? flag : flag6)) { return; } _wheelOpen = true; _wheelAssigning = flag9; flag10 = (_wheelAssigning ? button : flag5); _wheelOpenedFrame = Time.frameCount; _wheelTool = localPlayer.GetBuildTool(); _wheelSource = (_wheelAssigning ? HoveredPiece.Invoke(Hud.instance) : localPlayer.GetSelectedPiece()); _wheelSlot = -1; _wheelGesture.Reset(); _wheelPaging.Reset(ZInput.GetButton("JoyDPadLeft"), ZInput.GetButton("JoyDPadRight")); _hotbarActive = true; _nextRefresh = 0f; } _wheelConsumedFrame = Time.frameCount; if (ZInput.GetButtonDown("JoyDPadDown")) { CloseWheel(flag11); OpenControllerSettings(); return; } if (Input.GetKeyDown((KeyCode)27) || (Time.frameCount != _wheelOpenedFrame && ZInput.GetButtonDown("JoyButtonB"))) { CloseWheel(flag11); return; } int num = _wheelPaging.Update(ZInput.GetButton("JoyDPadLeft"), ZInput.GetButton("JoyDPadRight"), Time.unscaledTime); if (num != 0) { _activeRow.Value = HotbarRows.Step(CurrentRow, _rows.Value, num); _nextRefresh = 0f; _wheelGesture.Reset(); _wheelSlot = -1; } _wheelGesture.Update(ZInput.GetJoyLeftStickX(), 0f - ZInput.GetJoyLeftStickY(), _wheelDeadzone.Value, _count.Value); if (flag3) { _wheelGesture.ClearHighlight(); } _wheelSlot = _wheelGesture.Selected; if (!_wheelAssigning && _wheelSlot >= 0 && Time.frameCount != _wheelOpenedFrame) { if (flag2) { Slots(_wheelTool)[_wheelSlot].Value = ""; Notify(localPlayer, "Cleared row " + CurrentRow + ", slot " + (_wheelSlot + 1)); _nextRefresh = 0f; } else if (flag || (flag8 && _wheelSaveShortcut.Value != _wheelShortcut.Value)) { SaveWheelSlot(localPlayer); } } bool num2; if (!_wheelAssigning) { if (!_wheelToggle.Value) { num2 = !flag10; } else { if (Time.frameCount == _wheelOpenedFrame) { return; } num2 = ZInput.GetButtonDown("JoyButtonA"); } } else { num2 = !button; } if (!num2) { return; } if (_wheelAssigning) { if (_wheelSlot >= 0) { SaveWheelSlot(localPlayer); } } else if (_wheelSlot >= 0) { Piece val = Resolve(_wheelTool, Slots(_wheelTool)[_wheelSlot].Value); if (Object.op_Implicit((Object)(object)val) && localPlayer.IsPieceAvailable(val) && localPlayer.SetSelectedPiece(val)) { _nextRefresh = 0f; } else { Notify(localPlayer, "This slot is empty or its piece is unavailable."); } } CloseWheel(flag11); } finally { _readingWheel = false; } } private void SaveWheelSlot(Player player) { if (Object.op_Implicit((Object)(object)_wheelSource) && player.IsPieceAvailable(_wheelSource)) { Slots(_wheelTool)[_wheelSlot].Value = ((Object)((Component)_wheelSource).gameObject).name; Notify(player, "Saved " + Label(_wheelSource) + " to row " + CurrentRow + ", slot " + (_wheelSlot + 1)); _nextRefresh = 0f; } else { Notify(player, "Highlight an available piece in the build menu first."); } } private void CloseWheel(bool waitForRelease) { RestoreVanillaControlHints(); if (_wheelAssigning) { _uiNavigationWaitForCentre = true; } _wheelOpen = false; _wheelAssigning = false; _wheelWaitRelease = waitForRelease; _wheelConsumedFrame = Time.frameCount; _wheelSlot = -1; _wheelTool = null; _wheelSource = null; if (Object.op_Implicit((Object)(object)_wheelRoot)) { _wheelRoot.SetActive(false); } } private void RenderWheel() { //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Expected O, but got Unknown //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_03a4: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_04bd: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Expected O, but got Unknown //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Expected O, but got Unknown //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_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Expected O, but got Unknown //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_0535: Unknown result type (might be due to invalid IL or missing references) //IL_053c: Unknown result type (might be due to invalid IL or missing references) PollWheel(); if (!_wheelOpen) { if (Object.op_Implicit((Object)(object)_wheelRoot)) { _wheelRoot.SetActive(false); } return; } if (!Object.op_Implicit((Object)(object)_wheelRoot)) { MessageHud instance = MessageHud.instance; if (!Object.op_Implicit((Object)(object)instance) || !Object.op_Implicit((Object)(object)instance.m_messageText) || !Object.op_Implicit((Object)(object)instance.m_messageText.font)) { return; } TMP_Text messageText = instance.m_messageText; _wheelRoot = new GameObject("BuildHotbar_ControllerWheel", new Type[1] { typeof(RectTransform) }); _wheelRoot.transform.SetParent(Hud.instance.m_rootObject.transform, false); RectTransform val = (RectTransform)_wheelRoot.transform; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0.5f, 0.5f); val.pivot = val2; Vector2 anchorMin = (val.anchorMax = val2); val.anchorMin = anchorMin; val.sizeDelta = Vector2.zero; _wheelViews.Clear(); for (int i = 0; i < 8; i++) { float num = (float)i * (float)Math.PI / 4f; GameObject val4 = new GameObject("Direction" + i, new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(RadialSlice) }); val4.transform.SetParent((Transform)(object)val, false); Position((RectTransform)val4.transform, Vector2.zero, new Vector2(536f, 536f)); RadialSlice component = val4.GetComponent<RadialSlice>(); component.Slot = i; ((Graphic)component).SetVerticesDirty(); ((Graphic)component).raycastTarget = false; Vector2 val5 = new Vector2(Mathf.Sin(num), Mathf.Cos(num)) * 195f; val5.y += 268f; GameObject val6 = new GameObject("Icon", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }); val6.transform.SetParent(val4.transform, false); Position((RectTransform)val6.transform, val5 + new Vector2(0f, 10f), new Vector2(48f, 48f)); Image component2 = val6.GetComponent<Image>(); ((Graphic)component2).raycastTarget = false; component2.preserveAspect = true; TMP_Text label = Text(val4.transform, "Piece", messageText, 14, val5 + new Vector2(0f, -30f), new Vector2(104f, 34f)); TMP_Text val7 = Text(val4.transform, "Slot", messageText, 12, val5 + new Vector2(0f, 45f), new Vector2(24f, 20f)); ((Component)val7).gameObject.SetActive(false); _wheelViews.Add(new SlotView((Image)(object)component, component2, label, val7)); } _wheelTitle = Text((Transform)(object)val, "Page", messageText, 21, new Vector2(0f, 310f), new Vector2(360f, 60f)); } _wheelRoot.SetActive(true); RectTransform val8 = (RectTransform)_wheelRoot.transform.parent; Transform transform = _wheelRoot.transform; Vector3 one = Vector3.one; float value = _radialScale.Value; Rect rect = val8.rect; float availableWidth = ((Rect)(ref rect)).width - 24f; rect = val8.rect; transform.localScale = one * HotbarScale.Fit(value, 536f, 680f, availableWidth, ((Rect)(ref rect)).height - 24f); _wheelRoot.transform.SetAsLastSibling(); _wheelTitle.text = (_wheelAssigning ? "SAVE BUILD PIECE" : "BUILD SHORTCUTS") + "\nRow " + CurrentRow + " / " + _rows.Value; ConfigEntry<string>[] array = Slots(_wheelTool); for (int j = 0; j < 8; j++) { SlotView slotView = _wheelViews[j]; ((Component)slotView.Background).gameObject.SetActive(j < _count.Value); Piece val9 = Resolve(_wheelTool, array[j].Value); ((Graphic)slotView.Background).color = HotbarFill(j == _wheelSlot); slotView.Icon.sprite = (Object.op_Implicit((Object)(object)val9) ? val9.m_icon : null); ((Behaviour)slotView.Icon).enabled = Object.op_Implicit((Object)(object)slotView.Icon.sprite); ((Graphic)slotView.Icon).color = (Color)((Object.op_Implicit((Object)(object)val9) && Player.m_localPlayer.IsPieceAvailable(val9)) ? Color.white : new Color(1f, 1f, 1f, 0.3f)); slotView.Label.text = (Object.op_Implicit((Object)(object)val9) ? Label(val9) : (string.IsNullOrEmpty(array[j].Value) ? "Empty" : "Unavailable")); } } private void DestroyWheel() { if (Object.op_Implicit((Object)(object)_wheelRoot)) { Object.Destroy((Object)(object)_wheelRoot); } _wheelRoot = null; _wheelViews.Clear(); } private void InitializeBindings() { _scrollKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Key bindings", "Row scroll key", (KeyCode)308, "Hold this key with the mouse wheel to switch rows. None disables row scrolling."); _saveKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Key bindings", "Save key", (KeyCode)304, "Hold with a slot key to save the hovered or selected piece."); _clearKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Key bindings", "Clear key", (KeyCode)308, "Hold with a slot key to clear it."); for (int i = 0; i < 8; i++) { _slotKeys[i] = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Key bindings", "Slot " + (i + 1) + " key", (KeyCode)(49 + i), "Select this slot on the current row. Rebind in the built-in settings."); } _collapsed = ((BaseUnityPlugin)this).Config.Bind<bool>("Display", "Collapsed", false, "Hide the slots but retain the title, Settings and expand control. Slot shortcuts remain active."); } private static KeyCode Canonical(KeyCode key) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Invalid comparison between Unknown and I4 //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 //IL_002a: Unknown result type (might be due to invalid IL or missing references) if ((int)key == 303) { return (KeyCode)304; } if ((int)key == 305) { return (KeyCode)306; } if ((int)key == 307) { return (KeyCode)308; } return key; } private static bool Held(KeyCode key) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_001b: Invalid comparison between Unknown and I4 //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Invalid comparison between Unknown and I4 //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Invalid comparison between Unknown and I4 if ((int)key == 0) { return false; } key = Canonical(key); if (!Input.GetKey(key) && ((int)key != 304 || !Input.GetKey((KeyCode)303)) && ((int)key != 306 || !Input.GetKey((KeyCode)305))) { if ((int)key == 308) { return Input.GetKey((KeyCode)307); } return false; } return true; } private unsafe static string KeyName(KeyCode key) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Invalid comparison between Unknown and I4 //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected I4, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Invalid comparison between Unknown and I4 if ((int)key == 0) { return "Unbound"; } if ((int)key >= 48 && (int)key <= 57) { return (key - 48).ToString(); } if ((int)Canonical(key) == 304) { return "Shift"; } if ((int)Canonical(key) == 308) { return "Alt"; } if ((int)Canonical(key) == 306) { return "Ctrl"; } return ((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString(); } private void TriggerSlot(Player player, int slot) { if (_slotFrames[slot] != Time.frameCount) { _slotFrames[slot] = Time.frameCount; HandleSlot(player, slot); } } private void StartBinding(ConfigEntry<KeyCode> entry) { _capture = entry; _captureFrame = Time.frameCount; _bindingMessage = "Press a key for " + ((ConfigEntryBase)entry).Definition.Key + ". Esc cancels; Backspace unbinds."; RefreshSettings(); } private bool BindingConflict(ConfigEntry<KeyCode> target, KeyCode key) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: 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_0102: Unknown result type (might be due to invalid IL or missing references) if ((int)key == 0) { return false; } if (target != _toggleKey && Canonical(key) == Canonical(_toggleKey.Value)) { return true; } if (target == _toggleKey && (Canonical(key) == Canonical(_saveKey.Value) || Canonical(key) == Canonical(_clearKey.Value) || Canonical(key) == Canonical(_scrollKey.Value))) { return true; } ConfigEntry<KeyCode>[] slotKeys = _slotKeys; foreach (ConfigEntry<KeyCode> val in slotKeys) { if (val != target && Canonical(val.Value) == Canonical(key)) { return true; } } if (Array.IndexOf(_slotKeys, target) >= 0 && (Canonical(key) == Canonical(_saveKey.Value) || Canonical(key) == Canonical(_clearKey.Value) || Canonical(key) == Canonical(_scrollKey.Value))) { return true; } if (target != _saveKey || Canonical(key) != Canonical(_clearKey.Value)) { if (target == _clearKey) { return Canonical(key) == Canonical(_saveKey.Value); } return false; } return true; } private void CaptureBinding() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Invalid comparison between Unknown and I4 //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Invalid comparison between Unknown and I4 //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) if (_capture == null || Time.frameCount <= _captureFrame) { return; } if (Input.GetKeyDown((KeyCode)27)) { _capture = null; _bindingMessage = "Binding cancelled."; RefreshSettings(); return; } KeyCode[] captureKeys = CaptureKeys; foreach (KeyCode val in captureKeys) { if ((int)val != 0 && (int)val < 323 && Input.GetKeyDown(val)) { KeyCode val2 = (KeyCode)(((int)val != 8) ? ((int)val) : 0); if (BindingConflict(_capture, val2)) { _bindingMessage = "That key is already assigned. Choose another key, or unbind the other action first."; RefreshSettings(); break; } _capture.Value = val2; _bindingMessage = ((ConfigEntryBase)_capture).Definition.Key + " saved: " + KeyName(val2); _capture = null; _nextRefresh = 0f; RefreshSettings(); break; } } } private void BindingButton(Transform parent, TMP_Text font, ConfigEntry<KeyCode> entry, Vector2 position, Vector2 size) { //IL_001b: 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_0028: 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_003b: Expected O, but got Unknown Button val = MakeButton(parent, KeyName(entry.Value), font, position, size, (UnityAction)delegate { StartBinding(entry); }); _bindingLabels.Add(Tuple.Create<ConfigEntry<KeyCode>, TMP_Text>(entry, ((Component)val).GetComponentInChildren<TMP_Text>())); } private void ApplyCollapsed() { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)_panelRect) || !Object.op_Implicit((Object)(object)_handleRect)) { return; } bool flag = _collapsed.Value || !_hotbarActive; float num = (flag ? 28 : 126); _panelRect.sizeDelta = new Vector2(_panelRect.sizeDelta.x, num); _handleRect.anchoredPosition = new Vector2(0f, num - 14f); if (Object.op_Implicit((Object)(object)_settingsButton)) { ((RectTransform)_settingsButton.transform).anchoredPosition = new Vector2(_panelRect.sizeDelta.x / 2f - 94f, num - 14f); } if (Object.op_Implicit((Object)(object)_toggleButton)) { ((RectTransform)_toggleButton.transform).anchoredPosition = new Vector2(_panelRect.sizeDelta.x / 2f - 170f, num - 14f); } if (Object.op_Implicit((Object)(object)_toggleText)) { _toggleText.text = (_hotbarActive ? "Disable" : "Enable"); } if (Object.op_Implicit((Object)(object)_collapseButton)) { ((RectTransform)_collapseButton.transform).anchoredPosition = new Vector2(_panelRect.sizeDelta.x / 2f - 24f, num - 14f); } if (Object.op_Implicit((Object)(object)_collapseText)) { _collapseText.text = (_collapsed.Value ? "+" : "−"); } foreach (SlotView view in _views) { ((Component)view.Background).gameObject.SetActive(!flag); } if (Object.op_Implicit((Object)(object)_hint)) { ((Component)_hint).gameObject.SetActive(false); } } private void InitializeScale() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown _horizontalScale = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "Horizontal hotbar scale", 1f, new ConfigDescription("Horizontal hotbar size. 1 = 100%. Automatically fits within the screen.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2f), Array.Empty<object>())); _radialScale = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "Radial menu scale", 1f, new ConfigDescription("Radial menu size including icons and labels. 1 = 100%. Automatically fits within the screen.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2f), Array.Empt