Decompiled source of ChestContents v1.1.0

ChestContents.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ChestContents.Commands;
using ChestContents.Effects;
using ChestContents.Managers;
using ChestContents.Models;
using ChestContents.Patches;
using ChestContents.UI;
using HarmonyLib;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ChestContents")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ChestContents")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("17DB9714-F030-4255-B20B-4B37B53FA521")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.1.0.0")]
namespace ChestContents.UI
{
	public class ConfigPanelManager : MonoBehaviour
	{
		private GameObject panel;

		private InputField radiusInputField;

		private Toggle verticalMarkerToggle;

		private InputField markerHeightInputField;

		private bool isOpen;

		private GameObject previewPanel;

		private Toggle previewToggle;

		private bool previewEnabled;

		private const int PlayerPreviewEffectId = -999;

		private ActionableEffect previewEffect;

		private Vector3? previewEffectOffset;

		private GameObject playerVerticalIndicator;

		private void Awake()
		{
			Debug.Log((object)"ConfigPanelManager Awake called");
			previewEffect = new ActionableEffect("vfx_ExtensionConnection");
		}

		public void ShowPanel()
		{
			if ((Object)(object)panel == (Object)null)
			{
				CreatePanel();
			}
			panel.SetActive(true);
			radiusInputField.text = ChestContentsPlugin.ChestSearchRadius.Value.ToString();
			if ((Object)(object)verticalMarkerToggle != (Object)null)
			{
				verticalMarkerToggle.isOn = ChestContentsPlugin.EnableVerticalMarker.Value;
			}
			if ((Object)(object)markerHeightInputField != (Object)null)
			{
				markerHeightInputField.text = ChestContentsPlugin.VerticalMarkerHeight.Value.ToString();
			}
			ShowPreviewPanel();
		}

		public void HidePanel()
		{
			if ((Object)(object)panel != (Object)null)
			{
				panel.SetActive(false);
			}
			HidePreviewPanel();
			previewEffect.ClearEffectForTarget(-999);
			previewEffectOffset = null;
			if ((Object)(object)playerVerticalIndicator != (Object)null)
			{
				Object.Destroy((Object)(object)playerVerticalIndicator);
				playerVerticalIndicator = null;
			}
		}

		public void ShowPreviewPanel()
		{
			if ((Object)(object)previewPanel == (Object)null)
			{
				CreatePreviewPanel();
			}
			previewPanel.SetActive(true);
			if ((Object)(object)previewToggle != (Object)null)
			{
				previewToggle.isOn = previewEnabled;
			}
		}

		public void HidePreviewPanel()
		{
			if ((Object)(object)previewPanel != (Object)null)
			{
				previewPanel.SetActive(false);
			}
		}

		private void Update()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Expected O, but got Unknown
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			if (previewEnabled && (Object)(object)Player.m_localPlayer != (Object)null && previewEffect != null)
			{
				float num = 1f;
				Vector3 val = ((Component)Player.m_localPlayer).transform.position + new Vector3(0f, num, 0f);
				if (previewEffectOffset.HasValue)
				{
					Vector3 val2 = val - previewEffectOffset.Value;
					if (!(((Vector3)(ref val2)).sqrMagnitude > 0.01f))
					{
						goto IL_00a0;
					}
				}
				previewEffect.ShowEffectForTarget(val, Quaternion.identity, -999);
				previewEffectOffset = val;
				goto IL_00a0;
			}
			if ((Object)(object)playerVerticalIndicator != (Object)null)
			{
				playerVerticalIndicator.SetActive(false);
			}
			return;
			IL_00a0:
			if (ChestContentsPlugin.EnableVerticalMarker.Value)
			{
				if ((Object)(object)playerVerticalIndicator == (Object)null)
				{
					playerVerticalIndicator = GameObject.CreatePrimitive((PrimitiveType)2);
					((Object)playerVerticalIndicator).name = "PlayerVerticalIndicator";
					Object.Destroy((Object)(object)playerVerticalIndicator.GetComponent<Collider>());
					Material val3 = new Material(Shader.Find("Sprites/Default"));
					val3.color = new Color(1f, 0.5f, 0f, 0.5f);
					playerVerticalIndicator.GetComponent<Renderer>().material = val3;
				}
				float value = ChestContentsPlugin.VerticalMarkerHeight.Value;
				playerVerticalIndicator.transform.position = ((Component)Player.m_localPlayer).transform.position + new Vector3(0f, value / 2f, 0f);
				playerVerticalIndicator.transform.localScale = new Vector3(0.15f, value / 2f, 0.15f);
				playerVerticalIndicator.transform.rotation = Quaternion.identity;
				playerVerticalIndicator.SetActive(true);
			}
			else if ((Object)(object)playerVerticalIndicator != (Object)null)
			{
				playerVerticalIndicator.SetActive(false);
			}
		}

		private void TogglePanel()
		{
			isOpen = !isOpen;
			Debug.Log((object)$"Config panel set active: {isOpen}");
			if (isOpen)
			{
				ShowPanel();
			}
			else
			{
				HidePanel();
			}
		}

