Decompiled source of LevelValuesAndCosmeticsScanner v1.0.0

plugins/LevelValuesAndCosmeticsScanner/LevelValuesAndCosmeticsScanner.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using LevelValuesAndCosmeticsScanner.GameInterop;
using LevelValuesAndCosmeticsScanner.Hud;
using LevelValuesAndCosmeticsScanner.Runtime;
using LevelValuesAndCosmeticsScanner.Scanning;
using LevelValuesAndCosmeticsScanner.Settings;
using LevelValuesAndCosmeticsScanner.Snapshots;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LevelValuesAndCosmeticsScanner
{
	[BepInPlugin("DarkSpider90.LevelValuesAndCosmeticsScanner", "LevelValuesAndCosmeticsScanner", "1.0.0")]
	public sealed class ModEntryPoint : BaseUnityPlugin
	{
		private const string PLUGIN_GUID = "DarkSpider90.LevelValuesAndCosmeticsScanner";

		private const string PLUGIN_NAME = "LevelValuesAndCosmeticsScanner";

		private const string PLUGIN_VERSION = "1.0.0";

		public static ManualLogSource Log { get; private set; }

		public void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			ModSettings.Bind(((BaseUnityPlugin)this).Config);
			((Component)this).gameObject.AddComponent<LevelScannerRuntime>();
			Log.LogInfo((object)"LevelValuesAndCosmeticsScanner 1.0.0 loaded.");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "LevelValuesAndCosmeticsScanner";

		public const string PLUGIN_NAME = "Level Values And Cosmetics Scanner";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace LevelValuesAndCosmeticsScanner.Snapshots
{
	public sealed class BoxRaritySnapshot
	{
		public static readonly BoxRaritySnapshot Empty = new BoxRaritySnapshot();

		public int Common { get; set; }

		public int Uncommon { get; set; }

		public int Rare { get; set; }

		public int UltraRare { get; set; }

		public int Total => Common + Uncommon + Rare + UltraRare;

		public bool HasAny => Total > 0;

		public void Include(Rarity rarity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected I4, but got Unknown
			switch ((int)rarity)
			{
			case 0:
				Common++;
				break;
			case 1:
				Uncommon++;
				break;
			case 2:
				Rare++;
				break;
			case 3:
				UltraRare++;
				break;
			}
		}
	}
	public readonly struct LevelValuablesSnapshot
	{
		public static readonly LevelValuablesSnapshot Empty = new LevelValuablesSnapshot(0, 0f);

		public readonly int LooseItemCount;

		public readonly float LooseItemValue;

		public bool HasLooseItems => LooseItemCount > 0;

		public LevelValuablesSnapshot(int looseItemCount, float looseItemValue)
		{
			LooseItemCount = looseItemCount;
			LooseItemValue = looseItemValue;
		}
	}
}
namespace LevelValuesAndCosmeticsScanner.Settings
{
	public enum HudAnchor
	{
		BottomRight,
		Right
	}
	internal static class ModSettings
	{
		public static ConfigEntry<bool> AlwaysOn { get; private set; }

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

		public static ConfigEntry<bool> ShowItemCount { get; private set; }

		public static ConfigEntry<bool> ShowCosmeticBoxes { get; private set; }

		public static ConfigEntry<HudAnchor> UIPosition { get; private set; }

		public static void Bind(ConfigFile config)
		{
			config.SaveOnConfigSet = false;
			AlwaysOn = Entry(config, "Default", "AlwaysOn", value: true, "Always show the tracker during a level instead of only while the map key is held.");
			ShowTotalValue = Entry(config, "Default", "ShowTotalValue", value: true, "Show the total value of valuables outside the extraction zone.");
			ShowItemCount = Entry(config, "Default", "ShowItemCount", value: true, "Show the number of valuables outside the extraction zone.");
			ShowCosmeticBoxes = Entry(config, "Default", "ShowCosmeticBoxes", value: true, "Scan and show compact cosmetic box counters beside the value tracker.");
			UIPosition = Entry(config, "UIPosition", "UIPosition", HudAnchor.BottomRight, "Preset tracker position.");
			RemoveUnknownEntries(config);
			config.Save();
			config.SaveOnConfigSet = true;
		}

		private static ConfigEntry<T> Entry<T>(ConfigFile config, string section, string key, T value, string description)
		{
			return config.Bind<T>(section, key, value, description);
		}

		private static void RemoveUnknownEntries(ConfigFile config)
		{
			PropertyInfo property = typeof(ConfigFile).GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
			if (!(property == null))
			{
				((Dictionary<ConfigDefinition, string>)property.GetValue(config))?.Clear();
			}
		}
	}
}
namespace LevelValuesAndCosmeticsScanner.Scanning
{
	public sealed class CosmeticBoxCounter
	{
		private const float RefreshDelay = 0.5f;

		private float _nextRefreshTime;

		private BoxRaritySnapshot _latest = BoxRaritySnapshot.Empty;

		public void Reset()
		{
			_latest = BoxRaritySnapshot.Empty;
			_nextRefreshTime = 0f;
		}

		public BoxRaritySnapshot Read(bool force = false)
		{
			if (!force && Time.unscaledTime < _nextRefreshTime)
			{
				return _latest;
			}
			_nextRefreshTime = Time.unscaledTime + 0.5f;
			_latest = BuildSnapshot();
			return _latest;
		}

		private static BoxRaritySnapshot BuildSnapshot()
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			RoundDirector instance = RoundDirector.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return BoxRaritySnapshot.Empty;
			}
			BoxRaritySnapshot boxRaritySnapshot = new BoxRaritySnapshot();
			foreach (CosmeticWorldObject cosmeticWorldObject in instance.cosmeticWorldObjects)
			{
				if (!((Object)(object)cosmeticWorldObject == (Object)null) && !((Object)(object)((Component)cosmeticWorldObject).gameObject == (Object)null) && ((Behaviour)cosmeticWorldObject).isActiveAndEnabled && ((Component)cosmeticWorldObject).gameObject.activeInHierarchy)
				{
					boxRaritySnapshot.Include(cosmeticWorldObject.rarity);
				}
			}
			return boxRaritySnapshot;
		}
	}
	public sealed class ValuableObjectScanner
	{
		private const float RefreshDelay = 0.25f;

		private float _nextRefreshTime;

		private LevelValuablesSnapshot _latest = LevelValuablesSnapshot.Empty;

		public void Reset()
		{
			_latest = LevelValuablesSnapshot.Empty;
			_nextRefreshTime = 0f;
		}

		public LevelValuablesSnapshot Read(bool force = false)
		{
			if (!force && Time.unscaledTime < _nextRefreshTime)
			{
				return _latest;
			}
			_nextRefreshTime = Time.unscaledTime + 0.25f;
			_latest = BuildSnapshot();
			return _latest;
		}

		private static LevelValuablesSnapshot BuildSnapshot()
		{
			ValuableDirector instance = ValuableDirector.instance;
			RoundDirector instance2 = RoundDirector.instance;
			if ((Object)(object)instance == (Object)null || (Object)(object)instance2 == (Object)null)
			{
				return LevelValuablesSnapshot.Empty;
			}
			List<GameObject> dollarHaulList = instance2.dollarHaulList;
			int num = 0;
			float num2 = 0f;
			foreach (ValuableObject valuable in instance.valuableList)
			{
				if (ShouldCount(valuable, dollarHaulList))
				{
					num++;
					num2 += Mathf.Max(0f, GameFieldReader.CurrentValue(valuable));
				}
			}
			return new LevelValuablesSnapshot(num, num2);
		}

		private static bool ShouldCount(ValuableObject valuable, List<GameObject> extractedObjects)
		{
			if ((Object)(object)valuable == (Object)null || (Object)(object)((Component)valuable).gameObject == (Object)null)
			{
				return false;
			}
			if (!((Behaviour)valuable).isActiveAndEnabled || !((Component)valuable).gameObject.activeInHierarchy)
			{
				return false;
			}
			if (!GameFieldReader.ValueWasAssigned(valuable))
			{
				return false;
			}
			if (extractedObjects != null)
			{
				return !extractedObjects.Contains(((Component)valuable).gameObject);
			}
			return true;
		}
	}
}
namespace LevelValuesAndCosmeticsScanner.Runtime
{
	public sealed class LevelScannerRuntime : MonoBehaviour
	{
		private readonly ValuableObjectScanner _valuableScanner = new ValuableObjectScanner();

