Decompiled source of Monitor Label Continued v3.2.1

BepInEx/Plugins/Monitor_Labels_Continued/MonitorLabelsContinued.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using LobbyCompatibility.Enums;
using LobbyCompatibility.Features;
using Microsoft.CodeAnalysis;
using MonitorLabelsContinued.BepInEx;
using MonitorLabelsContinued.BulkImport;
using MonitorLabelsContinued.ModCompat;
using MonitorLabelsContinued.ModIntegrations;
using MonitorLabelsContinued.Utils;
using MonitorLabelsContinued.Utils.ExtensionMethods;
using Steamworks;
using Steamworks.Data;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MonitorLabelsContinued")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Lethal Company Plugin")]
[assembly: AssemblyTitle("MonitorLabelsContinued")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MonitorLabelsContinued
{
	[BepInProcess("Lethal Company.exe")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("LethalCompany.Lego.MonitorLabelContinued", "Monitor Label Continued", "3.2.1")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		public static Plugin Instance;

		private void Awake()
		{
			Instance = this;
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Monitor Label Continued v3.2.1 Loading...");
			ConfigMigration.Migrate();
			InitBepInEx.Init(((BaseUnityPlugin)this).Config);
			InitModIntegrations.Init("LethalCompany.Lego.MonitorLabelContinued", "3.2.1");
			InitModCompat.Init();
			ConfigMigration.HandleBridgeDLLState();
			BepInExConfig.EnableLegacyBridge.SettingChanged += delegate
			{
				ConfigMigration.HandleBridgeDLLState();
			};
			Logger.LogInfo((object)"Monitor Label Continued v3.2.1 plugin fully loaded.");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "MonitorLabelsContinued";

		public const string PLUGIN_NAME = "Lethal Company Plugin";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace MonitorLabelsContinued.Utils
{
	public static class ColorCalculator
	{
		public const int FULL_HEALTH = 100;

		public const int HALF_HEALTH = 50;

		public const int CRITICAL_HEALTH = 10;

		public static Color GetColorDependingOnHealth(PlayerControllerB playerController, bool isTarget)
		{
			//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_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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_0059: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			Color value = BepInExConfig.PlayerFullHealthColour.Value;
			Color value2 = BepInExConfig.PlayerHalfHealthColour.Value;
			Color value3 = BepInExConfig.PlayerCriticalHealthColour.Value;
			if (playerController == null)
			{
				return value;
			}
			if (playerController.health == 100)
			{
				return Colors.GetPlayerColor(playerController, isTarget);
			}
			float num;
			if (playerController.health >= 50)
			{
				num = Mathf.InverseLerp(50f, 100f, (float)playerController.health);
				return Color.Lerp(value2, value, num);
			}
			num = Mathf.InverseLerp(10f, 50f, (float)playerController.health);
			return Color.Lerp(value3, value2, num);
		}
	}
	public static class ConfigMigration
	{
		private static float lastMigrationClickTime;

		public static void Migrate()
		{
			try
			{
				string configPath = Paths.ConfigPath;
				string path = Path.Combine(configPath, "DannyVD.mods.LethalCompany.MonitorLabels.cfg");
				string text = Path.Combine(configPath, "LethalComapny.Lego.MonitorLabelContinued.cfg");
				string text2 = Path.Combine(configPath, "LethalCompany.Lego.MonitorLabelContinued.cfg");
				if (!File.Exists(text2))
				{
					if (File.Exists(text))
					{
						File.Move(text, text2);
						BepInExConfig.config.Reload();
						Plugin.Logger.LogInfo((object)"Successfully migrated and renamed misspelled configuration file (v3.0.0 -> v3.0.1)");
					}
					else
					{
						File.Exists(path);
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogWarning((object)("Failed to run configuration migration: " + ex.Message));
			}
		}

		public static void RequestMigration()
		{
			try
			{
				string configPath = Paths.ConfigPath;
				string text = Path.Combine(configPath, "DannyVD.mods.LethalCompany.MonitorLabels.cfg");
				string destFileName = Path.Combine(configPath, "LethalCompany.Lego.MonitorLabelContinued.cfg");
				if (File.Exists(text))
				{
					float realtimeSinceStartup = Time.realtimeSinceStartup;
					if (realtimeSinceStartup - lastMigrationClickTime > 3f)
					{
						lastMigrationClickTime = realtimeSinceStartup;
						return;
					}
					lastMigrationClickTime = 0f;
					File.Copy(text, destFileName, overwrite: true);
					((BaseUnityPlugin)Plugin.Instance).Config.Reload();
					Plugin.Logger.LogInfo((object)"Successfully migrated and applied settings from the original MonitorLabels mod");
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogWarning((object)("Failed to run configuration migration request: " + ex.Message));
			}
		}

		internal static void HandleBridgeDLLState()
		{
			try
			{
				string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
				if (string.IsNullOrEmpty(directoryName))
				{
					return;
				}
				string path = "API";
				string text = Path.Combine(directoryName, path, "MonitorLabels.dll");
				string text2 = Path.Combine(directoryName, path, "MonitorLabels.dll.disabled");
				if (BepInExConfig.EnableLegacyBridge.Value)
				{
					if (File.Exists(text2))
					{
						File.Move(text2, text);
						Plugin.Logger.LogWarning((object)"Legacy compatibility bridge enabled. it will apply at restart.");
					}
				}
				else if (File.Exists(text))
				{
					File.Move(text, text2);
					Plugin.Logger.LogWarning((object)"Legacy compatibility bridge disabled. it will apply at restart.");
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("Failed to manage legacy bridge DLL state: " + ex.Message));
			}
		}
	}
	public static class Constants
	{
		public const string CUSTOM_PLAYER_COLOR_METADATA_KEY = "MonitorLabelsContinued_CustomPlayerLabelColor";
	}
	public static class PluginInfos
	{
		public const string PLUGIN_NAME = "Monitor Label Continued";

		public const string PLUGIN_GUID = "LethalCompany.Lego.MonitorLabelContinued";

		public const string PLUGIN_VERSION = "3.2.1";
	}
	public static class SteamIDs
	{
		public const ulong ORIGINAL_DEV_ID = 76561198166372065uL;

		public const ulong CONTINUED_DEV_ID = 76561198368204860uL;
	}
	public static class Colors
	{
		public static readonly Color OriginalDevColor = new Color(0.52f, 0f, 0.56f);

		public static readonly Color ContinuedDevColor = new Color(0.81f, 0.34f, 1f);

		public static readonly string ContinuedDevColorHex = "#" + ColorUtility.ToHtmlStringRGB(ContinuedDevColor).ToLower();

		public static Color GetPlayerColor(PlayerControllerB player, bool isTarget)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_00bb: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)player == (Object)null)
			{
				return Color.white;
			}
			if (player.playerSteamId == 76561198166372065L)
			{
				return OriginalDevColor;
			}
			if (player.playerSteamId == 76561198368204860L)
			{
				if ((Object)(object)GameNetworkManager.Instance != (Object)null && GameNetworkManager.Instance.currentLobby.HasValue)
				{
					try
					{
						Lobby value = GameNetworkManager.Instance.currentLobby.Value;
						SteamId val = SteamId.op_Implicit(player.playerSteamId);
						Friend val2 = default(Friend);
						((Friend)(ref val2))..ctor(val);
						string memberData = ((Lobby)(ref value)).GetMemberData(val2, "MonitorLabelsContinued_CustomPlayerLabelColor");
						Color result = default(Color);
						if (!string.IsNullOrEmpty(memberData) && ColorUtility.TryParseHtmlString(memberData, ref result))
						{
							return result;
						}
					}
					catch
					{
					}
				}
				return ContinuedDevColor;
			}
			if (!isTarget)
			{
				return BepInExConfig.DefaultPlayerLabelColour.Value;
			}
			return BepInExConfig.TargetPlayerLabelColour.Value;
		}
	}
}
namespace MonitorLabelsContinued.Utils.ExtensionMethods
{
	public static class StringExtensions
	{
		public static string InsertSpaceBeforeCapitals(this string text)
		{
			if (string.IsNullOrEmpty(text))
			{
				return text;
			}
			string text2 = text.ToUpper();
			string text3 = text;
			if (text.Length == 1)
			{
				return text3;
			}
			for (int num = text.Length - 1; num >= 1; num--)
			{
				if (text[num] == text2[num])
				{
					text3 = text3.Insert(num, " ");
				}
			}
			return text3;
		}
	}
}
namespace MonitorLabelsContinued.ModIntegrations
{
	internal class InitModIntegrations
	{
		public static void Init(string pluginGuid, string pluginVersion)
		{
			if (Chainloader.PluginInfos.ContainsKey("BMX.LobbyCompatibility"))
			{
				LobbyCompatModIntegration.Register(pluginGuid, pluginVersion);
			}
			else
			{
				Plugin.Logger.LogInfo((object)"LobbyCompatibility not detected. Skipping compatibility registration.");
			}
			if (Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig"))
			{
				LethalConfigIntegration.Init();
			}
			else
			{
				Plugin.Logger.LogInfo((object)"LethalConfig not detected. Skipping custom menu setup.");
			}
		}
	}
	internal class LethalConfigIntegration
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static GenericButtonHandler <0>__ApplyChanges;

			public static GenericButtonHandler <1>__RequestMigration;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void Init()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Expected O, but got Unknown
			//IL_00d8: 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_00e3: Expected O, but got Unknown
			try
			{
				LethalConfigManager.SetModDescription("No desc yet");
				string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "icon.png");
				if (File.Exists(path))
				{
					byte[] array = File.ReadAllBytes(path);
					Texture2D val = new Texture2D(2, 2);
					if (ImageConversion.LoadImage(val, array))
					{
						LethalConfigManager.SetModIcon(Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)));
					}
				}
				object obj = <>O.<0>__ApplyChanges;
				if (obj == null)
				{
					GenericButtonHandler val2 = ApplyChanges;
					<>O.<0>__ApplyChanges = val2;
					obj = (object)val2;
				}
				LethalConfigManager.AddConfigItem((BaseConfigItem)new GenericButtonConfigItem("Config File", "Apply all config file changes", "Apply the settings from the config file.\nThis way if you made changes in the file the change will they will be loaded.", "Apply", (GenericButtonHandler)obj));
				object obj2 = <>O.<1>__RequestMigration;
				if (obj2 == null)
				{
					GenericButtonHandler val3 = ConfigMigration.RequestMigration;
					<>O.<1>__RequestMigration = val3;
					obj2 = (object)val3;
				}
				LethalConfigManager.AddConfigItem((BaseConfigItem)new GenericButtonConfigItem("Config File", "Copy config from original mod (3s-Double click)", "Imports your configuration from the original MonitorLabels mod (If you have one).\n\nWarning: This will overwrite your current settings! [[ require a 3s double click to execute ]]", "Copy", (GenericButtonHandler)obj2));
				Plugin.Logger.LogInfo((object)"Successfully registered configs with LethalConfig!");
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogWarning((object)("Failed to register with LethalConfig: " + ex.Message));
			}
		}

		private static void ApplyChanges()
		{
			BepInExConfig.config.Reload();
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void RegisterDevColor(ConfigEntry<string> devColorConfig)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			try
			{
				LethalConfigManager.AddConfigItem((BaseConfigItem)new HexColorInputFieldConfigItem(devColorConfig, false));
				Plugin.Logger.LogInfo((object)"Registered DevRadarColor with LethalConfig!");
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogWarning((object)("Failed to register DevRadarColor with LethalConfig: " + ex.Message));
			}
		}
	}
	public static class LobbyCompatModIntegration
	{
		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void Register(string pluginGuid, string pluginVersion)
		{
			try
			{
				PluginHelper.RegisterPlugin(pluginGuid, new Version(pluginVersion), (CompatibilityLevel)0, (VersionStrictness)0);
				Plugin.Logger.LogInfo((object)"Successfully registered with LobbyCompatibility.");
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogWarning((object)("Failed to register with LobbyCompatibility: " + ex.Message));
			}
		}
	}
}
namespace MonitorLabelsContinued.ModCompat
{
	internal class InitModCompat
	{
		public static void Init()
		{
		}
	}
}
namespace MonitorLabelsContinued.BulkImport
{
	public static class AIMapLabelManager
	{
		public static readonly Dictionary<Type, CustomLabelData> CustomAINames = new Dictionary<Type, CustomLabelData>();