		private void CreatePanel()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Expected O, but got Unknown
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Expected O, but got Unknown
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Expected O, but got Unknown
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Expected O, but got Unknown
			//IL_01eb: 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_0200: Expected O, but got Unknown
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Expected O, but got Unknown
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: 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_0297: 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_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0407: Unknown result type (might be due to invalid IL or missing references)
			//IL_0445: Unknown result type (might be due to invalid IL or missing references)
			//IL_0465: Unknown result type (might be due to invalid IL or missing references)
			//IL_047a: Unknown result type (might be due to invalid IL or missing references)
			//IL_048f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ce: Expected O, but got Unknown
			//IL_0518: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Object.FindObjectOfType<EventSystem>() == (Object)null)
			{
				GameObject val2 = new GameObject("EventSystem");
				val2.AddComponent<EventSystem>();
				val2.AddComponent<StandaloneInputModule>();
				Object.DontDestroyOnLoad((Object)val2);
			}
			panel = new GameObject("ChestContentsConfigPanel");
			Canvas obj = panel.AddComponent<Canvas>();
			obj.renderMode = (RenderMode)0;
			obj.overrideSorting = true;
			obj.sortingOrder = 1000;
			panel.AddComponent<CanvasScaler>();
			panel.AddComponent<GraphicRaycaster>();
			GameObject val3 = new GameObject("BG");
			val3.transform.SetParent(panel.transform, false);
			((Graphic)val3.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.85f);
			RectTransform component = val3.GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(400f, 200f);
			component.anchoredPosition = new Vector2(0f, 0f);
			val3.transform.SetAsLastSibling();
			VerticalLayoutGroup obj2 = val3.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)obj2).childAlignment = (TextAnchor)0;
			((HorizontalOrVerticalLayoutGroup)obj2).spacing = 10f;
			((LayoutGroup)obj2).padding = new RectOffset(15, 15, 15, 15);
			((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = false;
			GameObject val4 = new GameObject("ContentContainer");
			val4.transform.SetParent(val3.transform, false);
			HorizontalLayoutGroup obj3 = val4.AddComponent<HorizontalLayoutGroup>();
			((LayoutGroup)obj3).childAlignment = (TextAnchor)0;
			((HorizontalOrVerticalLayoutGroup)obj3).spacing = 10f;
			((HorizontalOrVerticalLayoutGroup)obj3).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj3).childForceExpandHeight = false;
			val4.GetComponent<RectTransform>().sizeDelta = new Vector2(370f, 100f);
			GameObject val5 = new GameObject("LeftCol");
			val5.transform.SetParent(val4.transform, false);
			VerticalLayoutGroup obj4 = val5.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)obj4).childAlignment = (TextAnchor)0;
			((HorizontalOrVerticalLayoutGroup)obj4).spacing = 18f;
			((HorizontalOrVerticalLayoutGroup)obj4).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj4).childForceExpandHeight = false;
			((LayoutGroup)obj4).padding = new RectOffset(0, 10, 0, 0);
			val5.GetComponent<RectTransform>().sizeDelta = new Vector2(220f, 100f);
			GameObject val6 = new GameObject("RightCol");
			val6.transform.SetParent(val4.transform, false);
			VerticalLayoutGroup obj5 = val6.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)obj5).childAlignment = (TextAnchor)2;
			((HorizontalOrVerticalLayoutGroup)obj5).spacing = 18f;
			((HorizontalOrVerticalLayoutGroup)obj5).childForceExpandWidth = false;
			((HorizontalOrVerticalLayoutGroup)obj5).childForceExpandHeight = false;
			((LayoutGroup)obj5).padding = new RectOffset(10, 0, 0, 0);
			val6.GetComponent<RectTransform>().sizeDelta = new Vector2(120f, 100f);
			GameObject val7 = new GameObject("VerticalDivider");
			val7.transform.SetParent(val4.transform, false);
			((Graphic)val7.AddComponent<Image>()).color = new Color(1f, 1f, 1f, 0.3f);
			RectTransform component2 = val7.GetComponent<RectTransform>();
			component2.sizeDelta = new Vector2(2f, 1000f);
			component2.anchorMin = new Vector2(0.5f, 0f);
			component2.anchorMax = new Vector2(0.5f, 1f);
			component2.anchoredPosition = Vector2.zero;
			AddLabelToColumn(val5.transform, "Chest Search Radius (m):");
			AddLabelToColumn(val5.transform, "Enable Vertical Marker");
			AddLabelToColumn(val5.transform, "Vertical Marker Height:");
			AddInputToColumn(val6.transform);
			AddVerticalMarkerToggleToColumn(val6.transform);
			AddMarkerHeightInputToColumn(val6.transform);
			((UnityEvent<string>)(object)radiusInputField.onEndEdit).AddListener((UnityAction<string>)delegate(string val)
			{
				if (int.TryParse(val, out var result2))
				{
					ChestContentsPlugin.ChestSearchRadius.Value = result2;
					if (previewEnabled)
					{
						ApplyLivePreview();
					}
				}
				else
				{
					radiusInputField.text = ChestContentsPlugin.ChestSearchRadius.Value.ToString();
				}
			});
			((UnityEvent<bool>)(object)verticalMarkerToggle.onValueChanged).AddListener((UnityAction<bool>)delegate(bool val)
			{
				ChestContentsPlugin.EnableVerticalMarker.Value = val;
			});
			((UnityEvent<string>)(object)markerHeightInputField.onEndEdit).AddListener((UnityAction<string>)delegate(string val)
			{
				if (float.TryParse(val, out var result))
				{
					ChestContentsPlugin.VerticalMarkerHeight.Value = result;
				}
			});
			GameObject val8 = new GameObject("FlexibleSpacer");
			val8.transform.SetParent(val3.transform, false);
			val8.AddComponent<LayoutElement>().flexibleHeight = 1f;
			GameObject val9 = new GameObject("Subtext");
			val9.transform.SetParent(val3.transform, false);
			Text obj6 = val9.AddComponent<Text>();
			obj6.text = "Tip: Open your inventory/crafting window to change these options. (This will allow using the mouse)";
			obj6.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			obj6.fontSize = 14;
			((Graphic)obj6).color = new Color(1f, 1f, 1f, 0.7f);
			obj6.alignment = (TextAnchor)4;
			RectTransform component3 = val9.GetComponent<RectTransform>();
			component3.sizeDelta = new Vector2(370f, 24f);
			component3.anchorMin = new Vector2(0.5f, 0f);
			component3.anchorMax = new Vector2(0.5f, 0f);
			component3.pivot = new Vector2(0.5f, 0f);
			component3.anchoredPosition = new Vector2(0f, 10f);
			GameObject val10 = new GameObject("CloseContainer");
			val10.transform.SetParent(val3.transform, false);
			HorizontalLayoutGroup obj7 = val10.AddComponent<HorizontalLayoutGroup>();
			((LayoutGroup)obj7).childAlignment = (TextAnchor)4;
			((HorizontalOrVerticalLayoutGroup)obj7).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj7).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)obj7).spacing = 0f;
			val10.GetComponent<RectTransform>().sizeDelta = new Vector2(400f, 40f);
			CreateCloseButton(val10.transform);
		}

		private void CreatePreviewPanel()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Expected O, but got Unknown
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Expected O, but got Unknown
			//IL_01a0: 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_01b5: Expected O, but got Unknown
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: 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_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			previewPanel = new GameObject("ChestContentsPreviewPanel");
			Canvas obj = previewPanel.AddComponent<Canvas>();
			obj.renderMode = (RenderMode)0;
			obj.overrideSorting = true;
			obj.sortingOrder = 1001;
			previewPanel.AddComponent<CanvasScaler>();
			previewPanel.AddComponent<GraphicRaycaster>();
			GameObject val2 = new GameObject("BG");
			val2.transform.SetParent(previewPanel.transform, false);
			((Graphic)val2.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.85f);
			RectTransform component = val2.GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(300f, 100f);
			component.anchoredPosition = new Vector2(0f, -220f);
			VerticalLayoutGroup obj2 = val2.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)obj2).childAlignment = (TextAnchor)1;
			((HorizontalOrVerticalLayoutGroup)obj2).spacing = 10f;
			((LayoutGroup)obj2).padding = new RectOffset(15, 15, 15, 15);
			((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = false;
			GameObject val3 = new GameObject("Label");
			val3.transform.SetParent(val2.transform, false);
			Text obj3 = val3.AddComponent<Text>();
			obj3.text = "Preview Config Options";
			obj3.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			obj3.fontSize = 18;
			((Graphic)obj3).color = Color.white;
			obj3.alignment = (TextAnchor)4;
			val3.GetComponent<RectTransform>().sizeDelta = new Vector2(220f, 24f);
			GameObject val4 = new GameObject("PreviewToggle");
			val4.transform.SetParent(val2.transform, false);
			previewToggle = val4.AddComponent<Toggle>();
			val4.GetComponent<RectTransform>().sizeDelta = new Vector2(32f, 32f);
			GameObject val5 = new GameObject("Background");
			val5.transform.SetParent(val4.transform, false);
			Image val6 = val5.AddComponent<Image>();
			((Graphic)val6).color = Color.gray;
			val5.GetComponent<RectTransform>().sizeDelta = new Vector2(20f, 20f);
			GameObject val7 = new GameObject("Checkmark");
			val7.transform.SetParent(val5.transform, false);
			Image val8 = val7.AddComponent<Image>();
			((Graphic)val8).color = Color.green;
			RectTransform component2 = val7.GetComponent<RectTransform>();
			component2.sizeDelta = new Vector2(16f, 16f);
			component2.anchorMin = new Vector2(0.5f, 0.5f);
			component2.anchorMax = new Vector2(0.5f, 0.5f);
			component2.pivot = new Vector2(0.5f, 0.5f);
			component2.anchoredPosition = Vector2.zero;
			((Selectable)previewToggle).targetGraphic = (Graphic)(object)val6;
			previewToggle.graphic = (Graphic)(object)val8;
			previewToggle.isOn = previewEnabled;
			((UnityEvent<bool>)(object)previewToggle.onValueChanged).AddListener((UnityAction<bool>)delegate(bool val)
			{
				previewEnabled = val;
				if (previewEnabled)
				{
					ApplyLivePreview();
				}
			});
		}

		private void AddLabelToColumn(Transform parent, string textValue)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Label");
			val.transform.SetParent(parent, false);
			Text obj = val.AddComponent<Text>();
			obj.text = textValue;
			obj.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			obj.fontSize = 18;
			((Graphic)obj).color = Color.white;
			obj.alignment = (TextAnchor)3;
			val.GetComponent<RectTransform>().sizeDelta = new Vector2(220f, 24f);
		}

		private void AddInputToColumn(Transform parent)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: 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_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: 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_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			GameObject val2 = new GameObject("RadiusInputField");
			val2.transform.SetParent(parent, false);
			Image val3 = val2.AddComponent<Image>();
			((Graphic)val3).color = Color.white;
			radiusInputField = val2.AddComponent<InputField>();
			((Selectable)radiusInputField).targetGraphic = (Graphic)(object)val3;
			RectTransform component = val2.GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(0f, 32f);
			component.anchorMin = new Vector2(0f, 0f);
			component.anchorMax = new Vector2(1f, 1f);
			component.pivot = new Vector2(1f, 0.5f);
			component.anchoredPosition = Vector2.zero;
			LayoutElement obj = val2.AddComponent<LayoutElement>();
			obj.minWidth = 100f;
			obj.flexibleWidth = 1f;
			GameObject val4 = new GameObject("Text");
			val4.transform.SetParent(val2.transform, false);
			Text val5 = val4.AddComponent<Text>();
			val5.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			val5.fontSize = 18;
			((Graphic)val5).color = Color.black;
			val5.alignment = (TextAnchor)3;
			RectTransform component2 = val4.GetComponent<RectTransform>();
			((Transform)component2).SetAsLastSibling();
			component2.anchorMin = new Vector2(0f, 0f);
			component2.anchorMax = new Vector2(1f, 1f);
			component2.offsetMin = new Vector2(4f, 0f);
			component2.offsetMax = new Vector2(-4f, 0f);
			component2.pivot = new Vector2(0.5f, 0.5f);
			GameObject val6 = new GameObject("Placeholder");
			val6.transform.SetParent(val2.transform, false);
			Text val7 = val6.AddComponent<Text>();
			val7.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			val7.fontSize = 18;
			((Graphic)val7).color = new Color(0.5f, 0.5f, 0.5f, 0.75f);
			val7.text = "Radius (m)";
			val7.alignment = (TextAnchor)3;
			RectTransform component3 = val6.GetComponent<RectTransform>();
			((Transform)component3).SetAsLastSibling();
			component3.anchorMin = new Vector2(0f, 0f);
			component3.anchorMax = new Vector2(1f, 1f);
			component3.offsetMin = new Vector2(4f, 0f);
			component3.offsetMax = new Vector2(-4f, 0f);
			component3.pivot = new Vector2(0.5f, 0.5f);
			radiusInputField.textComponent = val5;
			radiusInputField.placeholder = (Graphic)(object)val7;
			((UnityEvent<string>)(object)radiusInputField.onEndEdit).AddListener((UnityAction<string>)delegate(string val)
			{
				if (int.TryParse(val, out var result))
				{
					ChestContentsPlugin.ChestSearchRadius.Value = result;
					if (previewEnabled)
					{
						ApplyLivePreview();
					}
				}
				else
				{
					radiusInputField.text = ChestContentsPlugin.ChestSearchRadius.Value.ToString();
				}
			});
		}

		private void AddVerticalMarkerToggleToColumn(Transform parent)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: 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_013f: Unknown result type (might be due to invalid IL or missing references)
			GameObject val2 = new GameObject("VerticalMarkerToggle");
			val2.transform.SetParent(parent, false);
			verticalMarkerToggle = val2.AddComponent<Toggle>();
			val2.GetComponent<RectTransform>().sizeDelta = new Vector2(32f, 32f);
			LayoutElement obj = val2.AddComponent<LayoutElement>();
			obj.minHeight = 32f;
			obj.minWidth = 32f;
			obj.preferredHeight = 32f;
			obj.preferredWidth = 32f;
			GameObject val3 = new GameObject("Background");
			val3.transform.SetParent(val2.transform, false);
			Image val4 = val3.AddComponent<Image>();
			((Graphic)val4).color = Color.gray;
			val3.GetComponent<RectTransform>().sizeDelta = new Vector2(20f, 20f);
			GameObject val5 = new GameObject("Checkmark");
			val5.transform.SetParent(val3.transform, false);
			Image val6 = val5.AddComponent<Image>();
			((Graphic)val6).color = Color.green;
			RectTransform component = val5.GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(16f, 16f);
			component.anchorMin = new Vector2(0.5f, 0.5f);
			component.anchorMax = new Vector2(0.5f, 0.5f);
			component.pivot = new Vector2(0.5f, 0.5f);
			component.anchoredPosition = Vector2.zero;
			((Selectable)verticalMarkerToggle).targetGraphic = (Graphic)(object)val4;
			verticalMarkerToggle.graphic = (Graphic)(object)val6;
			verticalMarkerToggle.isOn = ChestContentsPlugin.EnableVerticalMarker.Value;
			((UnityEvent<bool>)(object)verticalMarkerToggle.onValueChanged).AddListener((UnityAction<bool>)delegate(bool val)
			{
				ChestContentsPlugin.EnableVerticalMarker.Value = val;
			});
		}

		private void AddMarkerHeightInputToColumn(Transform parent)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: 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_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: 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_0153: 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_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: 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_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val2 = new GameObject("MarkerHeightInputField");
			val2.transform.SetParent(parent, false);
			Image val3 = val2.AddComponent<Image>();
			((Graphic)val3).color = Color.white;
			markerHeightInputField = val2.AddComponent<InputField>();
			((Selectable)markerHeightInputField).targetGraphic = (Graphic)(object)val3;
			val2.GetComponent<RectTransform>().sizeDelta = new Vector2(0f, 32f);
			LayoutElement obj = val2.AddComponent<LayoutElement>();
			obj.minWidth = 100f;
			obj.flexibleWidth = 1f;
			GameObject val4 = new GameObject("Text");
			val4.transform.SetParent(val2.transform, false);
			Text val5 = val4.AddComponent<Text>();
			val5.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			val5.fontSize = 18;
			((Graphic)val5).color = Color.black;
			val5.alignment = (TextAnchor)3;
			RectTransform component = val4.GetComponent<RectTransform>();
			((Transform)component).SetAsLastSibling();
			component.anchorMin = new Vector2(0f, 0f);
			component.anchorMax = new Vector2(1f, 1f);
			component.offsetMin = new Vector2(4f, 0f);
			component.offsetMax = new Vector2(-4f, 0f);
			component.pivot = new Vector2(0.5f, 0.5f);
			GameObject val6 = new GameObject("Placeholder");
			val6.transform.SetParent(val2.transform, false);
			Text val7 = val6.AddComponent<Text>();
			val7.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			val7.fontSize = 18;
			((Graphic)val7).color = new Color(0.5f, 0.5f, 0.5f, 0.75f);
			val7.text = "Height (m)";
			val7.alignment = (TextAnchor)3;
			RectTransform component2 = val6.GetComponent<RectTransform>();
			((Transform)component2).SetAsLastSibling();
			component2.anchorMin = new Vector2(0f, 0f);
			component2.anchorMax = new Vector2(1f, 1f);
			component2.offsetMin = new Vector2(4f, 0f);
			component2.offsetMax = new Vector2(-4f, 0f);
			component2.pivot = new Vector2(0.5f, 0.5f);
			markerHeightInputField.textComponent = val5;
			markerHeightInputField.placeholder = (Graphic)(object)val7;
			((UnityEvent<string>)(object)markerHeightInputField.onEndEdit).AddListener((UnityAction<string>)delegate(string val)
			{
				if (float.TryParse(val, out var result))
				{
					ChestContentsPlugin.VerticalMarkerHeight.Value = result;
				}
				else
				{
					markerHeightInputField.text = ChestContentsPlugin.VerticalMarkerHeight.Value.ToString();
				}
			});
		}

		private void CreateCloseButton(Transform parent)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Expected O, but got Unknown
			Debug.Log((object)"Creating Close Button...");
			try
			{
				GameObject val = new GameObject("CloseButton");
				val.transform.SetParent(parent, false);
				Image val2 = val.AddComponent<Image>();
				((Graphic)val2).color = new Color(0.2f, 0.2f, 0.2f, 1f);
				Button obj = val.AddComponent<Button>();
				((Selectable)obj).targetGraphic = (Graphic)(object)val2;
				RectTransform component = val.GetComponent<RectTransform>();
				component.sizeDelta = new Vector2(120f, 36f);
				component.anchorMin = new Vector2(0.5f, 0.5f);
				component.anchorMax = new Vector2(0.5f, 0.5f);
				component.pivot = new Vector2(0.5f, 0.5f);
				component.anchoredPosition = Vector2.zero;
				GameObject val3 = new GameObject("Text");
				val3.transform.SetParent(val.transform, false);
				Text obj2 = val3.AddComponent<Text>();
				obj2.text = "Close";
				obj2.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
				obj2.fontSize = 18;
				((Graphic)obj2).color = Color.white;
				obj2.alignment = (TextAnchor)4;
				RectTransform component2 = val3.GetComponent<RectTransform>();
				if ((Object)(object)component2 == (Object)null)
				{
					Debug.LogError((object)"closeTextRect is null!");
				}
				else
				{
					component2.sizeDelta = new Vector2(120f, 36f);
					component2.anchoredPosition = Vector2.zero;
				}
				((UnityEvent)obj.onClick).AddListener((UnityAction)delegate
				{
					HidePanel();
				});
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"Exception in CreateCloseButton: {arg}");
			}
		}

		private void ApplyLivePreview()
		{
			//IL_006a: 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_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Expected O, but got Unknown
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			previewEffect.ClearEffectForTarget(-999);
			previewEffectOffset = null;
			if ((Object)(object)playerVerticalIndicator != (Object)null)
			{
				Object.Destroy((Object)(object)playerVerticalIndicator);
				playerVerticalIndicator = null;
			}
			if (!previewEnabled)
			{
				return;
			}
			if ((Object)(object)Player.m_localPlayer != (Object)null)
			{
				float value = ChestContentsPlugin.VerticalMarkerHeight.Value;
				Vector3 position = ((Component)Player.m_localPlayer).transform.position;
				if (ChestContentsPlugin.EnableVerticalMarker.Value)
				{
					playerVerticalIndicator = GameObject.CreatePrimitive((PrimitiveType)2);
					((Object)playerVerticalIndicator).name = "PlayerVerticalIndicator";
					Object.Destroy((Object)(object)playerVerticalIndicator.GetComponent<Collider>());
					Material val = new Material(Shader.Find("Sprites/Default"));
					val.color = new Color(1f, 0.5f, 0f, 0.5f);
					playerVerticalIndicator.GetComponent<Renderer>().material = val;
					playerVerticalIndicator.transform.position = position + new Vector3(0f, value / 2f, 0f);
					playerVerticalIndicator.transform.localScale = new Vector3(0.15f, value / 2f, 0.15f);
					playerVerticalIndicator.transform.rotation = Quaternion.identity;
					playerVerticalIndicator.SetActive(true);
				}
				Vector3 val2 = position + new Vector3(0f, value, 0f);
				previewEffect.ShowEffectForTarget(val2, Quaternion.identity, -999);
				previewEffectOffset = val2;
			}
			Debug.Log((object)$"[ChestContents] Live preview applied: Radius={ChestContentsPlugin.ChestSearchRadius.Value}, VerticalMarker={ChestContentsPlugin.EnableVerticalMarker.Value}, MarkerHeight={ChestContentsPlugin.VerticalMarkerHeight.Value}");
		}
	}
	public static class PopupManager
	{
		public static void ShowSearchResultsPopup(string itemName, Vector3 chestPos, int quantity = -1)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Expected O, but got Unknown
			//IL_00e6: 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_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: 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_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: 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_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: 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_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: 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_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: 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_0304: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Player.m_localPlayer == (Object)null))
			{
				GameObject val = GameObject.Find("ChestContentsSearchPopup");
				if ((Object)(object)val != (Object)null)
				{
					Object.Destroy((Object)(object)val);
				}
				float num = Vector3.Distance(((Component)Player.m_localPlayer).transform.position, chestPos);
				string text = itemName;
				if (text.StartsWith("$"))
				{
					text = text.Substring(1);
				}
				text = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(text.Replace("_", " "));
				int num2 = Mathf.Clamp(Screen.height / 24, 18, 48);
				GameObject val2 = new GameObject("ChestContentsSearchPopup");
				Canvas obj = val2.AddComponent<Canvas>();
				obj.renderMode = (RenderMode)0;
				obj.sortingOrder = 1000;
				GameObject val3 = new GameObject("Panel");
				val3.transform.SetParent(val2.transform, false);
				((Graphic)val3.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.7f);
				RectTransform component = val3.GetComponent<RectTransform>();
				component.sizeDelta = new Vector2(420f, (float)(num2 * 2 + 32));
				component.anchorMin = new Vector2(0f, 0.5f);
				component.anchorMax = new Vector2(0f, 0.5f);
				component.pivot = new Vector2(0f, 0.5f);
				component.anchoredPosition = new Vector2(20f, 0f);
				GameObject val4 = new GameObject("Text");
				val4.transform.SetParent(val3.transform, false);
				Text obj2 = val4.AddComponent<Text>();
				obj2.text = text + ((quantity > 0) ? $" x{quantity}" : "");
				obj2.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
				obj2.fontSize = num2;
				((Graphic)obj2).color = Color.white;
				obj2.alignment = (TextAnchor)0;
				RectTransform component2 = val4.GetComponent<RectTransform>();
				component2.sizeDelta = new Vector2(400f, (float)(num2 + 8));
				component2.anchorMin = new Vector2(0f, 1f);
				component2.anchorMax = new Vector2(0f, 1f);
				component2.pivot = new Vector2(0f, 1f);
				component2.anchoredPosition = new Vector2(12f, -8f);
				GameObject val5 = new GameObject("Distance");
				val5.transform.SetParent(val3.transform, false);
				Text obj3 = val5.AddComponent<Text>();
				obj3.text = $"Distance: {num:F1} m";
				obj3.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
				obj3.fontSize = num2 - 4;
				((Graphic)obj3).color = Color.yellow;
				obj3.alignment = (TextAnchor)6;
				RectTransform component3 = val5.GetComponent<RectTransform>();
				component3.sizeDelta = new Vector2(400f, (float)(num2 + 8));
				component3.anchorMin = new Vector2(0f, 0f);
				component3.anchorMax = new Vector2(0f, 0f);
				component3.pivot = new Vector2(0f, 0f);
				component3.anchoredPosition = new Vector2(12f, 8f);
				Object.Destroy((Object)(object)val2, 4f);
			}
		}

		public static void ShowMetaPopup(string meta)
		{
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Expected O, but got Unknown
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Expected O, but got Unknown
			//IL_0141: 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)
			//IL_016c: 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_0196: 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_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: 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_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Expected O, but got Unknown
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ef: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Player.m_localPlayer == (Object)null))
			{
				GameObject val = GameObject.Find("ChestContentsMetaPopup");
				if ((Object)(object)val != (Object)null)
				{
					Object.Destroy((Object)(object)val);
				}
				int num = Mathf.Clamp(Screen.height / 36, 14, 32);
				int num2 = ((meta == null) ? 1 : meta.Split(new char[1] { '\n' }).Length);
				string[] obj = meta?.Split(new char[1] { '\n' }) ?? new string[1] { "" };
				int num3 = 0;
				string[] array = obj;
				foreach (string text in array)
				{
					num3 = Mathf.Max(num3, text.Length);
				}
				float num4 = Mathf.Clamp(20f + (float)Mathf.Max(num3, 32) * ((float)num * 0.6f), 260f, 600f);
				float num5 = num * num2 + 48 + num * 4 + 16;
				GameObject val2 = new GameObject("ChestContentsMetaPopup");
				Canvas obj2 = val2.AddComponent<Canvas>();
				obj2.renderMode = (RenderMode)0;
				obj2.sortingOrder = 1000;
				GameObject val3 = new GameObject("Panel");
				val3.transform.SetParent(val2.transform, false);
				((Graphic)val3.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.7f);
				RectTransform component = val3.GetComponent<RectTransform>();
				component.sizeDelta = new Vector2(num4, num5);
				component.anchorMin = new Vector2(0f, 0.5f);
				component.anchorMax = new Vector2(0f, 0.5f);
				component.pivot = new Vector2(0f, 0.5f);
				component.anchoredPosition = new Vector2(20f, 0f);
				GameObject val4 = new GameObject("Text");
				val4.transform.SetParent(val3.transform, false);
				Text obj3 = val4.AddComponent<Text>();
				obj3.text = meta;
				obj3.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
				obj3.fontSize = num;
				((Graphic)obj3).color = Color.white;
				obj3.alignment = (TextAnchor)0;
				RectTransform component2 = val4.GetComponent<RectTransform>();
				component2.sizeDelta = new Vector2(num4 - 20f, (float)(num * num2 + 8));
				component2.anchorMin = new Vector2(0f, 1f);
				component2.anchorMax = new Vector2(0f, 1f);
				component2.pivot = new Vector2(0f, 1f);
				component2.anchoredPosition = new Vector2(12f, -8f);
				GameObject val5 = new GameObject("ConfigTable");
				val5.transform.SetParent(val3.transform, false);
				Text val6 = val5.AddComponent<Text>();
				string[] obj4 = new string[5] { "<b>Current Config</b>\nVertical Marker: <color=yellow>", null, null, null, null };
				ConfigEntry<bool> enableVerticalMarker = ChestContentsPlugin.EnableVerticalMarker;
				obj4[1] = ((enableVerticalMarker != null && enableVerticalMarker.Value) ? "Enabled" : "Disabled");
				obj4[2] = "</color>\n";
				obj4[3] = $"Marker Height: <color=yellow>{ChestContentsPlugin.VerticalMarkerHeight?.Value:F1}</color>\n";
				obj4[4] = $"Search Radius: <color=yellow>{ChestContentsPlugin.ChestSearchRadius?.Value}</color>";
				string text2 = string.Concat(obj4);
				val6.text = text2;
				val6.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
				val6.fontSize = num - 2;
				((Graphic)val6).color = Color.cyan;
				val6.alignment = (TextAnchor)0;
				val6.supportRichText = true;
				RectTransform component3 = val5.GetComponent<RectTransform>();
				component3.sizeDelta = new Vector2(num4 - 20f, (float)(num * 4 + 8));
				component3.anchorMin = new Vector2(0f, 1f);
				component3.anchorMax = new Vector2(0f, 1f);
				component3.pivot = new Vector2(0f, 1f);
				component3.anchoredPosition = new Vector2(12f, (float)(-8 - (num * num2 + 12)));
				Object.Destroy((Object)(object)val2, 4f);
			}
		}
	}
}
namespace ChestContents.Patches
{
	[HarmonyPatch(typeof(Container), "Interact")]
	public static class ContainerInteractPatch
	{
		public static void Postfix(Container __instance, Humanoid character, bool hold, bool alt, bool __result)
		{
			if (__result && ChestContentsPlugin.IndicatedList != null && ChestContentsPlugin.IndicatedList.ChestList.Count != 0)
			{
				ChestInfo chestInfo = ChestContentsPlugin.IndicatedList.ChestList[0];
				if (((Object)__instance).GetInstanceID() == chestInfo.InstanceID)
				{
					ChestContentsPlugin.IndicatedList.Clear();
				}
			}
		}
	}
	[HarmonyPatch]
	public static class ContainerPatch
	{
		[HarmonyReversePatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPatch(typeof(Container), "CheckAccess")]
		public static bool RunCheckAccess(Container container, long playerID)
		{
			throw new NotImplementedException("This is a reverse patch, please use the original method instead.");
		}
	}
}
namespace ChestContents.Models
{
	public class ChestInfo
	{
		public Vector3 Position { get; }