		private readonly CosmeticBoxCounter _cosmeticCounter = new CosmeticBoxCounter();

		private bool _levelReady;

		private void Update()
		{
			if (!IsLevelReady())
			{
				LeaveLevelIfNeeded();
				return;
			}
			EnterLevelIfNeeded();
			RefreshHud();
		}

		private void RefreshHud()
		{
			if ((Object)(object)RoundDirector.instance == (Object)null)
			{
				HudOverlay.Instance.Hide();
				return;
			}
			bool flag = ModSettings.AlwaysOn.Value || IsMapVisible();
			LevelValuablesSnapshot valuables = _valuableScanner.Read();
			BoxRaritySnapshot boxes = ReadCosmeticBoxes();
			if (GameFieldReader.ExtractionIsFinished(RoundDirector.instance) || !flag || NothingToShow(valuables, boxes))
			{
				HudOverlay.Instance.Hide();
			}
			else
			{
				HudOverlay.Instance.Show(BuildValueText(valuables), boxes, ModSettings.ShowCosmeticBoxes.Value, ModSettings.UIPosition.Value);
			}
		}

		private void EnterLevelIfNeeded()
		{
			if (!_levelReady)
			{
				_levelReady = true;
				_valuableScanner.Reset();
				_cosmeticCounter.Reset();
				_valuableScanner.Read(force: true);
				if (ModSettings.ShowCosmeticBoxes.Value)
				{
					_cosmeticCounter.Read(force: true);
				}
				ModEntryPoint.Log.LogDebug((object)"Level scan session started.");
			}
		}