		private static bool _checkedLegacyBridge;

		private static IDictionary _legacyCustomAINames;

		private static FieldInfo _legacyLabelField;

		private static FieldInfo _legacyShowLabelField;

		public static bool TryAddNewAI(Type type, CustomLabelData labelData)
		{
			return CustomAINames.TryAdd(type, labelData);
		}

		public static bool TryAddNewAI(Type type, string label, bool showLabel = true)
		{
			return CustomAINames.TryAdd(type, new CustomLabelData(label, showLabel));
		}

		public static void SetAI(Type type, CustomLabelData customLabelData)
		{
			CustomAINames[type] = customLabelData;
		}

		public static void SetAI(Type type, string label, bool showLabel = true)
		{
			SetAI(type, new CustomLabelData(label, showLabel));
		}

		public static void RemoveAI(Type type)
		{
			CustomAINames.Remove(type);
		}

		public static void AddLabelToAI(EnemyAI enemyAI, Transform mapDotParent, bool checkDisabledObjectsForMapDot)
		{
			//IL_008b: 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_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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			bool showLabel;
			string aILabel = GetAILabel(enemyAI, out showLabel);
			if (!showLabel)
			{
				return;
			}
			Transform mapDot = MapLabelUtil.GetMapDot(mapDotParent, checkDisabledObjectsForMapDot);
			if (mapDot == null)
			{
				Plugin.Logger.LogInfo((object)("Child MapDot cannot be found for enemy: " + ((Object)((Component)enemyAI).gameObject).name));
				return;
			}
			if (enemyAI is SandSpiderAI)
			{
				Vector3 localScale = mapDot.localScale;
				float num = Mathf.Max(new float[3] { localScale.x, localScale.y, localScale.z });
				mapDot.localScale = new Vector3(num, num, num);
			}
			TMP_Text obj = MapLabelUtil.AddLabelObject(((Component)mapDot).gameObject, BepInExConfig.EnemyLabelOffset.Value);
			((Graphic)obj).color = BepInExConfig.EnemyLabelColour.Value;
			obj.text = aILabel;
		}

		public static void UpdateAILabel(EnemyAI enemyAI)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			Transform mapDot = MapLabelUtil.GetMapDot(((Component)enemyAI).transform);
			if (mapDot == null)
			{
				return;
			}
			MapLabelUtil.GetRadarLabel(mapDot, out var label);
			if (label != null)
			{
				if (!BepInExConfig.ShowLabelOnDeadEnemies.Value)
				{
					Object.Destroy((Object)(object)((Component)label).gameObject);
				}
				else
				{
					((Graphic)label).color = BepInExConfig.DeadEnemyLabelColour.Value;
				}
			}
		}

		private static string GetAILabel(EnemyAI enemyAI, out bool showLabel)
		{
			showLabel = true;
			if (!(enemyAI is BaboonBirdAI))
			{
				if (!(enemyAI is BlobAI))
				{
					if (!(enemyAI is CentipedeAI))
					{
						if (!(enemyAI is CrawlerAI))
						{
							if (!(enemyAI is RedLocustBees) && !(enemyAI is DocileLocustBeesAI))
							{
								if (!(enemyAI is DoublewingAI))
								{
									if (!(enemyAI is DressGirlAI))
									{
										if (!(enemyAI is FlowermanAI))
										{
											if (!(enemyAI is ForestGiantAI))
											{
												if (!(enemyAI is HoarderBugAI))
												{
													if (!(enemyAI is JesterAI))
													{
														if (!(enemyAI is LassoManAI))
														{
															if (!(enemyAI is MaskedPlayerEnemy))
															{
																if (!(enemyAI is MouthDogAI))
																{
																	if (!(enemyAI is NutcrackerEnemyAI))
																	{
																		if (!(enemyAI is PufferAI))
																		{
																			if (!(enemyAI is SandSpiderAI))
																			{
																				if (!(enemyAI is SandWormAI))
																				{
																					if (!(enemyAI is SpringManAI))
																					{
																						if (!(enemyAI is TestEnemy))
																						{
																							if (!(enemyAI is ButlerEnemyAI))
																							{
																								if (!(enemyAI is RadMechAI))
																								{
																									if (!(enemyAI is FlowerSnakeEnemy))
																									{
																										if (!(enemyAI is BushWolfEnemy))
																										{
																											CaveDwellerAI val = (CaveDwellerAI)(object)((enemyAI is CaveDwellerAI) ? enemyAI : null);
																											if (val == null)
																											{
																												if (!(enemyAI is ClaySurgeonAI))
																												{
																													if (!(enemyAI is GiantKiwiAI))
																													{
																														if (!(enemyAI is PumaAI))
																														{
																															if (!(enemyAI is CadaverBloomAI))
																															{
																																if (!(enemyAI is CadaverGrowthAI))
																																{
																																	if (enemyAI is StingrayAI)
																																	{
																																		return BepInExConfig.GunkfishLabel.Value;
																																	}
																																	return GetUnknownAILabel(enemyAI, out showLabel);
																																}
																																return BepInExConfig.CadaverGrowthLabel.Value;
																															}
																															showLabel = false;
																															return BepInExConfig.CadaverBloomLabel.Value;
																														}
																														return BepInExConfig.FeioparLabel.Value;
																													}
																													return BepInExConfig.GiantSapsuckerLabel.Value;
																												}
																												return BepInExConfig.ClaySurgeonLabel.Value;
																											}
																											if (!ManeaterUtil.HasTransformed(val))
																											{
																												return BepInExConfig.BabyManeaterLabel.Value;
																											}
																											return BepInExConfig.ManeaterLabel.Value;
																										}
																										return BepInExConfig.BushWolfLabel.Value;
																									}
																									if (BepInExConfig.HideLabelOnSomeEnemies.Value)
																									{
																										showLabel = false;
																									}
																									return BepInExConfig.FlowerSnakeLabel.Value;
																								}
																								return BepInExConfig.RadMechLabel.Value;
																							}
																							return BepInExConfig.ButlerLabel.Value;
																						}
																						return "Obunga";
																					}
																					return BepInExConfig.CoilHeadLabel.Value;
																				}
																				if (BepInExConfig.HideLabelOnSomeEnemies.Value)
																				{
																					showLabel = false;
																				}
																				return BepInExConfig.SandWormLabel.Value;
																			}
																			return BepInExConfig.SpiderLabel.Value;
																		}
																		return BepInExConfig.SporeLizardLabel.Value;
																	}
																	return BepInExConfig.NutCrackerLabel.Value;
																}
																return BepInExConfig.DogLabel.Value;
															}
															return BepInExConfig.MaskedLabel.Value;
														}
														return "Lasso";
													}
													return BepInExConfig.JesterLabel.Value;
												}
												return BepInExConfig.HoarderBugLabel.Value;
											}
											return BepInExConfig.ForestGiantLabel.Value;
										}
										return BepInExConfig.BrackenLabel.Value;
									}
									showLabel = false;
									return "Girl";
								}
								if (BepInExConfig.HideLabelOnSomeEnemies.Value)
								{
									showLabel = false;
								}
								return BepInExConfig.ManticoilLabel.Value;
							}
							showLabel = false;
							return "Bees";
						}
						return BepInExConfig.CrawlerLabel.Value;
					}
					return BepInExConfig.CentipedeLabel.Value;
				}
				return BepInExConfig.BlobLabel.Value;
			}
			return BepInExConfig.BaboonHawkLabel.Value;
		}

		private static string GetUnknownAILabel(EnemyAI enemyAISubclassInstance, out bool showLabel)
		{
			foreach (KeyValuePair<Type, CustomLabelData> customAIName in CustomAINames)
			{
				if (customAIName.Key.IsInstanceOfType(enemyAISubclassInstance))
				{
					showLabel = customAIName.Value.ShowLabel;
					return customAIName.Value.Label;
				}
			}
			if (TryGetLegacyBridgeLabel(((object)enemyAISubclassInstance).GetType(), out var label, out var showLabel2))
			{
				showLabel = showLabel2;
				return label;
			}
			showLabel = true;
			string value = BepInExConfig.UnknownLabel.Value;
			if (!value.Equals(string.Empty))
			{
				return value;
			}
			return MapLabelUtil.RemoveCloneFromString(((Object)((Component)enemyAISubclassInstance).gameObject).name).InsertSpaceBeforeCapitals();
		}