		public int InstanceID { get; }

		public Quaternion Rotation { get; }

		public List<ItemData> Contents { get; }

		public DateTime LastUpdated { get; }

		public int LastRevision { get; }

		public ChestInfo(Container container)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (!((Behaviour)container).enabled)
			{
				throw new Exception("Container is not enabled");
			}
			Position = ((Component)container).transform.position;
			Rotation = ((Component)container).transform.rotation;
			InstanceID = ((Object)container).GetInstanceID();
			Contents = container.GetInventory().GetAllItemsInGridOrder();
			LastUpdated = DateTime.Now;
			object value = Traverse.Create((object)container).Field("m_lastRevision").GetValue();
			if (value is int num)
			{
				LastRevision = num;
			}
			else if (value is long num2)
			{
				LastRevision = (int)num2;
			}
			else if (value is uint num3)
			{
				LastRevision = (int)num3;
			}
			else if (value is short num4)
			{
				LastRevision = num4;
			}
			else if (value is byte b)
			{
				LastRevision = b;
			}
			else
			{
				LastRevision = 0;
			}
		}

		public ChestInfo(Vector3 position, int instanceId, Quaternion rotation, List<ItemData> contents, DateTime lastUpdated, int lastRevision)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			Position = position;
			InstanceID = instanceId;
			Rotation = rotation;
			Contents = contents;
			LastUpdated = lastUpdated;
			LastRevision = lastRevision;
		}
	}
	public struct ItemLocationInfo
	{
		public string ItemName;

		public int Stack;

		public int ChestId;

		public Vector3 Position;
	}
}
namespace ChestContents.Managers
{
	[BepInPlugin("sticky.chestcontents", "ChestContents", "1.1.0")]
	public class ChestContentsPlugin : BaseUnityPlugin
	{
		private const string PluginGuid = "sticky.chestcontents";

