Decompiled source of ValueDisplay v0.0.2

ValueDisplay.dll

Decompiled an hour ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("ValueDisplay")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("ValueDisplay - Lethal Company HUD mod that shows each inventory slot's scrap price below the slot and the total value of carried scrap above the inventory. Pure client-side, depends only on BepInEx and Harmony.")]
[assembly: AssemblyFileVersion("0.0.2.0")]
[assembly: AssemblyInformationalVersion("0.0.2")]
[assembly: AssemblyProduct("ValueDisplay")]
[assembly: AssemblyTitle("ValueDisplay")]
[assembly: AssemblyVersion("0.0.2.0")]
namespace ValueDisplay;

[HarmonyPatch(typeof(HUDManager))]
internal static class HudManagerPatch
{
	[HarmonyPostfix]
	[HarmonyPatch("Start")]
	private static void StartPostfix()
	{
		if ((Object)(object)Object.FindObjectOfType<ValueHudController>() == (Object)null)
		{
			ValueHudController.Create();
		}
	}
}
[BepInPlugin("ValueDisplay", "ValueDisplay", "0.0.2")]
public class ValueDisplayPlugin : BaseUnityPlugin
{
	public const string GUID = "ValueDisplay";

	public const string NAME = "ValueDisplay";

	public const string VERSION = "0.0.2";

	private Harmony _harmony;

	private static string _blacklistRawCache;

	private static List<string> _blacklistParsedCache;

	public static ValueDisplayPlugin Instance { get; private set; }

	public static ManualLogSource Log { get; private set; }

	public ConfigEntry<bool> ShowSlotValue { get; private set; }

	public ConfigEntry<bool> ShowTotalValue { get; private set; }

	public ConfigEntry<bool> FixUnscannableScrap { get; private set; }

	public ConfigEntry<string> BlacklistScrapNames { get; private set; }

	public ConfigEntry<float> ScannedValueDisplayTime { get; private set; }

	public ConfigEntry<float> ScannedScanRange { get; private set; }

	public ConfigEntry<float> SlotFontSize { get; private set; }

	public ConfigEntry<float> TotalFontSize { get; private set; }

	public ConfigEntry<bool> SlotColorEnabled { get; private set; }

	public ConfigEntry<bool> TotalColorEnabled { get; private set; }

	public ConfigEntry<float> ColorThresholdGreen { get; private set; }

	public ConfigEntry<float> ColorThresholdBlue { get; private set; }

	public ConfigEntry<float> ColorThresholdPurple { get; private set; }

	public ConfigEntry<float> ColorThresholdGold { get; private set; }

	public ConfigEntry<float> ColorThresholdRed { get; private set; }

	public ConfigEntry<string> Language { get; private set; }

	public ConfigEntry<KeyboardShortcut> ToggleKey { get; private set; }

