Decompiled source of ValuableTracker v1.0.8

ValuableTracker.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
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: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("ValuableTracker")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ValuableTracker")]
[assembly: AssemblyTitle("ValuableTracker")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ValuableTracker
{
	[BepInPlugin("ValuableTracker", "Valuable Tracker", "1.0.8")]
	public class ValuableTracker : BaseUnityPlugin
	{
		public class ItemState
		{
			public ValuableObject itemRef;

			public bool markedAsSold;

			public bool isLost;

			public bool isExtracted;
		}

		public static ValuableTracker Instance;

		private static bool _hintShownInSession = false;

		public static List<ItemState> TrackedItems = new List<ItemState>();

		public static int TotalItemsRecorded = 0;

		private void Awake()
		{
			Instance = this;
			PluginConfig.Init(((BaseUnityPlugin)this).Config);
			Harmony.CreateAndPatchAll(typeof(ValuableTracker), (string)null);
			SceneManager.activeSceneChanged += OnSceneChanged;
		}

		private void OnSceneChanged(Scene oldScene, Scene newScene)
		{
			if ((Object)(object)RunManager.instance == (Object)null || !SemiFunc.RunIsLevel())
			{
				_hintShownInSession = false;
			}
		}

		public static void RegisterItem(ValuableObject val)
		{
			if (!((Object)(object)val == (Object)null) && !TrackedItems.Any((ItemState x) => (Object)(object)x.itemRef == (Object)(object)val))
			{
				TrackedItems.Add(new ItemState
				{
					itemRef = val
				});
				TotalItemsRecorded++;
			}
		}

		[HarmonyPatch(typeof(LevelGenerator), "GenerateDone")]
		[HarmonyPostfix]
		private static void OnLevelGenDone()
		{
			TrackedItems.Clear();
			TotalItemsRecorded = 0;
			ValuableObject[] array = Object.FindObjectsOfType<ValuableObject>();
			foreach (ValuableObject val in array)
			{
				RegisterItem(val);
			}
		}

		[HarmonyPatch(typeof(GameDirector), "Update")]
		[HarmonyPostfix]
		private static void GameDirectorUpdate_Patch()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Invalid comparison between Unknown and I4
			//IL_0035: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			if (!_hintShownInSession && SemiFunc.RunIsLevel() && (int)GameDirector.instance.currentState == 2)
			{
				_hintShownInSession = true;
				string friendlyName = GetFriendlyName(PluginConfig.MenuKeybind.Value);
				SemiFunc.UIFocusText("Press " + friendlyName + " to view Valuable Tracker Settings", Color.white, new Color(1f, 0.46f, 0f, 1f), 5f);
			}
			ValuableTrackerHUD.UpdateTick();
		}

		[HarmonyPatch(typeof(ValuableObject), "Start")]
		[HarmonyPostfix]
		private static void OnValuableStart(ValuableObject __instance)
		{
			if (SemiFunc.LevelGenDone())
			{
				RegisterItem(__instance);
			}
		}

		[HarmonyPatch(typeof(RoundDirector), "HaulCheck")]
		[HarmonyPostfix]
		private static void OnHaulCheck()
		{
			List<GameObject> dollarHaulList = RoundDirector.instance.dollarHaulList;
			foreach (ItemState trackedItem in TrackedItems)
			{
				if ((Object)(object)trackedItem.itemRef != (Object)null && dollarHaulList.Contains(((Component)trackedItem.itemRef).gameObject))
				{
					trackedItem.markedAsSold = true;
				}
			}
		}

		[HarmonyPatch(typeof(RunManager), "ChangeLevel")]
		[HarmonyPostfix]
		private static void OnChangeLevel()
		{
			ValuableTrackerHUD.Cleanup();
		}

		public static string GetFriendlyName(KeyCode k)
		{
			string text = ((object)(KeyCode)(ref k)).ToString();
			if (text.StartsWith("Alpha"))
			{
				return text.Replace("Alpha", "");
			}
			if (text.StartsWith("Keypad"))
			{
				return text.Replace("Keypad", "Numpad ");
			}
			if (text == "Return")
			{
				return "Enter";
			}
			if (text == "Escape")
			{
				return "Esc";
			}
			if (text.Contains("Mouse0"))
			{
				return "Mouse Left";
			}
			if (text.Contains("Mouse1"))
			{
				return "Mouse Right";
			}
			if (text.Contains("Mouse2"))
			{
				return "Mouse Mid";
			}
			return Regex.Replace(text, "(\\B[A-Z])", " $1");
		}
	}
	public static class PluginConfig
	{
		public enum Positions
		{
			Default,
			TopLeft,
			BottomRight,
			Custom
		}

		public static ConfigEntry<Positions> UIPosition;

		public static ConfigEntry<Vector2> CustomPositionCoords;

		public static ConfigEntry<bool> ShowHUD;

		public static ConfigEntry<bool> ShowCartCount;

		public static ConfigEntry<bool> ShowLostCount;

		public static ConfigEntry<KeyCode> MenuKeybind;

		public static void Init(ConfigFile config)
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			MenuKeybind = config.Bind<KeyCode>("Controls", "Menu Keybind", (KeyCode)285, "Key to open settings.");
			ShowHUD = config.Bind<bool>("Features", "Enable HUD", true, "Show the tracker.");
			ShowCartCount = config.Bind<bool>("Features", "Track Cart Items", true, "Count items in carts.");
			UIPosition = config.Bind<Positions>("UI Layout", "Position Preset", Positions.Default, "Tracker position.");
			CustomPositionCoords = config.Bind<Vector2>("UI Layout", "Custom Coords", new Vector2(0f, 0f), "Offset for custom position.");
			ShowLostCount = config.Bind<bool>("Features", "Track Lost Items", true, "Show items lost or destroyed.");
		}
	}
	public static class ValuableTrackerHUD
	{
		private class ResetHandler : MonoBehaviour
		{
			private TextMeshProUGUI text;

			private RectTransform rect;

			private bool isHovering;

			private Vector2 originalPos;

			public void Setup(TextMeshProUGUI t, RectTransform r)
			{
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				text = t;
				rect = r;
				originalPos = ((TMP_Text)text).rectTransform.anchoredPosition;
			}

			private void Update()
			{
				//IL_0088: 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_00c5: 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)
				if (!isMenuOpen)
				{
					return;
				}
				bool flag = IsMouseOver(rect);
				if (flag)
				{
					if ((Object)(object)MenuManager.instance != (Object)null)
					{
						MenuManager.instance.MenuHover();
					}
					if (!isHovering && (Object)(object)MenuManager.instance != (Object)null)
					{
						MenuManager.instance.MenuEffectHover(1f, -1f);
					}
				}
				isHovering = flag;
				((Graphic)text).color = (flag ? Color.white : Color.gray);
				((TMP_Text)text).rectTransform.anchoredPosition = (Vector2)(flag ? new Vector2(originalPos.x + 2f, originalPos.y) : originalPos);
				if (flag && Input.GetMouseButtonDown(0))
				{
					PluginConfig.ShowHUD.Value = true;
					PluginConfig.ShowCartCount.Value = true;
					PluginConfig.ShowLostCount.Value = true;
					PluginConfig.MenuKeybind.Value = (KeyCode)285;
					UpdateFooterText();
					if ((Object)(object)MenuManager.instance != (Object)null)
					{
						MenuManager.instance.MenuEffectClick((MenuClickEffectType)1, (MenuPage)null, -1f, -1f, true);
					}
				}
			}

			private bool IsMouseOver(RectTransform target)
			{
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0035: 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_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)target == (Object)null || (Object)(object)MenuCursor.instance == (Object)null)
				{
					return false;
				}
				Vector3 val = ((Transform)target).InverseTransformPoint(((Component)MenuCursor.instance).transform.position);
				Rect val2 = target.rect;
				return ((Rect)(ref val2)).Contains(val);
			}
		}

		private class KeybindHandler : MonoBehaviour
		{
			public static bool IsRebinding;

			private Image border;

			private Image btnBg;

			private TextMeshProUGUI keyText;

			private RectTransform btnRect;

			private bool listening;

			private bool isHovering;

			private float invalidTimer = 0f;

			private Vector2 originalTextPos;

			public void Setup(Image b, Image bg, TextMeshProUGUI t, RectTransform rect)
			{
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				border = b;
				btnBg = bg;
				keyText = t;
				btnRect = rect;
				originalTextPos = ((TMP_Text)keyText).rectTransform.anchoredPosition;
			}

			private void OnDisable()
			{
				listening = false;
				IsRebinding = false;
				invalidTimer = 0f;
			}

			private void Update()
			{
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b1: 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_0118: 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_0120: 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_032c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0131: Unknown result type (might be due to invalid IL or missing references)
				//IL_0138: Invalid comparison between Unknown and I4
				//IL_013a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0141: Invalid comparison between Unknown and I4
				//IL_0370: Unknown result type (might be due to invalid IL or missing references)
				//IL_034d: 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_014a: Invalid comparison between Unknown and I4
				//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b5: Invalid comparison between Unknown and I4
				//IL_016d: 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_01d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_0268: 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_03a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
				//IL_0425: Unknown result type (might be due to invalid IL or missing references)
				//IL_043b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0456: Unknown result type (might be due to invalid IL or missing references)
				if (!isMenuOpen)
				{
					if (listening)
					{
						listening = false;
						IsRebinding = false;
						((TMP_Text)keyText).text = ValuableTracker.GetFriendlyName(PluginConfig.MenuKeybind.Value);
						((Graphic)btnBg).color = repoBlueActive;
					}
					return;
				}
				if (invalidTimer > 0f)
				{
					invalidTimer -= Time.deltaTime;
					if (!(invalidTimer <= 0f))
					{
						return;
					}
					listening = true;
					((TMP_Text)keyText).text = "[PRESS KEY]";
					((Graphic)keyText).color = repoYellow;
					((Graphic)btnBg).color = repoOrange;
				}
				if (listening)
				{
					if (!Input.anyKeyDown)
					{
						return;
					}
					{
						foreach (KeyCode value in Enum.GetValues(typeof(KeyCode)))
						{
							if (!Input.GetKeyDown(value))
							{
								continue;
							}
							if ((int)value == 323 || (int)value == 324 || (int)value == 325)
							{
								((TMP_Text)keyText).text = "INVALID INPUT";
								((Graphic)keyText).color = Color.red;
								invalidTimer = 1.2f;
								if ((Object)(object)MenuManager.instance != (Object)null)
								{
									MenuManager.instance.MenuEffectClick((MenuClickEffectType)2, (MenuPage)null, -1f, -1f, true);
								}
								break;
							}
							if ((int)value == 27)
							{
								((TMP_Text)keyText).text = "INVALID INPUT";
								((Graphic)keyText).color = Color.red;
								invalidTimer = 1.2f;
								if ((Object)(object)MenuManager.instance != (Object)null)
								{
									MenuManager.instance.MenuEffectClick((MenuClickEffectType)2, (MenuPage)null, -1f, -1f, true);
								}
								break;
							}
							PluginConfig.MenuKeybind.Value = value;
							listening = false;
							IsRebinding = false;
							UpdateFooterText();
							if ((Object)(object)MenuManager.instance != (Object)null)
							{
								MenuManager.instance.MenuEffectClick((MenuClickEffectType)1, (MenuPage)null, -1f, -1f, true);
							}
							((TMP_Text)keyText).text = ValuableTracker.GetFriendlyName(value);
							((Graphic)btnBg).color = repoBlueActive;
							break;
						}
						return;
					}
				}
				bool flag = IsMouseOver(btnRect);
				if (flag && (Object)(object)MenuManager.instance != (Object)null)
				{
					MenuManager.instance.MenuHover();
				}
				if (flag && !isHovering && (Object)(object)MenuManager.instance != (Object)null)
				{
					MenuManager.instance.MenuEffectHover(1f, -1f);
				}
				isHovering = flag;
				((Graphic)border).color = (flag ? Color.white : repoBlueBorder);
				((TMP_Text)keyText).rectTransform.anchoredPosition = (Vector2)(flag ? new Vector2(originalTextPos.x + 2f, originalTextPos.y) : originalTextPos);
				if (flag && Input.GetMouseButtonDown(0))
				{
					listening = true;
					IsRebinding = true;
					((Graphic)btnBg).color = repoOrange;
					((TMP_Text)keyText).text = "[PRESS KEY]";
					((Graphic)keyText).color = repoYellow;
					if ((Object)(object)MenuManager.instance != (Object)null)
					{
						MenuManager.instance.MenuEffectClick((MenuClickEffectType)0, (MenuPage)null, -1f, -1f, true);
					}
				}
				if (!listening && invalidTimer <= 0f)
				{
					((TMP_Text)keyText).text = ValuableTracker.GetFriendlyName(PluginConfig.MenuKeybind.Value);
					((Graphic)keyText).color = Color.white;
					if (!flag)
					{
						((Graphic)btnBg).color = repoBlueActive;
					}
				}
			}

			private bool IsMouseOver(RectTransform target)
			{
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0035: 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_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)target == (Object)null || (Object)(object)MenuCursor.instance == (Object)null)
				{
					return false;
				}
				Vector3 val = ((Transform)target).InverseTransformPoint(((Component)MenuCursor.instance).transform.position);
				Rect rect = target.rect;
				return ((Rect)(ref rect)).Contains(val);
			}
		}

		private class RepoRowHandler : MonoBehaviour
		{
			private Image border;

			private Image onHover;

			private Image offHover;

			private RectTransform activeGroup;

			private RectTransform glow;

			private RectTransform onRect;

			private RectTransform offRect;

			private TextMeshProUGUI onText;

			private TextMeshProUGUI offText;

			private Func<bool> getter;

			private Action<bool> setter;

			private bool isHoveringAny;

			private bool isClickAnimActive;

			private float flickerTimer;

			private float popScale = 0f;

			public void Setup(Image brd, RectTransform h, RectTransform g, TextMeshProUGUI on, TextMeshProUGUI off, Func<bool> get, Action<bool> set, Image hOn, Image hOff)
			{
				border = brd;
				activeGroup = h;
				glow = g;
				onText = on;
				offText = off;
				getter = get;
				setter = set;
				onHover = hOn;
				offHover = hOff;
			}

			public void SetOnTarget(RectTransform r)
			{
				onRect = r;
			}

			public void SetOffTarget(RectTransform r)
			{
				offRect = r;
			}

			private void Update()
			{
				//IL_0172: 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_017f: 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_01bf: 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_01c4: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_020b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0210: Unknown result type (might be due to invalid IL or missing references)
				//IL_0220: Unknown result type (might be due to invalid IL or missing references)
				//IL_0231: Unknown result type (might be due to invalid IL or missing references)
				//IL_0236: 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_027d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0372: 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_02f1: Unknown result type (might be due to invalid IL or missing references)
				//IL_0301: Unknown result type (might be due to invalid IL or missing references)
				//IL_0342: 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_035d: 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)
				if (!isMenuOpen)
				{
					return;
				}
				bool flag = getter();
				bool flag2 = IsMouseOver(onRect);
				bool flag3 = IsMouseOver(offRect);
				if (Object.op_Implicit((Object)(object)onHover))
				{
					((Behaviour)onHover).enabled = flag2 && !flag;
				}
				if (Object.op_Implicit((Object)(object)offHover))
				{
					((Behaviour)offHover).enabled = flag3 && flag;
				}
				bool flag4 = flag2 || flag3;
				if (flag4)
				{
					if ((Object)(object)MenuManager.instance != (Object)null)
					{
						MenuManager.instance.MenuHover();
					}
					if (!isHoveringAny && (Object)(object)MenuManager.instance != (Object)null)
					{
						MenuManager.instance.MenuEffectHover(1f, -1f);
					}
					if (Input.GetMouseButtonDown(0))
					{
						bool flag5 = flag2 || (!flag3 && flag);
						if (flag5 != flag)
						{
							setter(flag5);
							flickerTimer = 0.25f;
							isClickAnimActive = true;
							popScale = 0f;
							if ((Object)(object)MenuManager.instance != (Object)null)
							{
								MenuManager.instance.MenuEffectClick((MenuClickEffectType)4, (MenuPage)null, -1f, -1f, true);
							}
						}
					}
				}
				isHoveringAny = flag4;
				((Graphic)border).color = Color.Lerp(((Graphic)border).color, isHoveringAny ? Color.white : repoBlueBorder, Time.deltaTime * 10f);
				Vector2 val = (flag ? new Vector2(-30f, 0f) : new Vector2(30f, 0f));
				activeGroup.anchoredPosition = Vector2.Lerp(activeGroup.anchoredPosition, val, Time.deltaTime * 25f);
				if (isClickAnimActive)
				{
					((Transform)glow).localScale = Vector3.Lerp(((Transform)glow).localScale, Vector3.zero, Time.deltaTime * 40f);
					if (Vector2.Distance(activeGroup.anchoredPosition, val) < 1f)
					{
						popScale = Mathf.MoveTowards(popScale, 1.4f, Time.deltaTime * 12f);
						((Transform)glow).localScale = Vector3.one * popScale;
						if (popScale >= 1.4f)
						{
							isClickAnimActive = false;
						}
					}
				}
				else
				{
					((Transform)glow).localScale = Vector3.Lerp(((Transform)glow).localScale, new Vector3(((flag && flag2) || (!flag && flag3)) ? 1.15f : 1f, ((flag && flag2) || (!flag && flag3)) ? 1.15f : 1f, 1f), Time.deltaTime * 15f);
				}
				if (flickerTimer > 0f)
				{
					flickerTimer -= Time.deltaTime;
					((Graphic)onText).color = (flag ? repoOrange : Color.white);
					((Graphic)offText).color = ((!flag) ? repoOrange : Color.white);
				}
				else
				{
					((Graphic)onText).color = Color.white;
					((Graphic)offText).color = Color.white;
				}
			}

			private bool IsMouseOver(RectTransform target)
			{
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0035: 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_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)target == (Object)null || (Object)(object)MenuCursor.instance == (Object)null)
				{
					return false;
				}
				Vector3 val = ((Transform)target).InverseTransformPoint(((Component)MenuCursor.instance).transform.position);
				Rect rect = target.rect;
				return ((Rect)(ref rect)).Contains(val);
			}
		}

		private class RepoButton : MonoBehaviour
		{
			public bool targetValue;
		}

		private static GameObject UIObject;

		private static TextMeshProUGUI UIText;

		private static GameObject SettingsPanel;

		private static MenuPage SettingsMenuPage;

		private static GameObject DimmerPanel;

		private static GameObject WindowContainer;

		private static CanvasGroup SettingsCanvasGroup;

		private static TextMeshProUGUI FooterHintText;

		public static bool isMenuOpen = false;

		private static float introLerp = 0f;

		private static Color repoBlueActive = new Color(0.067f, 0.298f, 0.725f, 1f);

		private static Color repoBlueBorder = new Color(0f, 0.5f, 1f, 1f);

		private static Color repoOrange = new Color(1f, 0.46f, 0f, 1f);

		private static Color repoYellow = new Color(1f, 0.8f, 0f, 1f);

		private static Color repoHover = new Color(0f, 0.5f, 1f, 0.3f);

		private static TMP_FontAsset nativeFont;

		private static FieldInfo inputDisableTimerField = typeof(PlayerController).GetField("InputDisableTimer", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static FieldInfo itemsInCartListField = AccessTools.Field(typeof(PhysGrabCart), "itemsInCart");

		private static FieldInfo menuManagerStateField = AccessTools.Field(typeof(MenuManager), "currentMenuState");

		private static float _updateTimer = 0f;

		private const float UPDATE_INTERVAL = 0.25f;

		public static void Cleanup()
		{
			if ((Object)(object)SettingsMenuPage != (Object)null && (Object)(object)MenuManager.instance != (Object)null)
			{
				MenuManager.instance.PageRemove(SettingsMenuPage);
			}
			if ((Object)(object)SettingsPanel != (Object)null)
			{
				Object.Destroy((Object)(object)SettingsPanel);
			}
			if ((Object)(object)UIObject != (Object)null)
			{
				Object.Destroy((Object)(object)UIObject);
			}
			SettingsPanel = null;
			SettingsMenuPage = null;
			DimmerPanel = null;
			WindowContainer = null;
			UIObject = null;
			SettingsCanvasGroup = null;
			UIText = null;
			FooterHintText = null;
			isMenuOpen = false;
			introLerp = 0f;
			KeybindHandler.IsRebinding = false;
		}

		public static void UpdateTick()
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: 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_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			int num = 1;
			if ((Object)(object)MenuManager.instance != (Object)null && menuManagerStateField != null)
			{
				num = (int)menuManagerStateField.GetValue(MenuManager.instance);
			}
			if (isMenuOpen && num == 0)
			{
				isMenuOpen = false;
				if ((Object)(object)MenuManager.instance != (Object)null)
				{
					MenuManager.instance.MenuEffectPopUpClose();
				}
				return;
			}
			if (!KeybindHandler.IsRebinding && Input.GetKeyDown(PluginConfig.MenuKeybind.Value) && (isMenuOpen || num != 0))
			{
				isMenuOpen = !isMenuOpen;
				if (isMenuOpen && (Object)(object)SettingsPanel != (Object)null)
				{
					SettingsPanel.transform.SetAsLastSibling();
					UpdateFooterText();
				}
				if ((Object)(object)MenuManager.instance != (Object)null)
				{
					if (isMenuOpen)
					{
						MenuManager.instance.MenuEffectPopUpOpen();
					}
					else
					{
						MenuManager.instance.MenuEffectPopUpClose();
					}
					MenuManager.instance.StateSet((MenuState)((!isMenuOpen) ? 1 : 0));
				}
			}
			if (isMenuOpen)
			{
				if ((Object)(object)CursorManager.instance != (Object)null)
				{
					CursorManager.instance.Unlock(0.1f);
				}
				if ((Object)(object)PlayerController.instance != (Object)null && inputDisableTimerField != null)
				{
					inputDisableTimerField.SetValue(PlayerController.instance, 0.1f);
				}
				SemiFunc.UIHideAim();
				SemiFunc.UIHideInventory();
				SemiFunc.UIHideHaul();
				SemiFunc.UIHideHealth();
				SemiFunc.UIHideEnergy();
				SemiFunc.CameraOverrideStopAim();
			}
			if ((Object)(object)SettingsPanel == (Object)null)
			{
				CreateSettingsMenu();
			}
			if ((Object)(object)SettingsPanel != (Object)null && (Object)(object)WindowContainer != (Object)null)
			{
				introLerp = Mathf.MoveTowards(introLerp, isMenuOpen ? 1f : 0f, Time.deltaTime * 5f);
				Vector2 val = (isMenuOpen ? new Vector2(0f, 50f) : new Vector2(0f, -50f));
				WindowContainer.GetComponent<RectTransform>().anchoredPosition = Vector2.Lerp(val, Vector2.zero, introLerp);
				if ((Object)(object)SettingsCanvasGroup != (Object)null)
				{
					SettingsCanvasGroup.alpha = introLerp;
				}
				bool flag = isMenuOpen || introLerp > 0f;
				if (SettingsPanel.activeSelf != flag)
				{
					SettingsPanel.SetActive(flag);
				}
			}
			if (SemiFunc.RunIsLevel())
			{
				if ((Object)(object)UIObject == (Object)null)
				{
					CreateHUD();
				}
				if (!((Object)(object)UIObject != (Object)null))
				{
					return;
				}
				bool active = PluginConfig.ShowHUD.Value || PluginConfig.ShowCartCount.Value || PluginConfig.ShowLostCount.Value;
				UIObject.SetActive(active);
				if (UIObject.activeSelf)
				{
					_updateTimer += Time.deltaTime;
					if (_updateTimer >= 0.25f)
					{
						_updateTimer = 0f;
						UpdateDisplay();
					}
				}
			}
			else if ((Object)(object)UIObject != (Object)null)
			{
				UIObject.SetActive(false);
			}
		}

		public static void UpdateFooterText()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)FooterHintText == (Object)null))
			{
				string friendlyName = ValuableTracker.GetFriendlyName(PluginConfig.MenuKeybind.Value);
				((TMP_Text)FooterHintText).text = (friendlyName.Contains("Mouse") ? (friendlyName + " to Close") : ("Press " + friendlyName + " to Close"));
			}
		}

		private static void FetchNativeFont()
		{
			if (!((Object)(object)nativeFont != (Object)null))
			{
				GameObject val = GameObject.Find("Tax Haul");
				if ((Object)(object)val != (Object)null)
				{
					nativeFont = ((TMP_Text)val.GetComponent<TextMeshProUGUI>()).font;
				}
			}
		}

		private static void CreateSettingsMenu()
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//IL_00a6: 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_00be: 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_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Expected O, but got Unknown
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: 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_0185: 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_01a7: Expected O, but got Unknown
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_0368: 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_03f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0404: Unknown result type (might be due to invalid IL or missing references)
			//IL_0418: Unknown result type (might be due to invalid IL or missing references)
			object obj2;
			if (!Object.op_Implicit((Object)(object)MenuHolder.instance))
			{
				GameObject obj = GameObject.Find("Game Hud");
				obj2 = ((obj != null) ? obj.transform : null);
			}
			else
			{
				obj2 = ((Component)MenuHolder.instance).transform;
			}
			Transform val = (Transform)obj2;
			if (!((Object)(object)val == (Object)null))
			{
				FetchNativeFont();
				SettingsPanel = new GameObject("ValuableTracker_SettingsRoot");
				SettingsPanel.transform.SetParent(val, false);
				SettingsPanel.layer = ((Component)val).gameObject.layer;
				SettingsMenuPage = SettingsPanel.AddComponent<MenuPage>();
				((Behaviour)SettingsMenuPage).enabled = false;
				RectTransform val2 = SettingsPanel.AddComponent<RectTransform>();
				val2.anchorMin = Vector2.zero;
				val2.anchorMax = Vector2.one;
				val2.offsetMin = Vector2.zero;
				val2.offsetMax = Vector2.zero;
				SettingsCanvasGroup = SettingsPanel.AddComponent<CanvasGroup>();
				SettingsCanvasGroup.blocksRaycasts = true;
				SettingsCanvasGroup.alpha = 0f;
				DimmerPanel = new GameObject("Dimmer");
				DimmerPanel.transform.SetParent(SettingsPanel.transform, false);
				RectTransform val3 = DimmerPanel.AddComponent<RectTransform>();
				val3.anchorMin = Vector2.zero;
				val3.anchorMax = Vector2.one;
				val3.offsetMin = Vector2.zero;
				val3.offsetMax = Vector2.zero;
				Image val4 = DimmerPanel.AddComponent<Image>();
				((Graphic)val4).color = new Color(0f, 0f, 0f, 0.7f);
				((Graphic)val4).raycastTarget = true;
				WindowContainer = new GameObject("WindowContainer");
				WindowContainer.transform.SetParent(SettingsPanel.transform, false);
				RectTransform val5 = WindowContainer.AddComponent<RectTransform>();
				val5.sizeDelta = new Vector2(500f, 350f);
				val5.anchoredPosition = Vector2.zero;
				Image val6 = WindowContainer.AddComponent<Image>();
				((Graphic)val6).color = new Color(0.02f, 0.02f, 0.02f, 0.4f);
				((Graphic)val6).raycastTarget = true;
				CreateTextElement("Title", "VALUABLE TRACKER SETTINGS", 36, new Vector2(0f, 130f), WindowContainer.transform, repoOrange, (TextAlignmentOptions)514, new Vector2(480f, 60f));
				CreateResetButton("RESET TO DEFAULT SETTINGS", new Vector2(0f, 90f), WindowContainer.transform);
				CreateSettingRow("TRACK VALUABLE ITEMS", new Vector2(0f, 45f), WindowContainer.transform, () => PluginConfig.ShowHUD.Value, delegate(bool v)
				{
					PluginConfig.ShowHUD.Value = v;
				});
				CreateSettingRow("TRACK ITEMS IN CART", new Vector2(0f, 0f), WindowContainer.transform, () => PluginConfig.ShowCartCount.Value, delegate(bool v)
				{
					PluginConfig.ShowCartCount.Value = v;
				});
				CreateSettingRow("TRACK LOST/DESTROYED", new Vector2(0f, -45f), WindowContainer.transform, () => PluginConfig.ShowLostCount.Value, delegate(bool v)
				{
					PluginConfig.ShowLostCount.Value = v;
				});
				CreateKeybindRow("MENU KEYBIND", new Vector2(0f, -90f), WindowContainer.transform);
				FooterHintText = CreateTextElement("Hint", "Press F4 to Close", 18, new Vector2(0f, -140f), WindowContainer.transform, Color.white, (TextAlignmentOptions)514, new Vector2(300f, 40f));
				UpdateFooterText();
				SettingsPanel.SetActive(false);
			}
		}

		private static void CreateResetButton(string label, Vector2 pos, Transform parent)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_002c: 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_0047: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("ResetBtn");
			val.transform.SetParent(parent, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.sizeDelta = new Vector2(380f, 25f);
			val2.anchoredPosition = pos;
			TextMeshProUGUI t = CreateTextElement("Label", label, 18, Vector2.zero, val.transform, Color.gray, (TextAlignmentOptions)514, new Vector2(380f, 25f));
			ResetHandler resetHandler = val.AddComponent<ResetHandler>();
			resetHandler.Setup(t, val2);
		}

		private static void CreateKeybindRow(string label, Vector2 pos, Transform parent)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			//IL_006c: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: 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_0110: 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_0140: Expected O, but got Unknown
			//IL_016a: 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_0197: 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_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(label + "_Row");
			val.transform.SetParent(parent, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.sizeDelta = new Vector2(380f, 35f);
			val2.anchoredPosition = pos;
			GameObject val3 = new GameObject("Border");
			val3.transform.SetParent(val.transform, false);
			RectTransform val4 = val3.AddComponent<RectTransform>();
			val4.sizeDelta = val2.sizeDelta;
			Image val5 = val3.AddComponent<Image>();
			((Graphic)val5).color = repoBlueBorder;
			GameObject val6 = new GameObject("InnerHole");
			val6.transform.SetParent(val3.transform, false);
			RectTransform val7 = val6.AddComponent<RectTransform>();
			val7.sizeDelta = new Vector2(376f, 31f);
			((Graphic)val6.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.95f);
			CreateTextElement("Label", label, 20, new Vector2(-60f, 0f), val6.transform, Color.white, (TextAlignmentOptions)513, new Vector2(240f, 35f), -2f);
			GameObject val8 = new GameObject("KeybindBtn");
			val8.transform.SetParent(val6.transform, false);
			RectTransform val9 = val8.AddComponent<RectTransform>();
			val9.sizeDelta = new Vector2(120f, 31f);
			val9.anchoredPosition = new Vector2(128f, 0f);
			Image val10 = val8.AddComponent<Image>();
			((Graphic)val10).color = repoBlueActive;
			TextMeshProUGUI t = CreateTextElement("KeyText", ValuableTracker.GetFriendlyName(PluginConfig.MenuKeybind.Value), 20, Vector2.zero, val8.transform, Color.white, (TextAlignmentOptions)514, new Vector2(120f, 35f), -2f);
			KeybindHandler keybindHandler = val.AddComponent<KeybindHandler>();
			keybindHandler.Setup(val5, val10, t, val9);
		}

		private static void CreateSettingRow(string label, Vector2 pos, Transform parent, Func<bool> getter, Action<bool> setter)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			//IL_006c: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: 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_0110: 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_0140: Expected O, but got Unknown
			//IL_016a: 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_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Expected O, but got Unknown
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Expected O, but got Unknown
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: 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_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Expected O, but got Unknown
			//IL_02ca: 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_02e1: Expected O, but got Unknown
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: Expected O, but got Unknown
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: 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_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0439: 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_046b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0485: Unknown result type (might be due to invalid IL or missing references)
			//IL_0494: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b7: 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)
			GameObject val = new GameObject(label + "_Row");
			val.transform.SetParent(parent, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.sizeDelta = new Vector2(380f, 35f);
			val2.anchoredPosition = pos;
			GameObject val3 = new GameObject("Border");
			val3.transform.SetParent(val.transform, false);
			RectTransform val4 = val3.AddComponent<RectTransform>();
			val4.sizeDelta = val2.sizeDelta;
			Image val5 = val3.AddComponent<Image>();
			((Graphic)val5).color = repoBlueBorder;
			GameObject val6 = new GameObject("InnerHole");
			val6.transform.SetParent(val3.transform, false);
			RectTransform val7 = val6.AddComponent<RectTransform>();
			val7.sizeDelta = new Vector2(376f, 31f);
			((Graphic)val6.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.95f);
			CreateTextElement("Label", label, 20, new Vector2(-60f, 0f), val6.transform, Color.white, (TextAlignmentOptions)513, new Vector2(240f, 35f), -2f);
			GameObject val8 = new GameObject("ToggleBox");
			val8.transform.SetParent(val6.transform, false);
			RectTransform val9 = val8.AddComponent<RectTransform>();
			val9.sizeDelta = new Vector2(120f, 31f);
			val9.anchoredPosition = new Vector2(128f, 0f);
			GameObject val10 = new GameObject("OnHover");
			val10.transform.SetParent(val8.transform, false);
			Image val11 = val10.AddComponent<Image>();
			((Graphic)val11).color = repoHover;
			((Behaviour)val11).enabled = false;
			RectTransform component = val10.GetComponent<RectTransform>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.sizeDelta = new Vector2(60f, 31f);
			}
			component.anchoredPosition = new Vector2(-30f, 0f);
			GameObject val12 = new GameObject("OffHover");
			val12.transform.SetParent(val8.transform, false);
			Image val13 = val12.AddComponent<Image>();
			((Graphic)val13).color = repoHover;
			((Behaviour)val13).enabled = false;
			RectTransform component2 = val12.GetComponent<RectTransform>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				component2.sizeDelta = new Vector2(60f, 31f);
			}
			component2.anchoredPosition = new Vector2(30f, 0f);
			GameObject val14 = new GameObject("ActiveGroup");
			val14.transform.SetParent(val8.transform, false);
			RectTransform val15 = val14.AddComponent<RectTransform>();
			val15.sizeDelta = new Vector2(60f, 31f);
			GameObject val16 = new GameObject("OrangeGlow");
			val16.transform.SetParent(val14.transform, false);
			RectTransform val17 = val16.AddComponent<RectTransform>();
			val17.sizeDelta = new Vector2(64f, 35f);
			((Graphic)val16.AddComponent<Image>()).color = repoOrange;
			GameObject val18 = new GameObject("BlueBody");
			val18.transform.SetParent(val14.transform, false);
			RectTransform val19 = val18.AddComponent<RectTransform>();
			val19.sizeDelta = new Vector2(60f, 31f);
			((Graphic)val18.AddComponent<Image>()).color = repoBlueActive;
			TextMeshProUGUI on = CreateTextElement("ON", "ON", 18, new Vector2(-30f, 0f), val8.transform, Color.white, (TextAlignmentOptions)514, new Vector2(50f, 35f), -2f);
			TextMeshProUGUI off = CreateTextElement("OFF", "OFF", 18, new Vector2(30f, 0f), val8.transform, Color.white, (TextAlignmentOptions)514, new Vector2(50f, 35f), -2f);
			RepoRowHandler repoRowHandler = val.AddComponent<RepoRowHandler>();
			repoRowHandler.Setup(val5, val15, val17, on, off, getter, setter, val11, val13);
			CreateHitbox("Hit_ON", new Vector2(-30f, 0f), new Vector2(60f, 31f), val8.transform, val: true, repoRowHandler, new Color(0f, 1f, 0f, 0.01f));
			CreateHitbox("Hit_OFF", new Vector2(30f, 0f), new Vector2(60f, 31f), val8.transform, val: false, repoRowHandler, new Color(1f, 0f, 0f, 0.01f));
		}

		private static void CreateHitbox(string name, Vector2 pos, Vector2 size, Transform parent, bool val, RepoRowHandler handler, Color debugColor)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			GameObject val2 = new GameObject(name);
			val2.transform.SetParent(parent, false);
			RectTransform val3 = val2.AddComponent<RectTransform>();
			val3.sizeDelta = size;
			val3.anchoredPosition = pos;
			Image val4 = val2.AddComponent<Image>();
			((Graphic)val4).color = debugColor;
			((Graphic)val4).raycastTarget = true;
			RepoButton repoButton = val2.AddComponent<RepoButton>();
			repoButton.targetValue = val;
			if (val)
			{
				handler.SetOnTarget(val3);
			}
			else
			{
				handler.SetOffTarget(val3);
			}
		}

		private static TextMeshProUGUI CreateTextElement(string name, string content, int size, Vector2 pos, Transform parent, Color color, TextAlignmentOptions align, Vector2 boxSize, float yOffset = 0f)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
			if ((Object)(object)nativeFont != (Object)null)
			{
				((TMP_Text)val2).font = nativeFont;
			}
			((TMP_Text)val2).text = content;
			((TMP_Text)val2).fontSize = size;
			((Graphic)val2).color = color;
			((TMP_Text)val2).alignment = align;
			((TMP_Text)val2).rectTransform.anchoredPosition = new Vector2(pos.x, pos.y + yOffset);
			((TMP_Text)val2).rectTransform.sizeDelta = boxSize;
			((Graphic)val2).raycastTarget = false;
			return val2;
		}

		private static void CreateHUD()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			GameObject val = GameObject.Find("Game Hud");
			GameObject val2 = GameObject.Find("Tax Haul");
			if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null)
			{
				UIObject = new GameObject("ValuableTracker_HUD");
				UIObject.transform.SetParent(val.transform, false);
				UIText = UIObject.AddComponent<TextMeshProUGUI>();
				((TMP_Text)UIText).font = val2.GetComponent<TMP_Text>().font;
				((TMP_Text)UIText).fontSize = 24f;
				((TMP_Text)UIText).alignment = (TextAlignmentOptions)2052;
				((TMP_Text)UIText).enableWordWrapping = false;
			}
		}

		private static void UpdateDisplay()
		{
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)UIObject == (Object)null)
			{
				return;
			}
			UpdatePosition();
			int num = 0;
			int num2 = 0;
			List<GameObject> dollarHaulList = RoundDirector.instance.dollarHaulList;
			foreach (ValuableTracker.ItemState trackedItem in ValuableTracker.TrackedItems)
			{
				if (trackedItem.isLost)
				{
					if (trackedItem.isExtracted)
					{
						num++;
					}
					else
					{
						num2++;
					}
					continue;
				}
				bool flag = false;
				if ((Object)(object)trackedItem.itemRef != (Object)null)
				{
					if (dollarHaulList.Contains(((Component)trackedItem.itemRef).gameObject))
					{
						flag = true;
					}
					else if ((Object)(object)((Component)trackedItem.itemRef).transform.parent != (Object)null && dollarHaulList.Contains(((Component)((Component)trackedItem.itemRef).transform.parent).gameObject))
					{
						flag = true;
					}
				}
				bool flag2 = false;
				if ((Object)(object)trackedItem.itemRef != (Object)null && (!((Component)trackedItem.itemRef).gameObject.activeInHierarchy || !((Behaviour)trackedItem.itemRef).enabled))
				{
					flag2 = true;
				}
				if (trackedItem.markedAsSold || flag)
				{
					num++;
				}
				else if ((Object)(object)trackedItem.itemRef == (Object)null || flag2)
				{
					trackedItem.isLost = true;
					num2++;
				}
			}
			int num3 = 0;
			if (PluginConfig.ShowCartCount.Value && itemsInCartListField != null)
			{
				PhysGrabCart[] array = Object.FindObjectsOfType<PhysGrabCart>();
				foreach (PhysGrabCart obj in array)
				{
					if (!(itemsInCartListField.GetValue(obj) is IEnumerable enumerable))
					{
						continue;
					}
					foreach (object item in enumerable)
					{
						PhysGrabObject val = (PhysGrabObject)((item is PhysGrabObject) ? item : null);
						if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).GetComponent<ValuableObject>() != (Object)null)
						{
							num3++;
						}
					}
				}
			}
			int num4 = ValuableTracker.TotalItemsRecorded - num2;
			if (!((Object)(object)UIText != (Object)null))
			{
				return;
			}
			StringBuilder stringBuilder = new StringBuilder();
			bool flag3 = false;
			((Graphic)UIText).color = new Color(0.78f, 0.91f, 0.9f, 1f);
			if (PluginConfig.ShowHUD.Value)
			{
				bool flag4 = num == num4 && num4 > 0;
				if (flag4)
				{
					stringBuilder.Append("<color=green>");
				}
				stringBuilder.Append($"Items: {num} / {num4}");
				if (flag4)
				{
					stringBuilder.Append("</color>");
				}
				flag3 = true;
			}
			if (PluginConfig.ShowCartCount.Value && num3 > 0)
			{
				if (flag3)
				{
					stringBuilder.Append("\n");
				}
				stringBuilder.Append($"In Cart: {num3}");
				flag3 = true;
			}
			if (PluginConfig.ShowLostCount.Value && num2 > 0)
			{
				if (flag3)
				{
					stringBuilder.Append("\n");
				}
				stringBuilder.Append($"<color=#FF4444>Lost: {num2}</color>");
			}
			((TMP_Text)UIText).text = stringBuilder.ToString();
		}

		private static void UpdatePosition()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_00ba: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = UIObject.GetComponent<RectTransform>();
			float num = 225f;
			foreach (RectTransform item in UIObject.transform.parent)
			{
				RectTransform val = item;
				if ((Object)(object)val == (Object)(object)component || !((Component)val).gameObject.activeSelf || !(val.anchoredPosition.y > 220f) || !(val.anchoredPosition.y < 230f))
				{
					continue;
				}
				num = 195f;
				break;
			}
			component.pivot = new Vector2(1f, 1f);
			component.anchorMin = Vector2.zero;
			component.anchorMax = new Vector2(1f, 0f);
			component.offsetMax = new Vector2(0f, num);
			component.offsetMin = new Vector2(0f, num);
			component.sizeDelta = Vector2.zero;
		}
	}
}