		private const string PluginName = "ChestContents";

		private const string PluginVersion = "1.1.0";

		private const float InventoryCheckInterval = 0.5f;

		public static ManualLogSource Logger = Logger.CreateLogSource("ChestContents");

		private static readonly List<Container> Chests = new List<Container>();

		public static readonly Dictionary<int, ChestInfo> ChestInfoDict = new Dictionary<int, ChestInfo>();

		public static readonly Dictionary<string, List<ItemLocationInfo>> ItemNameIndex = new Dictionary<string, List<ItemLocationInfo>>();

		private static readonly Collider[] Colliders = (Collider[])(object)new Collider[10240];

		public static int LastTotalChestCount;

		private readonly Harmony _harmonyInstance = new Harmony("sticky.chestcontents");

		private CustomStatusEffect _chestIndexEffect;

		private float _lastCheckTime;

		private int _lastChestCount = -1;

		private int _lastInventoryHash;

		public static ConfigEntry<bool> EnableChestHighlighting;

		public static ConfigEntry<int> ChestSearchRadius;

		public static ConfigEntry<string> HighlightColor;

		public static ConfigEntry<bool> EnableVerticalMarker;

		public static ConfigEntry<float> VerticalMarkerHeight;

		public static ConfigPanelManager ConfigPanelManagerInstance;

