Decompiled source of TotalLootTracker v1.1.0

plugins/TotalLootTracker.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using MenuLib;
using MenuLib.MonoBehaviors;
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: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("Korbah")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+eabe09a26cdfea627897f0de9651449a36afab11")]
[assembly: AssemblyProduct("TotalLootTracker")]
[assembly: AssemblyTitle("TotalLootTracker")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace TotalLootTracker
{
	[BepInPlugin("Korbah.TotalLootTracker", "TotalLootTracker", "1.0.0")]
	public class TotalLootTracker : BaseUnityPlugin
	{
		private const string ModGuid = "Korbah.TotalLootTracker";

		private const string ModName = "TotalLootTracker";

		private const string ModVersion = "1.0.0";

		internal static TotalLootTracker Instance { get; private set; }

		internal static ManualLogSource Logger => Instance._logger;

		private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;

		internal Harmony? Harmony { get; set; }

		internal static ConfigEntry<float> LabelHoldDuration { get; private set; }

		internal static ConfigEntry<float> LabelFadeDuration { get; private set; }

		internal static ConfigEntry<float> CosmeticBoxDisplayDuration { get; private set; }

		private void Awake()
		{
			Instance = this;
			LabelHoldDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Labels", "HoldDuration", 2f, "How long transient labels stay fully visible before fading (seconds).");
			LabelFadeDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Labels", "FadeDuration", 1f, "How long transient labels take to fade out (seconds).");
			CosmeticBoxDisplayDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Labels", "CosmeticBoxDisplayDuration", 4f, "How long the cosmetic box summary is shown at level start (seconds).");
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Patch();
			Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
		}

		internal void Patch()
		{
			//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)
			//IL_0020: Expected O, but got Unknown
			//IL_0025: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
				Harmony val2 = val;
				Harmony = val;
			}
			Harmony.PatchAll();
		}

		internal void Unpatch()
		{
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private void Update()
		{
		}
	}
}
namespace TotalLootTracker.Patches
{
	[HarmonyPatch(typeof(RoundDirector))]
	internal static class TotalLootPatch
	{
		private static float _totalLoot;

		private static float _extractionDollarTotal;

		private static bool _duringBreak;

		private static REPOLabel? _totalLootLabel;

		private static REPOLabel? _extractionAmountLabel;

		private static Coroutine? _extractionLabelCoroutine;

		private static REPOLabel? _damageLabel;

		private static float _damageAccumulated;

		private static Coroutine? _damageLabelCoroutine;

		private static float _damageAlignX;

		private static REPOLabel? _cosmeticBoxHeaderLabel;

		private static REPOLabel? _cosmeticBoxCommonLabel;

		private static REPOLabel? _cosmeticBoxUncommonLabel;

		private static REPOLabel? _cosmeticBoxRareLabel;

		private static REPOLabel? _cosmeticBoxUltraRareLabel;

		private static Coroutine? _cosmeticBoxCoroutine;

		private const int LootStartingX = 135;

		private const string TotalLootPrefix = "Loot Left: ";

		[HarmonyPostfix]
		[HarmonyPatch(typeof(ExtractionPoint), "ActivateTheFirstExtractionPointAutomaticallyWhenAPlayerLeaveTruck")]
		private static void PlayerLeaveTruck_Postfix(ExtractionPoint __instance)
		{
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Expected I4, but got Unknown
			TotalLootTracker.Logger.LogDebug((object)string.Format("{0}: {1}", "PlayerLeaveTruck_Postfix", __instance));
			_totalLoot = 0f;
			if (!LevelGenerator.Instance.Generated)
			{
				TotalLootTracker.Logger.LogWarning((object)"PlayerLeaveTruck_Postfix LevelGenerator instance not found.");
				return;
			}
			if ((Object)(object)_totalLootLabel == (Object)null)
			{
				TotalLootTracker.Logger.LogError((object)"PlayerLeaveTruck_Postfix _totalLootLabel is null.");
				return;
			}
			if (SemiFunc.RunIsShop())
			{
				((Component)_totalLootLabel).gameObject.SetActive(false);
				return;
			}
			((Component)_totalLootLabel).gameObject.SetActive(true);
			List<ValuableObject> valuableList = ValuableDirector.instance.valuableList;
			for (int i = 0; i < valuableList.Count; i++)
			{
				ValuableObject val = valuableList[i];
				if (val == null)
				{
					TotalLootTracker.Logger.LogWarning((object)string.Format("{0} Found null valuable at index {1}.", "PlayerLeaveTruck_Postfix", i));
				}
				else if (!float.IsFinite(val.dollarValueCurrent))
				{
					TotalLootTracker.Logger.LogWarning((object)string.Format("{0} Found valuable with non-finite dollar value at index {1}: {2}.", "PlayerLeaveTruck_Postfix", i, val));
				}
				else
				{
					_totalLoot += val.dollarValueCurrent;
				}
			}
			TotalLootTracker.Logger.LogInfo((object)string.Format("{0} Total loot for this round: ${1}", "PlayerLeaveTruck_Postfix", _totalLoot));
			List<CosmeticWorldObject> cosmeticWorldObjects = RoundDirector.instance.cosmeticWorldObjects;
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			int num4 = 0;
			foreach (CosmeticWorldObject item in cosmeticWorldObjects)
			{
				if (!((Object)(object)item == (Object)null))
				{
					Rarity rarity = item.rarity;
					switch ((int)rarity)
					{
					case 0:
						num++;
						break;
					case 1:
						num2++;
						break;
					case 2:
						num3++;
						break;
					case 3:
						num4++;
						break;
					}
				}
			}
			int num5 = num + num2 + num3 + num4;
			TotalLootTracker.Logger.LogInfo((object)string.Format("{0} Cosmetic boxes: {1} total ({2} Common, {3} Uncommon, {4} Rare, {5} Ultra-Rare)", "PlayerLeaveTruck_Postfix", num5, num, num2, num3, num4));
			if ((Object)(object)_cosmeticBoxHeaderLabel != (Object)null)
			{
				if (_cosmeticBoxCoroutine != null)
				{
					((MonoBehaviour)TotalLootTracker.Instance).StopCoroutine(_cosmeticBoxCoroutine);
				}
				_cosmeticBoxCoroutine = ((MonoBehaviour)TotalLootTracker.Instance).StartCoroutine(ShowCosmeticBoxSummary(num5, num, num2, num3, num4));
			}
			UpdateLabel(_totalLoot, "PlayerLeaveTruck_Postfix");
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(LoadingUI), "StopLoading")]
		private static void StopLoading_Postfix(LoadingUI __instance)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: 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_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: 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_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			TotalLootTracker.Logger.LogDebug((object)$"StopLoading_Postfix(): {__instance} Start Postfix");
			Transform transform = GameObject.Find("Game Hud").transform;
			_totalLootLabel = MenuAPI.CreateREPOLabel("Loot Left", transform, new Vector2(135f, -200f));
			float x = ((TMP_Text)_totalLootLabel.labelTMP).GetPreferredValues("Loot Left: ").x;
			float x2 = ((TMP_Text)_totalLootLabel.labelTMP).GetPreferredValues("-").x;
			_damageAlignX = 135f + x - x2 / 2f;
			TotalLootTracker.Logger.LogDebug((object)$"prefixWidth: {x}");
			TotalLootTracker.Logger.LogDebug((object)$"minusWidth: {x2}");
			((Component)_totalLootLabel).gameObject.SetActive(false);
			_extractionAmountLabel = MenuAPI.CreateREPOLabel("", transform, new Vector2(135f, -170f));
			((Component)_extractionAmountLabel).gameObject.SetActive(false);
			_damageLabel = MenuAPI.CreateREPOLabel("", transform, new Vector2(_damageAlignX, -170f));
			((Component)_damageLabel).gameObject.SetActive(false);
			_cosmeticBoxHeaderLabel = MenuAPI.CreateREPOLabel("", transform, Vector2.zero);
			SetCenterAnchor(_cosmeticBoxHeaderLabel);
			_cosmeticBoxCommonLabel = MenuAPI.CreateREPOLabel("", transform, Vector2.zero);
			SetCenterAnchor(_cosmeticBoxCommonLabel);
			_cosmeticBoxUncommonLabel = MenuAPI.CreateREPOLabel("", transform, Vector2.zero);
			SetCenterAnchor(_cosmeticBoxUncommonLabel);
			_cosmeticBoxRareLabel = MenuAPI.CreateREPOLabel("", transform, Vector2.zero);
			SetCenterAnchor(_cosmeticBoxRareLabel);
			_cosmeticBoxUltraRareLabel = MenuAPI.CreateREPOLabel("", transform, Vector2.zero);
			SetCenterAnchor(_cosmeticBoxUltraRareLabel);
			TotalLootTracker.Logger.LogDebug((object)$"Labels created, totalLootLabel: {_totalLootLabel}");
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(ExtractionPoint), "StateSetRPC")]
		private static void StateSetRPC_Postfix(ExtractionPoint __instance, State state)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Invalid comparison between Unknown and I4
			TotalLootTracker.Logger.LogDebug((object)$"StateSetRPC_Postfix(): New state: {state}");
			if ((int)state == 6)
			{
				_extractionDollarTotal = 0f;
				((MonoBehaviour)TotalLootTracker.Instance).StartCoroutine(DelayedCaptureExtractionTotal(__instance));
			}
		}

		private static IEnumerator DelayedCaptureExtractionTotal(ExtractionPoint extractionPoint)
		{
			yield return (object)new WaitForSeconds(1f);
			State value = Traverse.Create((object)extractionPoint).Field<State>("currentState").Value;
			if ((int)value != 6)
			{
				TotalLootTracker.Logger.LogDebug((object)"DelayedCaptureExtractionTotal(): State changed from Extracting, aborting.");
				yield break;
			}
			if (RoundDirector.instance.extractionPointsCompleted != RoundDirector.instance.extractionPoints - 1)
			{
				_extractionDollarTotal = RoundDirector.instance.currentHaul;
				TotalLootTracker.Logger.LogDebug((object)$"DelayedCaptureExtractionTotal(): Non-final extraction, currentHaul: ${_extractionDollarTotal}");
			}
			else
			{
				_extractionDollarTotal = 0f;
				foreach (GameObject dollarHaul in RoundDirector.instance.dollarHaulList)
				{
					if (!((Object)(object)dollarHaul == (Object)null))
					{
						ValuableObject component = dollarHaul.GetComponent<ValuableObject>();
						if ((Object)(object)component != (Object)null)
						{
							_extractionDollarTotal += component.dollarValueCurrent;
						}
					}
				}
				foreach (ItemValuableBox valuableBoxHaul in RoundDirector.instance.valuableBoxHaulList)
				{
					if ((Object)(object)valuableBoxHaul != (Object)null)
					{
						_extractionDollarTotal += valuableBoxHaul.ExtractionValue;
					}
				}
				TotalLootTracker.Logger.LogInfo((object)$"DelayedCaptureExtractionTotal(): Final extraction, total: ${_extractionDollarTotal}");
			}
			_totalLoot = RecountRemainingLoot();
			TotalLootTracker.Logger.LogInfo((object)$"DelayedCaptureExtractionTotal(): Recounted remaining loot: ${_totalLoot}");
			if (_extractionDollarTotal > 0f)
			{
				_extractionLabelCoroutine = ((MonoBehaviour)TotalLootTracker.Instance).StartCoroutine(ShowExtractionAmount(_extractionDollarTotal));
			}
			UpdateLabel(_totalLoot, "DelayedCaptureExtractionTotal");
		}

		private static float RecountRemainingLoot()
		{
			float num = 0f;
			HashSet<ValuableObject> hashSet = new HashSet<ValuableObject>();
			HashSet<ItemValuableBox> hashSet2 = new HashSet<ItemValuableBox>();
			RoundDirector instance = RoundDirector.instance;
			if ((Object)(object)instance != (Object)null)
			{
				foreach (GameObject dollarHaul in instance.dollarHaulList)
				{
					if (!((Object)(object)dollarHaul == (Object)null))
					{
						ValuableObject component = dollarHaul.GetComponent<ValuableObject>();
						if ((Object)(object)component != (Object)null)
						{
							hashSet.Add(component);
						}
					}
				}
				foreach (ItemValuableBox valuableBoxHaul in instance.valuableBoxHaulList)
				{
					if ((Object)(object)valuableBoxHaul != (Object)null)
					{
						hashSet2.Add(valuableBoxHaul);
					}
				}
			}
			List<ValuableObject> list = ValuableDirector.instance?.valuableList;
			if (list != null)
			{
				for (int i = 0; i < list.Count; i++)
				{
					ValuableObject val = list[i];
					if (!((Object)(object)val == (Object)null))
					{
						if (!float.IsFinite(val.dollarValueCurrent))
						{
							TotalLootTracker.Logger.LogWarning((object)string.Format("{0} Found valuable with non-finite dollar value at index {1}: {2}.", "RecountRemainingLoot", i, val));
						}
						else if (!hashSet.Contains(val))
						{
							num += val.dollarValueCurrent;
						}
					}
				}
			}
			else
			{
				TotalLootTracker.Logger.LogWarning((object)"RecountRemainingLoot valuableList is null.");
			}
			ItemValuableBox[] array = Object.FindObjectsOfType<ItemValuableBox>();
			foreach (ItemValuableBox val2 in array)
			{
				if (!((Object)(object)val2 == (Object)null) && !val2.InExtractionPoint && !hashSet2.Contains(val2) && float.IsFinite(val2.CurrentValue))
				{
					num += val2.CurrentValue;
				}
			}
			TotalLootTracker.Logger.LogInfo((object)string.Format("{0} Recounted remaining loot: ${1}", "RecountRemainingLoot", num));
			return num;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(ExtractionPoint), "ExtractionPointSurplusRPC")]
		private static void ExtractionPointSurplusRPC_Postfix(int surplus, bool ___taxReturn)
		{
			if (surplus > 0 && ___taxReturn)
			{
				((MonoBehaviour)TotalLootTracker.Instance).StartCoroutine(DelayedExtractionPointSurplus(surplus, ___taxReturn));
			}
		}

		private static IEnumerator DelayedExtractionPointSurplus(int surplus, bool ___taxReturn)
		{
			yield return (object)new WaitForSeconds(1f);
			_totalLoot = RecountRemainingLoot();
			_totalLoot += surplus;
			TotalLootTracker.Logger.LogInfo((object)$"ExtractionPointSurplusRPC_Postfix: surplus bag worth ${surplus} added to total");
			UpdateLabel(_totalLoot, "DelayedExtractionPointSurplus");
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "BreakRPC")]
		private static void BreakRPC_Prefix()
		{
			_duringBreak = true;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "BreakRPC")]
		private static void BreakRPC_Postfix(PhysGrabObjectImpactDetector __instance, float valueLost, bool _loseValue)
		{
			_duringBreak = false;
			if (Object.op_Implicit((Object)(object)__instance.valuableObject) && _loseValue)
			{
				if (__instance.valuableObject.dollarValueCurrent < __instance.valuableObject.dollarValueOriginal * 0.15f)
				{
					TotalLootTracker.Logger.LogInfo((object)$"BreakRPC_Postfix(): {((Object)__instance.valuableObject).name} Has been destroyed ${valueLost}");
				}
				else
				{
					TotalLootTracker.Logger.LogInfo((object)$"BreakRPC_Postfix(): {((Object)__instance.valuableObject).name} lost ${valueLost}");
				}
				_totalLoot -= valueLost;
				UpdateLabel(_totalLoot, "BreakRPC_Postfix");
				ShowOrUpdateDamageLabel(valueLost);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "DestroyObjectRPC")]
		private static void DestroyObjectRPC_Postfix(PhysGrabObjectImpactDetector __instance)
		{
			if (Object.op_Implicit((Object)(object)__instance.valuableObject) && !_duringBreak)
			{
				float dollarValueCurrent = __instance.valuableObject.dollarValueCurrent;
				TotalLootTracker.Logger.LogInfo((object)$"DestroyObjectRPC_Postfix(): {((Object)__instance.valuableObject).name} Has been destroyed ${dollarValueCurrent}");
				_totalLoot -= dollarValueCurrent;
				UpdateLabel(_totalLoot, "DestroyObjectRPC_Postfix");
				ShowOrUpdateDamageLabel(dollarValueCurrent);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(EnemyValuable), "Start")]
		private static void EnemyValuableStart_Postfix(EnemyValuable __instance)
		{
			TotalLootTracker.Logger.LogDebug((object)"EnemyValuableStart_Postfix(): Start Postfix");
			if (!LevelGenerator.Instance.Generated)
			{
				TotalLootTracker.Logger.LogWarning((object)"EnemyValuableStart_Postfix(): LevelGenerator has not finished generating the level");
			}
			else if ((Object)(object)_totalLootLabel == (Object)null)
			{
				TotalLootTracker.Logger.LogWarning((object)"EnemyValuableStart_Postfix(): _totalLootLabel is null");
			}
			else
			{
				((MonoBehaviour)TotalLootTracker.Instance).StartCoroutine(DelayedAddEnemyValuable(__instance));
			}
		}

		private static IEnumerator DelayedAddEnemyValuable(EnemyValuable enemyValuable)
		{
			yield return (object)new WaitForSeconds(0.5f);
			ValuableObject component = ((Component)enemyValuable).GetComponent<ValuableObject>();
			if ((Object)(object)component == (Object)null)
			{
				TotalLootTracker.Logger.LogWarning((object)("DelayedAddEnemyValuable(): Could not find ValuableObject on " + ((Object)enemyValuable).name + "."));
				yield break;
			}
			TotalLootTracker.Logger.LogDebug((object)("DelayedAddEnemyValuable(): EnemyValuable name: " + ((Object)enemyValuable).name));
			TotalLootTracker.Logger.LogDebug((object)$"DelayedAddEnemyValuable(): EnemyValuable dollarValueOriginal: {component.dollarValueOriginal}");
			_totalLoot += component.dollarValueOriginal;
			UpdateLabel(_totalLoot, "DelayedAddEnemyValuable");
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(ClownTrap), "TrapStop")]
		private static void ClownTrapStop_Postfix(ClownTrap __instance)
		{
			TotalLootTracker.Logger.LogDebug((object)$"ClownTrapStop_Postfix(): {__instance} Start Postfix");
			ValuableObject componentInParent = ((Component)__instance).GetComponentInParent<ValuableObject>();
			if ((Object)(object)componentInParent == (Object)null)
			{
				TotalLootTracker.Logger.LogWarning((object)"ClownTrapStop_Postfix(): Could not find ValuableObject on clown parent.");
				return;
			}
			float dollarValueCurrent = componentInParent.dollarValueCurrent;
			TotalLootTracker.Logger.LogInfo((object)$"ClownTrapStop_Postfix(): Clown Current Value: ${dollarValueCurrent}");
			_totalLoot -= dollarValueCurrent;
			UpdateLabel(_totalLoot, "ClownTrapStop_Postfix");
		}

		private static IEnumerator ShowExtractionAmount(float amount)
		{
			if (!((Object)(object)_extractionAmountLabel == (Object)null))
			{
				float value = TotalLootTracker.LabelHoldDuration.Value;
				float fadeDuration = TotalLootTracker.LabelFadeDuration.Value;
				((RectTransform)((Component)_extractionAmountLabel).transform).anchoredPosition = new Vector2(135f, DamageLabelActive() ? (-140f) : (-170f));
				((TMP_Text)_extractionAmountLabel.labelTMP).text = $"Extracted: ${amount:N0}";
				((Graphic)_extractionAmountLabel.labelTMP).color = Color.green;
				((Component)_extractionAmountLabel).gameObject.SetActive(true);
				yield return (object)new WaitForSeconds(value);
				float elapsed = 0f;
				while (elapsed < fadeDuration)
				{
					elapsed += Time.deltaTime;
					((Graphic)_extractionAmountLabel.labelTMP).color = new Color(0f, 1f, 0f, Mathf.Lerp(1f, 0f, elapsed / fadeDuration));
					yield return null;
				}
				((Component)_extractionAmountLabel).gameObject.SetActive(false);
				_extractionLabelCoroutine = null;
			}
		}

		private static void ShowOrUpdateDamageLabel(float amount)
		{
			_damageAccumulated += amount;
			if (_damageLabelCoroutine != null)
			{
				((MonoBehaviour)TotalLootTracker.Instance).StopCoroutine(_damageLabelCoroutine);
			}
			_damageLabelCoroutine = ((MonoBehaviour)TotalLootTracker.Instance).StartCoroutine(ShowDamageAmount());
		}

		private static IEnumerator ShowDamageAmount()
		{
			if (!((Object)(object)_damageLabel == (Object)null))
			{
				float value = TotalLootTracker.LabelHoldDuration.Value;
				float fadeDuration = TotalLootTracker.LabelFadeDuration.Value;
				RectTransform val = (RectTransform)((Component)_damageLabel).transform;
				if (!((Component)_damageLabel).gameObject.activeSelf)
				{
					val.anchoredPosition = new Vector2(_damageAlignX, ExtractionLabelActive() ? (-140f) : (-170f));
				}
				((TMP_Text)_damageLabel.labelTMP).text = $"-${_damageAccumulated:N0}";
				((Graphic)_damageLabel.labelTMP).color = Color.red;
				((Component)_damageLabel).gameObject.SetActive(true);
				yield return (object)new WaitForSeconds(value);
				float elapsed = 0f;
				while (elapsed < fadeDuration)
				{
					elapsed += Time.deltaTime;
					((Graphic)_damageLabel.labelTMP).color = new Color(1f, 0f, 0f, Mathf.Lerp(1f, 0f, elapsed / fadeDuration));
					yield return null;
				}
				((Component)_damageLabel).gameObject.SetActive(false);
				_damageAccumulated = 0f;
				_damageLabelCoroutine = null;
			}
		}

		private static void SetCenterAnchor(REPOLabel label)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0017: 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_0041: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: 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_00b7: 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_00d7: 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)
			RectTransform val = (RectTransform)((Component)label).transform;
			val.anchorMin = new Vector2(0.5f, 0.5f);
			val.anchorMax = new Vector2(0.5f, 0.5f);
			val.pivot = new Vector2(0.5f, 0.5f);
			val.anchoredPosition = Vector2.zero;
			val.sizeDelta = new Vector2(1400f, 80f);
			((Transform)val).localScale = Vector3.one;
			RectTransform rectTransform = ((TMP_Text)label.labelTMP).rectTransform;
			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.anchoredPosition = Vector2.zero;
			rectTransform.sizeDelta = new Vector2(1400f, 80f);
			((Transform)rectTransform).localScale = Vector3.one;
			((TMP_Text)label.labelTMP).alignment = (TextAlignmentOptions)514;
			((TMP_Text)label.labelTMP).enableWordWrapping = false;
			((TMP_Text)label.labelTMP).overflowMode = (TextOverflowModes)0;
			((Component)label).gameObject.SetActive(false);
		}

		private static string FormatBox(int count, string rarityName)
		{
			return string.Format("{0} {1} {2}", count, rarityName, (count == 1) ? "Box" : "Boxes");
		}

		private static IEnumerator ShowCosmeticBoxSummary(int total, int common, int uncommon, int rare, int ultraRare)
		{
			if ((Object)(object)_cosmeticBoxHeaderLabel == (Object)null)
			{
				yield break;
			}
			Color item = default(Color);
			((Color)(ref item))..ctor(0.4f, 0.9f, 0.4f);
			Color item2 = default(Color);
			((Color)(ref item2))..ctor(0.3f, 0.5f, 1f);
			Color item3 = default(Color);
			((Color)(ref item3))..ctor(0.8f, 0.3f, 1f);
			Color item4 = default(Color);
			((Color)(ref item4))..ctor(1f, 0.85f, 0.1f);
			List<(REPOLabel label, Color color)> activeLines = new List<(REPOLabel, Color)>();
			if (common > 0 && (Object)(object)_cosmeticBoxCommonLabel != (Object)null)
			{
				((TMP_Text)_cosmeticBoxCommonLabel.labelTMP).text = FormatBox(common, "Common");
				activeLines.Add((_cosmeticBoxCommonLabel, item));
			}
			if (uncommon > 0 && (Object)(object)_cosmeticBoxUncommonLabel != (Object)null)
			{
				((TMP_Text)_cosmeticBoxUncommonLabel.labelTMP).text = FormatBox(uncommon, "Uncommon");
				activeLines.Add((_cosmeticBoxUncommonLabel, item2));
			}
			if (rare > 0 && (Object)(object)_cosmeticBoxRareLabel != (Object)null)
			{
				((TMP_Text)_cosmeticBoxRareLabel.labelTMP).text = FormatBox(rare, "Rare");
				activeLines.Add((_cosmeticBoxRareLabel, item3));
			}
			if (ultraRare > 0 && (Object)(object)_cosmeticBoxUltraRareLabel != (Object)null)
			{
				((TMP_Text)_cosmeticBoxUltraRareLabel.labelTMP).text = FormatBox(ultraRare, "Ultra-Rare");
				activeLines.Add((_cosmeticBoxUltraRareLabel, item4));
			}
			float num = (float)activeLines.Count * 28f / 2f;
			RectTransform val = (RectTransform)((Component)_cosmeticBoxHeaderLabel).transform;
			val.anchoredPosition = new Vector2(0f, num);
			((TMP_Text)_cosmeticBoxHeaderLabel.labelTMP).text = string.Format("Level contains {0} cosmetic {1}", total, (total == 1) ? "box" : "boxes");
			((Graphic)_cosmeticBoxHeaderLabel.labelTMP).color = Color.white;
			((Component)_cosmeticBoxHeaderLabel).gameObject.SetActive(true);
			float num2 = num - 28f;
			foreach (var (val2, color) in activeLines)
			{
				((RectTransform)((Component)val2).transform).anchoredPosition = new Vector2(0f, num2);
				((Graphic)val2.labelTMP).color = color;
				((Component)val2).gameObject.SetActive(true);
				num2 -= 28f;
			}
			yield return (object)new WaitForSeconds(TotalLootTracker.CosmeticBoxDisplayDuration.Value);
			float fadeDuration = TotalLootTracker.LabelFadeDuration.Value;
			float elapsed = 0f;
			while (elapsed < fadeDuration)
			{
				elapsed += Time.deltaTime;
				float num3 = Mathf.Lerp(1f, 0f, elapsed / fadeDuration);
				((Graphic)_cosmeticBoxHeaderLabel.labelTMP).color = new Color(1f, 1f, 1f, num3);
				foreach (var (val3, val4) in activeLines)
				{
					((Graphic)val3.labelTMP).color = new Color(val4.r, val4.g, val4.b, num3);
				}
				yield return null;
			}
			((Component)_cosmeticBoxHeaderLabel).gameObject.SetActive(false);
			foreach (var item6 in activeLines)
			{
				REPOLabel item5 = item6.label;
				((Component)item5).gameObject.SetActive(false);
			}
			_cosmeticBoxCoroutine = null;
		}

		private static bool ExtractionLabelActive()
		{
			if ((Object)(object)_extractionAmountLabel != (Object)null)
			{
				return ((Component)_extractionAmountLabel).gameObject.activeSelf;
			}
			return false;
		}

		private static bool DamageLabelActive()
		{
			if ((Object)(object)_damageLabel != (Object)null)
			{
				return ((Component)_damageLabel).gameObject.activeSelf;
			}
			return false;
		}

		private static void UpdateLabel(float totalLoot, [CallerMemberName] string callerName = "")
		{
			TotalLootTracker.Logger.LogDebug((object)(callerName + "(): running UpdateLabel()"));
			if ((Object)(object)_totalLootLabel == (Object)null)
			{
				TotalLootTracker.Logger.LogError((object)"UpdateLabel(): _totalLootLabel is null");
				return;
			}
			TotalLootTracker.Logger.LogDebug((object)$"Total loot: {totalLoot}");
			((TMP_Text)_totalLootLabel.labelTMP).text = string.Format("{0}${1:N0}", "Loot Left: ", totalLoot);
		}
	}
}