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 Storehouse v0.5.2
BepInEx/plugins/Storehouse.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; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GUIFramework; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("Storehouse")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+692dabdf4b05db39f53f1f284f9dba025b2da524")] [assembly: AssemblyProduct("Storehouse")] [assembly: AssemblyTitle("Storehouse")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Storehouse { internal static class Affinity { private class Key { public int Type; public string[] Gear; public int ItemType; public string Family; public int Order; public string Prefab; } private static readonly Dictionary<string, Key> Cache = new Dictionary<string, Key>(); public static void ClearCache() { Cache.Clear(); } private static Key KeyOf(string prefab) { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) prefab = prefab ?? ""; if (Cache.TryGetValue(prefab, out var value)) { return value; } ItemInfo itemInfo = TagDb.Info(prefab); List<string> value2; List<string> list = (TagDb.SetOrder.TryGetValue("Type", out value2) ? value2 : new List<string>()); ItemInfo itemInfo2 = ((itemInfo != null && itemInfo.Family != null) ? (TagDb.Info(itemInfo.Family) ?? itemInfo) : itemInfo); value = new Key { Type = ((itemInfo2 == null) ? int.MaxValue : Math.Max(0, list.IndexOf(itemInfo2.Type))), Gear = (itemInfo?.Gear ?? new string[0]), ItemType = ((itemInfo != null) ? ((int)itemInfo.ItemType) : 0), Family = (itemInfo?.Family ?? prefab), Order = (itemInfo?.Order ?? int.MaxValue), Prefab = prefab }; Cache[prefab] = value; return value; } public static int Compare(string a, string b) { Key key = KeyOf(a); Key key2 = KeyOf(b); int num = key.Type.CompareTo(key2.Type); if (num != 0) { return num; } for (int i = 0; i < Math.Max(key.Gear.Length, key2.Gear.Length); i++) { num = string.CompareOrdinal((i < key.Gear.Length) ? key.Gear[i] : "", (i < key2.Gear.Length) ? key2.Gear[i] : ""); if (num != 0) { return num; } } num = key.ItemType.CompareTo(key2.ItemType); if (num != 0) { return num; } num = string.CompareOrdinal(key.Family, key2.Family); if (num != 0) { return num; } return key.Order.CompareTo(key2.Order); } public static double Distance(string a, string b) { Key key = KeyOf(a); Key key2 = KeyOf(b); if (key.Prefab == key2.Prefab) { return 0.0; } if (key.Family == key2.Family) { return 0.2; } if (key.Type != key2.Type) { return 1000.0; } for (int i = 0; i < Math.Max(key.Gear.Length, key2.Gear.Length); i++) { if (((i < key.Gear.Length) ? key.Gear[i] : "") != ((i < key2.Gear.Length) ? key2.Gear[i] : "")) { return i switch { 1 => 30, 0 => 100, _ => 20, }; } } if (key.ItemType != key2.ItemType) { return 15.0; } return 1.0; } } internal static class ChestUi { [HarmonyPatch(typeof(InventoryGui), "UpdateContainer")] private static class UpdateContainerPatch { private static void Postfix(InventoryGui __instance) { Stopwatch stopwatch = ((Plugin.DebugLog != null && Plugin.DebugLog.Value) ? Stopwatch.StartNew() : null); bool flag = (Object)(object)Current.Invoke(__instance) != (Object)(object)_shown; try { Update(__instance); } catch (Exception ex) { Plugin.Log.LogError((object)("Chest UI: " + ex)); _root = null; } if (stopwatch != null && stopwatch.ElapsedMilliseconds >= 8) { Plugin.Log.LogInfo((object)string.Format("Chest UI took {0} ms{1}", stopwatch.ElapsedMilliseconds, flag ? " (opening)" : "")); } } } [HarmonyPatch(typeof(InventoryGui), "Hide")] private static class HidePatch { private static void Postfix(InventoryGui __instance) { if (Object.op_Implicit((Object)(object)_shown)) { Close(__instance); } } } [HarmonyPatch(typeof(InventoryGui), "OnStackAll")] private static class StoreAllPatch { private static bool Prefix(InventoryGui __instance) { //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_00df: Unknown result type (might be due to invalid IL or missing references) if (!WorldSync.Ready) { return true; } Container val = Current.Invoke(__instance); if (QuickStack || !Object.op_Implicit((Object)(object)val) || !Registry.IsManaged(val)) { return true; } Player localPlayer = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)localPlayer) || ((Character)localPlayer).IsTeleporting()) { return false; } Inventory inventory = ((Humanoid)localPlayer).GetInventory(); Inventory inventory2 = val.GetInventory(); foreach (ItemData item in inventory.GetAllItems().ToList()) { if (item.m_gridPos.y != 0 && !item.m_equipped && item.m_gridPos.y < 4) { inventory2.MoveItemToThis(inventory, item); } } __instance.m_moveItemEffects.Create(((Component)__instance).transform.position, Quaternion.identity, (Transform)null, 1f, -1, default(ZDOID)); return false; } } private static readonly FieldRef<InventoryGui, Container> Current = AccessTools.FieldRefAccess<InventoryGui, Container>("m_currentContainer"); private static readonly FieldRef<InventoryGui, InventoryGrid> Grid = AccessTools.FieldRefAccess<InventoryGui, InventoryGrid>("m_containerGrid"); private static RectTransform _root; private static Button _mode; private static Button _group; private static Button _menu; private static RectTransform _picker; private static Container _shown; private static string _stateKey; private static bool _pickerOpen; private static bool _menuOpen; private static string _stackAllText; private static string _lastLabel; private static Container _lastLabelChest; public static bool QuickStack => Chainloader.PluginInfos.ContainsKey("goldenrevolver.quick_stack_store"); public static Container Chest => _shown; public static bool MenuOpen => _menuOpen; private static void Update(InventoryGui gui) { Container val = Current.Invoke(gui); if (Object.op_Implicit((Object)(object)val)) { TagDb.EnsureFresh(); } TMP_Text val2; int num; string text; if (!Plugin.MenuEnabled.Value || !WorldSync.Ready || !Object.op_Implicit((Object)(object)val) || !((Component)gui.m_container).gameObject.activeSelf || !Registry.Eligible(val) || !TagDb.Ready) { val2 = (Object.op_Implicit((Object)(object)gui.m_stackAllButton) ? ((Component)gui.m_stackAllButton).GetComponentInChildren<TMP_Text>(true) : null); if (Object.op_Implicit((Object)(object)val2) && _lastLabel != null && _stackAllText != null) { if (Object.op_Implicit((Object)(object)val)) { num = (((Object)(object)val == (Object)(object)_lastLabelChest) ? 1 : 0); if (num == 0) { text = _stackAllText; goto IL_00b6; } } else { num = 1; } text = _lastLabel; goto IL_00b6; } goto IL_00d9; } UiKit.Capture(gui); if (!UiKit.Ready) { return; } if (!Object.op_Implicit((Object)(object)_root)) { Build(gui); } ((Component)_root).gameObject.SetActive(true); if ((Object)(object)val != (Object)(object)_shown) { Close(gui); _shown = val; } bool flag = Registry.IsManaged(val); Group obj = Registry.GroupOf(val); string text2 = ((Object)val).GetInstanceID() + "|" + flag + "|" + obj?.Id + "|" + obj?.Last + "|" + _pickerOpen + "|" + _menuOpen + "|" + GroupMenu.Revision; TMP_Text componentInChildren = ((Component)gui.m_stackAllButton).GetComponentInChildren<TMP_Text>(true); if (Object.op_Implicit((Object)(object)componentInChildren)) { if (_stackAllText == null && componentInChildren.text != "Store all") { _stackAllText = componentInChildren.text; } string text3 = (_lastLabel = ((!QuickStack && flag) ? "Store all" : _stackAllText)); _lastLabelChest = val; if (text3 != null && componentInChildren.text != text3) { componentInChildren.text = text3; } } if (text2 == _stateKey) { HideNativeStackButton(gui, flag); return; } _stateKey = text2; UiKit.SetButtonIcon(_mode, flag ? UiKit.ManagedIcon() : UiKit.ChestIcon()); UiKit.Tooltip(((Component)_mode).gameObject, flag ? "Managed chest" : "Normal chest", ""); ((Component)_group).gameObject.SetActive(flag && !_menuOpen); ((Component)_menu).gameObject.SetActive(flag); UiKit.SetButtonIcon(_group, GroupIcon(obj)); if (!flag) { _pickerOpen = false; _menuOpen = false; } SetChestContentVisible(gui, !_pickerOpen && !_menuOpen); HideNativeStackButton(gui, flag); ((Component)_picker).gameObject.SetActive(_pickerOpen); if (_pickerOpen) { FillPicker(val); } GroupMenu.Show(_menuOpen, val); return; IL_00d9: if (Object.op_Implicit((Object)(object)_root)) { ((Component)_root).gameObject.SetActive(false); } if (Object.op_Implicit((Object)(object)_shown)) { Close(gui); } return; IL_00b6: string text4 = text; if (val2.text != text4) { val2.text = text4; } if (num == 0) { _lastLabel = null; } goto IL_00d9; } private static void HideNativeStackButton(InventoryGui gui, bool managed) { if (QuickStack && managed && Object.op_Implicit((Object)(object)gui.m_stackAllButton)) { ((Component)gui.m_stackAllButton).gameObject.SetActive(false); } } private static void Build(InventoryGui gui) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) _root = UiKit.Stretch(UiKit.Rect("gl_chest_ui", (Transform)(object)gui.m_container, 0f, 0f, 0f, 0f)); ((Transform)_root).SetAsLastSibling(); Rect rect = gui.m_container.rect; float width = ((Rect)(ref rect)).width; if (QuickStack) { _mode = UiKit.IconButton((Transform)(object)_root, null, 12f, 10f, 34f, ToggleMode); _group = UiKit.IconButton((Transform)(object)_root, null, 52f, 10f, 34f, TogglePicker, 0.7f); _menu = UiKit.IconButton((Transform)(object)_root, UiKit.EmbeddedSprite("menu"), width - 12f - 34f, 10f, 34f, ToggleMenu); } else { RectTransform val = ((!Object.op_Implicit((Object)(object)gui.m_stackAllButton)) ? ((RectTransform)null) : ((RectTransform)((Component)gui.m_stackAllButton).transform)); float num; if (!Object.op_Implicit((Object)(object)val)) { num = 34f; } else { rect = val.rect; num = ((Rect)(ref rect)).height; } float num2 = num; float num3 = 8f; if (Object.op_Implicit((Object)(object)val)) { Vector3[] array = (Vector3[])(object)new Vector3[4]; val.GetWorldCorners(array); rect = _root.rect; num3 = ((Rect)(ref rect)).yMax - ((Transform)_root).InverseTransformPoint(array[1]).y; } _mode = UiKit.IconButton((Transform)(object)_root, null, width + 8f, num3, num2, ToggleMode); _menu = UiKit.IconButton((Transform)(object)_root, UiKit.EmbeddedSprite("menu"), width + 8f, num3 + num2 + 6f, num2, ToggleMenu); _group = UiKit.IconButton((Transform)(object)_root, null, 0f, 0f, num2, TogglePicker, 0.7f); Transform transform = ((Component)_group).transform; Transform rt = ((transform is RectTransform) ? transform : null); Transform transform2 = ((Component)gui.m_takeAllButton).transform; PlaceNextTo((RectTransform)(object)rt, (RectTransform)(object)((transform2 is RectTransform) ? transform2 : null), num2); } UiKit.Tooltip(((Component)_menu).gameObject, "Storage groups", ""); RectTransform root = _root; float w = width - 24f; rect = gui.m_container.rect; _picker = UiKit.Rect("gl_picker", (Transform)(object)root, 12f, 48f, w, ((Rect)(ref rect)).height - 60f); ((Component)_picker).gameObject.SetActive(false); RectTransform root2 = _root; rect = gui.m_container.rect; GroupMenu.Build(root2, width, ((Rect)(ref rect)).height, gui); } private static void PlaceNextTo(RectTransform rt, RectTransform anchor, float size) { //IL_000f: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) ((Transform)rt).SetParent(((Transform)anchor).parent, false); rt.anchorMin = anchor.anchorMin; rt.anchorMax = anchor.anchorMax; rt.pivot = new Vector2(0.5f, 0.5f); Vector2 anchoredPosition = anchor.anchoredPosition; Vector2 val = new Vector2(0.5f, 0.5f) - anchor.pivot; Rect rect = anchor.rect; Vector2 val2 = anchoredPosition + val * ((Rect)(ref rect)).size; rect = anchor.rect; rt.anchoredPosition = val2 + new Vector2(((Rect)(ref rect)).width / 2f + 6f + size / 2f, 0f); rt.sizeDelta = new Vector2(size, size); } private static void SetChestContentVisible(InventoryGui gui, bool visible) { InventoryGrid val = Grid.Invoke(gui); if (Object.op_Implicit((Object)(object)val)) { ((Component)val).gameObject.SetActive(visible); } if (Object.op_Implicit((Object)(object)gui.m_takeAllButton)) { ((Component)gui.m_takeAllButton).gameObject.SetActive(visible); } if (Object.op_Implicit((Object)(object)gui.m_stackAllButton)) { ((Component)gui.m_stackAllButton).gameObject.SetActive(visible); } if (Object.op_Implicit((Object)(object)gui.m_containerName)) { ((Component)gui.m_containerName).gameObject.SetActive(!_menuOpen); } } private static void Close(InventoryGui gui) { _pickerOpen = false; _menuOpen = false; _stateKey = null; if (Object.op_Implicit((Object)(object)_root)) { SetChestContentVisible(gui, visible: true); } GroupMenu.Show(open: false, null); _shown = null; } private static void ToggleMode() { Container chest; bool toNormal; if (Object.op_Implicit((Object)(object)_shown)) { chest = _shown; toNormal = Registry.IsManaged(chest); int count = OrderData.Get(chest).Count; if (toNormal && count > 0) { UiKit.Confirm("Switch to Normal?", string.Format("This chest has {0} order{1}. Switching to Normal cancels {2}.", count, (count == 1) ? "" : "s", (count == 1) ? "it" : "them"), Do); } else { Do(); } } void Do() { Registry.SetManaged(chest, !toNormal); _stateKey = null; } } private static void TogglePicker() { _pickerOpen = !_pickerOpen; _stateKey = null; } private static void ToggleMenu() { _menuOpen = !_menuOpen; _pickerOpen = false; _stateKey = null; } public static void Refresh() { _stateKey = null; } public static Sprite GroupIcon(Group g) { if (g == null) { return UiKit.ChestIcon(); } if (g.Last != null && g.Accepts(g.Last)) { return UiKit.ItemIcon(g.Last); } foreach (string item in g.Take.Concat(g.Only)) { if (TagDb.Tags.TryGetValue(item, out var value)) { string text = TagsTab.TagIconItem(value); string text2 = ((text != null && g.Accepts(text)) ? text : value.Items.FirstOrDefault(g.Accepts)); if (text2 != null) { return UiKit.ItemIcon(text2); } } } return UiKit.ChestIcon(); } private static void FillPicker(Container chest) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_011e: Unknown result type (might be due to invalid IL or missing references) UiKit.Clear((Transform)(object)_picker); RectTransform picker = _picker; Rect rect = _picker.rect; float width = ((Rect)(ref rect)).width; rect = _picker.rect; ScrollRect scroll; RectTransform content = UiKit.Scroll((Transform)(object)picker, 0f, 0f, width, ((Rect)(ref rect)).height, out scroll); string current = Registry.GroupId(chest); float y = 0f; rect = _picker.rect; float rowW = ((Rect)(ref rect)).width - 12f; Add("", "No group", "", UiKit.ChestIcon()); foreach (Group group in WorldStore.Data.Groups) { Add(group.Id, group.Name, GroupMenu.Summary(group), GroupIcon(group)); } content.sizeDelta = new Vector2(content.sizeDelta.x, y); void Add(string id, string name, string sub, Sprite icon) { //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Expected O, but got Unknown //IL_00ce: Unknown result type (might be due to invalid IL or missing references) GameObject val = UiKit.Row((Transform)(object)content, y, rowW, 34f); ((Component)val.transform.Find("icon")).GetComponent<Image>().sprite = icon; ((Component)val.transform.Find("name")).GetComponent<TMP_Text>().text = name; Transform obj = val.transform.Find("QualityLevel"); if (obj != null) { ((Component)obj).gameObject.SetActive(false); } Transform obj2 = val.transform.Find("selected"); if (obj2 != null) { ((Component)obj2).gameObject.SetActive(id == current); } if (!string.IsNullOrEmpty(sub)) { UiKit.Label(val.transform, sub, 11f, UiKit.Grey, rowW * 0.45f, 0f, rowW * 0.53f, 34f, (TextAlignmentOptions)4100); } ((UnityEvent)val.GetComponent<Button>().onClick).AddListener((UnityAction)delegate { int count = OrderData.Get(chest).Count; if (count > 0 && (Registry.GroupId(chest) ?? "") != (id ?? "")) { UiKit.Confirm("Change group?", string.Format("This chest has {0} order{1}. Changing its group cancels {2}.", count, (count == 1) ? "" : "s", (count == 1) ? "it" : "them"), Do); } else { Do(); } }); y += 36f; void Do() { Registry.SetGroup(chest, id); _pickerOpen = false; _stateKey = null; } } } } internal static class ClientWork { private static readonly Dictionary<ZDOID, float> Settled = new Dictionary<ZDOID, float>(); private static readonly MethodInfo Load = AccessTools.Method(typeof(Container), "Load", (Type[])null, (Type[])null); public static bool IsWorker(Container chest) { Container val = (from c in Network.ChestsOf(chest) orderby ((ZDOID)(ref Registry.Zdo(c).m_uid)).UserID, ((ZDOID)(ref Registry.Zdo(c).m_uid)).ID select c).FirstOrDefault(); if (Object.op_Implicit((Object)(object)val)) { return Registry.IsOwner(val); } return false; } public static bool Prepare(Container chest) { //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)Player.m_localPlayer) || !Object.op_Implicit((Object)(object)chest)) { return false; } List<Container> list = (from c in Network.ChestsOf(chest) orderby ((ZDOID)(ref Registry.Zdo(c).m_uid)).UserID, ((ZDOID)(ref Registry.Zdo(c).m_uid)).ID select c).ToList(); if (list.Count == 0 || !Registry.IsOwner(list[0])) { return false; } bool flag = true; foreach (Container item in list) { ZDO val = Registry.Zdo(item); if (item.IsInUse() || val.GetInt(ZDOVars.s_inUse, 0) == 1) { return false; } ZNetView component = ((Component)item).GetComponent<ZNetView>(); float value; if (!component.IsOwner()) { component.ClaimOwnership(); Settled.Remove(val.m_uid); flag = false; } else if (!Settled.TryGetValue(val.m_uid, out value)) { Settled[val.m_uid] = Time.unscaledTime; flag = false; } else if (Time.unscaledTime - value < 1f) { flag = false; } } if (!flag) { return false; } foreach (Container item2 in list) { Load.Invoke(item2, null); } return true; } } internal static class DefaultIcons { public static readonly Dictionary<string, string> Icon = new Dictionary<string, string> { ["Type/Wood"] = "Wood", ["Type/Stone"] = "Stone", ["Type/Ores"] = "CopperOre", ["Type/Metals"] = "Iron", ["Type/Coal"] = "Coal", ["Type/Hides & leather"] = "DeerHide", ["Type/Fibers & cloth"] = "LinenThread", ["Type/Creature parts"] = "Feathers", ["Type/Components"] = "BronzeNails", ["Type/Valuables"] = "Coins", ["Type/Seeds"] = "CarrotSeeds", ["Type/Plants & forage"] = "Raspberry", ["Type/Raw meat"] = "RawMeat", ["Type/Fish"] = "Fish1", ["Type/Cooking prep"] = "BarleyFlour", ["Type/Food"] = "CookedMeat", ["Type/Mead bases"] = "MeadBaseHealthMinor", ["Type/Meads"] = "MeadHealthMinor", ["Type/Ammo"] = "ArrowFlint", ["Type/Gear"] = "AxeFlint", ["Type/Trophies"] = "TrophyDeer", ["Type/Boss items"] = "HardAntler", ["Type/Moulds & casts"] = "MoldSword", ["Use/Crafting"] = "LeatherScraps", ["Use/Cooking"] = "RawMeat", ["Use/Building"] = "Wood", ["Use/Brewing"] = "Honey", ["Use/Eat"] = "Raspberry", ["Use/Taming & feeding"] = "Mushroom", ["Use/Magic"] = "Eitr", ["Use/Planting"] = "CarrotSeeds", ["Use/Smelting"] = "CopperOre", ["Use/Fuel"] = "Coal", ["Use/Treasure"] = "Coins", ["Use/Summoning"] = "TrophyDeer", ["Biome/Meadows"] = "TrophyEikthyr", ["Biome/Black Forest"] = "TrophyTheElder", ["Biome/Swamp"] = "TrophyBonemass", ["Biome/Ocean"] = "TrophySerpent", ["Biome/Mountains"] = "TrophyDragonQueen", ["Biome/Plains"] = "TrophyGoblinKing", ["Biome/Mistlands"] = "TrophySeekerQueen", ["Biome/Ashlands"] = "TrophyFader", ["Biome/Deep North"] = "TrophyJotunWarrior", ["Source/Crafted"] = "Club", ["Source/Creature drop"] = "LeatherScraps", ["Source/Cooked"] = "CookedMeat", ["Source/Processed"] = "Iron", ["Source/Brewed"] = "MeadHealthMinor", ["Source/Foraging"] = "Raspberry", ["Source/Trader"] = "YmirRemains", ["Source/Salvage"] = "MoldSword", ["Source/Loot"] = "Amber", ["Source/Farming"] = "Carrot", ["Source/Boss drop"] = "HardAntler", ["Source/Woodcutting"] = "Wood", ["Source/Mining"] = "CopperOre", ["Source/Fishing"] = "Fish1" }; } internal static class GroupMenu { public enum Tab { Groups, Tags, Ledger } private class RecapClick : MonoBehaviour, IPointerClickHandler, IEventSystemHandler { public void OnPointerClick(PointerEventData e) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) Group sel = Sel; if (sel != null && (int)e.button == 0) { int num = TMP_TextUtilities.FindIntersectingLink(_recap, Vector2.op_Implicit(e.position), e.pressEventCamera); if (num >= 0) { string linkID = ((TMP_LinkInfo)(ref _recap.textInfo.linkInfo[num])).GetLinkID(); sel.Take.Remove(linkID); sel.Only.Remove(linkID); sel.Never.Remove(linkID); Changed(); Refresh(); } } } } [CompilerGenerated] private static class <>O { public static Action <0>__OnNew; public static UnityAction<string> <1>__OnRename; public static Action <2>__AskDelete; public static UnityAction <3>__OnNew; } public static int Revision; public static Tab Current = Tab.Groups; private static RectTransform _root; private static RectTransform _left; private static RectTransform _right; private static RectTransform _body; private static RectTransform _listContent; private static Button _tabGroups; private static Button _tabTags; private static Button _tabLedger; private static Button _newBtn; private static Button _tagsBtn; private static Button _delBtn; private static Button _sortBtn; private static TMP_Text _recap; private static TMP_Text _recapCount; private static TMP_Text _title; private static Image _headerIcon; private static TMP_InputField _name; private static TMP_InputField _search; private static RectTransform _confirm; private static Container _chest; private static int _selected; private static bool _tagsView; private static string _set = "Type"; private static bool _sortAz; private static string _scrollKey; private static float _scrollY; private static InventoryGui _gui; private const float RowH = 40f; private const float PriorityW = 12f; private static RectTransform _dropdown; private static bool _revealSel; public static RectTransform Root => _root; private static List<Group> Groups => WorldStore.Data.Groups; private static Group Sel { get { if (_selected < 0 || _selected >= Groups.Count) { return null; } return Groups[_selected]; } } public static void Build(RectTransform parent, float w, float h, InventoryGui gui) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Expected O, but got Unknown //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Expected O, but got Unknown //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Expected O, but got Unknown //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Expected O, but got Unknown //IL_0445: Unknown result type (might be due to invalid IL or missing references) //IL_0454: Expected O, but got Unknown //IL_046e: Unknown result type (might be due to invalid IL or missing references) //IL_04a7: Unknown result type (might be due to invalid IL or missing references) //IL_04f0: Unknown result type (might be due to invalid IL or missing references) //IL_059b: Unknown result type (might be due to invalid IL or missing references) //IL_05aa: Expected O, but got Unknown //IL_0634: Unknown result type (might be due to invalid IL or missing references) //IL_0643: Expected O, but got Unknown //IL_06b9: Unknown result type (might be due to invalid IL or missing references) _gui = gui; _root = UiKit.Stretch(UiKit.Rect("gl_menu", (Transform)(object)parent, 0f, 0f, w, h)); ((Component)_root).gameObject.SetActive(false); _title = UiKit.Label((Transform)(object)_root, "STORAGE GROUPS", 32f, UiKit.Gold, 206f, 4f, 354f, 38f, (TextAlignmentOptions)514); UiKit.FillW(_title.rectTransform, 10f); if (Object.op_Implicit((Object)(object)gui.m_craftingStationName)) { _title.font = gui.m_craftingStationName.font; _title.fontSharedMaterial = gui.m_craftingStationName.fontSharedMaterial; } Image obj = ((Component)UiKit.FillW(UiKit.Rect("sep", (Transform)(object)_root, 0f, 44f, w, 2f), 0f)).gameObject.AddComponent<Image>(); obj.sprite = UiKit.GameSprite("panel_separator"); ((Graphic)obj).raycastTarget = false; float num = (ChestUi.QuickStack ? 52 : 37); float num2 = (ChestUi.QuickStack ? 72 : 78); _tabGroups = UiKit.Tab((Transform)(object)_root, "GROUPS", num, 12f, num2, 32f, delegate { SetTab(Tab.Groups); }); _tabTags = UiKit.Tab((Transform)(object)_root, "TAGS", num + num2 + 2f, 12f, num2, 32f, delegate { SetTab(Tab.Tags); }); _tabLedger = UiKit.Tab((Transform)(object)_root, "LEDGER", num + 2f * (num2 + 2f), 12f, num2, 32f, delegate { SetTab(Tab.Ledger); }); _left = UiKit.FillH(((Graphic)UiKit.Box((Transform)(object)_root, 10f, 46f, 187f, 284f, UiKit.DimBox, "left")).rectTransform, 10f); _listContent = UiKit.Scroll((Transform)(object)_left, 0f, 4f, 187f, 238f, out var _); UiKit.FillH((RectTransform)((Transform)_listContent).parent.parent, 46f); _newBtn = UiKit.Button((Transform)(object)_left, "New group", 30f, 246f, 127f, 32f, OnNew, 15f); UiKit.PinBottom((RectTransform)((Component)_newBtn).transform, 6f); _right = UiKit.Stretch(UiKit.Rect("right", (Transform)(object)_root, 0f, 0f, w, h)); _headerIcon = UiKit.Icon((Transform)(object)_right, null, 212f, 49f, 42f); _name = UiKit.Input((Transform)(object)_right, 260f, 51f, 190f, 38f, "Name", 18f); UiKit.FillW((RectTransform)((Component)_name).transform, 120f); ((UnityEvent<string>)(object)_name.onEndEdit).AddListener((UnityAction<string>)OnRename); _tagsBtn = UiKit.Button((Transform)(object)_right, "TAGS", 456f, 51f, 62f, 38f, delegate { Orders.CloseEditor(); _tagsView = !_tagsView; Refresh(); }, 13f); UiKit.PinRight((RectTransform)((Component)_tagsBtn).transform, 52f); _delBtn = UiKit.IconButton((Transform)(object)_right, UiKit.GameSprite("x_no"), 522f, 51f, 38f, AskDelete, 0.4f); UiKit.PinRight((RectTransform)((Component)_delBtn).transform, 10f); RectTransform parent2 = UiKit.Fill(((Graphic)UiKit.Box((Transform)(object)_right, 206f, 94f, 354f, 236f, UiKit.DimBox, "desc")).rectTransform, 206f, 94f, 10f, 10f); _recap = UiKit.Label((Transform)(object)parent2, "", 12f, UiKit.Cream, 9f, 7f, 335f, 20f, (TextAlignmentOptions)513); UiKit.FillW(_recap.rectTransform, 80f); _recapCount = UiKit.Label((Transform)(object)parent2, "", 12f, UiKit.Dim, 9f, 7f, 335f, 20f, (TextAlignmentOptions)4100); UiKit.FillW(_recapCount.rectTransform, 10f); _recap.richText = true; ((Graphic)_recap).raycastTarget = true; ((Component)_recap).gameObject.AddComponent<RecapClick>(); KeyHints.Attach(((Component)_recap).gameObject, "LMB:Remove a tag"); _search = UiKit.Input((Transform)(object)parent2, 9f, 31f, 335f, 26f, "Search items or tags...", 14f); UiKit.FillW((RectTransform)((Component)_search).transform, 10f); ((UnityEvent<string>)(object)_search.onValueChanged).AddListener((UnityAction<string>)delegate { FillBody(); }); _sortBtn = UiKit.IconButton(((Component)_search).transform, UiKit.EmbeddedSprite("sort_game"), 309f, 1f, 24f, delegate { _sortAz = !_sortAz; FillBody(); }, 0.8f); UiKit.PinRight((RectTransform)((Component)_sortBtn).transform, 2f); UiKit.Borderless(_sortBtn, _search); _body = UiKit.Fill(UiKit.Rect("body", (Transform)(object)parent2, 9f, 63f, 342f, 166f), 9f, 63f, 3f, 7f); _confirm = UiKit.Center(((Graphic)UiKit.Box((Transform)(object)parent2, 40f, 70f, 274f, 96f, new Color(0f, 0f, 0f, 0.9f), "confirm")).rectTransform); ((Component)_confirm).gameObject.SetActive(false); TagsTab.Build(_root, gui); Ledger.Build(_root); } public static void Show(bool open, Container chest) { if (Object.op_Implicit((Object)(object)_root) && (!open || !((Component)_root).gameObject.activeSelf || !((Object)(object)_chest == (Object)(object)chest))) { ((Component)_root).gameObject.SetActive(open); _chest = chest; Orders.CloseEditor(); if (open) { Refresh(); } } } private static void SetTab(Tab t) { if (t != Tab.Ledger || Plugin.LedgerEnabled.Value) { Orders.CloseEditor(); Current = t; Refresh(); } } public static void Refresh() { //IL_011a: 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_0125: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)_root) || !((Component)_root).gameObject.activeSelf) { return; } if (!Plugin.LedgerEnabled.Value && Current == Tab.Ledger) { Current = Tab.Groups; } ((Component)_tabLedger).gameObject.SetActive(Plugin.LedgerEnabled.Value); UiKit.SetTabSelected(_tabGroups, Current == Tab.Groups); UiKit.SetTabSelected(_tabTags, Current == Tab.Tags); UiKit.SetTabSelected(_tabLedger, Current == Tab.Ledger); bool flag = Current == Tab.Groups; ((Component)_left).gameObject.SetActive(Current != Tab.Ledger); ((Component)_right).gameObject.SetActive(flag); TagsTab.Show(Current == Tab.Tags, _left, _listContent, _newBtn); Ledger.Show(Current == Tab.Ledger); if (flag) { UiKit.SetButtonText(_newBtn, "New group"); UiKit.ResetClick(_newBtn); ButtonClickedEvent onClick = _newBtn.onClick; object obj = <>O.<3>__OnNew; if (obj == null) { UnityAction val = OnNew; <>O.<3>__OnNew = val; obj = (object)val; } ((UnityEvent)onClick).AddListener((UnityAction)obj); FillList(); FillRight(); } } public static void SetRightVisible(bool on) { if (Object.op_Implicit((Object)(object)_right)) { ((Component)_right).gameObject.SetActive(on && Sel != null && Current == Tab.Groups); } } private static void Changed() { WorldStore.Save(); Revision++; ChestUi.Refresh(); } private static void FillList() { //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0255: 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_00d6: 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_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Expected O, but got Unknown UiKit.Clear((Transform)(object)_listContent); float num = 0f; for (int i = 0; i < Groups.Count; i++) { Group obj = Groups[i]; int index = i; GameObject obj2 = UiKit.Row((Transform)(object)_listContent, num, 175f, 40f); Transform val = obj2.transform.Find("icon"); ((Component)val).GetComponent<Image>().sprite = ChestUi.GroupIcon(obj); TMP_Text component = ((Component)obj2.transform.Find("name")).GetComponent<TMP_Text>(); component.text = obj.Name; RectTransform rectTransform = component.rectTransform; rectTransform.anchoredPosition += new Vector2(12f, 7f); Transform obj3 = obj2.transform.Find("QualityLevel"); if (obj3 != null) { ((Component)obj3).gameObject.SetActive(false); } RectTransform val2 = (RectTransform)val; val2.anchoredPosition += new Vector2(12f, 0f); UiKit.Label(obj2.transform, (i + 1).ToString(), 12f, UiKit.Grey, 2f, 0f, 12f, 40f, (TextAlignmentOptions)514); UiKit.Label(obj2.transform, Summary(obj), 10f, UiKit.Dim, 52f, 22f, 118f, 14f, (TextAlignmentOptions)513); Transform obj4 = obj2.transform.Find("selected"); if (obj4 != null) { ((Component)obj4).gameObject.SetActive(i == _selected); } ((UnityEvent)obj2.GetComponent<Button>().onClick).AddListener((UnityAction)delegate { Orders.CloseEditor(); _selected = index; _tagsView = false; Refresh(); }); obj2.AddComponent<RowDrag>().End = delegate(PointerEventData e) { DropRow(index, e); }; KeyHints.Attach(obj2, "Drag:Change priority"); num += 42f; } _listContent.sizeDelta = new Vector2(_listContent.sizeDelta.x, num); if (_revealSel) { _revealSel = false; Rect rect = ((RectTransform)((Transform)_listContent).parent).rect; float height = ((Rect)(ref rect)).height; _listContent.anchoredPosition = new Vector2(_listContent.anchoredPosition.x, Mathf.Max(0f, num - height)); } } private static void DropRow(int from, PointerEventData e) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); RectTransformUtility.ScreenPointToLocalPointInRectangle(_listContent, e.position, e.pressEventCamera, ref val); int num = Mathf.Clamp(Mathf.FloorToInt((0f - val.y) / 42f), 0, Groups.Count - 1); if (num != from) { Group item = Groups[from]; Groups.RemoveAt(from); Groups.Insert(num, item); _selected = num; Changed(); Refresh(); } } public static string Summary(Group g) { List<string> list = new List<string>(); if (g.Take.Count > 0) { list.Add(string.Join(", ", g.Take.Select(Name))); } if (g.Only.Count > 0) { list.Add("only " + string.Join(", ", g.Only.Select(Name))); } if (g.Never.Count > 0) { list.Add("not " + string.Join(", ", g.Never.Select(Name))); } if (list.Count <= 0) { return "no tags"; } return string.Join(" · ", list); static string Name(string id) { Tag value; string text = (TagDb.Tags.TryGetValue(id, out value) ? value.Set : id.Substring(0, id.IndexOf('/'))); object obj; switch (text) { default: obj = text + ": "; break; case "Type": case "Custom": case "Mods": obj = ""; break; } return (string?)obj + TagName(id); } } public static string TagName(string id) { if (!TagDb.Tags.TryGetValue(id, out var value)) { return id.Substring(id.IndexOf('/') + 1); } return value.Name; } private static void OnNew() { int n = 1; while (Groups.Any((Group x) => x.Name == "New group " + n)) { n++; } Groups.Add(new Group { Id = WorldStore.NewId(), Name = "New group " + n }); _selected = Groups.Count - 1; _revealSel = true; _tagsView = true; Changed(); Refresh(); ((Selectable)_name).Select(); _name.ActivateInputField(); } private static void OnRename(string text) { Group sel = Sel; if (sel != null && !string.IsNullOrWhiteSpace(text) && !(text == sel.Name)) { sel.Name = text.Trim(); Changed(); FillList(); } } private static void AskDelete() { //IL_0084: Unknown result type (might be due to invalid IL or missing references) Group g = Sel; if (g != null) { UiKit.Clear((Transform)(object)_confirm); int count = g.Orders.Count; UiKit.Label((Transform)(object)_confirm, "Delete " + g.Name + "?" + ((count > 0) ? string.Format(" ({0} order{1} cancelled)", count, (count == 1) ? "" : "s") : ""), 17f, UiKit.Cream, 0f, 12f, 274f, 26f, (TextAlignmentOptions)514); UiKit.Button((Transform)(object)_confirm, "Delete", 30f, 50f, 100f, 34f, delegate { Groups.Remove(g); Registry.OnGroupDeleted(g.Id); _selected = Mathf.Clamp(_selected, 0, Groups.Count - 1); ((Component)_confirm).gameObject.SetActive(false); Changed(); Refresh(); }, 15f); UiKit.Button((Transform)(object)_confirm, "Cancel", 144f, 50f, 100f, 34f, delegate { ((Component)_confirm).gameObject.SetActive(false); }, 15f); ((Component)_confirm).gameObject.SetActive(true); ((Transform)_confirm).SetAsLastSibling(); } } private static void FillRight() { Group sel = Sel; ((Component)_right).gameObject.SetActive(sel != null && !Orders.EditorOpen); if (sel != null) { _headerIcon.sprite = ChestUi.GroupIcon(sel); if (!_name.isFocused) { _name.text = sel.Name; } ((Component)_search).gameObject.SetActive(!_tagsView); UiKit.Fill(_body, 9f, _tagsView ? 31 : 63, 3f, 7f); _recap.text = RecapText(sel); int num = TagDb.Items.Keys.Count(sel.Accepts); _recapCount.text = num + " item" + ((num == 1) ? "" : "s"); FillBody(); } } private static string Hex(Color c) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return UiKit.Hex(c); } private static string RecapText(Group g) { //IL_00a3: Unknown result type (might be due to invalid IL or missing references) IEnumerable<string> values = g.Take.Select((string t) => Chip(t, UiKit.Green)).Concat(g.Only.Select((string t) => Chip(t, UiKit.Blue))).Concat(g.Never.Select((string t) => Chip(t, UiKit.Red))); string text = string.Join(" ", values); if (text.Length <= 0) { return "<color=#" + Hex(UiKit.Grey) + "><i>No tags</i></color>"; } return text; static string Chip(string id, Color c) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) return "<link=\"" + id + "\"><mark=#00000066><color=#" + Hex(c) + "> " + TagName(id) + " </color></mark></link>"; } } private static void FillBody() { //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_029e: 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_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) UiKit.Clear((Transform)(object)_body); Group g = Sel; if (g == null) { return; } if (_tagsView) { FillTagChecklist(g); return; } UiKit.SetButtonIcon(_sortBtn, UiKit.EmbeddedSprite(_sortAz ? "sort_az" : "sort_game")); UiKit.Tooltip(((Component)_sortBtn).gameObject, _sortAz ? "Sort: A to Z" : "Sort: Game order", ""); Group probe = new Group { Take = g.Take, Only = g.Only, Never = g.Never }; string q = _search.text.Trim(); List<ItemInfo> items = TagDb.Items.Values.Where((ItemInfo i) => probe.Accepts(i.Prefab) && Search.Matches(i.Prefab, q)).ToList(); items = (_sortAz ? items.OrderBy((ItemInfo i) => UiKit.ItemName(i.Prefab)).ToList() : items.OrderBy((ItemInfo i) => i.Order).ToList()); items = items.Where((ItemInfo i) => !g.Barred.Contains(i.Prefab)).Concat(items.Where((ItemInfo i) => g.Barred.Contains(i.Prefab))).ToList(); items = UiKit.StableOrder(items, (ItemInfo i) => i.Prefab, g.Id + "|" + q + "|" + _sortAz); if (items.Count == 0) { UiKit.Label((Transform)(object)_body, (g.Take.Count + g.Only.Count == 0) ? "No tags yet. Press TAGS to add some." : "No items match.", 14f, UiKit.Grey, 4f, 8f, 330f, 20f, (TextAlignmentOptions)513).fontStyle = (FontStyles)2; return; } RectTransform body = _body; Rect rect = _body.rect; float width = ((Rect)(ref rect)).width; rect = _body.rect; ScrollRect scroll; RectTransform content = UiKit.Scroll((Transform)(object)body, 0f, 0f, width, ((Rect)(ref rect)).height, out scroll, cells: true); string text = g.Id + "|items"; float scrollY = ((_scrollKey == text) ? _scrollY : 0f); _scrollKey = text; _scrollY = scrollY; rect = content.rect; float sc = UiKit.CellScale(((Rect)(ref rect)).width, 5); UiKit.LazyGrid(content, scroll, items.Count, UiKit.CellSize * sc, UiKit.CellStep * sc, delegate(float x, float y, int i) { string prefab = items[i].Prefab; UiKit.Cell cell = UiKit.MakeCell((Transform)(object)content, x, y, sc); if (Object.op_Implicit((Object)(object)cell.Icon)) { cell.Icon.sprite = UiKit.ItemIcon(prefab); } bool flag = g.Barred.Contains(prefab); if (flag) { UiKit.Icon((Transform)(object)cell.Rt, UiKit.Cross(), 6f, 6f, cell.Size - 12f); } UiKit.Tooltip(cell.Go, UiKit.ItemName(prefab), UiKit.ItemTooltip(prefab, items[i].Drop.m_itemData)); Orders.DecorateGroupCell(cell, g, prefab); if (Object.op_Implicit((Object)(object)cell.Input)) { cell.Input.m_onLeftDown = delegate { if (UiKit.ShiftHeld) { if (g.Barred.Contains(prefab)) { return; } g.Last = prefab; } else if (g.Barred.Contains(prefab)) { g.Barred.Remove(prefab); g.Last = prefab; } else { g.Barred.Add(prefab); } Changed(); FillRight(); }; } KeyHints.Attach(cell.Go, flag ? "LMB:Allow in this group" : "LMB:Bar from this group;Shift+LMB:Use as icon"); }, scrollY, delegate(float y) { _scrollY = y; }); } private static void FillTagChecklist(Group g) { //IL_0026: 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) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: 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_036b: Unknown result type (might be due to invalid IL or missing references) RectTransform body = _body; string set = _set; Rect rect = _body.rect; UiKit.Button((Transform)(object)body, set, 0f, 0f, ((Rect)(ref rect)).width - 6f, 28f, delegate { OpenSetDropdown(); }, 15f); RectTransform body2 = _body; rect = _body.rect; float width = ((Rect)(ref rect)).width; rect = _body.rect; ScrollRect scroll; RectTransform val = UiKit.Scroll((Transform)(object)body2, 0f, 32f, width, ((Rect)(ref rect)).height - 32f, out scroll); float num = 0f; Tag value; List<Tag> tags = (from n in TagDb.SetOrder[_set] select (!TagDb.Tags.TryGetValue(_set + "/" + n, out value)) ? null : value into t where t != null && (!t.Misc || t.Items.Count != 0) select t).ToList(); tags.AddRange(TagDb.Tags.Values.Where((Tag t) => !t.Preset && t.Set == _set)); Tag tag = (OneTagPerItem(_set) ? tags.FirstOrDefault((Tag t) => g.Only.Contains(t.Id)) : null); if (_set == "Type") { bool all = tags.All((Tag t) => g.Take.Contains(t.Id)); num = TickRow(val, num, "All", null, all ? "or" : "", "every item", delegate { List<string> list = tags.Select((Tag t) => t.Id).ToList(); g.Only.RemoveAll(list.Contains); g.Never.RemoveAll(list.Contains); if (all) { g.Take.RemoveAll(list.Contains); } else { g.Take.AddRange(list.Where((string id) => !g.Take.Contains(id))); } Changed(); FillRight(); }, "Type: All", "<color=#" + Hex(UiKit.Green) + ">Take</color> every tag in this category.", "LMB:Toggle", legend: false, tag != null); } foreach (Tag item in tags) { string mode = (g.Take.Contains(item.Id) ? "or" : (g.Only.Contains(item.Id) ? "and" : (g.Never.Contains(item.Id) ? "bar" : ""))); Tag tag2 = item; num = TickRow(val, num, item.Name, TagsTab.TagIcon(item), mode, item.Items.Count + " items", delegate { Cycle(g, tag2); Changed(); FillRight(); }, item.Set + ": " + item.Name, Legend.Text(mode), "LMB:Next state", legend: true, tag != null && tag != item); } val.sizeDelta = new Vector2(val.sizeDelta.x, num); } private static bool OneTagPerItem(string set) { switch (set) { default: return set == "Mods"; case "Type": case "Biome": case "Source": return true; } } private static bool Ticked(Group g, string id) { if (!g.Take.Contains(id) && !g.Only.Contains(id)) { return g.Never.Contains(id); } return true; } private static void Cycle(Group g, Tag t) { string id = t.Id; bool flag = g.Take.Remove(id); bool flag2 = g.Only.Remove(id); bool flag3 = g.Never.Remove(id); if (!flag && !flag2 && !flag3) { g.Take.Add(id); string text = TagsTab.TagIconItem(t); if (text == null || !t.Items.Contains(text)) { text = t.Items.FirstOrDefault(); } if (text != null) { g.Last = text; } } else if (flag) { if (OneTagPerItem(t.Set) && TagDb.Tags.Values.Any((Tag o) => o.Set == t.Set && o.Id != id && Ticked(g, o.Id))) { g.Never.Add(id); } else { g.Only.Add(id); } } else if (flag2) { g.Never.Add(id); } } private static float TickRow(RectTransform parent, float y, string name, Sprite icon, string mode, string count, Action onClick, string tipTitle, string tipText, string hint, bool legend = false, bool blocked = false) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) Rect rect = parent.rect; float num = ((Rect)(ref rect)).width - 2f; Image val = UiKit.Box((Transform)(object)parent, 0f, y, num, 30f, new Color(0f, 0f, 0f, 0.2f), "tick"); Button obj = ((Component)val).gameObject.AddComponent<Button>(); UiKit.AddSfx(obj); ((UnityEvent)obj.onClick).AddListener((UnityAction)delegate { onClick(); }); ((Selectable)obj).interactable = !blocked; Legend.Tick(((Component)val).transform, mode, 10f, 7f); float num2 = 34f; if (Object.op_Implicit((Object)(object)icon)) { UiKit.Icon(((Component)val).transform, icon, num2, 3f, 24f); num2 += 32f; } UiKit.Label(((Component)val).transform, name, 15f, (Color)((mode == "") ? UiKit.Dim : ((mode == "bar") ? new Color(0.91f, 0.69f, 0.65f) : Color.white)), num2, 0f, 150f, 30f, (TextAlignmentOptions)4097); UiKit.Label(((Component)val).transform, count, 11f, UiKit.Grey, num - 100f, 0f, 92f, 30f, (TextAlignmentOptions)4100); UiKit.Tooltip(((Component)val).gameObject, tipTitle, tipText); if (legend) { ((Component)val).gameObject.AddComponent<Legend.Marker>().Mode = mode; } KeyHints.Attach(((Component)val).gameObject, blocked ? null : hint); if (blocked) { ((Component)val).gameObject.AddComponent<CanvasGroup>().alpha = 0.4f; } return y + 30f + 2f; } private static void OpenSetDropdown() { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)_dropdown)) { Object.Destroy((Object)(object)((Component)_dropdown).gameObject); _dropdown = null; return; } List<string> list = TagDb.AllSets.Where((string x) => x != _set).ToList(); RectTransform body = _body; Rect rect = _body.rect; _dropdown = ((Graphic)UiKit.Box((Transform)(object)body, 0f, 28f, ((Rect)(ref rect)).width - 6f, list.Count * 26 + 4, new Color(0f, 0f, 0f, 0.95f), "dropdown")).rectTransform; ((Transform)_dropdown).SetAsLastSibling(); for (int num = 0; num < list.Count; num++) { string s = list[num]; RectTransform dropdown = _dropdown; string text = s; float y = 2 + num * 26; rect = _dropdown.rect; UiKit.Button((Transform)(object)dropdown, text, 2f, y, ((Rect)(ref rect)).width - 4f, 24f, delegate { _set = s; _dropdown = null; FillBody(); }, 14f); } } } internal static class GroupOrders { public static string Target(Group g, OrderEntry o) { return g.Id + "@" + o.Anchor; } public static bool IsTarget(string target) { return target?.Contains("@") ?? false; } public static (Group g, OrderEntry o) Find(string target, string item) { int num = target.IndexOf('@'); Group obj = WorldStore.GroupById(target.Substring(0, num)); string anchor = target.Substring(num + 1); OrderEntry item2 = (from x in obj?.Orders where x.Item == item && x.Anchor == anchor orderby x.Keep ? 1 : 0, x.Created select x).FirstOrDefault(); return (g: obj, o: item2); } public static Container Anchor(Group g, OrderEntry o) { Container val = Production.FindChest(o.Anchor ?? ""); if (Object.op_Implicit((Object)(object)val) && Registry.IsManaged(val) && Registry.GroupOf(val) == g) { return val; } val = ((IEnumerable<Container>)Registry.Chests).FirstOrDefault((Func<Container, bool>)((Container x) => Object.op_Implicit((Object)(object)x) && Registry.IsManaged(x) && Registry.GroupOf(x) == g)); if (Object.op_Implicit((Object)(object)val) && ClientWork.IsWorker(val)) { o.Anchor = Production.ChestId(val); WorldStore.Save(); } return val; } public static List<Container> Chests(Group g, Container anchor) { return (from c in Network.ChestsOf(anchor) where Registry.GroupOf(c) == g select c).ToList(); } public static int Count(Group g, Container anchor, string item) { return Chests(g, anchor).Sum((Container c) => (from i in c.GetInventory().GetAllItems() where TagDb.PrefabOf(i) == item select i).Sum((ItemData i) => i.m_stack)); } public static int Room(Group g, Container anchor, string item) { return Chests(g, anchor).Sum((Container c) => OrderData.Room(c, item)); } public static int Have(Group g, OrderEntry o, Container anchor) { if (!o.Keep) { return o.Got; } return Count(g, anchor, o.Item); } public static IEnumerable<(Group g, OrderEntry o)> All() { return WorldStore.Data.Groups.SelectMany((Group g) => g.Orders.Select((OrderEntry o) => (g: g, o: o))).ToList(); } public static void Place(Group g, Container anchor, string item, int want, bool keep) { long created = (Object.op_Implicit((Object)(object)ZNet.instance) ? ZNet.instance.GetTime().Ticks : DateTime.Now.Ticks); string anchor2 = Production.ChestId(anchor); if (keep) { g.Orders.RemoveAll((OrderEntry o) => o.Keep && o.Item == item); } g.Orders.Add(new OrderEntry { Id = Guid.NewGuid().ToString("N"), Item = item, Want = want, Keep = keep, Anchor = anchor2, Created = created }); WorldStore.Save(); } public static void Cancel(Group g, OrderEntry o) { g.Orders.Remove(o); WorldStore.Save(); } } internal static class InputBlock { public class Marker : MonoBehaviour { } [HarmonyPatch(typeof(ZInput), "GetButtonDown")] private static class ButtonDown { private static bool Prefix(ref bool __result) { return Allow(ref __result); } [HarmonyPriority(0)] private static void Postfix(ref bool __result) { KeepBlocked(ref __result); } } [HarmonyPatch(typeof(ZInput), "GetButtonUp")] private static class ButtonUp { private static bool Prefix(ref bool __result) { return Allow(ref __result); } [HarmonyPriority(0)] private static void Postfix(ref bool __result) { KeepBlocked(ref __result); } } [HarmonyPatch(typeof(ZInput), "GetButton")] private static class Button { private static bool Prefix(ref bool __result) { return Allow(ref __result); } [HarmonyPriority(0)] private static void Postfix(ref bool __result) { KeepBlocked(ref __result); } } [HarmonyPatch(typeof(ZInput), "GetKeyDown")] private static class KeyDown { private static bool Prefix(ref bool __result) { return Allow(ref __result); } [HarmonyPriority(0)] private static void Postfix(ref bool __result) { KeepBlocked(ref __result); } } [HarmonyPatch(typeof(ZInput), "GetKey")] private static class Key { private static bool Prefix(ref bool __result) { return Allow(ref __result); } [HarmonyPriority(0)] private static void Postfix(ref bool __result) { KeepBlocked(ref __result); } } [HarmonyPatch(typeof(ZInput), "GetKeyUp")] private static class KeyUp { private static bool Prefix(ref bool __result) { return Allow(ref __result); } [HarmonyPriority(0)] private static void Postfix(ref bool __result) { KeepBlocked(ref __result); } } [HarmonyPatch(typeof(KeyboardShortcut), "IsDown")] private static class ShortcutDown { [HarmonyPriority(0)] private static void Postfix(ref bool __result) { KeepBlocked(ref __result); } } [HarmonyPatch(typeof(KeyboardShortcut), "IsPressed")] private static class ShortcutHeld { [HarmonyPriority(0)] private static void Postfix(ref bool __result) { KeepBlocked(ref __result); } } [HarmonyPatch(typeof(KeyboardShortcut), "IsUp")] private static class ShortcutUp { [HarmonyPriority(0)] private static void Postfix(ref bool __result) { KeepBlocked(ref __result); } } [HarmonyPatch(typeof(TextInput), "IsVisible")] private static class ReportTextEntry { [HarmonyPriority(0)] private static void Postfix(ref bool __result) { if (Typing) { __result = true; } } } [HarmonyPatch(typeof(InventoryGui), "Update")] private static class InventoryKeys { private static bool Prefix() { return !Typing; } } [HarmonyPatch(typeof(GuiInputField), "Update")] private static class NativeFieldInput { private static void Prefix(GuiInputField __instance, out bool __state) { __state = _readingFieldKeys; if (Object.op_Implicit((Object)(object)__instance) && ((TMP_InputField)__instance).isFocused) { _readingFieldKeys = true; } } private static Exception Finalizer(Exception __exception, bool __state) { _readingFieldKeys = __state; return __exception; } } private static bool _readingFieldKeys; public static bool Typing { get { GameObject val = (Object.op_Implicit((Object)(object)EventSystem.current) ? EventSystem.current.currentSelectedGameObject : null); if (!Object.op_Implicit((Object)(object)val)) { return false; } Marker obj = val.GetComponent<Marker>() ?? val.GetComponentInParent<Marker>(); TMP_InputField val2 = val.GetComponent<TMP_InputField>() ?? val.GetComponentInParent<TMP_InputField>(); if (Object.op_Implicit((Object)(object)obj) && Object.op_Implicit((Object)(object)val2)) { return val2.isFocused; } return false; } } private static bool Allow(ref bool result) { if (_readingFieldKeys || !Typing) { return true; } result = false; return false; } private static void KeepBlocked(ref bool result) { if (Typing && !_readingFieldKeys) { result = false; } } } internal static class Ledger { private class CarryWatch : MonoBehaviour { private string _last = ""; private void Update() { Inventory from; int amount; ItemData val = Carried(out from, out amount); string text = ((val == null) ? "" : (TagDb.PrefabOf(val) + "|" + amount)); if (!(text == _last)) { _last = text; if (val == null) { _hover = null; } Refill(); } } } private class HoverTarget : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler { public Group G; public void OnPointerEnter(PointerEventData e) { if (_hover != G) { _hover = G; Refill(); } } public void OnPointerExit(PointerEventData e) { if (!_filling && _hover == G && Object.op_Implicit((Object)(object)this)) { _hover = null; Refill(); } } } private static RectTransform _root; private static RectTransform _body; private static RectTransform _content; private static ScrollRect _scroll; private static float _scrollY; private static TMP_InputField _search; private static Group _pick; private static bool _editing; private static Group _hover; private static bool _filling; private const string NoGroupKey = ""; private static readonly FieldInfo DragItemF = AccessTools.Field(typeof(InventoryGui), "m_dragItem"); private static readonly FieldInfo DragInvF = AccessTools.Field(typeof(InventoryGui), "m_dragInventory"); private static readonly FieldInfo DragAmountF = AccessTools.Field(typeof(InventoryGui), "m_dragAmount"); private static readonly MethodInfo SetupDrag = AccessTools.Method(typeof(InventoryGui), "SetupDragItem", (Type[])null, (Type[])null); private static readonly MethodInfo SplitDialog = AccessTools.Method(typeof(InventoryGui), "ShowSplitDialog", (Type[])null, (Type[])null); private static ItemData Carried(out Inventory from, out int amount) { InventoryGui instance = InventoryGui.instance; from = (Inventory)(Object.op_Implicit((Object)(object)instance) ? /*isinst with value type is only supported in some contexts*/: null); amount = (Object.op_Implicit((Object)(object)instance) ? ((int)DragAmountF.GetValue(instance)) : 0); if (!Object.op_Implicit((Object)(object)instance)) { return null; } object? value = DragItemF.GetValue(instance); return (ItemData)((value is ItemData) ? value : null); } public static void Build(RectTransform menuRoot) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Expected O, but got Unknown _root = UiKit.Fill(((Graphic)UiKit.Box((Transform)(object)menuRoot, 10f, 46f, 550f, 284f, UiKit.DimBox, "gl_ledger")).rectTransform, 10f, 46f, 10f, 10f); ((Component)_root).gameObject.SetActive(false); ((Component)_root).gameObject.AddComponent<CarryWatch>(); _search = UiKit.Input((Transform)(object)_root, 8f, 8f, 534f, 26f, "Search items or tags...", 14f); UiKit.FillW((RectTransform)((Component)_search).transform, 8f); ((UnityEvent<string>)(object)_search.onValueChanged).AddListener((UnityAction<string>)delegate { Fill(); }); _body = UiKit.Fill(UiKit.Rect("body", (Transform)(object)_root, 8f, 40f, 540f, 238f), 8f, 40f, 2f, 6f); } public static void Show(bool on) { if (!Object.op_Implicit((Object)(object)_root)) { return; } on = on && Plugin.LedgerEnabled.Value; if (!on) { _pick = null; if (_editing) { Orders.CloseEditor(); } _editing = false; _hover = null; } ((Component)_root).gameObject.SetActive(on); if (on) { Fill(); } } public static void Refill() { if (Object.op_Implicit((Object)(object)_root) && ((Component)_root).gameObject.activeInHierarchy && !_filling) { Fill(); } } private static Dictionary<string, int> Totals(Container chest, Search.Query q) { Dictionary<string, int> dictionary = new Dictionary<string, int>(); foreach (Container item in Network.ChestsOf(chest)) { foreach (ItemData allItem in item.GetInventory().GetAllItems()) { string text = TagDb.PrefabOf(allItem); if (text != null && (q == null || Search.Matches(text, q))) { dictionary[text] = (dictionary.TryGetValue(text, out var value) ? value : 0) + allItem.m_stack; } } } return dictionary; } private static bool Folded(string key) { return WorldStore.Data.Folded.Contains(key); } private static void ToggleFold(string key) { if (!WorldStore.Data.Folded.Remove(key)) { WorldStore.Data.Folded.Add(key); } WorldStore.Save(); Fill(); } private static void Fill() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Expected O, but got Unknown //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: 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_0302: Expected O, but got Unknown //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) if (_editing) { return; } _filling = true; try { if (Object.op_Implicit((Object)(object)_scroll) && Object.op_Implicit((Object)(object)_content)) { _scrollY = _content.anchoredPosition.y; } Container chest = ChestUi.Chest; if (!Object.op_Implicit((Object)(object)chest)) { return; } ((Component)_search).gameObject.SetActive(true); UiKit.Fill(_body, 8f, 40f, 2f, 6f); if (_pick != null) { ClearBody(); FillPick(chest); return; } Search.Query q = Search.Parse(_search.text); Dictionary<string, int> dictionary = Totals(chest, q); Inventory from; int amount; ItemData val = Carried(out from, out amount); string carried = ((val != null) ? TagDb.PrefabOf(val) : null); Rect rect; if (!Object.op_Implicit((Object)(object)_scroll) || !Object.op_Implicit((Object)(object)_content)) { ClearBody(); RectTransform body = _body; rect = _body.rect; float width = ((Rect)(ref rect)).width; rect = _body.rect; _content = UiKit.Scroll((Transform)(object)body, 0f, 0f, width, ((Rect)(ref rect)).height, out _scroll, cells: true); UiKit.Fill((RectTransform)((Component)_scroll).transform, 0f, 0f, 0f, 0f); } else { UiKit.Clear((Transform)(object)_content); } RectTransform content = _content; float y = 0f; y = Orders.LedgerSection(content, y, q); List<Group> groups = WorldStore.Data.Groups; Dictionary<Group, List<string>> dictionary2 = groups.ToDictionary((Group g) => g, (Group g) => new List<string>()); List<string> list = new List<string>(); foreach (string p in dictionary.Keys.OrderBy((string prefab) => TagDb.Info(prefab)?.Order ?? int.MaxValue)) { Group obj = groups.FirstOrDefault((Group obj2) => obj2.Accepts(p)); ((obj != null) ? dictionary2[obj] : list).Add(p); } List<Container> net = Network.ChestsOf(chest); foreach (Group item in groups) { y = Section(content, y, item, dictionary2[item], dictionary, net, chest, carried, amount); } if (list.Count > 0) { y = Section(content, y, null, list, dictionary, net, chest, carried, amount); } content.sizeDelta = new Vector2(content.sizeDelta.x, y); LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform)((Component)_scroll).transform); float x = content.anchoredPosition.x; float scrollY = _scrollY; rect = content.rect; float height = ((Rect)(ref rect)).height; rect = _scroll.viewport.rect; content.anchoredPosition = new Vector2(x, Mathf.Clamp(scrollY, 0f, Mathf.Max(0f, height - ((Rect)(ref rect)).height))); _scroll.Rebuild((CanvasUpdate)2); } finally { _filling = false; } } private static void ClearBody() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)_scroll) && Object.op_Implicit((Object)(object)_content)) { _scrollY = _content.anchoredPosition.y; } _scroll = null; _content = null; UiKit.Clear((Transform)(object)_body); } private static float Section(RectTransform parent, float y, Group g, List<string> items, Dictionary<string, int> totals, List<Container> net, Container open, string carried, int carriedAmount) { //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: 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_0249: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: 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_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0380: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Expected O, but got Unknown //IL_043f: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Expected O, but got Unknown //IL_05c3: Unknown result type (might be due to invalid IL or missing references) List<Container> source = ((g != null) ? net.Where((Container c) => Registry.GroupOf(c) == g).ToList() : new List<Container>()); int num = source.Sum((Container c) => c.GetInventory().GetWidth() * c.GetInventory().GetHeight()); int num2 = source.Sum((Container c) => c.GetInventory().GetAllItems().Count); bool full = g != null && num2 >= num; bool dim = carried != null && (g == null || !g.TagsAccept(carried)); int room = ((carried != null && g != null && !dim) ? GroupOrders.Room(g, open, carried) : 0); bool flag = carried != null && !dim && room == 0; bool flag2 = carried != null && !dim && _hover == g && g != null; bool flag3 = Folded(g?.Id ?? "") && !flag2; Rect rect = parent.rect; float width = ((Rect)(ref rect)).width; Image val = UiKit.Box((Transform)(object)parent, 0f, y, width, 26f, new Color(0f, 0f, 0f, 0.001f), "lhead"); Button val2 = ((Component)val).gameObject.AddComponent<Button>(); UiKit.AddSfx(val2); Image val3 = UiKit.Icon(((Component)val).transform, (g != null) ? ChestUi.GroupIcon(g) : UiKit.ChestIcon(), 0f, 3f, 20f); TMP_Text val4 = UiKit.Label(((Component)val).transform, (g != null) ? g.Name : "No group", 15f, UiKit.Gold, 26f, 0f, width - 140f, 26f, (TextAlignmentOptions)4097, bold: true); TMP_Text val5 = UiKit.Label(((Component)val).transform, (g != null) ? $"<mspace=0.55em>{num2}/{num}</mspace>" : "", 13f, (full || flag) ? UiKit.Red : UiKit.Grey, width - 8f - 15f - 10f - 64f, 0f, 64f, 26f, (TextAlignmentOptions)4100); val5.richText = true; Image val6 = UiKit.Icon(((Component)val).transform, UiKit.EmbeddedSprite("fold_arrow"), width - 8f - 15f, 5.5f, 15f); ((Graphic)val6).rectTransform.pivot = new Vector2(0.5f, 0.5f); ((Graphic)val6).rectTransform.anchoredPosition = new Vector2(width - 8f - 7.5f, -13f); if (!flag3) { ((Transform)((Graphic)val6).rectTransform).localEulerAngles = new Vector3(0f, 0f, -90f); } if (dim) { ((Graphic)val4).color = UiKit.Grey; ((Graphic)val5).color = UiKit.Grey; ((Graphic)val3).color = UiKit.Unavailable; ((Graphic)val6).color = UiKit.Grey; ((Selectable)val2).interactable = false; } string key = g?.Id ?? ""; if (carried == null) { ((UnityEvent)val2.onClick).AddListener((UnityAction)delegate { ToggleFold(key); }); KeyHints.Attach(((Component)val).gameObject, flag3 ? "LMB:Unfold" : "LMB:Fold"); } else if (!dim) { ((UnityEvent)val2.onClick).AddListener((UnityAction)delegate { DropInto(g, open); }); KeyHints.Attach(((Component)val).gameObject, "LMB:Put in " + g.Name + ";RMB:Cancel"); ((Component)val).gameObject.AddComponent<HoverTarget>().G = g; } y += 28f; if (flag3) { return y; } List<(string prefab, bool orderSlot, bool ghost)> cells = new List<(string, bool, bool)>(); if (g != null && (WorldSync.OrdersEnabled || WorldSync.KeepInStockEnabled)) { cells.Add((null, true, false)); } foreach (string item in items) { cells.Add((item, false, false)); } string plusOn = null; if (flag2) { if (items.Contains(carried) && room > 0) { plusOn = carried; } else { int order = TagDb.Info(carried)?.Order ?? int.MaxValue; int num3 = cells.FindIndex(((string prefab, bool orderSlot, bool ghost) c) => !c.orderSlot && (TagDb.Info(c.prefab)?.Order ?? int.MaxValue) > order); cells.Insert((num3 < 0) ? cells.Count : num3, (carried, false, true)); } } if (cells.Count == 0) { UiKit.Label((Transform)(object)parent, "Nothing stored", 12f, UiKit.Grey, 4f, y - 2f, 300f, 18f, (TextAlignmentOptions)513).fontStyle = (FontStyles)2; return y + 20f; } return UiKit.CellGrid(parent, y, cells.Count, delegate(UiKit.Cell cell, int i) { //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) var (p, flag4, flag5) = cells[i]; if (flag4) { OrderSlot(cell, g, full, dim); } else { if (Object.op_Implicit((Object)(object)cell.Icon)) { cell.Icon.sprite = UiKit.ItemIcon(p); } if (flag5) { if (Object.op_Implicit((Object)(object)cell.Icon)) { ((Graphic)cell.Icon).color = new Color(1f, 1f, 1f, 0.45f); } UiKit.CellCount(cell, Mathf.Min(carriedAmount, room).ToString(), UiKit.Green); } else { int value; int num4 = (totals.TryGetValue(p, out value) ? value : 0); if (p == plusOn) { UiKit.CellCount(cell, "+" + Mathf.Min(carriedAmount, room), UiKit.Green); } else { UiKit.CellCount(cell, num4.ToString(), Color.white); } if (dim && Object.op_Implicit((Object)(object)cell.Icon)) { ((Graphic)cell.Icon).color = UiKit.Unavailable; } ItemInfo itemInfo = TagDb.Info(p); if (Object.op_Implicit((Object)(object)itemInfo?.Drop)) { UiKit.Tooltip(cell.Go, UiKit.ItemName(p), itemInfo.Drop.m_itemData.GetTooltip(num4)); } if (carried == null && Object.op_Implicit((Object)(object)cell.Input)) { cell.Input.m_onLeftDown = delegate { PickUp(p, open); }; KeyHints.Attach(cell.Go, "LMB:Pick up;Shift+LMB:Pick up some"); } } } }); } private static void OrderSlot(UiKit.Cell cell, Group g, bool full, bool dim) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)cell.Icon)) { ((Behaviour)cell.Icon).enabled = false; } bool flag = full || dim; UiKit.Label((Transform)(object)cell.Rt, "+", 26f, flag ? UiKit.Grey : UiKit.Amber, 0f, 4f, cell.Size, 30f, (TextAlignmentOptions)514, bold: true); UiKit.Label((Transform)(object)cell.Rt, "Order", 12f, flag ? UiKit.Grey : UiKit.Cream, 0f, cell.Size - 24f, cell.Size, 18f, (TextAlignmentOptions)514); if (flag) { return; } if (Object.op_Implicit((Object)(object)cell.Input)) { cell.Input.m_onLeftDown = delegate { _pick = g; _search.text = ""; Fill(); }; } KeyHints.Attach(cell.Go, "LMB:Order for " + g.Name); } private static void PickUp(string prefab, Container open) { InventoryGui instance = InventoryGui.instance; if (!Object.op_Implicit((Object)(object)instance)) { return; } ItemData val = null; Inventory val2 = null; foreach (Container item in Network.ChestsOf(open)) { foreach (ItemData allItem in item.GetInventory().GetAllItems()) { if (TagDb.PrefabOf(allItem) == prefab && (val == null || allItem.m_stack > val.m_stack)) { val = allItem; val2 = item.GetInventory(); } } } if (val != null) { if (UiKit.ShiftHeld && val.m_stack > 1) { SplitDialog.Invoke(instance, new object[2] { val, val2 }); } else { SetupDrag.Invoke(instance, new object[3] { val, val2, val.m_stack }); } } } private static void DropInto(Group g, Container open) { InventoryGui instance = InventoryGui.instance; Inventory from; int amount; ItemData val = Carried(out from, out amount); if (val == null || from == null || g == null) { return; } string prefab = TagDb.PrefabOf(val); if (!g.TagsAccept(prefab)) { return; } int num = GroupOrders.Room(g, open, prefab); if (num <= 0) { MessageHud instance2 = MessageHud.instance; if (instance2 != null) { instance2.ShowMessage((MessageType)2, g.Name + " is full", 0, (Sprite)null, false, true); } return; } List<Group> groups = WorldStore.Data.Groups; g.Barred.Remove(prefab); foreach (Group item in groups.TakeWhile((Group x) => x != g)) { if (item.TagsAccept(prefab) && !item.Barred.Contains(prefab)) { item.Barred.Add(prefab); } } WorldStore.Save(); GroupMenu.Revision++; int num2 = Mathf.Min(amount, num); int num3 = 0; foreach (Container item2 in GroupOrders.Chests(g, open)) { Inventory inventory = item2.GetInventory(); foreach (ItemData item3 in (from i in inventory.GetAllItems() where TagDb.PrefabOf(i) == prefab && i.m_stack < i.m_shared.m_maxStackSize select i).ToList()) { if (num3 >= num2 || val.m_stack <= 0) { break; } int num4 = Mathf.Min(num2 - num3, item3.m_shared.m_maxStackSize - item3.m_stack); int stack = val.m_stack; inventory.MoveItemToThis(from, val, num4, item3.m_gridPos.x, item3.m_gridPos.y); num3 += stack - val.m_stack; } for (int num5 = 0; num5 < inventory.GetHeight(); num5++) { if (num3 >= num2) { break; } if (val.m_stack <= 0) { break; } for (int num6 = 0; num6 < inventory.GetWidth(); num6++) { if (num3 >= num2) { break; } if (val.m_stack <= 0) { break; } if (inventory.GetItemAt(num6, num5) == null) { int stack2 = val.m_stack; inventory.MoveItemToThis(from, val, Mathf.Min(num2 - num3, val.m_shared.m_maxStackSize), num6, num5); num3 += stack2 - val.m_stack; } } } if (num3 >= num2) { break; } } int num7 = amount - num3; if (num7 > 0 && val.m_stack > 0 && from.ContainsItem(val)) { SetupDrag.Invoke(instance, new object[3] { val, from, Mathf.Min(num7, val.m_stack) }); } else { SetupDrag.Invoke(instance, new object[3] { null, null, 1 }); } MessageHud instance3 = MessageHud.instance; if (instance3 != null) { instance3.ShowMessage((MessageType)2, (num7 > 0) ? (num3 + " moved · " + g.Name + " is full") : (UiKit.ItemName(prefab) + " now goes to " + g.Name), 0, (Sprite)null, false, true); } _hover = null; Fill(); } private static void FillPick(Container chest) { //IL_0117: 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_0126: 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) Group g = _pick; float num = TopBar(_body, "Order for " + g.Name, ChestUi.GroupIcon(g), null, delegate { _pick = null; Fill(); }); Search.Query q = Search.Parse(_search.text); Dictionary<string, int> totals = Totals(chest, null); List<ItemInfo> items = (from i in TagDb.Items.Values where g.Accepts(i.Prefab) && Search.Matches(i.Prefab, q) orderby i.Order select i).ToList(); RectTransform val = UiKit.Fill(UiKit.Rect("pick", (Transform)(object)_body, 0f, num, 10f, 10f), 0f, num, 0f, 0f); Rect rect = val.rect; float width = ((Rect)(ref rect)).width; rect = val.rect; ScrollRect scroll; RectTransform content = UiKit.Scroll((Transform)(object)val, 0f, 0f, width, ((Rect)(ref rect)).height, out scroll, cells: true); float sc = UiKit.CellScale(330f, 5); UiKit.LazyGrid(content, scroll, items.Count, UiKit.CellSize * sc, UiKit.CellStep * sc, delegate(float x, float y, int n) { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) string p = items[n].Prefab; UiKit.Cell cell = UiKit.MakeCell((Transform)(object)content, x, y, sc); int value; int num2 = (totals.TryGetValue(p, out value) ? value : 0); if (Object.op_Implicit((Object)(object)cell.Icon)) { cell.Icon.sprite = UiKit.ItemIcon(p); if (num2 == 0) { ((Graphic)cell.Icon).color = new Color(1f, 1f, 1f, 0.35f); } } if (num2 > 0) { UiKit.CellCount(cell, num2.ToString(), Color.white); } UiKit.Tooltip(cell.Go, UiKit.ItemName(p), UiKit.ItemTooltip(p, items[n].Drop.m_itemData)); if (Object.op_Implicit((Object)(object)cell.Input)) { cell.Input.m_onLeftDown = delegate { OpenEdit(chest, g, p); }; } KeyHints.Attach(cell.Go, "LMB:Order this"); }); } private static void OpenEdit(Container open, Group g, string prefab) { //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) Container val = (Container)((Registry.GroupOf(open) == g) ? ((object)open) : ((object)((IEnumerable<Container>)Network.ChestsOf(open)).FirstOrDefault((Func<Container, bool>)((Container c) => Registry.GroupOf(c) == g)))); if (!Object.op_Implicit((Object)(object)val)) { MessageHud instance = MessageHud.instance; if (instance != null) { instance.ShowMessage((MessageType)2, "No " + g.Name + " chest here to order into", 0, (Sprite)null, false, true); } return; } ClearBody(); _editing = true; ((Component)_search).gameObject.SetActive(false); UiKit.Fill(_body, 8f, 8f, 2f, 6f); float num = TopBar(_body, "Order for " + g.Name, ChestUi.GroupIcon(g), null, delegate { Orders.CloseEditor(); }); RectTransform val2 = UiKit.Rect("editor", (Transform)(object)_body, 0f, 0f, 354f, 10f); val2.anchorMin = new Vector2(0.5f, 0f); val2.anchorMax = new Vector2(0.5f, 1f); val2.pivot = new Vector2(0.5f, 1f); val2.offsetMin = new Vector2(-177f, 0f); val2.offsetMax = new Vector2(177f, 0f - num); Orders.OpenEditor(g, val, prefab, val2, delegate { _editing = false; Fill(); }); } private static float TopBar(RectTransform parent, string title, Sprite icon, string note, Action back) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) UiKit.Button((Transform)(object)parent, "Back", 0f, 0f, 74f, 30f, delegate { back(); }, 13f); UiKit.Icon((Transform)(object)parent, icon, 84f, 5f, 20f); TMP_Text val = UiKit.Label((Transform)(object)parent, title, 16f, UiKit.Gold, 110f, 0f, 260f, 30f, (TextAlignmentOptions)4097, bold: true); if (note != null) { UiKit.Label((Transform)(object)parent, note, 12f, UiKit.Cream, 110f + val.preferredWidth + 10f, 0f, 240f, 30f, (TextAlignmentOptions)4097); } return 36f; } public static float Header(RectTransform parent, float y, Sprite icon, string title, Action order = null) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) UiKit.Icon((Transform)(object)parent, icon, 0f, y + 3f, 20f); UiKit.Label((Transform)(object)parent, title, 15f, UiKit.Gold, 26f, y, 400f, 26f, (TextAlignmentOptions)4097, bold: true); return y + 28f; } } [HarmonyPatch(typeof(Container), "GetHoverText")] internal static class ChestHoverLabel { private static void Postfix(Container __instance, ref string __result) { if (Plugin.MenuEnabled.Value && Registry.Eligible(__instance) && Registry.IsManaged(__instance) && !string.IsNullOrEmpty(__result)) { Group obj = Registry.GroupOf(__instance); int num = __result.IndexOf('\n'); string text = ((num < 0) ? __result : __result.Substring(0, num)); __result = text + " · " + ((obj != null) ? obj.Name : "No group") + ((num < 0) ? "" : __result.Substring(num)); } } } internal static class Legend { public class Marker : MonoBehaviour { public string Mode; } [HarmonyPatch(typeof(UITooltip), "OnHoverStart")] private static class HoverStart { private static void Postfix(UITooltip __instance) { object? obj = TooltipField?.GetValue(null); GameObject val = (GameObject)((obj is GameObject) ? obj : null); if (!Object.op_Implicit((Object)(object)val)) { return; } Transform obj2 = Utils.FindChild(val.transform, "Text", (IterativeSearchType)0); TMP_Text val2 = ((obj2 != null) ? ((Component)obj2).GetComponent<TMP_Text>() : null); if (Object.op_Implicit((Object)(object)val2)) { Placer component = ((Component)val2).GetComponent<Placer>(); if (Object.op_Implicit((Object)(object)component)) { Object.Destroy((Object)(object)component); } Marker component2 = ((Component)__instance).GetComponent<Marker>(); if (Object.op_Implicit((Object)(object)component2)) { ((Component)val2).gameObject.AddComponent<Placer>().Mode = component2.Mode; } } } } private class Placer : MonoBehaviour { public string Mode; private readonly List<RectTransform> _icons = new List<RectTransform>(); private TMP_Text _text; private void Start() { //IL_0056: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) _text = ((Component)this).GetComponent<TMP_Text>(); string[] modes = Modes; Vector2 val2 = default(Vector2); foreach (string text in modes) { RectTransform val = UiKit.Rect("gl_legend", ((Component)this).transform, 0f, 0f, 16f, 16f); ((Vector2)(ref val2))..ctor(0.5f, 0.5f); val.pivot = val2; Vector2 anchorMin = (val.anchorMax = val2); val.anchorMin = anchorMin; Tick((Transform)(object)val, text, 0f, 0f, 0.9f); CanvasGroup obj = ((Component)val).gameObject.AddComponent<CanvasGroup>(); obj.alpha = ((text == Mode) ? 1f : 0.45f); obj.blocksRaycasts = false; ((Component)val).gameObject.SetActive(false); _icons.Add(val); } } private void LateUpdate() { //IL_0092: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)_text) || _icons.Count == 0) { return; } TMP_TextInfo textInfo = _text.textInfo; List<int> list = new List<int> { 0 }; for (int i = 0; i < textInfo.characterCount; i++) { if (list.Count >= 4) { break; } if (textInfo.characterInfo[i].character == '\n' && i + 1 < textInfo.characterCount) { list.Add(textInfo.characterInfo[i + 1].lineNumber); } } Rect rect = _text.rectTransform.rect; for (int j = 0; j < _icons.Count; j++) { bool flag = j < list.Count && list[j] < textInfo.lineCount; ((Component)_icons[j]).gameObject.SetActive(flag); if (flag) { TMP_LineInfo val = textInfo.lineInfo[list[j]]; float num = (val.ascender + val.descender) / 2f; ((Transform)_icons[j]).localPosition = new Vector3(((Rect)(ref rect)).xMin + 10f, num, 0f); } } } private void OnDestroy() { foreach (RectTransform icon in _icons) { if (Object.op_Implicit((Object)(object)icon)) { Object.Destroy((Object)(object)((Component)icon).gameObject); } } } } public static readonly string[] Modes = new string[4] { "", "or", "and", "bar" }; private const string Faded = "73"; private static readonly FieldInfo TooltipField = AccessTools.Field(typeof(UITooltip), "m_tooltip"); public static string Text(string mode) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) return "<indent=24>" + Row("", "", Color.white, "Not used") + "\n" + Row("or", "Take", UiKit.Green, ": add items with this tag") + "\n" + Row("and", "Only", UiKit.Blue, ": restrict the selection to items with this tag") + "\n" + Row("bar", "Never", UiKit.Red, ": exclude items with this tag") + "</indent>"; string Row(string key, string word, Color c, string rest) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) string text = ((key == mode) ? "FF" : "73"); string text2 = ((word.Length > 0) ? ("<color=#" + UiKit.Hex(c) + text + ">" + word + "</color>") : ""); return "<alpha=#" + text + ">" + text2 + rest + "<alpha=#FF>"; } } public static void Tick(Transform parent, string mode, float x, float y, float scale = 1f) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) UiKit.Icon(parent, UiKit.EmbeddedSprite("checkbox"), x, y, 16f * scale); switch (mode) { case "or": case "and": ((Graphic)UiKit.Icon(parent, UiKit.EmbeddedSprite((mode == "and") ? "check_blue" : "check_yes"), x, y - 2.5f * scale, 20f * scale)).rectTransform.sizeDelta = new Vector2(20f * scale, 19f * scale); break; case "bar": UiKit.Icon(parent, UiKit.Cross(), x - 1f * scale, y - 1f * scale, 18f * scale); break; } } } internal static class ModdedItems { internal class GameUses { public readonly HashSet<string> SmeltIn = new HashSet<string>(); public readonly HashSet<string> SmeltOut = new HashSet<string>(); public readonly HashSet<string> Fuel = new HashSet<string>(); public readonly HashSet<string> FermentIn = new HashSet<string>(); public readonly HashSet<string> CookIn = new HashSet<string>(); public readonly HashSet<string> Planted = new HashSet<string>(); public readonly HashSet<string> Crafted = new HashSet<string>(); public bool WithScene; } public const string OtherMods = "Other mods"; private static string N(Component c) { if (!Object.op_Implicit((Object)(object)c)) { return null; } return ((Object)c.gameObject).name; } private static string N(GameObject g) { if (!Object.op_Implicit((Object)(object)g)) { return null; } return ((Object)g).name; } public static GameUses Read(ObjectDB db) { GameUses gameUses = new GameUses(); foreach (Recipe recipe in db.m_recipes) { if (Object.op_Implicit((Object)(object)recipe) && Object.op_Implicit((Object)(object)recipe.m_item)) { gameUses.Crafted.Add(N((Component)(object)recipe.m_item)); } } ZNetScene instance = ZNetScene.instance; if (!Object.op_Implicit((Object)(object)instance)) { return gameUses; } gameUses.WithScene = true; foreach (GameObject prefab in instance.m_prefabs) { if (!Object.op_Implicit((Object)(object)prefab)) { continue; } Smelter component = prefab.GetComponent<Smelter>(); if (Object.op_Implicit((Object)(object)component)) { if (Object.op_Implicit((Object)(object)component.m_fuelItem)) { gameUses.Fuel.Add(N((Component)(object)component.m_fuelItem)); } foreach (ItemConversion item in component.m_conversion) { if (Object.op_Implicit((Object)(object)item.m_from)) { gameUses.SmeltIn.Add(N((Component)(object)item.m_from)); } if (Object.op_Implicit((Object)(object)item.m_to)) { gameUses.SmeltOut.Add(N((Component)(object)item.m_to)); } } } Fermenter component2 = prefab.GetComponent<Fermenter>(); if (Object.op_Implicit((Object)(object)component2)) { foreach (ItemConversion item2 in component2.m_conversion) { if (Object.op_Implicit((Object)(object)item2.m_from)) { gameUses.FermentIn.Add(N((Component)(object)item2.m_from)); } } } CookingStation component3 = prefab.GetComponent<CookingStation>(); if (Object.op_Implicit((Object)(object)component3)) { foreach (ItemConversion item3 in component3.m_conversion) { if (Object.op_Implicit((Object)(object)item3.m_from)) { gameUses.CookIn.Add(N((Component)(object)item3.m_from)); } } } if (!Object.op_Implicit((Object)(object)prefab.GetComponent<Plant>())) { continue; } Piece component4 = prefab.GetComponent<Piece>(); if (!Object.op_Implicit((Object)(object)component4)) { continue; } Requirement[] resources = component4.m_resources; foreach (Requirement val in resources) { if (Object.op_Implicit((Object)(object)val.m_resItem)) { gameUses.Planted.Add(N((Component)(object)val.m_resItem)); } } } return gameUses; } public static string TypeOf(string prefab, GameUses u) { if (u.Fuel.Contains(prefab)) { return "Coal"; } if (u.SmeltIn.Contains(prefab)) { return "Ores"; } if (u.SmeltOut.Contains(prefab)) { return "Metals"; } if (u.FermentIn.Contains(prefab)) { return "Mead bases"; } if (u.CookIn.Contains(prefab)) { if (!u.Crafted.Contains(prefab)) { return "Raw meat"; } return "Cooking prep"; } if (u.Planted.Contains(prefab)) { return "Seeds"; } return "Misc"; } public static Dictionary<string, string> Owners() { Dictionary<string, string> dictionary = new Dictionary<string, string>(); try { Type type = AccessTools.TypeByName("Jotunn.Managers.ItemManager"); object obj = ((type == null) ? null : AccessTools.Property(type, "Instance")?.GetValue(null)); if (obj == null) { return dictionary; } if (!((AccessTools.Field(type, "Items")?.GetValue(obj) ?? AccessTools.Property(type, "Items")?.GetValue(obj)) is IEnumerable enumerable)) { return dictionary; } foreach (object item in enumerable) { object obj2 = item; PropertyInfo propertyInfo = item?.GetType().GetProperty("Value"); if (propertyInfo != null && item.GetType().Name.StartsWith("KeyValuePair")) { obj2 = propertyInfo.GetValue(item); } if (obj2 != null) { GameObject val = Traverse.Create(