		private void LeaveLevelIfNeeded()
		{
			if (_levelReady)
			{
				_levelReady = false;
				_valuableScanner.Reset();
				_cosmeticCounter.Reset();
				HudOverlay.Instance.Hide();
				ModEntryPoint.Log.LogDebug((object)"Level scan session cleared.");
			}
		}

		private static bool IsLevelReady()
		{
			if (SemiFunc.RunIsLevel() && (Object)(object)LevelGenerator.Instance != (Object)null)
			{
				return LevelGenerator.Instance.Generated;
			}
			return false;
		}

		private static bool IsMapVisible()
		{
			if (SemiFunc.InputHold((InputKey)8))
			{
				return true;
			}
			MapToolController instance = MapToolController.instance;
			if ((Object)(object)instance != (Object)null)
			{
				return GameFieldReader.LocalMapIsOpen(instance);
			}
			return false;
		}

		private static bool NothingToShow(LevelValuablesSnapshot valuables, BoxRaritySnapshot boxes)
		{
			if (!valuables.HasLooseItems)
			{
				return !boxes.HasAny;
			}
			return false;
		}

		private BoxRaritySnapshot ReadCosmeticBoxes()
		{
			if (ModSettings.ShowCosmeticBoxes.Value)
			{
				return _cosmeticCounter.Read();
			}
			_cosmeticCounter.Reset();
			return BoxRaritySnapshot.Empty;
		}

		private static string BuildValueText(LevelValuablesSnapshot valuables)
		{
			if (!valuables.HasLooseItems)
			{
				return string.Empty;
			}
			bool value = ModSettings.ShowTotalValue.Value;
			bool value2 = ModSettings.ShowItemCount.Value;
			if (value && value2)
			{
				return $"${valuables.LooseItemValue:N0}  x{valuables.LooseItemCount}";
			}
			if (value)
			{
				return $"${valuables.LooseItemValue:N0}";
			}
			if (!value2)
			{
				return string.Empty;
			}
			return $"x{valuables.LooseItemCount}";
		}
	}
}
namespace LevelValuesAndCosmeticsScanner.Hud
{
	public sealed class HudOverlay
	{
		private readonly struct RarityLine
		{
			public readonly GameObject Root;

			public readonly RectTransform Rect;

			public readonly TextMeshProUGUI Count;

			public RarityLine(GameObject root, RectTransform rect, TextMeshProUGUI count)
			{
				Root = root;
				Rect = rect;
				Count = count;
			}
		}

		private const float RowHeight = 24f;

		private const float ValueLineHeight = 28f;

		private const float ValueGap = 8f;

		private const float DefaultRightPadding = 10f;

		private const float DefaultBottomPadding = 8f;

		private static readonly Vector2 ValueTextSize = new Vector2(210f, 28f);

		private static readonly Vector2 RowSize = new Vector2(42f, 22f);

		private static HudOverlay _instance;