		private static bool TryGetLegacyBridgeLabel(Type enemyType, out string label, out bool showLabel)
		{
			label = null;
			showLabel = false;
			if (!_checkedLegacyBridge)
			{
				_checkedLegacyBridge = true;
				try
				{
					Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
					foreach (Assembly assembly in assemblies)
					{
						if (assembly.GetName().Name == "MonitorLabels")
						{
							_legacyCustomAINames = (assembly.GetType("MonitorLabels.AIMapLabelManager")?.GetField("CustomAINames", BindingFlags.Static | BindingFlags.Public))?.GetValue(null) as IDictionary;
							break;
						}
					}
				}
				catch (Exception ex)
				{
					Plugin.Logger.LogError((object)("Error linking legacy MonitorLabels bridge: " + ex.Message));
				}
			}
			if (_legacyCustomAINames == null || _legacyCustomAINames.Count == 0)
			{
				return false;
			}
			foreach (object key in _legacyCustomAINames.Keys)
			{
				if (!(key is Type type) || !type.IsAssignableFrom(enemyType))
				{
					continue;
				}
				object obj = _legacyCustomAINames[key];
				if (obj != null)
				{
					Type type2 = obj.GetType();
					if ((object)_legacyLabelField == null)
					{
						_legacyLabelField = type2.GetField("Label");
					}
					if ((object)_legacyShowLabelField == null)
					{
						_legacyShowLabelField = type2.GetField("ShowLabel");
					}
					label = _legacyLabelField?.GetValue(obj) as string;
					showLabel = (bool)(_legacyShowLabelField?.GetValue(obj) ?? ((object)true));
					return true;
				}
			}
			return false;
		}
	}
	public static class AssetBundleUtil
	{
		private static readonly string assemblyDirectory;

		private static readonly Dictionary<string, AssetBundle> loadedAssetBundles;

		static AssetBundleUtil()
		{
			loadedAssetBundles = new Dictionary<string, AssetBundle>();
			assemblyDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
		}

		public static bool TryLoadAsset<TAssetType>(string bundleName, string assetPath, out TAssetType asset) where TAssetType : Object
		{
			if (!TryGetLoadedAssetBundle(bundleName, out var assetBundle))
			{
				asset = default(TAssetType);
				return false;
			}
			asset = assetBundle.LoadAsset<TAssetType>(assetPath);
			return true;
		}

		public static bool TryLoadAllAssets<TAssetType>(string bundleName, out TAssetType[] assets) where TAssetType : Object
		{
			if (!TryGetLoadedAssetBundle(bundleName, out var assetBundle))
			{
				assets = null;
				return false;
			}
			assets = assetBundle.LoadAllAssets<TAssetType>();
			return assets.Length != 0;
		}

		public static bool TryLoadAssetBundle(string bundleName, out AssetBundle assetBundle)
		{
			assetBundle = AssetBundle.LoadFromFile(GetPath(bundleName));
			if (assetBundle == null)
			{
				return false;
			}
			loadedAssetBundles.Add(bundleName, assetBundle);
			return true;
		}

		public static bool TryUnloadAssetBundle(string bundleName, bool unloadAllLoadedObjects)
		{
			if (loadedAssetBundles.Remove(bundleName, out var value))
			{
				value.Unload(unloadAllLoadedObjects);
				return true;
			}
			return false;
		}

		public static void UnloadAllAssetBundles(bool unloadAllLoadedObjects)
		{
			AssetBundle.UnloadAllAssetBundles(unloadAllLoadedObjects);
		}

		private static bool TryGetLoadedAssetBundle(string bundleName, out AssetBundle assetBundle)
		{
			if (loadedAssetBundles.TryGetValue(bundleName, out var value))
			{
				assetBundle = value;
				return true;
			}
			return TryLoadAssetBundle(bundleName, out assetBundle);
		}

		private static string GetPath(string path)
		{
			return Path.Combine(assemblyDirectory, path);
		}
	}
	public class BetterMonoBehaviour : MonoBehaviour
	{
		[CompilerGenerated]
		private Transform <CachedTransform>k__BackingField;

		[CompilerGenerated]
		private GameObject <CachedGameObject>k__BackingField;

		public Transform CachedTransform
		{
			get
			{
				if ((Object)(object)<CachedTransform>k__BackingField == (Object)null)
				{
					<CachedTransform>k__BackingField = ((Component)this).transform;
				}
				return <CachedTransform>k__BackingField;
			}
		}

		public GameObject CachedGameObject
		{
			get
			{
				if (<CachedGameObject>k__BackingField == null)
				{
					<CachedGameObject>k__BackingField = ((Component)this).gameObject;
				}
				return <CachedGameObject>k__BackingField;
			}
		}

		public Transform transform => CachedTransform;

		public GameObject gameObject => CachedGameObject;
	}
	internal class ContinuouslyUpdateToolLabel : BetterMonoBehaviour
	{
		private TMP_Text label;

		private GrabbableObject item;

		internal bool IsUpdating { get; private set; }

		internal void Initialize(GrabbableObject grabbableObject, TMP_Text radarLabel)
		{
			item = grabbableObject;
			label = radarLabel;
			((MonoBehaviour)this).StartCoroutine(UpdateLabelRoutine());
		}

		private void UpdateLabel()
		{
			PlayerItemSlotsUtil.GetFirstToolAndFirstToolInUse(item.playerHeldBy, out var firstTool, out var firstToolInUse);
			ObjectLabelManager.SetScrapLabel(item, label, firstTool, firstToolInUse);
		}

		private IEnumerator UpdateLabelRoutine()
		{
			while (true)
			{
				IsUpdating = true;
				while (item.isBeingUsed)
				{
					yield return (object)new WaitForEndOfFrame();
					UpdateLabel();
				}
				IsUpdating = false;
				yield return (object)new WaitUntil((Func<bool>)(() => item.isBeingUsed));
			}
		}
	}
	public struct CustomLabelData
	{
		public string Label;

		public bool ShowLabel;

		public CustomLabelData(string label, bool showLabel = true)
		{
			Label = label;
			ShowLabel = showLabel;
		}
	}
	public class DestroyRadarIconOnDestroy : BetterMonoBehaviour
	{
		private GrabbableObject grabbableObject;

		private void Awake()
		{
			grabbableObject = ((Component)this).GetComponent<GrabbableObject>();
		}

		private void OnDestroy()
		{
			if (!((Object)(object)grabbableObject == (Object)null))
			{
				Transform radarIcon = grabbableObject.radarIcon;
				if (!((Object)(object)radarIcon == (Object)null))
				{
					Object.Destroy((Object)(object)((Component)radarIcon).gameObject);
					grabbableObject = null;
				}
			}
		}
	}
	public class LabelOffsetManager : BetterMonoBehaviour
	{
		public const float LABEL_HEIGHT = 1.15f;

		public Vector2 Offset { get; set; }

		private void Start()
		{
			SetOffset();
		}

		protected void SetOffset()
		{
			//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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = base.transform.parent.position;
			position += MapCameraRotationObserver.MapCameraUp * Offset.y;
			position += MapCameraRotationObserver.MapCameraRight * Offset.x;
			position += Vector3.up * 1.15f;
			base.transform.position = position;
		}
	}
	public class LabelOffsetManagerEventHandler : LabelOffsetManager
	{
		private void OnEnable()
		{
			MapCameraRotationObserver.OnMapCameraRotated += base.SetOffset;
		}

		private void OnDisable()
		{
			MapCameraRotationObserver.OnMapCameraRotated -= base.SetOffset;
		}
	}
	public class LabelOffsetManagerContinuously : LabelOffsetManager
	{
		private void LateUpdate()
		{
			SetOffset();
		}
	}
	public static class ManeaterUtil
	{
		public static bool HasTransformed(CaveDwellerAI caveDwellerAI)
		{
			return (double)caveDwellerAI.growthMeter >= 1.0;
		}
	}
	public class MapCameraRotationObserver : BetterMonoBehaviour
	{
		public static Vector3 MapCameraUp { get; private set; }

		public static Vector3 MapCameraRight { get; private set; }

		public static Quaternion MapCameraRotation { get; private set; }

		public static event Action OnMapCameraRotated;

		private void LateUpdate()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			Quaternion rotation = base.CachedTransform.rotation;
			if (!QuaternionMathUtil.IsApproximate(MapCameraRotation, rotation))
			{
				MapCameraRotated(base.CachedTransform);
			}
		}

		private static void MapCameraRotated(Transform transform)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			MapCameraUp = transform.up;
			MapCameraRight = transform.right;
			MapCameraRotation = transform.rotation;
			MapCameraRotationObserver.OnMapCameraRotated();
		}

		static MapCameraRotationObserver()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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)
			MapCameraRotationObserver.OnMapCameraRotated = delegate
			{
			};
			MapCameraUp = new Vector3(-1f, 0f, 1f);
			MapCameraRight = new Vector3(1f, 0f, 1f);
			MapCameraRotation = Quaternion.Euler(90f, -45f, 0f);
		}
	}
	public static class MapLabelUtil
	{
		public const string MAP_DOT_NAME = "MapDot";

		public const string RADAR_BOOSTER_DOT_NAME = "RadarBoosterDot";

		public const string LABEL_OBJECT_NAME = "MapLabel";

		private static readonly Vector3 labelPosition = new Vector3(0f, 0.5f, 0f);

		private static readonly Vector3 labelScale = new Vector3(0.5f, 0.5f, 0.5f);

		public static TMP_Text AddLabelObject(GameObject parent, Vector2 labelOffset, bool continuouslyUpdateRotationAndOffset = true)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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)
			GameObject val = new GameObject("MapLabel");
			Transform transform = val.transform;
			transform.SetParent(parent.transform, false);
			transform.localPosition = labelPosition;
			transform.rotation = MapCameraRotationObserver.MapCameraRotation;
			transform.localScale = labelScale;
			val.layer = parent.layer;
			val.tag = parent.tag;
			LabelOffsetManager labelOffsetManager;
			if (continuouslyUpdateRotationAndOffset)
			{
				val.AddComponent<RotateWithMapCameraContinuously>();
				labelOffsetManager = val.AddComponent<LabelOffsetManagerContinuously>();
			}
			else
			{
				val.AddComponent<RotateWithMapCamera>();
				labelOffsetManager = val.AddComponent<LabelOffsetManagerEventHandler>();
			}
			labelOffsetManager.Offset = labelOffset;
			TextMeshPro obj = val.AddComponent<TextMeshPro>();
			((TMP_Text)obj).alignment = (TextAlignmentOptions)514;
			((TMP_Text)obj).autoSizeTextContainer = true;
			((TMP_Text)obj).enableWordWrapping = false;
			((TMP_Text)obj).overflowMode = (TextOverflowModes)0;
			return (TMP_Text)(object)obj;
		}

		public static Transform GetMapDot(Transform parent, bool checkDisabledObjects = false)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			Queue<Transform> queue = new Queue<Transform>();
			foreach (Transform item in parent)
			{
				Transform val = item;
				if (checkDisabledObjects || ((Component)val).gameObject.activeInHierarchy)
				{
					queue.Enqueue(val);
				}
			}
			while (queue.Count > 0)
			{
				Transform val2 = queue.Dequeue();
				if (((Object)((Component)val2).gameObject).name.Contains("MapDot"))
				{
					return val2;
				}
				foreach (Transform item2 in val2)
				{
					Transform val3 = item2;
					if (checkDisabledObjects || ((Component)val3).gameObject.activeInHierarchy)
					{
						queue.Enqueue(val3);
					}
				}
			}
			return null;
		}

		public static Transform GetRadarLabel(Transform radarParent, out TMP_Text label)
		{
			Transform val = radarParent.Find("MapLabel");
			label = ((val != null) ? ((Component)val).GetComponent<TMP_Text>() : null);
			return val;
		}

		public static Transform GetRadarBoosterMapDot(Transform radarParent)
		{
			return radarParent.Find("RadarBoosterDot");
		}

		public static string RemoveCloneFromString(string name)
		{
			int num = name.IndexOf('(');
			if (num != -1)
			{
				return name.Substring(0, num);
			}
			return name;
		}
	}
	internal static class ObjectLabelManager
	{
		internal static void TryAddLabelToScrap(GrabbableObject item)
		{
			Transform radarIcon = item.radarIcon;
			if (!((Object)(object)radarIcon == (Object)null))
			{
				AddLabelToScrap(item, ((Component)radarIcon).gameObject);
			}
		}

		internal static void UpdateScrapLabel(GrabbableObject item)
		{
			UpdateItemSlotLabel(item, null, null);
		}

		internal static void UpdateItemSlotLabel(GrabbableObject item, GrabbableObject firstToolInItemSlots, GrabbableObject firstToolInUseInItemSlots)
		{
			Transform radarIcon = item.radarIcon;
			if ((Object)(object)radarIcon == (Object)null && !item.itemProperties.isScrap && BepInExConfig.ShowIconOnTools.Value)
			{
				ContinuouslyUpdateToolLabel component = ((Component)item).GetComponent<ContinuouslyUpdateToolLabel>();
				if ((Object)(object)component != (Object)null)
				{
					Object.Destroy((Object)(object)component);
				}
				ToolIconSpawner.SpawnIcon(item);
				radarIcon = item.radarIcon;
				if ((Object)(object)radarIcon != (Object)null && BepInExConfig.ShowLabelOnTools.Value)
				{
					TryAddLabelToScrap(item);
				}
			}
			if ((Object)(object)radarIcon == (Object)null)
			{
				return;
			}
			ContinuouslyUpdateToolLabel component2 = ((Component)item).GetComponent<ContinuouslyUpdateToolLabel>();
			if (!((Object)(object)component2 != (Object)null) || !component2.IsUpdating)
			{
				MapLabelUtil.GetRadarLabel(radarIcon, out var label);
				if (label != null)
				{
					SetScrapLabel(item, label, firstToolInItemSlots, firstToolInUseInItemSlots);
				}
			}
		}

		internal static void SetScrapLabel(GrabbableObject item, TMP_Text radarLabel, GrabbableObject firstToolInItemSlots = null, GrabbableObject firstToolInUseInItemSlots = null)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			radarLabel.text = GetScrapLabelString(item, out var labelColour, firstToolInItemSlots, firstToolInUseInItemSlots);
			((Graphic)radarLabel).color = labelColour;
		}

		private static void AddLabelToScrap(GrabbableObject item, GameObject radarParent)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			bool isScrap = item.itemProperties.isScrap;
			TMP_Text val = MapLabelUtil.AddLabelObject(radarParent, isScrap ? BepInExConfig.ScrapLabelOffset.Value : BepInExConfig.ToolLabelOffset.Value, continuouslyUpdateRotationAndOffset: false);
			if (isScrap)
			{
				val.fontSize *= BepInExConfig.ScrapLabelScaleFactor.Value;
			}
			else
			{
				val.fontSize = BepInExConfig.ToolLabelFontSize.Value;
			}
			SetScrapLabel(item, val);
			if (item.itemProperties.requiresBattery && BepInExConfig.ShowBatteryChargeOnLabel.Value)
			{
				((Component)item).gameObject.AddComponent<ContinuouslyUpdateToolLabel>().Initialize(item, val);
			}
		}

		private static string GetScrapLabelString(GrabbableObject item, out Color labelColour, GrabbableObject firstToolInItemSlots, GrabbableObject firstToolInUseInItemSlots)
		{
			//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_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: 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_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)item == (Object)null)
			{
				labelColour = Color.white;
				return string.Empty;
			}
			bool flag = !item.itemProperties.isScrap;
			int scrapValue = item.scrapValue;
			if (item.isHeld)
			{
				if (flag && (Object)(object)item.playerHeldBy != (Object)null)
				{
					labelColour = BepInExConfig.CarriedToolLabelColour.Value;
					GrabbableObject currentlyHeldObjectServer = item.playerHeldBy.currentlyHeldObjectServer;
					bool flag2 = (Object)(object)currentlyHeldObjectServer != (Object)null && !currentlyHeldObjectServer.itemProperties.isScrap;
					if (item.isPocketed && BepInExConfig.HideToolLabelIfPocketed.Value)
					{
						if (!item.isBeingUsed || !BepInExConfig.ShowToolIfInUseAndNoOtherToolHeld.Value || flag2)
						{
							return string.Empty;
						}
						if (BepInExConfig.OnlyShow1PocketedLabel.Value)
						{
							GrabbableObject val = ((IEnumerable<GrabbableObject>)item.playerHeldBy.ItemSlots).FirstOrDefault((Func<GrabbableObject, bool>)((GrabbableObject grabbableObject) => (Object)(object)grabbableObject != (Object)null && grabbableObject.isBeingUsed));
							if ((Object)(object)val == (Object)null && (Object)(object)item.playerHeldBy.ItemOnlySlot != (Object)null && item.playerHeldBy.ItemOnlySlot.isBeingUsed)
							{
								val = item.playerHeldBy.ItemOnlySlot;
							}
							if ((Object)(object)item != (Object)(object)val)
							{
								return string.Empty;
							}
						}
					}
					else if (item.isPocketed && BepInExConfig.OnlyShow1PocketedLabel.Value)
					{
						if (flag2 && !BepInExConfig.HideToolLabelIfInHand.Value)
						{
							return string.Empty;
						}
						if (BepInExConfig.ShowToolIfInUseAndNoOtherToolHeld.Value)
						{
							if ((Object)(object)firstToolInUseInItemSlots != (Object)null)
							{
								if ((Object)(object)firstToolInUseInItemSlots != (Object)(object)item)
								{
									return string.Empty;
								}
							}
							else if ((Object)(object)firstToolInItemSlots != (Object)(object)item)
							{
								return string.Empty;
							}
						}
						else if ((Object)(object)item != (Object)(object)firstToolInItemSlots)
						{
							return string.Empty;
						}
					}
					else if (!item.isPocketed && BepInExConfig.HideToolLabelIfInHand.Value)
					{
						return string.Empty;
					}
				}
				else if (flag)
				{
					labelColour = BepInExConfig.CarriedToolLabelColour.Value;
					if (BepInExConfig.HideToolLabelIfInHand.Value)
					{
						return string.Empty;
					}
				}
				else
				{
					labelColour = BepInExConfig.CarriedScrapLabelColour.Value;
					if (BepInExConfig.HideScrapLabelIfCarried.Value)
					{
						return string.Empty;
					}
				}
			}
			else if (item.isInShipRoom)
			{
				if (flag)
				{
					labelColour = BepInExConfig.InShipToolLabelColour.Value;
					if (BepInExConfig.HideToolLabelIfOnShip.Value)
					{
						return string.Empty;
					}
				}
				else
				{
					labelColour = BepInExConfig.InShipScrapLabelColour.Value;
					if (BepInExConfig.HideScrapLabelIfOnShip.Value)
					{
						return string.Empty;
					}
				}
			}
			else
			{
				labelColour = (flag ? BepInExConfig.ToolLabelColour.Value : ((scrapValue >= BepInExConfig.HighValueScrapThreshold.Value) ? BepInExConfig.HighValueScrapLabelColour.Value : BepInExConfig.ScrapLabelColour.Value));
			}
			if (!TryGetCustomLabel(item, out var label))
			{
				return GetFormattedScrapLabel(item, scrapValue, flag);
			}
			return label;
		}

		private static bool TryGetCustomLabel(GrabbableObject item, out string label)
		{
			label = string.Empty;
			if (BepInExConfig.HideScrapLabelOnNutcracker.Value && item is ShotgunItem && item.isHeldByEnemy)
			{
				return true;
			}
			return false;
		}

		private static string GetFormattedScrapLabel(GrabbableObject item, int scrapValue, bool isTool)
		{
			string scrapName = GetScrapName(item);
			if (isTool)
			{
				string arg = string.Empty;
				if (item.itemProperties.requiresBattery && BepInExConfig.ShowBatteryChargeOnLabel.Value && item.insertedBattery != null)
				{
					float num = (item.insertedBattery.empty ? 0f : item.insertedBattery.charge);
					arg = string.Format(BepInExConfig.ToolBatteryStringFormat.Value, num);
				}
				return string.Format(BepInExConfig.ToolLabelStringFormat.Value, scrapName, arg);
			}
			return string.Format(BepInExConfig.ScrapLabelStringFormat.Value, scrapName, scrapValue);
		}

		private static string GetScrapName(GrabbableObject item)
		{
			Item itemProperties = item.itemProperties;
			if (Object.op_Implicit((Object)(object)itemProperties) && !string.IsNullOrEmpty(itemProperties.itemName))
			{
				return itemProperties.itemName;
			}
			ScanNodeProperties componentInChildren = ((Component)item).GetComponentInChildren<ScanNodeProperties>();
			if (!Object.op_Implicit((Object)(object)componentInChildren))
			{
				return MapLabelUtil.RemoveCloneFromString(((Object)((Component)item).gameObject).name).InsertSpaceBeforeCapitals();
			}
			return componentInChildren.headerText;
		}
	}
	public static class PlayerItemSlotsUtil
	{
		public static void GetFirstToolAndFirstToolInUse(PlayerControllerB player, out GrabbableObject firstTool, out GrabbableObject firstToolInUse)
		{
			firstTool = null;
			firstToolInUse = null;
			if (player == null)
			{
				return;
			}
			GrabbableObject[] itemSlots = player.ItemSlots;
			foreach (GrabbableObject val in itemSlots)
			{
				if (!((Object)(object)val == (Object)null) && !val.itemProperties.isScrap)
				{
					if (firstTool == null)
					{
						firstTool = val;
					}
					if (val.isBeingUsed && firstToolInUse == null)
					{
						firstToolInUse = val;
						return;
					}
				}
			}
			if ((Object)(object)player.ItemOnlySlot != (Object)null && !player.ItemOnlySlot.itemProperties.isScrap)
			{
				if (firstTool == null)
				{
					firstTool = player.ItemOnlySlot;
				}
				if (player.ItemOnlySlot.isBeingUsed && firstToolInUse == null)
				{
					firstToolInUse = player.ItemOnlySlot;
				}
			}
		}

		public static void UpdateLabelsOfItemSlots(PlayerControllerB player)
		{
			if (!BepInExConfig.ShowLabelOnTools.Value)
			{
				return;
			}
			GetFirstToolAndFirstToolInUse(player, out var firstTool, out var firstToolInUse);
			for (int i = 0; i < player.ItemSlots.Length; i++)
			{
				GrabbableObject val = player.ItemSlots[i];
				if (!((Object)(object)val == (Object)null) && !val.itemProperties.isScrap)
				{
					ObjectLabelManager.UpdateItemSlotLabel(val, firstTool, firstToolInUse);
				}
			}
			if ((Object)(object)player.ItemOnlySlot != (Object)null && !player.ItemOnlySlot.itemProperties.isScrap)
			{
				ObjectLabelManager.UpdateItemSlotLabel(player.ItemOnlySlot, firstTool, firstToolInUse);
			}
		}
	}
	public static class QuaternionMathUtil
	{
		public static bool IsApproximate(Quaternion lhs, Quaternion rhs, float precision = 4E-07f)
		{
			//IL_0005: 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)
			return 1f - Mathf.Abs(Quaternion.Dot(lhs, rhs)) < precision;
		}
	}
	internal static class RadarTargetLabelManager
	{
		internal static void UpdateLabel(Transform radarTargetTransform)
		{
			if (!((Object)(object)radarTargetTransform == (Object)null))
			{
				int index;
				bool isCurrentRadarTarget;
				TransformAndName matchingRadarTarget = RadarTargetUtils.GetMatchingRadarTarget(radarTargetTransform, out index, out isCurrentRadarTarget);
				if (matchingRadarTarget == null || (Object)(object)matchingRadarTarget.transform == (Object)null)
				{
					Plugin.Logger.LogInfo((object)"Tried to update an invalid transform!\nUpdating all radar targets to make sure everything is correct!");
					UpdateLabels();
				}
				else
				{
					AddTargetLabel(matchingRadarTarget, index, isCurrentRadarTarget);
				}
			}
		}

		internal static void UpdateLabels(int radarTargetIndex = -1)
		{
			if ((Object)(object)StartOfRound.Instance == (Object)null || (Object)(object)StartOfRound.Instance.mapScreen == (Object)null)
			{
				return;
			}
			int num = ((radarTargetIndex != -1) ? radarTargetIndex : StartOfRound.Instance.mapScreen.targetTransformIndex);
			for (int i = 0; i < StartOfRound.Instance.mapScreen.radarTargets.Count; i++)
			{
				bool isCurrentTarget = num == i;
				TransformAndName val = StartOfRound.Instance.mapScreen.radarTargets[i];
				if (val != null && (Object)(object)val.transform != (Object)null)
				{
					AddTargetLabel(val, i, isCurrentTarget);
				}
			}
		}

		internal static void AddTargetLabel(TransformAndName transformAndName, int index, bool isCurrentTarget)
		{
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB component = ((Component)transformAndName.transform).gameObject.GetComponent<PlayerControllerB>();
			bool isDead = false;
			Transform val;
			if ((Object)(object)component != (Object)null)
			{
				if (component.isPlayerDead)
				{
					isDead = true;
					if ((Object)(object)component.redirectToEnemy != (Object)null)
					{
						val = FindRadarDotOfPlayer(((Component)component.redirectToEnemy).transform);
					}
					else
					{
						if (!((Object)(object)component.deadBody != (Object)null))
						{
							return;
						}
						val = MapLabelUtil.GetMapDot(((Component)component.deadBody).transform);
					}
				}
				else
				{
					val = FindRadarDotOfPlayer(((Component)component).transform);
				}
			}
			else
			{
				val = MapLabelUtil.GetRadarBoosterMapDot(transformAndName.transform);
			}
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Logger.LogInfo((object)("Cannot find radar icon for " + transformAndName.name));
				return;
			}
			TMP_Text label;
			Transform radarLabel = MapLabelUtil.GetRadarLabel(val, out label);
			if ((Object)(object)label == (Object)null)
			{
				if ((Object)(object)radarLabel != (Object)null)
				{
					Plugin.Logger.LogInfo((object)"The LabelObject exists but the TMP_Text component does not, this should never happen!\nDestroying the object and reinstantiating it...");
					Object.Destroy((Object)(object)((Component)radarLabel).gameObject);
				}
				label = MapLabelUtil.AddLabelObject(((Component)val).gameObject, BepInExConfig.RadarTargetLabelOffset.Value);
			}
			label.text = GetLabelString(transformAndName, index, isCurrentTarget, isDead, transformAndName.isNonPlayer, component, out var labelColour);
			((Graphic)label).color = labelColour;
		}

		private static string GetLabelString(TransformAndName targetName, int index, bool isTarget, bool isDead, bool isRadarBooster, PlayerControllerB playerControllerB, out Color labelColour)
		{
			//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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: 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_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			if (isDead)
			{
				labelColour = BepInExConfig.DeadPlayerLabelColour.Value;
				if (BepInExConfig.ForceDeadPlayerLabel.Value)
				{
					return GetRadarTargetNameString(targetName, index, isDead: true);
				}
				if (BepInExConfig.HideDeadPlayerLabels.Value || BepInExConfig.HidePlayerLabels.Value)
				{
					return string.Empty;
				}
			}
			else
			{
				if (!isRadarBooster && BepInExConfig.HidePlayerLabels.Value)
				{
					labelColour = Color.white;
					return string.Empty;
				}
				if (isTarget)
				{
					labelColour = (isRadarBooster ? BepInExConfig.TargetRadarBoosterLabelColour.Value : (BepInExConfig.UseColorsToShowPlayerHealth.Value ? ColorCalculator.GetColorDependingOnHealth(playerControllerB, isTarget: true) : Colors.GetPlayerColor(playerControllerB, isTarget: true)));
					if (!BepInExConfig.ShowLabelOnTarget.Value)
					{
						return string.Empty;
					}
				}
				else if (isRadarBooster)
				{
					labelColour = BepInExConfig.RadarBoosterLabelColour.Value;
					if (BepInExConfig.HideRadarBoosterLabels.Value)
					{
						return string.Empty;
					}
				}
				else
				{
					labelColour = (BepInExConfig.UseColorsToShowPlayerHealth.Value ? ColorCalculator.GetColorDependingOnHealth(playerControllerB, isTarget: false) : Colors.GetPlayerColor(playerControllerB, isTarget: false));
				}
			}
			return GetRadarTargetNameString(targetName, index, isDead);
		}

		private static string GetRadarTargetNameString(TransformAndName targetTransformAndName, int index, bool isDead = false)
		{
			string text = targetTransformAndName.name;
			if (isDead)
			{
				string value = BepInExConfig.CustomDeadName.Value;
				if (value != string.Empty)
				{
					text = value;
				}
			}
			text = text[..Mathf.Min(text.Length, BepInExConfig.MaximumNameLength.Value)];
			string arg = string.Empty;
			if (!targetTransformAndName.isNonPlayer && !isDead)
			{
				int currentSlotValue;
				int totalValueCarrying = ScrapUtil.GetTotalValueCarrying(((Component)targetTransformAndName.transform).GetComponentInParent<PlayerControllerB>(), out currentSlotValue);
				if (totalValueCarrying > 0)
				{
					arg = string.Format(BepInExConfig.PlayerCarriedScrapValueStringFormat.Value, totalValueCarrying, currentSlotValue);
				}
			}
			return string.Format(BepInExConfig.PlayerLabelStringFormat.Value, text, index, arg);
		}

		private static Transform FindRadarDotOfPlayer(Transform parent)
		{
			Transform val = parent.Find("Misc");
			return val.Find("MapDot") ?? MapLabelUtil.GetMapDot(val);
		}
	}
	public static class RadarTargetUtils
	{
		public static TransformAndName GetMatchingRadarTarget(Transform transform, out int index, out bool isCurrentRadarTarget)
		{
			if (transform == null)
			{
				index = -1;
				isCurrentRadarTarget = false;
				return null;
			}
			ManualCameraRenderer mapScreen = StartOfRound.Instance.mapScreen;
			int targetTransformIndex = mapScreen.targetTransformIndex;
			for (index = 0; index < mapScreen.radarTargets.Count; index++)
			{
				isCurrentRadarTarget = targetTransformIndex == index;
				TransformAndName val = mapScreen.radarTargets[index];
				if (val != null)
				{
					Transform transform2 = val.transform;
					if (transform == transform2)
					{
						return val;
					}
				}
			}
			isCurrentRadarTarget = false;
			return null;
		}
	}
	public class RotateWithMapCamera : BetterMonoBehaviour
	{
		private void Awake()
		{
			MapCameraRotationObserver.OnMapCameraRotated += RotateWithCamera;
		}

		private void RotateWithCamera()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			base.CachedTransform.rotation = MapCameraRotationObserver.MapCameraRotation;
		}

		private void OnDestroy()
		{
			MapCameraRotationObserver.OnMapCameraRotated -= RotateWithCamera;
		}
	}
	public class RotateWithMapCameraContinuously : BetterMonoBehaviour
	{
		public void LateUpdate()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			base.CachedTransform.rotation = MapCameraRotationObserver.MapCameraRotation;
		}
	}
	public static class ScrapUtil
	{
		public static int GetTotalValueCarrying(PlayerControllerB player, out int currentSlotValue)
		{
			currentSlotValue = 0;
			if (player == null)
			{
				return 0;
			}
			GrabbableObject val = null;
			if (player.currentItemSlot >= 0 && player.currentItemSlot < player.ItemSlots.Length)
			{
				val = player.ItemSlots[player.currentItemSlot];
			}
			else if (player.currentItemSlot == 50)
			{
				val = player.ItemOnlySlot;
			}
			if ((Object)(object)val != (Object)null && val.itemProperties.isScrap)
			{
				currentSlotValue = val.scrapValue;
			}
			int num = player.ItemSlots.Sum((GrabbableObject item) => (!((Object)(object)item == (Object)null) && item.itemProperties.isScrap) ? item.scrapValue : 0);
			if ((Object)(object)player.ItemOnlySlot != (Object)null && player.ItemOnlySlot.itemProperties.isScrap)
			{
				num += player.ItemOnlySlot.scrapValue;
			}
			return num;
		}
	}
	public static class ToolIconSpawner
	{
		private const int mapRadarLayer = 14;

		private static readonly GameObject iconPrefab;

		static ToolIconSpawner()
		{
			AssetBundleUtil.TryLoadAsset<GameObject>("terminalmarker.lem", "Assets/Mods/TerminalMarker/ItemMarker.prefab", out iconPrefab);
			AssetBundleUtil.TryLoadAsset<Material>("terminalmarker.lem", "Assets/Mods/TerminalMarker/MarkerMaterial.mat", out Material asset);
			iconPrefab.GetComponent<Renderer>().sharedMaterial = asset;
		}

		public static void SpawnIcon(GrabbableObject grabbableObject)
		{
			GameObject val = Object.Instantiate<GameObject>(iconPrefab, RoundManager.Instance.mapPropsContainer.transform);
			((Object)val).name = "Tool Marker (" + grabbableObject.itemProperties.itemName + ")";
			val.layer = 14;
			grabbableObject.radarIcon = val.transform;
		}
	}
}
namespace MonitorLabelsContinued.BepInEx
{
	public class BepInExConfig
	{
		public static ConfigEntry<bool> EnableLegacyBridge;