		private bool _configPanelInitialized;

		private IChestScanner _chestScanner;

		private IChestIndexer _chestIndexer;

		public static IndicatedChestList IndicatedList { get; private set; }

		private void Awake()
		{
			EnableChestHighlighting = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableChestHighlighting", true, "Enable or disable chest highlighting.");
			ChestSearchRadius = ((BaseUnityPlugin)this).Config.Bind<int>("General", "ChestSearchRadius", 30, "Radius (in meters) to search for chests.");
			HighlightColor = ((BaseUnityPlugin)this).Config.Bind<string>("General", "HighlightColor", "yellow", "Color to use for highlighting chests.");
			EnableVerticalMarker = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableVerticalMarker", true, "Enable or disable the vertical marker.");
			VerticalMarkerHeight = ((BaseUnityPlugin)this).Config.Bind<float>("General", "VerticalMarkerHeight", 8f, "Height of the vertical marker.");
			_harmonyInstance.PatchAll(Assembly.GetExecutingAssembly());
			AddStatusEffect();
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new SearchChestsCommand(() => IndicatedList, () => ChestInfoDict, () => ItemNameIndex, () => LastTotalChestCount));
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new SearchChestsCommand(() => IndicatedList, () => ChestInfoDict, () => ItemNameIndex, () => LastTotalChestCount, "cs"));
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new SearchChestsCommand(() => IndicatedList, () => ChestInfoDict, () => ItemNameIndex, () => LastTotalChestCount, "sc"));
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new ConfigPanelCommand());
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new ConfigPanelCommand("cc"));
			_chestScanner = new ChestScanner();
			_chestIndexer = new ChestIndexer();
		}

		private void Update()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			if (!_configPanelInitialized && (Object)(object)Player.m_localPlayer != (Object)null)
			{
				GameObject val = new GameObject("ConfigPanelManager");
				ConfigPanelManagerInstance = val.AddComponent<ConfigPanelManager>();
				Object.DontDestroyOnLoad((Object)val);
				_configPanelInitialized = true;
			}
			if ((Object)(object)Player.m_localPlayer == (Object)null)
			{
				return;
			}
			if (IndicatedList == null)
			{
				IndicatedList = new IndicatedChestList(() => EnableVerticalMarker != null && EnableVerticalMarker.Value, () => (VerticalMarkerHeight == null) ? 3f : VerticalMarkerHeight.Value);
			}
			if (Time.time - _lastCheckTime > 0.5f)
			{
				_lastCheckTime = Time.time;
				int nearbyChestCount = _chestScanner.GetNearbyChestCount(((Component)Player.m_localPlayer).transform.position, 30f, Colliders, Player.m_localPlayer);
				int nearbyInventoryHash = _chestScanner.GetNearbyInventoryHash(((Component)Player.m_localPlayer).transform.position, 30f, Colliders, Player.m_localPlayer);
				int num = (LastTotalChestCount = _chestScanner.GetAllChestCount());
				if (nearbyChestCount != _lastChestCount || nearbyInventoryHash != _lastInventoryHash || num != _lastChestCount)
				{
					PopulateContainers();
					ParseChests();
					_lastChestCount = nearbyChestCount;
					_lastInventoryHash = nearbyInventoryHash;
				}
			}
			IndicatedList.RunEffects();
			SEMan sEMan = ((Character)Player.m_localPlayer).GetSEMan();
			StatusEffect statusEffect = _chestIndexEffect.StatusEffect;
			int count = ChestInfoDict.Count;
			if (statusEffect is SeChestIndex)
			{
				statusEffect.m_tooltip = count.ToString();
			}
			if (!Object.op_Implicit((Object)(object)sEMan.GetStatusEffect(_chestIndexEffect.StatusEffect.NameHash())))
			{
				sEMan.AddStatusEffect(_chestIndexEffect.StatusEffect, true, 0, 0f);
			}
		}

		private void PopulateContainers()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			Chests.Clear();
			foreach (Container item in _chestScanner.ScanNearbyChests(((Component)Player.m_localPlayer).transform.position, 30f, Colliders, Player.m_localPlayer))
			{
				if (!((Object)(object)item == (Object)null) && item.GetInventory() != null)
				{
					int instanceID = ((Object)item).GetInstanceID();
					if ((Object)(object)Chests.Find((Container x) => ((Object)x).GetInstanceID() == instanceID) == (Object)null)
					{
						Chests.Add(item);
					}
				}
			}
		}

		private void ParseChests()
		{
			Chests.RemoveAll((Container chest) => (Object)(object)chest == (Object)null || (Object)(object)((Component)chest).transform == (Object)null || chest.GetInventory() == null);
			List<Container> list = Chests.ToList();
			_chestIndexer.IndexChests(list, ChestInfoDict, ItemNameIndex);
			IndicatedList?.PurgeInvalid(new HashSet<int>(list.Select((Container c) => ((Object)c).GetInstanceID())));
		}

		public static bool CheckContainerAccess(Container container, Player player)
		{
			return ContainerPatch.RunCheckAccess(container, player.GetPlayerID());
		}

		private void AddStatusEffect()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			SeChestIndex seChestIndex = ScriptableObject.CreateInstance<SeChestIndex>();
			((StatusEffect)seChestIndex).GetIconText();
			((Object)seChestIndex).name = "ChestIndexEffect";
			((StatusEffect)seChestIndex).m_name = "Chest Contents";
			((StatusEffect)seChestIndex).m_icon = AssetUtils.LoadSpriteFromFile("ChestContents/Assets/chest.png");
			_chestIndexEffect = new CustomStatusEffect((StatusEffect)(object)seChestIndex, false);
			ItemManager.Instance.AddStatusEffect(_chestIndexEffect);
		}
	}
	public interface IChestScanner
	{
		List<Container> ScanNearbyChests(Vector3 position, float radius, Collider[] colliders, Player player);

		int GetNearbyChestCount(Vector3 position, float radius, Collider[] colliders, Player player);

		int GetNearbyInventoryHash(Vector3 position, float radius, Collider[] colliders, Player player);

		int GetAllChestCount();
	}
	public class ChestScanner : IChestScanner
	{
		public List<Container> ScanNearbyChests(Vector3 position, float radius, Collider[] colliders, Player player)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			List<Container> list = new List<Container>();
			int num = Physics.OverlapSphereNonAlloc(position, radius, colliders);
			for (int i = 0; i < num; i++)
			{
				Collider val = colliders[i];
				if (!((Object)(object)((Component)val).transform.parent == (Object)null))
				{
					Container componentInParent = ((Component)((Component)val).transform).gameObject.GetComponentInParent<Container>();
					if (Object.op_Implicit((Object)(object)componentInParent) && componentInParent.GetInventory() != null && ChestContentsPlugin.CheckContainerAccess(componentInParent, player))
					{
						list.Add(componentInParent);
					}
				}
			}
			return list;
		}

		public int GetNearbyChestCount(Vector3 position, float radius, Collider[] colliders, Player player)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			int num = Physics.OverlapSphereNonAlloc(position, radius, colliders);
			int num2 = 0;
			for (int i = 0; i < num; i++)
			{
				if (!((Object)(object)((Component)colliders[i]).transform.parent == (Object)null))
				{
					Container componentInParent = ((Component)((Component)colliders[i]).transform).gameObject.GetComponentInParent<Container>();
					if (Object.op_Implicit((Object)(object)componentInParent) && componentInParent.GetInventory() != null && ChestContentsPlugin.CheckContainerAccess(componentInParent, player))
					{
						num2++;
					}
				}
			}
			return num2;
		}

		public int GetNearbyInventoryHash(Vector3 position, float radius, Collider[] colliders, Player player)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			int num = Physics.OverlapSphereNonAlloc(position, radius, colliders);
			int num2 = 17;
			for (int i = 0; i < num; i++)
			{
				Collider val = colliders[i];
				if ((Object)(object)((Component)val).transform.parent == (Object)null)
				{
					continue;
				}
				Container componentInParent = ((Component)((Component)val).transform).gameObject.GetComponentInParent<Container>();
				if (!Object.op_Implicit((Object)(object)componentInParent) || componentInParent.GetInventory() == null || !ChestContentsPlugin.CheckContainerAccess(componentInParent, player))
				{
					continue;
				}
				foreach (ItemData item in componentInParent.GetInventory().GetAllItemsInGridOrder())
				{
					num2 = num2 * 31 + (item.m_shared.m_name?.GetHashCode() ?? 0);
					num2 = num2 * 31 + item.m_stack;
				}
			}
			return num2;
		}

		public int GetAllChestCount()
		{
			return Object.FindObjectsOfType<Container>().Length;
		}
	}
	public interface IChestIndexer
	{
		void IndexChests(IEnumerable<Container> chests, Dictionary<int, ChestInfo> chestInfoDict, Dictionary<string, List<ItemLocationInfo>> itemNameIndex);
	}
	public class ChestIndexer : IChestIndexer
	{
		public void IndexChests(IEnumerable<Container> chests, Dictionary<int, ChestInfo> chestInfoDict, Dictionary<string, List<ItemLocationInfo>> itemNameIndex)
		{
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			HashSet<int> validInstanceIds = new HashSet<int>(chests.Select((Container c) => ((Object)c).GetInstanceID()));
			foreach (int item in chestInfoDict.Keys.Where((int id) => !validInstanceIds.Contains(id)).ToList())
			{
				chestInfoDict.Remove(item);
			}
			itemNameIndex.Clear();
			foreach (Container item2 in chests.Where((Container chest) => (Object)(object)chest != (Object)null && (Object)(object)((Component)chest).transform != (Object)null && chest.GetInventory() != null))
			{
				int value = (int)Traverse.Create((object)item2).Field("m_lastRevision").GetValue<uint>();
				int instanceID = ((Object)item2).GetInstanceID();
				bool flag = false;
				if (!chestInfoDict.ContainsKey(instanceID))
				{
					flag = true;
				}
				else if (chestInfoDict[instanceID].LastRevision != value)
				{
					flag = true;
				}
				if (flag)
				{
					ChestInfo chestInfo = new ChestInfo(item2);
					chestInfoDict[chestInfo.InstanceID] = chestInfo;
				}
				ChestInfo chestInfo2 = chestInfoDict[instanceID];
				foreach (ItemData content in chestInfo2.Contents)
				{
					string key = content.m_shared.m_name.ToLowerInvariant();
					if (!itemNameIndex.TryGetValue(key, out var value2))
					{
						value2 = (itemNameIndex[key] = new List<ItemLocationInfo>());
					}
					value2.Add(new ItemLocationInfo
					{
						ItemName = content.m_shared.m_name,
						Stack = content.m_stack,
						ChestId = chestInfo2.InstanceID,
						Position = chestInfo2.Position
					});
				}
			}
		}
	}
	public class IndicatedChestList
	{
		private readonly HashSet<int> _chestSet;

		private readonly ActionableEffect _effect;

		private readonly Dictionary<int, GameObject> _verticalIndicators = new Dictionary<int, GameObject>();

		private GameObject _activeConnectionVfx;

		private readonly Func<bool> _getShowVertical;

		private readonly Func<float> _getMarkerHeight;

		public List<ChestInfo> ChestList { get; }

		public IndicatedChestList()
		{
			ChestList = new List<ChestInfo>();
			_chestSet = new HashSet<int>();
			_effect = new ActionableEffect("vfx_ExtensionConnection");
		}

		public IndicatedChestList(List<ChestInfo> chestList, ActionableEffect effect)
		{
			ChestList = chestList;
			_chestSet = new HashSet<int>(chestList.Select((ChestInfo c) => c.InstanceID));
			_effect = effect;
		}

		public IndicatedChestList(List<ChestInfo> chestList)
		{
			ChestList = chestList;
			_chestSet = new HashSet<int>(chestList.Select((ChestInfo c) => c.InstanceID));
			_effect = new ActionableEffect("vfx_ExtensionConnection");
		}

		public IndicatedChestList(Func<bool> getShowVertical, Func<float> getMarkerHeight)
		{
			ChestList = new List<ChestInfo>();
			_chestSet = new HashSet<int>();
			_effect = new ActionableEffect("vfx_ExtensionConnection");
			_getShowVertical = getShowVertical;
			_getMarkerHeight = getMarkerHeight;
		}

		public void Add(ChestInfo chest, bool unique = true)
		{
			if (unique)
			{
				if (_chestSet.Add(chest.InstanceID))
				{
					ChestList.Add(chest);
				}
			}
			else
			{
				ChestList.Add(chest);
				_chestSet.Add(chest.InstanceID);
			}
		}

		public void Clear()
		{
			ChestList.Clear();
			_chestSet.Clear();
			_effect.PurgeInvalid(new HashSet<int>());
		}

		public void PurgeInvalid(HashSet<int> validInstanceIds)
		{
			ChestList.RemoveAll((ChestInfo ci) => !validInstanceIds.Contains(ci.InstanceID));
			_chestSet.RemoveWhere((int id) => !validInstanceIds.Contains(id));
			_effect.PurgeInvalid(validInstanceIds);
		}

		public void RunEffects()
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Expected O, but got Unknown
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0360: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: 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_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Expected O, but got Unknown
			//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d8: Expected O, but got Unknown
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_042e: 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)
			if (Game.IsPaused())
			{
				return;
			}
			float num = (float)DateTime.Now.TimeOfDay.TotalSeconds;
			bool flag = _getShowVertical();
			float num2 = _getMarkerHeight();
			foreach (ChestInfo chest in ChestList)
			{
				float num3 = 0.5f;
				float num4 = 2f;
				Vector3 val = new Vector3(Mathf.Cos(num * num4), 0f, Mathf.Sin(num * num4)) * num3;
				Vector3 position = chest.Position + val;
				_effect.RunEffect(position, chest.Rotation, chest.InstanceID);
				if (flag)
				{
					if (!_verticalIndicators.ContainsKey(chest.InstanceID) || (Object)(object)_verticalIndicators[chest.InstanceID] == (Object)null)
					{
						GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)2);
						((Object)val2).name = $"ChestVerticalIndicator_{chest.InstanceID}";
						Object.Destroy((Object)(object)val2.GetComponent<Collider>());
						val2.transform.localScale = new Vector3(0.15f, num2 / 2f, 0.15f);
						Material val3 = new Material(Shader.Find("Sprites/Default"));
						val3.color = new Color(1f, 0.5f, 0f, 0.5f);
						val2.GetComponent<Renderer>().material = val3;
						_verticalIndicators[chest.InstanceID] = val2;
					}
					GameObject obj = _verticalIndicators[chest.InstanceID];
					float num5 = num2;
					obj.transform.position = chest.Position + new Vector3(0f, num5 / 2f, 0f);
					obj.transform.localScale = new Vector3(0.15f, num5 / 2f, 0.15f);
					obj.transform.rotation = Quaternion.identity;
				}
				else if (_verticalIndicators.ContainsKey(chest.InstanceID) && (Object)(object)_verticalIndicators[chest.InstanceID] != (Object)null)
				{
					Object.Destroy((Object)(object)_verticalIndicators[chest.InstanceID]);
					_verticalIndicators[chest.InstanceID] = null;
				}
			}
			HashSet<int> validIds = new HashSet<int>(ChestList.Select((ChestInfo c) => c.InstanceID));
			foreach (int item in _verticalIndicators.Keys.Where((int id) => !validIds.Contains(id)).ToList())
			{
				if ((Object)(object)_verticalIndicators[item] != (Object)null)
				{
					Object.Destroy((Object)(object)_verticalIndicators[item]);
				}
				_verticalIndicators.Remove(item);
			}
			if (ChestList.Count > 0 && (Object)(object)Player.m_localPlayer != (Object)null)
			{
				Vector3 position2 = ((Component)Player.m_localPlayer).transform.position;
				Vector3 position3 = ChestList[0].Position;
				position2.y += 1.5f;
				position3.y += 1.5f;
				if ((Object)(object)_activeConnectionVfx == (Object)null)
				{
					_activeConnectionVfx = new GameObject("ChestConnectionLine");
					LineRenderer obj2 = _activeConnectionVfx.AddComponent<LineRenderer>();
					((Renderer)obj2).material = new Material(Shader.Find("Sprites/Default"));
					obj2.widthMultiplier = 0.1f;
					obj2.positionCount = 2;
					obj2.useWorldSpace = true;
					obj2.startColor = Color.cyan;
					obj2.endColor = Color.yellow;
				}
				if ((Object)(object)_activeConnectionVfx != (Object)null)
				{
					LineRenderer component = _activeConnectionVfx.GetComponent<LineRenderer>();
					if ((Object)(object)component != (Object)null)
					{
						component.SetPosition(0, position2);
						component.SetPosition(1, position3);
					}
				}
			}
			else if ((Object)(object)_activeConnectionVfx != (Object)null)
			{
				Object.Destroy((Object)(object)_activeConnectionVfx);
				_activeConnectionVfx = null;
			}
		}
	}
}
namespace ChestContents.Effects
{
	public interface IEffectRunner
	{
		void RunEffect(Vector3 position, Quaternion rotation, int chestInstanceID);

