Decompiled source of LethalHUD v1.4.1

plugins/LethalHUD/LethalHUD.dll

Decompiled 4 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
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 System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using BetterScanVision;
using GameNetcodeStuff;
using GoodItemScan;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using LethalHUD.Compats;
using LethalHUD.Configs;
using LethalHUD.HUD;
using LethalHUD.Misc;
using LethalHUD.NetcodePatcher;
using LethalHUD.Networking;
using LethalHUD.Scan;
using Microsoft.CodeAnalysis;
using SoftMasking;
using TMPro;
using Unity.Netcode;
using Unity.Netcode.Transports.UTP;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("BepInEx")]
[assembly: IgnoresAccessChecksTo("BetterScanVision")]
[assembly: IgnoresAccessChecksTo("EladsHUD")]
[assembly: IgnoresAccessChecksTo("GoodItemScan")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("s1ckboy")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright © 2025 s1ckboy")]
[assembly: AssemblyFileVersion("1.4.1.0")]
[assembly: AssemblyInformationalVersion("1.4.1+88d86fe91912ea959402d3b4ffb077327eb608c1")]
[assembly: AssemblyProduct("LethalHUD")]
[assembly: AssemblyTitle("LethalHUD")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.4.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LethalHUD
{
	public static class Enums
	{
		public enum SelfRedMode
		{
			Vanilla,
			ColoredFilled,
			RedFillUp
		}

		public enum BillboardGradientMode
		{
			Static,
			Wave,
			Pulse
		}

		public enum VertexGradientLayout
		{
			Horizontal,
			Vertical,
			Diagonal
		}

		public enum SlotEnums
		{
			None,
			Rainbow,
			Summer,
			Winter,
			Vaporwave,
			Deepmint,
			Radioactive,
			TideEmber
		}

		public enum ItemValue
		{
			Default,
			Dollar
		}

		public enum ScanMode
		{
			Default,
			Hold,
			Toggle
		}

		public enum ScanLines
		{
			Default,
			Circles,
			Hexagons,
			Circuit,
			Noisy,
			Scifi,
			Bol,
			Chu
		}

		public enum ScanNodeShape
		{
			Default,
			Triangle,
			Target,
			Web,
			Idk
		}

		public enum WeightUnit
		{
			Pounds,
			Kilograms,
			Manuls
		}

		public enum WeightUnitDisplay
		{
			OnlyOne,
			KgAndPounds,
			PoundsAndManuls,
			KgAndManuls,
			KgPoundsAndManuls
		}

		public enum WeightDecimalFormat
		{
			Rounded,
			TwoDecimalsDot,
			TwoDecimalsComma
		}

		public enum MTColorMode
		{
			Solid,
			Gradient
		}

		public enum SprintStyle
		{
			Solid,
			Shades,
			Gradient
		}

		public enum ClockStyle
		{
			Regular,
			Compact
		}

		public enum HPDisplayMode
		{
			Plain,
			Percent,
			Label
		}

		public enum FPSPingLayout
		{
			Vertical,
			Horizontal
		}

		public enum TotalValuePrefix
		{
			Full,
			Short,
			None
		}

		internal static Color solarFlare = new Color(1f, 0.8f, 0.3f);

		internal static Color moltenCore = new Color(1f, 0.2f, 0f);

		internal static Color skyWave = new Color(0.4f, 0.65f, 1f);

		internal static Color moonlitMist = new Color(0.8f, 0.8f, 1f);

		internal static Color pinkPrism = new Color(1f, 0.4f, 1f);

		internal static Color aquaPulse = new Color(0.4f, 1f, 1f);

		internal static Color mintWave = new Color(0.5647f, 0.8706f, 0.7843f);

		internal static Color deepTeal = new Color(0.1608f, 0.2863f, 0.2549f);

		internal static Color neonLime = new Color(0.443f, 0.78f, 0f);

		internal static Color lemonGlow = new Color(0.941f, 1f, 0.471f);

		internal static Color crimsonSpark = new Color(1f, 0.27f, 0f);

		internal static Color deepOcean = new Color(0f, 0.48f, 0.54f);

		private static readonly float _baseIntensity = 352.08f;

		private static readonly float _customBaseIntensity = 100f;

		internal static void DirtIntensityHandlerByScanLine()
		{
			Bloom scanBloom = ScanController.ScanBloom;
			if (!((Object)(object)scanBloom == (Object)null))
			{
				if (Plugins.ConfigEntries.SelectedScanlineMode.Value == ScanLines.Default)
				{
					((VolumeParameter<float>)(object)scanBloom.dirtIntensity).Override(Mathf.Max(0f, _baseIntensity + Plugins.ConfigEntries.DirtIntensity.Value));
				}
				else
				{
					((VolumeParameter<float>)(object)scanBloom.dirtIntensity).Override(Mathf.Max(0f, _customBaseIntensity + Plugins.ConfigEntries.DirtIntensity.Value));
				}
			}
		}
	}
	internal class Loggers
	{
		private static void Log(LogLevel logLevel, object data)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			Plugins.Logger.Log(logLevel, data);
		}

		internal static void Info(object data)
		{
			Log((LogLevel)16, data);
		}

		internal static void Debug(object data)
		{
			Log((LogLevel)32, data);
		}

		internal static void Message(object data)
		{
			Log((LogLevel)8, data);
		}

		internal static void Warning(object data)
		{
			Log((LogLevel)4, data);
		}

		internal static void Error(object data)
		{
			Log((LogLevel)2, data);
		}

		internal static void Fatal(object data)
		{
			Log((LogLevel)1, data);
		}
	}
	[BepInPlugin("LethalHUD", "LethalHUD", "1.4.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugins : BaseUnityPlugin
	{
		internal struct ScanNodeTextures
		{
			public Sprite Outer;

			public Sprite Inner;
		}

		internal static Dictionary<Enums.ScanLines, Texture2D> ScanlineTextures = new Dictionary<Enums.ScanLines, Texture2D>();

		internal static Dictionary<Enums.ScanNodeShape, ScanNodeTextures> ScanNodeSprites = new Dictionary<Enums.ScanNodeShape, ScanNodeTextures>();

		internal static Plugins Instance { get; private set; }

		internal static Harmony Harmony { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static ConfigFile Config { get; private set; }

		internal static ConfigEntries ConfigEntries { get; private set; }

		public void Awake()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			Harmony = new Harmony("LethalHUD");
			Logger = Logger.CreateLogSource("LethalHUD");
			SerializeNetworkVariables();
			ConfigFile val = ConfigUtils.CreateLocalConfigFile((BaseUnityPlugin)(object)this, "bootstrap", saveOnInit: true);
			ConfigEntry<bool> val2 = val.Bind<bool>("Main", "Use Local Config", false, "If enabled, uses a local config file instead of the global config. Requires restart.");
			Config = (val2.Value ? ConfigUtils.CreateLocalConfigFile((BaseUnityPlugin)(object)this) : ConfigUtils.CreateGlobalConfigFile((BaseUnityPlugin)(object)this));
			ConfigEntries = new ConfigEntries();
			string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			string text = Path.Combine(directoryName, "incomprehensibleandalsoridiculousoriginalassetbundlenameforlethalhud");
			AssetBundle val3 = AssetBundle.LoadFromFile(text);
			if ((Object)(object)val3 == (Object)null)
			{
				Loggers.Error("Failed to load unfathomablyridiculousoriginalassetbundlenameforlethalhud assetbundle.");
				return;
			}
			foreach (Enums.ScanLines value in Enum.GetValues(typeof(Enums.ScanLines)))
			{
				string text2 = value.ToString();
				Texture2D val4 = val3.LoadAsset<Texture2D>(text2);
				if ((Object)(object)val4 != (Object)null)
				{
					ScanlineTextures[value] = val4;
				}
				else
				{
					Loggers.Warning("Texture '" + text2 + "' not found in asset bundle.");
				}
			}
			foreach (Enums.ScanNodeShape value2 in Enum.GetValues(typeof(Enums.ScanNodeShape)))
			{
				string text3 = $"{value2}_Outer";
				string text4 = $"{value2}_Inner";
				Sprite val5 = val3.LoadAsset<Sprite>(text3);
				Sprite val6 = val3.LoadAsset<Sprite>(text4);
				if ((Object)(object)val5 == (Object)null)
				{
					Logger.LogWarning((object)("ScanNode texture '" + text3 + "' not found."));
				}
				if ((Object)(object)val6 == (Object)null)
				{
					Logger.LogWarning((object)("ScanNode texture '" + text4 + "' not found."));
				}
				ScanNodeSprites[value2] = new ScanNodeTextures
				{
					Outer = val5,
					Inner = val6
				};
			}
			Harmony.PatchAll();
			val.Save();
			Loggers.Info("Plugin LethalHUD loaded!");
		}

		private static void SerializeNetworkVariables()
		{
			NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<PlayerColorInfo>();
			NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<PlayerColorInfo>();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "LethalHUD";

		public const string PLUGIN_NAME = "LethalHUD";

		public const string PLUGIN_VERSION = "1.4.1";
	}
}
namespace LethalHUD.Scan
{
	internal static class ScanController
	{
		private const float ScanDuration = 1.3f;

		private static Texture2D _lastRecoloredTexture;

		private static MeshRenderer _scanRenderer;

		private static Volume _cachedScanVolume;

		private static Material _scanMat;

		private static MeshRenderer ScanRenderer
		{
			get
			{
				if ((Object)(object)_scanRenderer == (Object)null && (Object)(object)HUDManager.Instance != (Object)null)
				{
					Animator scanEffectAnimator = HUDManager.Instance.scanEffectAnimator;
					if ((Object)(object)scanEffectAnimator != (Object)null)
					{
						_scanRenderer = ((Component)scanEffectAnimator).GetComponent<MeshRenderer>();
					}
				}
				return _scanRenderer;
			}
		}

		private static Volume ScanVolume
		{
			get
			{
				if ((Object)(object)_cachedScanVolume == (Object)null)
				{
					GameObject val = GameObject.Find("Systems/Rendering/ScanSphere/ScanVolume");
					if ((Object)(object)val != (Object)null)
					{
						_cachedScanVolume = val.GetComponent<Volume>();
					}
				}
				return _cachedScanVolume;
			}
		}

		private static Vignette ScanVignette
		{
			get
			{
				if ((Object)(object)ScanVolume == (Object)null)
				{
					return null;
				}
				if ((Object)(object)ScanVolume.profile == (Object)null)
				{
					return null;
				}
				return ScanVolume.profile.components?.OfType<Vignette>().FirstOrDefault();
			}
		}

		internal static Bloom ScanBloom
		{
			get
			{
				if ((Object)(object)ScanVolume == (Object)null)
				{
					return null;
				}
				if ((Object)(object)ScanVolume.profile == (Object)null)
				{
					return null;
				}
				return ScanVolume.profile.components?.OfType<Bloom>().FirstOrDefault();
			}
		}

		private static float ScanProgress
		{
			get
			{
				if ((Object)(object)HUDManager.Instance == (Object)null)
				{
					return 0f;
				}
				return (HUDManager.Instance.playerPingingScan + 1f) / 1.3f;
			}
		}

		private static bool IsInspecting
		{
			get
			{
				if ((Object)(object)StartOfRound.Instance == (Object)null)
				{
					return false;
				}
				if ((Object)(object)StartOfRound.Instance.localPlayerController == (Object)null)
				{
					return false;
				}
				return StartOfRound.Instance.localPlayerController.IsInspectingItem;
			}
		}

		private static Material ScanMaterial
		{
			get
			{
				if ((Object)(object)_scanMat == (Object)null && (Object)(object)ScanRenderer != (Object)null)
				{
					_scanMat = ((Renderer)ScanRenderer).sharedMaterial;
				}
				return _scanMat;
			}
		}

		private static void SetScanColorAlpha(float alpha)
		{
			//IL_0013: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)ScanMaterial == (Object)null))
			{
				Color color = ScanMaterial.color;
				color.a = alpha;
				ScanMaterial.color = color;
			}
		}

		internal static void SetScanColor(Color? overrideColor = null)
		{
			//IL_001a: 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_001f: 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_0059: 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)
			if (!IsInspecting)
			{
				Color val = (overrideColor.HasValue ? overrideColor.Value : ConfigHelper.GetScanColor());
				if (ModCompats.IsBetterScanVisionPresent)
				{
					BetterScanVisionProxy.OverrideNightVisionColor();
				}
				if ((Object)(object)ScanMaterial != (Object)null)
				{
					ScanMaterial.color = val;
				}
				Vignette scanVignette = ScanVignette;
				if ((Object)(object)scanVignette != (Object)null)
				{
					((VolumeParameter<Color>)(object)scanVignette.color).Override(val);
					UpdateVignetteIntensity();
				}
				Bloom scanBloom = ScanBloom;
				if ((Object)(object)scanBloom != (Object)null)
				{
					((VolumeParameter<Color>)(object)scanBloom.tint).Override(val);
					UpdateScanTexture();
				}
			}
		}

		internal static void UpdateScanAlpha()
		{
			if (!((Object)(object)HUDManager.Instance == (Object)null) && !((Object)(object)ScanRenderer == (Object)null) && !IsInspecting)
			{
				float value = Plugins.ConfigEntries.Alpha.Value;
				float num = value;
				if (Plugins.ConfigEntries.FadeOut.Value && HUDManager.Instance.playerPingingScan > -1f)
				{
					num *= ScanProgress;
				}
				SetScanColorAlpha(num);
			}
		}

		internal static void UpdateVignetteIntensity()
		{
			if (!IsInspecting)
			{
				Vignette scanVignette = ScanVignette;
				if ((Object)(object)scanVignette != (Object)null)
				{
					((VolumeParameter<float>)(object)scanVignette.intensity).Override(Plugins.ConfigEntries.VignetteIntensity.Value);
				}
			}
		}

		internal static void UpdateScanTexture()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			Bloom scanBloom = ScanBloom;
			if ((Object)(object)scanBloom == (Object)null || IsInspecting)
			{
				return;
			}
			Enums.DirtIntensityHandlerByScanLine();
			Texture2D selectedTexture = GetSelectedTexture();
			if (!((Object)(object)selectedTexture == (Object)null))
			{
				if (Plugins.ConfigEntries.RecolorScanLines.Value)
				{
					RecolorAndApplyTexture(ConfigHelper.GetScanColor(), selectedTexture);
				}
				else
				{
					((VolumeParameter<Texture>)(object)scanBloom.dirtTexture).Override((Texture)(object)selectedTexture);
				}
			}
		}

		private static void RecolorAndApplyTexture(Color color, Texture2D baseTex)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			Texture2D texture = new Texture2D(((Texture)baseTex).width, ((Texture)baseTex).height, (TextureFormat)4, true);
			texture.SetPixels(baseTex.GetPixels());
			HUDUtils.RecolorTexture(ref texture, color);
			texture.Apply(true, false);
			if ((Object)(object)_lastRecoloredTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_lastRecoloredTexture);
			}
			_lastRecoloredTexture = texture;
			Bloom scanBloom = ScanBloom;
			if ((Object)(object)scanBloom != (Object)null)
			{
				((VolumeParameter<Texture>)(object)scanBloom.dirtTexture).Override((Texture)(object)_lastRecoloredTexture);
			}
		}

		private static Texture2D GetSelectedTexture()
		{
			Enums.ScanLines value = Plugins.ConfigEntries.SelectedScanlineMode.Value;
			if (Plugins.ScanlineTextures.TryGetValue(value, out var value2) && (Object)(object)value2 != (Object)null)
			{
				return value2;
			}
			Loggers.Warning($"Scanline texture '{value}' missing. Falling back to Default.");
			if (value != 0 && Plugins.ScanlineTextures.TryGetValue(Enums.ScanLines.Default, out var value3) && (Object)(object)value3 != (Object)null)
			{
				return value3;
			}
			Loggers.Error("No scanline textures could be applied.");
			return null;
		}
	}
	internal static class ScanNodeController
	{
		internal static float lifetime = Plugins.ConfigEntries.ScanNodeLifetime.Value;

		internal static float fadeDuration = Plugins.ConfigEntries.ScanNodeFadeDuration.Value;

		private static readonly Dictionary<ScanNodeProperties, float> _nodeAppearTimes = new Dictionary<ScanNodeProperties, float>();

		private static readonly AnimationCurve _fadeCurve = AnimationCurve.EaseInOut(0f, 1f, 1f, 0f);

		internal static void UpdateTimers(RectTransform[] scanElements, Dictionary<RectTransform, ScanNodeProperties> scanNodes)
		{
			foreach (RectTransform val in scanElements)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				if (!scanNodes.TryGetValue(val, out var value) || (Object)(object)value == (Object)null)
				{
					CleanInvalidNodes();
					continue;
				}
				if (!_nodeAppearTimes.ContainsKey(value))
				{
					_nodeAppearTimes[value] = Time.time;
				}
				float num = Time.time - _nodeAppearTimes[value];
				if (num >= lifetime + fadeDuration)
				{
					RemoveNode(val, value, scanNodes);
					continue;
				}
				float alpha = ((num > lifetime) ? _fadeCurve.Evaluate((num - lifetime) / fadeDuration) : 1f);
				CanvasGroup component = ((Component)val).GetComponent<CanvasGroup>();
				component.alpha = alpha;
			}
		}

		internal static void UpdateGoodItemScanNodes()
		{
			if (!ModCompats.IsGoodItemScanPresent || GoodItemScan.scanner == null)
			{
				return;
			}
			Scanner scanner = GoodItemScan.scanner;
			List<ScanNodeProperties> list = scanner._scanNodes.Keys.ToList();
			foreach (ScanNodeProperties item in list)
			{
				if (!GoodItemScanProxy.TryGetRectTransform(item, out var rectTransform) || (Object)(object)rectTransform == (Object)null)
				{
					_nodeAppearTimes.Remove(item);
					continue;
				}
				if (!((Component)rectTransform).gameObject.activeInHierarchy)
				{
					_nodeAppearTimes.Remove(item);
					continue;
				}
				if (!_nodeAppearTimes.ContainsKey(item))
				{
					_nodeAppearTimes[item] = Time.time;
				}
				float num = Time.time - _nodeAppearTimes[item];
				float num2 = ((num > lifetime) ? _fadeCurve.Evaluate((num - lifetime) / fadeDuration) : 1f);
				CanvasGroup component = ((Component)rectTransform).GetComponent<CanvasGroup>();
				if ((Object)(object)component != (Object)null)
				{
					component.alpha = num2;
				}
				((Component)rectTransform).gameObject.SetActive(num2 > 0f);
			}
		}

		internal static void ResetGoodItemScanNodes()
		{
			if (!ModCompats.IsGoodItemScanPresent || GoodItemScan.scanner == null)
			{
				return;
			}
			Scanner scanner = GoodItemScan.scanner;
			if (scanner == null || scanner._scannedNodes == null)
			{
				return;
			}
			foreach (KeyValuePair<ScanNodeProperties, int> scanNode in scanner._scanNodes)
			{
				if (GoodItemScanProxy.TryGetRectTransform(scanNode.Key, out var rectTransform) && !((Object)(object)rectTransform == (Object)null))
				{
					_nodeAppearTimes[scanNode.Key] = Time.time;
					((Component)rectTransform).gameObject.SetActive(true);
					CanvasGroup component = ((Component)rectTransform).GetComponent<CanvasGroup>();
					if ((Object)(object)component != (Object)null)
					{
						component.alpha = 1f;
					}
				}
			}
		}

		private static void RemoveNode(RectTransform element, ScanNodeProperties node, Dictionary<RectTransform, ScanNodeProperties> scanNodes)
		{
			((Component)element).gameObject.SetActive(false);
			scanNodes.Remove(element);
			_nodeAppearTimes.Remove(node);
		}

		private static void CleanInvalidNodes()
		{
			List<ScanNodeProperties> list = new List<ScanNodeProperties>();
			foreach (KeyValuePair<ScanNodeProperties, float> nodeAppearTime in _nodeAppearTimes)
			{
				if ((Object)(object)nodeAppearTime.Key == (Object)null)
				{
					list.Add(nodeAppearTime.Key);
				}
			}
			foreach (ScanNodeProperties item in list)
			{
				_nodeAppearTimes.Remove(item);
			}
		}
	}
	internal static class ScanNodeTextureManager
	{
		private static readonly Dictionary<GameObject, Color> _nodeColors = new Dictionary<GameObject, Color>();

		internal static void Tick()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			GameObject val = GameObject.Find("UI/Canvas/ObjectScanner");
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Enums.ScanNodeShape value = Plugins.ConfigEntries.ScanNodeShapeChoice.Value;
			if (!Plugins.ScanNodeSprites.TryGetValue(value, out var value2))
			{
				return;
			}
			Sprite inner = value2.Inner;
			Sprite outer = value2.Outer;
			foreach (Transform item in val.transform)
			{
				Transform val2 = item;
				if (((Object)val2).name.StartsWith("ScanObject"))
				{
					ApplySpritesToScanObject(((Component)val2).gameObject, inner, outer);
				}
			}
		}

		private static void ApplySpritesToScanObject(GameObject scanObject, Sprite innerSprite, Sprite outerSprite)
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)scanObject == (Object)null || !scanObject.activeInHierarchy)
			{
				return;
			}
			Transform obj = scanObject.transform.Find("Circle/Inner");
			Image val = ((obj != null) ? ((Component)obj).GetComponent<Image>() : null);
			Transform obj2 = scanObject.transform.Find("Circle/Outer");
			Image val2 = ((obj2 != null) ? ((Component)obj2).GetComponent<Image>() : null);
			if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null))
			{
				if (!_nodeColors.ContainsKey(((Component)val).gameObject))
				{
					_nodeColors[((Component)val).gameObject] = ((Graphic)val).color;
				}
				if (!_nodeColors.ContainsKey(((Component)val2).gameObject))
				{
					_nodeColors[((Component)val2).gameObject] = ((Graphic)val2).color;
				}
				val.sprite = innerSprite;
				val2.sprite = outerSprite;
				((Graphic)val).color = _nodeColors[((Component)val).gameObject];
				((Graphic)val2).color = _nodeColors[((Component)val2).gameObject];
			}
		}

		internal static void ForceRefresh()
		{
			Tick();
		}

		internal static void ClearDestroyedObjects()
		{
			List<GameObject> list = new List<GameObject>();
			foreach (KeyValuePair<GameObject, Color> nodeColor in _nodeColors)
			{
				if ((Object)(object)nodeColor.Key == (Object)null)
				{
					list.Add(nodeColor.Key);
				}
			}
			foreach (GameObject item in list)
			{
				_nodeColors.Remove(item);
			}
		}
	}
}
namespace LethalHUD.Patches
{
	[HarmonyPatch(typeof(GameNetworkManager))]
	internal static class GameNetworkManagerPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("NoPunctuation")]
		private static bool NoPunctuation_Prefix(string input, ref string __result)
		{
			if (string.IsNullOrEmpty(input))
			{
				__result = "Nameless";
			}
			else
			{
				__result = ChatController.NoPunctuation(input);
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	internal static class HUDManagerPatch
	{
		[CompilerGenerated]
		private sealed class <ApplySelfRedAfterTick>d__26 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public HUDManager hud;

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

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

			[DebuggerHidden]
			public <ApplySelfRedAfterTick>d__26(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
				{
					<>1__state = -1;
					if ((Object)(object)hud == (Object)null || (Object)(object)hud.selfRedCanvasGroup == (Object)null)
					{
						return false;
					}
					PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
					if ((Object)(object)localPlayerController == (Object)null)
					{
						return false;
					}
					int health = localPlayerController.health;
					switch (Plugins.ConfigEntries.SelfRedCanvasMode.Value)
					{
					case Enums.SelfRedMode.Vanilla:
						return false;
					case Enums.SelfRedMode.ColoredFilled:
						PlayerRedCanvasController.ApplyFillAndColor(health);
						break;
					case Enums.SelfRedMode.RedFillUp:
						PlayerRedCanvasController.ApplyFillWithRedFade(health);
						break;
					}
					return false;
				}
				}
			}

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

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

		[CompilerGenerated]
		private sealed class <ScanTextureRoutine>d__21 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

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

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

			[DebuggerHidden]
			public <ScanTextureRoutine>d__21(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Expected O, but got Unknown
				int num = <>1__state;
				if (num != 0)
				{
					if (num != 1)
					{
						return false;
					}
					<>1__state = -1;
				}
				else
				{
					<>1__state = -1;
				}
				ScanNodeTextureManager.Tick();
				ScanNodeTextureManager.ClearDestroyedObjects();
				<>2__current = (object)new WaitForSeconds(1f);
				<>1__state = 1;
				return true;
			}

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

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

		[CompilerGenerated]
		private sealed class <ToggleScanRoutine>d__24 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public HUDManager __instance;

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

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

			[DebuggerHidden]
			public <ToggleScanRoutine>d__24(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				int num = <>1__state;
				if (num != 0)
				{
					if (num != 1)
					{
						return false;
					}
					<>1__state = -1;
				}
				else
				{
					<>1__state = -1;
				}
				TryPerformScan(__instance);
				<>2__current = null;
				<>1__state = 1;
				return true;
			}

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

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

		private static InputAction _pingScanAction;

		private static CallbackContext _pingScan;

		private static bool _isScanToggled;

		private static Coroutine _toggleCoroutine;

		private static int lastSlotCount;

		[HarmonyPrefix]
		[HarmonyPatch("PingScan_performed")]
		private static void OnScanTriggered(ref CallbackContext context)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			_pingScan = context;
			if (ModCompats.IsGoodItemScanPresent)
			{
				ScanNodeController.ResetGoodItemScanNodes();
			}
			LootInfoManager.LootScan();
		}

		[HarmonyPrefix]
		[HarmonyPatch("UseSignalTranslatorClientRpc")]
		private static void OnHUDManagerUseSignalTranslatorClientRpc(ref string signalMessage)
		{
			SignalTranslatorController.SetSignalText(signalMessage);
		}

		[HarmonyPrefix]
		[HarmonyPatch("DisableAllScanElements")]
		private static void OnHUDManagerDisabledAllScanElements()
		{
			if (ModCompats.IsGoodItemScanPresent)
			{
				ScanNodeController.ResetGoodItemScanNodes();
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("SetClockVisible")]
		private static void OnHUDManagerSetClockVisible(ref bool visible)
		{
			ClockController.UpdateClockVisibility(ref visible);
			ClockController.ApplyClockAlpha();
		}

		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		private static void OnHUDManagerStart(HUDManager __instance)
		{
			lastSlotCount = 0;
			ScrapValueDisplay.ResetForNewHUD();
			_pingScanAction = IngamePlayerSettings.Instance.playerInput.actions.FindAction("PingScan", false);
			ScanController.SetScanColor();
			ScanController.UpdateScanTexture();
			PlayerHPDisplay.Init();
			ScrapValueDisplay.Init();
			ClockController.ApplyClockAppearance();
			PlanetInfoDisplay.ApplyColors();
			SpectatorHUDController.ApplyColors();
			CanvasGroup selfRedCanvasGroup = __instance.selfRedCanvasGroup;
			if (!((Object)(object)selfRedCanvasGroup == (Object)null))
			{
				PlayerRedCanvasController.Bind(selfRedCanvasGroup);
				if (ModCompats.IsBetterScanVisionPresent)
				{
					BetterScanVisionProxy.OverrideNightVisionColor();
				}
				((MonoBehaviour)__instance).StartCoroutine(ScanTextureRoutine());
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("OnEnable")]
		private static void OnHUDManagerEnable(HUDManager __instance)
		{
			if ((Object)(object)((Component)__instance).gameObject.GetComponent<LethalHUDMono>() == (Object)null)
			{
				((Component)__instance).gameObject.AddComponent<LethalHUDMono>();
			}
			if ((Object)(object)((Component)__instance).gameObject.GetComponent<StatsDisplay>() == (Object)null)
			{
				((Component)__instance).gameObject.AddComponent<StatsDisplay>();
			}
			ChatController.ColorChatInputField(HUDManager.Instance.chatTextField, Time.time * 0.25f);
			((MonoBehaviour)__instance).StartCoroutine(ApplySelfRedAfterTick(__instance));
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(HUDManager), "DisplaySignalTranslatorMessage")]
		private static bool OnHUDManagerDisplaySignalTranslatorMessage(string signalMessage, int seed, SignalTranslator signalTranslator, ref IEnumerator __result)
		{
			if ((Object)(object)signalTranslator != (Object)null && !string.IsNullOrEmpty(signalMessage))
			{
				__result = SignalTranslatorController.DisplaySignalTranslatorMessage(signalMessage, seed, signalTranslator);
				return false;
			}
			return true;
		}

		[HarmonyPostfix]
		[HarmonyPatch("DisplayNewScrapFound")]
		private static void OnHUDManagerDisplayNewScrapFound()
		{
			InventoryFrames.SetSlotColors();
		}

		[HarmonyPostfix]
		[HarmonyPatch("SetClock")]
		private static void OnHUDManagerSetClock(HUDManager __instance, float timeNormalized, float numberOfHours)
		{
			ClockController.TryOverrideClock(__instance, timeNormalized, numberOfHours);
		}

		[HarmonyPostfix]
		[HarmonyPatch("Update")]
		private static void OnHUDManagerUpdate(HUDManager __instance)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			ScanController.UpdateScanAlpha();
			PlayerHPDisplay.UpdateNumber();
			WeightController.UpdateWeightDisplay();
			switch (Plugins.ConfigEntries.ScanModeType.Value)
			{
			case Enums.ScanMode.Default:
				StopToggleScan(__instance);
				break;
			case Enums.ScanMode.Hold:
				StopToggleScan(__instance);
				if (_pingScanAction.IsPressed())
				{
					__instance.PingScan_performed(_pingScan);
				}
				break;
			case Enums.ScanMode.Toggle:
				if (_pingScanAction.WasPressedThisFrame())
				{
					if (_isScanToggled)
					{
						StopToggleScan(__instance);
					}
					else
					{
						StartToggleScan(__instance);
					}
				}
				break;
			}
			int num = __instance.itemSlotIconFrames.Length;
			if (num != lastSlotCount)
			{
				ScrapValueDisplay.RefreshSlots();
				lastSlotCount = num;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("UpdateHealthUI")]
		private static void OnHUDManagerUpdateHealthUI(int health)
		{
			switch (Plugins.ConfigEntries.SelfRedCanvasMode.Value)
			{
			case Enums.SelfRedMode.Vanilla:
				break;
			case Enums.SelfRedMode.ColoredFilled:
				PlayerRedCanvasController.ApplyFillAndColor(health);
				break;
			case Enums.SelfRedMode.RedFillUp:
				PlayerRedCanvasController.ApplyFillWithRedFade(health);
				break;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("UpdateScanNodes")]
		private static void OnHUDManagerUpdateScanNodes(HUDManager __instance)
		{
			if (Plugins.ConfigEntries.ScanNodeFade.Value)
			{
				ScanNodeController.UpdateTimers(__instance.scanElements, __instance.scanNodes);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("AddChatMessage")]
		private static void OnHUDManagerAddChatMessage(HUDManager __instance, string chatMessage, string nameOfUserWhoTyped, int playerWhoSent)
		{
			if (string.IsNullOrEmpty(chatMessage))
			{
				return;
			}
			int num = __instance.ChatMessageHistory.Count - 1;
			if (num >= 0)
			{
				string text = __instance.ChatMessageHistory[num];
				Match match = Regex.Match(chatMessage, "^(<[^>]+>)+");
				string text2 = "";
				string message = chatMessage;
				if (match.Success)
				{
					text2 = match.Value;
					int length = match.Length;
					message = chatMessage.Substring(length, chatMessage.Length - length);
				}
				string text3 = ((chatMessage.Contains("<color=") || chatMessage.Contains("<gradient=")) ? chatMessage : (text2 + ChatController.GetColoredChatMessage(message)));
				string value;
				if (!string.IsNullOrEmpty(nameOfUserWhoTyped))
				{
					string coloredPlayerName = ChatController.GetColoredPlayerName(nameOfUserWhoTyped, playerWhoSent);
					value = coloredPlayerName + ": " + text3;
				}
				else
				{
					value = text3;
				}
				__instance.ChatMessageHistory[num] = value;
				StringBuilder stringBuilder = new StringBuilder();
				for (int i = 0; i < __instance.ChatMessageHistory.Count; i++)
				{
					stringBuilder.Append('\n');
					stringBuilder.Append(__instance.ChatMessageHistory[i]);
				}
				((TMP_Text)__instance.chatText).text = stringBuilder.ToString();
				__instance.PingHUDElement(__instance.Chat, Plugins.ConfigEntries.ChatFadeDelayTime.Value, 1f, 0f);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("OpenMenu_performed")]
		private static void OnHUDManagerOpenMenu_performed(HUDManager __instance)
		{
			__instance.PingHUDElement(__instance.Chat, Plugins.ConfigEntries.ChatFadeDelayTime.Value, 1f, 0f);
		}

		[HarmonyPostfix]
		[HarmonyPatch("ChangeControlTipMultiple")]
		private static void AfterChangeControlTipMultiple()
		{
			ControlTipController.ApplyColor();
		}

		[HarmonyPostfix]
		[HarmonyPatch("ClearControlTips")]
		private static void AfterClearControlTips()
		{
			ControlTipController.ApplyColor();
		}

		[IteratorStateMachine(typeof(<ScanTextureRoutine>d__21))]
		private static IEnumerator ScanTextureRoutine()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ScanTextureRoutine>d__21(0);
		}

		private static void StartToggleScan(HUDManager __instance)
		{
			if (_toggleCoroutine == null)
			{
				_isScanToggled = true;
				_toggleCoroutine = ((MonoBehaviour)__instance).StartCoroutine(ToggleScanRoutine(__instance));
			}
		}

		private static void StopToggleScan(HUDManager __instance)
		{
			if (_toggleCoroutine != null)
			{
				((MonoBehaviour)__instance).StopCoroutine(_toggleCoroutine);
				_toggleCoroutine = null;
				_isScanToggled = false;
			}
		}

		[IteratorStateMachine(typeof(<ToggleScanRoutine>d__24))]
		private static IEnumerator ToggleScanRoutine(HUDManager __instance)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ToggleScanRoutine>d__24(0)
			{
				__instance = __instance
			};
		}

		private static void TryPerformScan(HUDManager __instance)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if (!((Object)(object)localPlayerController == (Object)null))
			{
				float playerPingingScan = __instance.playerPingingScan;
				if (playerPingingScan <= -1f && __instance.CanPlayerScan())
				{
					__instance.playerPingingScan = 0.3f;
					((Component)__instance.scanEffectAnimator).transform.position = ((Component)localPlayerController.gameplayCamera).transform.position;
					__instance.scanEffectAnimator.SetTrigger("scan");
					__instance.PingHUDElement(__instance.Compass, 1f, 0.8f, 0.12f);
					__instance.UIAudio.PlayOneShot(__instance.scanSFX);
					LootInfoManager.LootScan();
				}
			}
		}

		[IteratorStateMachine(typeof(<ApplySelfRedAfterTick>d__26))]
		private static IEnumerator ApplySelfRedAfterTick(HUDManager hud)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ApplySelfRedAfterTick>d__26(0)
			{
				hud = hud
			};
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal static class PlayerControllerBPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("Awake")]
		private static void OnPlayerControllerBAwake(PlayerControllerB __instance)
		{
			PlayerColorNetworker playerColorNetworker = default(PlayerColorNetworker);
			if (!((Component)__instance).TryGetComponent<PlayerColorNetworker>(ref playerColorNetworker))
			{
				((Component)__instance).gameObject.AddComponent<PlayerColorNetworker>();
			}
			PlayerBillboardGradient playerBillboardGradient = default(PlayerBillboardGradient);
			if (!((Component)__instance).TryGetComponent<PlayerBillboardGradient>(ref playerBillboardGradient))
			{
				((Component)__instance).gameObject.AddComponent<PlayerBillboardGradient>();
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("BeginGrabObject")]
		private static void OnPlayerControllerBBeginGrabObject()
		{
			InventoryFrames.HandsFull();
		}

		[HarmonyPrefix]
		[HarmonyPatch("NoPunctuation")]
		private static bool OnPlayerControllerBNoPunctuation(string input, ref string __result)
		{
			if (string.IsNullOrEmpty(input))
			{
				__result = "Nameless";
			}
			else
			{
				__result = ChatController.NoPunctuation(input);
			}
			return false;
		}

		[HarmonyPostfix]
		[HarmonyPatch("SwitchToItemSlot")]
		private static void OnPlayerControllerBSwitchToItemSlot(PlayerControllerB __instance, int slot)
		{
			if ((Object)(object)__instance != (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				return;
			}
			if (!Plugins.ConfigEntries.ShowItemValue.Value && ScrapValueDisplay.slotTexts != null)
			{
				ScrapValueDisplay.Hide(slot);
			}
			if (ScrapValueDisplay.slotTexts != null && slot >= 0 && slot < ScrapValueDisplay.slotTexts.Length)
			{
				if ((Object)(object)__instance.ItemSlots[slot] != (Object)null)
				{
					int scrapValue = __instance.ItemSlots[slot].scrapValue;
					ScrapValueDisplay.UpdateSlot(slot, scrapValue);
				}
				else
				{
					ScrapValueDisplay.UpdateSlot(slot, 0);
				}
				if (__instance.twoHanded)
				{
					HUDManager.Instance.PingHUDElement(HUDManager.Instance.Inventory, Plugins.ConfigEntries.SlotFadeDelayTime.Value / 2f, Math.Clamp(Plugins.ConfigEntries.SlotFade.Value + 0.25f, 0f, 1f), Plugins.ConfigEntries.SlotFade.Value);
				}
				else
				{
					HUDManager.Instance.PingHUDElement(HUDManager.Instance.Inventory, Plugins.ConfigEntries.SlotFadeDelayTime.Value, 1f, Plugins.ConfigEntries.SlotFade.Value);
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("DespawnHeldObject")]
		private static void OnPlayerControllerBDespawnHeldObject(PlayerControllerB __instance)
		{
			ScrapValueDisplay.UpdateSlot(__instance.currentItemSlot, 0);
		}

		[HarmonyPostfix]
		[HarmonyPatch("DiscardHeldObject")]
		private static void OnPlayerControllerBDiscardHeldObject(PlayerControllerB __instance)
		{
			ScrapValueDisplay.UpdateSlot(__instance.currentItemSlot, 0);
		}

		[HarmonyPostfix]
		[HarmonyPatch("DestroyItemInSlot")]
		private static void OnPlayerControllerBDestroyItemInSlot(PlayerControllerB __instance)
		{
			ScrapValueDisplay.UpdateSlot(__instance.currentItemSlot, 0);
		}

		[HarmonyPostfix]
		[HarmonyPatch("DropAllHeldItems")]
		private static void OnPlayerControllerBDiscardAllHelditems(PlayerControllerB __instance)
		{
			ScrapValueDisplay.UpdateSlot(__instance.currentItemSlot, 0);
		}

		[HarmonyPostfix]
		[HarmonyPatch("DamagePlayer")]
		private static void OnPlayerControllerBDamagePlayer(PlayerControllerB __instance)
		{
			PlayerHPDisplay.ShakeOnHit(__instance);
		}

		[HarmonyPostfix]
		[HarmonyPatch("SpawnPlayerAnimation")]
		private static void OnPlayerControllerBSpawnPlayerAnimation()
		{
			ScrapValueDisplay.ClearItemSlots();
		}

		[HarmonyPostfix]
		[HarmonyPatch("LateUpdate")]
		private static void OnPlayerLateUpdate(PlayerControllerB __instance)
		{
			if (__instance.isTypingChat)
			{
				ChatController.PlayerTypingIndicator();
			}
			SprintMeterController.UpdateSprintMeterColor();
		}
	}
	[HarmonyPatch(typeof(Terminal))]
	internal static class TerminalPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("BeginUsingTerminal")]
		private static void OnTerminalBeginUsingTerminal()
		{
			HUDManager.Instance.PingHUDElement(HUDManager.Instance.Inventory, Plugins.ConfigEntries.TerminalFadeDelaysTime.Value, Plugins.ConfigEntries.SlotFade.Value, 0f);
			HUDManager.Instance.PingHUDElement(HUDManager.Instance.Chat, Plugins.ConfigEntries.TerminalFadeDelaysTime.Value, 0.13f, 0.01f);
			HUDManager.Instance.PingHUDElement(HUDManager.Instance.Compass, Plugins.ConfigEntries.TerminalFadeDelaysTime.Value, 0.8f, 0.01f);
		}

		[HarmonyPostfix]
		[HarmonyPatch("QuitTerminal")]
		private static void OnTerminalQuitTerminal()
		{
			HUDManager.Instance.PingHUDElement(HUDManager.Instance.Inventory, Plugins.ConfigEntries.TerminalFadeDelaysTime.Value, 0.13f, Plugins.ConfigEntries.SlotFade.Value);
			HUDManager.Instance.PingHUDElement(HUDManager.Instance.Chat, Plugins.ConfigEntries.TerminalFadeDelaysTime.Value, 0.13f, 0f);
			HUDManager.Instance.PingHUDElement(HUDManager.Instance.Compass, Plugins.ConfigEntries.TerminalFadeDelaysTime.Value, 0.8f, 0.12f);
		}
	}
	[HarmonyPatch(typeof(TimeOfDay))]
	internal static class TimeOfDayPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("MoveTimeOfDay")]
		private static void OnTimeOfDayMoveTimeOfDay()
		{
			ClockController.ApplyRealtimeClock();
		}
	}
}
namespace LethalHUD.Networking
{
	[DisallowMultipleComponent]
	internal class PlayerColorNetworker : NetworkBehaviour
	{
		internal readonly NetworkVariable<PlayerColorInfo> _syncedPlayerColors = new NetworkVariable<PlayerColorInfo>(default(PlayerColorInfo), (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)1);