		private readonly Dictionary<Rarity, RarityLine> _rarityLines = new Dictionary<Rarity, RarityLine>();

		private GameObject _root;

		private RectTransform _rootRect;

		private TextMeshProUGUI _valueText;

		private TMP_Text _fontSource;

		private Vector2 _contentOffset;

		public static HudOverlay Instance => _instance ?? (_instance = new HudOverlay());

		public void Show(string valueText, BoxRaritySnapshot boxes, bool showBoxes, HudAnchor anchor)
		{
			if (EnsureCreated())
			{
				ApplyPosition(anchor);
				RefreshVanillaFont();
				UpdateBoxRows(boxes, showBoxes);
				UpdateValueText(valueText);
				_root.SetActive(true);
			}
		}

		public void Hide()
		{
			if ((Object)(object)_root != (Object)null)
			{
				_root.SetActive(false);
			}
		}

		private bool EnsureCreated()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			if ((Object)(object)_root != (Object)null)
			{
				return true;
			}
			GameObject val = GameObject.Find("Game Hud");
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			_root = new GameObject("LevelValuesAndCosmeticsScanner HUD");
			_root.transform.SetParent(val.transform, false);
			_root.SetActive(false);
			_rootRect = _root.AddComponent<RectTransform>();
			StretchToHud(_rootRect);
			CanvasGroup obj = _root.AddComponent<CanvasGroup>();
			obj.alpha = 0.95f;
			obj.blocksRaycasts = false;
			obj.interactable = false;
			_fontSource = ResolveFontSource();
			TMP_Text fontSource = _fontSource;
			TMP_FontAsset font = ((fontSource != null) ? fontSource.font : null) ?? TMP_Settings.defaultFontAsset;
			_valueText = CreateValueText(_root.transform, font, _fontSource);
			AddRarityLine((Rarity)0, font, _fontSource);
			AddRarityLine((Rarity)1, font, _fontSource);
			AddRarityLine((Rarity)2, font, _fontSource);
			AddRarityLine((Rarity)3, font, _fontSource);
			return true;
		}

		private void ApplyPosition(HudAnchor anchor)
		{
			//IL_000d: 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)
			StretchToHud(_rootRect);
			_contentOffset = OffsetFor(anchor);
		}

		private static Vector2 OffsetFor(HudAnchor anchor)
		{
			//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_000e: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			if (anchor == HudAnchor.Right)
			{
				return new Vector2(-10f, 125f);
			}
			return new Vector2(-10f, 8f);
		}