		void ShowEffectForTarget(Vector3 position, Quaternion rotation, int uniqueId);

		void ClearEffectForTarget(int uniqueId);

		void PurgeInvalid(HashSet<int> validInstanceIds);
	}
	public class ActionableEffect : IEffectRunner
	{
		private class EffectInstance
		{
			public GameObject Obj;

			public Vector3 Offset;
		}

		private const int EffectsPerChest = 12;

		private readonly Dictionary<int, List<EffectInstance>> _activeEffectInstances = new Dictionary<int, List<EffectInstance>>();

		private readonly Dictionary<int, List<GameObject>> _activeEffects = new Dictionary<int, List<GameObject>>();

		private readonly string _prefabName;

		public ActionableEffect(string prefabName)
		{
			_prefabName = prefabName;
		}

		public void RunEffect(Vector3 position, Quaternion rotation, int chestInstanceID)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: 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_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			position.y += 1.5f;
			int num = 12;
			float num2 = 0.8f;
			Vector3[] array = (Vector3[])(object)new Vector3[num];
			for (int i = 0; i < num; i++)
			{
				float num3 = (float)i * (float)Math.PI * 2f / (float)num;
				array[i] = new Vector3(Mathf.Cos(num3), 0f, Mathf.Sin(num3)) * num2;
			}
			int num4 = Mathf.Min(12, array.Length);
			if (_activeEffectInstances.TryGetValue(chestInstanceID, out var value) && value != null && value.Count == num4)
			{
				for (int j = 0; j < num4; j++)
				{
					EffectInstance effectInstance = value[j];
					Vector3 val = array[j];
					Quaternion rotation2 = Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up);
					effectInstance.Obj.transform.position = position + val;
					effectInstance.Obj.transform.rotation = rotation2;
				}
				return;
			}
			if (value != null)
			{
				foreach (EffectInstance item in value)
				{
					if ((Object)(object)item.Obj != (Object)null)
					{
						Object.Destroy((Object)(object)item.Obj);
					}
				}
				_activeEffectInstances.Remove(chestInstanceID);
			}
			GameObject val2 = null;
			if ((Object)(object)ZNetScene.instance != (Object)null)
			{
				val2 = ZNetScene.instance.GetPrefab(_prefabName);
			}
			if ((Object)(object)val2 == (Object)null)
			{
				val2 = Cache.GetPrefab<GameObject>(_prefabName);
			}
			if ((Object)(object)val2 == (Object)null)
			{
				return;
			}
			List<EffectInstance> list = new List<EffectInstance>();
			for (int k = 0; k < num4; k++)
			{
				Vector3 val3 = array[k];
				Quaternion val4 = Quaternion.LookRotation(((Vector3)(ref val3)).normalized, Vector3.up);
				GameObject val5 = Object.Instantiate<GameObject>(val2, position + val3, val4);
				ParticleSystem componentInChildren = val5.GetComponentInChildren<ParticleSystem>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					ParticleSystemRenderer component = ((Component)componentInChildren).GetComponent<ParticleSystemRenderer>();
					if ((Object)(object)component != (Object)null)
					{
						component.renderMode = (ParticleSystemRenderMode)0;
					}
				}
				list.Add(new EffectInstance
				{
					Obj = val5,
					Offset = val3
				});
			}
			_activeEffectInstances[chestInstanceID] = list;
		}

		public void ShowEffectForTarget(Vector3 position, Quaternion rotation, int uniqueId)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			RunEffect(position, rotation, uniqueId);
		}

		public void ClearEffectForTarget(int uniqueId)
		{
			if (!_activeEffectInstances.TryGetValue(uniqueId, out var value))
			{
				return;
			}
			foreach (EffectInstance item in value)
			{
				if ((Object)(object)item.Obj != (Object)null)
				{
					Object.Destroy((Object)(object)item.Obj);
				}
			}
			_activeEffectInstances.Remove(uniqueId);
		}

		public void PurgeInvalid(HashSet<int> validInstanceIds)
		{
			foreach (int item in _activeEffectInstances.Keys.Where((int id) => !validInstanceIds.Contains(id)).ToList())
			{
				foreach (EffectInstance item2 in _activeEffectInstances[item])
				{
					if ((Object)(object)item2.Obj != (Object)null)
					{
						Object.Destroy((Object)(object)item2.Obj);
					}
				}
				_activeEffectInstances.Remove(item);
			}
		}
	}
	public class SeChestIndex : StatusEffect
	{
		public override string GetIconText()
		{
			int num = 0;
			try
			{
				num = ChestContentsPlugin.ChestInfoDict.Count;
			}
			catch
			{
			}
			if (num != 1)
			{
				return $"{num} chests";
			}
			return $"{num} chest";
		}
	}
}
namespace ChestContents.Commands
{
	public class ConfigPanelCommand : ConsoleCommand
	{
		private readonly string _name;