		public PlayerColorInfo PlayerColors { get; private set; }

		public override void OnNetworkSpawn()
		{
			((NetworkBehaviour)this).OnNetworkSpawn();
			NetworkVariable<PlayerColorInfo> syncedPlayerColors = _syncedPlayerColors;
			syncedPlayerColors.OnValueChanged = (OnValueChangedDelegate<PlayerColorInfo>)(object)Delegate.Combine((Delegate?)(object)syncedPlayerColors.OnValueChanged, (Delegate?)(object)(OnValueChangedDelegate<PlayerColorInfo>)delegate(PlayerColorInfo previousValue, PlayerColorInfo newValue)
			{
				PlayerColors = newValue;
			});
			RefreshColors();
		}

		protected override void OnOwnershipChanged(ulong previous, ulong current)
		{
			((NetworkBehaviour)this).OnOwnershipChanged(previous, current);
			RefreshColors();
		}

		private void RefreshColors()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)this).IsOwner)
			{
				string value = Plugins.ConfigEntries.GradientNameColorA.Value;
				string value2 = Plugins.ConfigEntries.GradientNameColorB.Value;
				Color val = default(Color);
				Color val2 = default(Color);
				PlayerColorInfo playerColors = new PlayerColorInfo(Color32.op_Implicit(ColorUtility.TryParseHtmlString(value, ref val) ? val : Color.red), ColorUtility.TryParseHtmlString(value2, ref val2) ? new Color32?(Color32.op_Implicit(val2)) : null)
				{
					billboardMode = Plugins.ConfigEntries.BillboardMode.Value,
					billboardLayout = Plugins.ConfigEntries.BillboardLayout.Value
				};
				PlayerColors = playerColors;
				if (_syncedPlayerColors.Value != PlayerColors)
				{
					_syncedPlayerColors.Value = PlayerColors;
				}
			}
			PlayerColors = _syncedPlayerColors.Value;
		}

		internal static void RefreshColors(object obj, EventArgs args)
		{
			PlayerColorNetworker playerColorNetworker = default(PlayerColorNetworker);
			if ((Object)(object)GameNetworkManager.Instance != (Object)null && (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null && ((Component)GameNetworkManager.Instance.localPlayerController).TryGetComponent<PlayerColorNetworker>(ref playerColorNetworker))
			{
				playerColorNetworker.RefreshColors();
			}
		}

		protected override void __initializeVariables()
		{
			if (_syncedPlayerColors == null)
			{
				throw new Exception("PlayerColorNetworker._syncedPlayerColors cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)_syncedPlayerColors).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_syncedPlayerColors, "_syncedPlayerColors");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)_syncedPlayerColors);
			((NetworkBehaviour)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			((NetworkBehaviour)this).__initializeRpcs();
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "PlayerColorNetworker";
		}
	}
	public struct PlayerColorInfo : INetworkSerializable, IEquatable<PlayerColorInfo>
	{
		public Color32 colorA;

		public Color32 colorB;

		public Enums.BillboardGradientMode billboardMode;

		public Enums.VertexGradientLayout billboardLayout;

		public PlayerColorInfo(Color32 a, Color32? b = null)
		{
			//IL_000f: 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_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			billboardMode = Enums.BillboardGradientMode.Static;
			billboardLayout = Enums.VertexGradientLayout.Horizontal;
			colorA = a;
			colorB = b.GetValueOrDefault(a);
		}

		public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
		{
			//IL_0024: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			serializer.SerializeValue(ref colorA);
			serializer.SerializeValue(ref colorB);
			((BufferSerializer<Enums.BillboardGradientMode>*)(&serializer))->SerializeValue<Enums.BillboardGradientMode>(ref billboardMode, default(ForEnums));
			((BufferSerializer<Enums.VertexGradientLayout>*)(&serializer))->SerializeValue<Enums.VertexGradientLayout>(ref billboardLayout, default(ForEnums));
		}

		public readonly bool Equals(PlayerColorInfo other)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			Color32 val = colorA;
			if (((object)(Color32)(ref val)).Equals((object?)other.colorA))
			{
				val = colorB;
				if (((object)(Color32)(ref val)).Equals((object?)other.colorB) && billboardMode == other.billboardMode)
				{
					return billboardLayout == other.billboardLayout;
				}
			}
			return false;
		}

		public override readonly bool Equals(object obj)
		{
			if (obj is PlayerColorInfo other)
			{
				return Equals(other);
			}
			return false;
		}

		public static bool operator ==(PlayerColorInfo left, PlayerColorInfo right)
		{
			return left.Equals(right);
		}

		public static bool operator !=(PlayerColorInfo left, PlayerColorInfo right)
		{
			return !(left == right);
		}

		public override readonly int GetHashCode()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return HashCode.Combine<Color32, Color32, Enums.BillboardGradientMode, Enums.VertexGradientLayout>(colorA, colorB, billboardMode, billboardLayout);
		}
	}
}
namespace LethalHUD.Misc
{
	internal static class ControlTipController
	{
		private static readonly Color DefaultColorA = Color.white;