		public static ConfigEntry<LogLevel> LoggingLevel;

		public static ConfigEntry<bool> ForceDeadPlayerLabel;

		public static ConfigEntry<int> MaximumNameLength;

		public static ConfigEntry<bool> ShowLabelOnTarget;

		public static ConfigEntry<string> CustomDeadName;

		public static ConfigEntry<bool> HidePlayerLabels;

		public static ConfigEntry<bool> HideDeadPlayerLabels;

		public static ConfigEntry<bool> HideRadarBoosterLabels;

		public static ConfigEntry<bool> UseColorsToShowPlayerHealth;

		public static ConfigEntry<bool> ShowIconOnTools;

		public static ConfigEntry<bool> ShowLabelOnTools;

		public static ConfigEntry<bool> ShowBatteryChargeOnLabel;

		public static ConfigEntry<float> ToolLabelFontSize;

		public static ConfigEntry<bool> HideToolLabelIfOnShip;

		public static ConfigEntry<bool> HideToolLabelIfInHand;

		public static ConfigEntry<bool> HideToolLabelIfPocketed;

		public static ConfigEntry<bool> OnlyShow1PocketedLabel;

		public static ConfigEntry<bool> ShowToolIfInUseAndNoOtherToolHeld;

		public static ConfigEntry<bool> ShowLabelOnScrap;