	private void Awake()
	{
		//IL_0296: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ca: Expected O, but got Unknown
		Instance = this;
		Log = ((BaseUnityPlugin)this).Logger;
		ShowSlotValue = ((BaseUnityPlugin)this).Config.Bind<bool>("Display", "ShowSlotValue", true, "Show the scrap price directly below each inventory slot (only when the slot holds a valuable scrap item).");
		ShowTotalValue = ((BaseUnityPlugin)this).Config.Bind<bool>("Display", "ShowTotalValue", true, "Show the total value of all carried scrap on the HUD.");
		FixUnscannableScrap = ((BaseUnityPlugin)this).Config.Bind<bool>("Display", "FixUnscannableScrap", true, "Fix scrap that cannot be scanned for a price: some special items (e.g. ShotgunShell) have a scrap-type scan node but the item itself has isScrap=false, so the scan record used to be rejected and the item kept showing ??? while held. When enabled, such items are recorded when scanned and count toward the total; when disabled, the original behavior is kept. Enabled by default.");
		BlacklistScrapNames = ((BaseUnityPlugin)this).Config.Bind<string>("Display", "BlacklistScrapNames", "Training Manual, Sticky Note", "Comma-separated list of item names. Blacklisted scrap is not recorded even when scanned, and does not count toward the scanned value / total value (e.g. Training Manual has a price but is a non-carryable instruction item; Sticky Note is a decorative writeable scrap). Matches itemProperties.itemName or GameObject name, ignoring case and spaces. Defaults to Training Manual, Sticky Note.");
		ScannedValueDisplayTime = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "ScannedValueDisplayTime", 10f, "How long the scanned value text stays visible (seconds): starts counting when a new scrap value is scanned, then auto-hides. Default 10 seconds.");
		ScannedScanRange = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "ScannedScanRange", 6f, "Scanned value range (meters): a scan counts toward the scanned value only when the player is within this distance of the ship (shipBounds) or any vehicle (VehicleController). Scans outside the range or indoors (isInsideFactory) still record the slot price and total value, but do not count toward the scanned value. Default 6 meters (about one car length).");
		SlotFontSize = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "SlotFontSize", 25f, "Font size of the slot price text (single item price). Default 25.");
		TotalFontSize = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "TotalFontSize", 16f, "Font size of the total value text. Default 16.");
		SlotFontSize.SettingChanged += OnFontSizeSettingChanged;
		TotalFontSize.SettingChanged += OnFontSizeSettingChanged;
		SlotColorEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Display", "SlotColorEnabled", true, "Color slot prices by value tier. Enabled by default.");
		TotalColorEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Display", "TotalColorEnabled", false, "Color the total value by value tier. Disabled by default (white text).");
		ColorThresholdGreen = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "ColorThresholdGreen", 30f, "Color tier threshold: values >= this are colored green. Default 30.");
		ColorThresholdBlue = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "ColorThresholdBlue", 60f, "Color tier threshold: values >= this are colored blue. Default 60.");
		ColorThresholdPurple = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "ColorThresholdPurple", 90f, "Color tier threshold: values >= this are colored purple. Default 90.");
		ColorThresholdGold = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "ColorThresholdGold", 120f, "Color tier threshold: values >= this are colored gold. Default 120.");
		ColorThresholdRed = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "ColorThresholdRed", 150f, "Color tier threshold: values >= this are colored red. Default 150.");
		Language = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Language", "en", "UI language, corresponding to the ValueDisplay_<lang>.lang file next to the DLL. Built-in: en, zh-CN, ru, pl, la, fr, pt, es. Falls back to built-in English text if the file is missing or fails to load.");
		ToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "ToggleKey", new KeyboardShortcut((KeyCode)277, Array.Empty<KeyCode>()), "Hotkey to show/hide all price texts in real time. Supports modifiers (e.g. Ctrl+Shift+F1; format is key names joined by '+'). Default Insert.");
		Translation.Load(Language.Value);
		_harmony = new Harmony("ValueDisplay");
		_harmony.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)("ValueDisplay v0.0.2 loaded. Language: " + Language.Value));
	}

	private void OnFontSizeSettingChanged(object sender, EventArgs e)
	{
		ValueHudController.ApplyFontSizesFromConfig();
	}

	public static bool IsBlacklisted(GrabbableObject grabbable)
	{
		string text = Instance?.BlacklistScrapNames?.Value;
		if (string.IsNullOrWhiteSpace(text) || (Object)(object)grabbable == (Object)null)
		{
			return false;
		}
		List<string> parsedBlacklist = GetParsedBlacklist(text);
		if (parsedBlacklist.Count == 0)
		{
			return false;
		}
		List<string> list = new List<string>();
		if ((Object)(object)grabbable.itemProperties != (Object)null && !string.IsNullOrEmpty(grabbable.itemProperties.itemName))
		{
			list.Add(grabbable.itemProperties.itemName);
		}
		if (!string.IsNullOrEmpty(((Object)grabbable).name))
		{
			list.Add(((Object)grabbable).name);
		}
		foreach (string item in parsedBlacklist)
		{
			foreach (string item2 in list)
			{
				string text2 = item2.Replace(" ", "").ToLowerInvariant();
				if (text2 == item || text2.Contains(item) || item.Contains(text2))
				{
					return true;
				}
			}
		}
		return false;
	}

	private static List<string> GetParsedBlacklist(string config)
	{
		if (_blacklistRawCache != config)
		{
			_blacklistRawCache = config;
			List<string> list = new List<string>();
			string[] array = config.Split(new char[1] { ',' });
			for (int i = 0; i < array.Length; i++)
			{
				string text = array[i].Trim();
				if (text.Length != 0)
				{
					list.Add(text.Replace(" ", "").ToLowerInvariant());
				}
			}
			_blacklistParsedCache = list;
		}
		return _blacklistParsedCache;
	}

	private void OnDestroy()
	{
		Harmony harmony = _harmony;
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
	}
}
[HarmonyPatch(typeof(HUDManager))]
internal static class ScanNodePatch
{
	private static readonly Dictionary<ScanNodeProperties, float> _lastMapTime = new Dictionary<ScanNodeProperties, float>();

	private static readonly HashSet<string> _loggedFailures = new HashSet<string>();

	private static VehicleController[] _vehicleCache;

	private static float _vehicleCacheTime = -999f;

	private const float VehicleCacheLifetime = 0.5f;

	private static float _lastCacheCleanTime;

	[HarmonyPostfix]
	[HarmonyPatch("UpdateScanNodes")]
	private static void UpdateScanNodesPostfix(List<ScanNodeProperties> ___nodesOnScreen, float ___playerPingingScan)
	{
		if (___playerPingingScan < 0f || ___nodesOnScreen == null)
		{
			return;
		}
		bool countsForScannedTotal = CanScanAtCurrentPosition();
		if (Time.time - _lastCacheCleanTime > 30f)
		{
			_lastCacheCleanTime = Time.time;
			if (_lastMapTime.Count > 256)
			{
				_lastMapTime.Clear();
			}
			if (_loggedFailures.Count > 256)
			{
				_loggedFailures.Clear();
			}
		}
		foreach (ScanNodeProperties item in ___nodesOnScreen)
		{
			if ((Object)(object)item != (Object)null)
			{
				RecordScannedValue(item, countsForScannedTotal);
			}
		}
	}

	private static bool CanScanAtCurrentPosition()
	{
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		StartOfRound instance = StartOfRound.Instance;
		if ((Object)(object)instance == (Object)null)
		{
			return false;
		}
		PlayerControllerB localPlayerController = instance.localPlayerController;
		if ((Object)(object)localPlayerController == (Object)null)
		{
			return false;
		}
		if (localPlayerController.isInsideFactory)
		{
			return false;
		}
		float num = ValueDisplayPlugin.Instance?.ScannedScanRange?.Value ?? 6f;
		float num2 = num * num;
		Vector3 position = ((Component)localPlayerController).transform.position;
		Collider shipBounds = instance.shipBounds;
		Vector3 val;
		if ((Object)(object)shipBounds != (Object)null)
		{
			val = shipBounds.ClosestPoint(position) - position;
			if (((Vector3)(ref val)).sqrMagnitude <= num2)
			{
				return true;
			}
		}
		VehicleController[] vehicles = GetVehicles();
		foreach (VehicleController val2 in vehicles)
		{
			if (!((Object)(object)val2 == (Object)null))
			{
				val = ((Component)val2).transform.position - position;
				if (((Vector3)(ref val)).sqrMagnitude <= num2)
				{
					return true;
				}
			}
		}
		return false;
	}