		private void UpdateValueText(string text)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			bool flag = text.Length > 0;
			((Component)_valueText).gameObject.SetActive(flag);
			if (flag)
			{
				((TMP_Text)_valueText).rectTransform.anchoredPosition = _contentOffset;
				((TMP_Text)_valueText).SetText(text, true);
			}
		}

		private void UpdateBoxRows(BoxRaritySnapshot boxes, bool showBoxes)
		{
			int visibleCount = VisibleRarityCount(boxes, showBoxes);
			int rowIndex = 0;
			rowIndex = PlaceRarityLine((Rarity)0, boxes.Common, showBoxes, visibleCount, rowIndex);
			rowIndex = PlaceRarityLine((Rarity)1, boxes.Uncommon, showBoxes, visibleCount, rowIndex);
			rowIndex = PlaceRarityLine((Rarity)2, boxes.Rare, showBoxes, visibleCount, rowIndex);
			PlaceRarityLine((Rarity)3, boxes.UltraRare, showBoxes, visibleCount, rowIndex);
		}

		private int PlaceRarityLine(Rarity rarity, int count, bool showBoxes, int visibleCount, int rowIndex)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			RarityLine rarityLine = _rarityLines[rarity];
			bool flag = showBoxes && count > 0;
			rarityLine.Root.SetActive(flag);
			if (!flag)
			{
				return rowIndex;
			}
			((TMP_Text)rarityLine.Count).SetText(count.ToString(), true);
			int num = visibleCount - rowIndex - 1;
			float num2 = 36f + (float)num * 24f + RowSize.y * 0.5f;
			rarityLine.Rect.anchoredPosition = new Vector2(_contentOffset.x, _contentOffset.y + num2);
			return rowIndex + 1;
		}

		private static int VisibleRarityCount(BoxRaritySnapshot boxes, bool showBoxes)
		{
			if (!showBoxes)
			{
				return 0;
			}
			int num = 0;
			if (boxes.Common > 0)
			{
				num++;
			}
			if (boxes.Uncommon > 0)
			{
				num++;
			}
			if (boxes.Rare > 0)
			{
				num++;
			}
			if (boxes.UltraRare > 0)
			{
				num++;
			}
			return num;
		}

		private void AddRarityLine(Rarity rarity, TMP_FontAsset font, TMP_Text fontSource)
		{
			//IL_0005: 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_0016: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_00ab: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: 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)
			GameObject val = new GameObject($"{rarity} Box Counter");
			val.transform.SetParent(_root.transform, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.anchorMin = new Vector2(1f, 0f);
			val2.anchorMax = new Vector2(1f, 0f);
			val2.pivot = new Vector2(1f, 0.5f);
			val2.sizeDelta = RowSize;
			GameObject val3 = new GameObject("Icon");
			val3.transform.SetParent(val.transform, false);
			RectTransform obj = val3.AddComponent<RectTransform>();
			obj.anchorMin = new Vector2(0f, 0.5f);
			obj.anchorMax = new Vector2(0f, 0.5f);
			obj.pivot = new Vector2(0f, 0.5f);
			obj.anchoredPosition = new Vector2(0f, 0f);
			obj.sizeDelta = new Vector2(20f, 20f);
			RawImage obj2 = val3.AddComponent<RawImage>();
			obj2.texture = (Texture)(object)RarityIconPainter.GetIconTexture(rarity);
			((Graphic)obj2).raycastTarget = false;
			GameObject val4 = new GameObject("Count");
			val4.transform.SetParent(val.transform, false);
			TextMeshProUGUI val5 = val4.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val5).font = font;
			ApplySharedFontMaterial(val5, fontSource);
			((TMP_Text)val5).fontSize = 15f;
			((Graphic)val5).color = new Color(0.82f, 0.96f, 0.93f, 0.95f);
			((TMP_Text)val5).alignment = (TextAlignmentOptions)516;
			((TMP_Text)val5).enableWordWrapping = false;
			((Graphic)val5).raycastTarget = false;
			RectTransform component = ((Component)val5).GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.offsetMin = new Vector2(24f, -2f);
			component.offsetMax = Vector2.zero;
			_rarityLines[rarity] = new RarityLine(val, val2, val5);
		}

		private static TextMeshProUGUI CreateValueText(Transform parent, TMP_FontAsset font, TMP_Text fontSource)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Loose Loot Summary");
			val.transform.SetParent(parent, false);
			TextMeshProUGUI obj = val.AddComponent<TextMeshProUGUI>();
			((TMP_Text)obj).font = font;
			ApplySharedFontMaterial(obj, fontSource);
			((TMP_Text)obj).fontSize = 20f;
			((Graphic)obj).color = new Color(0.82f, 0.96f, 0.93f, 1f);
			((TMP_Text)obj).alignment = (TextAlignmentOptions)516;
			((TMP_Text)obj).horizontalAlignment = (HorizontalAlignmentOptions)4;
			((TMP_Text)obj).verticalAlignment = (VerticalAlignmentOptions)512;
			((TMP_Text)obj).enableWordWrapping = false;
			((Graphic)obj).raycastTarget = false;
			RectTransform component = ((Component)obj).GetComponent<RectTransform>();
			component.anchorMin = new Vector2(1f, 0f);
			component.anchorMax = new Vector2(1f, 0f);
			component.pivot = new Vector2(1f, 0f);
			component.anchoredPosition = Vector2.zero;
			component.sizeDelta = ValueTextSize;
			return obj;
		}

		private static TMP_Text ResolveFontSource()
		{
			GameObject obj = GameObject.Find("Tax Haul");
			TMP_Text val = ((obj != null) ? obj.GetComponent<TMP_Text>() : null);
			if ((Object)(object)val != (Object)null && (Object)(object)val.font != (Object)null)
			{
				return val;
			}
			if ((Object)(object)HaulUI.instance != (Object)null)
			{
				val = ((Component)HaulUI.instance).GetComponent<TMP_Text>();
				if ((Object)(object)val != (Object)null && (Object)(object)val.font != (Object)null)
				{
					return val;
				}
			}
			return null;
		}

		private void RefreshVanillaFont()
		{
			if ((Object)(object)_fontSource != (Object)null && (Object)(object)_fontSource.font != (Object)null)
			{
				return;
			}
			_fontSource = ResolveFontSource();
			if ((Object)(object)_fontSource == (Object)null || (Object)(object)_fontSource.font == (Object)null)
			{
				return;
			}
			ApplyFont(_valueText, _fontSource);
			foreach (RarityLine value in _rarityLines.Values)
			{
				ApplyFont(value.Count, _fontSource);
			}
		}

		private static void ApplyFont(TextMeshProUGUI text, TMP_Text fontSource)
		{
			((TMP_Text)text).font = fontSource.font;
			ApplySharedFontMaterial(text, fontSource);
		}

		private static void ApplySharedFontMaterial(TextMeshProUGUI text, TMP_Text fontSource)
		{
			if ((Object)(object)((fontSource != null) ? fontSource.fontSharedMaterial : null) != (Object)null)
			{
				((TMP_Text)text).fontSharedMaterial = fontSource.fontSharedMaterial;
			}
		}

		private static void StretchToHud(RectTransform rect)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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_0037: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			rect.anchorMin = Vector2.zero;
			rect.anchorMax = Vector2.one;
			rect.pivot = new Vector2(0.5f, 0.5f);
			rect.anchoredPosition = Vector2.zero;
			rect.sizeDelta = Vector2.zero;
			rect.offsetMin = Vector2.zero;
			rect.offsetMax = Vector2.zero;
		}
	}
	public static class RarityIconPainter
	{
		private readonly struct IconPalette
		{
			public readonly Color Main;

			public readonly Color Inner;

			public readonly Color Glow;

			public IconPalette(Color main, Color inner, Color glow)
			{
				//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_0008: 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_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)
				Main = main;
				Inner = inner;
				Glow = glow;
			}
		}

		private const int TextureSize = 64;

		private static readonly Dictionary<Rarity, Texture2D> Textures = new Dictionary<Rarity, Texture2D>();

		public static Texture2D GetIconTexture(Rarity rarity)
		{
			//IL_0005: 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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			if (Textures.TryGetValue(rarity, out var value))
			{
				return value;
			}
			Texture2D val = DrawRarityIcon(GetPalette(rarity));
			((Object)val).name = $"LevelValuesAndCosmeticsScanner_{rarity}_Icon";
			((Texture)val).wrapMode = (TextureWrapMode)1;
			((Texture)val).filterMode = (FilterMode)1;
			Textures[rarity] = val;
			return val;
		}

		private static Texture2D DrawRarityIcon(IconPalette palette)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//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)
			//IL_00dd: 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_00ed: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: 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_0120: 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_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false);
			Color[] array = (Color[])(object)new Color[4096];
			for (int i = 0; i < 64; i++)
			{
				for (int j = 0; j < 64; j++)
				{
					float x = (float)j + 0.5f;
					float y = (float)i + 0.5f;
					float num = StrokeRoundedRect(x, y, 32f, 32f, 21f, 16f, 6.5f, 3.2f);
					float num2 = GlowRoundedRect(x, y, 32f, 32f, 21f, 16f, 6.5f, 12f);
					float num3 = StrokeRoundedRect(x, y, 32f, 32f, 10f, 8.5f, 1.5f, 3f);
					float num4 = GlowRoundedRect(x, y, 32f, 32f, 10f, 8.5f, 1.5f, 6f);
					Color clear = Color.clear;
					clear = Blend(clear, palette.Glow, num2 * 0.28f);
					clear = Blend(clear, palette.Glow, num4 * 0.16f);
					clear = Blend(clear, palette.Main, num * 0.96f);
					clear = Blend(clear, palette.Inner, num3 * 0.88f);
					array[i * 64 + j] = clear;
				}
			}
			val.SetPixels(array);
			val.Apply(false, true);
			return val;
		}

		private static IconPalette GetPalette(Rarity rarity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected I4, but got Unknown
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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_00b7: 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)
			//IL_00f4: 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_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: 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_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			return (int)rarity switch
			{
				0 => new IconPalette(new Color(0.34f, 1f, 0.22f, 1f), new Color(0.62f, 1f, 0.46f, 1f), new Color(0.12f, 1f, 0.08f, 1f)), 
				1 => new IconPalette(new Color(0.07f, 0.6f, 1f, 1f), new Color(0.26f, 0.82f, 1f, 1f), new Color(0f, 0.45f, 1f, 1f)), 
				2 => new IconPalette(new Color(0.72f, 0.16f, 1f, 1f), new Color(0.94f, 0.36f, 1f, 1f), new Color(0.6f, 0.06f, 1f, 1f)), 
				3 => new IconPalette(new Color(1f, 0.6f, 0.08f, 1f), new Color(1f, 0.82f, 0.22f, 1f), new Color(1f, 0.42f, 0f, 1f)), 
				_ => new IconPalette(Color.white, Color.white, Color.white), 
			};
		}

		private static float StrokeRoundedRect(float x, float y, float centerX, float centerY, float halfWidth, float halfHeight, float radius, float thickness)
		{
			float value = Mathf.Abs(RoundedRectDistance(x, y, centerX, centerY, halfWidth, halfHeight, radius));
			return Smooth01(thickness * 0.5f + 1.1f, thickness * 0.5f - 0.6f, value);
		}

		private static float GlowRoundedRect(float x, float y, float centerX, float centerY, float halfWidth, float halfHeight, float radius, float glowWidth)
		{
			float num = Mathf.Abs(RoundedRectDistance(x, y, centerX, centerY, halfWidth, halfHeight, radius));
			float num2 = 1f - Mathf.Clamp01(num / glowWidth);
			return num2 * num2;
		}

		private static float RoundedRectDistance(float x, float y, float centerX, float centerY, float halfWidth, float halfHeight, float radius)
		{
			float num = Mathf.Abs(x - centerX) - halfWidth + radius;
			float num2 = Mathf.Abs(y - centerY) - halfHeight + radius;
			float num3 = Mathf.Sqrt(Mathf.Max(num, 0f) * Mathf.Max(num, 0f) + Mathf.Max(num2, 0f) * Mathf.Max(num2, 0f));
			float num4 = Mathf.Min(Mathf.Max(num, num2), 0f);
			return num3 + num4 - radius;
		}

		private static float Smooth01(float edge0, float edge1, float value)
		{
			float num = Mathf.Clamp01((value - edge0) / (edge1 - edge0));
			return num * num * (3f - 2f * num);
		}

		private static Color Blend(Color under, Color over, float alpha)
		{
			//IL_0009: 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_002f: 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_0047: 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_0055: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			alpha = Mathf.Clamp01(alpha);
			float num = alpha + under.a * (1f - alpha);
			if (num <= 0f)
			{
				return Color.clear;
			}
			return new Color((over.r * alpha + under.r * under.a * (1f - alpha)) / num, (over.g * alpha + under.g * under.a * (1f - alpha)) / num, (over.b * alpha + under.b * under.a * (1f - alpha)) / num, num);
		}
	}
}
namespace LevelValuesAndCosmeticsScanner.GameInterop
{
	internal static class GameFieldReader
	{
		private static readonly BindingFlags InstanceField = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

