Decompiled source of InteractableESP v1.1.0

plugins/InteractableESP/InteractableESP.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HG;
using Microsoft.CodeAnalysis;
using RoR2;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("InteractableESP")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+7c853e419e1525f01374bb8cf6454dd171e0fabf")]
[assembly: AssemblyProduct("InteractableESP")]
[assembly: AssemblyTitle("InteractableESP")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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 ExamplePlugin
{
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
}
namespace InteractableESP
{
	public class ConfigGUI : MonoBehaviour
	{
		private bool showWindow;

		private bool waitingForHighlightKey;

		private bool waitingForGUIKey;

		private bool showColorPicker;

		private bool colorPickerHexChangedByUser;

		private Rect windowRect = new Rect(100f, 100f, 420f, 600f);

		private Rect colorPickerRect = new Rect(400f, 200f, 260f, 340f);

		private string colorPickerKey;

		private string colorPickerHex = "";

		private Color colorPickerValue;

		private static Texture2D _previewTex;

		private void Update()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown(ESP.Instance.GUIToggleKey))
			{
				showWindow = !showWindow;
			}
		}

		private void OnGUI()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_006d: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			if (showWindow)
			{
				windowRect = GUI.Window(123456, windowRect, new WindowFunction(DrawWindow), "Interactable ESP Settings");
				if (showColorPicker && colorPickerKey != null)
				{
					colorPickerRect = GUI.Window(654321, colorPickerRect, new WindowFunction(DrawColorPickerWindow), "Pick Color: " + colorPickerKey);
				}
			}
		}

		private void DrawWindow(int id)
		{
			//IL_0461: Unknown result type (might be due to invalid IL or missing references)
			//IL_0466: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: 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_0402: 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_040f: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			GUILayout.Label("<b>General</b>", GetHeaderStyle(), Array.Empty<GUILayoutOption>());
			DrawToggleButton("Draw Labels", () => ESP.Instance.DrawLabels, delegate(bool v)
			{
				ESP.Instance.DrawLabels = v;
			});
			DrawToggleButton("Draw Bounding Box", () => ESP.Instance.DrawBoundingBox, delegate(bool v)
			{
				ESP.Instance.DrawBoundingBox = v;
			});
			DrawToggleButton("Use Advanced Label", () => ESP.Instance.UseAdvancedLabel, delegate(bool v)
			{
				ESP.Instance.UseAdvancedLabel = v;
			});
			DrawToggleButton("High Contrast Text", () => ESP.Instance.HighContrastText, delegate(bool v)
			{
				ESP.Instance.HighContrastText = v;
			});
			DrawToggleButton("Highlight Interactables", () => ESP.Instance.HighlightInteractablesEnabled, delegate(bool v)
			{
				ESP.Instance.HighlightInteractablesEnabled = v;
				if (!v)
				{
					Highlight[] array = Object.FindObjectsOfType<Highlight>();
					for (int i = 0; i < array.Length; i++)
					{
						array[i].isOn = false;
					}
				}
				else
				{
					ESP.Instance.HighlightAllInteractables();
				}
			});
			GUILayout.Space(10f);
			GUILayout.Label("Label Font Size: " + ESP.Instance.LabelFontSize, Array.Empty<GUILayoutOption>());
			int num = (int)GUILayout.HorizontalSlider((float)ESP.Instance.LabelFontSize, 8f, 48f, Array.Empty<GUILayoutOption>());
			if (num != ESP.Instance.LabelFontSize)
			{
				ESP.Instance.LabelFontSize = num;
			}
			GUILayout.Space(10f);
			GUILayout.Label("<b>Key Bindings</b>", GetHeaderStyle(), Array.Empty<GUILayoutOption>());
			DrawKeyBinding("Toggle Highlight Key", () => ESP.Instance.HighlightToggleKey, delegate(KeyCode k)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				ESP.Instance.HighlightToggleKey = k;
			}, ref waitingForHighlightKey);
			DrawKeyBinding("Toggle GUI Key", () => ESP.Instance.GUIToggleKey, delegate(KeyCode k)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				ESP.Instance.GUIToggleKey = k;
			}, ref waitingForGUIKey);
			GUILayout.Space(10f);
			GUILayout.Label("<b>Colors</b>", GetHeaderStyle(), Array.Empty<GUILayoutOption>());
			Dictionary<string, ConfigEntry<Color>> colorConfigs = ESP.Instance.GetColorConfigs();
			Dictionary<string, ConfigEntry<bool>> colorEnabledConfigs = ESP.Instance.GetColorEnabledConfigs();
			foreach (KeyValuePair<string, ConfigEntry<Color>> item in colorConfigs)
			{
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				GUILayout.Label(item.Key, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) });
				bool value = colorEnabledConfigs[item.Key].Value;
				string text = (value ? "Enabled" : "Disabled");
				bool flag = GUILayout.Toggle(value, text, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) });
				if (flag != value)
				{
					colorEnabledConfigs[item.Key].Value = flag;
					if (!flag)
					{
						ESP.Instance.RemoveHighlightsAndLabelsForColorGroup(item.Key);
					}
					else
					{
						ESP.Instance.HighlightAllInteractables();
					}
				}
				Color color = GUI.color;
				GUI.color = item.Value.Value;
				if (GUILayout.Button("", (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Width(32f),
					GUILayout.Height(18f)
				}))
				{
					showColorPicker = true;
					colorPickerKey = item.Key;
					colorPickerValue = item.Value.Value;
					colorPickerHex = ColorToHex(colorPickerValue);
					colorPickerHexChangedByUser = false;
				}
				GUI.color = color;
				GUILayout.EndHorizontal();
			}
			GUILayout.Space(10f);
			KeyCode gUIToggleKey = ESP.Instance.GUIToggleKey;
			GUILayout.Label("Press " + ((object)(KeyCode)(ref gUIToggleKey)).ToString() + " to close this window.", Array.Empty<GUILayoutOption>());
			GUILayout.EndVertical();
			GUI.DragWindow();
		}

		private void DrawColorPickerWindow(int id)
		{
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Invalid comparison between Unknown and I4
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Invalid comparison between Unknown and I4
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: 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_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Invalid comparison between Unknown and I4
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: 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: 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_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Expected O, but got Unknown
			//IL_019b: 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)
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			DrawColorSlider("Red", ref colorPickerValue.r);
			DrawColorSlider("Green", ref colorPickerValue.g);
			DrawColorSlider("Blue", ref colorPickerValue.b);
			DrawColorSlider("Alpha", ref colorPickerValue.a);
			GUILayout.Space(10f);
			GUILayout.Label("Hex (RRGGBBAA):", Array.Empty<GUILayoutOption>());
			GUI.SetNextControlName("HexInputField");
			string text = GUILayout.TextField(colorPickerHex, 8, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) });
			bool num = text != colorPickerHex;
			colorPickerHex = text.ToUpper();
			if (num)
			{
				colorPickerHexChangedByUser = true;
				if (TryParseHexColor(colorPickerHex, out var color))
				{
					colorPickerValue = color;
				}
			}
			else if ((int)Event.current.type == 7 && !colorPickerHexChangedByUser)
			{
				colorPickerHex = ColorToHex(colorPickerValue);
			}
			if ((int)Event.current.type == 4 && (int)Event.current.keyCode == 13)
			{
				colorPickerHexChangedByUser = false;
				GUI.FocusControl((string)null);
			}
			if ((int)Event.current.type == 0 && GUI.GetNameOfFocusedControl() != "HexInputField")
			{
				colorPickerHexChangedByUser = false;
			}
			GUILayout.Space(5f);
			GUILayout.Label("Preview:", Array.Empty<GUILayoutOption>());
			Rect rect = GUILayoutUtility.GetRect(60f, 24f);
			if ((Object)(object)_previewTex == (Object)null)
			{
				_previewTex = new Texture2D(1, 1);
				_previewTex.SetPixel(0, 0, Color.white);
				_previewTex.Apply();
			}
			Color color2 = GUI.color;
			GUI.color = colorPickerValue;
			GUI.DrawTexture(rect, (Texture)(object)_previewTex);
			GUI.color = color2;
			GUILayout.Space(10f);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Apply", Array.Empty<GUILayoutOption>()))
			{
				Dictionary<string, ConfigEntry<Color>> colorConfigs = ESP.Instance.GetColorConfigs();
				if (colorConfigs.ContainsKey(colorPickerKey))
				{
					colorConfigs[colorPickerKey].Value = colorPickerValue;
				}
				ESP.Instance.RefreshTokenColorMap();
				ESP.Instance.HighlightAllInteractables();
				showColorPicker = false;
				colorPickerKey = null;
				colorPickerHexChangedByUser = false;
			}
			if (GUILayout.Button("Cancel", Array.Empty<GUILayoutOption>()))
			{
				showColorPicker = false;
				colorPickerKey = null;
				colorPickerHexChangedByUser = false;
			}
			GUILayout.EndHorizontal();
			GUILayout.EndVertical();
			GUI.DragWindow();
		}

		private void DrawToggleButton(string label, Func<bool> getter, Action<bool> setter)
		{
			if (GUILayout.Button(label + ": " + (getter() ? "ON" : "OFF"), Array.Empty<GUILayoutOption>()))
			{
				setter(!getter());
			}
		}

		private void DrawKeyBinding(string label, Func<KeyCode> getter, Action<KeyCode> setter, ref bool waiting)
		{
			//IL_0011: 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_0096: Invalid comparison between Unknown and I4
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label($"{label}: {getter()}", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(220f) });
			if (!waiting)
			{
				if (GUILayout.Button("Change", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) }))
				{
					waiting = true;
				}
			}
			else
			{
				GUILayout.Label("Press any key...", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) });
				if (Event.current.isKey && (int)Event.current.type == 4)
				{
					setter(Event.current.keyCode);
					waiting = false;
					Event.current.Use();
				}
			}
			GUILayout.EndHorizontal();
		}

		private void DrawColorSlider(string label, ref float value)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.Label(label, Array.Empty<GUILayoutOption>());
			float num = value;
			value = GUILayout.HorizontalSlider(value, 0f, 1f, Array.Empty<GUILayoutOption>());
			if (!colorPickerHexChangedByUser && value != num)
			{
				colorPickerHex = ColorToHex(colorPickerValue);
			}
		}

		private string ColorToHex(Color c)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			return $"{(int)(c.r * 255f):X2}{(int)(c.g * 255f):X2}{(int)(c.b * 255f):X2}{(int)(c.a * 255f):X2}";
		}

		private bool TryParseHexColor(string hex, out Color color)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			color = Color.white;
			if (hex.Length == 8)
			{
				return ColorUtility.TryParseHtmlString("#" + hex, ref color);
			}
			return false;
		}

		private GUIStyle GetHeaderStyle()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			return new GUIStyle(GUI.skin.label)
			{
				richText = true,
				fontStyle = (FontStyle)1
			};
		}
	}
	public static class InteractableDisplayNames
	{
		public static readonly Dictionary<string, string> Map = new Dictionary<string, string>
		{
			{ "CHEST1_NAME", "Chest" },
			{ "CHEST2_NAME", "Large Chest" },
			{ "LOCKBOX_NAME", "Lockbox" },
			{ "CASINOCHEST_NAME", "Adaptive Chest" },
			{ "GOLDCHEST_NAME", "Legendary Chest" },
			{ "CHEST1_STEALTHED_NAME", "Cloaked Chest" },
			{ "LUNAR_CHEST_NAME", "Lunar Pod" },
			{ "BARREL_NAME", "Barrel" },
			{ "EQUIPMENTBARREL_NAME", "Equipment Barrel" },
			{ "CATEGORYCHEST_HEALING_NAME", "Chest - Healing" },
			{ "CATEGORYCHEST_DAMAGE_NAME", "Chest - Damage" },
			{ "CATEGORYCHEST_UTILITY_NAME", "Chest - Utility" },
			{ "CATEGORYCHEST2_HEALING_NAME", "Large Chest - Healing" },
			{ "CATEGORYCHEST2_DAMAGE_NAME", "Large Chest - Damage" },
			{ "CATEGORYCHEST2_UTILITY_NAME", "Large Chest - Utility" },
			{ "TRIPLE_SHOP", "Shop" },
			{ "DUPLICATOR_NAME", "3D Printer" },
			{ "DUPLICATOR_WILD_NAME", "3D Printer - Overgrown" },
			{ "DUPLICATOR_MILITARY_NAME", "3D Printer - Military" },
			{ "BAZAAR_CAULDRON_NAME", "Bazaar Cauldron" },
			{ "SCRAPPER_NAME", "Scrapper" },
			{ "RADIOTOWER_NAME", "Radio Tower" },
			{ "TURRET1_INTERACTABLE_NAME", "Gunner Turret" },
			{ "DRONE_GUNNER_INTERACTABLE_NAME", "Drone - Gunner" },
			{ "DRONE_HEALING_INTERACTABLE_NAME", "Drone - Healing" },
			{ "EMERGENCYDRONE_INTERACTABLE_NAME", "Drone - Emergency" },
			{ "DRONE_MISSILE_INTERACTABLE_NAME", "Drone - Missile" },
			{ "EQUIPMENTDRONE_INTERACTABLE_NAME", "Drone - Equipment" },
			{ "FLAMEDRONE_INTERACTABLE_NAME", "Drone - Incinerator" },
			{ "DRONE_MEGA_INTERACTABLE_NAME", "TC-280" },
			{ "NEWT_STATUE_NAME", "Newt Statue" },
			{ "SECRET_BUTTON", "Secret Button" },
			{ "SHRINE_BLOOD_NAME", "Shrine of Blood" },
			{ "SHRINE_CHANCE_NAME", "Shrine of Chance" },
			{ "SHRINE_CLEANSE_NAME", "Cleansing Pool" },
			{ "SHRINE_COMBAT_NAME", "Shrine of Combat" },
			{ "SHRINE_GOLDSHORES_NAME", "Altar of Gold" },
			{ "SHRINE_BOSS_NAME", "Shrine of the Mountain" },
			{ "SHRINE_RESTACK_NAME", "Shrine of Order" },
			{ "SHRINE_HEALING_NAME", "Shrine of the Woods" },
			{ "SHRINE_REBIRTH_NAME", "Shrine of Rebirth" },
			{ "TELEPORTER_NAME", "Teleporter" },
			{ "MOON_BATTERY_MASS_NAME", "Pillar of Mass" },
			{ "MOON_BATTERY_DESIGN_NAME", "Pillar of Design" },
			{ "MOON_BATTERY_SOUL_NAME", "Pillar of Soul" },
			{ "MOON_BATTERY_BLOOD_NAME", "Pillar of Blood" },
			{ "LUNAR_TERMINAL_NAME", "Lunar Bud" },
			{ "LUNAR_REROLL_NAME", "Reroll Slab" },
			{ "BAZAAR_SEER_NAME", "Lunar Seer" },
			{ "VOID_CHEST_NAME", "Void Cradle" },
			{ "VOID_TRIPLE_NAME", "Void Potential" },
			{ "VOIDLOCKBOX_NAME", "Encrusted Lockbox" },
			{ "DEEPVOIDBATTERY_NAME", "Deep Void Signal" },
			{ "NULL_WARD_NAME", "Cell Vent" },
			{ "SHRINE_HALCYONITE_NAME", "Halcyon Shrine" },
			{ "SHRINE_COLOSSUS_NAME", "Shrine of Shaping" },
			{ "GOLDTOTEM_NAME", "Halcyon Beacon" },
			{ "FAN_NAME", "Fan" }
		};
	}
	public class HighlightCleaner : MonoBehaviour
	{
		public GameObject target;

		private float shrineUnavailableSince = -1f;

		private const float ShrineUnavailableDelay = 3f;

		private void Update()
		{
			if (!Object.op_Implicit((Object)(object)target))
			{
				Object.Destroy((Object)(object)this);
				return;
			}
			PurchaseInteraction component = target.GetComponent<PurchaseInteraction>();
			if ((Object)(object)component != (Object)null && (component.displayNameToken.Contains("DUPLICATOR") || component.displayNameToken.Contains("BAZAAR_CAULDRON")))
			{
				return;
			}
			ShrineBehavior component2 = target.GetComponent<ShrineBehavior>();
			MultiShopController component3 = target.GetComponent<MultiShopController>();
			if ((Object)(object)component2 != (Object)null)
			{
				if ((Object)(object)component != (Object)null && !component.available)
				{
					if (shrineUnavailableSince < 0f)
					{
						shrineUnavailableSince = Time.unscaledTime;
					}
					if (Time.unscaledTime - shrineUnavailableSince > 3f)
					{
						Cleanup();
					}
				}
				else
				{
					shrineUnavailableSince = -1f;
				}
				return;
			}
			if ((Object)(object)component3 != (Object)null && !component3.available)
			{
				Cleanup();
				return;
			}
			if (!Object.op_Implicit((Object)(object)component) || component.available)
			{
				ChestBehavior component4 = target.GetComponent<ChestBehavior>();
				if (component4 == null || !component4.isChestOpened)
				{
					BarrelInteraction component5 = target.GetComponent<BarrelInteraction>();
					if (component5 == null || !component5.opened)
					{
						ShopTerminalBehavior component6 = target.GetComponent<ShopTerminalBehavior>();
						if (component6 == null || !component6.hasBeenPurchased)
						{
							return;
						}
					}
				}
			}
			Cleanup();
		}

		private void Cleanup()
		{
			Highlight val = default(Highlight);
			if (target.TryGetComponent<Highlight>(ref val))
			{
				val.isOn = false;
				Object.Destroy((Object)(object)val);
			}
			Transform val2 = target.transform.Find("ESPMarker");
			if ((Object)(object)val2 != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)val2).gameObject);
			}
			Object.Destroy((Object)(object)this);
		}
	}
	public class InteractableLabel : MonoBehaviour
	{
		public string Label;

		public Color Color;

		public Vector2 BoundingBoxSize = new Vector2(60f, 30f);

		private Camera _camera;

		private static Texture2D _lineTexture;

		public GameObject Interactable { get; set; }

		public ManualLogSource Logger { get; set; }

		public ConfigEntry<bool> DrawLabelsConfig { get; set; }

		public ConfigEntry<bool> DrawBoundingBoxConfig { get; set; }

		public ConfigEntry<bool> UseAdvancedLabelConfig { get; set; }

		public ConfigEntry<bool> HighContrastConfig { get; set; }

		public ConfigEntry<int> LabelFontSizeConfig { get; set; }

		private void Awake()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			_camera = Camera.main;
			if ((Object)(object)_lineTexture == (Object)null)
			{
				_lineTexture = new Texture2D(1, 1);
				_lineTexture.SetPixel(0, 0, Color.white);
				_lineTexture.Apply();
			}
		}

		private void OnGUI()
		{
			//IL_0041: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: 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_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: 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_015b: 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_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Expected O, but got Unknown
			//IL_019a: Expected O, but got Unknown
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Expected O, but got Unknown
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Expected O, but got Unknown
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: 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_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)_camera))
			{
				_camera = Camera.main;
			}
			if (!Object.op_Implicit((Object)(object)_camera) || !((Behaviour)this).enabled || !((Component)this).gameObject.activeInHierarchy)
			{
				return;
			}
			Vector3 position = ((Component)this).transform.position;
			Vector3 val = _camera.WorldToScreenPoint(position);
			if (val.z <= 0f)
			{
				return;
			}
			val.y = (float)Screen.height - val.y;
			Rect rect = default(Rect);
			((Rect)(ref rect))..ctor(val.x - BoundingBoxSize.x / 2f, val.y - BoundingBoxSize.y / 2f, BoundingBoxSize.x, BoundingBoxSize.y);
			ConfigEntry<bool> drawBoundingBoxConfig = DrawBoundingBoxConfig;
			if (drawBoundingBoxConfig != null && drawBoundingBoxConfig.Value)
			{
				DrawRectOutline(rect, Color, 2);
			}
			if (DrawLabelsConfig == null || DrawLabelsConfig.Value)
			{
				string advancedInfo = GetAdvancedInfo();
				float num = Vector3.Distance(((Component)_camera).transform.position, position);
				string text = $"<color=#{ColorUtility.ToHtmlStringRGB(Color)}>{Label}</color>\n<color=#FFFFFF>{Mathf.RoundToInt(num)}m</color>{advancedInfo}";
				GUIStyle val2 = new GUIStyle
				{
					fontSize = (LabelFontSizeConfig?.Value ?? 14),
					alignment = (TextAnchor)1,
					richText = true,
					normal = new GUIStyleState
					{
						textColor = Color.white
					}
				};
				Vector2 val3 = val2.CalcSize(new GUIContent(text));
				Rect val4 = default(Rect);
				((Rect)(ref val4))..ctor(((Rect)(ref rect)).center.x - val3.x / 2f, ((Rect)(ref rect)).yMin - val3.y, val3.x, val3.y);
				ConfigEntry<bool> highContrastConfig = HighContrastConfig;
				if (highContrastConfig != null && highContrastConfig.Value)
				{
					GUIStyle val5 = new GUIStyle(val2);
					val5.normal.textColor = Color.black;
					GUI.Label(new Rect(((Rect)(ref val4)).x - 1f, ((Rect)(ref val4)).y, ((Rect)(ref val4)).width, ((Rect)(ref val4)).height), text, val5);
					GUI.Label(new Rect(((Rect)(ref val4)).x + 1f, ((Rect)(ref val4)).y, ((Rect)(ref val4)).width, ((Rect)(ref val4)).height), text, val5);
					GUI.Label(new Rect(((Rect)(ref val4)).x, ((Rect)(ref val4)).y - 1f, ((Rect)(ref val4)).width, ((Rect)(ref val4)).height), text, val5);
					GUI.Label(new Rect(((Rect)(ref val4)).x, ((Rect)(ref val4)).y + 1f, ((Rect)(ref val4)).width, ((Rect)(ref val4)).height), text, val5);
				}
				GUI.Label(val4, text, val2);
			}
		}

		private string GetAdvancedInfo()
		{
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: 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_01ce: Unknown result type (might be due to invalid IL or missing references)
			if (UseAdvancedLabelConfig == null || !UseAdvancedLabelConfig.Value || (Object)(object)Interactable == (Object)null)
			{
				return "";
			}
			string text = "";
			PurchaseInteraction component = Interactable.GetComponent<PurchaseInteraction>();
			if ((Object)(object)component != (Object)null && !component.displayNameToken.Contains("DUPLICATOR") && !component.displayNameToken.Contains("SHRINE") && !component.displayNameToken.Contains("BAZAAR_CAULDRON") && !component.displayNameToken.Contains("MOON_BATTERY") && !component.displayNameToken.Contains("EQUIPMENTDRONE") && !component.displayNameToken.Contains("NULL_WARD"))
			{
				text += $" <color=#FFFFFF>- ${component.cost}</color>";
			}
			if ((Object)(object)component != (Object)null && (component.displayNameToken.Contains("DUPLICATOR") || component.displayNameToken.Contains("BAZAAR_CAULDRON")))
			{
				text += FormatPickup(Interactable.GetComponent<ShopTerminalBehavior>()?.pickupIndex, "\n\n");
			}
			ChestBehavior component2 = Interactable.GetComponent<ChestBehavior>();
			if ((Object)(object)component2 != (Object)null)
			{
				text += FormatPickup(component2.dropPickup, "\n\n");
			}
			MultiShopController component3 = Interactable.GetComponent<MultiShopController>();
			if ((Object)(object)component3 != (Object)null)
			{
				text += $" <color=#FFFFFF>- ${component3.cost}</color>\n";
				Enumerator<GameObject> enumerator = component3.terminalGameObjects.GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						text += FormatPickup(enumerator.Current.GetComponent<ShopTerminalBehavior>()?.pickupIndex);
					}
				}
				finally
				{
					((IDisposable)enumerator).Dispose();
				}
			}
			return text;
		}

		private string FormatPickup(PickupIndex? pickupIndex, string prefix = "\n")
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Invalid comparison between Unknown and I4
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Invalid comparison between Unknown and I4
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			if (pickupIndex.HasValue)
			{
				PickupIndex? val = pickupIndex;
				PickupIndex none = PickupIndex.none;
				if (!val.HasValue || !(val.GetValueOrDefault() == none))
				{
					PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex.Value);
					if (pickupDef == null)
					{
						return "";
					}
					if ((int)pickupDef.itemIndex != -1)
					{
						ItemDef itemDef = ItemCatalog.GetItemDef(pickupDef.itemIndex);
						if ((Object)(object)itemDef != (Object)null)
						{
							string text = ColorUtility.ToHtmlStringRGB(GetTierColor(itemDef.tier));
							string @string = Language.GetString(itemDef.nameToken);
							return prefix + "<color=#" + text + ">" + @string + "</color>";
						}
					}
					else if ((int)pickupDef.equipmentIndex != -1)
					{
						EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(pickupDef.equipmentIndex);
						if ((Object)(object)equipmentDef != (Object)null)
						{
							string text2 = ColorUtility.ToHtmlStringRGB((Color)(equipmentDef.isLunar ? Color.cyan : new Color(1f, 0.5f, 0f)));
							string string2 = Language.GetString(equipmentDef.nameToken);
							return prefix + "<color=#" + text2 + ">" + string2 + "</color>";
						}
					}
					return "";
				}
			}
			return "";
		}

		private void DrawRectOutline(Rect rect, Color color, int thickness)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			Color color2 = GUI.color;
			GUI.color = color;
			GUI.DrawTexture(new Rect(((Rect)(ref rect)).xMin, ((Rect)(ref rect)).yMin, ((Rect)(ref rect)).width, (float)thickness), (Texture)(object)_lineTexture);
			GUI.DrawTexture(new Rect(((Rect)(ref rect)).xMin, ((Rect)(ref rect)).yMax - (float)thickness, ((Rect)(ref rect)).width, (float)thickness), (Texture)(object)_lineTexture);
			GUI.DrawTexture(new Rect(((Rect)(ref rect)).xMin, ((Rect)(ref rect)).yMin, (float)thickness, ((Rect)(ref rect)).height), (Texture)(object)_lineTexture);
			GUI.DrawTexture(new Rect(((Rect)(ref rect)).xMax - (float)thickness, ((Rect)(ref rect)).yMin, (float)thickness, ((Rect)(ref rect)).height), (Texture)(object)_lineTexture);
			GUI.color = color2;
		}

		private static Color GetTierColor(ItemTier tier)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Expected I4, but got Unknown
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			return (Color)((int)tier switch
			{
				0 => Color.white, 
				1 => Color.green, 
				2 => Color.red, 
				4 => Color.yellow, 
				3 => Color.cyan, 
				6 => new Color(0.988f, 0.725f, 0.925f), 
				7 => new Color(0.776f, 0.47f, 0.705f), 
				8 => new Color(0.584f, 0.043f, 0.458f), 
				_ => Color.white, 
			});
		}
	}
	public static class Utils
	{
		public static string GetTokenForGameObject(GameObject go)
		{
			PurchaseInteraction component = go.GetComponent<PurchaseInteraction>();
			if ((Object)(object)component != (Object)null)
			{
				return component.displayNameToken;
			}
			if ((Object)(object)go.GetComponent<BarrelInteraction>() != (Object)null)
			{
				return "BARREL_NAME";
			}
			if ((Object)(object)go.GetComponent<ScrapperController>() != (Object)null)
			{
				return "SCRAPPER_NAME";
			}
			if ((Object)(object)go.GetComponent<MultiShopController>() != (Object)null)
			{
				return "TRIPLE_SHOP";
			}
			if ((Object)(object)go.GetComponent<PressurePlateController>() != (Object)null)
			{
				return "SECRET_BUTTON";
			}
			if ((Object)(object)go.GetComponent<TeleporterInteraction>() != (Object)null)
			{
				return "TELEPORTER_NAME";
			}
			return null;
		}
	}
	public static class PluginInfo
	{
		public const string PluginAuthor = "Floramene";

		public const string PluginName = "InteractableESP";

		public const string PluginVersion = "1.1.0";

		public const string PluginGUID = "Floramene.InteractableESP";
	}
	[BepInPlugin("Floramene.InteractableESP", "InteractableESP", "1.1.0")]
	public class ESP : BaseUnityPlugin
	{
		[CompilerGenerated]
		private sealed class <GetAllInteractables>d__59 : IEnumerable<GameObject>, IEnumerable, IEnumerator<GameObject>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private GameObject <>2__current;

			private int <>l__initialThreadId;

			private PurchaseInteraction[] <>7__wrap1;

			private int <>7__wrap2;

			private BarrelInteraction[] <>7__wrap3;

			private ScrapperController[] <>7__wrap4;

			private MultiShopController[] <>7__wrap5;

			private PressurePlateController[] <>7__wrap6;

			private TeleporterInteraction[] <>7__wrap7;

			private GenericPickupController[] <>7__wrap8;

			private GeodeController[] <>7__wrap9;

			GameObject IEnumerator<GameObject>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <GetAllInteractables>d__59(int <>1__state)
			{
				this.<>1__state = <>1__state;
				<>l__initialThreadId = Environment.CurrentManagedThreadId;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>7__wrap1 = null;
				<>7__wrap3 = null;
				<>7__wrap4 = null;
				<>7__wrap5 = null;
				<>7__wrap6 = null;
				<>7__wrap7 = null;
				<>7__wrap8 = null;
				<>7__wrap9 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>7__wrap1 = Object.FindObjectsOfType<PurchaseInteraction>();
					<>7__wrap2 = 0;
					goto IL_0086;
				case 1:
					<>1__state = -1;
					<>7__wrap2++;
					goto IL_0086;
				case 2:
					<>1__state = -1;
					<>7__wrap2++;
					goto IL_00e9;
				case 3:
					<>1__state = -1;
					<>7__wrap2++;
					goto IL_014c;
				case 4:
					<>1__state = -1;
					<>7__wrap2++;
					goto IL_01b1;
				case 5:
					<>1__state = -1;
					<>7__wrap2++;
					goto IL_0216;
				case 6:
					<>1__state = -1;
					<>7__wrap2++;
					goto IL_027b;
				case 7:
					<>1__state = -1;
					<>7__wrap2++;
					goto IL_02e0;
				case 8:
					{
						<>1__state = -1;
						<>7__wrap2++;
						break;
					}
					IL_0086:
					if (<>7__wrap2 < <>7__wrap1.Length)
					{
						PurchaseInteraction val = <>7__wrap1[<>7__wrap2];
						<>2__current = ((Component)val).gameObject;
						<>1__state = 1;
						return true;
					}
					<>7__wrap1 = null;
					<>7__wrap3 = Object.FindObjectsOfType<BarrelInteraction>();
					<>7__wrap2 = 0;
					goto IL_00e9;
					IL_0216:
					if (<>7__wrap2 < <>7__wrap6.Length)
					{
						PressurePlateController val2 = <>7__wrap6[<>7__wrap2];
						<>2__current = ((Component)val2).gameObject;
						<>1__state = 5;
						return true;
					}
					<>7__wrap6 = null;
					<>7__wrap7 = Object.FindObjectsOfType<TeleporterInteraction>();
					<>7__wrap2 = 0;
					goto IL_027b;
					IL_00e9:
					if (<>7__wrap2 < <>7__wrap3.Length)
					{
						BarrelInteraction val3 = <>7__wrap3[<>7__wrap2];
						<>2__current = ((Component)val3).gameObject;
						<>1__state = 2;
						return true;
					}
					<>7__wrap3 = null;
					<>7__wrap4 = Object.FindObjectsOfType<ScrapperController>();
					<>7__wrap2 = 0;
					goto IL_014c;
					IL_027b:
					if (<>7__wrap2 < <>7__wrap7.Length)
					{
						TeleporterInteraction val4 = <>7__wrap7[<>7__wrap2];
						<>2__current = ((Component)val4).gameObject;
						<>1__state = 6;
						return true;
					}
					<>7__wrap7 = null;
					<>7__wrap8 = Object.FindObjectsOfType<GenericPickupController>();
					<>7__wrap2 = 0;
					goto IL_02e0;
					IL_014c:
					if (<>7__wrap2 < <>7__wrap4.Length)
					{
						ScrapperController val5 = <>7__wrap4[<>7__wrap2];
						<>2__current = ((Component)val5).gameObject;
						<>1__state = 3;
						return true;
					}
					<>7__wrap4 = null;
					<>7__wrap5 = Object.FindObjectsOfType<MultiShopController>();
					<>7__wrap2 = 0;
					goto IL_01b1;
					IL_02e0:
					if (<>7__wrap2 < <>7__wrap8.Length)
					{
						GenericPickupController val6 = <>7__wrap8[<>7__wrap2];
						<>2__current = ((Component)val6).gameObject;
						<>1__state = 7;
						return true;
					}
					<>7__wrap8 = null;
					<>7__wrap9 = Object.FindObjectsOfType<GeodeController>();
					<>7__wrap2 = 0;
					break;
					IL_01b1:
					if (<>7__wrap2 < <>7__wrap5.Length)
					{
						MultiShopController val7 = <>7__wrap5[<>7__wrap2];
						<>2__current = ((Component)val7).gameObject;
						<>1__state = 4;
						return true;
					}
					<>7__wrap5 = null;
					<>7__wrap6 = Object.FindObjectsOfType<PressurePlateController>();
					<>7__wrap2 = 0;
					goto IL_0216;
				}
				if (<>7__wrap2 < <>7__wrap9.Length)
				{
					GeodeController val8 = <>7__wrap9[<>7__wrap2];
					<>2__current = ((Component)val8).gameObject;
					<>1__state = 8;
					return true;
				}
				<>7__wrap9 = null;
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}

			[DebuggerHidden]
			IEnumerator<GameObject> IEnumerable<GameObject>.GetEnumerator()
			{
				if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
				{
					<>1__state = 0;
					return this;
				}
				return new <GetAllInteractables>d__59(0);
			}

			[DebuggerHidden]
			IEnumerator IEnumerable.GetEnumerator()
			{
				return ((IEnumerable<GameObject>)this).GetEnumerator();
			}
		}

		private static ManualLogSource _log;

		private readonly Dictionary<string, ConfigEntry<Color>> _colorConfigs = new Dictionary<string, ConfigEntry<Color>>();

		private readonly Dictionary<string, ConfigEntry<bool>> _colorEnabledConfigs = new Dictionary<string, ConfigEntry<bool>>();

		private Dictionary<string, Color> _tokenColorMap;

		private ConfigEntry<KeyCode> _highlightToggleKey;

		private ConfigEntry<KeyCode> _guiToggleKey;

		private ConfigEntry<bool> _drawLabels;

		private ConfigEntry<bool> _drawBoundingBox;

		private ConfigEntry<bool> _useAdvancedLabel;

		private ConfigEntry<bool> _highlightInteractables;

		private ConfigEntry<bool> _highContrastText;

		private ConfigEntry<int> _labelFontSize;

		private bool _highlightEnabled = true;

		public static ESP Instance { get; private set; }

		public bool DrawLabels
		{
			get
			{
				return _drawLabels.Value;
			}
			set
			{
				_drawLabels.Value = value;
			}
		}

		public bool DrawBoundingBox
		{
			get
			{
				return _drawBoundingBox.Value;
			}
			set
			{
				_drawBoundingBox.Value = value;
			}
		}

		public bool UseAdvancedLabel
		{
			get
			{
				return _useAdvancedLabel.Value;
			}
			set
			{
				_useAdvancedLabel.Value = value;
			}
		}

		public bool HighlightInteractablesEnabled
		{
			get
			{
				return _highlightInteractables.Value;
			}
			set
			{
				_highlightInteractables.Value = value;
			}
		}

		public bool HighContrastText
		{
			get
			{
				return _highContrastText.Value;
			}
			set
			{
				_highContrastText.Value = value;
			}
		}

		public int LabelFontSize
		{
			get
			{
				return _labelFontSize.Value;
			}
			set
			{
				_labelFontSize.Value = value;
			}
		}

		public KeyCode GUIToggleKey
		{
			get
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				return _guiToggleKey.Value;
			}
			set
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				_guiToggleKey.Value = value;
			}
		}

		public KeyCode HighlightToggleKey
		{
			get
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				return _highlightToggleKey.Value;
			}
			set
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				_highlightToggleKey.Value = value;
			}
		}

		private void Awake()
		{
			Instance = this;
			_log = ((BaseUnityPlugin)this).Logger;
			_log.LogInfo((object)"Interactable ESP plugin loaded.");
			InitializeConfig();
			Stage.onStageStartGlobal += delegate
			{
				ScheduleHighlight();
			};
			((Component)this).gameObject.AddComponent<ConfigGUI>();
		}

		private void Update()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown(_highlightToggleKey.Value))
			{
				_highlightEnabled = !_highlightEnabled;
				_log.LogInfo((object)("Interactable ESP toggled " + (_highlightEnabled ? "ON" : "OFF")));
				ToggleAllHighlights(_highlightEnabled);
			}
		}

		private void ToggleAllHighlights(bool enable)
		{
			if (!enable)
			{
				Highlight[] array = Object.FindObjectsOfType<Highlight>();
				for (int i = 0; i < array.Length; i++)
				{
					array[i].isOn = false;
				}
				InteractableLabel[] array2 = Object.FindObjectsOfType<InteractableLabel>();
				for (int i = 0; i < array2.Length; i++)
				{
					Object.Destroy((Object)(object)array2[i]);
				}
			}
			else
			{
				HighlightAllInteractables();
			}
		}

		private void ScheduleHighlight()
		{
			((MonoBehaviour)this).CancelInvoke("HighlightAllInteractables");
			((MonoBehaviour)this).Invoke("HighlightAllInteractables", 2f);
		}

		private void InitializeConfig()
		{
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Expected O, but got Unknown
			_highlightToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "ToggleHighlightKey", (KeyCode)284, "Key to toggle interactable highlights / labels on/off");
			_guiToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "ToggleGUIKey", (KeyCode)285, "Key to open/close the ESP settings GUI");
			_highlightInteractables = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "HighlightInteractables", true, "Whether to highlight interactable items");
			_drawLabels = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DrawLabels", false, "Whether to draw labels on interactables");
			_drawBoundingBox = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DrawBoundingBox", false, "Whether to draw a bounding box around interactables");
			_useAdvancedLabel = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "UseAdvancedLabel", false, "Whether to show advanced label info (cost, item, etc.)");
			_highContrastText = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "HighContrastText", false, "Whether to use high contrast text for labels");
			_labelFontSize = ((BaseUnityPlugin)this).Config.Bind<int>("General", "LabelFontSize", 14, new ConfigDescription("Font size for the label text", (AcceptableValueBase)(object)new AcceptableValueRange<int>(8, 48), Array.Empty<object>()));
			_drawLabels.SettingChanged += delegate
			{
				UpdateAllLabelsAndBoxes();
			};
			_drawBoundingBox.SettingChanged += delegate
			{
				UpdateAllLabelsAndBoxes();
			};
			AddColorConfig("Default", "FFFFFFFF", "Default highlight color");
			AddColorConfig("Chest", "FFEA04FF", "Chest highlight color");
			AddColorConfig("Barrel", "FF5804FF", "Barrel highlight color");
			AddColorConfig("Shop", "19FF04FF", "Shop terminal highlight color");
			AddColorConfig("Printer", "FF04D9FF", "3D printer highlight color");
			AddColorConfig("Lunar", "01FFFFFF", "Lunar Chest / Newt Statue highlight color");
			AddColorConfig("Drone", "FF0400FF", "Drone / Turret highlight color");
			AddColorConfig("Teleporter", "8E38FFFF", "Teleporter highlight color");
			RefreshTokenColorMap();
		}

		private void AddColorConfig(string key, string hex, string desc)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			_colorConfigs[key] = ((BaseUnityPlugin)this).Config.Bind<Color>("Colors", key + "Color", HexToColor(hex), desc);
			_colorEnabledConfigs[key] = ((BaseUnityPlugin)this).Config.Bind<bool>("Colors", key + "Enabled", true, "Enable ESP for " + key + " interactables");
		}

		private static Color HexToColor(string hex)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			Color result = default(Color);
			if (!ColorUtility.TryParseHtmlString("#" + hex, ref result))
			{
				return Color.white;
			}
			return result;
		}

		public Dictionary<string, ConfigEntry<Color>> GetColorConfigs()
		{
			return _colorConfigs;
		}

		public Dictionary<string, ConfigEntry<bool>> GetColorEnabledConfigs()
		{
			return _colorEnabledConfigs;
		}

		public void HighlightAllInteractables()
		{
			if (_highlightEnabled)
			{
				HighlightInteractables<PurchaseInteraction>((Func<PurchaseInteraction, string>)((PurchaseInteraction i) => i.displayNameToken));
				HighlightInteractables<BarrelInteraction>((Func<BarrelInteraction, string>)((BarrelInteraction _) => "BARREL_NAME"));
				HighlightInteractables<ScrapperController>((Func<ScrapperController, string>)((ScrapperController _) => "SCRAPPER_NAME"));
				HighlightInteractables<MultiShopController>((Func<MultiShopController, string>)((MultiShopController _) => "TRIPLE_SHOP"));
				HighlightInteractables<PressurePlateController>((Func<PressurePlateController, string>)((PressurePlateController _) => "SECRET_BUTTON"));
				HighlightInteractables<TeleporterInteraction>((Func<TeleporterInteraction, string>)((TeleporterInteraction _) => "TELEPORTER_NAME"));
				HighlightInteractables<GenericPickupController>((Func<GenericPickupController, string>)((GenericPickupController i) => i.GetDisplayName()));
				HighlightInteractables<GeodeController>((Func<GeodeController, string>)((GeodeController i) => i.GetDisplayName()));
			}
		}

		private void HighlightInteractables<T>(Func<T, string> tokenSelector) where T : Component
		{
			T[] array = Object.FindObjectsOfType<T>();
			foreach (T val in array)
			{
				HighlightInteractable(((Component)val).gameObject, tokenSelector(val));
			}
		}

		private void HighlightInteractable(GameObject interactable, string token)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)interactable))
			{
				return;
			}
			string colorGroupForToken = GetColorGroupForToken(token);
			if (colorGroupForToken != null && !_colorEnabledConfigs[colorGroupForToken].Value)
			{
				return;
			}
			Color value;
			Color val = (_tokenColorMap.TryGetValue(token, out value) ? value : _colorConfigs["Default"].Value);
			if (HighlightInteractablesEnabled)
			{
				Highlight val2 = interactable.GetComponent<Highlight>() ?? interactable.AddComponent<Highlight>();
				((Behaviour)val2).enabled = (val2.isOn = true);
				if (!Object.op_Implicit((Object)(object)val2.targetRenderer))
				{
					val2.targetRenderer = GetRendererForInteractable(interactable, token);
					if (!Object.op_Implicit((Object)(object)val2.targetRenderer))
					{
						_log.LogWarning((object)("No renderer for " + ((Object)interactable).name));
						return;
					}
				}
				val2.strength = 1f;
				val2.highlightColor = (HighlightColor)3;
				val2.CustomColor = val;
			}
			(interactable.GetComponent<HighlightCleaner>() ?? interactable.AddComponent<HighlightCleaner>()).target = interactable;
			if (!(token == "MULTISHOP_TERMINAL_NAME"))
			{
				bool needLabel = _drawLabels.Value || _drawBoundingBox.Value;
				UpdateLabelForInteractable(interactable, token, needLabel, val);
			}
		}

		public void UpdateAllLabelsAndBoxes()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			foreach (GameObject allInteractable in GetAllInteractables())
			{
				string tokenForGameObject = Utils.GetTokenForGameObject(allInteractable);
				if (!(tokenForGameObject == "`"))
				{
					Color value;
					Color color = ((_tokenColorMap != null && tokenForGameObject != null && _tokenColorMap.TryGetValue(tokenForGameObject, out value)) ? value : _colorConfigs["Default"].Value);
					bool needLabel = _drawLabels.Value || _drawBoundingBox.Value;
					UpdateLabelForInteractable(allInteractable, tokenForGameObject, needLabel, color);
				}
			}
		}

		private void UpdateLabelForInteractable(GameObject interactable, string token, bool needLabel, Color color)
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			if (token == "MULTISHOP_TERMINAL_NAME")
			{
				return;
			}
			Transform val = interactable.transform.Find("ESPMarker") ?? CreateMarker(interactable.transform);
			InteractableLabel interactableLabel = ((Component)val).GetComponent<InteractableLabel>();
			if (needLabel)
			{
				if ((Object)(object)interactableLabel == (Object)null)
				{
					interactableLabel = ((Component)val).gameObject.AddComponent<InteractableLabel>();
				}
				string value;
				string label = (InteractableDisplayNames.Map.TryGetValue(token, out value) ? value : token);
				interactableLabel.Label = label;
				interactableLabel.Color = color;
				interactableLabel.BoundingBoxSize = new Vector2(40f, 40f);
				interactableLabel.Interactable = interactable;
				interactableLabel.Logger = _log;
				interactableLabel.DrawLabelsConfig = _drawLabels;
				interactableLabel.DrawBoundingBoxConfig = _drawBoundingBox;
				interactableLabel.UseAdvancedLabelConfig = _useAdvancedLabel;
				interactableLabel.HighContrastConfig = _highContrastText;
				interactableLabel.LabelFontSizeConfig = _labelFontSize;
			}
			else if ((Object)(object)interactableLabel != (Object)null)
			{
				Object.Destroy((Object)(object)interactableLabel);
			}
		}

		private static Renderer GetRendererForInteractable(GameObject interactable, string token)
		{
			if (token == "BARREL_NAME")
			{
				ModelLocator component = interactable.GetComponent<ModelLocator>();
				Transform val = ((component != null) ? component.modelTransform : null);
				if (!Object.op_Implicit((Object)(object)val))
				{
					return null;
				}
				return ((Component)val).GetComponentInChildren<Renderer>(true);
			}
			return interactable.GetComponentInChildren<Renderer>();
		}

		private static Transform CreateMarker(Transform parent)
		{
			//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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("ESPMarker");
			val.transform.SetParent(parent, false);
			val.transform.localPosition = Vector3.up * 1f;
			return val.transform;
		}

		private string GetColorGroupForToken(string token)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			foreach (KeyValuePair<string, ConfigEntry<Color>> colorConfig in _colorConfigs)
			{
				if (_tokenColorMap.TryGetValue(token, out var value) && value == colorConfig.Value.Value)
				{
					return colorConfig.Key;
				}
			}
			return null;
		}

		public void RefreshTokenColorMap()
		{
			//IL_001c: 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_005c: 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_009c: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: 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_019c: 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)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: 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_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_039c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dc: 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_041c: Unknown result type (might be due to invalid IL or missing references)
			//IL_043c: Unknown result type (might be due to invalid IL or missing references)
			//IL_045c: Unknown result type (might be due to invalid IL or missing references)
			//IL_047c: Unknown result type (might be due to invalid IL or missing references)
			//IL_049c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_051c: Unknown result type (might be due to invalid IL or missing references)
			_tokenColorMap = new Dictionary<string, Color>
			{
				{
					"CHEST1_NAME",
					_colorConfigs["Chest"].Value
				},
				{
					"CHEST2_NAME",
					_colorConfigs["Chest"].Value
				},
				{
					"LOCKBOX_NAME",
					_colorConfigs["Chest"].Value
				},
				{
					"CASINOCHEST_NAME",
					_colorConfigs["Chest"].Value
				},
				{
					"GOLDCHEST_NAME",
					_colorConfigs["Chest"].Value
				},
				{
					"CHEST1_STEALTHED_NAME",
					_colorConfigs["Chest"].Value
				},
				{
					"LUNAR_CHEST_NAME",
					_colorConfigs["Lunar"].Value
				},
				{
					"BARREL_NAME",
					_colorConfigs["Barrel"].Value
				},
				{
					"EQUIPMENTBARREL_NAME",
					_colorConfigs["Chest"].Value
				},
				{
					"CATEGORYCHEST_HEALING_NAME",
					_colorConfigs["Chest"].Value
				},
				{
					"CATEGORYCHEST_DAMAGE_NAME",
					_colorConfigs["Chest"].Value
				},
				{
					"CATEGORYCHEST_UTILITY_NAME",
					_colorConfigs["Chest"].Value
				},
				{
					"CATEGORYCHEST2_HEALING_NAME",
					_colorConfigs["Chest"].Value
				},
				{
					"CATEGORYCHEST2_DAMAGE_NAME",
					_colorConfigs["Chest"].Value
				},
				{
					"CATEGORYCHEST2_UTILITY_NAME",
					_colorConfigs["Chest"].Value
				},
				{
					"MULTISHOP_TERMINAL_NAME",
					_colorConfigs["Shop"].Value
				},
				{
					"TRIPLE_SHOP",
					_colorConfigs["Shop"].Value
				},
				{
					"DUPLICATOR_NAME",
					_colorConfigs["Printer"].Value
				},
				{
					"DUPLICATOR_WILD_NAME",
					_colorConfigs["Printer"].Value
				},
				{
					"DUPLICATOR_MILITARY_NAME",
					_colorConfigs["Printer"].Value
				},
				{
					"BAZAAR_CAULDRON_NAME",
					_colorConfigs["Printer"].Value
				},
				{
					"SCRAPPER_NAME",
					_colorConfigs["Printer"].Value
				},
				{
					"RADIOTOWER_NAME",
					_colorConfigs["Drone"].Value
				},
				{
					"TURRET1_INTERACTABLE_NAME",
					_colorConfigs["Drone"].Value
				},
				{
					"DRONE_GUNNER_INTERACTABLE_NAME",
					_colorConfigs["Drone"].Value
				},
				{
					"DRONE_HEALING_INTERACTABLE_NAME",
					_colorConfigs["Drone"].Value
				},
				{
					"EMERGENCYDRONE_INTERACTABLE_NAME",
					_colorConfigs["Drone"].Value
				},
				{
					"DRONE_MISSILE_INTERACTABLE_NAME",
					_colorConfigs["Drone"].Value
				},
				{
					"EQUIPMENTDRONE_INTERACTABLE_NAME",
					_colorConfigs["Drone"].Value
				},
				{
					"FLAMEDRONE_INTERACTABLE_NAME",
					_colorConfigs["Drone"].Value
				},
				{
					"DRONE_MEGA_INTERACTABLE_NAME",
					_colorConfigs["Drone"].Value
				},
				{
					"NEWT_STATUE_NAME",
					_colorConfigs["Lunar"].Value
				},
				{
					"SECRET_BUTTON",
					_colorConfigs["Lunar"].Value
				},
				{
					"MOON_BATTERY_MASS_NAME",
					_colorConfigs["Lunar"].Value
				},
				{
					"MOON_BATTERY_DESIGN_NAME",
					_colorConfigs["Lunar"].Value
				},
				{
					"MOON_BATTERY_SOUL_NAME",
					_colorConfigs["Lunar"].Value
				},
				{
					"MOON_BATTERY_BLOOD_NAME",
					_colorConfigs["Lunar"].Value
				},
				{
					"LUNAR_TERMINAL_NAME",
					_colorConfigs["Lunar"].Value
				},
				{
					"LUNAR_REROLL_NAME",
					_colorConfigs["Lunar"].Value
				},
				{
					"BAZAAR_SEER_NAME",
					_colorConfigs["Lunar"].Value
				},
				{
					"TELEPORTER_NAME",
					_colorConfigs["Teleporter"].Value
				}
			};
		}

		[IteratorStateMachine(typeof(<GetAllInteractables>d__59))]
		private IEnumerable<GameObject> GetAllInteractables()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <GetAllInteractables>d__59(-2);
		}

		public void RemoveHighlightsAndLabelsForColorGroup(string colorGroup)
		{
			Highlight[] array = Object.FindObjectsOfType<Highlight>();
			foreach (Highlight val in array)
			{
				string tokenForGameObject = Utils.GetTokenForGameObject(((Component)val).gameObject);
				if (tokenForGameObject != null && GetColorGroupForToken(tokenForGameObject) == colorGroup)
				{
					val.isOn = false;
					Object.Destroy((Object)(object)val);
				}
			}
			InteractableLabel[] array2 = Object.FindObjectsOfType<InteractableLabel>();
			foreach (InteractableLabel interactableLabel in array2)
			{
				GameObject interactable = interactableLabel.Interactable;
				if (!((Object)(object)interactable == (Object)null))
				{
					string tokenForGameObject2 = Utils.GetTokenForGameObject(interactable);
					if (tokenForGameObject2 != null && GetColorGroupForToken(tokenForGameObject2) == colorGroup)
					{
						Object.Destroy((Object)(object)interactableLabel);
					}
				}
			}
		}
	}
}