		public override string Name => _name;

		public override string Help => "Open the ChestContents config panel";

		public override bool IsNetwork => false;

		public ConfigPanelCommand(string name = "chestconfig")
		{
			_name = name;
		}

		public override void Run(string[] args)
		{
			ChestContentsPlugin.Logger.LogWarning((object)"/chestconfig command run.");
			if ((Object)(object)ChestContentsPlugin.ConfigPanelManagerInstance == (Object)null)
			{
				ChestContentsPlugin.Logger.LogWarning((object)"Config panel is not available yet. Try again in a few seconds after entering the world.");
			}
			else
			{
				ChestContentsPlugin.ConfigPanelManagerInstance.ShowPanel();
			}
		}
	}
	public class SearchChestsCommand : ConsoleCommand
	{
		private readonly string _name;

		private readonly Func<IndicatedChestList> _getIndicatedList;

		private readonly Func<Dictionary<int, ChestInfo>> _getChestInfoDict;

		private readonly Func<Dictionary<string, List<ItemLocationInfo>>> _getItemNameIndex;

		private readonly Func<int> _getLastTotalChestCount;

		public override string Help => "Search Chests for an item";

		public override string Name => _name;

		public override bool IsNetwork => true;

		public SearchChestsCommand(Func<IndicatedChestList> getIndicatedList, Func<Dictionary<int, ChestInfo>> getChestInfoDict, Func<Dictionary<string, List<ItemLocationInfo>>> getItemNameIndex, Func<int> getLastTotalChestCount, string name = "searchchests")
		{
			_name = name;
			_getIndicatedList = getIndicatedList;
			_getChestInfoDict = getChestInfoDict;
			_getItemNameIndex = getItemNameIndex;
			_getLastTotalChestCount = getLastTotalChestCount;
		}