		private static readonly FieldInfo ValuableCurrentValue = typeof(ValuableObject).GetField("dollarValueCurrent", InstanceField);

		private static readonly FieldInfo ValuableValueReady = typeof(ValuableObject).GetField("dollarValueSet", InstanceField);

		private static readonly FieldInfo RoundCompleted = typeof(RoundDirector).GetField("allExtractionPointsCompleted", InstanceField);

		private static readonly FieldInfo MapIsActive = typeof(MapToolController).GetField("Active", InstanceField);

		public static float CurrentValue(ValuableObject valuable)
		{
			return ReadField(ValuableCurrentValue, valuable, 0f);
		}

		public static bool ValueWasAssigned(ValuableObject valuable)
		{
			return ReadField(ValuableValueReady, valuable, defaultValue: true);
		}

		public static bool ExtractionIsFinished(RoundDirector roundDirector)
		{
			return ReadField(RoundCompleted, roundDirector, defaultValue: false);
		}

		public static bool LocalMapIsOpen(MapToolController mapTool)
		{
			return ReadField(MapIsActive, mapTool, defaultValue: false);
		}

		private static T ReadField<T>(FieldInfo field, object owner, T defaultValue)
		{
			if (field == null || owner == null)
			{
				return defaultValue;
			}
			object value = field.GetValue(owner);
			if (value is T)
			{
				return (T)value;
			}
			return defaultValue;
		}
	}
}