	private static VehicleController[] GetVehicles()
	{
		float time = Time.time;
		if (_vehicleCache == null || time - _vehicleCacheTime >= 0.5f)
		{
			_vehicleCache = Object.FindObjectsOfType<VehicleController>();
			_vehicleCacheTime = time;
		}
		return _vehicleCache;
	}

	private static void RecordScannedValue(ScanNodeProperties node, bool countsForScannedTotal)
	{
		if ((Object)(object)node == (Object)null)
		{
			return;
		}
		bool flag = node.nodeType == 2;
		if (_lastMapTime.TryGetValue(node, out var value) && Time.time - value < 1f)
		{
			return;
		}
		_lastMapTime[node] = Time.time;
		GrabbableObject val = ResolveGrabbable(node, allowPositionFallback: true);
		if ((Object)(object)val == (Object)null)
		{
			if (!flag)
			{
				return;
			}
			string text = (((Object)(object)((Component)node).transform != (Object)null && (Object)(object)((Component)node).transform.root != (Object)null) ? ((Object)((Component)node).transform.root).name : "?");
			string item = text + "/" + ((Object)node).name;
			if (_loggedFailures.Add(item))
			{
				ManualLogSource log = ValueDisplayPlugin.Log;
				if (log != null)
				{
					log.LogWarning((object)$"ScanNodePatch: node {((Object)node).name} root={text} resolve failed grabbable=null scrapValue={node.scrapValue}");
				}
			}
			return;
		}
		if (ValueDisplayPlugin.IsBlacklisted(val))
		{
			string item2 = (((Object)(object)((Component)node).transform != (Object)null && (Object)(object)((Component)node).transform.root != (Object)null) ? ((Object)((Component)node).transform.root).name : "?") + "/" + ((Object)node).name;
			if (_loggedFailures.Add(item2))
			{
				ManualLogSource log2 = ValueDisplayPlugin.Log;
				if (log2 != null)
				{
					log2.LogInfo((object)("ScanNodePatch: node " + ((Object)node).name + " grabbable=" + ((Object)val).name + " is blacklisted, skipped (no scanned marker)"));
				}
			}
			return;
		}
		bool isScrap = val.itemProperties.isScrap;
		bool flag2 = ValueDisplayPlugin.Instance?.FixUnscannableScrap?.Value ?? true;
		if (!isScrap && !flag2)
		{
			if (!flag)
			{
				return;
			}
			string text2 = (((Object)(object)((Component)node).transform != (Object)null && (Object)(object)((Component)node).transform.root != (Object)null) ? ((Object)((Component)node).transform.root).name : "?");
			string item3 = text2 + "/" + ((Object)node).name;
			if (_loggedFailures.Add(item3))
			{
				ManualLogSource log3 = ValueDisplayPlugin.Log;
				if (log3 != null)
				{
					log3.LogWarning((object)$"ScanNodePatch: node {((Object)node).name} root={text2} resolve failed grabbable={((Object)val).name} isScrap=False scrapValue={node.scrapValue} (FixUnscannableScrap=off, rejected)");
				}
			}
			return;
		}
		ValueHudController.ScannedMarker scannedMarker = ((Component)val).GetComponent<ValueHudController.ScannedMarker>();
		if ((Object)(object)scannedMarker == (Object)null)
		{
			scannedMarker = ((Component)val).gameObject.AddComponent<ValueHudController.ScannedMarker>();
			ManualLogSource log4 = ValueDisplayPlugin.Log;
			if (log4 != null)
			{
				log4.LogInfo((object)string.Format("ScanNodePatch: marked scrap grabbable={0} node={1} nodeType={2} scrapValue={3}{4}", ((Object)val).name, ((Object)node).name, node.nodeType, node.scrapValue, isScrap ? "" : " [FixUnscannableScrap]"));
			}
		}
		scannedMarker.Value = node.scrapValue;
		if (countsForScannedTotal)
		{
			scannedMarker.CountsForScannedTotal = true;
			ValueHudController.NotifyScanRecorded();
		}
	}

	private static GrabbableObject ResolveGrabbable(ScanNodeProperties node, bool allowPositionFallback)
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: 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)
		GrabbableObject componentInParent = ((Component)node).GetComponentInParent<GrabbableObject>();
		if ((Object)(object)componentInParent != (Object)null)
		{
			return componentInParent;
		}
		GrabbableObject componentInChildren = ((Component)node).GetComponentInChildren<GrabbableObject>();
		if ((Object)(object)componentInChildren != (Object)null)
		{
			return componentInChildren;
		}
		if (!allowPositionFallback)
		{
			return null;
		}
		Vector3 position = ((Component)node).transform.position;
		GrabbableObject result = null;
		float num = 9f;
		GrabbableObject[] grabbables = ValueHudController.GetGrabbables();
		foreach (GrabbableObject val in grabbables)
		{
			if (!((Object)(object)val == (Object)null))
			{
				Vector3 val2 = ((Component)val).transform.position - position;
				float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
				if (sqrMagnitude < num)
				{
					num = sqrMagnitude;
					result = val;
				}
			}
		}
		return result;
	}
}
public static class Translation
{
	private const string FilePrefix = "ValueDisplay_";