		private static readonly Color DefaultColorB = Color.white;

		private static TMP_Text[] _lastTips;

		private static string[] _lastTipTexts;

		private static string _lastHexA;

		private static string _lastHexB;

		private static Enums.MTColorMode _lastMode;

		internal static void ApplyColor()
		{
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			HUDManager instance = HUDManager.Instance;
			if (instance?.controlTipLines == null || instance.controlTipLines.Length == 0 || (instance.controlTipLines == _lastTips && !HasConfigChanged() && !HasTextChanged(instance)))
			{
				return;
			}
			string value = Plugins.ConfigEntries.MTColorGradientA.Value;
			string value2 = Plugins.ConfigEntries.MTColorGradientB.Value;
			switch (Plugins.ConfigEntries.MTColorSelection.Value)
			{
			case Enums.MTColorMode.Solid:
				ApplySingleColor(instance, value, DefaultColorA);
				break;
			case Enums.MTColorMode.Gradient:
				if (HUDUtils.HasCustomGradient(value, value2))
				{
					ApplyGradient(instance, value, value2, DefaultColorA, DefaultColorB);
				}
				else
				{
					ApplySingleColor(instance, value, DefaultColorA);
				}
				break;
			}
			CacheState(instance);
		}

		private static bool HasConfigChanged()
		{
			Enums.MTColorMode value = Plugins.ConfigEntries.MTColorSelection.Value;
			string value2 = Plugins.ConfigEntries.MTColorGradientA.Value;
			string value3 = Plugins.ConfigEntries.MTColorGradientB.Value;
			if (value == _lastMode && !(value2 != _lastHexA))
			{
				return value3 != _lastHexB;
			}
			return true;
		}

