using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Entities; using Jotunn.Managers; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("SonicChestFilters")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1+daeb12fe14336c3cde1064af94634546a47507bc")] [assembly: AssemblyProduct("SonicChestFilters")] [assembly: AssemblyTitle("SonicChestFilters")] [assembly: AssemblyVersion("1.0.1.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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 SonicChestFilters { internal static class ChestFilter { internal static string Query { get; private set; } = string.Empty; internal static bool HasQuery => !string.IsNullOrWhiteSpace(Query); internal static void SetQuery(string query) { Query = query ?? string.Empty; } internal static void Clear() { Query = string.Empty; } internal static bool ItemIsVisible(ItemData item) { if (!HasQuery) { return true; } if (item?.m_shared == null) { return true; } string matchedLabel; return ItemMatch.ItemMatchesPattern(item, Query.Trim(), out matchedLabel); } internal static void ApplyToGrid(InventoryGrid grid, Inventory inventory) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0070: 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) if ((Object)grid == (Object)null || inventory == null || !(AccessTools.Field(typeof(InventoryGrid), "m_elements")?.GetValue(grid) is List list)) { return; } for (int i = 0; i < list.Count; i++) { InventoryElement val = list[i]; if (!((Object)val == (Object)null)) { if (!HasQuery || !val.m_used) { RestoreClickable(val); } else if (ItemIsVisible(inventory.GetItemAt(val.Position.x, val.Position.y))) { RestoreClickable(val); } else { HideOccupied(val); } } } } private static void RestoreClickable(InventoryElement element) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown if ((Object)element.m_button != (Object)null) { ((Selectable)element.m_button).interactable = true; } } private static void HideOccupied(InventoryElement element) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown SetGraphicEnabled((Graphic)(object)element.m_icon, enabled: false); SetGraphicEnabled((Graphic)(object)element.m_amount, enabled: false); SetGraphicEnabled((Graphic)(object)element.m_quality, enabled: false); SetGraphicEnabled((Graphic)(object)element.m_equiped, enabled: false); SetGraphicEnabled((Graphic)(object)element.m_queued, enabled: false); SetGraphicEnabled((Graphic)(object)element.m_noteleport, enabled: false); SetGraphicEnabled((Graphic)(object)element.m_food, enabled: false); if ((Object)element.m_durability != (Object)null) { ((Component)element.m_durability).gameObject.SetActive(false); } if ((Object)element.m_tooltip != (Object)null) { ((Behaviour)element.m_tooltip).enabled = false; } if ((Object)element.m_button != (Object)null) { ((Selectable)element.m_button).interactable = false; } element.m_canBeDroppedOn = false; } private static void SetGraphicEnabled(Graphic graphic, bool enabled) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown if ((Object)graphic != (Object)null) { ((Behaviour)graphic).enabled = enabled; } } } internal static class ChestPanelUi { [CompilerGenerated] private static class <>O { public static UnityAction <0>__OnFilterChanged; public static UnityAction <1>__OnClearClicked; public static UnityAction <2>__OnSortClicked; } private const string FilterRootName = "SonicChestFilters_Root"; private const float ToolbarHeight = 44f; private static GameObject _root; private static Button _clearButton; private static InputField _filterInput; private static string _lastFilterText = string.Empty; private static Container _boundContainer; private static bool _expanded; private static bool _inputBlocked; private static bool FilterFieldFocused { get { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown if ((Object)_filterInput != (Object)null) { return _filterInput.isFocused; } return false; } } internal static void EnsureControls(InventoryGui gui) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_005c: 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_006c: Expected O, but got Unknown //IL_006c: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown if ((Object)gui == (Object)null || (Object)gui.m_container == (Object)null) { return; } if (SonicChestFiltersPlugin.Enabled == null || !SonicChestFiltersPlugin.Enabled.Value) { DestroyControls(gui); return; } Container val = GameAccess.Get(gui, "m_currentContainer"); if ((Object)val == (Object)null) { return; } if ((Object)_boundContainer != (Object)val) { RestoreFrame(gui); DestroyWidgets(); } if (GUIManager.Instance != null) { if ((Object)_root == (Object)null) { CreateToolbar(gui); _boundContainer = val; } ApplyFrameLayout(gui); RefreshClearButton(); } } internal static void Tick() { SyncInputBlock(FilterFieldFocused); SyncFilterField(); } internal static void ResetFilterText() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown _lastFilterText = string.Empty; ChestFilter.Clear(); if ((Object)_filterInput != (Object)null) { _filterInput.SetTextWithoutNotify(string.Empty); } RefreshClearButton(); RefreshContainerGrid(); } internal static void DestroyControls() { DestroyControls(InventoryGui.instance); } internal static void DestroyControls(InventoryGui gui) { RestoreFrame(gui); DestroyWidgets(); _boundContainer = null; } private static void CreateToolbar(InventoryGui gui) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0050: 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) //IL_007a: 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_00cc: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Expected O, but got Unknown //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Expected O, but got Unknown //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Expected O, but got Unknown //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Expected O, but got Unknown //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Expected O, but got Unknown //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Expected O, but got Unknown //IL_0235: 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_0240: Expected O, but got Unknown //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Expected O, but got Unknown RectTransform container = gui.m_container; _root = new GameObject("SonicChestFilters_Root", new Type[1] { typeof(RectTransform) }); _root.transform.SetParent((Transform)(object)container, false); RectTransform component = _root.GetComponent(); component.anchorMin = new Vector2(0f, 1f); component.anchorMax = new Vector2(1f, 1f); component.pivot = new Vector2(0.5f, 1f); component.sizeDelta = new Vector2(0f, 44f); float num = 101f; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0f, 0.5f); if (SonicChestFiltersPlugin.EnableFilterBox == null || SonicChestFiltersPlugin.EnableFilterBox.Value) { GameObject val2 = GUIManager.Instance.CreateInputField((Transform)(object)component, val, val, new Vector2(num, 0f), (ContentType)0, ModLocalization.Translate("$sonic_chestfilters_filter", "Filter..."), 16, 170f, 28f); if ((Object)val2 != (Object)null) { ((Object)val2).name = "SonicChestFilters_FilterField"; _filterInput = val2.GetComponent(); if ((Object)_filterInput != (Object)null) { _filterInput.characterLimit = 64; _filterInput.SetTextWithoutNotify(string.Empty); ((UnityEvent)(object)_filterInput.onValueChanged).AddListener((UnityAction)OnFilterChanged); ((UnityEvent)(object)_filterInput.onEndEdit).AddListener((UnityAction)OnFilterChanged); } num += 133f; } GameObject val3 = GUIManager.Instance.CreateButton(ModLocalization.Translate("$sonic_chestfilters_clear", "Clear"), (Transform)(object)component, val, val, new Vector2(num, 0f), 80f, 28f); if ((Object)val3 != (Object)null) { ((Object)val3).name = "SonicChestFilters_Clear"; _clearButton = val3.GetComponent