	private const string FileExtension = ".lang";

	private static readonly Dictionary<string, string> EnglishFallback = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
	{
		["slot_value_format"] = "{0}",
		["slot_value_unknown"] = "???",
		["total_value_format"] = "Total: {0}",
		["scanned_value_format"] = "Scanned: {0}"
	};

	private static Dictionary<string, string> _entries = EnglishFallback;

	public static string CurrentLanguage { get; private set; } = "en";

	public static void Load(string language)
	{
		if (string.IsNullOrWhiteSpace(language))
		{
			language = "en";
		}
		CurrentLanguage = language;
		_entries = EnglishFallback;
		string langFilePath = GetLangFilePath(language);
		if (langFilePath == null)
		{
			ManualLogSource log = ValueDisplayPlugin.Log;
			if (log != null)
			{
				log.LogWarning((object)"ValueDisplay: could not locate plugin directory, using built-in English text.");
			}
			return;
		}
		if (!File.Exists(langFilePath))
		{
			ManualLogSource log2 = ValueDisplayPlugin.Log;
			if (log2 != null)
			{
				log2.LogWarning((object)("ValueDisplay: language file " + langFilePath + " not found, using built-in English text."));
			}
			return;
		}
		try
		{
			Dictionary<string, string> dictionary = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
			string[] array = File.ReadAllLines(langFilePath);
			for (int i = 0; i < array.Length; i++)
			{
				string text = array[i].Trim();
				if (text.Length != 0 && !text.StartsWith("#") && !text.StartsWith(";"))
				{
					int num = text.IndexOf('=');
					if (num > 0)
					{
						string key = text.Substring(0, num).Trim();
						string value = text.Substring(num + 1).Trim();
						dictionary[key] = value;
					}
				}
			}
			_entries = dictionary;
			ManualLogSource log3 = ValueDisplayPlugin.Log;
			if (log3 != null)
			{
				log3.LogInfo((object)$"ValueDisplay: loaded language file {langFilePath} ({dictionary.Count} entries).");
			}
		}
		catch (Exception ex)
		{
			ManualLogSource log4 = ValueDisplayPlugin.Log;
			if (log4 != null)
			{
				log4.LogWarning((object)("ValueDisplay: failed to read language file: " + ex.Message + ", using built-in English text."));
			}
			_entries = EnglishFallback;
		}
	}

	public static string Get(string key)
	{
		if (!_entries.TryGetValue(key, out var value) && !EnglishFallback.TryGetValue(key, out value))
		{
			return key;
		}
		return value;
	}

	public static string Get(string key, int arg0)
	{
		if (!_entries.TryGetValue(key, out var value) && !EnglishFallback.TryGetValue(key, out value))
		{
			return key;
		}
		if (value == null)
		{
			return string.Empty;
		}
		int num = value.IndexOf("{0}", StringComparison.Ordinal);
		if (num < 0)
		{
			return value;
		}
		string text = arg0.ToString();
		if (value.Length == 3)
		{
			return text;
		}
		return value.Substring(0, num) + text + value.Substring(num + 3);
	}

	private static string GetLangFilePath(string language)
	{
		try
		{
			string location = Assembly.GetExecutingAssembly().Location;
			if (string.IsNullOrEmpty(location))
			{
				return null;
			}
			string directoryName = Path.GetDirectoryName(location);
			return (directoryName == null) ? null : Path.Combine(directoryName, "ValueDisplay_" + language + ".lang");
		}
		catch
		{
			return null;
		}
	}
}
public class ValueHudController : MonoBehaviour
{
	public class ScannedMarker : MonoBehaviour
	{
		public int Value;

		public bool CountsForScannedTotal;
	}

	private const string TextTemplatePath = "Environment/HangarShip/ShipModels2b/MonitorWall/Cube/Canvas (1)/MainContainer/HeaderText";

	private const float TextWidth = 300f;

	private const float TextHeight = 80f;

	private const int EmptySlotState = -1;

	private const int UnknownSlotState = -2;

	private static readonly Color PriceColor = Color.white;

	private static readonly Color ColorGreen = new Color(0.2f, 0.9f, 0.2f);

	private static readonly Color ColorBlue = new Color(0.25f, 0.55f, 1f);

	private static readonly Color ColorPurple = new Color(0.7f, 0.3f, 1f);

	private static readonly Color ColorGold = new Color(1f, 0.84f, 0f);

	private static readonly Color ColorRed = new Color(1f, 0.2f, 0.2f);

	private readonly List<TextMeshProUGUI> _slotTexts = new List<TextMeshProUGUI>();

	private readonly List<int> _slotLastValues = new List<int>();

	private Vector3[] _slotLastFramePos;

	private readonly List<GrabbableObject> _slotItems = new List<GrabbableObject>();

	private readonly List<Item> _slotItemProperties = new List<Item>();

	private readonly List<ScannedMarker> _slotMarkers = new List<ScannedMarker>();

	private readonly List<Color> _slotLastColors = new List<Color>();

	private Image[] _slotFrames;

	private TextMeshProUGUI _totalValueText;

	private TextMeshProUGUI _scannedValueText;

	private int _totalLastValue = int.MinValue;

	private bool _totalLastVisible;

	private int _scannedLastValue = int.MinValue;

	private bool _scannedLastVisible;

	private Vector3 _totalLastFramePos = new Vector3(float.MinValue, 0f, 0f);

	private Vector3 _scannedLastFramePos = new Vector3(float.MinValue, 0f, 0f);

	private Color _totalLastColor = Color.white;

	private Color _scannedLastColor = Color.white;