		private static bool HasTextChanged(HUDManager hud)
		{
			if (_lastTipTexts == null || _lastTipTexts.Length != hud.controlTipLines.Length)
			{
				return true;
			}
			for (int i = 0; i < hud.controlTipLines.Length; i++)
			{
				TextMeshProUGUI val = hud.controlTipLines[i];
				if (!((Object)(object)val == (Object)null))
				{
					string text = ((TMP_Text)val).text;
					if (_lastTipTexts[i] != text)
					{
						return true;
					}
				}
			}
			return false;
		}

		private static void CacheState(HUDManager hud)
		{
			TMP_Text[] controlTipLines = (TMP_Text[])(object)hud.controlTipLines;
			_lastTips = controlTipLines;
			_lastMode = Plugins.ConfigEntries.MTColorSelection.Value;
			_lastHexA = Plugins.ConfigEntries.MTColorGradientA.Value;
			_lastHexB = Plugins.ConfigEntries.MTColorGradientB.Value;
			_lastTipTexts = new string[hud.controlTipLines.Length];
			for (int i = 0; i < hud.controlTipLines.Length; i++)
			{
				string[] lastTipTexts = _lastTipTexts;
				int num = i;
				TextMeshProUGUI obj = hud.controlTipLines[i];
				lastTipTexts[num] = ((obj != null) ? ((TMP_Text)obj).text : null);
			}
		}