		public static ConfigEntry<float> ScrapLabelScaleFactor;

		public static ConfigEntry<bool> HideScrapLabelIfOnShip;

		public static ConfigEntry<bool> HideScrapLabelIfCarried;

		public static ConfigEntry<int> HighValueScrapThreshold;

		public static ConfigEntry<bool> HideScrapLabelOnNutcracker;

		public static ConfigEntry<bool> ShowLabelOnEnemies;

		public static ConfigEntry<bool> ShowLabelOnDeadEnemies;

		public static ConfigEntry<bool> HideLabelOnSomeEnemies;

		public static ConfigEntry<string> UnknownLabel;

		public static ConfigEntry<string> BaboonHawkLabel;

		public static ConfigEntry<string> BlobLabel;

		public static ConfigEntry<string> CentipedeLabel;

		public static ConfigEntry<string> CrawlerLabel;

		public static ConfigEntry<string> ManticoilLabel;

		public static ConfigEntry<string> BrackenLabel;

		public static ConfigEntry<string> ForestGiantLabel;

		public static ConfigEntry<string> HoarderBugLabel;

		public static ConfigEntry<string> JesterLabel;

		public static ConfigEntry<string> MaskedLabel;

		public static ConfigEntry<string> DogLabel;

		public static ConfigEntry<string> NutCrackerLabel;

		public static ConfigEntry<string> SporeLizardLabel;

		public static ConfigEntry<string> SpiderLabel;

		public static ConfigEntry<string> SandWormLabel;

		public static ConfigEntry<string> CoilHeadLabel;

		public static ConfigEntry<string> ButlerLabel;

		public static ConfigEntry<string> RadMechLabel;

		public static ConfigEntry<string> FlowerSnakeLabel;

		public static ConfigEntry<string> ManeaterLabel;

		public static ConfigEntry<string> BabyManeaterLabel;

		public static ConfigEntry<string> ClaySurgeonLabel;

		public static ConfigEntry<string> BushWolfLabel;

		public static ConfigEntry<string> GiantSapsuckerLabel;

		public static ConfigEntry<string> FeioparLabel;

		public static ConfigEntry<string> CadaverBloomLabel;

		public static ConfigEntry<string> CadaverGrowthLabel;

		public static ConfigEntry<string> GunkfishLabel;

		public static ConfigEntry<Color> DeadPlayerLabelColour;

		public static ConfigEntry<Color> TargetPlayerLabelColour;

		public static ConfigEntry<Color> DefaultPlayerLabelColour;

		public static ConfigEntry<Color> PlayerFullHealthColour;

		public static ConfigEntry<Color> PlayerHalfHealthColour;

		public static ConfigEntry<Color> PlayerCriticalHealthColour;

		public static ConfigEntry<Color> TargetRadarBoosterLabelColour;

		public static ConfigEntry<Color> RadarBoosterLabelColour;

		public static ConfigEntry<Color> EnemyLabelColour;

		public static ConfigEntry<Color> DeadEnemyLabelColour;

		public static ConfigEntry<Color> ToolLabelColour;

		public static ConfigEntry<Color> CarriedToolLabelColour;

		public static ConfigEntry<Color> InShipToolLabelColour;

		public static ConfigEntry<Color> ScrapLabelColour;

		public static ConfigEntry<Color> HighValueScrapLabelColour;

		public static ConfigEntry<Color> CarriedScrapLabelColour;

		public static ConfigEntry<Color> InShipScrapLabelColour;

		public static ConfigEntry<Vector2> RadarTargetLabelOffset;

		public static ConfigEntry<Vector2> EnemyLabelOffset;

		public static ConfigEntry<Vector2> ToolLabelOffset;

		public static ConfigEntry<Vector2> ScrapLabelOffset;

		public static ConfigEntry<bool> RemoveDetonatedMineLabel;

		public static ConfigEntry<string> PlayerLabelStringFormat;

		public static ConfigEntry<string> PlayerCarriedScrapValueStringFormat;

		public static ConfigEntry<string> ScrapLabelStringFormat;

