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 Quads Ledger Chest v1.2.1
plugins/LedgerChest.dll
Decompiled 12 hours 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.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using DHack.Shared; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json.Linq; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyMetadata("AI_Assisted_Creation", "This assembly was partially or fully created with the assistance of Generative AI (Claude Code).")] [assembly: AssemblyMetadata("AI_Model_Vendor", "Anthropic")] [assembly: AssemblyMetadata("ClaudeTools.Reload", "world")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("0.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 LedgerChest { internal static class Categories { public const string Weapons = "Weapons"; public const string BowsAmmo = "Bows & Ammo"; public const string Shields = "Shields"; public const string Armor = "Armor & Capes"; public const string Trinkets = "Trinkets & Utility"; public const string Tools = "Tools"; public const string Food = "Food"; public const string Potions = "Potions & Mead"; public const string Fish = "Fish"; public const string Trophies = "Trophies"; public const string Ores = "Ores"; public const string Metals = "Metals"; public const string LegacyOresAndMetals = "Ores & Metals"; public const string Materials = "Materials"; public const string Misc = "Everything else"; public static readonly string[] All = new string[14] { "Weapons", "Bows & Ammo", "Shields", "Armor & Capes", "Trinkets & Utility", "Tools", "Food", "Potions & Mead", "Fish", "Trophies", "Ores", "Metals", "Materials", "Everything else" }; private static readonly HashSet<string> MetalBars = new HashSet<string> { "copper", "tin", "bronze", "iron", "silver", "blackmetal", "flametal" }; private static string Plain(string itemName) { string text = (itemName ?? "").ToLowerInvariant(); if (!text.StartsWith("$item_")) { return text; } return text.Substring(6); } private static bool IsOre(string plain) { if (!plain.EndsWith("ore") || plain.EndsWith("core")) { return plain.EndsWith("scrap"); } return true; } public static string Of(SharedData s) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected I4, but got Unknown ItemType itemType = s.m_itemType; switch (itemType - 1) { case 2: case 13: case 14: case 19: case 21: return "Weapons"; case 3: case 8: case 22: return "Bows & Ammo"; case 4: return "Shields"; case 5: case 6: case 10: case 16: return "Armor & Capes"; case 17: case 23: return "Trinkets & Utility"; case 18: return "Tools"; case 20: return "Fish"; case 12: return "Trophies"; case 1: if (s.m_isDrink || (!(s.m_food > 0f) && !(s.m_foodStamina > 0f) && !(s.m_foodEitr > 0f))) { return "Potions & Mead"; } return "Food"; case 0: { string text = Plain(s.m_name); if (IsOre(text)) { return "Ores"; } if (!MetalBars.Contains(text)) { return "Materials"; } return "Metals"; } default: return "Everything else"; } } } internal static class GameUi { private const string CanvasName = "LedgerChestCanvas"; internal static Func<bool> IsOpen = () => false; internal static TMP_FontAsset Norse; internal static TMP_FontAsset Serif; internal static TMP_FontAsset Sans; private static Image _panel; private static Image _sunken; private static Image _braid; private static Button _button; private static Button _tab; private static GameObject _cell; private static float _cellSpace = 70f; internal static readonly Color Warm = new Color(1f, 0.86f, 0.55f); internal static readonly Color Text = new Color(0.94f, 0.9f, 0.82f); internal static readonly Color Dim = new Color(0.75f, 0.72f, 0.66f); internal static readonly Color Gold = new Color(1f, 0.78f, 0.3f); internal static readonly Color Warn = new Color(1f, 0.55f, 0.35f); internal static readonly Color Good = new Color(0.6f, 0.9f, 0.55f); private static Canvas _canvas; internal static Transform Canvas { get { //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown if ((Object)(object)_canvas != (Object)null) { Match(); return ((Component)_canvas).transform; } InventoryGui instance = InventoryGui.instance; if ((Object)(object)instance == (Object)null) { return null; } foreach (Transform item in (from Transform t in (IEnumerable)((Component)instance).transform.parent where ((Object)t).name == "LedgerChestCanvas" select t).ToList()) { Object.Destroy((Object)(object)((Component)item).gameObject); } Canvas val = ((Component)instance).GetComponentInChildren<Canvas>(true) ?? ((Component)instance).GetComponentInParent<Canvas>(); GameObject val2 = new GameObject("LedgerChestCanvas", new Type[1] { typeof(RectTransform) }); val2.transform.SetParent(((Component)instance).transform.parent, false); _canvas = val2.AddComponent<Canvas>(); _canvas.renderMode = (RenderMode)0; _canvas.sortingOrder = (((Object)(object)val != (Object)null) ? val.sortingOrder : 0) + 5; val2.AddComponent<CanvasScaler>(); val2.AddComponent<GraphicRaycaster>(); Match(); return ((Component)_canvas).transform; } } internal static float CellSpace => _cellSpace; internal static Transform HudRoot { get { if (!((Object)(object)Hud.instance != (Object)null) || !((Object)(object)Hud.instance.m_rootObject != (Object)null)) { return null; } return Hud.instance.m_rootObject.transform; } } private static void Match() { //IL_0054: 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_006c: Unknown result type (might be due to invalid IL or missing references) InventoryGui instance = InventoryGui.instance; CanvasScaler val = (((Object)(object)_canvas != (Object)null) ? ((Component)_canvas).GetComponent<CanvasScaler>() : null); CanvasScaler val2 = (((Object)(object)instance != (Object)null) ? (((Component)instance).GetComponentInChildren<CanvasScaler>(true) ?? ((Component)instance).GetComponentInParent<CanvasScaler>()) : null); if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null)) { val.uiScaleMode = val2.uiScaleMode; val.referenceResolution = val2.referenceResolution; val.screenMatchMode = val2.screenMatchMode; val.matchWidthOrHeight = val2.matchWidthOrHeight; val.scaleFactor = val2.scaleFactor; val.referencePixelsPerUnit = val2.referencePixelsPerUnit; } } internal static void Destroy() { if ((Object)(object)_canvas != (Object)null) { Object.Destroy((Object)(object)((Component)_canvas).gameObject); } _canvas = null; _panel = null; _button = null; _cell = null; IsOpen = () => false; } internal static bool Ready() { if ((Object)(object)_button != (Object)null && (Object)(object)_panel != (Object)null && (Object)(object)_cell != (Object)null) { return true; } InventoryGui instance = InventoryGui.instance; if ((Object)(object)instance == (Object)null) { return false; } Transform root = ((Component)instance).transform; _panel = Find<Image>("root/Crafting/Bkg") ?? Find<Image>("root/Player/Bkg"); _sunken = Find<Image>("root/Player/sunken"); _braid = Find<Image>("root/Crafting/BraidLineHorisontalMedium"); _button = Find<Button>("root/Player/Container/TakeAll"); _tab = Find<Button>("root/Crafting/TabsButtons/Craft"); TMP_Text obj = Find<TMP_Text>("root/Crafting/topic"); Norse = ((obj != null) ? obj.font : null); TMP_Text obj2 = Find<TMP_Text>("root/Crafting/TabsButtons/Craft/Text"); Serif = ((obj2 != null) ? obj2.font : null); TMP_Text obj3 = Find<TMP_Text>("root/Crafting/Decription/Description"); Sans = ((obj3 != null) ? obj3.font : null) ?? Serif; InventoryGrid playerGrid = instance.m_playerGrid; if ((Object)(object)playerGrid != (Object)null) { _cell = playerGrid.m_elementPrefab; _cellSpace = ((playerGrid.m_elementSpace > 1f) ? playerGrid.m_elementSpace : 70f); } if ((Object)(object)_button == (Object)null || (Object)(object)_panel == (Object)null || (Object)(object)_cell == (Object)null) { Debug.LogWarning((object)"LedgerChestCanvas: the game's interface was not found where expected (a game update moved it?)"); } if ((Object)(object)_button != (Object)null && (Object)(object)_panel != (Object)null) { return (Object)(object)_cell != (Object)null; } return false; T Find<T>(string path) where T : Component { Transform val = root.Find(path); if (!((Object)(object)val != (Object)null)) { return default(T); } return ((Component)val).GetComponent<T>(); } } internal static RectTransform Rect(Transform parent, string name, Vector2 anchor, Vector2 pivot, Vector2 pos, Vector2 size) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) }); RectTransform val2 = (RectTransform)val.transform; ((Transform)val2).SetParent(parent, false); Vector2 anchorMin = (val2.anchorMax = anchor); val2.anchorMin = anchorMin; val2.pivot = pivot; val2.anchoredPosition = pos; val2.sizeDelta = size; return val2; } internal static RectTransform Window(string name, Vector2 size) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) RectTransform val = Rect(Canvas, name, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, size); Copy(_panel, ((Component)val).gameObject.AddComponent<Image>()); return val; } internal static RectTransform Box(Transform parent, Vector2 pos, Vector2 size) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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) RectTransform val = Rect(parent, "Box", new Vector2(0f, 1f), new Vector2(0f, 1f), pos, size); Image val2 = ((Component)val).gameObject.AddComponent<Image>(); if ((Object)(object)_sunken != (Object)null) { Copy(_sunken, val2); } else { ((Graphic)val2).color = new Color(0f, 0f, 0f, 0.35f); } return val; } internal static RectTransform Board(Transform parent, string name, Vector2 pos, Vector2 size) { //IL_000c: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) RectTransform val = Rect(parent, name, new Vector2(0f, 1f), new Vector2(0f, 1f), pos, size); Copy(_panel, ((Component)val).gameObject.AddComponent<Image>()); return val; } internal static TMP_InputField TextField(Transform parent, Vector2 pos, Vector2 size, string placeholder, int limit, float fontSize = 17f) { //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Expected O, but got Unknown //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Expected O, but got Unknown //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Expected O, but got Unknown //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Expected O, but got Unknown //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Expected O, but got Unknown //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Expected O, but got Unknown //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Expected O, but got Unknown //IL_03d8: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0291: 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_02c7: 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_0326: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_04ab: Unknown result type (might be due to invalid IL or missing references) //IL_04b8: Unknown result type (might be due to invalid IL or missing references) //IL_04be: Unknown result type (might be due to invalid IL or missing references) TMP_InputField val = (((Object)(object)TextInput.instance != (Object)null && (Object)(object)TextInput.instance.m_panel != (Object)null) ? TextInput.instance.m_panel.GetComponentInChildren<TMP_InputField>(true) : null); TMP_InputField val5; RectTransform area; if ((Object)(object)val != (Object)null) { GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject, parent, false); val2.SetActive(true); foreach (Transform item in ((IEnumerable)val2.transform).Cast<Transform>().ToList()) { if (((Object)item).name.StartsWith("gamepad_hint")) { Object.Destroy((Object)(object)((Component)item).gameObject); } } UIGamePad[] componentsInChildren = val2.GetComponentsInChildren<UIGamePad>(true); foreach (UIGamePad val3 in componentsInChildren) { Object.Destroy((Object)(object)val3); } ContentSizeFitter[] components = val2.GetComponents<ContentSizeFitter>(); foreach (ContentSizeFitter val4 in components) { Object.Destroy((Object)(object)val4); } val5 = val2.GetComponent<TMP_InputField>(); FieldInfo[] fields = ((object)val5).GetType().GetFields(BindingFlags.Instance | BindingFlags.Public); foreach (FieldInfo fieldInfo in fields) { if (typeof(UnityEventBase).IsAssignableFrom(fieldInfo.FieldType) && fieldInfo.DeclaringType != typeof(TMP_InputField) && !fieldInfo.FieldType.IsAbstract) { try { fieldInfo.SetValue(val5, Activator.CreateInstance(fieldInfo.FieldType)); } catch (Exception) { } } } val5.onValueChanged = new OnChangeEvent(); val5.onEndEdit = new SubmitEvent(); val5.onSubmit = new SubmitEvent(); val5.onSelect = new SelectionEvent(); val5.onDeselect = new SelectionEvent(); } else { GameObject val6 = new GameObject("TextField", new Type[1] { typeof(RectTransform) }); val6.SetActive(false); val6.transform.SetParent(parent, false); Image val7 = val6.AddComponent<Image>(); if ((Object)(object)_sunken != (Object)null) { Copy(_sunken, val7); } else { ((Graphic)val7).color = new Color(0f, 0f, 0f, 0.5f); } area = Rect(val6.transform, "Text Area", Vector2.zero, new Vector2(0.5f, 0.5f), Vector2.zero, Vector2.zero); area.anchorMin = Vector2.zero; area.anchorMax = Vector2.one; area.offsetMin = new Vector2(10f, 2f); area.offsetMax = new Vector2(-10f, -2f); ((Component)area).gameObject.AddComponent<RectMask2D>(); TMP_Text val8 = Line("Placeholder", new Color(Dim.r, Dim.g, Dim.b, 0.6f)); val8.fontStyle = (FontStyles)2; TMP_Text textComponent = Line("Text", Text); val5 = val6.AddComponent<TMP_InputField>(); ((Selectable)val5).targetGraphic = (Graphic)(object)val7; val5.textViewport = area; val5.textComponent = textComponent; val5.placeholder = (Graphic)(object)val8; val5.customCaretColor = true; val5.caretColor = Text; val5.selectionColor = new Color(Gold.r, Gold.g, Gold.b, 0.35f); val6.SetActive(true); } ((Object)((Component)val5).gameObject).name = "TextField"; RectTransform val9 = (RectTransform)((Component)val5).transform; Vector2 val10 = default(Vector2); ((Vector2)(ref val10))..ctor(0f, 1f); val9.anchorMax = val10; val9.anchorMin = val10; val9.pivot = new Vector2(0f, 1f); val9.anchoredPosition = pos; val9.sizeDelta = size; val5.contentType = (ContentType)0; val5.lineType = (LineType)0; val5.characterLimit = limit; val5.richText = false; val5.text = ""; if (!(val5.placeholder is TMP_Text) && (Object)(object)val5.textComponent != (Object)null) { TMP_Text component = Object.Instantiate<GameObject>(((Component)val5.textComponent).gameObject, val5.textComponent.transform.parent, false).GetComponent<TMP_Text>(); ((Object)component).name = "Placeholder"; ((Graphic)component).color = new Color(Dim.r, Dim.g, Dim.b, 0.6f); component.fontStyle = (FontStyles)(component.fontStyle | 2); ((Graphic)component).raycastTarget = false; val5.placeholder = (Graphic)(object)component; } TMP_Text[] array = (TMP_Text[])(object)new TMP_Text[2] { val5.textComponent, (TMP_Text)/*isinst with value type is only supported in some contexts*/ }; foreach (TMP_Text val11 in array) { if (!((Object)(object)val11 == (Object)null)) { val11.enableAutoSizing = false; val11.fontSize = fontSize; val11.enableWordWrapping = false; val11.alignment = (TextAlignmentOptions)513; } } val5.pointSize = fontSize; Graphic placeholder2 = val5.placeholder; TMP_Text val12 = (TMP_Text)(object)((placeholder2 is TMP_Text) ? placeholder2 : null); if (val12 != null) { val12.text = placeholder; } return val5; TMP_Text Line(string name, Color color) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) RectTransform val13 = Rect((Transform)(object)area, name, Vector2.zero, new Vector2(0.5f, 0.5f), Vector2.zero, Vector2.zero); val13.anchorMin = Vector2.zero; val13.anchorMax = Vector2.one; Vector2 offsetMin = (val13.offsetMax = Vector2.zero); val13.offsetMin = offsetMin; TextMeshProUGUI val14 = ((Component)val13).gameObject.AddComponent<TextMeshProUGUI>(); ((TMP_Text)val14).font = Sans; ((Graphic)val14).color = color; return (TMP_Text)(object)val14; } } internal static void Braid(Transform parent, Vector2 pos, float width) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_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_0070: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_braid == (Object)null)) { Vector2 anchor = new Vector2(0.5f, 1f); Vector2 pivot = new Vector2(0.5f, 0.5f); Rect rect = ((Graphic)_braid).rectTransform.rect; float num; if (!(((Rect)(ref rect)).height > 1f)) { num = 16f; } else { rect = ((Graphic)_braid).rectTransform.rect; num = ((Rect)(ref rect)).height; } RectTransform val = Rect(parent, "Braid", anchor, pivot, pos, new Vector2(width, num)); Copy(_braid, ((Component)val).gameObject.AddComponent<Image>()); } } private static void Copy(Image from, Image to) { //IL_0018: 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) if (!((Object)(object)from == (Object)null)) { to.sprite = from.sprite; to.type = from.type; ((Graphic)to).material = ((Graphic)from).material; ((Graphic)to).color = ((Graphic)from).color; to.pixelsPerUnitMultiplier = from.pixelsPerUnitMultiplier; to.fillCenter = from.fillCenter; } } internal static TMP_Text Label(Transform parent, string text, Vector2 pos, Vector2 size, float fontSize, Color color, TMP_FontAsset font = null, TextAlignmentOptions align = (TextAlignmentOptions)257, Vector2? anchor = null) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0063: Unknown result type (might be due to invalid IL or missing references) Vector2 val = (Vector2)(((??)anchor) ?? new Vector2(0f, 1f)); RectTransform val2 = Rect(parent, "Text", val, val, pos, size); TextMeshProUGUI val3 = ((Component)val2).gameObject.AddComponent<TextMeshProUGUI>(); ((TMP_Text)val3).font = font ?? Sans; ((TMP_Text)val3).fontSize = fontSize; ((Graphic)val3).color = color; ((TMP_Text)val3).alignment = align; ((TMP_Text)val3).richText = true; ((TMP_Text)val3).enableWordWrapping = true; ((TMP_Text)val3).overflowMode = (TextOverflowModes)0; ((TMP_Text)val3).text = text; ((Graphic)val3).raycastTarget = false; return (TMP_Text)(object)val3; } internal static Button Button(Transform parent, string text, Vector2 pos, Vector2 size, Action click, bool enabled = true, float fontSize = 18f) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown Button val = Clone(_button, parent, text, pos, size, fontSize); ((Selectable)val).interactable = enabled; ((Graphic)Label(val)).color = (enabled ? Text : Dim); ((UnityEvent)val.onClick).AddListener((UnityAction)delegate { click(); }); return val; } internal static Button Tab(Transform parent, string text, Vector2 pos, Vector2 size, bool chosen, Action click, float fontSize = 18f) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown Button val = Clone(_tab ?? _button, parent, text, pos, size, fontSize); Transform val2 = ((Component)val).transform.Find("Selected"); if ((Object)(object)val2 != (Object)null) { ((Component)val2).gameObject.SetActive(false); } ((Selectable)val).interactable = !chosen; ((Graphic)Label(val)).color = (chosen ? Gold : Text); ((UnityEvent)val.onClick).AddListener((UnityAction)delegate { click(); }); return val; } internal static TMP_Text Label(Button b) { return ((IEnumerable<TMP_Text>)((Component)b).GetComponentsInChildren<TMP_Text>(true)).FirstOrDefault((Func<TMP_Text, bool>)((TMP_Text t) => ((Component)t).gameObject.activeSelf)); } private static Button Clone(Button template, Transform parent, string text, Vector2 pos, Vector2 size, float fontSize) { //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Expected O, but got Unknown //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Expected O, but got Unknown //IL_01f1: 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_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_016d: 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) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate<GameObject>(((Component)template).gameObject, parent, false); ((Object)val).name = "Button"; val.SetActive(true); foreach (Transform item in ((IEnumerable)val.transform).Cast<Transform>().ToList()) { if (((Object)item).name.StartsWith("gamepad_hint")) { Object.Destroy((Object)(object)((Component)item).gameObject); } } UIGamePad[] componentsInChildren = val.GetComponentsInChildren<UIGamePad>(true); foreach (UIGamePad val2 in componentsInChildren) { Object.Destroy((Object)(object)val2); } ButtonTextColor[] componentsInChildren2 = val.GetComponentsInChildren<ButtonTextColor>(true); foreach (ButtonTextColor val3 in componentsInChildren2) { Object.Destroy((Object)(object)val3); } RectTransform val4 = (RectTransform)val.transform; Vector2 val5 = default(Vector2); ((Vector2)(ref val5))..ctor(0f, 1f); val4.anchorMax = val5; val4.anchorMin = val5; val4.pivot = new Vector2(0f, 1f); val4.anchoredPosition = pos; val4.sizeDelta = size; Button component = val.GetComponent<Button>(); component.onClick = new ButtonClickedEvent(); TMP_Text val6 = ((IEnumerable<TMP_Text>)val.GetComponentsInChildren<TMP_Text>(true)).FirstOrDefault((Func<TMP_Text, bool>)((TMP_Text t) => ((Object)t).name == "Text")); if ((Object)(object)val6 == (Object)null) { val6 = Label(val.transform, text, Vector2.zero, size, fontSize, Text, Serif, (TextAlignmentOptions)514, (Vector2?)new Vector2(0.5f, 0.5f)); ((RectTransform)val6.transform).pivot = new Vector2(0.5f, 0.5f); } val6.text = text; val6.fontSize = fontSize; val6.enableAutoSizing = false; val6.enableWordWrapping = false; val6.overflowMode = (TextOverflowModes)1; RectTransform val7 = (RectTransform)val6.transform; val7.anchorMin = Vector2.zero; val7.anchorMax = Vector2.one; val7.offsetMin = new Vector2(4f, 0f); val7.offsetMax = new Vector2(-4f, 0f); val6.alignment = (TextAlignmentOptions)514; TMP_Text[] componentsInChildren3 = val.GetComponentsInChildren<TMP_Text>(true); foreach (TMP_Text val8 in componentsInChildren3) { if ((Object)(object)val8 != (Object)(object)val6) { ((Component)val8).gameObject.SetActive(false); } } return component; } internal static Image Icon(Transform parent, Vector2 pos, Vector2 size, Sprite sprite) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) Image val = ((Component)Rect(parent, "Icon", new Vector2(0f, 1f), new Vector2(0f, 1f), pos, size)).gameObject.AddComponent<Image>(); val.sprite = sprite; val.preserveAspect = true; ((Graphic)val).raycastTarget = false; ((Behaviour)val).enabled = (Object)(object)sprite != (Object)null; return val; } internal static float Chip(Transform parent, Vector2 pos, ItemData item, string amount, float size = 28f, float fontSize = 17f) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) Image val = Icon(parent, pos, new Vector2(size, size), item.GetIcon()); ((Graphic)val).raycastTarget = true; UITooltip val2 = ((!((Object)(object)_cell != (Object)null)) ? null : _cell.GetComponent<InventoryElement>()?.m_tooltip); if ((Object)(object)val2 != (Object)null) { UITooltip val3 = ((Component)val).gameObject.AddComponent<UITooltip>(); val3.m_tooltipPrefab = val2.m_tooltipPrefab; val3.Set(item.m_shared.m_name, item.GetTooltip(-1), (RectTransform)null, default(Vector2)); } TMP_Text val4 = Label(parent, amount, new Vector2(pos.x + size + 3f, pos.y - (size - fontSize * 1.3f) / 2f), new Vector2(80f, size), fontSize, Text, null, (TextAlignmentOptions)257); val4.enableWordWrapping = false; float x = val4.GetPreferredValues(amount, 200f, 0f).x; ((RectTransform)val4.transform).sizeDelta = new Vector2(x + 2f, size); return size + 3f + x + 12f; } internal static RectTransform Bar(Transform parent, Vector2 pos, Vector2 size, float fraction, Color fill, string text, float fontSize = 15f) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) RectTransform val = Box(parent, pos, size); RectTransform val2 = Rect((Transform)(object)val, "Fill", new Vector2(0f, 0f), new Vector2(0f, 0f), new Vector2(2f, 2f), new Vector2(0f, 0f)); val2.anchorMax = new Vector2(0f, 1f); val2.offsetMax = new Vector2(2f + (size.x - 4f) * Mathf.Clamp01(fraction), -2f); Image val3 = ((Component)val2).gameObject.AddComponent<Image>(); ((Graphic)val3).color = new Color(fill.r * 0.8f, fill.g * 0.8f, fill.b * 0.8f, 0.9f); ((Graphic)val3).raycastTarget = false; if (!string.IsNullOrEmpty(text)) { bool[] array = new bool[2] { true, false }; foreach (bool flag in array) { TMP_Text val4 = Label((Transform)(object)val, text, new Vector2(flag ? 1f : 0f, flag ? (-1f) : 0f), size, fontSize, (Color)(flag ? new Color(0f, 0f, 0f, 0.85f) : Color.white), Sans, (TextAlignmentOptions)514); val4.enableWordWrapping = false; } } return val; } internal static InventoryElement Cell(Transform parent, Vector2 pos, ItemData item, string amount, bool selected, Action click) { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate<GameObject>(_cell, parent, false); ((Object)val).name = "Cell"; val.SetActive(true); UIDragHandler[] componentsInChildren = val.GetComponentsInChildren<UIDragHandler>(true); foreach (UIDragHandler val2 in componentsInChildren) { Object.Destroy((Object)(object)val2); } UIGamePad[] componentsInChildren2 = val.GetComponentsInChildren<UIGamePad>(true); foreach (UIGamePad val3 in componentsInChildren2) { Object.Destroy((Object)(object)val3); } RectTransform val4 = (RectTransform)val.transform; Vector2 val5 = default(Vector2); ((Vector2)(ref val5))..ctor(0f, 1f); val4.anchorMax = val5; val4.anchorMin = val5; val4.pivot = new Vector2(0f, 1f); val4.anchoredPosition = pos; InventoryElement component = val.GetComponent<InventoryElement>(); component.Initialize(0, 0); Transform val6 = val.transform.Find("binding"); if ((Object)(object)val6 != (Object)null) { TMP_Text component2 = ((Component)val6).GetComponent<TMP_Text>(); if (component2 != null) { ((Behaviour)component2).enabled = false; } } ((Behaviour)component.m_icon).enabled = true; component.m_icon.sprite = item.GetIcon(); ((Graphic)component.m_icon).color = Color.white; bool flag = item.m_shared.m_useDurability && item.m_durability < item.GetMaxDurability(); ((Component)component.m_durability).gameObject.SetActive(flag); if (flag) { component.m_durability.SetValue(item.GetDurabilityPercentage()); } ((Behaviour)component.m_equiped).enabled = item.m_equipped; ((Behaviour)component.m_queued).enabled = false; ((Behaviour)component.m_noteleport).enabled = false; ((Behaviour)component.m_food).enabled = false; ((Behaviour)component.m_quality).enabled = amount == null && item.m_shared.m_maxQuality > 1; if (((Behaviour)component.m_quality).enabled) { component.m_quality.text = item.m_quality.ToString(); } ((Behaviour)component.m_amount).enabled = amount != null || item.m_shared.m_maxStackSize > 1; component.m_amount.text = amount ?? $"{item.m_stack}/{item.m_shared.m_maxStackSize}"; if ((Object)(object)component.m_selected != (Object)null) { component.m_selected.SetActive(selected); } UITooltip tooltip = component.m_tooltip; string name = item.m_shared.m_name; string tooltip2 = item.GetTooltip(-1); val5 = default(Vector2); tooltip.Set(name, tooltip2, (RectTransform)null, val5); UIInputHandler componentInChildren = val.GetComponentInChildren<UIInputHandler>(true); if ((Object)(object)componentInChildren != (Object)null && click != null) { componentInChildren.m_onLeftClick = delegate { click(); }; } return component; } internal static RectTransform Scroll(RectTransform box, float inset) { //IL_0078: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Expected O, but got Unknown //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0297: 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_02b6: Expected O, but got Unknown InventoryGui gui = InventoryGui.instance; ScrollRect val = (((Object)(object)gui != (Object)null) ? ((IEnumerable<ScrollRect>)((Component)gui).GetComponentsInChildren<ScrollRect>(true)).FirstOrDefault((Func<ScrollRect, bool>)((ScrollRect s) => (Object)(object)s.content == (Object)(object)gui.m_recipeListRoot)) : null); Scrollbar val2 = (((Object)(object)gui != (Object)null) ? gui.m_recipeListScroll : null); float num; if (!((Object)(object)val2 != (Object)null)) { num = 0f; } else { Rect rect = ((RectTransform)((Component)val2).transform).rect; num = Mathf.Max(8f, ((Rect)(ref rect)).width); } float num2 = num; RectTransform val3 = Rect((Transform)(object)box, "View", new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(inset, 0f - inset), box.sizeDelta - new Vector2(inset * 2f + ((num2 > 0f) ? (num2 + 4f) : 0f), inset * 2f)); ((Component)val3).gameObject.AddComponent<RectMask2D>(); Image val4 = ((Component)val3).gameObject.AddComponent<Image>(); ((Graphic)val4).color = Color.clear; RectTransform val5 = Rect((Transform)(object)val3, "Content", new Vector2(0f, 1f), new Vector2(0f, 1f), Vector2.zero, new Vector2(val3.sizeDelta.x, 0f)); ScrollRect val6 = ((Component)val3).gameObject.AddComponent<ScrollRect>(); val6.content = val5; val6.viewport = val3; val6.horizontal = false; val6.movementType = (MovementType)2; val6.scrollSensitivity = (((Object)(object)val != (Object)null && val.scrollSensitivity > 0f) ? val.scrollSensitivity : 300f); val6.inertia = false; if ((Object)(object)val2 != (Object)null) { GameObject val7 = Object.Instantiate<GameObject>(((Component)val2).gameObject, (Transform)(object)box, false); ((Object)val7).name = "Scrollbar"; val7.SetActive(true); UIGamePad[] componentsInChildren = val7.GetComponentsInChildren<UIGamePad>(true); foreach (UIGamePad val8 in componentsInChildren) { Object.Destroy((Object)(object)val8); } RectTransform val9 = (RectTransform)val7.transform; val9.anchorMin = new Vector2(1f, 0f); val9.anchorMax = new Vector2(1f, 1f); val9.pivot = new Vector2(1f, 0.5f); val9.sizeDelta = new Vector2(num2, (0f - inset) * 2f); val9.anchoredPosition = new Vector2((0f - inset) * 0.5f, 0f); Scrollbar component = val7.GetComponent<Scrollbar>(); component.onValueChanged = new ScrollEvent(); val6.verticalScrollbar = component; val6.verticalScrollbarVisibility = (ScrollbarVisibility)1; } return val5; } } [HarmonyPatch(typeof(PlayerController), "TakeInput")] internal static class GameUi_PlayerControllerTakeInput { private static void Postfix(ref bool __result) { if (GameUi.IsOpen()) { __result = false; } } } [HarmonyPatch(typeof(Player), "TakeInput")] internal static class GameUi_PlayerTakeInput { private static void Postfix(ref bool __result) { if (GameUi.IsOpen()) { __result = false; } } } [HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")] internal static class GameUi_UpdateMouseCapture { private static bool Prefix() { if (!GameUi.IsOpen()) { return true; } ZCursor.LockState = (CursorLockMode)0; ZCursor.Show(); return false; } } [HarmonyPatch(typeof(ZInput), "GetMouseScrollWheel")] internal static class GameUi_ScrollWheel { private static void Postfix(ref float __result) { if (GameUi.IsOpen()) { __result = 0f; } } } [HarmonyPatch(typeof(Menu), "Update")] internal static class GameUi_EscapeCloses { internal static Action Close = delegate { }; private static bool Prefix() { if (!GameUi.IsOpen()) { return true; } if (!ZInput.GetKeyDown((KeyCode)27, true) && !ZInput.GetButtonDown("JoyMenu")) { return true; } Close(); return false; } } internal static class Icon { private const int Size = 128; private static readonly MethodInfo LoadImageMethod = Type.GetType("UnityEngine.ImageConversion, UnityEngine.ImageConversionModule")?.GetMethod("LoadImage", new Type[2] { typeof(Texture2D), typeof(byte[]) }); internal static Sprite Make(GameObject prefab) { Sprite val = null; try { val = Render(prefab); } catch (Exception ex) { Debug.LogWarning((object)("[LedgerChest] could not draw the build icon: " + ex.Message)); } if (!((Object)(object)val != (Object)null)) { return FromResource(); } return val; } private static Sprite Render(GameObject prefab) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected O, but got Unknown //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Expected O, but got Unknown //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Expected O, but got Unknown //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) Transform val = prefab.transform.Find("Model"); if ((Object)(object)val == (Object)null) { return null; } GameObject val2 = new GameObject("LedgerChestIconStage"); val2.transform.position = new Vector3(0f, -3000f, 0f); GameObject val3 = Object.Instantiate<GameObject>(((Component)val).gameObject, val2.transform); val3.transform.localPosition = Vector3.zero; val3.transform.localRotation = Quaternion.identity; val3.SetActive(true); Renderer[] componentsInChildren = val3.GetComponentsInChildren<Renderer>(true); foreach (Renderer val4 in componentsInChildren) { val4.enabled = true; } Bounds val5 = default(Bounds); bool flag = false; Renderer[] componentsInChildren2 = val3.GetComponentsInChildren<Renderer>(); foreach (Renderer val6 in componentsInChildren2) { if (!flag) { val5 = val6.bounds; flag = true; } else { ((Bounds)(ref val5)).Encapsulate(val6.bounds); } } if (!flag) { Object.DestroyImmediate((Object)(object)val2); return null; } GameObject val7 = new GameObject("IconCamera"); val7.transform.SetParent(val2.transform, false); Camera val8 = val7.AddComponent<Camera>(); ((Behaviour)val8).enabled = false; val8.clearFlags = (CameraClearFlags)2; val8.backgroundColor = new Color(0f, 0f, 0f, 0f); val8.fieldOfView = 24f; val8.nearClipPlane = 0.1f; val8.farClipPlane = 60f; val8.allowHDR = false; val8.allowMSAA = false; Vector3 val9 = ((Bounds)(ref val5)).extents; float magnitude = ((Vector3)(ref val9)).magnitude; val9 = new Vector3(0.5f, 0.45f, -1f); Vector3 normalized = ((Vector3)(ref val9)).normalized; ((Component)val8).transform.position = ((Bounds)(ref val5)).center + normalized * (magnitude / Mathf.Sin(val8.fieldOfView * 0.5f * ((float)Math.PI / 180f))) * 1.02f; ((Component)val8).transform.LookAt(((Bounds)(ref val5)).center); GameObject val10 = new GameObject("IconLight"); val10.transform.SetParent(val2.transform, false); val10.transform.rotation = Quaternion.Euler(38f, 28f, 0f); Light val11 = val10.AddComponent<Light>(); val11.type = (LightType)1; val11.intensity = 1.25f; val11.shadows = (LightShadows)0; RenderTexture temporary = RenderTexture.GetTemporary(256, 256, 24, (RenderTextureFormat)0); RenderTexture active = RenderTexture.active; Sprite result = null; try { val8.targetTexture = temporary; val8.Render(); RenderTexture.active = temporary; Texture2D val12 = new Texture2D(((Texture)temporary).width, ((Texture)temporary).height, (TextureFormat)4, false); val12.ReadPixels(new Rect(0f, 0f, (float)((Texture)temporary).width, (float)((Texture)temporary).height), 0, 0); val12.Apply(); if (LooksFine(val12)) { result = Sprite.Create(val12, new Rect(0f, 0f, (float)((Texture)val12).width, (float)((Texture)val12).height), new Vector2(0.5f, 0.5f), 100f); } else { Object.Destroy((Object)(object)val12); } } finally { RenderTexture.active = active; val8.targetTexture = null; RenderTexture.ReleaseTemporary(temporary); Object.Destroy((Object)(object)val2); } return result; } private static bool LooksFine(Texture2D tex) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) Color32[] pixels = tex.GetPixels32(); int num = 0; long num2 = 0L; for (int i = 0; i < pixels.Length; i += 7) { Color32 val = pixels[i]; if (val.a > 40) { num++; num2 += val.r + val.g + val.b; } } int num3 = pixels.Length / 7 + 1; if ((float)num > (float)num3 * 0.08f) { return num2 / Math.Max(1, num) > 60; } return false; } private static bool LoadImage(Texture2D tex, byte[] data) { if (LoadImageMethod != null) { return (bool)LoadImageMethod.Invoke(null, new object[2] { tex, data }); } return false; } private static Sprite FromResource() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_006e: 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) Assembly assembly = typeof(Icon).Assembly; using Stream stream = assembly.GetManifestResourceStream("icon.png"); if (stream == null) { return null; } byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); if (!LoadImage(val, array)) { return null; } return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f); } } internal static class Kinds { public const string All = "All"; public const string Wood = "Wood"; public const string Stone = "Stone & minerals"; public const string Metal = "Ores & metals"; public const string Hides = "Hides & cloth"; public const string Drops = "Monster drops"; public const string Valuables = "Valuables"; public const string Meat = "Cooking"; public const string Farming = "Plants & seeds"; public const string Food = "Food"; public const string Potions = "Potions & mead"; public const string Fish = "Fish & bait"; public const string Weapons = "Weapons"; public const string Bows = "Bows & ammo"; public const string Shields = "Shields"; public const string Armor = "Armor & capes"; public const string Trinkets = "Trinkets"; public const string Tools = "Tools"; public const string Trophies = "Trophies"; public const string Smithing = "Moulds & upgrades"; public const string Other = "Everything else"; public static readonly string[] Order = new string[20] { "Wood", "Stone & minerals", "Ores & metals", "Hides & cloth", "Monster drops", "Valuables", "Cooking", "Plants & seeds", "Food", "Potions & mead", "Fish & bait", "Weapons", "Bows & ammo", "Shields", "Armor & capes", "Trinkets", "Tools", "Moulds & upgrades", "Trophies", "Everything else" }; private static readonly Dictionary<string, string> Words = new Dictionary<string, string> { { "All", "$radial_all" }, { "Wood", "$item_wood" }, { "Stone & minerals", "$ledgerchest_kind_stone" }, { "Ores & metals", "$ledgerchest_kind_metal" }, { "Hides & cloth", "$ledgerchest_kind_hides" }, { "Monster drops", "$ledgerchest_kind_drops" }, { "Valuables", "$ledgerchest_kind_valuables" }, { "Cooking", "$ledgerchest_kind_cooking" }, { "Plants & seeds", "$ledgerchest_kind_farming" }, { "Food", "$ledgerchest_kind_food" }, { "Potions & mead", "$ledgerchest_kind_potions" }, { "Fish & bait", "$ledgerchest_kind_fish" }, { "Weapons", "$ledgerchest_kind_weapons" }, { "Bows & ammo", "$ledgerchest_kind_bows" }, { "Shields", "$ledgerchest_kind_shields" }, { "Armor & capes", "$ledgerchest_kind_armor" }, { "Trinkets", "$ledgerchest_kind_trinkets" }, { "Tools", "$ledgerchest_kind_tools" }, { "Trophies", "$inventory_trophies" }, { "Moulds & upgrades", "$ledgerchest_kind_smithing" }, { "Everything else", "$ledgerchest_kind_other" } }; private static readonly Dictionary<string, int> Rank = Order.Select((string k, int i) => new { k, i }).ToDictionary(x => x.k, x => x.i); private static readonly HashSet<string> WoodNames = new HashSet<string> { "wood", "finewood", "roundlog", "elderbark", "yggdrasilwood", "blackwood", "frostwood", "barkabranch" }; private static readonly HashSet<string> StoneNames = new HashSet<string> { "stone", "flint", "obsidian", "crystal", "blackmarble", "grausten", "coal", "sulfurstone", "sulfur", "tar", "sap", "softtissue", "stonerock", "ice" }; private static readonly HashSet<string> MetalNames = new HashSet<string> { "copper", "tin", "bronze", "iron", "silver", "blackmetal", "flametal", "flametalnew", "flametal_old", "bronzenails", "ironnails", "chain", "gold", "ironpit" }; public static string Label(string kind) { if (kind == null || !Words.TryGetValue(kind, out var value)) { return kind; } return Localization.instance.Localize(value); } public static int RankOf(string kind) { if (kind == null || !Rank.TryGetValue(kind, out var value)) { return Order.Length; } return value; } private static string Plain(string itemName) { string text = (itemName ?? "").ToLowerInvariant(); if (!text.StartsWith("$item_")) { return text; } return text.Substring(6); } private static bool Has(string plain, params string[] parts) { return parts.Any(plain.Contains); } public static string Of(SharedData s) { //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Invalid comparison between Unknown and I4 //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Invalid comparison between Unknown and I4 string plain = Plain(s.m_name); if (Has(plain, "bait")) { return "Fish & bait"; } if (Has(plain, "meadbase", "winebase")) { return "Potions & mead"; } switch (Categories.Of(s)) { case "Weapons": if ((int)s.m_itemType != 15) { return "Weapons"; } return "Tools"; case "Bows & Ammo": return "Bows & ammo"; case "Shields": return "Shields"; case "Armor & Capes": return "Armor & capes"; case "Trinkets & Utility": return "Trinkets"; case "Tools": return "Tools"; case "Food": return "Food"; case "Potions & Mead": return "Potions & mead"; case "Fish": return "Fish & bait"; case "Trophies": return "Trophies"; case "Ores": case "Metals": return "Ores & metals"; case "Materials": return Material(s, plain, "Monster drops"); default: return Material(s, plain, ((int)s.m_itemType == 1) ? "Monster drops" : "Everything else"); } } private static string Material(SharedData s, string plain, string none) { if (Has(plain, "mold_", "_gold_uncooked", "upgrader", "smallparts", "staff_", "frostorbs_")) { return "Moulds & upgrades"; } if (Has(plain, "firework", "catapult", "key", "saddle", "hildir", "dragon", "yagluth", "totem")) { return "Everything else"; } if (Has(plain, "feast")) { return "Food"; } if (WoodNames.Contains(plain)) { return "Wood"; } if (StoneNames.Contains(plain)) { return "Stone & minerals"; } if (MetalNames.Contains(plain) || (plain.EndsWith("ore") && !plain.EndsWith("core")) || plain.EndsWith("ore_old") || plain.EndsWith("scrap")) { return "Ores & metals"; } if (s.m_value > 0 || Has(plain, "coins", "amber", "ruby", "pearl", "necklace", "goldnugget", "gemstone", "jewel")) { return "Valuables"; } if (Has(plain, "hide", "pelt", "leather", "fur", "wolfhair", "jute", "linen", "thread")) { return "Hides & cloth"; } if (Has(plain, "meat", "entrails", "flour", "dough", "necktail", "raw", "bloodbag", "uncooked", "spice", "egg", "honey", "asksvintail")) { return "Cooking"; } if (Has(plain, "seed", "cone", "acorn", "sapling", "barley", "flax", "onion", "carrot", "turnip", "dandelion", "thistle", "seaweed")) { return "Plants & seeds"; } return none; } } internal class Ledger { private static readonly FieldRef<InventoryGui, Container> Current = AccessTools.FieldRefAccess<InventoryGui, Container>("m_currentContainer"); private static readonly FieldRef<InventoryGui, GameObject> DragGo = AccessTools.FieldRefAccess<InventoryGui, GameObject>("m_dragGo"); private static readonly FieldRef<InventoryGui, ItemData> DragItem = AccessTools.FieldRefAccess<InventoryGui, ItemData>("m_dragItem"); private static readonly FieldRef<InventoryGui, Inventory> DragInventory = AccessTools.FieldRefAccess<InventoryGui, Inventory>("m_dragInventory"); private static readonly FieldRef<InventoryGui, int> DragAmount = AccessTools.FieldRefAccess<InventoryGui, int>("m_dragAmount"); private static readonly MethodInfo SetupDrag = AccessTools.Method(typeof(InventoryGui), "SetupDragItem", (Type[])null, (Type[])null); private static readonly FieldRef<Inventory, List<ItemData>> Items = AccessTools.FieldRefAccess<Inventory, List<ItemData>>("m_inventory"); private static readonly FieldRef<InventoryGrid, List<InventoryElement>> Elements = AccessTools.FieldRefAccess<InventoryGrid, List<InventoryElement>>("m_elements"); private static readonly MethodInfo Hovered = AccessTools.Method(typeof(InventoryGrid), "GetHoveredElement", (Type[])null, (Type[])null); private const int Width = 8; internal const string DisplayName = "LedgerChest.Ledger"; private static readonly MethodInfo SplitDialog = AccessTools.Method(typeof(InventoryGui), "ShowSplitDialog", (Type[])null, (Type[])null); private static readonly PropertyInfo SplitDropping = AccessTools.Property(typeof(InventoryGui), "IsSplitDropping"); private Line _carry; private Container _open; private List<Container> _chests = new List<Container>(); private List<Line> _lines = new List<Line>(); private readonly List<Line> _shown = new List<Line>(); private readonly Dictionary<string, int> _counts = new Dictionary<string, int>(); private string _search = ""; private string _built; private string _note = ""; private float _noteUntil; private float _nextScan; private float _nextSend; private float _nextError; private bool _dirty = true; private int _order; private string _kind = "All"; private static readonly string[] OrderNames = new string[3] { "ledgerchest_order_kind", "ledgerchest_order_name", "ledgerchest_order_most" }; private GameObject _panel; private InventoryGrid _grid; private TMP_Text _title; private TMP_Text _weight; private Inventory _display; private TMP_InputField _searchField; private Button _sortButton; private RectTransform _below; private TMP_Text _info; private string _chipsShown; private string _infoShown; private float _chipsBottom; private const float BarTop = 9f; private const float BarH = 30f; private const float Edge = 14f; private const float Reserve = 64f; private const float SortW = 100f; private const float ClearW = 64f; private const float Gap = 4f; private const float Pad = 12f; private const float ChipH = 28f; private const float ChipFont = 15f; private const float InfoFont = 15f; public bool Typing { get { if ((Object)(object)_open != (Object)null && (Object)(object)_searchField != (Object)null) { return _searchField.isFocused; } return false; } } public bool IsOpen { get { if ((Object)(object)_open != (Object)null && (Object)(object)_panel != (Object)null) { return _panel.activeSelf; } return false; } } public bool Carrying { get { if ((Object)(object)InventoryGui.instance != (Object)null && (Object)(object)DragGo.Invoke(InventoryGui.instance) != (Object)null) { return IsDisplay(DragInventory.Invoke(InventoryGui.instance)); } return false; } } internal static bool IsDisplay(Inventory inv) { if (inv != null) { return inv.GetName() == "LedgerChest.Ledger"; } return false; } private static Container OpenLedger(InventoryGui gui) { if ((Object)(object)gui == (Object)null || !InventoryGui.IsVisible()) { return null; } Container val = Current.Invoke(gui); if (!((Object)(object)val != (Object)null) || !Plugin.IsLedger((Component)(object)val)) { return null; } return val; } public void Tick() { Container val = OpenLedger(InventoryGui.instance); if ((Object)(object)val != (Object)(object)_open) { _open = val; _search = ""; _built = null; _nextScan = 0f; } if (!((Object)(object)_open == (Object)null) && !((Object)(object)Player.m_localPlayer == (Object)null)) { if (Time.unscaledTime >= _nextSend && _open.GetInventory().NrOfItems() > 0 && (Object)(object)DragGo.Invoke(InventoryGui.instance) == (Object)null) { _nextSend = Time.unscaledTime + 0.15f; Send(); } if (Time.unscaledTime >= _nextScan) { _nextScan = Time.unscaledTime + 0.5f; _chests = Stores.Around(_open, Player.m_localPlayer); _lines = Stores.Lines(_chests); _dirty = true; } } } public void AfterGui(InventoryGui gui) { if ((Object)(object)_open == (Object)null || (Object)(object)gui == (Object)null) { if ((Object)(object)_panel != (Object)null && _panel.activeSelf) { _panel.SetActive(false); } } else { if (!Build(gui)) { return; } ((Component)gui.m_container).gameObject.SetActive(false); if (!_panel.activeSelf) { _panel.SetActive(true); _grid.ResetView(); } _panel.transform.SetAsLastSibling(); if (!Carrying && (_dirty || _built != _search)) { Fill(); } try { _grid.UpdateInventory(_display, (Player)null, (ItemData)null); Amounts(); } catch (Exception arg) { if (Time.unscaledTime >= _nextError) { _nextError = Time.unscaledTime + 10f; Debug.LogWarning((object)string.Format("[{0}] the ledger window: {1}", "LedgerChest", arg)); Diagnose(); } } _title.text = ""; if ((Object)(object)_weight != (Object)null) { _weight.text = $"{_chests.Count}"; } if (!_searchField.isFocused && _searchField.text != _search) { _searchField.text = _search; } Below(); } } public void Close() { if ((Object)(object)_open != (Object)null && (Object)(object)Player.m_localPlayer != (Object)null) { Send(); } _open = null; if ((Object)(object)_panel != (Object)null) { _panel.SetActive(false); } } public void Destroy() { if ((Object)(object)_panel != (Object)null) { Object.Destroy((Object)(object)_panel); } _panel = null; _searchField = null; _sortButton = null; _below = null; _info = null; } private bool Build(InventoryGui gui) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Expected O, but got Unknown //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Expected O, but got Unknown if ((Object)(object)_panel != (Object)null) { return true; } if ((Object)(object)gui.m_container == (Object)null || !GameUi.Ready()) { return false; } foreach (Transform item in ((Transform)gui.m_container).parent) { Transform val = item; if (((Object)val).name == "LedgerChestPanel") { Object.Destroy((Object)(object)((Component)val).gameObject); } } _panel = Object.Instantiate<GameObject>(((Component)gui.m_container).gameObject, ((Transform)gui.m_container).parent); ((Object)_panel).name = "LedgerChestPanel"; _grid = _panel.GetComponentInChildren<InventoryGrid>(true); if ((Object)(object)_grid == (Object)null) { Object.Destroy((Object)(object)_panel); _panel = null; return false; } if ((Object)(object)_grid.m_gridRoot != (Object)null) { foreach (Transform item2 in (Transform)_grid.m_gridRoot) { Transform val2 = item2; Object.Destroy((Object)(object)((Component)val2).gameObject); } } _grid.m_onSelected = OnSelected; _grid.m_onRightClick = OnRightClick; _grid.m_onReleased = delegate { }; _grid.m_onEnter = delegate { }; _grid.OnSetTouchSelection = delegate { }; _grid.CanDropDragOntoItem = (ItemData i) => false; ref TMP_Text title = ref _title; Component obj = Twin((Transform)(object)gui.m_container, _panel.transform, (Component)(object)gui.m_containerName); title = (TMP_Text)(object)((obj is TMP_Text) ? obj : null); ref TMP_Text weight = ref _weight; Component obj2 = Twin((Transform)(object)gui.m_container, _panel.transform, (Component)(object)gui.m_containerWeight); weight = (TMP_Text)(object)((obj2 is TMP_Text) ? obj2 : null); Component[] array = (Component[])(object)new Component[2] { Twin((Transform)(object)gui.m_container, _panel.transform, (Component)(object)gui.m_takeAllButton), Twin((Transform)(object)gui.m_container, _panel.transform, (Component)(object)gui.m_stackAllButton) }; foreach (Component val3 in array) { if ((Object)(object)val3 != (Object)null) { val3.gameObject.SetActive(false); } } _display = new Inventory("LedgerChest.Ledger", (Sprite)null, 8, 4); TitleBar(); _below = null; _chipsShown = (_infoShown = null); return true; } private static void Pin(RectTransform r, Vector2 corner, Vector2 pos) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) Vector2 val = (r.pivot = corner); Vector2 anchorMin = (r.anchorMax = val); r.anchorMin = anchorMin; r.anchoredPosition = pos; Loose((Component)(object)r); } private static void Loose(Component c) { LayoutElement val = c.GetComponent<LayoutElement>(); if ((Object)(object)val == (Object)null) { val = c.gameObject.AddComponent<LayoutElement>(); } val.ignoreLayout = true; } private void TitleBar() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Expected O, but got Unknown //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Expected O, but got Unknown RectTransform parent = (RectTransform)_panel.transform; float num = 236f; _searchField = GameUi.TextField((Transform)(object)parent, new Vector2(14f, -9f), new Vector2(200f, 30f), Translations.T("ledgerchest_search"), 60, 16f); RectTransform val = (RectTransform)((Component)_searchField).transform; val.anchorMax = new Vector2(1f, 1f); val.offsetMin = new Vector2(14f, -39f); val.offsetMax = new Vector2(0f - (14f + num), -9f); Loose((Component)(object)val); ((UnityEvent<string>)(object)_searchField.onValueChanged).AddListener((UnityAction<string>)delegate(string text) { _search = text ?? ""; }); Button val2 = GameUi.Button((Transform)(object)parent, Translations.T("ledgerchest_clear"), Vector2.zero, new Vector2(64f, 30f), delegate { _search = ""; _searchField.text = ""; }, enabled: true, 15f); Shrink(val2); Pin((RectTransform)((Component)val2).transform, new Vector2(1f, 1f), new Vector2(-182f, -9f)); _sortButton = GameUi.Button((Transform)(object)parent, Translations.T(OrderNames[_order]), Vector2.zero, new Vector2(100f, 30f), delegate { _order = (_order + 1) % OrderNames.Length; _dirty = true; GameUi.Label(_sortButton).text = Translations.T(OrderNames[_order]); }, enabled: true, 15f); Shrink(_sortButton); Pin((RectTransform)((Component)_sortButton).transform, new Vector2(1f, 1f), new Vector2(-78f, -9f)); } private static void Shrink(Button b) { TMP_Text val = GameUi.Label(b); if (!((Object)(object)val == (Object)null)) { val.enableAutoSizing = true; val.fontSizeMin = 10f; val.fontSizeMax = val.fontSize; } } private void Below() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp(Plugin.Scale.Value, 0.6f, 2f); Rect rect = ((RectTransform)_panel.transform).rect; float num2 = ((Rect)(ref rect)).width / num; if (!(num2 < 100f)) { List<string> list = new List<string> { "All" }; list.AddRange(Kinds.Order.Where((string k) => k == _kind || (_counts.TryGetValue(k, out var value) && value > 0))); List<string> list2 = list.Select((string k) => $"{Kinds.Label(k)} {(_counts.TryGetValue(k, out value) ? value : 0)}").ToList(); string text = string.Format("{0:0}|{1:0.00}|{2}|{3}", num2, num, _kind, string.Join("|", list2.ToArray())); if ((Object)(object)_below == (Object)null || text != _chipsShown) { _chipsShown = text; _infoShown = null; Chips(list, list2, num2, num); } string text2 = Info(); if (!(text2 == _infoShown)) { _infoShown = text2; float num3 = num2 - 24f; _info.text = text2; float num4 = Mathf.Max(_info.GetPreferredValues(text2, num3, 0f).y, 39f); ((RectTransform)_info.transform).sizeDelta = new Vector2(num3, num4); _below.sizeDelta = new Vector2(num2, _chipsBottom + 6f + num4 + 12f); } } } private void Chips(List<string> kinds, List<string> labels, float width, float scale) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_0082: 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) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Expected O, but got Unknown //IL_018e: 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) if ((Object)(object)_below != (Object)null) { Object.Destroy((Object)(object)((Component)_below).gameObject); } _below = GameUi.Board(_panel.transform, "LedgerChestBelow", Vector2.zero, new Vector2(width, 100f)); Pin(_below, new Vector2(0f, 0f), new Vector2(0f, -4f)); _below.pivot = new Vector2(0f, 1f); ((Transform)_below).localScale = Vector3.one * scale; float num = 12f; float num2 = 12f; for (int i = 0; i < kinds.Count; i++) { string kind = kinds[i]; Button val = GameUi.Tab((Transform)(object)_below, labels[i], Vector2.zero, new Vector2(40f, 28f), kind == _kind, delegate { if (!(kind == _kind)) { _kind = kind; _dirty = true; _grid.ResetView(); } }, 15f); TMP_Text val2 = GameUi.Label(val); val2.fontStyle = (FontStyles)(val2.fontStyle & -57); float num3 = val2.GetPreferredValues(labels[i], 1000f, 0f).x + 22f; if (num + num3 > width - 12f && num > 12f) { num = 12f; num2 += 32f; } RectTransform val3 = (RectTransform)((Component)val).transform; val3.anchoredPosition = new Vector2(num, 0f - num2); val3.sizeDelta = new Vector2(num3, 28f); num += num3 + 4f; } _chipsBottom = num2 + 28f; _info = GameUi.Label((Transform)(object)_below, "", new Vector2(12f, 0f - (_chipsBottom + 6f)), new Vector2(width - 24f, 39f), 15f, GameUi.Text, null, (TextAlignmentOptions)257); } private string Info() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) object? obj = Hovered?.Invoke(_grid, null); InventoryElement val = (InventoryElement)((obj is InventoryElement) ? obj : null); if (val != null && (Object)(object)val != (Object)null) { Line line = LineAt(val.Position); if (line != null) { Vector3 from = ((Component)_open).transform.position; return Translations.T("ledgerchest_in_all", line.Name, line.Total) + " " + string.Join(", ", (from kv in line.Where.Take(4) select Translations.T("ledgerchest_in_chest", kv.Value, Vector3.Distance(((Component)kv.Key).transform.position, @from).ToString("0"))).ToArray()) + ((line.Where.Count > 4) ? (" " + Translations.T("ledgerchest_more_chests", line.Where.Count - 4)) : ""); } } if (Time.unscaledTime < _noteUntil) { return _note; } return Translations.T("ledgerchest_chests_within", _chests.Count, Plugin.Radius.Value.ToString("0")) + " <color=#bdb7a9>· " + Translations.T("ledgerchest_help") + "</color>"; } private static Component Twin(Transform original, Transform copy, Component part) { if ((Object)(object)part == (Object)null) { return null; } List<string> list = new List<string>(); Transform val = part.transform; while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)original) { list.Insert(0, ((Object)val).name); val = val.parent; } Transform val2 = copy.Find(string.Join("/", list.ToArray())); if (!((Object)(object)val2 != (Object)null)) { return null; } return ((Component)val2).GetComponent(((object)part).GetType()); } private void Fill() { //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Expected O, but got Unknown //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) _dirty = false; _built = _search; string[] words = (_search ?? "").Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); IEnumerable<Line> enumerable = _lines.Where((Line l) => words.All((string w) => l.Name.IndexOf(w, StringComparison.OrdinalIgnoreCase) >= 0)); _counts.Clear(); foreach (Line item in enumerable) { _counts[item.Kind] = (_counts.TryGetValue(item.Kind, out var value) ? value : 0) + 1; } _counts["All"] = enumerable.Count(); if (_kind != "All") { enumerable = enumerable.Where((Line l) => l.Kind == _kind); } _shown.Clear(); _shown.AddRange((_order == 2) ? (from l in enumerable orderby l.Total descending, l.Name select l) : ((_order == 1) ? enumerable.OrderBy((Line l) => l.Name) : (from l in enumerable orderby Kinds.RankOf(l.Kind), l.Name select l))); int num = Mathf.Max(4, Mathf.CeilToInt((float)_shown.Count / 8f)); if (_display.GetHeight() != num) { _display = new Inventory("LedgerChest.Ledger", (Sprite)null, 8, num); } List<ItemData> list = Items.Invoke(_display); list.Clear(); for (int num2 = 0; num2 < _shown.Count; num2++) { ItemData val = Sample(_shown[num2]); if (val != null) { ItemData val2 = val.Clone(); val2.m_stack = Mathf.Max(1, _shown[num2].Total); val2.m_equipped = false; val2.m_gridPos = new Vector2i(num2 % 8, num2 / 8); list.Add(val2); } } } private void Diagnose() { //IL_029b: Unknown result type (might be due to invalid IL or missing references) List<InventoryElement> list = Elements.Invoke(_grid); Debug.LogWarning((object)string.Format("[{0}] grid: elements {1}, uiGroup {2}, tooltipAnchor {3}, gridRoot {4}, prefab {5}", "LedgerChest", list?.Count, (Object)(object)_grid.m_uiGroup != (Object)null, (Object)(object)_grid.m_tooltipAnchor != (Object)null, (Object)(object)_grid.m_gridRoot != (Object)null, (Object)(object)_grid.m_elementPrefab != (Object)null)); if (list != null && list.Count > 0) { InventoryElement val = list[1]; Debug.LogWarning((object)string.Format("[{0}] element: icon {1}, durability {2}, equiped {3}, queued {4}, noteleport {5}, food {6}, quality {7}, amount {8}, tooltip {9}, dropFocus {10}, selected {11}", "LedgerChest", (Object)(object)val.m_icon != (Object)null, (Object)(object)val.m_durability != (Object)null, (Object)(object)val.m_equiped != (Object)null, (Object)(object)val.m_queued != (Object)null, (Object)(object)val.m_noteleport != (Object)null, (Object)(object)val.m_food != (Object)null, (Object)(object)val.m_quality != (Object)null, (Object)(object)val.m_amount != (Object)null, (Object)(object)val.m_tooltip != (Object)null, (Object)(object)val.m_dropFocus != (Object)null, (Object)(object)val.m_selected != (Object)null)); } foreach (ItemData item in _display.GetAllItems().Take(4)) { string text = ""; try { item.GetIcon(); } catch { text += " icon"; } try { item.GetMaxDurability(); item.GetDurabilityPercentage(); } catch { text += " durability"; } try { bool flag = !item.m_shared.m_teleportable && !ZoneSystem.instance.GetGlobalKey((GlobalKeys)35); } catch { text += " teleport"; } Debug.LogWarning((object)string.Format("[{0}] item {1} at {2}: {3}", "LedgerChest", Localization.instance.Localize(item.m_shared.m_name), item.m_gridPos, (text.Length == 0) ? "ok" : text)); } } private static ItemData Sample(Line line) { foreach (KeyValuePair<Container, int> item in line.Where) { if (!((Object)(object)item.Key != (Object)null)) { continue; } foreach (ItemData allItem in item.Key.GetInventory().GetAllItems()) { if (allItem.m_shared.m_name + ((allItem.m_shared.m_maxQuality > 1) ? ("#" + allItem.m_quality) : "") == line.Key) { return allItem; } } } return null; } private void Amounts() { List<InventoryElement> list = Elements.Invoke(_grid); if (list == null) { return; } for (int i = 0; i < _shown.Count && i < list.Count; i++) { InventoryElement val = list[i]; if (!((Object)(object)val == (Object)null) && !((Object)(object)val.m_amount == (Object)null)) { int total = _shown[i].Total; ((Behaviour)val.m_amount).enabled = total > 1 || _shown[i].MaxStack > 1; val.m_amount.text = ((total >= 10000) ? $"{(float)total / 1000f:0.#}k" : total.ToString()); } } } private Line LineAt(Vector2i pos) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) int num = pos.y * 8 + pos.x; if (num < 0 || num >= _shown.Count) { return null; } return _shown[num]; } private void OnSelected(InventoryGrid grid, ItemData item, Vector2i pos, Modifier mod) { //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Invalid comparison between Unknown and I4 //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Invalid comparison between Unknown and I4 InventoryGui instance = InventoryGui.instance; Player localPlayer = Player.m_localPlayer; if ((Object)(object)instance == (Object)null || (Object)(object)localPlayer == (Object)null || (Object)(object)_open == (Object)null) { return; } if ((Object)(object)DragGo.Invoke(instance) != (Object)null && IsDisplay(DragInventory.Invoke(instance))) { Drop(); return; } if ((Object)(object)DragGo.Invoke(instance) != (Object)null) { ItemData val = DragItem.Invoke(instance); Inventory val2 = DragInventory.Invoke(instance); if (val != null && val2 != null && (val2 == ((Humanoid)localPlayer).GetInventory() || val2 == _open.GetInventory()) && val2.ContainsItem(val)) { if (((Humanoid)localPlayer).IsItemEquiped(val)) { ((Humanoid)localPlayer).UnequipItem(val, false); } List<string> list = new List<string>(); int num = Mathf.Clamp(DragAmount.Invoke(instance), 1, val.m_stack); int num2 = Stores.Route(_open, localPlayer, val, val2, num, list); Note((num2 > 0) ? (Translations.T("ledgerchest_sent", string.Join(", ", list.Take(3).ToArray())) + ((num2 < num) ? (" " + Translations.T("ledgerchest_no_room_other", num - num2)) : "")) : Translations.T("ledgerchest_no_chest_here")); if (num2 < num) { ((Character)localPlayer).Message((MessageType)2, Translations.T("ledgerchest_no_chest_room", Localization.instance.Localize(val.m_shared.m_name)), 0, (Sprite)null, false); } } SetupDrag.Invoke(instance, new object[3] { null, null, 1 }); _nextScan = 0f; return; } Line line = LineAt(pos); if (line == null || item == null) { return; } if ((int)mod == 2) { Take(line, line.Total, null); return; } _carry = line; if ((int)mod == 1 && line.Total > 1) { SplitDialog.Invoke(instance, new object[2] { item, _display }); } else { SetupDrag.Invoke(instance, new object[3] { item, _display, line.Total }); } } private void OnRightClick(InventoryGrid grid, ItemData item, Vector2i pos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Line line = LineAt(pos); if (line != null && (Object)(object)DragGo.Invoke(InventoryGui.instance) == (Object)null) { Take(line, line.MaxStack, null); } } public void DropOnto(InventoryGrid grid, Vector2i pos) { //IL_0099: Unknown result type (might be due to invalid IL or missing references) InventoryGui instance = InventoryGui.instance; Player localPlayer = Player.m_localPlayer; int num = (((Object)(object)instance != (Object)null) ? DragAmount.Invoke(instance) : 0); Line line = ((_carry == null) ? null : (_lines.FirstOrDefault((Line l) => l.Key == _carry.Key) ?? _carry)); Drop(); if (line != null && !((Object)(object)localPlayer == (Object)null) && num > 0) { if ((Object)(object)grid == (Object)null || grid.GetInventory() != ((Humanoid)localPlayer).GetInventory()) { Note(Translations.T("ledgerchest_take_to_own")); } else { Take(line, num, pos); } } } public void Drop() { if (Carrying) { SetupDrag.Invoke(InventoryGui.instance, new object[3] { null, null, 1 }); } if ((Object)(object)InventoryGui.instance != (Object)null) { SplitDropping?.SetValue(InventoryGui.instance, false); } _carry = null; _dirty = true; } private void Take(Line line, int want, Vector2i? at) { Player localPlayer = Player.m_localPlayer; Inventory inventory = ((Humanoid)localPlayer).GetInventory(); int fromChests; bool busy; Vector2i landed; int num = Stores.Take(line, want, inventory, at, out fromChests, out busy, out landed); Note((num > 0) ? (((fromChests > 1) ? Translations.T("ledgerchest_took_from", num, line.Name, fromChests) : Translations.T("ledgerchest_took", num, line.Name)) + ((num < want) ? (" " + (busy ? Translations.T("ledgerchest_some_busy") : Translations.T("ledgerchest_no_room_other", want - num))) : "")) : (busy ? Translations.T("ledgerchest_busy") : Translations.T("ledgerchest_no_room"))); if (num < want && !busy) { ((Character)localPlayer).Message((MessageType)2, (num > 0) ? Translations.T("ledgerchest_room_only", num) : Translations.T("ledgerchest_no_room_msg"), 0, (Sprite)null, false); } _nextScan = 0f; } private void Send() { List<string> list = new List<string>(); List<string> list2 = new List<string>(); List<string> list3 = Stores.SendOut(_open, Player.m_localPlayer, list, list2); if (list3.Count != 0 || list.Count != 0 || list2.Count != 0) { string text = string.Join(", ", list3.Take(3).ToArray()); Note((((list3.Count > 3) ? (Translations.T("ledgerchest_sent_more", text, list3.Count - 3) + " ") : ((list3.Count > 0) ? (Translations.T("ledgerchest_sent", text) + " ") : "")) + ((list.Count > 0) ? (Translations.T("ledgerchest_back_to_you", string.Join(", ", list.Take(3).ToArray())) + " ") : "") + ((list2.Count > 0) ? Translations.T("ledgerchest_stays", string.Join(", ", list2.Take(3).ToArray())) : "")).TrimEnd(Array.Empty<char>())); if (list2.Count > 0) { ((Character)Player.m_localPlayer).Message((MessageType)2, Translations.T("ledgerchest_stays_msg", string.Join(", ", list2.Take(2).ToArray())), 0, (Sprite)null, false); } else if (list.Count > 0) { ((Character)Player.m_localPlayer).Message((MessageType)2, Translations.T("ledgerchest_no_chest_room", string.Join(", ", list.Take(2).ToArray())), 0, (Sprite)null, false); } _nextScan = 0f; } } private void Note(string text) { _note = text; _noteUntil = Time.unscaledTime + 6f; Debug.Log((object)("[LedgerChest] " + text)); } } public static class Window { public static bool IsOpen { get { if ((Object)(object)Plugin.Instance != (Object)null) { return Plugin.Instance.Ledger.IsOpen; } return false; } } public static void Close() { if (IsOpen && (Object)(object)InventoryGui.instance != (Object)null) { InventoryGui.instance.Hide(); } } } [HarmonyPatch(typeof(InventoryGui), "Update")] internal static class InventoryGui_Update_Ledger { private static void Postfix(InventoryGui __instance) { Plugin.Instance?.Ledger.AfterGui(__instance); } } [HarmonyPatch(typeof(InventoryGui), "Hide")] internal static class InventoryGui_Hide { private static void Postfix() { Plugin.Instance?.Ledger.Close(); } } [HarmonyPatch(typeof(InventoryGui), "OnSelectedItem")] internal static class InventoryGui_OnSelectedItem_Ledger { private static bool Prefix(InventoryGrid grid, Vector2i pos) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) InventoryGui instance = InventoryGui.instance; if ((Object)(object)instance == (Object)null || !Ledger.IsDisplay(AccessTools.FieldRefAccess<InventoryGui, Inventory>(instance, "m_dragInventory"))) { return true; } Plugin.Instance?.Ledger.DropOnto(grid, pos); return false; } } [HarmonyPatch(typeof(InventoryGrid), "DropItem")] internal static class InventoryGrid_DropItem_Ledger { private static bool Prefix(InventoryGrid __instance, Inventory fromInventory, Vector2i pos, ref bool __result) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (!Ledger.IsDisplay(fromInventory) || Ledger.IsDisplay(__instance.GetInventory())) { return true; } __result = true; Plugin.Instance?.Ledger.DropOnto(__instance, pos); return false; } } [HarmonyPatch(typeof(InventoryGui), "OnDropOutside")] internal static class InventoryGui_OnDropOutside_Ledger { private static bool Prefix() { InventoryGui instance = InventoryGui.instance; if ((Object)(object)instance == (Object)null || !Ledger.IsDisplay(AccessTools.FieldRefAccess<InventoryGui, Inventory>(instance, "m_dragInventory"))) { return true; } Plugin.Instance?.Ledger.Drop(); return false; } } [HarmonyPatch(typeof(Humanoid), "DropItem")] internal static class Humanoid_DropItem_Ledger { private static bool Prefix(Inventory inventory, ref bool __result) { if (!Ledger.IsDisplay(inventory)) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(Inventory), "MoveItemToThis", new Type[] { typeof(Inventory), typeof(ItemData), typeof(int), typeof(int), typeof(int) })] internal static class Inventory_MoveItemToThis_Ledger { private static bool Prefix(Inventory __instance, Inventory fromInventory, ref bool __result) { if (!Ledger.IsDisplay(fromInventory) || __instance == fromInventory) { return true; } __result = false; return false; } } internal static class Look { private static readonly Dictionary<string, Material> Materials = new Dictionary<string, Material>(); private static readonly Dictionary<string, Color> Plain = new Dictionary<string, Color> { { "StoneDark", new Color(0.36f, 0.36f, 0.38f) }, { "Coal", new Color(0.15f, 0.15f, 0.17f) }, { "Parchment", new Color(0.9f, 0.82f, 0.63f) }, { "Ink", new Color(0.16f, 0.11f, 0.08f) }, { "Bone", new Color(0.92f, 0.89f, 0.8f) }, { "Red", new Color(0.66f, 0.1f, 0.08f) }, { "Gold", new Color(0.93f, 0.72f, 0.2f) }, { "Leather", new Color(0.42f, 0.26f, 0.13f) }, { "Glow", new Color(1f, 0.72f, 0.28f) }, { "Cream", new Color(0.95f, 0.92f, 0.84f) }, { "Black", new Color(0.06f, 0.06f, 0.07f) }, { "Green", new Color(0.18f, 0.5f, 0.25f) }, { "Blue", new Color(0.2f, 0.35f, 0.7f) }, { "Teal", new Color(0.25f, 0.75f, 0.8f) }, { "RedDark", new Color(0.38f, 0.05f, 0.05f) }, { "Chrome", new Color(0.78f, 0.8f, 0.84f) } }; private static readonly Dictionary<string, float> Glows = new Dictionary<string, float> { { "Glow", 1.1f }, { "Gold", 0.18f } }; private static Material Find(ZNetScene scene, string prefab, string material) { GameObject prefab2 = scene.GetPrefab(prefab); if ((Object)(object)prefab2 == (Object)null) { return null; } Renderer[] componentsInChildren = prefab2.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { Material[] sharedMaterials = val.sharedMaterials; foreach (Material val2 in sharedMaterials) { if ((Object)(object)val2 != (Object)null && ((Object)val2).name == material) { return val2; } } } return null; } internal static void Harvest(ZNetScene scene, Material fallbackBase) { //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Expected O, but got Unknown //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Expected O, but got Unknown //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) Materials.Clear(); Materials["Stone"] = Find(scene, "stone_wall_1x1", "stone_mat"); Materials["Planks"] = Find(scene, "wood_floor", "woodwall"); Materials["Dark"] = Find(scene, "darkwood_pole", "DarkWood_mat"); Materials["Iron"] = Find(scene, "iron_grate", "metalwall"); Material val = Find(scene, "piece_cauldron", "cauldron_chain"); Material val2 = (((Object)(object)val != (Object)null) ? val : fallbackBase); foreach (KeyValuePair<string, Color> item in Plain) { Material val3 = new Material(val2) { color = item.Value }; if (val3.HasProperty("_MainTex")) { val3.mainTexture = null; } if (Glows.TryGetValue(item.Key, out var value) && val3.HasProperty("_EmissionColor")) { val3.EnableKeyword("_EMISSION"); val3.SetColor("_EmissionColor", item.Value * value); } Materials[item.Key] = val3; } string[] array = new string[4] { "Stone", "Planks", "Dark", "Iron" }; foreach (string text in array) { if ((Object)(object)Materials[text] == (Object)null) { Materials[text] = new Material(val2) { color = (Color)(text switch { "Dark" => new Color(0.25f, 0.17f, 0.11f), "Planks" => new Color(0.5f, 0.34f, 0.2f), "Stone" => new Color(0.5f, 0.5f, 0.52f), _ => new Color(0.38f, 0.38f, 0.42f), }) }; } } Debug.Log((object)("[LedgerChest] materials: " + string.Join(", ", Materials.Select((KeyValuePair<string, Material> kv) => kv.Key + "=" + ((Object)kv.Value).name).ToArray()))); } internal static Material Of(string name) { if (!Materials.