		private static void ApplySingleColor(HUDManager hud, string hex, Color fallback)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			Color color = HUDUtils.ParseHexColor(hex, fallback);
			TextMeshProUGUI[] controlTipLines = hud.controlTipLines;
			foreach (TextMeshProUGUI val in controlTipLines)
			{
				if ((Object)(object)val != (Object)null)
				{
					((Graphic)val).color = color;
				}
			}
		}

		private static void ApplyGradient(HUDManager hud, string hexA, string hexB, Color fallbackA, Color fallbackB)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			Color val = HUDUtils.ParseHexColor(hexA, fallbackA);
			Color val2 = HUDUtils.ParseHexColor(hexB, fallbackB);
			TextMeshProUGUI[] controlTipLines = hud.controlTipLines;
			foreach (TextMeshProUGUI val3 in controlTipLines)
			{
				if ((Object)(object)val3 == (Object)null)
				{
					continue;
				}
				((TMP_Text)val3).ForceMeshUpdate(false, false);
				TMP_TextInfo textInfo = ((TMP_Text)val3).textInfo;
				int characterCount = textInfo.characterCount;
				if (characterCount == 0)
				{
					continue;
				}
				for (int j = 0; j < characterCount; j++)
				{
					TMP_CharacterInfo val4 = textInfo.characterInfo[j];
					if (val4.isVisible)
					{
						float num = ((characterCount > 1) ? ((float)j / (float)(characterCount - 1)) : 0f);
						Color val5 = Color.Lerp(val, val2, num);
						int vertexIndex = val4.vertexIndex;
						TMP_MeshInfo val6 = textInfo.meshInfo[val4.materialReferenceIndex];
						val6.colors32[vertexIndex] = Color32.op_Implicit(val5);
						val6.colors32[vertexIndex + 1] = Color32.op_Implicit(val5);
						val6.colors32[vertexIndex + 2] = Color32.op_Implicit(val5);
						val6.colors32[vertexIndex + 3] = Color32.op_Implicit(val5);
					}
				}
				for (int k = 0; k < ((TMP_Text)val3).textInfo.meshInfo.Length; k++)
				{
					((TMP_Text)val3).textInfo.meshInfo[k].mesh.colors32 = ((TMP_Text)val3).textInfo.meshInfo[k].colors32;
					((TMP_Text)val3).UpdateGeometry(((TMP_Text)val3).textInfo.meshInfo[k].mesh, k);
				}
			}
		}
	}
	public static class LootInfoManager
	{
		[CompilerGenerated]
		private sealed class <DisplayCoroutine>d__28 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			private float <timer>5__2;

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

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

			[DebuggerHidden]
			public <DisplayCoroutine>d__28(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					_isCoroutineRunning = true;
					EnsureTotalCounter();
					EnsureShipCounter();
					EnsureVanillaTotalLoot();
					AlignShipToTotalDiagonal();
					<timer>5__2 = 0f;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (<timer>5__2 < _displayTimeLeft)
				{
					<timer>5__2 += Time.deltaTime;
					PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
					bool flag = (Object)(object)localPlayerController != (Object)null && localPlayerController.isInHangarShipRoom;
					if (Plugins.ConfigEntries.ReplaceScrapCounterVisual.Value)
					{
						UpdateVanillaScanTotal();
						_scanDisplayTotal = (int)Mathf.MoveTowards((float)_scanDisplayTotal, (float)_scanRealTotal, 500f * Time.deltaTime);
						if (_scanDisplayTotal > 0)
						{
							FadeInCounter(_totalCounter, _totalCG);
							((TMP_Text)_totalText).SetText($"Total: ${_scanDisplayTotal}", true);
							HideVanillaScanUI();
						}
						else
						{
							FadeOutCounter(_totalCounter, _totalCG);
						}
					}
					else
					{
						FadeOutCounter(_totalCounter, _totalCG);
						RestoreVanillaScanUI();
					}
					if (flag && Plugins.ConfigEntries.ShowShipLoot.Value)
					{
						_shipLootValue = CalculateShipLoot();
						FadeInCounter(_shipCounter, _shipCG);
						((TMP_Text)_shipText).SetText($"Ship: ${_shipLootValue}", true);
					}
					else
					{
						FadeOutCounter(_shipCounter, _shipCG);
					}
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				FadeOutCounter(_totalCounter, _totalCG);
				FadeOutCounter(_shipCounter, _shipCG);
				_scanDisplayTotal = 0;
				_scanRealTotal = 0;
				_isCoroutineRunning = false;
				return false;
			}

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

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

		[CompilerGenerated]
		private sealed class <Fade>d__31 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public CanvasGroup cg;

			public float from;

			public float to;

			private float <t>5__2;

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

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

			[DebuggerHidden]
			public <Fade>d__31(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<t>5__2 = 0f;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (<t>5__2 < 0.25f)
				{
					<t>5__2 += Time.deltaTime;
					float num = FadeCurve.Evaluate(<t>5__2 / 0.25f);
					cg.alpha = Mathf.Lerp(from, to, num);
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				cg.alpha = to;
				return false;
			}

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

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

		[CompilerGenerated]
		private sealed class <FadeOutRoutine>d__34 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public CanvasGroup cg;

			public GameObject go;

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

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

			[DebuggerHidden]
			public <FadeOutRoutine>d__34(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = Fade(cg, cg.alpha, 0f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					go.SetActive(false);
					return false;
				}
			}

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

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

		private static GameObject _ship;

		private static GameObject _totalCounter;

		private static GameObject _shipCounter;

		private static GameObject _vanillaTotalLoot;

		private static TextMeshProUGUI _totalText;

		private static TextMeshProUGUI _shipText;

		private static TextMeshProUGUI _vanillaTotalNum;

		private static Image _totalBg;

		private static Image _shipBg;

		private static RectTransform _totalDiagonalRT;

		private static RectTransform _shipDiagonalRT;

		private static CanvasGroup _totalCG;

		private static CanvasGroup _shipCG;

		private static float _displayTimeLeft;

		private static bool _isCoroutineRunning;

		private static int _shipLootValue;

		private static int _scanRealTotal;

		private static int _scanDisplayTotal;

		private static Color _lootInfoColor = Color.white;

		private const float CountSpeed = 500f;

		private const float FadeDuration = 0.25f;

		private static readonly AnimationCurve FadeCurve = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f);

		public static void ApplyLootInfoColor()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			_lootInfoColor = HUDUtils.ParseHexColor(Plugins.ConfigEntries.LootInfoColor.Value);
			ApplyColor(_totalText, _totalBg);
			ApplyColor(_shipText, _shipBg);
		}

		public static void ApplyLootInfoPos()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = _totalCounter.GetComponent<RectTransform>();
			component.anchoredPosition = new Vector2(Plugins.ConfigEntries.LootPosX.Value, Plugins.ConfigEntries.LootPosY.Value);
			((Transform)component).localRotation = Quaternion.identity;
			RectTransform component2 = _shipCounter.GetComponent<RectTransform>();
			((Transform)component2).localRotation = Quaternion.identity;
			((Transform)component2).localScale = ((Transform)component).localScale * 0.95f;
			component2.anchoredPosition = component.anchoredPosition + new Vector2(18f, -17f);
		}

		public static void OnDisplayTimeChanged()
		{
			_displayTimeLeft = Plugins.ConfigEntries.DisplayTime.Value;
		}

		public static void OnShowShipLootChanged()
		{
			if (!Plugins.ConfigEntries.ShowShipLoot.Value)
			{
				FadeOutCounter(_shipCounter, _shipCG);
			}
		}

		public static void OnReplaceScrapCounterVisualChanged()
		{
			if (!Plugins.ConfigEntries.ReplaceScrapCounterVisual.Value)
			{
				FadeOutCounter(_totalCounter, _totalCG);
				RestoreVanillaScanUI();
			}
		}

		public static void LootScan()
		{
			if (!((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null))
			{
				_displayTimeLeft = Plugins.ConfigEntries.DisplayTime.Value;
				if (!_isCoroutineRunning)
				{
					((MonoBehaviour)GameNetworkManager.Instance).StartCoroutine(DisplayCoroutine());
				}
			}
		}

		[IteratorStateMachine(typeof(<DisplayCoroutine>d__28))]
		private static IEnumerator DisplayCoroutine()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DisplayCoroutine>d__28(0);
		}

		private static void EnsureTotalCounter()
		{
			if ((Object)(object)_totalCounter != (Object)null)
			{
				return;
			}
			GameObject val = GameObject.Find("/Systems/UI/Canvas/IngamePlayerHUD/BottomMiddle/ValueCounter");
			if (Object.op_Implicit((Object)(object)val))
			{
				_totalCounter = Object.Instantiate<GameObject>(val, val.transform.parent, false);
				_totalText = _totalCounter.GetComponentInChildren<TextMeshProUGUI>(true);
				_totalBg = _totalCounter.GetComponentInChildren<Image>(true);
				Image? obj = ((IEnumerable<Image>)_totalCounter.GetComponentsInChildren<Image>(true)).FirstOrDefault((Func<Image, bool>)((Image i) => ((Object)i).name.ToLower().Contains("line")));
				_totalDiagonalRT = ((obj != null) ? ((Component)obj).GetComponent<RectTransform>() : null);
				_totalCG = _totalCounter.GetComponent<CanvasGroup>() ?? _totalCounter.AddComponent<CanvasGroup>();
				_totalCG.alpha = 0f;
				_totalCounter.SetActive(false);
				ApplyLootInfoColor();
			}
		}

		private static void EnsureShipCounter()
		{
			if (!((Object)(object)_shipCounter != (Object)null))
			{
				EnsureTotalCounter();
				_shipCounter = Object.Instantiate<GameObject>(_totalCounter, _totalCounter.transform.parent, false);
				_shipText = _shipCounter.GetComponentInChildren<TextMeshProUGUI>(true);
				_shipBg = _shipCounter.GetComponentInChildren<Image>(true);
				Image? obj = ((IEnumerable<Image>)_shipCounter.GetComponentsInChildren<Image>(true)).FirstOrDefault((Func<Image, bool>)((Image i) => ((Object)i).name.ToLower().Contains("line")));
				_shipDiagonalRT = ((obj != null) ? ((Component)obj).GetComponent<RectTransform>() : null);
				_shipCG = _shipCounter.GetComponent<CanvasGroup>() ?? _shipCounter.AddComponent<CanvasGroup>();
				_shipCG.alpha = 0f;
				_shipCounter.SetActive(false);
				ApplyLootInfoPos();
				ApplyLootInfoColor();
			}
		}

		[IteratorStateMachine(typeof(<Fade>d__31))]
		private static IEnumerator Fade(CanvasGroup cg, float from, float to)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Fade>d__31(0)
			{
				cg = cg,
				from = from,
				to = to
			};
		}

		private static void FadeInCounter(GameObject go, CanvasGroup cg)
		{
			if (!((Object)(object)go == (Object)null) && !((Object)(object)cg == (Object)null) && !go.activeSelf && !(cg.alpha > 0.99f))
			{
				go.SetActive(true);
				((MonoBehaviour)GameNetworkManager.Instance).StartCoroutine(Fade(cg, 0f, 1f));
			}
		}

		private static void FadeOutCounter(GameObject go, CanvasGroup cg)
		{
			if (!((Object)(object)go == (Object)null) && !((Object)(object)cg == (Object)null) && go.activeSelf && !(cg.alpha < 0.01f))
			{
				((MonoBehaviour)GameNetworkManager.Instance).StartCoroutine(FadeOutRoutine(go, cg));
			}
		}

		[IteratorStateMachine(typeof(<FadeOutRoutine>d__34))]
		private static IEnumerator FadeOutRoutine(GameObject go, CanvasGroup cg)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <FadeOutRoutine>d__34(0)
			{
				go = go,
				cg = cg
			};
		}

		private static void ApplyColor(TextMeshProUGUI text, Image bg)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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)
			if ((Object)(object)text != (Object)null)
			{
				((Graphic)text).color = _lootInfoColor;
			}
			if ((Object)(object)bg != (Object)null)
			{
				Color lootInfoColor = _lootInfoColor;
				lootInfoColor.a *= 0.25f;
				((Graphic)bg).color = lootInfoColor;
			}
		}

		private static void AlignShipToTotalDiagonal()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_0057: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_totalDiagonalRT == (Object)null) && !((Object)(object)_shipDiagonalRT == (Object)null))
			{
				RectTransform component = _shipCounter.GetComponent<RectTransform>();
				RectTransform totalDiagonalRT = _totalDiagonalRT;
				Rect rect = _totalDiagonalRT.rect;
				float y = ((Transform)totalDiagonalRT).TransformPoint(Vector2.op_Implicit(((Rect)(ref rect)).min)).y;
				RectTransform shipDiagonalRT = _shipDiagonalRT;
				rect = _shipDiagonalRT.rect;
				float y2 = ((Transform)shipDiagonalRT).TransformPoint(Vector2.op_Implicit(((Rect)(ref rect)).max)).y;
				((Transform)component).position = ((Transform)component).position + new Vector3(0f, y - y2, 0f);
			}
		}

		private static int CalculateShipLoot()
		{
			if ((Object)(object)_ship == (Object)null)
			{
				_ship = GameObject.Find("/Environment/HangarShip");
			}
			if ((Object)(object)_ship == (Object)null)
			{
				return 0;
			}
			return (from o in _ship.GetComponentsInChildren<GrabbableObject>()
				where o.itemProperties.isScrap && !(o is RagdollGrabbableObject)
				select o).Sum((GrabbableObject o) => o.scrapValue);
		}

		private static void EnsureVanillaTotalLoot()
		{
			if ((Object)(object)_vanillaTotalLoot == (Object)null)
			{
				_vanillaTotalLoot = GameObject.Find("UI/Canvas/ObjectScanner/GlobalScanInfo/AnimContainer/Image");
			}
			if ((Object)(object)_vanillaTotalLoot != (Object)null && (Object)(object)_vanillaTotalNum == (Object)null)
			{
				_vanillaTotalNum = ((IEnumerable<TextMeshProUGUI>)_vanillaTotalLoot.GetComponentsInChildren<TextMeshProUGUI>(true)).FirstOrDefault((Func<TextMeshProUGUI, bool>)((TextMeshProUGUI t) => ((Object)((Component)t).gameObject).name == "TotalNum"));
			}
		}

		private static void UpdateVanillaScanTotal()
		{
			HUDManager instance = HUDManager.Instance;
			if (!((Object)(object)instance == (Object)null))
			{
				_scanRealTotal = instance.totalScrapScanned;
			}
		}

		private static void HideVanillaScanUI()
		{
			if (!((Object)(object)_vanillaTotalLoot == (Object)null))
			{
				CanvasGroup val = _vanillaTotalLoot.GetComponent<CanvasGroup>() ?? _vanillaTotalLoot.AddComponent<CanvasGroup>();
				val.alpha = 0f;
				val.interactable = false;
				val.blocksRaycasts = false;
			}
		}

		private static void RestoreVanillaScanUI()
		{
			if (!((Object)(object)_vanillaTotalLoot == (Object)null))
			{
				CanvasGroup component = _vanillaTotalLoot.GetComponent<CanvasGroup>();
				if (!((Object)(object)component == (Object)null))
				{
					component.alpha = 1f;
					component.interactable = true;
					component.blocksRaycasts = true;
				}
			}
		}
	}
	[DisallowMultipleComponent]
	internal class PlayerBillboardGradient : MonoBehaviour
	{
		private PlayerControllerB _player;

		private TextMeshProUGUI _text;

		private CanvasGroup _canvasAlpha;

		private PlayerColorNetworker _networker;

		[Header("Performance Options")]
		public float maxUpdateDistance = 30f;

		public float updateInterval = 0.033f;

		private float _timeSinceLastUpdate;

		private PlayerColorInfo _currentColors;

		private bool _hasColors;

		private static bool ColoringEnabled => Plugins.ConfigEntries.BillboardColor.Value;

		private void Awake()
		{
			_player = ((Component)this).GetComponent<PlayerControllerB>();
			if (!((Object)(object)_player == (Object)null))
			{
				_text = _player.usernameBillboardText;
				_canvasAlpha = _player.usernameAlpha;
				_networker = ((Component)_player).GetComponent<PlayerColorNetworker>();
				if ((Object)(object)_text != (Object)null)
				{
					((TMP_Text)_text).enableVertexGradient = true;
				}
			}
		}

		private void Start()
		{
			if (!((Object)(object)_networker == (Object)null))
			{
				_currentColors = _networker._syncedPlayerColors.Value;
				_hasColors = true;
				NetworkVariable<PlayerColorInfo> syncedPlayerColors = _networker._syncedPlayerColors;
				syncedPlayerColors.OnValueChanged = (OnValueChangedDelegate<PlayerColorInfo>)(object)Delegate.Combine((Delegate?)(object)syncedPlayerColors.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<PlayerColorInfo>(OnPlayerColorsChanged));
			}
		}

		private void OnPlayerColorsChanged(PlayerColorInfo previous, PlayerColorInfo current)
		{
			_currentColors = current;
			_hasColors = true;
		}

		private void LateUpdate()
		{
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			if (!ColoringEnabled)
			{
				ResetBillboardToDefault();
				return;
			}
			if (!((TMP_Text)_text).enableVertexGradient)
			{
				((TMP_Text)_text).enableVertexGradient = true;
			}
			if (!_hasColors || (Object)(object)_player == (Object)null || (Object)(object)_text == (Object)null || (Object)(object)_canvasAlpha == (Object)null || !((Component)_player.usernameCanvas).gameObject.activeSelf || _canvasAlpha.alpha < 0.95f || (Object)(object)GameNetworkManager.Instance?.localPlayerController == (Object)null)
			{
				return;
			}
			Vector3 val = ((Component)_player).transform.position - ((Component)GameNetworkManager.Instance.localPlayerController).transform.position;
			float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
			if (sqrMagnitude > maxUpdateDistance * maxUpdateDistance)
			{
				return;
			}
			_timeSinceLastUpdate += Time.deltaTime;
			if (!(_timeSinceLastUpdate < updateInterval))
			{
				_timeSinceLastUpdate = 0f;
				_currentColors = _networker._syncedPlayerColors.Value;
				switch (_currentColors.billboardMode)
				{
				case Enums.BillboardGradientMode.Static:
					HUDUtils.ApplyStaticVertexGradient(_text, Color32.op_Implicit(_currentColors.colorA), Color32.op_Implicit(_currentColors.colorB), _currentColors.billboardLayout);
					break;
				case Enums.BillboardGradientMode.Wave:
					HUDUtils.ApplyWaveVertexGradient(_text, Color32.op_Implicit(_currentColors.colorA), Color32.op_Implicit(_currentColors.colorB), Time.time / 2f, _currentColors.billboardLayout);
					break;
				case Enums.BillboardGradientMode.Pulse:
					HUDUtils.ApplyPulsingVertexGradient(_text, Color32.op_Implicit(_currentColors.colorA), Color32.op_Implicit(_currentColors.colorB), Time.time / 2f, _currentColors.billboardLayout);
					break;
				}
			}
		}

		private void ResetBillboardToDefault()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_text == (Object)null))
			{
				((TMP_Text)_text).enableVertexGradient = false;
				((Graphic)_text).color = Color.white;
			}
		}
	}
	internal static class SpectatorHUDController
	{
		internal static void ApplyColors()
		{
			HUDManager instance = HUDManager.Instance;
			if (!((Object)(object)instance == (Object)null))
			{
				ConfigEntries configEntries = Plugins.ConfigEntries;
				ApplyColorPreserveAlpha(instance.spectatorTipText, configEntries.SpectatorTipColor.Value);
				ApplyColorPreserveAlpha(instance.spectatingPlayerText, configEntries.SpectatingPlayerColor.Value);
				ApplyColorPreserveAlpha(instance.holdButtonToEndGameEarlyText, configEntries.HoldEndGameColor.Value);
				ApplyColorPreserveAlpha(instance.holdButtonToEndGameEarlyVotesText, configEntries.HoldEndGameVotesColor.Value);
			}
		}

		private static void ApplyColorPreserveAlpha(TextMeshProUGUI text, string hexColor)
		{
			//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_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: 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_001b: 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)
			if (!((Object)(object)text == (Object)null))
			{
				Color color = ((Graphic)text).color;
				Color color2 = HUDUtils.ParseHexColor(hexColor, color);
				color2.a = color.a;
				((Graphic)text).color = color2;
			}
		}
	}
	public class StatsDisplay : NetworkBehaviour
	{
		private float _deltaTime;

		private ulong _currentPing;

		private float _pingTimer;

		private TextMeshProUGUI _statsText;

		private UnityTransport _transport;

		private string _lastText = "";

		private Enums.MTColorMode _lastMode;

		private string _lastHexA = "";

		private string _lastHexB = "";

		private bool _lastSplit;

		private string _lastSeparateHex = "";

		private void Start()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			ref UnityTransport transport = ref _transport;
			NetworkTransport networkTransport = NetworkManager.Singleton.NetworkConfig.NetworkTransport;
			transport = (UnityTransport)(object)((networkTransport is UnityTransport) ? networkTransport : null);
			GameObject val = new GameObject("StatsDisplay");
			GameObject val2 = GameObject.Find("Systems/UI/Canvas/IngamePlayerHUD/");
			val.transform.SetParent(val2.transform, false);
			_statsText = val.AddComponent<TextMeshProUGUI>();
			((TMP_Text)_statsText).font = ((TMP_Text)HUDManager.Instance.chatText).font;
			((TMP_Text)_statsText).fontSize = 12f;
			((TMP_Text)_statsText).richText = true;
			((TMP_Text)_statsText).alignment = (TextAlignmentOptions)257;
			Material val3 = Object.Instantiate<Material>(((TMP_Text)_statsText).fontMaterial);
			val3.EnableKeyword("UNDERLAY_ON");
			val3.SetColor("_UnderlayColor", Color.black);
			val3.SetFloat("_UnderlayOffsetX", 1.2f);
			val3.SetFloat("_UnderlayOffsetY", -1.2f);
			val3.SetFloat("_UnderlaySoftness", 0.35f);
			((TMP_Text)_statsText).fontMaterial = val3;
			RectTransform rectTransform = ((TMP_Text)_statsText).rectTransform;
			rectTransform.anchorMin = new Vector2(0f, 1f);
			rectTransform.anchorMax = new Vector2(0f, 1f);
			rectTransform.pivot = new Vector2(0f, 1f);
			rectTransform.anchoredPosition = new Vector2(Plugins.ConfigEntries.FPSCounterX.Value, 0f - Plugins.ConfigEntries.FPSCounterY.Value);
		}

		private void Update()
		{
			_deltaTime += (Time.unscaledDeltaTime - _deltaTime) * 0.1f;
			HandlePing();
			UpdateStatsText();
		}

		private void HandlePing()
		{
			//IL_0044: 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)
			if (((NetworkBehaviour)this).IsOwner && !((Object)(object)_transport == (Object)null))
			{
				_pingTimer += Time.deltaTime;
				if (_pingTimer >= 0.5f)
				{
					_pingTimer = 0f;
					RequestPingServerRpc();
				}
			}
		}

		private void UpdateStatsText()
		{
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			if (!Plugins.ConfigEntries.ShowFPSDisplay.Value && !Plugins.ConfigEntries.ShowPingDisplay.Value && !Plugins.ConfigEntries.ShowSeedDisplay.Value)
			{
				((TMP_Text)_statsText).text = "";
				_lastText = "";
				return;
			}
			List<string> list = new List<string>();
			if (Plugins.ConfigEntries.ShowFPSDisplay.Value)
			{
				int num = Mathf.RoundToInt(1f / _deltaTime);
				list.Add($"FPS: {num}");
			}
			if (Plugins.ConfigEntries.ShowPingDisplay.Value)
			{
				list.Add($"Ping: {_currentPing} ms");
			}
			if (Plugins.ConfigEntries.ShowSeedDisplay.Value && (Object)(object)StartOfRound.Instance != (Object)null && !StartOfRound.Instance.inShipPhase)
			{
				list.Add($"Seed: {StartOfRound.Instance.randomMapSeed}");
			}
			string separator = ((Plugins.ConfigEntries.MiscLayoutEnum.Value == Enums.FPSPingLayout.Vertical) ? "\n─────────\n" : " | ");
			string text = string.Join(separator, list);
			bool value = Plugins.ConfigEntries.SplitAdditionalMTFromToolTips.Value;
			string value2 = Plugins.ConfigEntries.SeperateAdditionalMiscToolsColors.Value;
			if (text != _lastText || Plugins.ConfigEntries.MTColorSelection.Value != _lastMode || Plugins.ConfigEntries.MTColorGradientA.Value != _lastHexA || Plugins.ConfigEntries.MTColorGradientB.Value != _lastHexB || value != _lastSplit || value2 != _lastSeparateHex)
			{
				((TMP_Text)_statsText).text = text;
				((TMP_Text)_statsText).alignment = (TextAlignmentOptions)257;
				((TMP_Text)_statsText).rectTransform.anchoredPosition = new Vector2(Plugins.ConfigEntries.FPSCounterX.Value, 0f - Plugins.ConfigEntries.FPSCounterY.Value);
				((TMP_Text)_statsText).enableWordWrapping = false;
				ApplyTextColor(_statsText);
				_lastText = text;
				_lastMode = Plugins.ConfigEntries.MTColorSelection.Value;
				_lastHexA = Plugins.ConfigEntries.MTColorGradientA.Value;
				_lastHexB = Plugins.ConfigEntries.MTColorGradientB.Value;
				_lastSplit = value;
				_lastSeparateHex = value2;
			}
		}

		private void ApplyTextColor(TextMeshProUGUI tmp)
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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_009f: Unknown result type (might be due to invalid IL or missing references)
			bool value = Plugins.ConfigEntries.SplitAdditionalMTFromToolTips.Value;
			string text = (value ? Plugins.ConfigEntries.SeperateAdditionalMiscToolsColors.Value : Plugins.ConfigEntries.MTColorGradientA.Value);
			string text2 = (value ? Plugins.ConfigEntries.SeperateAdditionalMiscToolsColors.Value : Plugins.ConfigEntries.MTColorGradientB.Value);
			switch (Plugins.ConfigEntries.MTColorSelection.Value)
			{
			case Enums.MTColorMode.Solid:
				((Graphic)tmp).color = HUDUtils.ParseHexColor(text, Color.white);
				break;
			case Enums.MTColorMode.Gradient:
				if (HUDUtils.HasCustomGradient(text, text2) && !value)
				{
					ApplyGradient(tmp, text, text2);
				}
				else
				{
					((Graphic)tmp).color = HUDUtils.ParseHexColor(text, Color.white);
				}
				break;
			}
		}

		private void ApplyGradient(TextMeshProUGUI tmp, string hexA, string hexB)
		{
			//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_0025: 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_0031: 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_0047: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			((TMP_Text)tmp).ForceMeshUpdate(false, false);
			TMP_TextInfo textInfo = ((TMP_Text)tmp).textInfo;
			int characterCount = textInfo.characterCount;
			if (characterCount == 0)
			{
				return;
			}
			Color val = HUDUtils.ParseHexColor(hexA, Color.white);
			Color val2 = HUDUtils.ParseHexColor(hexB, Color.white);
			for (int i = 0; i < characterCount; i++)
			{
				TMP_CharacterInfo val3 = textInfo.characterInfo[i];
				if (val3.isVisible)
				{
					float num = ((characterCount > 1) ? ((float)i / (float)(characterCount - 1)) : 0f);
					Color val4 = Color.Lerp(val, val2, num);
					TMP_MeshInfo val5 = textInfo.meshInfo[val3.materialReferenceIndex];
					int vertexIndex = val3.vertexIndex;
					val5.colors32[vertexIndex] = Color32.op_Implicit(val4);
					val5.colors32[vertexIndex + 1] = Color32.op_Implicit(val4);
					val5.colors32[vertexIndex + 2] = Color32.op_Implicit(val4);
					val5.colors32[vertexIndex + 3] = Color32.op_Implicit(val4);
				}
			}
			for (int j = 0; j < ((TMP_Text)tmp).textInfo.meshInfo.Length; j++)
			{
				((TMP_Text)tmp).textInfo.meshInfo[j].mesh.colors32 = ((TMP_Text)tmp).textInfo.meshInfo[j].colors32;
				((TMP_Text)tmp).UpdateGeometry(((TMP_Text)tmp).textInfo.meshInfo[j].mesh, j);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void RequestPingServerRpc(ServerRpcParams rpcParams = default(ServerRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(1694769970u, rpcParams, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 1694769970u, rpcParams, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				if (!((Object)(object)_transport == (Object)null))
				{
					ulong senderClientId = rpcParams.Receive.SenderClientId;
					ulong currentRtt = ((NetworkTransport)_transport).GetCurrentRtt(senderClientId);
					SendPingClientRpc(currentRtt, new ClientRpcParams
					{
						Send = new ClientRpcSendParams
						{
							TargetClientIds = new <>z__ReadOnlySingleElementList<ulong>(senderClientId)
						}
					});
				}
			}
		}

		[ClientRpc]
		private void SendPingClientRpc(ulong ping, ClientRpcParams rpcParams = default(ClientRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3343597132u, rpcParams, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val, ping);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 3343597132u, rpcParams, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					_currentPing = ping;
				}
			}
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(1694769970u, new RpcReceiveHandler(__rpc_handler_1694769970), "RequestPingServerRpc");
			((NetworkBehaviour)this).__registerRpc(3343597132u, new RpcReceiveHandler(__rpc_handler_3343597132), "SendPingClientRpc");
			((NetworkBehaviour)this).__initializeRpcs();
		}

		private static void __rpc_handler_1694769970(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ServerRpcParams server = rpcParams.Server;
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((StatsDisplay)(object)target).RequestPingServerRpc(server);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3343597132(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong ping = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref ping);
				ClientRpcParams client = rpcParams.Client;
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((StatsDisplay)(object)target).SendPingClientRpc(ping, client);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "StatsDisplay";
		}
	}
}
namespace LethalHUD.HUD
{
	internal static class ChatController
	{
		private static bool ColoringEnabled => Plugins.ConfigEntries.ColoredNames.Value;

		internal static string NoPunctuation(string input)
		{
			return new string(new ReadOnlySpan<char>(input.Where((char c) => char.IsLetterOrDigit(c) || c == '_' || c == '.').ToArray()));
		}

		internal static string GetColoredPlayerName(string playerName, int playerId = -1)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(playerName))
			{
				return playerName;
			}
			if (ColoringEnabled && playerId < StartOfRound.Instance.allPlayerScripts.Length)
			{
				PlayerControllerB val = ((playerId >= 0) ? StartOfRound.Instance.allPlayerScripts[playerId] : GameNetworkManager.Instance.localPlayerController);
				PlayerColorNetworker playerColorNetworker = default(PlayerColorNetworker);
				if (((Component)val).TryGetComponent<PlayerColorNetworker>(ref playerColorNetworker))
				{
					PlayerColorInfo playerColors = playerColorNetworker.PlayerColors;
					return HUDUtils.ApplyStaticGradient(playerName, Color32.op_Implicit(playerColors.colorA), Color32.op_Implicit(playerColors.colorB));
				}
			}
			return "<color=#FF0000>" + playerName + "</color>";
		}

		internal static string GetColoredChatMessage(string message)
		{
			//IL_0068: Unknown result type (might be due to