	private RectTransform _containerRect;

	private bool _uiReady;

	private bool _pricesVisible = true;

	private PlayerControllerB _localPlayer;

	private int _scannedValue;

	private float _scannedRefreshTimer;

	private float _scannedValueTimer;

	private int _scanRecordVersionSeen = -1;

	private static GrabbableObject[] _grabbableCache;

	private static float _grabbableCacheTime = -999f;

	private const float GrabbableCacheLifetime = 0.5f;

	private TextMeshProUGUI _template;

	public static int ScanRecordVersion { get; private set; }

	public static void NotifyScanRecorded()
	{
		ScanRecordVersion++;
	}

	public static GrabbableObject[] GetGrabbables()
	{
		float time = Time.time;
		if (_grabbableCache == null || time - _grabbableCacheTime >= 0.5f)
		{
			_grabbableCache = Object.FindObjectsOfType<GrabbableObject>();
			_grabbableCacheTime = time;
		}
		return _grabbableCache;
	}

	public static ValueHudController Create()
	{
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = (((Object)(object)HUDManager.Instance != (Object)null) ? HUDManager.Instance.HUDContainer : null);
		if ((Object)(object)val == (Object)null)
		{
			ManualLogSource log = ValueDisplayPlugin.Log;
			if (log != null)
			{
				log.LogWarning((object)"ValueDisplay: HUDContainer is null, cannot create UI controller.");
			}
			return null;
		}
		RectTransform component = val.GetComponent<RectTransform>();
		if ((Object)(object)component == (Object)null)
		{
			ManualLogSource log2 = ValueDisplayPlugin.Log;
			if (log2 != null)
			{
				log2.LogWarning((object)"ValueDisplay: HUDContainer is missing a RectTransform, cannot do coordinate conversion.");
			}
			return null;
		}
		GameObject val2 = new GameObject("ValueDisplayHUD", new Type[1] { typeof(RectTransform) });
		val2.transform.SetParent(val.transform, false);
		ValueHudController valueHudController = val2.AddComponent<ValueHudController>();
		valueHudController._containerRect = component;
		return valueHudController;
	}

	public static void ApplyFontSizesFromConfig()
	{
		ValueHudController valueHudController = Object.FindObjectOfType<ValueHudController>();
		if ((Object)(object)valueHudController == (Object)null || !valueHudController._uiReady)
		{
			return;
		}
		float fontSize = ValueDisplayPlugin.Instance?.SlotFontSize?.Value ?? 10f;
		float fontSize2 = ValueDisplayPlugin.Instance?.TotalFontSize?.Value ?? 8f;
		foreach (TextMeshProUGUI slotText in valueHudController._slotTexts)
		{
			if ((Object)(object)slotText != (Object)null)
			{
				((TMP_Text)slotText).fontSize = fontSize;
			}
		}
		if ((Object)(object)valueHudController._totalValueText != (Object)null)
		{
			((TMP_Text)valueHudController._totalValueText).fontSize = fontSize2;
		}
		if ((Object)(object)valueHudController._scannedValueText != (Object)null)
		{
			((TMP_Text)valueHudController._scannedValueText).fontSize = fontSize2;
		}
	}

	private void Start()
	{
		_template = FindTextTemplate();
		if (!((Object)(object)_template == (Object)null))
		{
			TryInitializeUi();
		}
	}