		public override void Run(string[] args)
		{
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			IndicatedChestList indicatedChestList = _getIndicatedList();
			Dictionary<int, ChestInfo> dictionary = _getChestInfoDict();
			Dictionary<string, List<ItemLocationInfo>> dictionary2 = _getItemNameIndex();
			int num = _getLastTotalChestCount();
			if (args.Length == 0)
			{
				indicatedChestList?.Clear();
				int count = dictionary.Count;
				int count2 = dictionary2.Count;
				int num2 = dictionary2.Values.SelectMany((List<ItemLocationInfo> x) => x).Sum((ItemLocationInfo x) => x.Stack);
				int num3 = num;
				PopupManager.ShowMetaPopup($"Chests indexed: {count}\nAll chests: {num3}\nUnique item types: {count2}\nTotal items: {num2}");
				return;
			}
			string text = args[0].ToLowerInvariant();
			List<ItemLocationInfo> list = new List<ItemLocationInfo>();
			foreach (KeyValuePair<string, List<ItemLocationInfo>> item in dictionary2)
			{
				if (item.Key.Contains(text))
				{
					list.AddRange(item.Value);
				}
			}
			if (list.Count == 0)
			{
				ChestContentsPlugin.Logger.LogInfo((object)("No items found matching '" + text + "'."));
				return;
			}
			ItemLocationInfo topEntry = list.OrderByDescending((ItemLocationInfo x) => x.Stack).First();
			ChestContentsPlugin.Logger.LogInfo((object)$"Found '{topEntry.ItemName}' x{topEntry.Stack} in chest {topEntry.ChestId} at {topEntry.Position}");
			string text2 = topEntry.ItemName;
			ChestInfo value = null;
			dictionary.TryGetValue(topEntry.ChestId, out value);
			if (value != null && value.Contents != null)
			{
				ItemData val = ((IEnumerable<ItemData>)value.Contents).FirstOrDefault((Func<ItemData, bool>)((ItemData i) => i.m_shared.m_name == topEntry.ItemName));
				if (val != null && !string.IsNullOrEmpty(val.m_shared.m_name))
				{
					string text3 = LocalizationManager.Instance.TryTranslate(val.m_shared.m_name);
					text2 = (string.IsNullOrEmpty(text3) ? val.m_shared.m_name : text3);
				}
			}
			else if (text2.StartsWith("$"))
			{
				string text4 = LocalizationManager.Instance.TryTranslate(text2);
				text2 = (string.IsNullOrEmpty(text4) ? text2.TrimStart(new char[1] { '$' }) : text4);
			}
			PopupManager.ShowSearchResultsPopup(text2, topEntry.Position, topEntry.Stack);
			if (indicatedChestList != null)
			{
				indicatedChestList.Clear();
				if (value != null && value.Position != Vector3.zero)
				{
					indicatedChestList.Add(value);
				}
				else
				{
					indicatedChestList.Add(new ChestInfo(topEntry.Position, topEntry.ChestId, Quaternion.identity, new List<ItemData>(), DateTime.Now, 0));
				}
			}
		}
	}
}