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 TradingStall v1.0.0
TradingStall.dll
Decompiled 15 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.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using HarmonyLib; using Jotunn; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using TradingStall; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("TradingStall")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("TradingStall")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] public static class TradingStallBuyUI { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__26_0; public static UnityAction <>9__31_0; public static UnityAction<string> <>9__31_1; public static UnityAction <>9__31_2; public static UnityAction <>9__31_3; public static UnityAction <>9__37_0; internal void <BuildTipPanel>b__26_0() { _tipPanel.SetActive(false); RefreshDimOverlay(); } internal void <BuildQuantityPanel>b__31_0() { AdjustQty(-1); } internal void <BuildQuantityPanel>b__31_1(string _) { UpdateQtyTotal(); } internal void <BuildQuantityPanel>b__31_2() { AdjustQty(1); } internal void <BuildQuantityPanel>b__31_3() { _quantityPanel.SetActive(false); RefreshDimOverlay(); } internal void <BuildConfirmPanel>b__37_0() { _confirmPanel.SetActive(false); RefreshDimOverlay(); } } private static GameObject _panel; private static GameObject _titleText; private static GameObject _errorText; private static GameObject _tipPanel; private static GameObject _tipCustomInputGO; private static GameObject _tipErrorText; private static GameObject _confirmPanel; private static GameObject _confirmMessageText; private static GameObject _quantityPanel; private static GameObject _qtyItemNameText; private static GameObject _qtyInputGO; private static GameObject _qtyTotalText; private static GameObject _qtyErrorText; private static GameObject _dimOverlay; private static Action _confirmAction; private static TradingStallComponent _currentStall; private static Player _currentBuyer; private static string _qtyCurrentToken; private static int _qtyUnitPrice; private static int _qtyMaxAvailable; private static string _qtyDisplayName; private const float RowHeight = 68f; private static readonly Dictionary<GameObject, Coroutine> _messageClearRoutines = new Dictionary<GameObject, Coroutine>(); private const float MessageDisplaySeconds = 4f; public static void Show(TradingStallComponent stall, Player buyer) { if ((Object)(object)Player.m_localPlayer == (Object)null) { return; } _currentStall = stall; _currentBuyer = buyer; if (GUIManager.Instance == null) { Logger.LogError((object)"[TradingStall] GUIManager instance is null"); return; } if (!Object.op_Implicit((Object)(object)GUIManager.CustomGUIFront)) { Logger.LogError((object)"[TradingStall] GUIManager CustomGUIFront is null"); return; } if (!Object.op_Implicit((Object)(object)_panel)) { BuildPanel(); } if ((Object)(object)_titleText != (Object)null) { _titleText.GetComponent<Text>().text = stall.GetShopName(); } RefreshItems(); _panel.SetActive(true); GUIManager.BlockInput(true); } private static void Hide() { if (Object.op_Implicit((Object)(object)_panel)) { _panel.SetActive(false); } if (Object.op_Implicit((Object)(object)_tipPanel)) { _tipPanel.SetActive(false); } if (Object.op_Implicit((Object)(object)_confirmPanel)) { _confirmPanel.SetActive(false); } if (Object.op_Implicit((Object)(object)_quantityPanel)) { _quantityPanel.SetActive(false); } if (Object.op_Implicit((Object)(object)_dimOverlay)) { _dimOverlay.SetActive(false); } GUIManager.BlockInput(false); } public static void CloseIfOpen() { if ((Object)(object)_confirmPanel != (Object)null && _confirmPanel.activeSelf) { _confirmPanel.SetActive(false); RefreshDimOverlay(); } else if ((Object)(object)_tipPanel != (Object)null && _tipPanel.activeSelf) { _tipPanel.SetActive(false); RefreshDimOverlay(); } else if ((Object)(object)_quantityPanel != (Object)null && _quantityPanel.activeSelf) { _quantityPanel.SetActive(false); RefreshDimOverlay(); } else if ((Object)(object)_panel != (Object)null && _panel.activeSelf) { Hide(); } } private static void BuildPanel() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0135: 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_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Expected O, but got Unknown //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Expected O, but got Unknown _panel = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), 520f, 520f, true); _panel.SetActive(false); _titleText = GUIManager.Instance.CreateText("Trading Stall", _panel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -40f), GUIManager.Instance.AveriaSerifBold, 28, GUIManager.Instance.ValheimOrange, true, Color.black, 460f, 40f, false); _titleText.GetComponent<Text>().alignment = (TextAnchor)4; GameObject val = GUIManager.Instance.CreateScrollView(_panel.transform, false, true, 8f, 20f, GUIManager.Instance.ValheimScrollbarHandleColorBlock, new Color(0.1568628f, 0.1019608f, 0.0627451f, 1f), 460f, 350f); ((RectTransform)val.transform).anchoredPosition = new Vector2(0f, 20f); ((Object)val).name = "ItemScrollView"; DisableContentLayoutGroup(val.transform.Find("Scroll View/Viewport/Content")); SetScrollSensitivity(val, 150f); _errorText = GUIManager.Instance.CreateText("", _panel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(0f, 70f), GUIManager.Instance.AveriaSerifBold, 16, Color.red, true, Color.black, 460f, 30f, false); GameObject val2 = CreateButtonNoSfx("Tip", _panel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(-80f, 30f), 140f, 40f); ((UnityEvent)val2.GetComponent<Button>().onClick).AddListener(new UnityAction(ShowTipPanel)); GameObject val3 = CreateButtonNoSfx("Close", _panel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(80f, 30f), 140f, 40f); ((UnityEvent)val3.GetComponent<Button>().onClick).AddListener(new UnityAction(Hide)); } private static void ShowTipPanel() { if (!Object.op_Implicit((Object)(object)_tipPanel)) { BuildTipPanel(); } _tipCustomInputGO.GetComponent<InputField>().text = ""; ShowTipError(""); ShowOverlayBehind(_tipPanel); } private static void BuildTipPanel() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Expected O, but got Unknown //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Expected O, but got Unknown //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: 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_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Expected O, but got Unknown _tipPanel = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), 420f, 300f, true); _tipPanel.SetActive(false); GUIManager.Instance.CreateText("Leave a Tip", _tipPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -30f), GUIManager.Instance.AveriaSerifBold, 22, GUIManager.Instance.ValheimOrange, true, Color.black, 340f, 30f, false).GetComponent<Text>().alignment = (TextAnchor)4; int[] array = new int[3] { 10, 50, 100 }; float[] array2 = new float[3] { -120f, 0f, 120f }; for (int i = 0; i < array.Length; i++) { int amount = array[i]; GameObject val = CreateButtonNoSfx($"{amount}", _tipPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(array2[i], -90f), 100f, 42f); ((UnityEvent)val.GetComponent<Button>().onClick).AddListener((UnityAction)delegate { ShowConfirm($"Tip {amount} coins?", delegate { DoTip(amount); }); }); } GUIManager.Instance.CreateText("Custom:", _tipPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(-140f, -150f), GUIManager.Instance.AveriaSerifBold, 15, Color.white, true, Color.black, 80f, 25f, false).GetComponent<Text>().alignment = (TextAnchor)3; _tipCustomInputGO = CreateInputField(_tipPanel.transform, new Vector2(0f, -150f), 120f, 32f, "", (ContentType)2); GameObject val2 = CreateButtonNoSfx("Tip", _tipPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(120f, -150f), 90f, 34f); ((UnityEvent)val2.GetComponent<Button>().onClick).AddListener(new UnityAction(OnCustomTipClicked)); _tipErrorText = GUIManager.Instance.CreateText("", _tipPanel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(0f, 90f), GUIManager.Instance.AveriaSerifBold, 14, Color.red, true, Color.black, 380f, 25f, false); _tipErrorText.GetComponent<Text>().alignment = (TextAnchor)4; GameObject val3 = CreateButtonNoSfx("Close", _tipPanel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(0f, 35f), 150f, 40f); ButtonClickedEvent onClick = val3.GetComponent<Button>().onClick; object obj = <>c.<>9__26_0; if (obj == null) { UnityAction val4 = delegate { _tipPanel.SetActive(false); RefreshDimOverlay(); }; <>c.<>9__26_0 = val4; obj = (object)val4; } ((UnityEvent)onClick).AddListener((UnityAction)obj); } private static void OnCustomTipClicked() { string text = _tipCustomInputGO.GetComponent<InputField>().text; if (!int.TryParse(text, out var amount) || amount <= 0) { ShowTipError("Enter a valid tip amount."); return; } ShowConfirm($"Tip {amount} coins?", delegate { DoTip(amount); }); } private static void DoTip(int amount) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_currentStall == (Object)null) && !((Object)(object)_currentBuyer == (Object)null)) { if (_currentStall.TryTip(_currentBuyer, amount, out var errorMessage)) { ShowTipError($"Thanks for the {amount} coin tip!", GUIManager.Instance.ValheimOrange); } else { ShowTipError(errorMessage); } } } private static void ShowTipError(string message, Color? color = null) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) SetTimedMessage(_tipErrorText, message, (Color)(((??)color) ?? Color.red)); } private static void ShowQuantityPanel(string itemToken, string displayName, int unitPrice, int maxAvailable) { _qtyCurrentToken = itemToken; _qtyDisplayName = displayName; _qtyUnitPrice = unitPrice; _qtyMaxAvailable = maxAvailable; if (!Object.op_Implicit((Object)(object)_quantityPanel)) { BuildQuantityPanel(); } _qtyItemNameText.GetComponent<Text>().text = displayName; _qtyInputGO.GetComponent<InputField>().text = "1"; ShowQtyError(""); UpdateQtyTotal(); ShowOverlayBehind(_quantityPanel); } private static void BuildQuantityPanel() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Expected O, but got Unknown //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_026f: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Unknown result type (might be due to invalid IL or missing references) //IL_041d: Unknown result type (might be due to invalid IL or missing references) //IL_0427: Expected O, but got Unknown //IL_0441: Unknown result type (might be due to invalid IL or missing references) //IL_0450: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Expected O, but got Unknown //IL_0493: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_049e: Expected O, but got Unknown _quantityPanel = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), 420f, 320f, true); _quantityPanel.SetActive(false); GUIManager.Instance.CreateText("Select Quantity", _quantityPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -30f), GUIManager.Instance.AveriaSerifBold, 22, GUIManager.Instance.ValheimOrange, true, Color.black, 340f, 30f, false).GetComponent<Text>().alignment = (TextAnchor)4; _qtyItemNameText = GUIManager.Instance.CreateText("", _quantityPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -70f), GUIManager.Instance.AveriaSerifBold, 16, Color.white, true, Color.black, 340f, 25f, false); _qtyItemNameText.GetComponent<Text>().alignment = (TextAnchor)4; GameObject val = CreateButtonNoSfx("-", _quantityPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(-90f, -125f), 50f, 44f); ButtonClickedEvent onClick = val.GetComponent<Button>().onClick; object obj = <>c.<>9__31_0; if (obj == null) { UnityAction val2 = delegate { AdjustQty(-1); }; <>c.<>9__31_0 = val2; obj = (object)val2; } ((UnityEvent)onClick).AddListener((UnityAction)obj); _qtyInputGO = CreateInputField(_quantityPanel.transform, new Vector2(0f, -125f), 90f, 40f, "1", (ContentType)2); ((UnityEvent<string>)(object)_qtyInputGO.GetComponent<InputField>().onValueChanged).AddListener((UnityAction<string>)delegate { UpdateQtyTotal(); }); GameObject val3 = CreateButtonNoSfx("+", _quantityPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(90f, -125f), 50f, 44f); ButtonClickedEvent onClick2 = val3.GetComponent<Button>().onClick; object obj2 = <>c.<>9__31_2; if (obj2 == null) { UnityAction val4 = delegate { AdjustQty(1); }; <>c.<>9__31_2 = val4; obj2 = (object)val4; } ((UnityEvent)onClick2).AddListener((UnityAction)obj2); _qtyTotalText = GUIManager.Instance.CreateText("Total: 0 coins", _quantityPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -175f), GUIManager.Instance.AveriaSerifBold, 18, new Color(1f, 0.85f, 0.2f), true, Color.black, 300f, 30f, false); _qtyTotalText.GetComponent<Text>().alignment = (TextAnchor)4; _qtyErrorText = GUIManager.Instance.CreateText("", _quantityPanel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(0f, 85f), GUIManager.Instance.AveriaSerifBold, 14, Color.red, true, Color.black, 380f, 25f, false); _qtyErrorText.GetComponent<Text>().alignment = (TextAnchor)4; GameObject val5 = CreateButtonNoSfx("Buy", _quantityPanel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(-80f, 35f), 130f, 40f); ((UnityEvent)val5.GetComponent<Button>().onClick).AddListener(new UnityAction(OnQuantityBuyClicked)); GameObject val6 = CreateButtonNoSfx("Cancel", _quantityPanel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(80f, 35f), 130f, 40f); ButtonClickedEvent onClick3 = val6.GetComponent<Button>().onClick; object obj3 = <>c.<>9__31_3; if (obj3 == null) { UnityAction val7 = delegate { _quantityPanel.SetActive(false); RefreshDimOverlay(); }; <>c.<>9__31_3 = val7; obj3 = (object)val7; } ((UnityEvent)onClick3).AddListener((UnityAction)obj3); } private static void AdjustQty(int delta) { InputField component = _qtyInputGO.GetComponent<InputField>(); if (!int.TryParse(component.text, out var result)) { result = 1; } component.text = Mathf.Clamp(result + delta, 1, Mathf.Max(1, _qtyMaxAvailable)).ToString(); } private static void UpdateQtyTotal() { if (!((Object)(object)_qtyTotalText == (Object)null)) { string text = _qtyInputGO.GetComponent<InputField>().text; if (int.TryParse(text, out var result) && result > 0) { _qtyTotalText.GetComponent<Text>().text = $"Total: {result * _qtyUnitPrice} coins"; } else { _qtyTotalText.GetComponent<Text>().text = "Total: — coins"; } } } private static void OnQuantityBuyClicked() { //IL_00b9: Unknown result type (might be due to invalid IL or missing references) string text = _qtyInputGO.GetComponent<InputField>().text; string errorMessage; if (!int.TryParse(text, out var result) || result <= 0) { ShowQtyError("Enter a valid quantity."); } else if (result > _qtyMaxAvailable) { ShowQtyError($"Only {_qtyMaxAvailable} in stock."); } else if (_currentStall.TryBuyItem(_currentBuyer, _qtyCurrentToken, result, out errorMessage)) { _quantityPanel.SetActive(false); RefreshDimOverlay(); RefreshItems(); ShowError($"Bought {result}x {_qtyDisplayName}!", GUIManager.Instance.ValheimOrange); } else { ShowQtyError(errorMessage); } } private static void ShowQtyError(string message) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) SetTimedMessage(_qtyErrorText, message, Color.red); } private static void ShowConfirm(string message, Action onConfirm) { if (!Object.op_Implicit((Object)(object)_confirmPanel)) { BuildConfirmPanel(); } _confirmMessageText.GetComponent<Text>().text = message; _confirmAction = onConfirm; ShowOverlayBehind(_confirmPanel); } private static void BuildConfirmPanel() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0109: 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_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Expected O, but got Unknown //IL_0163: 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_0181: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Expected O, but got Unknown _confirmPanel = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), 380f, 200f, true); _confirmPanel.SetActive(false); _confirmMessageText = GUIManager.Instance.CreateText("", _confirmPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -60f), GUIManager.Instance.AveriaSerifBold, 18, GUIManager.Instance.ValheimOrange, true, Color.black, 340f, 60f, false); _confirmMessageText.GetComponent<Text>().alignment = (TextAnchor)4; GameObject val = CreateButtonNoSfx("Yes", _confirmPanel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(-80f, 35f), 130f, 40f); ((UnityEvent)val.GetComponent<Button>().onClick).AddListener(new UnityAction(OnConfirmYes)); GameObject val2 = CreateButtonNoSfx("No", _confirmPanel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(80f, 35f), 130f, 40f); ButtonClickedEvent onClick = val2.GetComponent<Button>().onClick; object obj = <>c.<>9__37_0; if (obj == null) { UnityAction val3 = delegate { _confirmPanel.SetActive(false); RefreshDimOverlay(); }; <>c.<>9__37_0 = val3; obj = (object)val3; } ((UnityEvent)onClick).AddListener((UnityAction)obj); } private static void OnConfirmYes() { _confirmPanel.SetActive(false); RefreshDimOverlay(); _confirmAction?.Invoke(); _confirmAction = null; } private static void EnsureDimOverlay() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_dimOverlay != (Object)null)) { _dimOverlay = new GameObject("DimOverlay", new Type[2] { typeof(RectTransform), typeof(Image) }); _dimOverlay.transform.SetParent(GUIManager.CustomGUIFront.transform, false); RectTransform component = _dimOverlay.GetComponent<RectTransform>(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; Image component2 = _dimOverlay.GetComponent<Image>(); ((Graphic)component2).color = new Color(0f, 0f, 0f, 0.6f); ((Graphic)component2).raycastTarget = false; _dimOverlay.SetActive(false); } } private static void ShowOverlayBehind(GameObject panelToShow) { EnsureDimOverlay(); _dimOverlay.SetActive(true); _dimOverlay.transform.SetAsLastSibling(); panelToShow.SetActive(true); panelToShow.transform.SetAsLastSibling(); } private static void RefreshDimOverlay() { if (!((Object)(object)_dimOverlay == (Object)null)) { GameObject val = null; if ((Object)(object)_quantityPanel != (Object)null && _quantityPanel.activeSelf) { val = _quantityPanel; } else if ((Object)(object)_tipPanel != (Object)null && _tipPanel.activeSelf) { val = _tipPanel; } else if ((Object)(object)_confirmPanel != (Object)null && _confirmPanel.activeSelf) { val = _confirmPanel; } if ((Object)(object)val != (Object)null) { _dimOverlay.SetActive(true); _dimOverlay.transform.SetAsLastSibling(); val.transform.SetAsLastSibling(); } else { _dimOverlay.SetActive(false); } } } private static void ShowError(string message, Color? color = null) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) SetTimedMessage(_errorText, message, (Color)(((??)color) ?? Color.red)); } private static void RefreshItems() { //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0108: 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_0124: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) Transform val = _panel.transform.Find("ItemScrollView/Scroll View/Viewport/Content"); if ((Object)(object)val == (Object)null) { Logger.LogWarning((object)"[TradingStall] Could not find scroll content transform"); return; } for (int num = val.childCount - 1; num >= 0; num--) { Object.Destroy((Object)(object)((Component)val.GetChild(num)).gameObject); } ShowError(""); Transform val2 = _panel.transform.Find("EmptyStateText"); if ((Object)(object)val2 != (Object)null) { Object.Destroy((Object)(object)((Component)val2).gameObject); } List<TradingStallComponent.StockedItem> stockedItems = _currentStall.GetStockedItems(); if (stockedItems.Count == 0) { GameObject val3 = GUIManager.Instance.CreateText("Nothing for sale right now.", _panel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), GUIManager.Instance.AveriaSerifBold, 18, GUIManager.Instance.ValheimOrange, true, Color.black, 400f, 30f, false); val3.GetComponent<Text>().alignment = (TextAnchor)4; ((Object)val3).name = "EmptyStateText"; return; } int num2 = 0; foreach (TradingStallComponent.StockedItem item in stockedItems) { CreateItemRow(val, item, num2); num2++; } RectTransform component = ((Component)val).GetComponent<RectTransform>(); if ((Object)(object)component != (Object)null) { component.sizeDelta = new Vector2(component.sizeDelta.x, (float)num2 * 68f); } } private static void CreateItemRow(Transform content, TradingStallComponent.StockedItem stocked, int rowIndex) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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_00ee: Expected O, but got Unknown //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Expected O, but got Unknown //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Unknown result type (might be due to invalid IL or missing references) //IL_0410: Unknown result type (might be due to invalid IL or missing references) //IL_041f: Unknown result type (might be due to invalid IL or missing references) //IL_0448: Unknown result type (might be due to invalid IL or missing references) //IL_0452: Expected O, but got Unknown //IL_0478: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Expected O, but got Unknown //IL_04a8: Unknown result type (might be due to invalid IL or missing references) //IL_04bf: Unknown result type (might be due to invalid IL or missing references) //IL_04d6: Unknown result type (might be due to invalid IL or missing references) //IL_04ed: Unknown result type (might be due to invalid IL or missing references) //IL_0513: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Row_" + stocked.Token, new Type[1] { typeof(RectTransform) }); val.transform.SetParent(content, false); RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0.5f, 1f); component.anchorMax = new Vector2(0.5f, 1f); component.pivot = new Vector2(0.5f, 1f); component.sizeDelta = new Vector2(420f, 62f); component.anchoredPosition = new Vector2(25f, (float)(-rowIndex) * 68f); GameObject val2 = new GameObject("IconSlot", new Type[2] { typeof(RectTransform), typeof(Image) }); val2.transform.SetParent(val.transform, false); RectTransform component2 = val2.GetComponent<RectTransform>(); component2.anchorMin = new Vector2(0f, 0.5f); component2.anchorMax = new Vector2(0f, 0.5f); component2.anchoredPosition = new Vector2(36f, 0f); component2.sizeDelta = new Vector2(60f, 60f); Image component3 = val2.GetComponent<Image>(); ((Graphic)component3).color = new Color(0.1568628f, 0.1019608f, 0.0627451f, 0.85f); GameObject val3 = new GameObject("Icon", new Type[2] { typeof(RectTransform), typeof(Image) }); val3.transform.SetParent(val2.transform, false); RectTransform component4 = val3.GetComponent<RectTransform>(); component4.anchorMin = new Vector2(0.5f, 0.5f); component4.anchorMax = new Vector2(0.5f, 0.5f); component4.anchoredPosition = Vector2.zero; component4.sizeDelta = new Vector2(50f, 50f); val3.GetComponent<Image>().sprite = stocked.Icon; val3.GetComponent<Image>().preserveAspect = true; GUIManager.Instance.CreateText(stocked.DisplayName ?? "", val.transform, new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(163f, 8f), GUIManager.Instance.AveriaSerifBold, 16, GUIManager.Instance.ValheimOrange, true, Color.black, 170f, 26f, false).GetComponent<Text>().alignment = (TextAnchor)3; GUIManager.Instance.CreateText($"Qty: {stocked.Quantity}", val.transform, new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(163f, -12f), GUIManager.Instance.AveriaSerifBold, 13, new Color(0.85f, 0.85f, 0.85f), true, Color.black, 170f, 20f, false).GetComponent<Text>().alignment = (TextAnchor)3; GUIManager.Instance.CreateText($"{stocked.Price} coins", val.transform, new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(305f, 0f), GUIManager.Instance.AveriaSerifBold, 16, Color.white, true, Color.black, 90f, 30f, false).GetComponent<Text>().alignment = (TextAnchor)3; GameObject val4 = CreateButtonNoSfx("Buy", val.transform, new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(382.5f, 0f), 55f, 40f); ((UnityEvent)val4.GetComponent<Button>().onClick).AddListener((UnityAction)delegate { if (stocked.Quantity > 1) { ShowQuantityPanel(stocked.Token, stocked.DisplayName, stocked.Price, stocked.Quantity); } else { ShowConfirm($"Buy {stocked.DisplayName} for {stocked.Price} coins?", delegate { DoBuy(stocked.Token, 1, stocked.DisplayName); }); } }); GameObject val5 = new GameObject("Separator", new Type[2] { typeof(RectTransform), typeof(Image) }); val5.transform.SetParent(val.transform, false); RectTransform component5 = val5.GetComponent<RectTransform>(); component5.anchorMin = new Vector2(0.5f, 0f); component5.anchorMax = new Vector2(0.5f, 0f); component5.anchoredPosition = new Vector2(0f, -3f); component5.sizeDelta = new Vector2(410f, 1.5f); ((Graphic)val5.GetComponent<Image>()).color = new Color(1f, 1f, 1f, 0.12f); } private static void DoBuy(string itemToken, int quantity, string displayName) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_currentStall == (Object)null) && !((Object)(object)_currentBuyer == (Object)null)) { if (_currentStall.TryBuyItem(_currentBuyer, itemToken, quantity, out var errorMessage)) { RefreshItems(); ShowError($"Bought {quantity}x {displayName}!", GUIManager.Instance.ValheimOrange); } else { ShowError(errorMessage); } } } private static GameObject CreateInputField(Transform parent, Vector2 anchoredPosition, float width, float height, string initialText, ContentType contentType = (ContentType)0) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("InputField", new Type[3] { typeof(RectTransform), typeof(Image), typeof(InputField) }); val.transform.SetParent(parent, false); RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0.5f, 1f); component.anchorMax = new Vector2(0.5f, 1f); component.sizeDelta = new Vector2(width, height); component.anchoredPosition = anchoredPosition; Image component2 = val.GetComponent<Image>(); ((Graphic)component2).color = new Color(0.1f, 0.1f, 0.1f, 0.85f); GameObject val2 = new GameObject("Text", new Type[2] { typeof(RectTransform), typeof(Text) }); val2.transform.SetParent(val.transform, false); RectTransform component3 = val2.GetComponent<RectTransform>(); component3.anchorMin = Vector2.zero; component3.anchorMax = Vector2.one; component3.offsetMin = new Vector2(8f, 2f); component3.offsetMax = new Vector2(-8f, -2f); Text component4 = val2.GetComponent<Text>(); component4.font = GUIManager.Instance.AveriaSerifBold; component4.fontSize = 16; ((Graphic)component4).color = Color.white; component4.alignment = (TextAnchor)3; component4.supportRichText = false; InputField component5 = val.GetComponent<InputField>(); component5.textComponent = component4; component5.text = initialText; component5.contentType = contentType; ((Selectable)component5).targetGraphic = (Graphic)(object)component2; return val; } private static void DisableContentLayoutGroup(Transform content) { if (!((Object)(object)content == (Object)null)) { LayoutGroup component = ((Component)content).GetComponent<LayoutGroup>(); if ((Object)(object)component != (Object)null) { ((Behaviour)component).enabled = false; } ContentSizeFitter component2 = ((Component)content).GetComponent<ContentSizeFitter>(); if ((Object)(object)component2 != (Object)null) { ((Behaviour)component2).enabled = false; } } } private static void SetScrollSensitivity(GameObject scrollView, float sensitivity) { Transform obj = scrollView.transform.Find("Scroll View"); ScrollRect val = ((obj != null) ? ((Component)obj).GetComponent<ScrollRect>() : null); if ((Object)(object)val != (Object)null) { val.scrollSensitivity = sensitivity; } } private static void SetTimedMessage(GameObject textObj, string message, Color color) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)textObj == (Object)null)) { ((Graphic)textObj.GetComponent<Text>()).color = color; textObj.GetComponent<Text>().text = message; if (_messageClearRoutines.TryGetValue(textObj, out var value) && value != null && (Object)(object)_currentStall != (Object)null) { ((MonoBehaviour)_currentStall).StopCoroutine(value); _messageClearRoutines.Remove(textObj); } if (!string.IsNullOrEmpty(message) && (Object)(object)_currentStall != (Object)null) { _messageClearRoutines[textObj] = ((MonoBehaviour)_currentStall).StartCoroutine(ClearTextAfterDelay(textObj)); } } } private static IEnumerator ClearTextAfterDelay(GameObject textObj) { yield return (object)new WaitForSeconds(4f); if ((Object)(object)textObj != (Object)null) { textObj.GetComponent<Text>().text = ""; } _messageClearRoutines.Remove(textObj); } private static GameObject CreateButtonNoSfx(string text, Transform parent, Vector2 anchorMin, Vector2 anchorMax, Vector2 position, float width, float height) { //IL_0008: 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_000a: Unknown result type (might be due to invalid IL or missing references) return GUIManager.Instance.CreateButton(text, parent, anchorMin, anchorMax, position, width, height); } } public class TradingStallComponent : MonoBehaviour { public class StockedItem { public string Token; public string DisplayName; public Sprite Icon; public int Price; public int Quantity; } public class ContainerItemInfo { public string Token; public string DisplayName; public Sprite Icon; public int Quantity; public int Price; } public class HistoryEntry { public string PlayerName; public bool IsTip; public string ItemToken; public string ItemDisplayName; public int Amount; } private ZNetView m_nview; private Container m_container; private const string ZDO_OWNER_ID = "TS_OwnerID"; private const string ZDO_OWNER_NAME = "TS_OwnerName"; private const string ZDO_PRICES = "TS_Prices"; private const string ZDO_COINS = "TS_Coins"; private const string ZDO_SHOP_NAME = "TS_ShopName"; private const string ZDO_HISTORY = "TS_History"; private const string DefaultShopName = "Trading Stall"; private const int MaxHistoryEntries = 20; private const float StockRange = 3f; public string OwnerName => m_nview.GetZDO().GetString("TS_OwnerName", ""); private void Awake() { m_nview = ((Component)this).GetComponent<ZNetView>(); m_container = ((Component)this).GetComponent<Container>(); if (!((Object)(object)m_nview == (Object)null) && m_nview.IsValid() && m_nview.GetZDO().GetLong("TS_OwnerID", 0L) == 0L && (Object)(object)Player.m_localPlayer != (Object)null) { m_nview.GetZDO().Set("TS_OwnerID", Player.m_localPlayer.GetPlayerID()); m_nview.GetZDO().Set("TS_OwnerName", Player.m_localPlayer.GetPlayerName()); } } public bool IsOwner(Player player) { if ((Object)(object)m_nview == (Object)null || !m_nview.IsValid() || (Object)(object)player == (Object)null) { return false; } return m_nview.GetZDO().GetLong("TS_OwnerID", 0L) == player.GetPlayerID(); } public string GetShopName() { if ((Object)(object)m_nview == (Object)null || !m_nview.IsValid()) { return "Trading Stall"; } string text = m_nview.GetZDO().GetString("TS_ShopName", ""); return string.IsNullOrEmpty(text) ? "Trading Stall" : text; } public void SetShopName(string name) { if (!((Object)(object)m_nview == (Object)null) && m_nview.IsValid()) { m_nview.GetZDO().Set("TS_ShopName", name ?? ""); } } public Dictionary<string, int> GetPrices() { Dictionary<string, int> dictionary = new Dictionary<string, int>(); if ((Object)(object)m_nview == (Object)null || !m_nview.IsValid()) { Logger.LogWarning((object)"[TradingStall] GetPrices: nview null/invalid"); return dictionary; } string text = m_nview.GetZDO().GetString("TS_Prices", ""); Logger.LogInfo((object)("[TradingStall] GetPrices raw string: '" + text + "'")); if (string.IsNullOrEmpty(text)) { return dictionary; } string[] array = text.Split(new char[1] { ';' }); foreach (string text2 in array) { if (!string.IsNullOrEmpty(text2)) { string[] array2 = text2.Split(new char[1] { '|' }); if (array2.Length == 2 && int.TryParse(array2[1], out var result)) { dictionary[array2[0]] = result; } } } Logger.LogInfo((object)string.Format("[TradingStall] GetPrices parsed {0} entries: {1}", dictionary.Count, string.Join(", ", dictionary))); return dictionary; } public void SetPrice(string itemName, int price) { Dictionary<string, int> prices = GetPrices(); prices[itemName] = price; SavePrices(prices); Logger.LogInfo((object)$"[TradingStall] SetPrice: '{itemName}' = {price}, total entries now {prices.Count}"); } public void RemoveListing(string itemToken) { Dictionary<string, int> prices = GetPrices(); if (prices.Remove(itemToken)) { SavePrices(prices); Logger.LogInfo((object)$"[TradingStall] RemoveListing: '{itemToken}' removed, {prices.Count} entries left"); } } public bool RemoveItemFromStock(Player owner, string itemToken, out string errorMessage) { errorMessage = ""; if ((Object)(object)owner == (Object)null || (Object)(object)m_container == (Object)null) { errorMessage = "Something went wrong."; return false; } Inventory inventory = m_container.GetInventory(); ItemData val = inventory.GetAllItems().Find((ItemData i) => i.m_shared.m_name == itemToken); if (val == null) { errorMessage = "Item not found in stall."; return false; } ItemData val2 = val.Clone(); Inventory inventory2 = ((Humanoid)owner).GetInventory(); if (!inventory2.AddItem(val2)) { errorMessage = "Your inventory is full."; return false; } inventory.RemoveItem(val); Dictionary<string, int> prices = GetPrices(); if (prices.Remove(itemToken)) { SavePrices(prices); } Logger.LogInfo((object)("[TradingStall] RemoveItemFromStock: '" + itemToken + "' returned to owner and un-listed")); return true; } private void SavePrices(Dictionary<string, int> prices) { if ((Object)(object)m_nview == (Object)null || !m_nview.IsValid()) { Logger.LogWarning((object)"[TradingStall] SavePrices: nview null/invalid, write skipped"); return; } StringBuilder stringBuilder = new StringBuilder(); foreach (KeyValuePair<string, int> price in prices) { if (stringBuilder.Length > 0) { stringBuilder.Append(';'); } stringBuilder.Append(price.Key).Append('|').Append(price.Value); } string text = stringBuilder.ToString(); m_nview.GetZDO().Set("TS_Prices", text); Logger.LogInfo((object)("[TradingStall] SavePrices wrote string: '" + text + "'")); } public long GetCoinBalance() { return m_nview.GetZDO().GetLong("TS_Coins", 0L); } public void AddCoins(int amount) { m_nview.GetZDO().Set("TS_Coins", GetCoinBalance() + amount); } public long CollectCoins(Player owner) { long coinBalance = GetCoinBalance(); if (coinBalance <= 0) { return 0L; } GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("Coins"); ((Humanoid)owner).GetInventory().AddItem(itemPrefab, (int)coinBalance); m_nview.GetZDO().Set("TS_Coins", 0L); return coinBalance; } private void Update() { //IL_0055: 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) if (Input.GetKeyDown((KeyCode)27)) { TradingStallBuyUI.CloseIfOpen(); TradingStallStockUI.CloseIfOpen(); } if (ZInput.instance != null && !((Object)(object)Player.m_localPlayer == (Object)null) && IsOwner(Player.m_localPlayer)) { float num = Vector3.Distance(((Component)Player.m_localPlayer).transform.position, ((Component)this).transform.position); if (!(num > 3f) && ZInput.GetButtonDown(TradingStallPlugin.StockButton.Name)) { OpenStockUI(Player.m_localPlayer); } } } public void OpenBuyUI(Player player) { TradingStallBuyUI.Show(this, player); } public void OpenStockUI(Player player) { TradingStallStockUI.Show(this, player); } public List<StockedItem> GetStockedItems() { List<StockedItem> list = new List<StockedItem>(); if ((Object)(object)m_container == (Object)null) { return list; } Dictionary<string, int> prices = GetPrices(); if (prices.Count == 0) { return list; } List<string> list2 = new List<string>(); Dictionary<string, int> dictionary = new Dictionary<string, int>(); Dictionary<string, Sprite> dictionary2 = new Dictionary<string, Sprite>(); Dictionary<string, string> dictionary3 = new Dictionary<string, string>(); foreach (ItemData allItem in m_container.GetInventory().GetAllItems()) { string name = allItem.m_shared.m_name; if (!dictionary.ContainsKey(name)) { dictionary[name] = 0; dictionary2[name] = allItem.GetIcon(); dictionary3[name] = FormatItemToken(allItem.m_shared.m_name); list2.Add(name); } dictionary[name] += allItem.m_stack; } foreach (string item in list2) { if (prices.TryGetValue(item, out var value) && dictionary.TryGetValue(item, out var value2) && value2 > 0) { list.Add(new StockedItem { Token = item, DisplayName = dictionary3[item], Icon = dictionary2[item], Price = value, Quantity = value2 }); } } return list; } public List<ContainerItemInfo> GetAllContainerItems() { List<ContainerItemInfo> list = new List<ContainerItemInfo>(); if ((Object)(object)m_container == (Object)null) { return list; } Dictionary<string, int> prices = GetPrices(); List<string> list2 = new List<string>(); Dictionary<string, int> dictionary = new Dictionary<string, int>(); Dictionary<string, Sprite> dictionary2 = new Dictionary<string, Sprite>(); Dictionary<string, string> dictionary3 = new Dictionary<string, string>(); foreach (ItemData allItem in m_container.GetInventory().GetAllItems()) { string name = allItem.m_shared.m_name; if (!dictionary.ContainsKey(name)) { dictionary[name] = 0; dictionary2[name] = allItem.GetIcon(); dictionary3[name] = FormatItemToken(name); list2.Add(name); } dictionary[name] += allItem.m_stack; } foreach (string item in list2) { list.Add(new ContainerItemInfo { Token = item, DisplayName = dictionary3[item], Icon = dictionary2[item], Quantity = dictionary[item], Price = (prices.TryGetValue(item, out var value) ? value : 0) }); } return list; } public bool MoveItemToStock(Player owner, string itemToken, int quantity, out string errorMessage) { errorMessage = ""; if ((Object)(object)owner == (Object)null || (Object)(object)m_container == (Object)null) { errorMessage = "Something went wrong."; return false; } if (quantity <= 0) { errorMessage = "Enter a valid amount."; return false; } Inventory inventory = ((Humanoid)owner).GetInventory(); if (inventory.CountItems(itemToken, -1, true) < quantity) { errorMessage = "You don't have that many."; return false; } ItemData val = inventory.GetAllItems().Find((ItemData i) => i.m_shared.m_name == itemToken); if (val == null) { errorMessage = "Item not found."; return false; } ItemData val2 = val.Clone(); inventory.RemoveItem(itemToken, quantity, -1, true); ItemData val3 = val2.Clone(); val3.m_stack = quantity; if (!m_container.GetInventory().AddItem(val3)) { ItemData val4 = val2.Clone(); val4.m_stack = quantity; inventory.AddItem(val4); errorMessage = "Stall container is full."; return false; } return true; } public bool TryBuyItem(Player buyer, string itemToken, int quantity, out string errorMessage) { errorMessage = ""; if ((Object)(object)buyer == (Object)null || (Object)(object)m_container == (Object)null) { errorMessage = "Something went wrong."; return false; } if (quantity <= 0) { errorMessage = "Invalid quantity."; return false; } Dictionary<string, int> prices = GetPrices(); if (!prices.TryGetValue(itemToken, out var value)) { errorMessage = "That item is no longer for sale."; return false; } Inventory inventory = m_container.GetInventory(); int num = 0; ItemData val = null; foreach (ItemData allItem in inventory.GetAllItems()) { if (allItem.m_shared.m_name == itemToken) { num += allItem.m_stack; if (val == null) { val = allItem; } } } if (val == null || num <= 0) { errorMessage = "Out of stock."; return false; } if (quantity > num) { errorMessage = $"Only {num} in stock."; return false; } int num2 = value * quantity; Inventory inventory2 = ((Humanoid)buyer).GetInventory(); if (inventory2.CountItems("$item_coins", -1, true) < num2) { errorMessage = "Not enough coins."; return false; } inventory2.RemoveItem("$item_coins", num2, -1, true); ItemData val2 = val.Clone(); val2.m_stack = quantity; inventory2.AddItem(val2); List<ItemData> list = new List<ItemData>(); foreach (ItemData allItem2 in inventory.GetAllItems()) { if (allItem2.m_shared.m_name == itemToken) { list.Add(allItem2); } } int num3 = quantity; foreach (ItemData item in list) { if (num3 <= 0) { break; } int num4 = ((num3 < item.m_stack) ? num3 : item.m_stack); inventory.RemoveItem(item, num4); num3 -= num4; } AddCoins(num2); AddHistoryEntry(buyer.GetPlayerName(), isTip: false, itemToken, num2); return true; } public bool TryTip(Player buyer, int amount, out string errorMessage) { errorMessage = ""; if ((Object)(object)buyer == (Object)null) { errorMessage = "Something went wrong."; return false; } if (amount <= 0) { errorMessage = "Invalid tip amount."; return false; } Inventory inventory = ((Humanoid)buyer).GetInventory(); if (inventory.CountItems("$item_coins", -1, true) < amount) { errorMessage = "Not enough coins."; return false; } inventory.RemoveItem("$item_coins", amount, -1, true); AddCoins(amount); AddHistoryEntry(buyer.GetPlayerName(), isTip: true, "", amount); return true; } private static string FormatItemToken(string token) { if (TradingStallPlugin.Localization != null) { string text = TradingStallPlugin.Localization.TryTranslate(token); if (!string.IsNullOrEmpty(text) && text != token) { return text; } } string text2 = token.TrimStart(new char[1] { '$' }); int num = text2.LastIndexOf('_'); if (num >= 0 && num < text2.Length - 1) { text2 = text2.Substring(num + 1); } if (text2.Length == 0) { return token; } text2 = char.ToUpper(text2[0]) + text2.Substring(1); return Regex.Replace(text2, "(?<!^)([A-Z])", " $1"); } public List<HistoryEntry> GetHistory() { List<HistoryEntry> list = new List<HistoryEntry>(); if ((Object)(object)m_nview == (Object)null || !m_nview.IsValid()) { return list; } string text = m_nview.GetZDO().GetString("TS_History", ""); if (string.IsNullOrEmpty(text)) { return list; } string[] array = text.Split(new char[1] { ';' }); foreach (string text2 in array) { if (!string.IsNullOrEmpty(text2)) { string[] array2 = text2.Split(new char[1] { '|' }); if (array2.Length == 4 && int.TryParse(array2[3], out var result)) { list.Add(new HistoryEntry { PlayerName = array2[0], IsTip = (array2[1] == "T"), ItemToken = array2[2], ItemDisplayName = (string.IsNullOrEmpty(array2[2]) ? "" : FormatItemToken(array2[2])), Amount = result }); } } } return list; } private void AddHistoryEntry(string playerName, bool isTip, string itemToken, int amount) { if ((Object)(object)m_nview == (Object)null || !m_nview.IsValid()) { return; } List<HistoryEntry> history = GetHistory(); history.Add(new HistoryEntry { PlayerName = playerName, IsTip = isTip, ItemToken = itemToken, Amount = amount }); while (history.Count > 20) { history.RemoveAt(0); } StringBuilder stringBuilder = new StringBuilder(); foreach (HistoryEntry item in history) { if (stringBuilder.Length > 0) { stringBuilder.Append(';'); } stringBuilder.Append(item.PlayerName).Append('|').Append(item.IsTip ? "T" : "B") .Append('|') .Append(item.ItemToken) .Append('|') .Append(item.Amount); } m_nview.GetZDO().Set("TS_History", stringBuilder.ToString()); } } public static class TradingStallStockUI { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__35_0; public static UnityAction <>9__41_0; public static UnityAction <>9__44_0; internal void <BuildConfirmPanel>b__35_0() { _confirmPanel.SetActive(false); RefreshDimOverlay(); } internal void <BuildRenamePanel>b__41_0() { _renamePanel.SetActive(false); RefreshDimOverlay(); } internal void <BuildAddItemPanel>b__44_0() { _addItemPanel.SetActive(false); RefreshDimOverlay(); } } private static GameObject _panel; private static GameObject _renameBtnGO; private static GameObject _historyBtnGO; private static GameObject _coinText; private static GameObject _errorText; private static GameObject _addItemPanel; private static GameObject _renamePanel; private static GameObject _renameInputGO; private static GameObject _confirmPanel; private static GameObject _confirmMessageText; private static GameObject _dimOverlay; private static Action _confirmAction; private static TradingStallComponent _currentStall; private static Player _currentOwner; private static bool _showingHistory; private const float HistoryRowHeight = 40f; private const float StockRowHeight = 68f; private static Sprite _cachedCoinIcon; private const float InventoryRowHeight = 62f; private static readonly Dictionary<GameObject, Coroutine> _messageClearRoutines = new Dictionary<GameObject, Coroutine>(); private const float MessageDisplaySeconds = 4f; public static void Show(TradingStallComponent stall, Player owner) { if ((Object)(object)Player.m_localPlayer == (Object)null) { return; } _currentStall = stall; _currentOwner = owner; if (GUIManager.Instance == null || !Object.op_Implicit((Object)(object)GUIManager.CustomGUIFront)) { Logger.LogError((object)"[TradingStall] GUIManager not ready"); return; } if (!Object.op_Implicit((Object)(object)_panel)) { BuildPanel(); } _showingHistory = false; SetHistoryButtonText(); RefreshStockList(); RefreshCoinText(); _panel.SetActive(true); GUIManager.BlockInput(true); } private static void Hide() { if (Object.op_Implicit((Object)(object)_panel)) { _panel.SetActive(false); } if (Object.op_Implicit((Object)(object)_addItemPanel)) { _addItemPanel.SetActive(false); } if (Object.op_Implicit((Object)(object)_renamePanel)) { _renamePanel.SetActive(false); } if (Object.op_Implicit((Object)(object)_confirmPanel)) { _confirmPanel.SetActive(false); } if (Object.op_Implicit((Object)(object)_dimOverlay)) { _dimOverlay.SetActive(false); } GUIManager.BlockInput(false); } public static void CloseIfOpen() { if ((Object)(object)_confirmPanel != (Object)null && _confirmPanel.activeSelf) { _confirmPanel.SetActive(false); RefreshDimOverlay(); } else if ((Object)(object)_renamePanel != (Object)null && _renamePanel.activeSelf) { _renamePanel.SetActive(false); RefreshDimOverlay(); } else if ((Object)(object)_addItemPanel != (Object)null && _addItemPanel.activeSelf) { _addItemPanel.SetActive(false); RefreshDimOverlay(); } else if ((Object)(object)_panel != (Object)null && _panel.activeSelf) { Hide(); } } private static void BuildPanel() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Expected O, but got Unknown //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Expected O, but got Unknown //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Expected O, but got Unknown //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: 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_0424: Unknown result type (might be due to invalid IL or missing references) //IL_0433: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Expected O, but got Unknown //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_049e: Unknown result type (might be due to invalid IL or missing references) //IL_04ad: Unknown result type (might be due to invalid IL or missing references) //IL_04d6: Unknown result type (might be due to invalid IL or missing references) //IL_04e0: Expected O, but got Unknown //IL_04fa: Unknown result type (might be due to invalid IL or missing references) //IL_0509: Unknown result type (might be due to invalid IL or missing references) //IL_0518: Unknown result type (might be due to invalid IL or missing references) //IL_0541: Unknown result type (might be due to invalid IL or missing references) //IL_054b: Expected O, but got Unknown _panel = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), 580f, 580f, true); _panel.SetActive(false); GUIManager.Instance.CreateText("Manage Stall", _panel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -30f), GUIManager.Instance.AveriaSerifBold, 26, GUIManager.Instance.ValheimOrange, true, Color.black, 300f, 40f, false).GetComponent<Text>().alignment = (TextAnchor)4; _renameBtnGO = CreateButtonNoSfx("✎", _panel.transform, new Vector2(1f, 1f), new Vector2(1f, 1f), new Vector2(-38f, -30f), 36f, 36f); ((UnityEvent)_renameBtnGO.GetComponent<Button>().onClick).AddListener(new UnityAction(ShowRenamePanel)); _historyBtnGO = CreateButtonNoSfx("History", _panel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -75f), 160f, 34f); ((UnityEvent)_historyBtnGO.GetComponent<Button>().onClick).AddListener(new UnityAction(ToggleHistoryView)); GameObject val = new GameObject("CoinIcon", new Type[2] { typeof(RectTransform), typeof(Image) }); val.transform.SetParent(_panel.transform, false); RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0f, 1f); component.anchorMax = new Vector2(0f, 1f); component.anchoredPosition = new Vector2(44f, -38f); component.sizeDelta = new Vector2(48f, 48f); Image component2 = val.GetComponent<Image>(); component2.sprite = GetCoinIcon(); component2.preserveAspect = true; _coinText = GUIManager.Instance.CreateText("0", _panel.transform, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(111f, -30f), GUIManager.Instance.AveriaSerifBold, 20, new Color(1f, 0.85f, 0.2f), true, Color.black, 90f, 30f, false); _coinText.GetComponent<Text>().alignment = (TextAnchor)3; GameObject val2 = GUIManager.Instance.CreateScrollView(_panel.transform, false, true, 8f, 20f, GUIManager.Instance.ValheimScrollbarHandleColorBlock, new Color(0.1568628f, 0.1019608f, 0.0627451f, 1f), 500f, 272f); ((RectTransform)val2.transform).anchoredPosition = new Vector2(0f, 10f); ((Object)val2).name = "StockScrollView"; DisableContentLayoutGroup(val2.transform.Find("Scroll View/Viewport/Content")); SetScrollSensitivity(val2, 150f); _errorText = GUIManager.Instance.CreateText("", _panel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(0f, 80f), GUIManager.Instance.AveriaSerifBold, 14, Color.red, true, Color.black, 480f, 25f, false); GameObject val3 = CreateButtonNoSfx("Collect Coins", _panel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(-190f, 40f), 140f, 40f); ((UnityEvent)val3.GetComponent<Button>().onClick).AddListener(new UnityAction(OnCollectClicked)); GameObject val4 = CreateButtonNoSfx("Add Item", _panel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(0f, 40f), 140f, 40f); ((UnityEvent)val4.GetComponent<Button>().onClick).AddListener(new UnityAction(ShowAddItemPanel)); GameObject val5 = CreateButtonNoSfx("Close", _panel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(190f, 40f), 140f, 40f); ((UnityEvent)val5.GetComponent<Button>().onClick).AddListener(new UnityAction(Hide)); } private static void RefreshStockList() { //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) if (_showingHistory) { RefreshHistoryList(); return; } Transform val = _panel.transform.Find("StockScrollView/Scroll View/Viewport/Content"); if ((Object)(object)val == (Object)null) { return; } for (int num = val.childCount - 1; num >= 0; num--) { Object.Destroy((Object)(object)((Component)val.GetChild(num)).gameObject); } List<TradingStallComponent.ContainerItemInfo> allContainerItems = _currentStall.GetAllContainerItems(); Transform val2 = _panel.transform.Find("StockEmptyText"); if ((Object)(object)val2 != (Object)null) { Object.Destroy((Object)(object)((Component)val2).gameObject); } if (allContainerItems.Count == 0) { GameObject val3 = GUIManager.Instance.CreateText("Stall is empty. Use \"Add Item\" to stock it.", _panel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 20f), GUIManager.Instance.AveriaSerifBold, 16, GUIManager.Instance.ValheimOrange, true, Color.black, 400f, 30f, false); val3.GetComponent<Text>().alignment = (TextAnchor)4; ((Object)val3).name = "StockEmptyText"; return; } int num2 = 0; foreach (TradingStallComponent.ContainerItemInfo item in allContainerItems) { CreateStockRow(val, item, num2); num2++; } SetContentHeight(val, num2, 68f); } private static void ToggleHistoryView() { _showingHistory = !_showingHistory; SetHistoryButtonText(); RefreshStockList(); } private static void SetHistoryButtonText() { if ((Object)(object)_historyBtnGO != (Object)null) { _historyBtnGO.GetComponentInChildren<Text>().text = (_showingHistory ? "Back to Stock" : "History"); } } private static void RefreshHistoryList() { //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) Transform val = _panel.transform.Find("StockScrollView/Scroll View/Viewport/Content"); if ((Object)(object)val == (Object)null) { return; } for (int num = val.childCount - 1; num >= 0; num--) { Object.Destroy((Object)(object)((Component)val.GetChild(num)).gameObject); } Transform val2 = _panel.transform.Find("StockEmptyText"); if ((Object)(object)val2 != (Object)null) { Object.Destroy((Object)(object)((Component)val2).gameObject); } List<TradingStallComponent.HistoryEntry> history = _currentStall.GetHistory(); history.Reverse(); if (history.Count == 0) { GameObject val3 = GUIManager.Instance.CreateText("No activity yet.", _panel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 20f), GUIManager.Instance.AveriaSerifBold, 16, GUIManager.Instance.ValheimOrange, true, Color.black, 400f, 30f, false); val3.GetComponent<Text>().alignment = (TextAnchor)4; ((Object)val3).name = "StockEmptyText"; return; } int num2 = 0; foreach (TradingStallComponent.HistoryEntry item in history) { CreateHistoryRow(val, item, num2); num2++; } SetContentHeight(val, num2, 40f); } private static void CreateHistoryRow(Transform content, TradingStallComponent.HistoryEntry entry, int rowIndex) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_004a: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: 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_0157: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject($"HistRow_{rowIndex}", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(content, false); RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0.5f, 1f); component.anchorMax = new Vector2(0.5f, 1f); component.pivot = new Vector2(0.5f, 1f); component.sizeDelta = new Vector2(480f, 36f); component.anchoredPosition = new Vector2(25f, (float)(-rowIndex) * 40f); string text = (entry.IsTip ? $"{entry.PlayerName} tipped {entry.Amount} coins" : $"{entry.PlayerName} bought {entry.ItemDisplayName} for {entry.Amount} coins"); GUIManager.Instance.CreateText(text, val.transform, new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(220f, 0f), GUIManager.Instance.AveriaSerifBold, 14, entry.IsTip ? GUIManager.Instance.ValheimOrange : Color.white, true, Color.black, 440f, 30f, false).GetComponent<Text>().alignment = (TextAnchor)3; AddRowSeparator(val.transform, 440f); } private static void CreateStockRow(Transform content, TradingStallComponent.ContainerItemInfo stocked, int rowIndex) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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_00ee: Expected O, but got Unknown //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: 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_01b6: Expected O, but got Unknown //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_041a: Unknown result type (might be due to invalid IL or missing references) //IL_0429: Unknown result type (might be due to invalid IL or missing references) //IL_0438: Unknown result type (might be due to invalid IL or missing references) //IL_0461: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Expected O, but got Unknown //IL_0481: Unknown result type (might be due to invalid IL or missing references) //IL_0490: Unknown result type (might be due to invalid IL or missing references) //IL_049f: Unknown result type (might be due to invalid IL or missing references) //IL_04c8: Unknown result type (might be due to invalid IL or missing references) //IL_04d2: Expected O, but got Unknown GameObject val = new GameObject("Row_" + stocked.Token, new Type[1] { typeof(RectTransform) }); val.transform.SetParent(content, false); RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0.5f, 1f); component.anchorMax = new Vector2(0.5f, 1f); component.pivot = new Vector2(0.5f, 1f); component.sizeDelta = new Vector2(500f, 62f); component.anchoredPosition = new Vector2(25f, (float)(-rowIndex) * 68f); GameObject val2 = new GameObject("IconSlot", new Type[2] { typeof(RectTransform), typeof(Image) }); val2.transform.SetParent(val.transform, false); RectTransform component2 = val2.GetComponent<RectTransform>(); component2.anchorMin = new Vector2(0f, 0.5f); component2.anchorMax = new Vector2(0f, 0.5f); component2.anchoredPosition = new Vector2(32f, 0f); component2.sizeDelta = new Vector2(56f, 56f); ((Graphic)val2.GetComponent<Image>()).color = new Color(0.1568628f, 0.1019608f, 0.0627451f, 0.85f); GameObject val3 = new GameObject("Icon", new Type[2] { typeof(RectTransform), typeof(Image) }); val3.transform.SetParent(val2.transform, false); RectTransform component3 = val3.GetComponent<RectTransform>(); component3.anchorMin = new Vector2(0.5f, 0.5f); component3.anchorMax = new Vector2(0.5f, 0.5f); component3.anchoredPosition = Vector2.zero; component3.sizeDelta = new Vector2(46f, 46f); val3.GetComponent<Image>().sprite = stocked.Icon; val3.GetComponent<Image>().preserveAspect = true; GUIManager.Instance.CreateText(stocked.DisplayName, val.transform, new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(133f, 8f), GUIManager.Instance.AveriaSerifBold, 15, GUIManager.Instance.ValheimOrange, true, Color.black, 130f, 24f, false).GetComponent<Text>().alignment = (TextAnchor)3; GUIManager.Instance.CreateText($"x{stocked.Quantity}", val.transform, new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(133f, -12f), GUIManager.Instance.AveriaSerifBold, 12, new Color(0.85f, 0.85f, 0.85f), true, Color.black, 130f, 18f, false).GetComponent<Text>().alignment = (TextAnchor)3; GUIManager.Instance.CreateText("Price:", val.transform, new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(221f, 0f), GUIManager.Instance.AveriaSerifBold, 14, Color.white, true, Color.black, 38f, 25f, false).GetComponent<Text>().alignment = (TextAnchor)3; GameObject priceInput = CreateInputField(val.transform, new Vector2(271.5f, 0f), 55f, 30f, stocked.Price.ToString(), (ContentType)2); GameObject val4 = CreateButtonNoSfx("Set", val.transform, new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(334f, 0f), 60f, 34f); ((UnityEvent)val4.GetComponent<Button>().onClick).AddListener((UnityAction)delegate { InputField component4 = priceInput.GetComponent<InputField>(); if (int.TryParse(component4.text, out var result) && result > 0) { _currentStall.SetPrice(stocked.Token, result); ShowError(""); RefreshStockList(); } else { ShowError("Enter a valid price."); } }); GameObject val5 = CreateButtonNoSfx("Remove", val.transform, new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(405f, 0f), 70f, 34f); ((UnityEvent)val5.GetComponent<Button>().onClick).AddListener((UnityAction)delegate { ShowConfirm($"Remove {stocked.DisplayName} (x{stocked.Quantity}) from stock and return it to your inventory?", delegate { DoRemove(stocked.Token); }); }); AddRowSeparator(val.transform, 480f); } private static void DoRemove(string itemToken) { if (_currentStall.RemoveItemFromStock(_currentOwner, itemToken, out var errorMessage)) { ShowError(""); RefreshStockList(); RefreshAddItemList(); } else { ShowError(errorMessage); } } private static void RefreshCoinText() { if ((Object)(object)_coinText != (Object)null) { _coinText.GetComponent<Text>().text = $"{_currentStall.GetCoinBalance()}"; } } private static Sprite GetCoinIcon() { if ((Object)(object)_cachedCoinIcon != (Object)null) { return _cachedCoinIcon; } ObjectDB instance = ObjectDB.instance; GameObject val = ((instance != null) ? instance.GetItemPrefab("Coins") : null); ItemDrop val2 = ((val != null) ? val.GetComponent<ItemDrop>() : null); if ((Object)(object)val2 != (Object)null) { _cachedCoinIcon = val2.m_itemData.GetIcon(); } return _cachedCoinIcon; } private static void ShowError(string message, Color? color = null) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) SetTimedMessage(_errorText, message, (Color)(((??)color) ?? Color.red)); } private static void OnCollectClicked() { long coinBalance = _currentStall.GetCoinBalance(); if (coinBalance <= 0) { ShowError("Nothing to collect right now."); } else { ShowConfirm($"Collect {coinBalance} coins?", DoCollectCoins); } } private static void DoCollectCoins() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) long num = _currentStall.CollectCoins(_currentOwner); RefreshCoinText(); if (num > 0) { ShowError($"Collected {num} coins successfully!", GUIManager.Instance.ValheimOrange); } } private static void ShowConfirm(string message, Action onConfirm) { if (!Object.op_Implicit((Object)(object)_confirmPanel)) { BuildConfirmPanel(); } _confirmMessageText.GetComponent<Text>().text = message; _confirmAction = onConfirm; ShowOverlayBehind(_confirmPanel); } private static void BuildConfirmPanel() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0109: 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_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Expected O, but got Unknown //IL_0163: 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_0181: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Expected O, but got Unknown _confirmPanel = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), 420f, 220f, true); _confirmPanel.SetActive(false); _confirmMessageText = GUIManager.Instance.CreateText("", _confirmPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -70f), GUIManager.Instance.AveriaSerifBold, 16, GUIManager.Instance.ValheimOrange, true, Color.black, 370f, 80f, false); _confirmMessageText.GetComponent<Text>().alignment = (TextAnchor)4; GameObject val = CreateButtonNoSfx("Yes", _confirmPanel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(-80f, 35f), 130f, 40f); ((UnityEvent)val.GetComponent<Button>().onClick).AddListener(new UnityAction(OnConfirmYes)); GameObject val2 = CreateButtonNoSfx("No", _confirmPanel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(80f, 35f), 130f, 40f); ButtonClickedEvent onClick = val2.GetComponent<Button>().onClick; object obj = <>c.<>9__35_0; if (obj == null) { UnityAction val3 = delegate { _confirmPanel.SetActive(false); RefreshDimOverlay(); }; <>c.<>9__35_0 = val3; obj = (object)val3; } ((UnityEvent)onClick).AddListener((UnityAction)obj); } private static void OnConfirmYes() { _confirmPanel.SetActive(false); RefreshDimOverlay(); _confirmAction?.Invoke(); _confirmAction = null; } private static void EnsureDimOverlay() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_dimOverlay != (Object)null)) { _dimOverlay = new GameObject("DimOverlay", new Type[2] { typeof(RectTransform), typeof(Image) }); _dimOverlay.transform.SetParent(GUIManager.CustomGUIFront.transform, false); RectTransform component = _dimOverlay.GetComponent<RectTransform>(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; Image component2 = _dimOverlay.GetComponent<Image>(); ((Graphic)component2).color = new Color(0f, 0f, 0f, 0.6f); ((Graphic)component2).raycastTarget = false; _dimOverlay.SetActive(false); } } private static void ShowOverlayBehind(GameObject panelToShow) { EnsureDimOverlay(); _dimOverlay.SetActive(true); _dimOverlay.transform.SetAsLastSibling(); panelToShow.SetActive(true); panelToShow.transform.SetAsLastSibling(); } private static void RefreshDimOverlay() { if (!((Object)(object)_dimOverlay == (Object)null)) { GameObject val = null; if ((Object)(object)_confirmPanel != (Object)null && _confirmPanel.activeSelf) { val = _confirmPanel; } else if ((Object)(object)_renamePanel != (Object)null && _renamePanel.activeSelf) { val = _renamePanel; } else if ((Object)(object)_addItemPanel != (Object)null && _addItemPanel.activeSelf) { val = _addItemPanel; } if ((Object)(object)val != (Object)null) { _dimOverlay.SetActive(true); _dimOverlay.transform.SetAsLastSibling(); val.transform.SetAsLastSibling(); } else { _dimOverlay.SetActive(false); } } } private static void ShowRenamePanel() { if (!Object.op_Implicit((Object)(object)_renamePanel)) { BuildRenamePanel(); } _renameInputGO.GetComponent<InputField>().text = _currentStall.GetShopName(); ShowOverlayBehind(_renamePanel); } private static void BuildRenamePanel() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00eb: 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_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Expected O, but got Unknown //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Expected O, but got Unknown _renamePanel = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), 380f, 220f, true); _renamePanel.SetActive(false); GUIManager.Instance.CreateText("Rename Shop", _renamePanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -30f), GUIManager.Instance.AveriaSerifBold, 20, GUIManager.Instance.ValheimOrange, true, Color.black, 300f, 30f, false).GetComponent<Text>().alignment = (TextAnchor)4; _renameInputGO = CreateInputField(_renamePanel.transform, new Vector2(190f, 30f), 260f, 32f, "", (ContentType)0); GameObject val = CreateButtonNoSfx("Save", _renamePanel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(-80f, 35f), 130f, 38f); ((UnityEvent)val.GetComponent<Button>().onClick).AddListener(new UnityAction(OnConfirmRename)); GameObject val2 = CreateButtonNoSfx("Cancel", _renamePanel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(80f, 35f), 130f, 38f); ButtonClickedEvent onClick = val2.GetComponent<Button>().onClick; object obj = <>c.<>9__41_0; if (obj == null) { UnityAction val3 = delegate { _renamePanel.SetActive(false); RefreshDimOverlay(); }; <>c.<>9__41_0 = val3; obj = (object)val3; } ((UnityEvent)onClick).AddListener((UnityAction)obj); } private static void OnConfirmRename() { string text = _renameInputGO.GetComponent<InputField>().text; if (string.IsNullOrWhiteSpace(text)) { ShowError("Enter a shop name."); return; } _currentStall.SetShopName(text); ShowError(""); _renamePanel.SetActive(false); RefreshDimOverlay(); } private static void ShowAddItemPanel() { if (!Object.op_Implicit((Object)(object)_addItemPanel)) { BuildAddItemPanel(); } RefreshAddItemList(); ShowOverlayBehind(_addItemPanel); } private static void BuildAddItemPanel() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Expected O, but got Unknown _addItemPanel = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), 480f, 480f, true); _addItemPanel.SetActive(false); GUIManager.Instance.CreateText("Add Item From Your Inventory", _addItemPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -30f), GUIManager.Instance.AveriaSerifBold, 18, GUIManager.Instance.ValheimOrange, true, Color.black, 420f, 30f, false).GetComponent<Text>().alignment = (TextAnchor)4; GameObject val = GUIManager.Instance.CreateScrollView(_addItemPanel.transform, false, true, 8f, 20f, GUIManager.Instance.ValheimScrollbarHandleColorBlock, new Color(0.1568628f, 0.1019608f, 0.0627451f, 1f), 420f, 340f); ((RectTransform)val.transform).anchoredPosition = new Vector2(0f, 10f); ((Object)val).name = "InventoryScrollView"; DisableContentLayoutGroup(val.transform.Find("Scroll View/Viewport/Content")); SetScrollSensitivity(val, 150f); GameObject val2 = CreateButtonNoSfx("Close", _addItemPanel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(0f, 30f), 150f, 40f); ButtonClickedEvent onClick = val2.GetComponent<Button>().onClick; object obj = <>c.<>9__44_0; if (obj == null) { UnityAction val3 = delegate { _addItemPanel.SetActive(false); RefreshDimOverlay(); }; <>c.<>9__44_0 = val3; obj = (object)val3; } ((UnityEvent)onClick).AddListener((UnityAction)obj); } private static void RefreshAddItemList() { //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_addItemPanel == (Object)null) { return; } Transform val = _addItemPanel.transform.Find("InventoryScrollView/Scroll View/Viewport/Content"); if ((Object)(object)val == (Object)null) { return; } for (int num = val.childCount - 1; num >= 0; num--) { Object.Destroy((Object)(object)((Component)val.GetChild(num)).gameObject); } List<string> list = new List<string>(); Dictionary<string, int> dictionary = new Dictionary<string, int>(); Dictionary<string, Sprite> dictionary2 = new Dictionary<string, Sprite>(); Dictionary<string, string> dictionary3 = new Dictionary<string, string>(); foreach (ItemData allItem in ((Humanoid)_currentOwner).GetInventory().GetAllItems()) { string name = allItem.m_shared.m_name; if (!dictionary.ContainsKey(name)) { dictionary[name] = 0; dictionary2[name] = allItem.GetIcon(); dictionary3[name] = FormatToken(allItem.m_shared.m_name); list.Add(name); } dictionary[name] += allItem.m_stack; } if (list.Count == 0) { GUIManager.Instance.CreateText("Your inventory is empty.", val, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -20f), GUIManager.Instance.AveriaSerifBold, 14, GUIManager.Instance.ValheimOrange, true, Color.black, 380f, 30f, false); return; } int num2 = 0; foreach (string item in list) { CreateInventoryRow(val, item, dictionary3[item], dictionary2[item], dictionary[item], num2); num2++; } SetContentHeight(val, num2, 62f); } private static void CreateInventoryRow(Transform content, string token, string displayName, Sprite icon, int available, int rowIndex) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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) //I