	private void TryInitializeUi()
	{
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: 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)
		if (_uiReady || (Object)(object)_template == (Object)null)
		{
			return;
		}
		PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null);
		GrabbableObject[] array = (((Object)(object)val != (Object)null) ? val.ItemSlots : null);
		if (array != null && array.Length != 0)
		{
			float fontSize = ValueDisplayPlugin.Instance?.SlotFontSize?.Value ?? 10f;
			float fontSize2 = ValueDisplayPlugin.Instance?.TotalFontSize?.Value ?? 8f;
			_slotFrames = (((Object)(object)HUDManager.Instance != (Object)null) ? HUDManager.Instance.itemSlotIconFrames : null);
			_slotLastFramePos = (Vector3[])(object)new Vector3[array.Length];
			for (int i = 0; i < array.Length; i++)
			{
				_slotTexts.Add(CreateSlotText($"ValueDisplaySlot{i}", fontSize, _template, ((Component)this).transform));
				_slotLastValues.Add(int.MinValue);
				_slotItems.Add(null);
				_slotItemProperties.Add(null);
				_slotMarkers.Add(null);
				_slotLastColors.Add(Color.white);
				_slotLastFramePos[i] = new Vector3(float.MinValue, 0f, 0f);
			}
			_totalValueText = CreateSlotText("ValueDisplayTotal", fontSize2, _template, ((Component)this).transform);
			_scannedValueText = CreateSlotText("ValueDisplayScanned", fontSize2, _template, ((Component)this).transform);
			_uiReady = true;
			ManualLogSource log = ValueDisplayPlugin.Log;
			if (log != null)
			{
				log.LogInfo((object)"ValueDisplay: slot / total / scanned value UI created.");
			}
		}
	}

	private void Update()
	{
		//IL_06ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_06b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_06b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_06c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_06d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_06d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0537: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d5: Unknown result type (might be due to invalid IL or missing references)
		if (!_uiReady)
		{
			if ((Object)(object)_template != (Object)null)
			{
				TryInitializeUi();
			}
			return;
		}
		if (IsTogglePressed())
		{
			_pricesVisible = !_pricesVisible;
		}
		if (!_pricesVisible)
		{
			HideAllTexts();
			return;
		}
		PlayerControllerB val = _localPlayer;
		if ((Object)(object)val == (Object)null)
		{
			val = (_localPlayer = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null));
		}
		if ((Object)(object)val == (Object)null || !((NetworkBehaviour)val).IsOwner || val.isPlayerDead || val.ItemSlots == null)
		{
			HideAllTexts();
			return;
		}
		GrabbableObject[] itemSlots = val.ItemSlots;
		int num = 0;
		bool flag = false;
		ValueDisplayPlugin instance = ValueDisplayPlugin.Instance;
		bool flag2 = instance?.ShowSlotValue?.Value ?? true;
		bool flag3 = instance?.ShowTotalValue?.Value ?? true;
		bool valueOrDefault = instance?.SlotColorEnabled?.Value == true;
		bool valueOrDefault2 = instance?.TotalColorEnabled?.Value == true;
		bool flag4 = instance?.FixUnscannableScrap?.Value ?? true;
		float thresholdRed = instance?.ColorThresholdRed?.Value ?? 150f;
		float thresholdGold = instance?.ColorThresholdGold?.Value ?? 120f;
		float thresholdPurple = instance?.ColorThresholdPurple?.Value ?? 90f;
		float thresholdBlue = instance?.ColorThresholdBlue?.Value ?? 60f;
		float thresholdGreen = instance?.ColorThresholdGreen?.Value ?? 30f;
		float displayTime = instance?.ScannedValueDisplayTime?.Value ?? 10f;
		for (int i = 0; i < itemSlots.Length && i < _slotTexts.Count; i++)
		{
			TextMeshProUGUI val2 = _slotTexts[i];
			GrabbableObject val3 = itemSlots[i];
			if (_slotItems.Count <= i)
			{
				_slotItems.Add(val3);
				_slotMarkers.Add(((Object)(object)val3 != (Object)null) ? ((Component)val3).GetComponent<ScannedMarker>() : null);
				_slotItemProperties.Add(((Object)(object)val3 != (Object)null) ? val3.itemProperties : null);
			}
			else if ((Object)(object)_slotItems[i] != (Object)(object)val3)
			{
				_slotItems[i] = val3;
				_slotMarkers[i] = (((Object)(object)val3 != (Object)null) ? ((Component)val3).GetComponent<ScannedMarker>() : null);
				_slotItemProperties[i] = (((Object)(object)val3 != (Object)null) ? val3.itemProperties : null);
			}
			ScannedMarker scannedMarker = _slotMarkers[i];
			Item val4 = _slotItemProperties[i];
			bool flag5 = (Object)(object)val3 != (Object)null && (((Object)(object)val4 != (Object)null && val4.isScrap) || (flag4 && (Object)(object)scannedMarker != (Object)null));
			if (!flag2 || !flag5)
			{
				if (_slotLastValues[i] != -1)
				{
					((TMP_Text)val2).text = string.Empty;
					_slotLastValues[i] = -1;
				}
				((Behaviour)val2).enabled = false;
				continue;
			}
			int num2 = (((Object)(object)scannedMarker != (Object)null && scannedMarker.Value > 0) ? scannedMarker.Value : val3.scrapValue);
			if ((Object)(object)scannedMarker == (Object)null)
			{
				flag = true;
				if (_slotLastValues[i] != -2)
				{
					((TMP_Text)val2).text = Translation.Get("slot_value_unknown");
					_slotLastValues[i] = -2;
				}
				((Behaviour)val2).enabled = true;
				SetSlotColor(i, val2, Color.white);
			}
			else
			{
				if (num2 <= 0)
				{
					if (_slotLastValues[i] != -1)
					{
						((TMP_Text)val2).text = string.Empty;
						_slotLastValues[i] = -1;
					}
					((Behaviour)val2).enabled = false;
					continue;
				}
				num += num2;
				if (_slotLastValues[i] != num2)
				{
					((TMP_Text)val2).text = Translation.Get("slot_value_format", num2);
					_slotLastValues[i] = num2;
				}
				((Behaviour)val2).enabled = true;
				SetSlotColor(i, val2, GetValueColor(num2, valueOrDefault, thresholdRed, thresholdGold, thresholdPurple, thresholdBlue, thresholdGreen));
			}
			Image slotFrame = GetSlotFrame(i);
			if ((Object)(object)slotFrame != (Object)null)
			{
				PositionBelowSlot(val2, slotFrame, ref _slotLastFramePos[i]);
			}
		}
		if ((Object)(object)_totalValueText != (Object)null)
		{
			int num3 = ((!flag) ? num : 0);
			bool flag6 = flag3 && (num3 > 0 || flag);
			if (_totalLastValue != num3 || _totalLastVisible != flag6)
			{
				((TMP_Text)_totalValueText).text = Translation.Get("total_value_format", num3);
				_totalLastValue = num3;
				_totalLastVisible = flag6;
			}
			((Behaviour)_totalValueText).enabled = flag6;
			if (flag6)
			{
				Color valueColor = GetValueColor(num3, valueOrDefault2, thresholdRed, thresholdGold, thresholdPurple, thresholdBlue, thresholdGreen);
				if (_totalLastColor != valueColor)
				{
					((Graphic)_totalValueText).color = valueColor;
					_totalLastColor = valueColor;
				}
				PositionAboveItemBar(_totalValueText, ref _totalLastFramePos);
			}
		}
		UpdateScannedValueText(valueOrDefault2, displayTime, thresholdRed, thresholdGold, thresholdPurple, thresholdBlue, thresholdGreen);
	}

	private void UpdateScannedValueText(bool totalColorEnabled, float displayTime, float thresholdRed, float thresholdGold, float thresholdPurple, float thresholdBlue, float thresholdGreen)
	{
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_scannedValueText == (Object)null)
		{
			return;
		}
		_scannedRefreshTimer += Time.deltaTime;
		if (_scannedRefreshTimer >= 0.5f)
		{
			_scannedRefreshTimer = 0f;
			_scannedValue = ComputeScannedValue();
		}
		if (_scanRecordVersionSeen != ScanRecordVersion)
		{
			_scanRecordVersionSeen = ScanRecordVersion;
			_scannedValueTimer = displayTime;
		}
		if (_scannedValueTimer > 0f)
		{
			_scannedValueTimer -= Time.deltaTime;
		}
		bool flag = _scannedValue > 0 && _scannedValueTimer > 0f;
		if (_scannedLastValue != _scannedValue || _scannedLastVisible != flag)
		{
			((TMP_Text)_scannedValueText).text = Translation.Get("scanned_value_format", _scannedValue);
			_scannedLastValue = _scannedValue;
			_scannedLastVisible = flag;
		}
		((Behaviour)_scannedValueText).enabled = flag;
		if (flag)
		{
			Color valueColor = GetValueColor(_scannedValue, totalColorEnabled, thresholdRed, thresholdGold, thresholdPurple, thresholdBlue, thresholdGreen);
			if (_scannedLastColor != valueColor)
			{
				((Graphic)_scannedValueText).color = valueColor;
				_scannedLastColor = valueColor;
			}
			Image fourthSlotFrame = GetFourthSlotFrame();
			if ((Object)(object)fourthSlotFrame != (Object)null)
			{
				PositionAboveSlot(_scannedValueText, fourthSlotFrame, ref _scannedLastFramePos);
			}
		}
	}

	private static int ComputeScannedValue()
	{
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		StartOfRound instance = StartOfRound.Instance;
		if ((Object)(object)instance == (Object)null)
		{
			return 0;
		}
		Collider shipBounds = instance.shipBounds;
		VehicleController attachedVehicle = instance.attachedVehicle;
		bool flag = (Object)(object)attachedVehicle != (Object)null && attachedVehicle.magnetedToShip;
		int num = 0;
		GrabbableObject[] grabbables = GetGrabbables();
		foreach (GrabbableObject val in grabbables)
		{
			if ((Object)(object)val == (Object)null || val.isHeld || val.isHeldByEnemy)
			{
				continue;
			}
			ScannedMarker component = ((Component)val).GetComponent<ScannedMarker>();
			if ((Object)(object)component == (Object)null || !component.CountsForScannedTotal || ValueDisplayPlugin.IsBlacklisted(val))
			{
				continue;
			}
			int num2 = ((component.Value > 0) ? component.Value : val.scrapValue);
			if (num2 > 0)
			{
				int num3;
				if ((Object)(object)shipBounds != (Object)null)
				{
					Bounds bounds = shipBounds.bounds;
					num3 = (((Bounds)(ref bounds)).Contains(((Component)val).transform.position) ? 1 : 0);
				}
				else
				{
					num3 = 0;
				}
				bool flag2 = flag && ((Component)val).transform.IsChildOf(((Component)attachedVehicle).transform);
				if (((uint)num3 | (flag2 ? 1u : 0u)) != 0)
				{
					num += num2;
				}
			}
		}
		return num;
	}

	private Image GetFourthSlotFrame()
	{
		Image[] slotFrames = _slotFrames;
		if (slotFrames == null || slotFrames.Length == 0)
		{
			return null;
		}
		if (slotFrames.Length < 4)
		{
			return slotFrames[^1];
		}
		return slotFrames[3];
	}

	private static Color GetValueColor(int value, bool enabled, float thresholdRed, float thresholdGold, float thresholdPurple, float thresholdBlue, float thresholdGreen)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: 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_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: 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)
		if (!enabled)
		{
			return Color.white;
		}
		if ((float)value >= thresholdRed)
		{
			return ColorRed;
		}
		if ((float)value >= thresholdGold)
		{
			return ColorGold;
		}
		if ((float)value >= thresholdPurple)
		{
			return ColorPurple;
		}
		if ((float)value >= thresholdBlue)
		{
			return ColorBlue;
		}
		if ((float)value >= thresholdGreen)
		{
			return ColorGreen;
		}
		return Color.white;
	}

	private void PositionBelowSlot(TextMeshProUGUI text, Image frame, ref Vector3 lastFramePos)
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_003f: 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_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		RectTransform rectTransform = ((Graphic)frame).rectTransform;
		if (!((Object)(object)rectTransform == (Object)null) && !((Object)(object)_containerRect == (Object)null) && !((Object)(object)text == (Object)null))
		{
			Vector3 position = ((Transform)rectTransform).position;
			if (!(lastFramePos == position))
			{
				lastFramePos = position;
				Vector3 val = ((Transform)_containerRect).InverseTransformPoint(position);
				float num = rectTransform.sizeDelta.y * 0.5f;
				((Transform)((TMP_Text)text).rectTransform).localPosition = new Vector3(val.x, val.y - num, val.z);
				ResetTextTransform(text);
			}
		}
	}

	private void PositionAboveItemBar(TextMeshProUGUI text, ref Vector3 lastFramePos)
	{
		Image slotFrame = GetSlotFrame(0);
		if ((Object)(object)slotFrame != (Object)null)
		{
			PositionAboveSlot(text, slotFrame, ref lastFramePos);
		}
	}

	private void PositionAboveSlot(TextMeshProUGUI text, Image frame, ref Vector3 lastFramePos)
	{
		//IL_0035: 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_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: 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_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		RectTransform val = (((Object)(object)frame != (Object)null) ? ((Graphic)frame).rectTransform : null);
		if (!((Object)(object)val == (Object)null) && !((Object)(object)_containerRect == (Object)null) && !((Object)(object)text == (Object)null))
		{
			Vector3 position = ((Transform)val).position;
			if (!(lastFramePos == position))
			{
				lastFramePos = position;
				Vector3 val2 = ((Transform)_containerRect).InverseTransformPoint(position);
				float num = val.sizeDelta.y * 1.5f;
				((Transform)((TMP_Text)text).rectTransform).localPosition = new Vector3(val2.x, val2.y + num, val2.z);
				ResetTextTransform(text);
			}
		}
	}

	private static void ResetTextTransform(TextMeshProUGUI text)
	{
		//IL_0007: 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)
		RectTransform rectTransform = ((TMP_Text)text).rectTransform;
		((Transform)rectTransform).localRotation = Quaternion.identity;
		((Transform)rectTransform).localScale = Vector3.one;
	}

	private static TextMeshProUGUI CreateSlotText(string objectName, float fontSize, TextMeshProUGUI template, Transform parent)
	{
		//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_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)template == (Object)null || (Object)(object)((TMP_Text)template).font == (Object)null)
		{
			ManualLogSource log = ValueDisplayPlugin.Log;
			if (log != null)
			{
				log.LogWarning((object)"ValueDisplay: text template has no font asset, cannot create text.");
			}
			return null;
		}
		GameObject val = new GameObject(objectName, new Type[1] { typeof(RectTransform) });
		val.transform.SetParent(parent, false);
		TextMeshProUGUI obj = val.AddComponent<TextMeshProUGUI>();
		((TMP_Text)obj).font = ((TMP_Text)template).font;
		((TMP_Text)obj).fontSharedMaterial = ((TMP_Text)template).fontSharedMaterial;
		((TMP_Text)obj).text = string.Empty;
		((Behaviour)obj).enabled = false;
		((TMP_Text)obj).fontSize = fontSize;
		((Graphic)obj).color = PriceColor;
		((TMP_Text)obj).alignment = (TextAlignmentOptions)514;
		((TMP_Text)obj).enableWordWrapping = false;
		((TMP_Text)obj).overflowMode = (TextOverflowModes)0;
		((TMP_Text)obj).enableAutoSizing = false;
		((Graphic)obj).raycastTarget = false;
		RectTransform rectTransform = ((TMP_Text)obj).rectTransform;
		((Transform)rectTransform).localPosition = Vector3.zero;
		((Transform)rectTransform).localRotation = Quaternion.identity;
		((Transform)rectTransform).localScale = Vector3.one;
		rectTransform.anchorMin = new Vector2(0.5f, 0.5f);
		rectTransform.anchorMax = new Vector2(0.5f, 0.5f);
		rectTransform.pivot = new Vector2(0.5f, 0.5f);
		rectTransform.sizeDelta = new Vector2(300f, 80f);
		return obj;
	}

	private TextMeshProUGUI FindTextTemplate()
	{
		GameObject val = GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall/Cube/Canvas (1)/MainContainer/HeaderText");
		if ((Object)(object)val == (Object)null)
		{
			ManualLogSource log = ValueDisplayPlugin.Log;
			if (log != null)
			{
				log.LogWarning((object)"ValueDisplay: text template Environment/HangarShip/ShipModels2b/MonitorWall/Cube/Canvas (1)/MainContainer/HeaderText not found, cannot create slot price UI.");
			}
			return null;
		}
		TextMeshProUGUI component = val.GetComponent<TextMeshProUGUI>();
		if ((Object)(object)component == (Object)null)
		{
			ManualLogSource log2 = ValueDisplayPlugin.Log;
			if (log2 != null)
			{
				log2.LogWarning((object)"ValueDisplay: text template Environment/HangarShip/ShipModels2b/MonitorWall/Cube/Canvas (1)/MainContainer/HeaderText is missing a TextMeshProUGUI component.");
			}
			return null;
		}
		return component;
	}

	private bool IsTogglePressed()
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		KeyboardShortcut? val = ValueDisplayPlugin.Instance?.ToggleKey?.Value;
		if (val.HasValue)
		{
			KeyboardShortcut value = val.Value;
			return ((KeyboardShortcut)(ref value)).IsDown();
		}
		return false;
	}

	private Image GetSlotFrame(int index)
	{
		Image[] slotFrames = _slotFrames;
		if (slotFrames == null || index < 0 || index >= slotFrames.Length)
		{
			return null;
		}
		return slotFrames[index];
	}

	private void SetSlotColor(int index, TextMeshProUGUI text, Color color)
	{
		//IL_0016: 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_0024: 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)
		if (_slotLastColors.Count > index && _slotLastColors[index] != color)
		{
			((Graphic)text).color = color;
			_slotLastColors[index] = color;
		}
	}

	private void HideAllTexts()
	{
		foreach (TextMeshProUGUI slotText in _slotTexts)
		{
			if ((Object)(object)slotText != (Object)null)
			{
				((Behaviour)slotText).enabled = false;
			}
		}
		if ((Object)(object)_totalValueText != (Object)null)
		{
			((Behaviour)_totalValueText).enabled = false;
		}
		if ((Object)(object)_scannedValueText != (Object)null)
		{
			((Behaviour)_scannedValueText).enabled = false;
		}
	}
}