		public static ConfigEntry<string> ToolLabelStringFormat;

		public static ConfigEntry<string> ToolBatteryStringFormat;

		public static ConfigFile config;

		internal static void Init(ConfigFile configFile)
		{
			config = configFile;
		}

		public static void ReadConfig()
		{
			//IL_0777: Unknown result type (might be due to invalid IL or missing references)
			//IL_079a: Unknown result type (might be due to invalid IL or missing references)
			//IL_07bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_081e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0861: Unknown result type (might be due to invalid IL or missing references)
			//IL_0890: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_090d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0944: Unknown result type (might be due to invalid IL or missing references)
			//IL_097b: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a0c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a2f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a52: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a75: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a98: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aa2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ac5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0acf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0af2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0afc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b1f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b29: Unknown result type (might be due to invalid IL or missing references)
			EnableLegacyBridge = config.Bind<bool>("0. General", "enableLegacyCompatibility", false, "This allows mod that had the original mod as dependency to work.\n\nThis setting is more of an \"in case you need that\" because those mods a few and probably deprecated.\nYou can enable this if you have a mod that require this (example a mod that had a custom name for their monster).\nNote that this mod tries to name modded monsters based of their name in the code anyway.\nIt can cause a crash if for some reason a mod was dependant on MonitorLabels, for code that isn't the API (verry not likely)\nIf you get crashes, in rare case, this could be why.\nREQUIRES A GAME RESTART TO APPLY.");
			LoggingLevel = config.Bind<LogLevel>("0. General", "logLevel", (LogLevel)7, "What should be logged?\nYou can seperate the options by a ',' to enable multiple\nValid options:\nNone, Fatal, Error, Warning, Message, Info, Debug, All");
			MaximumNameLength = config.Bind<int>("1.1 RadarTarget/Player", "maximumNameLength", 5, "The maximum length of the name that will be shown on the terminal");
			ShowLabelOnTarget = config.Bind<bool>("1.1 RadarTarget/Player", "showLabelOnTarget", true, "Should the currently targeted player also show a label");
			ForceDeadPlayerLabel = config.Bind<bool>("1.1 RadarTarget/Player", "forceDeadPlayerLabel", true, "Should the label of a dead player always be visible?\nThis is to show dead labels if 'hideNormalLabels' is disabled");
			CustomDeadName = config.Bind<string>("1.1 RadarTarget/Player", "customDeadLabel", string.Empty, "A custom label to show if someone is dead, leave empty to use their name instead");
			HidePlayerLabels = config.Bind<bool>("1.1 RadarTarget/Player", "hidePlayerLabels", false, "Don't use any player labels except for 'forceDeadPlayerLabel'");
			HideDeadPlayerLabels = config.Bind<bool>("1.1 RadarTarget/Player", "hideDeadPlayerLabels", false, "Don't use labels for dead players");
			UseColorsToShowPlayerHealth = config.Bind<bool>("1.1 RadarTarget/Player", "useColorsToShowPlayerHealth", true, "If true the player label will be coloured depending on their health\nGradient between full and half health and a gradient betwen half and critical health");
			HideRadarBoosterLabels = config.Bind<bool>("1.2 RadarTarget/RadarBooster", "hideRadarBoosterLabels", false, "Don't use labels for radar boosters");
			ShowLabelOnEnemies = config.Bind<bool>("2.1 Enemies", "showLabelOnEnemies", true, "Should enemies have labels?");
			ShowLabelOnDeadEnemies = config.Bind<bool>("2.1 Enemies", "showLabelOnDeadEnemies", false, "Should the label stay on a dead enemy?");
			HideLabelOnSomeEnemies = config.Bind<bool>("2.1 Enemies", "hideLabelOnSomeEnemies", true, "Don't show a label for the following enemies:\nManticoil\nWorm");
			UnknownLabel = config.Bind<string>("2.2 Enemy Labels", "unknownLabel", string.Empty, "The label of an unidentified enemy, leave empty to use the name");
			BaboonHawkLabel = config.Bind<string>("2.2 Enemy Labels", "baboonHawkLabel", "Hawk", "The label of the BaboonBird enemy");
			BlobLabel = config.Bind<string>("2.2 Enemy Labels", "blobLabel", "Blob", "The label of the Blob enemy");
			CentipedeLabel = config.Bind<string>("2.2 Enemy Labels", "snareFleaLabel", "Snare", "The label of the Centipede (Snare Flea) enemy");
			CrawlerLabel = config.Bind<string>("2.2 Enemy Labels", "crawlerLabel", "Half", "The label of the Crawler (Thumper) enemy");
			ManticoilLabel = config.Bind<string>("2.2 Enemy Labels", "manticoilLabel", "Bird", "The label of the Doublewing (Manticoil) enemy");
			BrackenLabel = config.Bind<string>("2.2 Enemy Labels", "brackenLabel", "Bracken", "The label of the FlowerMan (Bracken) enemy");
			ForestGiantLabel = config.Bind<string>("2.2 Enemy Labels", "forestGiantLabel", "Giant", "The label of the ForestGiant enemy");
			HoarderBugLabel = config.Bind<string>("2.2 Enemy Labels", "hoarderBugLabel", "Bug", "The label of the HoarderBug enemy");
			JesterLabel = config.Bind<string>("2.2 Enemy Labels", "jesterLabel", "Jester", "The label of the Jester enemy");
			MaskedLabel = config.Bind<string>("2.2 Enemy Labels", "maskedPlayerLabel", "X", "The label of the MaskedPlayer enemy");
			DogLabel = config.Bind<string>("2.2 Enemy Labels", "mouthDogLabel", "Dog", "The label of the MouthDog enemy");
			NutCrackerLabel = config.Bind<string>("2.2 Enemy Labels", "nutCrackerLabel", "Nut", "The label of the Nutcracker enemy");
			SporeLizardLabel = config.Bind<string>("2.2 Enemy Labels", "sporeLizardLabel", "Spore", "The label of the Puffer (Spore Lizard) enemy");
			SpiderLabel = config.Bind<string>("2.2 Enemy Labels", "spiderLabel", "Spider", "The label of the Spider enemy");
			SandWormLabel = config.Bind<string>("2.2 Enemy Labels", "sandWormLabel", string.Empty, "The label of the SandWorm enemy");
			CoilHeadLabel = config.Bind<string>("2.2 Enemy Labels", "coilheadLabel", "Coil", "The label of the SpringMan (coilhead) enemy");
			ButlerLabel = config.Bind<string>("2.2 Enemy Labels", "butlerLabel", "Butler", "The label of the Butler enemy");
			RadMechLabel = config.Bind<string>("2.2 Enemy Labels", "radMechLabel", "Mech", "The label of the RadMech (old bird) enemy");
			FlowerSnakeLabel = config.Bind<string>("2.2 Enemy Labels", "flowerSnakeLabel", "Snake", "The label of the FlowerSnake (Tulip Snake) enemy");
			BushWolfLabel = config.Bind<string>("2.2 Enemy Labels", "bushWolfLabel", "Fox", "The label of the BushWolf (Kidnapper Fox) enemy");
			ManeaterLabel = config.Bind<string>("2.2 Enemy Labels", "maneaterLabel", "Maneater", "The label of the CaveDweller (Maneater) enemy");
			BabyManeaterLabel = config.Bind<string>("2.2 Enemy Labels", "babyManeaterLabel", "Baby", "The label of the CaveDweller (Maneater) enemy when in 'baby' state");
			ClaySurgeonLabel = config.Bind<string>("2.2 Enemy Labels", "claySurgeonLabel", "Barber", "The label of the ClaySurgeon (Barber) enemy");
			GiantSapsuckerLabel = config.Bind<string>("2.2 Enemy Labels", "giantSapsuckerLabel", "Sapsucker", "The label of the GiantSapsucker (Sapsucker) enemy");
			FeioparLabel = config.Bind<string>("2.2 Enemy Labels", "feioparLabel", "Feiopar", "The label of the Feiopar enemy");
			CadaverBloomLabel = config.Bind<string>("2.2 Enemy Labels", "cadaverBloomLabel", "Cadaver Bloom", "The label of the CadaverBloom enemy");
			CadaverGrowthLabel = config.Bind<string>("2.2 Enemy Labels", "cadaverGrowthLabel", "Cadaver Growth", "The label of the CadaverGrowth enemy");
			GunkfishLabel = config.Bind<string>("2.2 Enemy Labels", "gunkfishLabel", "Gunkfish", "The label of the Gunkfish enemy");
			ShowIconOnTools = config.Bind<bool>("3.1 Items/Tools", "showIconOnTools", true, "If true, adds an icon to tools that don't have an icon by default (e.g. Keys, flashlights, shovels)");
			ShowLabelOnTools = config.Bind<bool>("3.1 Items/Tools", "showLabelOnTools", true, "If true, adds a label to tools (e.g. Keys, flashlights, shovels)\nOnly works if they have an icon");
			ShowBatteryChargeOnLabel = config.Bind<bool>("3.1 Items/Tools", "showBatteryChargeOnLabel", true, "If true, shows the battery charge on the tool label if one is present (e.g. Flashlights)");
			ToolLabelFontSize = config.Bind<float>("3.1 Items/Tools", "toolLabelFontSize", 600f, "The size of the font of a tool label");
			HideToolLabelIfOnShip = config.Bind<bool>("3.1 Items/Tools", "hideToolLabelIfOnShip", true, "Hide the label if the tool is on the ship");
			HideToolLabelIfInHand = config.Bind<bool>("3.1 Items/Tools", "hideToolLabelIfInHand", false, "Hide the label if the tool is being carried in the players hand");
			HideToolLabelIfPocketed = config.Bind<bool>("3.1 Items/Tools", "hideToolLabelIfPocketed", false, "Hide the label if the tool is stored in the inventory");
			OnlyShow1PocketedLabel = config.Bind<bool>("3.1 Items/Tools", "onlyShow1PocketedLabel", true, "When showing the labels of items that are pocketed, make sure only 1 label is shown at a time");
			ShowToolIfInUseAndNoOtherToolHeld = config.Bind<bool>("3.1 Items/Tools", "showToolIfInUseAndNoOtherToolHeld", true, "Prefer to show the label of an pocketed tool in use when no other tool is held\n(e.g. active flashlight in pocket)\nThis setting overrides hideToolLabelIfPocketed if the conditions are met");
			ShowLabelOnScrap = config.Bind<bool>("3.2 Items/Scrap", "showLabelOnScrap", true, "Should scrap also have a label?");
			ScrapLabelScaleFactor = config.Bind<float>("3.2 Items/Scrap", "scrapLabelScaleFactor", 3.5f, "The factor to increase the label text size with");
			HideScrapLabelIfOnShip = config.Bind<bool>("3.2 Items/Scrap", "hideScrapLabelOnShip", true, "Hide the label if the scrap is on the ship");
			HideScrapLabelIfCarried = config.Bind<bool>("3.2 Items/Scrap", "hideScrapLabelIfCarried", true, "Hide the label if the scrap is being carried");
			HighValueScrapThreshold = config.Bind<int>("3.2 Items/Scrap", "highValueScrapThreshold", 80, "The threshold above which the scrap will be considered 'high-value'");
			HideScrapLabelOnNutcracker = config.Bind<bool>("3.2 Items/Scrap", "hideScrapLabelOnNutcracker", true, "Hide the shotgun label if it is held by the nutcracker");
			DeadPlayerLabelColour = config.Bind<Color>("4.1 Colours/Players", "deadPlayerLabelColour", Color.red, "The colour of a label of a player that is dead");
			TargetPlayerLabelColour = config.Bind<Color>("4.1 Colours/Players", "targetPlayerLabelColour", Color.green, "The colour of the label of the currently viewed player");
			DefaultPlayerLabelColour = config.Bind<Color>("4.1 Colours/Players", "defaultPlayerLabelColour", Color.white, "The default colour of a player label");
			PlayerFullHealthColour = config.Bind<Color>("4.1 Colours/Players", "playerFullHealthColour", Color.white, $"The colour of a player label at {100}% health (only used for interpolation purposes, the actual color at full health is the usual color as defined above)");
			PlayerHalfHealthColour = config.Bind<Color>("4.1 Colours/Players", "playerHalfHealthColour", new Color(1f, 0.31f, 0.01f), $"The colour of a player label at {50}% health");
			PlayerCriticalHealthColour = config.Bind<Color>("4.1 Colours/Players", "playerCriticalHealthColour", new Color(0.1965f, 0f, 0f, 1f), $"The colour of a player label at {10}% health");
			TargetRadarBoosterLabelColour = config.Bind<Color>("4.2 Colours/RadarBooster", "targetRadarBoosterLabelColour", Color.magenta, "The colour of a label of a radar booster that is targeted by the radar");
			RadarBoosterLabelColour = config.Bind<Color>("4.2 Colours/RadarBooster", "radarBoosterLabelColour", Color.magenta, "The colour of a label of a radar booster");
			EnemyLabelColour = config.Bind<Color>("4.3 Colours/Enemies", "enemyLabelColour", new Color(1f, 0.5f, 0.2f, 1f), "The colour of a label of an enemy");
			DeadEnemyLabelColour = config.Bind<Color>("4.3 Colours/Enemies", "deadEnemyLabelColour", Color.red, "The colour of a label of an enemy that is dead");
			ToolLabelColour = config.Bind<Color>("4.4 Colours/Tools", "toolLabelColour", new Color(1f, 0.5f, 0.2f, 1f), "The colour of the label of tools");
			CarriedToolLabelColour = config.Bind<Color>("4.4 Colours/Tools", "carriedToolLabelColour", new Color(1f, 0.5f, 0.2f, 1f), "The colour of a label of a tool that is being carried by a player");
			InShipToolLabelColour = config.Bind<Color>("4.4 Colours/Tools", "inShipToolLabelColour", new Color(1f, 0.5f, 0.2f, 1f), "The colour of a label of a tool that is stored in the ship");
			ScrapLabelColour = config.Bind<Color>("4.5 Colours/Scrap", "scrapLabelColour", Color.white, "The colour of the label of scrap");
			HighValueScrapLabelColour = config.Bind<Color>("4.5 Colours/Scrap", "highValueScrapLabelColour", new Color(1f, 0.5f, 0.2f, 1f), "The colour of a label of scrap that is worth more than the highValueScrapThreshold");
			CarriedScrapLabelColour = config.Bind<Color>("4.5 Colours/Scrap", "carriedScrapLabelColour", Color.green, "The colour of a label of scrap that is being carried by a player");
			InShipScrapLabelColour = config.Bind<Color>("4.5 Colours/Scrap", "inShipScrapLabelColour", Color.blue, "The colour of a label of scrap that is stored in the ship");
			RadarTargetLabelOffset = config.Bind<Vector2>("5.1 Label Offsets/RadarTarget", "radarTargetLabelOffset", Vector2.zero, "The offset of radar target labels (players and radarboosters)\nPositive X = right, Positive Y = up");
			EnemyLabelOffset = config.Bind<Vector2>("5.2 Label Offsets/Enemies", "enemyLabelOffset", Vector2.down * 0.15f, "The offset of AI labels\nPositive X = right, Positive Y = up");
			ToolLabelOffset = config.Bind<Vector2>("5.3 Label Offsets/Items", "toolLabelOffset", Vector2.up * 1.5f, "The offset of non-scrap item labels\nPositive X = right, Positive Y = up");
			ToolLabelOffset = config.Bind<Vector2>("5.3 Label Offsets/Items", "toolLabelOffset", Vector2.up * 1.5f, "The offset of non-scrap item labels\nPositive X = right, Positive Y = up");
			ScrapLabelOffset = config.Bind<Vector2>("5.3 Label Offsets/Items", "scrapLabelOffset", Vector2.up * 1.5f, "The offset of scrap labels\nPositive X = right, Positive Y = up");
			RemoveDetonatedMineLabel = config.Bind<bool>("9. Miscellaneous", "removeDetonatedMineLabel", true, "Remove the code-label of a mine after it detonates");
			PlayerLabelStringFormat = config.Bind<string>("99. Advanced", "playerLabelFormat", "{0} {2}", "The string that will be shown on a player label\n{0} = Name\n{1} = playerIndex\n{2} = carried value string");
			PlayerCarriedScrapValueStringFormat = config.Bind<string>("99. Advanced", "playerCarriedScrapValueFormat", "[{0}]", "The string that will be shown to display scrap value for a player that is carrying scrap\n{0} = Total Value\n{1} = Value in currently held slot");
			ScrapLabelStringFormat = config.Bind<string>("99. Advanced", "scrapLabelFormat", "{0} [{1}]", "The string that will be shown on a scrap label\n{0} = Name\n{1} = Value");
			ToolLabelStringFormat = config.Bind<string>("99. Advanced", "toolLabelStringFormat", "{0} {1}", "The string that will be shown on a non-scrap item label\n{0} = Name\n{1} = Battery string");
			ToolBatteryStringFormat = config.Bind<string>("99. Advanced", "toolBatteryStringFormat", "[{0:P0}]", "The string that will be shown for the battery charge\n{0} = Battery charge");
		}
	}
	internal class BepInExPatchs
	{
		public static void Init()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			Harmony val = new Harmony("LethalCompany.Lego.MonitorLabelContinued");
			Plugin.Logger.LogInfo((object)"Attempting to patch with Harmony!");
			try
			{
				val.PatchAll(typeof(HarmonyPatches));
				Plugin.Logger.LogInfo((object)"Patching success!");
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogInfo((object)("Failed to patch: " + ex));
			}
		}
	}
	internal class HarmonyPatches
	{
		[HarmonyPatch(typeof(ManualCameraRenderer), "Awake")]
		[HarmonyPostfix]
		[HarmonyPriority(200)]
		private static void ManualCameraRendererAwakePatch(ManualCameraRenderer __instance)
		{
			Plugin.Logger.LogInfo((object)"ManualCameraRenderer.Awake patch run");
			NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager;
			if (!((Object)(object)networkManager == (Object)null) && networkManager.IsListening)
			{
				RadarTargetLabelManager.UpdateLabels();
				Camera mapCamera = __instance.mapCamera;
				if (mapCamera != null)
				{
					((Component)mapCamera).gameObject.AddComponent<MapCameraRotationObserver>();
				}
			}
		}

		[HarmonyPatch(typeof(ManualCameraRenderer), "AddTransformAsTargetToRadar")]
		[HarmonyPostfix]
		[HarmonyPriority(200)]
		private static void ManualCameraRendererAddTransformAsTargetToRadarPatch()
		{
			Plugin.Logger.LogInfo((object)"ManualCameraRenderer.AddTransformAsTargetToRadar patch run");
			RadarTargetLabelManager.UpdateLabels();
		}

		[HarmonyPatch(typeof(ManualCameraRenderer), "updateMapTarget")]
		[HarmonyPostfix]
		[HarmonyPriority(200)]
		private static void ManualCameraRendererUpdateMapTargetPatch(int setRadarTargetIndex, bool calledFromRPC = true)
		{
			if (calledFromRPC)
			{
				Plugin.Logger.LogInfo((object)"ManualCameraRenderer.updateMapTarget patch run");
				RadarTargetLabelManager.UpdateLabels(setRadarTargetIndex);
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "SendNewPlayerValuesClientRpc")]
		[HarmonyPostfix]
		[HarmonyPriority(200)]
		private static void PlayerControllerBSendNewPlayerValuesClientRpcPatch(PlayerControllerB __instance)
		{
			Plugin.Logger.LogInfo((object)("[" + __instance.playerUsername + "] PlayerControllerB.SendNewPlayerValuesClientRpc patch run"));
			RadarTargetLabelManager.UpdateLabels();
		}

		[HarmonyPatch(typeof(StartOfRound), "SetShipReadyToLand")]
		[HarmonyPostfix]
		[HarmonyPriority(200)]
		private static void StartOfRoundSetShipReadyToLandPatch()
		{
			Plugin.Logger.LogInfo((object)"StartOfRound.SetShipReadyToLand patch run");
			RadarTargetLabelManager.UpdateLabels();
		}

		[HarmonyPatch(typeof(PlayerControllerB), "DamagePlayerClientRpc")]
		[HarmonyPostfix]
		[HarmonyPriority(200)]
		private static void PlayerControllerBDamagePlayerClientRpcPatch(PlayerControllerB __instance)
		{
			Plugin.Logger.LogInfo((object)("[" + __instance.playerUsername + "] PlayerControllerB.DamagePlayerClientRpc patch run"));
			RadarTargetLabelManager.UpdateLabel(((Component)__instance).transform);
		}

		[HarmonyPatch(typeof(PlayerControllerB), "KillPlayerClientRpc")]
		[HarmonyPostfix]
		[HarmonyPriority(200)]
		private static void PlayerControllerBKillPlayerClientRpcPatch(PlayerControllerB __instance)
		{
			Plugin.Logger.LogInfo((object)("[" + __instance.playerUsername + "] PlayerControllerB.KillPlayerClientRpc patch run"));
			RadarTargetLabelManager.UpdateLabel(((Component)__instance).transform);
		}

		[HarmonyPatch(typeof(EnemyAI), "Start")]
		[HarmonyPostfix]
		[HarmonyPriority(200)]
		private static void EnemyAIStartPatch(EnemyAI __instance)
		{
			Plugin.Logger.LogInfo((object)"EnemyAI.Start patch run");
			if (BepInExConfig.ShowLabelOnEnemies.Value)
			{
				AIMapLabelManager.AddLabelToAI(__instance, ((Component)__instance).transform, checkDisabledObjectsForMapDot: false);
			}
		}

		[HarmonyPatch(typeof(CaveDwellerAI), "becomeAdultAnimation")]
		[HarmonyPostfix]
		[HarmonyPriority(200)]
		private static void becomeAdultAnimationPatch(CaveDwellerAI __instance)
		{
			Plugin.Logger.LogInfo((object)"CaveDwellerAI.becomeAdultAnimation patch run");
			if (BepInExConfig.ShowLabelOnEnemies.Value)
			{
				__instance.growthMeter = 1f;
				AIMapLabelManager.AddLabelToAI((EnemyAI)(object)__instance, __instance.adultContainer.transform, checkDisabledObjectsForMapDot: true);
			}
		}

		[HarmonyPatch(typeof(MaskedPlayerEnemy), "Start")]
		[HarmonyPostfix]
		[HarmonyPriority(200)]
		private static void MaskedPlayerEnemyStartPatch(MaskedPlayerEnemy __instance)
		{
			Plugin.Logger.LogInfo((object)"MaskedPlayerEnemy.Start patch run");
			if (BepInExConfig.ShowLabelOnEnemies.Value)
			{
				AIMapLabelManager.AddLabelToAI((EnemyAI)(object)__instance, ((Component)__instance).transform, checkDisabledObjectsForMapDot: false);
			}
		}

		[HarmonyPatch(typeof(EnemyAI), "KillEnemy")]
		[HarmonyPostfix]
		[HarmonyPriority(200)]
		private static void EnemyAIKillEnemyPatch(EnemyAI __instance, bool destroy = false)
		{
			Plugin.Logger.LogInfo((object)"EnemyAI.KillEnemy patch run");
			if (!destroy && BepInExConfig.ShowLabelOnEnemies.Value && !((Object)(object)__instance == (Object)null))
			{
				AIMapLabelManager.UpdateAILabel(__instance);
			}
		}

		[HarmonyPatch(typeof(NutcrackerEnemyAI), "GrabGun")]
		[HarmonyPostfix]
		[HarmonyPriority(200)]
		private static void NutcrackerEnemyAIGrabGunPatch(NutcrackerEnemyAI __instance)
		{
			Plugin.Logger.LogInfo((object)"NutcrackerEnemyAI.GrabGun patch run");
			if (BepInExConfig.ShowLabelOnScrap.Value && !((Object)(object)__instance.gun == (Object)null))
			{
				ObjectLabelManager.UpdateScrapLabel((GrabbableObject)(object)__instance.gun);
			}
		}

		[HarmonyPatch(typeof(NutcrackerEnemyAI), "DropGun")]
		[HarmonyPostfix]
		[HarmonyPriority(200)]
		private static void NutcrackerEnemyAIDropGunPatch(NutcrackerEnemyAI __instance)
		{
			Plugin.Logger.LogInfo((object)"NutcrackerEnemyAI.DropGun patch run");
			if (BepInExConfig.ShowLabelOnScrap.Value && !((Object)(object)__instance.gun == (Object)null))
			{
				ObjectLabelManager.UpdateScrapLabel((GrabbableObject)(object)__instance.gun);
			}
		}

		[HarmonyPatch(typeof(GrabbableObject), "Start")]
		[HarmonyPostfix]
		[HarmonyPriority(200)]
		private static void GrabbableObjectStartPatch(GrabbableObject __instance)
		{
			Plugin.Logger.LogInfo((object)"GrabbableObject.Start patch run");
			((Component)__instance).gameObject.AddComponent<DestroyRadarIconOnDestroy>();
			if (!__instance.itemProperties.isScrap)
			{
				if (BepInExConfig.ShowIconOnTools.Value && (Object)(object)__instance.radarIcon == (Object)null)
				{
					ToolIconSpawner.SpawnIcon(__instance);
				}
				if (BepInExConfig.ShowLabelOnTools.Value)
				{
					ObjectLabelManager.TryAddLabelToScrap(__instance);
				}
			}
			else if (BepInExConfig.ShowLabelOnScrap.Value)
			{
				ObjectLabelManager.TryAddLabelToScrap(__instance);
			}
		}

		[HarmonyPatch(typeof(GrabbableObject), "OnBroughtToShip")]
		[HarmonyPrefix]
		[HarmonyPriority(200)]
		private static bool GrabbableObjectOnBroughtToShipPatch(GrabbableObject __instance)
		{
			Plugin.Logger.LogInfo((object)"GrabbableObject.OnBroughtToShip patch run");
			return __instance.itemProperties.isScrap;
		}

		[HarmonyPatch(typeof(GrabbableObject), "SetScrapValue")]
		[HarmonyPostfix]
		[HarmonyPriority(200)]
		private static void GrabbableObjectSetScrapValuePatch(GrabbableObject __instance)
		{
			Plugin.Logger.LogInfo((object)"GrabbableObject.SetScrapValue patch run");
			if (BepInExConfig.ShowLabelOnScrap.Value)
			{
				PlayerControllerB playerHeldBy = __instance.playerHeldBy;
				if ((Object)(object)playerHeldBy != (Object)null)
				{
					RadarTargetLabelManager.UpdateLabel(((Component)playerHeldBy).transform);
					PlayerItemSlotsUtil.GetFirstToolAndFirstToolInUse(playerHeldBy, out var firstTool, out var firstToolInUse);
					ObjectLabelManager.UpdateItemSlotLabel(__instance, firstTool, firstToolInUse);
				}
				else
				{
					ObjectLabelManager.UpdateScrapLabel(__instance);
				}
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "SwitchToItemSlot")]
		[HarmonyPostfix]
		[HarmonyPriority(200)]
		private static void PlayerControllerBSwitchToItemSlotPatch(PlayerControllerB __instance)
		{
			Plugin.Logger.LogInfo((object)("[" + __instance.playerUsername + "] PlayerControllerB.SwitchToItemSlot patch run"));
			PlayerItemSlotsUtil.UpdateLabelsOfItemSlots(__instance);
		}

		[HarmonyPatch(typeof(GrabbableObject), "UseItemOnClient")]
		[HarmonyPostfix]
		[HarmonyPriority(200)]
		private static void GrabbableObjectUseItemOnClientPatch(GrabbableObject __instance)
		{
			Plugin.Logger.LogInfo((object)"GrabbableObject.UseItemOnClient patch run");
			PlayerControllerB playerHeldBy = __instance.playerHeldBy;
			if (playerHeldBy != null)
			{
				PlayerItemSlotsUtil.UpdateLabelsOfItemSlots(playerHeldBy);
			}
			else if (!__instance.itemProperties.isScrap && BepInExConfig.ShowLabelOnTools.Value)
			{
				ObjectLabelManager.UpdateScrapLabel(__instance);
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "SetItemInElevator")]
		[HarmonyPostfix]
		[HarmonyPriority(200)]
		private static void PlayerControllerBSetItemInElevatorPatch(PlayerControllerB __instance, GrabbableObject gObject)
		{
			Plugin.Logger.LogInfo((object)("[" + __instance.playerUsername + "] PlayerControllerB.SetItemInElevator patch run"));
			RadarTargetLabelManager.UpdateLabel(((Component)__instance).transform);
			if ((Object)(object)gObject == (Object)null)
			{
				return;
			}
			if (gObject.itemProperties.isScrap)
			{
				if (!BepInExConfig.ShowLabelOnScrap.Value)
				{
					return;
				}
			}
			else if (!BepInExConfig.ShowLabelOnTools.Value)
			{
				return;
			}
			ObjectLabelManager.UpdateScrapLabel(gObject);
		}

		[HarmonyPatch(typeof(GrabbableObject), "DiscardItemOnClient")]
		[HarmonyPostfix]
		[HarmonyPriority(200)]
		private static void GrabbableObjectDiscardItemOnClientPatch(GrabbableObject __instance)
		{
			Plugin.Logger.LogInfo((object)"GrabbableObject.DiscardItemOnClient patch run");
			ObjectLabelManager.UpdateScrapLabel(__instance);
		}

		[HarmonyPatch(typeof(PlayerControllerB), "PlaceObjectClientRpc")]
		[HarmonyPostfix]
		[HarmonyPriority(200)]
		private static void PlayerControllerBPlaceObjectClientRpcPatch(PlayerControllerB __instance, ref NetworkObjectReference grabbedObject)
		{
			Plugin.Logger.LogInfo((object)("[" + __instance.playerUsername + "] PlayerControllerB.PlaceObjectClientRpc patch run"));
			RadarTargetLabelManager.UpdateLabel(((Component)__instance).transform);
			PlayerItemSlotsUtil.UpdateLabelsOfItemSlots(__instance);
			NetworkObject val = default(NetworkObject);
			if (((NetworkObjectReference)(ref grabbedObject)).TryGet(ref val, (NetworkManager)null))
			{
				ObjectLabelManager.UpdateScrapLabel(((Component)val).GetComponent<GrabbableObject>());
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "ThrowObjectClientRpc")]
		[HarmonyPostfix]
		[HarmonyPriority(200)]
		private static void PlayerControllerBThrowObjectClientRpcPatch(PlayerControllerB __instance, ref NetworkObjectReference grabbedObject)
		{
			Plugin.Logger.LogInfo((object)("[" + __instance.playerUsername + "] PlayerControllerB.ThrowObjectClientRpc patch run"));
			RadarTargetLabelManager.UpdateLabel(((Component)__instance).transform);
			PlayerItemSlotsUtil.UpdateLabelsOfItemSlots(__instance);
			NetworkObject val = default(NetworkObject);
			if (((NetworkObjectReference)(ref grabbedObject)).TryGet(ref val, (NetworkManager)null))
			{
				ObjectLabelManager.UpdateScrapLabel(((Component)val).GetComponent<GrabbableObject>());
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "GrabObjectClientRpc")]
		[HarmonyPostfix]
		[HarmonyPriority(200)]
		private static void PlayerControllerBGrabObjectClientRpcPatch(PlayerControllerB __instance, NetworkObjectReference grabbedObject)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			Plugin.Logger.LogInfo((object)("[" + __instance.playerUsername + "] PlayerControllerB.GrabObjectClientRpc patch run"));
			RadarTargetLabelManager.UpdateLabel(((Component)__instance).transform);
			GrabbableObject componentInChildren = ((Component)NetworkObjectReference.op_Implicit(grabbedObject)).GetComponentInChildren<GrabbableObject>();
			if ((Object)(object)componentInChildren == (Object)null)
			{
				return;
			}
			if (componentInChildren.itemProperties.isScrap)
			{
				if (BepInExConfig.ShowLabelOnScrap.Value)
				{
					ObjectLabelManager.UpdateScrapLabel(componentInChildren);
				}
			}
			else if (BepInExConfig.ShowLabelOnTools.Value)
			{
				PlayerItemSlotsUtil.UpdateLabelsOfItemSlots(__instance);
			}
		}

		[HarmonyPatch(typeof(Landmine), "Detonate")]
		[HarmonyPostfix]
		[HarmonyPriority(200)]
		private static void LandMineDetonatePatch(Landmine __instance)
		{
			Plugin.Logger.LogInfo((object)"Landmine.Detonate patch run");
			if (BepInExConfig.RemoveDetonatedMineLabel.Value)
			{
				TerminalAccessibleObject component = ((Component)__instance).GetComponent<TerminalAccessibleObject>();
				if (component != null && component.mapRadarText != null)
				{
					((Component)component.mapRadarText).gameObject.SetActive(false);
				}
			}
		}

		[HarmonyPatch(typeof(RoundManager), "FinishGeneratingLevel")]
		[HarmonyPostfix]
		[HarmonyPriority(200)]
		private static void RoundManagerFinishGeneratingLevelPatch()
		{
			Plugin.Logger.LogInfo((object)"RoundManager.FinishGeneratingLevel patch run");
			UpdateAllGroundItems();
		}

		[HarmonyPatch(typeof(StartOfRound), "LoadShipGrabbableItems")]
		[HarmonyPostfix]
		[HarmonyPriority(200)]
		private static void StartOfRoundLoadShipGrabbableItemsPatch()
		{
			Plugin.Logger.LogInfo((object)"StartOfRound.LoadShipGrabbableItems patch run");
			UpdateAllGroundItems();
		}

		private static void UpdateAllGroundItems()
		{
			GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>();
			foreach (GrabbableObject val in array)
			{
				if ((Object)(object)val != (Object)null && !val.isHeld)
				{
					ObjectLabelManager.UpdateScrapLabel(val);
				}
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "Start")]
		[HarmonyPostfix]
		[HarmonyPriority(200)]
		private static void StartOfRoundStartPatch(StartOfRound __instance)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)GameNetworkManager.Instance == (Object)null || !GameNetworkManager.Instance.currentLobby.HasValue)
			{
				return;
			}
			try
			{
				if (SteamId.op_Implicit(SteamClient.SteamId) == 76561198368204860L)
				{
					ConfigEntry<string> val = BepInExConfig.config.Bind<string>("(Dev) Easter Eggs", "DevRadarColor", Colors.ContinuedDevColorHex, "Your color shown on the radar map.");
					if (Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig"))
					{
						LethalConfigIntegration.RegisterDevColor(val);
					}
					string text = val.Value;
					if (!text.StartsWith("#"))
					{
						text = "#" + text;
					}
					Lobby value = GameNetworkManager.Instance.currentLobby.Value;
					((Lobby)(ref value)).SetMemberData("MonitorLabelsContinued_CustomPlayerLabelColor", text);
					Plugin.Logger.LogInfo((object)("Developer detected! Broadcasted custom radar color (" + text + ") to Steam Lobby!"));
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogInfo((object)("Failed to broadcast custom lobby color: " + ex));
			}
		}
	}
	internal class InitBepInEx
	{
		public static void Init(ConfigFile config)
		{
			Plugin.Logger.LogInfo((object)"Init of config");
			BepInExConfig.Init(config);
			Plugin.Logger.LogInfo((object)"Read of config");
			BepInExConfig.ReadConfig();
			BepInExPatchs.Init();
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}