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 Better Organisation v1.0.0
plugins/ChestCategories.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.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using ChestCategories.Categories; using ChestCategories.Chests; using ChestCategories.Compat; using ChestCategories.Features; using ChestCategories.UI; using ChestCategories.Util; using HarmonyLib; 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: InternalsVisibleTo("LogicTests")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")] [assembly: AssemblyCompany("ChestCategories contributors")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Category based chest organisation for Valheim.")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ChestCategories")] [assembly: AssemblyTitle("ChestCategories")] [assembly: AssemblyVersion("1.0.0.0")] namespace ChestCategories { public enum SummaryMode { None, Brief, Detailed } public enum SortMode { Category, Name, Weight, Value } public enum ToolbarAnchor { BelowChest, AboveChest } internal static class ModConfig { public static ConfigEntry<float> Range; public static ConfigEntry<bool> PlayerBuiltOnly; public static ConfigEntry<bool> IncludeVehicles; public static ConfigEntry<int> DefaultPriority; public static ConfigEntry<bool> AllowRemoteOpen; public static ConfigEntry<bool> SkipHotbar; public static ConfigEntry<string> KeepCategories; public static ConfigEntry<string> KeepItems; public static ConfigEntry<bool> StackIntoUnconfigured; public static ConfigEntry<int> UnconfiguredPriority; public static ConfigEntry<bool> HighlightChests; public static ConfigEntry<float> HighlightSeconds; public static ConfigEntry<SummaryMode> Summary; public static ConfigEntry<bool> ReorganizeEnabled; public static ConfigEntry<float> ReorganizeRange; public static ConfigEntry<bool> ReorganizeOnSleep; public static ConfigEntry<bool> ReorganizeUnconfiguredSources; public static ConfigEntry<bool> SortAfterReorganize; public static ConfigEntry<SortMode> Sorting; public static ConfigEntry<bool> MergeStacks; public static ConfigEntry<bool> ShowToolbar; public static ConfigEntry<ToolbarAnchor> ToolbarPosition; public static ConfigEntry<Vector2> ToolbarOffset; public static ConfigEntry<Vector2> InventoryToolbarOffset; public static ConfigEntry<Vector2> WindowOffset; public static ConfigEntry<float> UiScale; public static ConfigEntry<bool> ShowHoverInfo; public static ConfigEntry<bool> ShowLabelAsTitle; public static ConfigEntry<float> DimAlpha; public static ConfigEntry<bool> SearchDimsPlayerInventory; public static ConfigEntry<Color> FavoriteColor; public static ConfigEntry<Color> AccentColor; public static ConfigEntry<KeyboardShortcut> StashKey; public static ConfigEntry<KeyboardShortcut> SortKey; public static ConfigEntry<KeyboardShortcut> ManagerKey; public static ConfigEntry<KeyboardShortcut> ReorganizeKey; public static ConfigEntry<KeyboardShortcut> SearchKey; public static ConfigEntry<KeyboardShortcut> FavoriteModifier; public static ConfigEntry<bool> AzuAutoStoreIntegration; public static ConfigEntry<bool> AzuAutoStoreBypassExisting; public static ConfigEntry<bool> AzuAutoStoreRespectFavorites; public static ConfigEntry<bool> DebugLogging; private static readonly HashSet<string> KeepCategorySet = new HashSet<string>(StringComparer.OrdinalIgnoreCase); private static readonly HashSet<string> KeepItemSet = new HashSet<string>(StringComparer.Ordinal); public static void Bind(ConfigFile cfg) { //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_04c0: Unknown result type (might be due to invalid IL or missing references) //IL_04fb: Unknown result type (might be due to invalid IL or missing references) //IL_0528: Unknown result type (might be due to invalid IL or missing references) //IL_0556: Unknown result type (might be due to invalid IL or missing references) //IL_0584: Unknown result type (might be due to invalid IL or missing references) //IL_05ab: Unknown result type (might be due to invalid IL or missing references) //IL_05e2: Unknown result type (might be due to invalid IL or missing references) //IL_0613: Unknown result type (might be due to invalid IL or missing references) Range = cfg.Bind<float>("1 - General", "Range", 15f, Describe("Radius in metres around the player that is searched for chests when stashing, finding items and listing chests.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 64f), 100)); PlayerBuiltOnly = cfg.Bind<bool>("1 - General", "Player built chests only", true, Describe("Ignore containers that were not placed by a player (dungeon chests, shipwrecks and other world loot).", null, 90)); IncludeVehicles = cfg.Bind<bool>("1 - General", "Include carts and ships", false, Describe("Allow the storage of carts and ships to take part in stashing and reorganising.", null, 80)); DefaultPriority = cfg.Bind<int>("1 - General", "Default chest priority", 5, Describe("Priority given to a chest when you first assign categories to it. Lower numbers are filled first.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 99), 70)); AllowRemoteOpen = cfg.Bind<bool>("1 - General", "Open chests from the chest list", true, Describe("Allow the 'Open' button of the chest list to open a chest within Range without walking up to it. Wards, private chests and chests that are in use stay closed as usual.", null, 60)); SkipHotbar = cfg.Bind<bool>("2 - Stash", "Keep hotbar", true, Describe("Never stash or sort items that are on the hotbar (the first inventory row).", null, 100)); KeepCategories = cfg.Bind<string>("2 - Stash", "Keep categories", "", Describe("Comma separated category or group ids that are never stashed from your inventory, e.g. 'food.meals, meads, ammo'. Use the console command 'cc_dump' to list all ids.", null, 90)); KeepItems = cfg.Bind<string>("2 - Stash", "Keep items", "", Describe("Comma separated item prefab names that are never stashed from your inventory, e.g. 'Hammer, Hoe'.", null, 80)); StackIntoUnconfigured = cfg.Bind<bool>("2 - Stash", "Stack into chests without categories", true, Describe("Chests that have no categories still accept items they already contain, like the vanilla 'place stacks' button.", null, 70)); UnconfiguredPriority = cfg.Bind<int>("2 - Stash", "Priority of chests without categories", 50, Describe("Priority used for chests without categories when 'Stack into chests without categories' is on.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 99), 60)); HighlightChests = cfg.Bind<bool>("2 - Stash", "Highlight chests", true, Describe("Briefly highlight every chest that received items.", null, 50)); HighlightSeconds = cfg.Bind<float>("2 - Stash", "Highlight duration", 3f, Describe("How long chests stay highlighted, in seconds.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 15f), 40)); Summary = cfg.Bind<SummaryMode>("2 - Stash", "Summary message", SummaryMode.Brief, Describe("What to show after stashing. Detailed also lists each chest in the top left corner.", null, 30)); ReorganizeEnabled = cfg.Bind<bool>("3 - Reorganize", "Enabled", false, Describe("Allow 'Reorganize': items lying in the wrong chest are moved to a chest that is linked to their category.", null, 100)); ReorganizeRange = cfg.Bind<float>("3 - Reorganize", "Range", 20f, Describe("Radius in metres around the player in which chests are reorganised.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 64f), 90)); ReorganizeOnSleep = cfg.Bind<bool>("3 - Reorganize", "Reorganize when going to sleep", false, Describe("Automatically reorganise nearby chests when you go to bed. Requires 'Enabled'.", null, 80)); ReorganizeUnconfiguredSources = cfg.Bind<bool>("3 - Reorganize", "Also empty chests without categories", false, Describe("Also move items out of chests that have no categories when another chest is linked to their category.", null, 70)); SortAfterReorganize = cfg.Bind<bool>("3 - Reorganize", "Sort chests afterwards", true, Describe("Sort the contents of every chest that was touched by a reorganise.", null, 60)); Sorting = cfg.Bind<SortMode>("4 - Sorting", "Sort by", SortMode.Category, Describe("Order used by the sort button. Category groups items the same way the category list does.", null, 100)); MergeStacks = cfg.Bind<bool>("4 - Sorting", "Merge stacks", true, Describe("Combine partial stacks of the same item before sorting.", null, 90)); ShowToolbar = cfg.Bind<bool>("5 - Interface", "Show chest toolbar", true, Describe("Show the ChestCategories buttons next to an open chest.", null, 100)); ToolbarPosition = cfg.Bind<ToolbarAnchor>("5 - Interface", "Toolbar position", ToolbarAnchor.BelowChest, Describe("Where the toolbar is attached to the chest window.", null, 90)); ToolbarOffset = cfg.Bind<Vector2>("5 - Interface", "Toolbar offset", Vector2.zero, Describe("Extra offset of the chest toolbar in UI pixels. Use this if another mod puts buttons in the same spot.", null, 80)); InventoryToolbarOffset = cfg.Bind<Vector2>("5 - Interface", "Inventory toolbar offset", Vector2.zero, Describe("Extra offset of the buttons below your own inventory (shown while no chest is open) in UI pixels.", null, 75)); WindowOffset = cfg.Bind<Vector2>("5 - Interface", "Window offset", new Vector2(380f, 0f), Describe("Offset of the category editor and chest manager windows from the centre of the screen.", null, 70)); UiScale = cfg.Bind<float>("5 - Interface", "Scale", 1f, Describe("Scale of all ChestCategories windows.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.6f, 1.6f), 60)); ShowHoverInfo = cfg.Bind<bool>("5 - Interface", "Show categories when looking at a chest", true, Describe("Add the label, categories and priority of a chest to its hover text.", null, 50)); ShowLabelAsTitle = cfg.Bind<bool>("5 - Interface", "Use label as chest title", true, Describe("Show the custom label instead of the chest name in the chest window.", null, 40)); DimAlpha = cfg.Bind<float>("5 - Interface", "Search dim strength", 0.15f, Describe("Opacity of items that do not match the search text.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 0.9f), 30)); SearchDimsPlayerInventory = cfg.Bind<bool>("5 - Interface", "Search also dims your inventory", true, Describe("Apply the search highlight to your own inventory as well as the chest.", null, 20)); FavoriteColor = cfg.Bind<Color>("5 - Interface", "Favourite marker colour", new Color(1f, 0.72f, 0.2f, 0.9f), Describe("Colour of the marker that is drawn on favourited items.", null, 10)); AccentColor = cfg.Bind<Color>("5 - Interface", "Accent colour", new Color(1f, 0.78f, 0.35f, 1f), Describe("Accent colour used for headers and selected categories.", null, 5)); StashKey = cfg.Bind<KeyboardShortcut>("6 - Hotkeys", "Stash inventory", new KeyboardShortcut((KeyCode)104, Array.Empty<KeyCode>()), Describe("Move every item in your inventory into the nearby chest that is linked to its category.", null, 100)); SortKey = cfg.Bind<KeyboardShortcut>("6 - Hotkeys", "Sort", new KeyboardShortcut((KeyCode)106, Array.Empty<KeyCode>()), Describe("While the inventory is open: sort the open chest, or your own inventory when no chest is open.", null, 90)); ManagerKey = cfg.Bind<KeyboardShortcut>("6 - Hotkeys", "Chest manager", new KeyboardShortcut((KeyCode)107, Array.Empty<KeyCode>()), Describe("Open the chest manager: every nearby chest, what it holds and where a given item is stored.", null, 80)); ReorganizeKey = cfg.Bind<KeyboardShortcut>("6 - Hotkeys", "Reorganize chests", KeyboardShortcut.Empty, Describe("Reorganise all nearby chests. Not bound by default. Requires 'Reorganize > Enabled'.", null, 70)); SearchKey = cfg.Bind<KeyboardShortcut>("6 - Hotkeys", "Focus search", new KeyboardShortcut((KeyCode)102, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), Describe("While a chest is open: jump to the search box.", null, 60)); FavoriteModifier = cfg.Bind<KeyboardShortcut>("6 - Hotkeys", "Favourite item modifier", new KeyboardShortcut((KeyCode)308, Array.Empty<KeyCode>()), Describe("Hold this key and click an item to favourite it. Favourited items are never stashed or sorted, wherever you move them.", null, 50)); AzuAutoStoreIntegration = cfg.Bind<bool>("7 - Compatibility", "AzuAutoStore: respect categories", true, Describe("When AzuAutoStore is installed, chests that have categories only accept items of those categories from AzuAutoStore.", null, 100)); AzuAutoStoreBypassExisting = cfg.Bind<bool>("7 - Compatibility", "AzuAutoStore: categories count as existing items", true, Describe("A chest with categories accepts matching items from AzuAutoStore even when 'Must Have Existing Item To Pull' is on and the chest does not contain that item yet.", null, 90)); AzuAutoStoreRespectFavorites = cfg.Bind<bool>("7 - Compatibility", "AzuAutoStore: respect favourites", true, Describe("Items and slots that are favourited in AzuAutoStore are never stashed or sorted by ChestCategories.", null, 80)); DebugLogging = cfg.Bind<bool>("8 - Debug", "Debug logging", false, Describe("Write detailed information to the BepInEx log.", null, 100)); KeepCategories.SettingChanged += delegate { RebuildKeepSets(); }; KeepItems.SettingChanged += delegate { RebuildKeepSets(); }; RebuildKeepSets(); } public static bool IsKeptCategory(string categoryId, string groupId) { if (KeepCategorySet.Count > 0) { if (!KeepCategorySet.Contains(categoryId)) { return KeepCategorySet.Contains(groupId); } return true; } return false; } public static bool IsKeptItem(string prefabName) { if (KeepItemSet.Count > 0 && prefabName != null) { return KeepItemSet.Contains(prefabName); } return false; } private static void RebuildKeepSets() { Fill(KeepCategorySet, KeepCategories.Value); Fill(KeepItemSet, KeepItems.Value); } private static void Fill(HashSet<string> set, string csv) { set.Clear(); if (string.IsNullOrWhiteSpace(csv)) { return; } string[] array = csv.Split(new char[2] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (text.Length > 0) { set.Add(text); } } } private static ConfigDescription Describe(string text, AcceptableValueBase range, int order) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown return new ConfigDescription(text, range, new object[1] { new ConfigurationManagerAttributes { Order = order } }); } } internal sealed class ConfigurationManagerAttributes { public int? Order; public bool? IsAdvanced; public bool? Browsable; } [BepInPlugin("com.chestcategories.valheim", "Better Organisation", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string ModGuid = "com.chestcategories.valheim"; public const string ModName = "Better Organisation"; public const string ModVersion = "1.0.0"; private Harmony _harmony; internal static Plugin Instance { get; private set; } private void Awake() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown Instance = this; Log.Init(((BaseUnityPlugin)this).Logger); ModConfig.Bind(((BaseUnityPlugin)this).Config); GameAccess.Init(); _harmony = new Harmony("com.chestcategories.valheim"); try { _harmony.PatchAll(typeof(Plugin).Assembly); } catch (Exception e) { Log.Error("Patching the game failed. ChestCategories is not compatible with this game version", e); _harmony.UnpatchSelf(); return; } CategoryService.Init(); ModCompat.Init(); AzuAutoStoreCompat.Init(_harmony); Log.Info("Better Organisation 1.0.0 loaded."); } private void OnDestroy() { CategoryService.Shutdown(); Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void Update() { try { CategoryService.Update(); if (!((Object)(object)Player.m_localPlayer == (Object)null)) { ContainerAccess.Update(); StashService.Update(); ReorganizeService.Update(); Highlighter.Update(); HandleHotkeys(); } } catch (Exception e) { Log.Error("Update failed", e); } } private static void HandleHotkeys() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_0065: 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) if (!CanUseHotkeys()) { return; } if (InputHelper.IsDown(ModConfig.StashKey.Value)) { StashService.StashAll(); } else if (InputHelper.IsDown(ModConfig.ReorganizeKey.Value)) { ReorganizeService.Run(quiet: false); } else if (InputHelper.IsDown(ModConfig.ManagerKey.Value)) { ModUi.Instance?.ToggleManager(); } else { if (!InventoryGui.IsVisible()) { return; } if (InputHelper.IsDown(ModConfig.SearchKey.Value)) { ModUi.Instance?.FocusSearch(); } else if (InputHelper.IsDown(ModConfig.SortKey.Value)) { Container currentContainer = GameAccess.CurrentContainer; if (Object.op_Implicit((Object)(object)currentContainer)) { SortService.SortContainer(currentContainer, announce: true); } else { SortService.SortPlayerInventory(Player.m_localPlayer); } } } } private static bool CanUseHotkeys() { if (ModUi.IsAnyTextFieldFocused) { return false; } if ((Object)(object)Chat.instance != (Object)null && Chat.instance.HasFocus()) { return false; } if (Console.IsVisible() || TextInput.IsVisible() || Menu.IsVisible()) { return false; } if (Minimap.InTextInput() || Minimap.IsOpen()) { return false; } if (StoreGui.IsVisible()) { return false; } if ((Object)(object)TextViewer.instance != (Object)null && TextViewer.instance.IsVisible()) { return false; } Player localPlayer = Player.m_localPlayer; if (!((Character)localPlayer).IsDead() && !((Character)localPlayer).InCutscene() && !((Character)localPlayer).IsTeleporting()) { return !localPlayer.IsSleeping(); } return false; } } } namespace ChestCategories.Util { internal static class GameAccess { private static FieldRef<InventoryGui, Container> _currentContainer; private static FieldRef<Container, ZNetView> _containerNview; private static Func<Container, long, bool> _checkAccess; private static Func<Container, bool> _containerLoad; private static Action<Inventory, bool, bool> _inventoryChanged; private static Action<InventoryGui> _closeContainer; public static Container CurrentContainer { get { InventoryGui instance = InventoryGui.instance; if ((Object)(object)instance == (Object)null || _currentContainer == null) { return null; } Container val = _currentContainer.Invoke(instance); if (!Object.op_Implicit((Object)(object)val)) { return null; } return val; } } public static void Init() { if ((1u & (Try("InventoryGui.m_currentContainer", delegate { _currentContainer = AccessTools.FieldRefAccess<InventoryGui, Container>("m_currentContainer"); }) ? 1u : 0u) & (Try("Container.m_nview", delegate { _containerNview = AccessTools.FieldRefAccess<Container, ZNetView>("m_nview"); }) ? 1u : 0u) & (Try("Container.CheckAccess", delegate { _checkAccess = AccessTools.MethodDelegate<Func<Container, long, bool>>(AccessTools.Method(typeof(Container), "CheckAccess", new Type[1] { typeof(long) }, (Type[])null), (object)null, true); }) ? 1u : 0u) & (Try("Container.Load", delegate { _containerLoad = AccessTools.MethodDelegate<Func<Container, bool>>(AccessTools.Method(typeof(Container), "Load", Type.EmptyTypes, (Type[])null), (object)null, true); }) ? 1u : 0u) & (Try("Inventory.Changed", delegate { _inventoryChanged = AccessTools.MethodDelegate<Action<Inventory, bool, bool>>(AccessTools.Method(typeof(Inventory), "Changed", new Type[2] { typeof(bool), typeof(bool) }, (Type[])null), (object)null, true); }) ? 1u : 0u) & (Try("InventoryGui.CloseContainer", delegate { _closeContainer = AccessTools.MethodDelegate<Action<InventoryGui>>(AccessTools.Method(typeof(InventoryGui), "CloseContainer", Type.EmptyTypes, (Type[])null), (object)null, true); }) ? 1u : 0u)) == 0) { Log.Error("Some game members could not be resolved. ChestCategories may not work with this game version."); } } private static bool Try(string what, Action bind) { try { bind(); return true; } catch (Exception e) { Log.Error("Could not bind " + what, e); return false; } } public static bool CloseCurrentContainer() { InventoryGui instance = InventoryGui.instance; if ((Object)(object)instance == (Object)null || _closeContainer == null) { return false; } _closeContainer(instance); return true; } public static ZNetView GetNetView(Container container) { if (!Object.op_Implicit((Object)(object)container) || _containerNview == null) { return null; } ZNetView val = _containerNview.Invoke(container); if (!Object.op_Implicit((Object)(object)val)) { return null; } return val; } public static ZDO GetZdo(Container container) { ZNetView netView = GetNetView(container); if (!((Object)(object)netView != (Object)null) || !netView.IsValid()) { return null; } return netView.GetZDO(); } public static bool CheckAccess(Container container, long playerId) { if (_checkAccess == null) { return true; } try { return _checkAccess(container, playerId); } catch (Exception ex) { Log.Debug("CheckAccess failed: " + ex.Message); return false; } } public static void Reload(Container container) { if (_containerLoad == null || !Object.op_Implicit((Object)(object)container)) { return; } try { _containerLoad(container); } catch (Exception ex) { Log.Debug("Container.Load failed: " + ex.Message); } } public static void NotifyChanged(Inventory inventory) { if (inventory != null) { if (_inventoryChanged != null) { _inventoryChanged(inventory, arg2: false, arg3: false); } else { inventory.m_onChanged?.Invoke(); } } } } internal static class InputHelper { private static bool _useZInput; public static bool IsDown(KeyboardShortcut shortcut) { //IL_0002: 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_002b: Unknown result type (might be due to invalid IL or missing references) if ((int)((KeyboardShortcut)(ref shortcut)).MainKey == 0) { return false; } if (!GetKeyDown(((KeyboardShortcut)(ref shortcut)).MainKey)) { return false; } foreach (KeyCode modifier in ((KeyboardShortcut)(ref shortcut)).Modifiers) { if (!GetKey(modifier)) { return false; } } return true; } public static bool IsHeld(KeyboardShortcut shortcut) { //IL_0002: 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_002b: Unknown result type (might be due to invalid IL or missing references) if ((int)((KeyboardShortcut)(ref shortcut)).MainKey == 0) { return false; } if (!GetKey(((KeyboardShortcut)(ref shortcut)).MainKey)) { return false; } foreach (KeyCode modifier in ((KeyboardShortcut)(ref shortcut)).Modifiers) { if (!GetKey(modifier)) { return false; } } return true; } public static bool IsShiftHeld() { if (!GetKey((KeyCode)304)) { return GetKey((KeyCode)303); } return true; } private static bool GetKeyDown(KeyCode key) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!_useZInput) { try { return Input.GetKeyDown(key); } catch (InvalidOperationException) { _useZInput = true; } } return ZInput.GetKeyDown(key, false); } private static bool GetKey(KeyCode key) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!_useZInput) { try { return Input.GetKey(key); } catch (InvalidOperationException) { _useZInput = true; } } return ZInput.GetKey(key, false); } } internal static class Loc { private static readonly Dictionary<string, string> English = new Dictionary<string, string>(StringComparer.Ordinal) { ["everything"] = "Everything", ["priority"] = "Priority", ["priority_short"] = "P{0}", ["and_more"] = "+{0} more", ["btn_categories"] = "Categories", ["btn_sort"] = "Sort", ["btn_deposit"] = "Deposit", ["btn_stash"] = "Stash", ["btn_chests"] = "Chests", ["search_placeholder"] = "Search...", ["tip_categories"] = "Choose which item categories belong in this chest.", ["tip_sort"] = "Sort the contents of this chest.", ["tip_deposit"] = "Move everything from your inventory that belongs in this chest.", ["tip_stash"] = "Move your whole inventory into the nearby chests it belongs in.", ["tip_chests"] = "List all nearby chests and find items.", ["tip_sort_inventory"] = "Sort your inventory. The hotbar and favourited items stay where they are.", ["no_categories"] = "No categories", ["editor_title"] = "Chest Categories", ["label"] = "Label", ["label_placeholder"] = "Name this chest...", ["opt_accept"] = "Accept stashed items", ["opt_accept_tip"] = "Turn off to keep Stash and Reorganize from putting items into this chest.", ["opt_frozen"] = "Keep contents", ["opt_frozen_tip"] = "Reorganize never takes items out of this chest.", ["opt_everything"] = "Accept everything", ["opt_everything_tip"] = "Catch-all: takes any item that no better matching chest has room for.", ["btn_detect"] = "Detect", ["btn_detect_tip"] = "Link the categories of the items that are in this chest right now.", ["btn_clear"] = "Clear", ["btn_copy"] = "Copy", ["btn_paste"] = "Paste", ["btn_close"] = "Close", ["items_in_chest"] = "{0} in chest", ["copied"] = "Chest setup copied", ["pasted"] = "Chest setup pasted", ["nothing_to_paste"] = "Copy a chest setup first", ["detected"] = "Linked {0} categories", ["detected_none"] = "This chest is empty", ["save_failed"] = "Could not save: the chest is in use", ["priority_hint"] = "1 is filled first. Shift-click: steps of 10", ["item_rules"] = "Item rules", ["item_rules_hint"] = "(click an item to override its category)", ["item_rule_tip"] = "Click to cycle: always accept (green), never accept (red), follow the category.", ["manager_title"] = "Nearby Chests", ["manager_empty"] = "No chests within {0} m", ["manager_no_match"] = "No nearby chest contains '{0}'", ["manager_count"] = "{0} chests within {1} m", ["manager_found"] = "'{0}': {1} items in {2} chests", ["find_placeholder"] = "Find an item...", ["btn_edit"] = "Edit", ["btn_ping"] = "Show", ["btn_open"] = "Open", ["btn_reorganize"] = "Reorganize", ["tip_reorganize"] = "Move items that are in the wrong chest to the chest linked to their category.", ["slots"] = "{0}/{1} slots", ["contains"] = "{0}x {1}", ["distance"] = "{0} m", ["hover_accepts"] = "Accepts", ["msg_stash_none"] = "Nothing to stash", ["msg_stash_no_chests"] = "No chest nearby accepts these items", ["msg_stash_done"] = "Stashed {0} items into {1} chests", ["msg_stash_done_one"] = "Stashed {0} items into {1}", ["msg_stash_left"] = "{0} stacks did not fit", ["msg_deposit_none"] = "Nothing in your inventory belongs in this chest", ["msg_deposit_done"] = "Deposited {0} items", ["msg_sort_denied"] = "This chest cannot be sorted right now", ["msg_reorganize_disabled"] = "Reorganize is turned off in the ChestCategories config", ["msg_reorganize_none"] = "Everything is already in its place", ["msg_reorganize_done"] = "Reorganized {0} items across {1} chests", ["msg_busy"] = "Still busy with the previous request", ["msg_favorite_on"] = "{0} is now a favourite", ["msg_favorite_off"] = "{0} is no longer a favourite", ["msg_chest_detail"] = "{0}: {1} items", ["unnamed_chest"] = "Chest" }; private static Dictionary<string, string> _translation; private static string _loadedLanguage; public static string T(string key) { EnsureLoaded(); if (_translation != null && _translation.TryGetValue(key, out var value)) { return value; } if (!English.TryGetValue(key, out var value2)) { return key; } return value2; } public static string T(string key, params object[] args) { string text = T(key); try { return string.Format(text, args); } catch (FormatException) { return text; } } public static void Reload() { _loadedLanguage = null; _translation = null; } public static string WriteTemplate() { string text = Path.Combine(Paths.ConfigPath, "ChestCategories.English.lang"); List<string> list = new List<string> { "# ChestCategories translation template.", "# Copy to ChestCategories.<Language>.lang (the language name as shown in the game settings, e.g. German) and translate the text after '='." }; foreach (KeyValuePair<string, string> item in English) { list.Add(item.Key + " = " + item.Value); } File.WriteAllLines(text, list); return text; } private static void EnsureLoaded() { string text; try { Localization instance = Localization.instance; text = ((instance != null) ? instance.GetSelectedLanguage() : null); } catch (Exception) { return; } if (string.IsNullOrEmpty(text) || text == _loadedLanguage) { return; } _loadedLanguage = text; _translation = null; if (text.Equals("English", StringComparison.OrdinalIgnoreCase)) { return; } try { string path = Path.Combine(Paths.ConfigPath, "ChestCategories." + text + ".lang"); if (!File.Exists(path)) { return; } Dictionary<string, string> dictionary = new Dictionary<string, string>(StringComparer.Ordinal); string[] array = File.ReadAllLines(path); for (int i = 0; i < array.Length; i++) { string text2 = array[i].Trim(); if (text2.Length != 0 && text2[0] != '#') { int num = text2.IndexOf('='); if (num > 0) { dictionary[text2.Substring(0, num).Trim()] = text2.Substring(num + 1).Trim(); } } } _translation = dictionary; Log.Info($"Loaded {dictionary.Count} translated strings for {text}."); } catch (Exception ex2) { Log.Warn("Could not load the " + text + " translation: " + ex2.Message); } } } internal static class Log { private static ManualLogSource _source; public static void Init(ManualLogSource source) { _source = source; } public static void Info(string message) { ManualLogSource source = _source; if (source != null) { source.LogInfo((object)message); } } public static void Warn(string message) { ManualLogSource source = _source; if (source != null) { source.LogWarning((object)message); } } public static void Error(string message) { ManualLogSource source = _source; if (source != null) { source.LogError((object)message); } } public static void Error(string message, Exception e) { ManualLogSource source = _source; if (source != null) { source.LogError((object)$"{message}: {e}"); } } public static void Debug(string message) { if (ModConfig.DebugLogging != null && ModConfig.DebugLogging.Value) { ManualLogSource source = _source; if (source != null) { source.LogInfo((object)("[debug] " + message)); } } } } } namespace ChestCategories.UI { internal sealed class CategoryEditor { private sealed class GroupRow { public CategoryGroup Group; public CheckMark Mark; public TextMeshProUGUI Arrow; public TextMeshProUGUI Count; public readonly List<CategoryRow> Children = new List<CategoryRow>(); public bool Expanded; } private sealed class CategoryRow { public Category Category; public GameObject Root; public CheckMark Mark; public TextMeshProUGUI Count; } private sealed class ItemCell { public string Prefab; public Image Frame; } private const float Width = 470f; private const float Height = 630f; private const float RowHeight = 28f; private static ChestConfig _clipboard; private readonly ModUi _ui; private readonly UiKit _kit; private readonly RectTransform _root; private readonly TextMeshProUGUI _subtitle; private readonly TMP_InputField _label; private readonly TextMeshProUGUI _priorityValue; private readonly LabeledCheck _acceptStash; private readonly LabeledCheck _keepContents; private readonly LabeledCheck _acceptEverything; private readonly RectTransform _content; private readonly ScrollRect _scroll; private readonly List<GroupRow> _groups = new List<GroupRow>(); private readonly List<ItemCell> _itemCells = new List<ItemCell>(); private RectTransform _itemGrid; private TextMeshProUGUI _itemHeader; private Container _container; private ChestConfig _config; private ChestConfig _baseline; private int _pendingSaves; private int _session; private int _builtForVersion = -1; private float _nextCountRefresh; private string _itemSignature; private bool _suppressLabelEvents; public bool IsOpen => ((Component)_root).gameObject.activeSelf; public CategoryEditor(ModUi ui, Transform parent) { //IL_008a: 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_00e3: Expected O, but got Unknown //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Expected O, but got Unknown //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_0329: 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_0347: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Expected O, but got Unknown //IL_0408: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_0435: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_047d: Unknown result type (might be due to invalid IL or missing references) //IL_048c: Unknown result type (might be due to invalid IL or missing references) //IL_049b: Unknown result type (might be due to invalid IL or missing references) //IL_04aa: Unknown result type (might be due to invalid IL or missing references) //IL_0500: Unknown result type (might be due to invalid IL or missing references) //IL_050f: Unknown result type (might be due to invalid IL or missing references) //IL_051e: Unknown result type (might be due to invalid IL or missing references) //IL_052d: Unknown result type (might be due to invalid IL or missing references) //IL_0583: Unknown result type (might be due to invalid IL or missing references) //IL_0592: Unknown result type (might be due to invalid IL or missing references) //IL_05a1: 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_0606: Unknown result type (might be due to invalid IL or missing references) //IL_0615: Unknown result type (might be due to invalid IL or missing references) //IL_0624: Unknown result type (might be due to invalid IL or missing references) //IL_0633: Unknown result type (might be due to invalid IL or missing references) //IL_06a5: Unknown result type (might be due to invalid IL or missing references) //IL_06ba: Unknown result type (might be due to invalid IL or missing references) //IL_06cf: Unknown result type (might be due to invalid IL or missing references) //IL_06e4: Unknown result type (might be due to invalid IL or missing references) //IL_06f9: Unknown result type (might be due to invalid IL or missing references) //IL_0728: Unknown result type (might be due to invalid IL or missing references) //IL_0732: Expected O, but got Unknown //IL_0746: Unknown result type (might be due to invalid IL or missing references) //IL_0750: Expected O, but got Unknown //IL_0764: Unknown result type (might be due to invalid IL or missing references) //IL_076e: Expected O, but got Unknown //IL_0782: Unknown result type (might be due to invalid IL or missing references) //IL_078c: Expected O, but got Unknown //IL_07c6: Unknown result type (might be due to invalid IL or missing references) //IL_07d0: Expected O, but got Unknown _ui = ui; _kit = ui.Kit; Image val = _kit.Panel("ChestCategories_Editor", parent); _root = ((Graphic)val).rectTransform; ((Component)_root).gameObject.SetActive(false); UiKit.Band(((TMP_Text)_kit.Text("Title", (Transform)(object)_root, Loc.T("editor_title"), 22f, ModConfig.AccentColor.Value, (TextAlignmentOptions)4097)).rectTransform, 22f, 60f, 14f, 30f); UiKit.Place(((Component)_kit.Button("Close", (Transform)(object)_root, "X", 16f, new UnityAction(Hide))).GetComponent<RectTransform>(), new Vector2(1f, 1f), new Vector2(1f, 1f), new Vector2(-16f, -14f), new Vector2(30f, 30f)); _subtitle = _kit.Text("Subtitle", (Transform)(object)_root, string.Empty, 14f, UiKit.MutedText, (TextAlignmentOptions)4097); UiKit.Band(((TMP_Text)_subtitle).rectTransform, 22f, 22f, 44f, 20f); UiKit.Place(((TMP_Text)_kit.Text("LabelCaption", (Transform)(object)_root, Loc.T("label"), 15f, UiKit.BodyText, (TextAlignmentOptions)4097)).rectTransform, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(22f, -72f), new Vector2(70f, 28f)); _label = _kit.Input("Label", (Transform)(object)_root, Loc.T("label_placeholder"), 15f, 40); UiKit.Band(((Component)_label).GetComponent<RectTransform>(), 96f, 22f, 72f, 28f); ((UnityEvent<string>)(object)_label.onEndEdit).AddListener((UnityAction<string>)OnLabelEdited); ModUi.RegisterInput(_label); UiKit.Place(((TMP_Text)_kit.Text("PriorityCaption", (Transform)(object)_root, Loc.T("priority"), 15f, UiKit.BodyText, (TextAlignmentOptions)4097)).rectTransform, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(22f, -106f), new Vector2(70f, 28f)); UiKit.Place(((Component)_kit.Button("Minus", (Transform)(object)_root, "-", 18f, (UnityAction)delegate { ChangePriority(-1); })).GetComponent<RectTransform>(), new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(96f, -106f), new Vector2(30f, 28f)); _priorityValue = _kit.Text("PriorityValue", (Transform)(object)_root, "5", 17f, UiKit.BodyText, (TextAlignmentOptions)514); UiKit.Place(((TMP_Text)_priorityValue).rectTransform, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(128f, -106f), new Vector2(40f, 28f)); UiKit.Place(((Component)_kit.Button("Plus", (Transform)(object)_root, "+", 18f, (UnityAction)delegate { ChangePriority(1); })).GetComponent<RectTransform>(), new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(170f, -106f), new Vector2(30f, 28f)); UiKit.Place(((TMP_Text)_kit.Text("PriorityHint", (Transform)(object)_root, Loc.T("priority_hint"), 13f, UiKit.MutedText, (TextAlignmentOptions)4097)).rectTransform, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(210f, -106f), new Vector2(200f, 28f)); _acceptStash = new LabeledCheck(_kit, (Transform)(object)_root, Loc.T("opt_accept"), Loc.T("opt_accept_tip"), delegate { ToggleFlag(ChestFlags.NoStash); }); UiKit.Place(_acceptStash.Root, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(18f, -140f), new Vector2(215f, 26f)); _keepContents = new LabeledCheck(_kit, (Transform)(object)_root, Loc.T("opt_frozen"), Loc.T("opt_frozen_tip"), delegate { ToggleFlag(ChestFlags.Frozen); }); UiKit.Place(_keepContents.Root, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(238f, -140f), new Vector2(210f, 26f)); _acceptEverything = new LabeledCheck(_kit, (Transform)(object)_root, Loc.T("opt_everything"), Loc.T("opt_everything_tip"), ToggleEverything); UiKit.Place(_acceptEverything.Root, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(18f, -168f), new Vector2(215f, 26f)); _scroll = _kit.ScrollView("Categories", (Transform)(object)_root, out _content); UiKit.Stretch(((Component)_scroll).GetComponent<RectTransform>(), 18f, 18f, 200f, 58f); RectTransform val2 = _kit.Rect("Buttons", (Transform)(object)_root); val2.anchorMin = new Vector2(0f, 0f); val2.anchorMax = new Vector2(1f, 0f); val2.pivot = new Vector2(0.5f, 0f); val2.offsetMin = new Vector2(18f, 16f); val2.offsetMax = new Vector2(-18f, 48f); UiKit.Row((Component)(object)val2, 6f, (TextAnchor)3); AddBottomButton((Transform)(object)val2, "btn_detect", "btn_detect_tip", 84f, new UnityAction(DetectFromContents)); AddBottomButton((Transform)(object)val2, "btn_clear", null, 70f, new UnityAction(ClearAll)); AddBottomButton((Transform)(object)val2, "btn_copy", null, 70f, new UnityAction(Copy)); AddBottomButton((Transform)(object)val2, "btn_paste", null, 70f, new UnityAction(Paste)); UiKit.Size((Component)(object)_kit.Rect("Spacer", (Transform)(object)val2), 0f, 32f, 1f); AddBottomButton((Transform)(object)val2, "btn_close", null, 80f, new UnityAction(Hide)); } public bool IsOpenFor(Container container) { if (IsOpen) { return (Object)(object)_container == (Object)(object)container; } return false; } public void ApplyLayout() { //IL_0010: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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) UiKit.Place(_root, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), ModConfig.WindowOffset.Value, new Vector2(470f, 630f)); ((Transform)_root).localScale = Vector3.one * ModConfig.UiScale.Value; } public void Show(Container container) { if (Object.op_Implicit((Object)(object)container)) { _container = container; _session++; _pendingSaves = 0; LoadStored(); CategoryService.EnsureReady(); if (_builtForVersion != CategoryService.Version) { BuildRows(); } ExpandGroupsInUse(); _itemSignature = null; ((Transform)_root).SetAsLastSibling(); ((Component)_root).gameObject.SetActive(true); RefreshAll(); LayoutRebuilder.ForceRebuildLayoutImmediate(_content); _scroll.verticalNormalizedPosition = 1f; } } public void Hide() { if (IsOpen) { if (_label.isFocused) { OnLabelEdited(_label.text); } ((Component)_root).gameObject.SetActive(false); _container = null; } } public void Tick() { //IL_0032: 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) if (!IsOpen) { return; } if (!Object.op_Implicit((Object)(object)_container)) { Hide(); return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || Vector3.Distance(((Component)localPlayer).transform.position, ((Component)_container).transform.position) > ModConfig.Range.Value + 4f) { Hide(); } else if (_builtForVersion != CategoryService.Version) { BuildRows(); ExpandGroupsInUse(); RefreshAll(); } else if (!(Time.unscaledTime < _nextCountRefresh)) { _nextCountRefresh = Time.unscaledTime + 0.5f; if (!_label.isFocused && _pendingSaves == 0 && ChestConfigStore.Get(_container).Serialize() != _baseline.Serialize()) { LoadStored(); } RefreshAll(); } } private void BuildRows() { //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: 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_01ee: Expected O, but got Unknown for (int num = ((Transform)_content).childCount - 1; num >= 0; num--) { Object.Destroy((Object)(object)((Component)((Transform)_content).GetChild(num)).gameObject); } _groups.Clear(); _itemCells.Clear(); _itemGrid = null; _itemSignature = null; foreach (CategoryGroup group in CategoryService.Registry.Groups) { List<Category> list = group.Categories.Where((Category c) => c.ItemCount > 0 || c.IsCustom).ToList(); if (list.Count == 0) { continue; } GroupRow groupRow = BuildGroupRow(group); foreach (Category item in list) { groupRow.Children.Add(BuildCategoryRow(groupRow, item)); } _groups.Add(groupRow); } _itemHeader = _kit.Text("ItemHeader", (Transform)(object)_content, string.Empty, 14f, ModConfig.AccentColor.Value, (TextAlignmentOptions)4097); ((TMP_Text)_itemHeader).margin = new Vector4(4f, 8f, 0f, 0f); UiKit.Size((Component)(object)_itemHeader, -1f, 34f); _itemGrid = _kit.Rect("Items", (Transform)(object)_content); GridLayoutGroup obj = ((Component)_itemGrid).gameObject.AddComponent<GridLayoutGroup>(); obj.cellSize = new Vector2(44f, 44f); obj.spacing = new Vector2(4f, 4f); ((LayoutGroup)obj).padding = new RectOffset(4, 4, 2, 8); obj.startAxis = (Axis)0; obj.constraint = (Constraint)1; obj.constraintCount = 8; _builtForVersion = CategoryService.Version; } private GroupRow BuildGroupRow(CategoryGroup group) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Expected O, but got Unknown //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0140: 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_015e: 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_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_022d: 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_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: 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_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) GroupRow row = new GroupRow { Group = group }; Image val = _kit.Box("Group_" + group.Id, (Transform)(object)_content, new Color(1f, 1f, 1f, 0.08f)); UiKit.Size((Component)(object)val, -1f, 30f); UiKit.Stretch(((Component)_kit.FlatButton("Expand", ((Component)val).transform, new Color(1f, 1f, 1f, 0f), UiKit.RowHoverColor, (UnityAction)delegate { SetExpanded(row, !row.Expanded); })).GetComponent<RectTransform>(), 34f, 0f, 0f, 0f); Button val2 = _kit.FlatButton("Toggle", ((Component)val).transform, new Color(1f, 1f, 1f, 0f), UiKit.RowHoverColor, (UnityAction)delegate { ToggleGroup(group); }); UiKit.Place(((Component)val2).GetComponent<RectTransform>(), new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(2f, 0f), new Vector2(32f, 28f)); row.Mark = new CheckMark(_kit, ((Component)val2).transform, 18f); UiKit.Place(row.Mark.Root, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, new Vector2(18f, 18f)); UiKit.Place(((Graphic)_kit.Icon("Icon", ((Component)val).transform, CategoryService.GetIcon(group))).rectTransform, new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(38f, 0f), new Vector2(26f, 26f)); UiKit.Stretch(((TMP_Text)_kit.Text("Name", ((Component)val).transform, group.Name, 16f, _kit.ButtonTextColor, (TextAlignmentOptions)4097)).rectTransform, 70f, 90f, 0f, 0f); row.Count = _kit.Text("Count", ((Component)val).transform, string.Empty, 13f, UiKit.MutedText, (TextAlignmentOptions)4100); UiKit.Place(((TMP_Text)row.Count).rectTransform, new Vector2(1f, 0.5f), new Vector2(1f, 0.5f), new Vector2(-28f, 0f), new Vector2(70f, 28f)); row.Arrow = _kit.Text("Arrow", ((Component)val).transform, "+", 16f, UiKit.MutedText, (TextAlignmentOptions)514); UiKit.Place(((TMP_Text)row.Arrow).rectTransform, new Vector2(1f, 0.5f), new Vector2(1f, 0.5f), new Vector2(-4f, 0f), new Vector2(20f, 28f)); return row; } private CategoryRow BuildCategoryRow(GroupRow parent, Category category) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0061: Expected O, but got Unknown //IL_00b5: 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) //IL_00d3: 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_011c: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: 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_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) CategoryRow obj = new CategoryRow { Category = category }; Button val = _kit.FlatButton("Category_" + category.Id, (Transform)(object)_content, UiKit.RowColor, UiKit.RowHoverColor, (UnityAction)delegate { ToggleCategory(category); }); obj.Root = ((Component)val).gameObject; UiKit.Size((Component)(object)val, -1f, 28f); obj.Mark = new CheckMark(_kit, ((Component)val).transform, 18f); UiKit.Place(obj.Mark.Root, new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(30f, 0f), new Vector2(18f, 18f)); UiKit.Place(((Graphic)_kit.Icon("Icon", ((Component)val).transform, CategoryService.GetIcon(category))).rectTransform, new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(56f, 0f), new Vector2(24f, 24f)); UiKit.Stretch(((TMP_Text)_kit.Text("Name", ((Component)val).transform, category.Name, 15f, UiKit.BodyText, (TextAlignmentOptions)4097)).rectTransform, 88f, 96f, 0f, 0f); obj.Count = _kit.Text("Count", ((Component)val).transform, string.Empty, 13f, UiKit.MutedText, (TextAlignmentOptions)4100); UiKit.Place(((TMP_Text)obj.Count).rectTransform, new Vector2(1f, 0.5f), new Vector2(1f, 0.5f), new Vector2(-8f, 0f), new Vector2(90f, 28f)); return obj; } private void AddBottomButton(Transform parent, string labelKey, string tipKey, float width, UnityAction onClick) { Button val = _kit.Button(labelKey, parent, Loc.T(labelKey), 14f, onClick); UiKit.Size((Component)(object)val, width, 32f); if (tipKey != null) { _kit.Tooltip(((Component)val).gameObject, Loc.T(labelKey), Loc.T(tipKey)); } } private void RefreshAll() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0226: 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) if (!Object.op_Implicit((Object)(object)_container) || _config == null) { return; } Color value = ModConfig.AccentColor.Value; Inventory inventory = _container.GetInventory(); int num = ((inventory != null) ? inventory.NrOfItems() : 0); int num2 = ((inventory != null) ? (inventory.GetWidth() * inventory.GetHeight()) : 0); ((TMP_Text)_subtitle).text = ChestNames.VanillaName(_container) + " - " + Loc.T("slots", num, num2); if (!_label.isFocused && _label.text != _config.Label) { _suppressLabelEvents = true; _label.text = _config.Label; _suppressLabelEvents = false; } ((TMP_Text)_priorityValue).text = _config.Priority.ToString(); _acceptStash.Set(_config.AcceptsStash); _keepContents.Set(_config.IsFrozen); _acceptEverything.Set(_config.AcceptsEverything); Dictionary<Category, int> dictionary = new Dictionary<Category, int>(); if (inventory != null) { foreach (ItemData allItem in inventory.GetAllItems()) { Category category = CategoryService.GetCategory(allItem); dictionary.TryGetValue(category, out var value2); dictionary[category] = value2 + allItem.m_stack; } } foreach (GroupRow group in _groups) { bool flag = _config.IsLinked(group.Group); int num3 = 0; foreach (CategoryRow child in group.Children) { bool flag2 = _config.IsLinked(child.Category); if (flag2 || flag) { num3++; } child.Mark.Set(flag2, flag && !flag2, value); dictionary.TryGetValue(child.Category, out var value3); ((TMP_Text)child.Count).text = ((value3 > 0) ? Loc.T("items_in_chest", value3) : string.Empty); } group.Mark.Set(flag, !flag && num3 > 0, value); ((TMP_Text)group.Count).text = ((num3 > 0) ? $"{num3} / {group.Children.Count}" : string.Empty); } RefreshItemRules(inventory); } private void RefreshItemRules(Inventory inventory) { //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Expected O, but got Unknown if ((Object)(object)_itemGrid == (Object)null) { return; } SortedSet<string> sortedSet = new SortedSet<string>(StringComparer.Ordinal); if (inventory != null) { foreach (ItemData allItem in inventory.GetAllItems()) { ItemInfo info = CategoryService.GetInfo(allItem); if (info != null && (Object)(object)info.Icon != (Object)null) { sortedSet.Add(info.PrefabName); } } } sortedSet.UnionWith(_config.IncludeItems); sortedSet.UnionWith(_config.ExcludeItems); string text = string.Join(",", sortedSet); if (text != _itemSignature) { _itemSignature = text; for (int num = ((Transform)_itemGrid).childCount - 1; num >= 0; num--) { Object.Destroy((Object)(object)((Component)((Transform)_itemGrid).GetChild(num)).gameObject); } _itemCells.Clear(); foreach (string item in sortedSet) { ItemInfo info2 = CategoryService.GetInfo(item); if (info2 != null) { string captured = item; Button val = _kit.FlatButton("Item_" + item, (Transform)(object)_itemGrid, Color.white, new Color(1f, 1f, 1f, 0.8f), (UnityAction)delegate { CycleItemRule(captured); }); UiKit.Stretch(((Graphic)_kit.Icon("Icon", ((Component)val).transform, info2.Icon)).rectTransform, 4f, 4f, 4f, 4f); _kit.Tooltip(((Component)val).gameObject, info2.LocalizedName, info2.Category.Group.Name + " - " + info2.Category.Name + "\n\n" + Loc.T("item_rule_tip")); _itemCells.Add(new ItemCell { Prefab = item, Frame = ((Component)val).GetComponent<Image>() }); } } UiKit.Size((Component)(object)_itemHeader, -1f, (sortedSet.Count > 0) ? 34f : 0f); ((TMP_Text)_itemHeader).text = ((sortedSet.Count > 0) ? (Loc.T("item_rules") + " <size=12><color=#B8B0A0>" + Loc.T("item_rules_hint") + "</color></size>") : string.Empty); } foreach (ItemCell itemCell in _itemCells) { if (_config.IncludeItems.Contains(itemCell.Prefab)) { ((Graphic)itemCell.Frame).color = new Color(0.3f, 0.7f, 0.3f, 0.85f); } else if (_config.ExcludeItems.Contains(itemCell.Prefab)) { ((Graphic)itemCell.Frame).color = new Color(0.8f, 0.25f, 0.2f, 0.85f); } else { ((Graphic)itemCell.Frame).color = new Color(0f, 0f, 0f, 0.45f); } } } private void ExpandGroupsInUse() { foreach (GroupRow group in _groups) { bool expanded = _config.IsLinked(group.Group) || group.Group.Categories.Any(_config.IsLinked); SetExpanded(group, expanded); } } private void SetExpanded(GroupRow group, bool expanded) { group.Expanded = expanded; ((TMP_Text)group.Arrow).text = (expanded ? "-" : "+"); foreach (CategoryRow child in group.Children) { child.Root.SetActive(expanded); } } private void Commit() { if (!Object.op_Implicit((Object)(object)_container) || _config == null) { return; } Container container = _container; int session = _session; _pendingSaves++; ChestConfigStore.Save(container, _baseline.Clone(), _config.Clone(), delegate(bool saved) { if (!saved) { Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, Loc.T("save_failed"), 0, (Sprite)null, false); } } if (session == _session) { _pendingSaves--; if (_pendingSaves == 0 && Object.op_Implicit((Object)(object)_container)) { LoadStored(); } } }); RefreshAll(); } private void LoadStored() { _config = ChestConfigStore.Get(_container).Clone(); _baseline = _config.Clone(); } private void ToggleCategory(Category category) { if (_config.IsLinked(category.Group)) { _config.Links.Remove(category.Group.Id); foreach (Category category2 in category.Group.Categories) { if (category2 != category) { _config.Links.Add(category2.Id); } } } else if (!_config.Links.Remove(category.Id)) { _config.Links.Add(category.Id); } Commit(); } private void ToggleGroup(CategoryGroup group) { bool flag = group.Categories.Any(_config.IsLinked); foreach (Category category in group.Categories) { _config.Links.Remove(category.Id); } if (_config.IsLinked(group)) { _config.Links.Remove(group.Id); } else if (!flag) { _config.Links.Add(group.Id); } Commit(); } private void ToggleEverything() { if (!_config.Links.Remove("*")) { _config.Links.Add("*"); } Commit(); } private void ToggleFlag(ChestFlags flag) { _config.Flags ^= flag; Commit(); } private void ChangePriority(int delta) { if (InputHelper.IsShiftHeld()) { delta *= 10; } _config.Priority = ChestConfig.Clamp(_config.Priority + delta); Commit(); } private void OnLabelEdited(string text) { if (!_suppressLabelEvents && _config != null) { string text2 = ChestConfig.CleanLabel(text); if (!(text2 == _config.Label)) { _config.Label = text2; Commit(); } } } private void CycleItemRule(string prefab) { if (_config.IncludeItems.Remove(prefab)) { _config.ExcludeItems.Add(prefab); } else if (!_config.ExcludeItems.Remove(prefab)) { _config.IncludeItems.Add(prefab); } Commit(); } private void DetectFromContents() { Inventory val = (Object.op_Implicit((Object)(object)_container) ? _container.GetInventory() : null); if (val == null || val.NrOfItems() == 0) { Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, Loc.T("detected_none"), 0, (Sprite)null, false); } return; } int count = _config.Links.Count; foreach (ItemData allItem in val.GetAllItems()) { Category category = CategoryService.GetCategory(allItem); if (category != null && !_config.Covers(category)) { _config.Links.Add(category.Id); } } Player localPlayer2 = Player.m_localPlayer; if (localPlayer2 != null) { ((Character)localPlayer2).Message((MessageType)1, Loc.T("detected", _config.Links.Count - count), 0, (Sprite)null, false); } foreach (GroupRow group in _groups) { if (group.Group.Categories.Any(_config.IsLinked)) { SetExpanded(group, expanded: true); } } Commit(); } private void ClearAll() { _config.Links.Clear(); _config.IncludeItems.Clear(); _config.ExcludeItems.Clear(); Commit(); } private void Copy() { _clipboard = _config.Clone(); Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)1, Loc.T("copied"), 0, (Sprite)null, false); } } private void Paste() { if (_clipboard == null) { Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)1, Loc.T("nothing_to_paste"), 0, (Sprite)null, false); } return; } _config.CopyRulesFrom(_clipboard); Player localPlayer2 = Player.m_localPlayer; if (localPlayer2 != null) { ((Character)localPlayer2).Message((MessageType)1, Loc.T("pasted"), 0, (Sprite)null, false); } Commit(); } } internal sealed class ChestManager { private sealed class Row { public Container Container; public Image Icon; public TextMeshProUGUI Name; public TextMeshProUGUI Detail; public TextMeshProUGUI Meta; } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__15_1; public static Func<ChestTarget, string> <>9__22_0; public static Func<KeyValuePair<string, int>, int> <>9__26_0; internal void <.ctor>b__15_1() { ReorganizeService.Run(quiet: false); } internal string <Refresh>b__22_0(ChestTarget c) { return ((Object)c.Container).GetInstanceID().ToString(); } internal int <DescribeHits>b__26_0(KeyValuePair<string, int> p) { return p.Value; } } private const float Width = 540f; private const float Height = 630f; private const float RowHeight = 54f; private readonly ModUi _ui; private readonly UiKit _kit; private readonly RectTransform _root; private readonly TMP_InputField _find; private readonly TextMeshProUGUI _status; private readonly RectTransform _content; private readonly ScrollRect _scroll; private readonly List<Row> _rows = new List<Row>(); private SearchQuery _query = new SearchQuery(string.Empty); private string _rowSignature; private float _nextRefresh; public bool IsOpen => ((Component)_root).gameObject.activeSelf; public ChestManager(ModUi ui, Transform parent) { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_029a: 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_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Expected O, but got Unknown //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: Expected O, but got Unknown //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Expected O, but got Unknown _ui = ui; _kit = ui.Kit; Image val = _kit.Panel("ChestCategories_Manager", parent); _root = ((Graphic)val).rectTransform; ((Component)_root).gameObject.SetActive(false); UiKit.Band(((TMP_Text)_kit.Text("Title", (Transform)(object)_root, Loc.T("manager_title"), 22f, ModConfig.AccentColor.Value, (TextAlignmentOptions)4097)).rectTransform, 22f, 60f, 14f, 30f); UiKit.Place(((Component)_kit.Button("Close", (Transform)(object)_root, "X", 16f, new UnityAction(Hide))).GetComponent<RectTransform>(), new Vector2(1f, 1f), new Vector2(1f, 1f), new Vector2(-16f, -14f), new Vector2(30f, 30f)); _find = _kit.Input("Find", (Transform)(object)_root, Loc.T("find_placeholder"), 15f, 40); UiKit.Band(((Component)_find).GetComponent<RectTransform>(), 22f, 22f, 50f, 30f); ((UnityEvent<string>)(object)_find.onValueChanged).AddListener((UnityAction<string>)delegate(string text) { _query = new SearchQuery(text); _nextRefresh = 0f; }); ModUi.RegisterInput(_find); _status = _kit.Text("Status", (Transform)(object)_root, string.Empty, 14f, UiKit.MutedText, (TextAlignmentOptions)4097); UiKit.Band(((TMP_Text)_status).rectTransform, 24f, 22f, 84f, 22f); _scroll = _kit.ScrollView("Chests", (Transform)(object)_root, out _content); UiKit.Stretch(((Component)_scroll).GetComponent<RectTransform>(), 18f, 18f, 110f, 58f); RectTransform val2 = _kit.Rect("Buttons", (Transform)(object)_root); val2.anchorMin = new Vector2(0f, 0f); val2.anchorMax = new Vector2(1f, 0f); val2.pivot = new Vector2(0.5f, 0f); val2.offsetMin = new Vector2(18f, 16f); val2.offsetMax = new Vector2(-18f, 48f); UiKit.Row((Component)(object)val2, 6f, (TextAnchor)3); Button val3 = _kit.Button("Stash", (Transform)(object)val2, Loc.T("btn_stash"), 14f, new UnityAction(StashService.StashAll)); UiKit.Size((Component)(object)val3, 80f, 32f); _kit.Tooltip(((Component)val3).gameObject, Loc.T("btn_stash"), Loc.T("tip_stash")); UiKit kit = _kit; string label = Loc.T("btn_reorganize"); object obj = <>c.<>9__15_1; if (obj == null) { UnityAction val4 = delegate { ReorganizeService.Run(quiet: false); }; <>c.<>9__15_1 = val4; obj = (object)val4; } Button val5 = kit.Button("Reorganize", (Transform)(object)val2, label, 14f, (UnityAction)obj); UiKit.Size((Component)(object)val5, 110f, 32f); _kit.Tooltip(((Component)val5).gameObject, Loc.T("btn_reorganize"), Loc.T("tip_reorganize")); UiKit.Size((Component)(object)_kit.Rect("Spacer", (Transform)(object)val2), 0f, 32f, 1f); UiKit.Size((Component)(object)_kit.Button("CloseBottom", (Transform)(object)val2, Loc.T("btn_close"), 14f, new UnityAction(Hide)), 80f, 32f); } public void ApplyLayout() { //IL_0010: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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) UiKit.Place(_root, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), ModConfig.WindowOffset.Value, new Vector2(540f, 630f)); ((Transform)_root).localScale = Vector3.one * ModConfig.UiScale.Value; } public void Show() { _rowSignature = null; _nextRefresh = 0f; ((Transform)_root).SetAsLastSibling(); ((Component)_root).gameObject.SetActive(true); Refresh(); LayoutRebuilder.ForceRebuildLayoutImmediate(_content); _scroll.verticalNormalizedPosition = 1f; } public void Hide() { if (IsOpen) { ((Component)_root).gameObject.SetActive(false); } } public void Tick() { if (IsOpen && !(Time.unscaledTime < _nextRefresh)) { Refresh(); } } private void Refresh() { _nextRefresh = Time.unscaledTime + 1f; CategoryService.EnsureReady(); float value = ModConfig.Range.Value; List<ChestTarget> list = ContainerRegistry.FindNearby(value); Dictionary<Container, string> dictionary = new Dictionary<Container, string>(); int num = 0; if (!_query.IsEmpty) { for (int num2 = list.Count - 1; num2 >= 0; num2--) { int units; string text = DescribeHits(list[num2].Container, out units); if (text == null) { list.RemoveAt(num2); } else { dictionary[list[num2].Container] = text; num += units; } } } if (_query.IsEmpty) { ((TMP_Text)_status).text = ((list.Count == 0) ? Loc.T("manager_empty", Mathf.RoundToInt(value)) : Loc.T("manager_count", list.Count, Mathf.RoundToInt(value))); } else { ((TMP_Text)_status).text = ((list.Count == 0) ? Loc.T("manager_no_match", _query.Text.Trim()) : Loc.T("manager_found", _query.Text.Trim(), num, list.Count)); } string text2 = string.Join(",", list.Select((ChestTarget c) => ((Object)c.Container).GetInstanceID().ToString())); if (text2 != _rowSignature) { _rowSignature = text2; for (int num3 = ((Transform)_content).childCount - 1; num3 >= 0; num3--) { Object.Destroy((Object)(object)((Component)((Transform)_content).GetChild(num3)).gameObject); } _rows.Clear(); foreach (ChestTarget item in list) { _rows.Add(BuildRow(item.Container)); } } for (int num4 = 0; num4 < _rows.Count && num4 < list.Count; num4++) { dictionary.TryGetValue(list[num4].Container, out var value2); UpdateRow(_rows[num4], list[num4], value2); } } private Row BuildRow(Container container) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0131: 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_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: 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_01db: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Expected O, but got Unknown //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Expected O, but got Unknown //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Expected O, but got Unknown //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_024f: 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) Row obj = new Row { Container = container }; Image val = _kit.Box("Chest", (Transform)(object)_content, UiKit.RowColor, raycastTarget: true); UiKit.Size((Component)(object)val, -1f, 54f); obj.Icon = _kit.Icon("Icon", ((Component)val).transform, null); UiKit.Place(((Graphic)obj.Icon).rectTransform, new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(6f, 0f), new Vector2(40f, 40f)); obj.Name = _kit.Text("Name", ((Component)val).transform, string.Empty, 16f, UiKit.BodyText, (TextAlignmentOptions)4097); UiKit.Band(((TMP_Text)obj.Name).rectTransform, 54f, 206f, 5f, 22f); obj.Detail = _kit.Text("Detail", ((Component)val).transform, string.Empty, 13f, UiKit.MutedText, (TextAlignmentOptions)4097); UiKit.Band(((TMP_Text)obj.Detail).rectTransform, 54f, 156f, 30f, 20f); obj.Meta = _kit.Text("Meta", ((Component)val).transform, string.Empty, 12f, UiKit.MutedText, (TextAlignmentOptions)4100); UiKit.Place(((TMP_Text)obj.Meta).rectTransform, new Vector2(1f, 0f), new Vector2(1f, 0f), new Vector2(-8f, 3f), new Vector2(140f, 18f)); if (ModConfig.AllowRemoteOpen.Value) { UiKit.Place(((Component)_kit.Button("Open", ((Component)val).transform, Loc.T("btn_open"), 13f, (UnityAction)delegate { if (Object.op_Implicit((Object)(object)container)) { Hide(); RemoteOpen.Open(container); } })).GetComponent<RectTransform>(), new Vector2(1f, 1f), new Vector2(1f, 1f), new Vector2(-138f, -4f), new Vector2(60f, 26f)); } UiKit.Place(((Component)_kit.Button("Show", ((Component)val).transform, Loc.T("btn_ping"), 13f, (UnityAction)delegate { //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)container)) { Highlighter.Flash(container, 6f, ModConfig.AccentColor.Value); } })).GetComponent<RectTransform>(), new Vector2(1f, 1f), new Vector2(1f, 1f), new Vector2(-72f, -4f), new Vector2(62f, 26f)); UiKit.Place(((Component)_kit.Button("Edit", ((Component)val).transform, Loc.T("btn_edit"), 13f, (UnityAction)delegate { if (Object.op_Implicit((Object)(object)container)) { _ui.ToggleEditor(container); } })).GetComponent<RectTransform>(), new Vector2(1f, 1f), new Vector2(1f, 1f), new Vector2(-8f, -4f), new Vector2(60f, 26f)); return obj; } private void UpdateRow(Row row, ChestTarget chest, string hit) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) ChestConfig config = chest.Config; bool flag = !string.IsNullOrEmpty(config.Label); ((TMP_Text)row.Name).text = (flag ? config.Label : ChestNames.VanillaName(chest.Container)); ((Graphic)row.Name).color = (flag ? ModConfig.AccentColor.Value : UiKit.BodyText); if (hit != null) { ((TMP_Text)row.Detail).text = hit; } else if (config.HasLinks) { ((TMP_Text)row.Detail).text = config.Summarize(3) + " (" + Loc.T("priority_short", config.Priority) + ")"; } else { ((TMP_Text)row.Detail).text = Loc.T("no_categories"); } Inventory inventory = chest.Container.GetInventory(); int num = ((inventory != null) ? inventory.NrOfItems() : 0); int num2 = ((inventory != null) ? (inventory.GetWidth() * inventory.GetHeight()) : 0); ((TMP_Text)row.Meta).text = Loc.T("distance", Mathf.RoundToInt(chest.Distance)) + " - " + Loc.T("slots", num, num2); Sprite val = PickIcon(config, inventory); row.Icon.sprite = val; ((Behaviour)row.Icon).enabled = (Object)(object)val != (Object)null; } private static Sprite PickIcon(ChestConfig config, Inventory inventory) { foreach (CategoryGroup group in CategoryService.Registry.Groups) { if (config.Links.Contains(group.Id)) { return CategoryService.GetIcon(group); } foreach (Category category in group.Categories) { if (config.Links.Contains(category.Id)) { return CategoryService.GetIcon(category); } } } ItemData val = null; if (inventory != null) { foreach (ItemData allItem in inventory.GetAllItems()) { if (val == null || allItem.m_stack > val.m_stack) { val = allItem; } } } if (val == null) { return null; } return val.GetIcon(); } private string DescribeHits(Container container, out int units) { units = 0; Inventory inventory = container.GetInventory(); if (inventory == null) { return null; } Dictionary<string, int> dictionary = null; foreach (ItemData allItem in inventory.GetAllItems()) { ItemInfo info = CategoryService.GetInfo(allItem); if (_query.Matches(info)) { if (dictionary == null) { dictionary = new Dictionary<string, int>(); } dictionary.TryGetValue(info.LocalizedName, out var value); dictionary[info.LocalizedName] = value + allItem.m_stack; units += allItem.m_stack; } } if (dictionary == null) { return null; } StringBuilder stringBuilder = new StringBuilder(); foreach (KeyValuePair<string, int> item in dictionary.OrderByDescending((KeyValuePair<string, int> p) => p.Value).Take(4)) { if (stringBuilder.Length > 0) { stringBuilder.Append(", "); } stringBuilder.Append(Loc.T("contains", item.Value, item.Key)); } if (dictionary.Count > 4) { stringBuilder.Append(" ").Append(Loc.T("and_more", dictionary.Count - 4)); } return stringBuilder.ToString(); } } internal sealed class ModUi : MonoBehaviour { private static readonly List<TMP_InputField> InputFields = new List<TMP_InputField>(); private static int _lastTypingFrame = -10; private bool _wasVisible; public static ModUi Instance { get; private set; } public UiKit Kit { get; private set; } public InventoryGui Gui { get; private set; } public ChestToolbar ChestBar { get; private set; } public InventoryToolbar InventoryBar { get; private set; } public CategoryEditor Editor { get; private set; } public ChestManager Manager { get; private set; } public static bool IsTyping { get { if (AnyFieldFocused()) { _lastTypingFrame = Time.frameCount; return true; } return Time.frameCount - _lastTypingFrame <= 1; } } public static bool IsAnyTextFieldFocused { get { if (IsTyping || GUIUtility.keyboardControl != 0) { return true; } GameObject val = (((Object)(object)EventSystem.current != (Object)null) ? EventSystem.current.currentSelectedGameObject : null); if ((Object)(object)val == (Object)null) { return false; } TMP_InputField val2 = default(TMP_InputField); if (val.TryGetComponent<TMP_InputField>(ref val2) && val2.isFocused) { return true; } InputField val3 = default(InputField); if (val.TryGetComponent<InputField>(ref val3)) { return val3.isFocused; } return false; } } private static bool AnyFieldFocused() { for (int num = InputFields.Count - 1; num >= 0; num--) { TMP_InputField val = InputFields[num]; if (!Object.op_Implicit((Object)(object)val)) { InputFields.RemoveAt(num); } else if (val.isFocused && ((Behaviour)val).isActiveAndEnabled) { return true; } } return false; } private static void ReleaseKeyboard() { foreach (TMP_InputField inputField in InputFields) { if (Object.op_Implicit((Object)(object)inputField) && inputField.isFocused) { inputField.DeactivateInputField(false); } } _lastTypingFrame = -10; } public static void RegisterInput(TMP_InputField field) { if ((Object)(object)field != (Object)null && !InputFields.Contains(field)) { InputFields.Add(field); } } public static void Create(InventoryGui gui) { if ((Object)(object)gui == (Object)null) { return; } if ((Object)(object)Instance != (Object)null) { Object.Destroy((Object)(object)Instance); } try { ModUi modUi = ((Component)gui).gameObject.AddComponent<ModUi>(); modUi.Build(gui); Instance = modUi; } catch (Exception e) { Log.Error("Could not build the ChestCategories interface. Hotkeys and chest rules still work", e); } } private void Build(InventoryGui gui) { Gui = gui; Kit = UiKit.Capture(gui); Transform parent = (((Object)(object)gui.m_inventoryRoot != (Object)null) ? gui.m_inventoryRoot : ((Component)gui).transform); ChestBar = new ChestToolbar(this, gui.m_container); InventoryBar = new InventoryToolbar(this, gui.m_player); Editor = new CategoryEditor(this, parent); Manager = new ChestManager(this, parent); ApplyLayoutSettings(); ModConfig.ToolbarOffset.SettingChanged += OnLayoutSettingChanged; ModConfig.InventoryToolbarOffset.SettingChanged += OnLayoutSettingChanged; ModConfig.ToolbarPosition.SettingChanged += OnLayoutSettingChanged; ModConfig.WindowOffset.SettingChanged += OnLayoutSettingChanged; ModConfig.UiScale.SettingChanged += OnLayoutSettingChanged; ModConfig.ShowToolbar.SettingChanged += OnLayoutSettingChanged; } private void OnDestroy() { ModConfig.ToolbarOffset.SettingChanged -= OnLayoutSettingChanged; ModConfig.InventoryToolbarOffset.SettingChanged -= OnLayoutSettingChanged; ModConfig.ToolbarPosition.SettingChanged -= OnLayoutSettingChanged; ModConfig.WindowOffset.SettingChanged -= OnLayoutSettingChanged; ModConfig.UiScale.SettingChanged -= OnLayoutSettingChanged; ModConfig.ShowToolbar.SettingChanged -= OnLayoutSettingChanged; if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } SearchFilter.Clear(); } private void OnLayoutSettingChanged(object sender, EventArgs e) { ApplyLayoutSettings(); } private void ApplyLayoutSettings() { ChestBar?.ApplyLayout(); InventoryBar?.ApplyLayout(); Editor?.ApplyLayout(); Manager?.ApplyLayout(); } private void Update() { if ((Object)(object)Gui == (Object)null || ChestBar == null) { return; } if (!InventoryGui.IsVisible()) { if (_wasVisible) { OnInventoryClosed(); } _wasVisible = false; return; } _wasVisible = true; try { Container currentContainer = GameAccess.CurrentContainer; bool value = ModConfig.ShowToolbar.Value; ChestBar.Tick(value ? currentContainer : null); InventoryBar.Tick(value && (Object)(object)currentContainer == (Object)null); Editor.Tick(); Manager.Tick(); } catch (Exception e) { Log.Error("Interface update failed", e); ((Behaviour)this).enabled = false; } } public void OnInventoryClosed() { ReleaseKeyboard(); Editor?.Hide(); Manager?.Hide(); ChestBar?.ClearSearch(); SearchFilter.Clear(); } public void ToggleEditor(Container container) { if (Editor != null && Object.op_Implicit((Object)(object)container)) { if (Editor.IsOpenFor(container)) { Editor.Hide(); return; } Manager?.Hide(); Editor.Show(container); } } public void ToggleManager() { if (Manager == null) { return; } if (Manager.IsOpen) { Manager.Hide(); return; } if (!InventoryGui.IsVisible()) { Gui.Show((Container)null, 1); } Editor?.Hide(); Manager.Show(); } public void FocusSearch() { if (InventoryGui.IsVisible()) { ChestBar?.FocusSearch(); } } } internal sealed class SearchQuery { private static readonly char[] Separators = new char[2] { ' ', '\t' }; private readonly string[] _terms; public string Text { get; } public bool IsEmpty => _terms.Length == 0; public SearchQuery(string text) { Text = text ?? string.Empty; _terms = Text.Trim().ToLowerInvariant().Split(Separators, StringSplitOptions.RemoveEmptyEntries); } public bool Matches(ItemInfo info) { if (_terms.Length == 0) { return true; } if (info == null) { return false; } string searchText = info.SearchText; string[] terms = _terms; foreach (string value in terms) { if (searchText.IndexOf(value, StringComparison.Ordinal) < 0) { return false; } } return true; } public bool Matches(ItemData item) { if (_terms.Length != 0) { return Matches(CategoryService.GetInfo(item)); } return true; } } internal static class SearchFilter { private static SearchQuery _query = new SearchQuery(string.Empty); public static SearchQuery Query => _query; public static bool Active => !_query.IsEmpty; public static void Set(string text) { if (!string.Equals(text ?? string.Empty, _query.Text, StringComparison.Ordinal)) { _query = new SearchQuery(text); } } public static void Clear() { Set(string.Empty); } } internal sealed class ChestToolbar { private const float ButtonRowHeight = 30f; private const float SummaryHeight = 22f; private const float Gap = 12f; private readonly ModUi _ui; private readonly RectTransform _root; private readonly TextMeshProUGUI _summary; private readonly TMP_InputField _search; private Container _container; private string _summaryCache; private float _nextRefresh; public ChestToolbar(ModUi ui, RectTransform chestPanel) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Expected O, but got Unknown //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Expected O, but got Unknown //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Expected O, but got Unknown //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0225: 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_023b: Expected O, but got Unknown //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_026a: 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_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) _ui = ui; UiKit kit = ui.Kit; _root = kit.Rect("ChestCategories_ChestToolbar", (Transform)(object)chestPanel); ((Component)_root).gameObject.SetActive(false); UiKit.Stretch(((Graphic)kit.Box("Backdrop", (Transform)(object)_root, new Color(0f, 0f, 0f, 0.55f), raycastTarget: true)).rectTransform, -6f, -6f, -5f, -5f); RectTransform val = kit.Rect("Buttons", (Transform)(object)_root); UiKit.Band(val, 0f, 0f, 0f, 30f); UiKit.Row((Component)(object)val, 4f, (TextAnchor)3); AddButton(kit, (Transform)(object)val, "btn_categories", "tip_categories", 104f, (UnityAction)delegate { _ui.ToggleEditor(_container); }); AddButton(kit, (Transform)(object)val, "btn_sort", "tip_sort", 56f, (UnityAction)delegate { SortService.SortContainer(_container, announce: true); }); AddButton(kit, (Transform)(object)val, "btn_deposit", "tip_deposit", 76f, (UnityAction)delegate { StashService.DepositInto(_container); }); AddButton(kit, (Transform)(object)val, "btn_stash", "tip_stash", 60f, new UnityAction(StashService.StashAll)); AddButton(kit, (Transform)(object)val, "btn_chests", "tip_chests", 66f, (UnityAction)delegate { _ui.ToggleManager(); }); _search = kit.Input("Search", (Transform)(object)val, Loc.T("search_placeholder"), 14f, 40); UiKit.Size((Component)(object)_search, 90f, 30f, 1f); ((UnityEvent<string>)(object)_search.onValueChanged).AddListener((UnityAction<string>)SearchFilter.Set); _search.textViewport.offsetMax = new Vector2(-24f, -3f); ModUi.RegisterInput(_search); Button val2 = kit.FlatButton("Clear", ((Component)_search).transform, new Color(1f, 1f, 1f, 0f), new Color(1f, 1f, 1f, 0.15f), new UnityAction(ClearSearch)); UiKit.Place(((Component)val2).GetComponent<RectTransform>(), new Vector2(1f, 0.5f), new Vector2(1f, 0.5f), new Vector2(-3f, 0f), new Vector2(20f, 20f)); UiKit.Stretch(((TMP_Text)kit.Text("X", ((Component)val2).transform, "x", 14f, UiKit.MutedText, (TextAlignmentOptions)514)).rectTransform, 0f, 0f, 0f, 0f); _summary = kit.Text("Summary", (Transform)(object)_root, string.Empty, 14f, UiKit.BodyText, (TextAlignmentOptions)4097); UiKit.Band(((TMP_Text)_summary).rectTransform, 2f, 2f, 33f, 22f); } public void ApplyLayout() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: 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) Vector2 value = ModConfig.ToolbarOffset.Value; float num = 55f; bool flag = ModConfig.ToolbarPosition.Value == ToolbarAnchor.BelowChest; _root.anchorMin = new Vector2(0f, flag ? 0f : 1f); _root.anchorMax = new Vector2(1f, flag ? 0f : 1f); _root.pivot = new Vector2(0f, flag ? 1f : 0f); _root.sizeDelta = new Vector2(0f, num); _root.anchoredPosition = new Vector2(value.x, (flag ? (-12f) : 12f) + value.y); ((Transform)_root).localScale = Vector3.one * ModConfig.UiScale.Value; } public void Tick(Container container) { //IL_0104: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)container)) { if ((Object)(object)_container != (Object)null || SearchFilter.Active) { ClearSearch(); } if (((Component)_root).gameObject.activeSelf) { ((Component)_root).gameObject.SetActive(false); } _container = null; return; } if (!((Component)_root).gameObject.activeSelf) { ((Component)_root).gameObject.SetActive(true); } if ((Object)(object)container != (Object)(object)_container) { if ((Object)(object)_container != (Object)null) { ClearSearch(); } _container = container; _nextRefresh = 0f; } if (!(Time.unscaledTime < _nextRefresh)) { _nextRefresh = Time.unscaledTime + 0.25f; ChestConfig chestConfig = ChestConfigStore.Get(container); string text = (chestConfig.HasLinks ? ("<color=#" + ColorUtility.ToHtmlStringRGB(ModConfig.AccentColor.Value) + ">" + Loc.T("hover_accepts") + ":</color> " + ChestConfigStore.GetSummary(container, 4) + " <color=#B8B0A0>(" + Loc.T("priority_short", chestConfig.Priority) + ")</color>") : ("<color=#B8B0A0>" + Loc.T("no_categories") + "</color>")); if (!(text == _summaryCache)) { _summaryCache = text; ((TMP_Text)_summary).text = text; } } } public void FocusSearch() { if (((Component)_root).gameObject.activeInHierarchy) { ((Selectable)_search).Select(); _search.ActivateInputField(); } } public void ClearSearch() { if ((Object)(object)_search != (Object)null && !string.IsNullOrEmpty(_search.text)) { _search.text = string.Empty; } SearchFilter.Clear(); } private static void AddButton(UiKit kit, Transform row, string labelKey, string tipKey, float width, UnityAction onClick) { Button val = kit.Button(labelKey, row, Loc.T(labelKey), 14f, onClick); UiKit.Size((Component)(object)val, width, 30f); kit.Tooltip(((Component)val).gameObject, Loc.T(labelKey), Loc.T(tipKey)); } } internal sealed class InventoryToolbar { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__3_0; internal void <.ctor>b__3_0() { SortService.SortPlayerInventory(Player.m_localPlayer); } } private const float Height = 30f; private const float Gap = 12f; private readonly RectTransform _root; public InventoryToolbar(ModUi ui, RectTransform playerPanel) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown //IL_0089: 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_0094: Expected O, but got Unknown UiKit kit = ui.Kit; _root = kit.Rect("ChestCategories_InventoryToolbar", (Transform)(object)playerPanel); ((Component)_root).gameObject.SetActive(false); UiKit.Row((Component)(object)_root, 4f, (TextAnchor)3); Add(kit, "btn_stash", "tip_stash", 60f, new UnityAction(StashService.StashAll)); object obj = <>c.<>9__3_0; if (obj == null) { UnityAction val = delegate { SortService.SortPlayerInventory(Player.m_localPlayer); }; <>c.<>9__3_0 = val; obj = (object)val; } Add(kit, "btn_sort", "tip_sort_inventory", 56f, (UnityAction)obj); Add(kit, "btn_chests", "tip_chests", 66f, new UnityAction(ui.ToggleManager)); } public void ApplyLayout() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_004f: Unknown result type (might be due to invalid IL or missing refere