Decompiled source of TotalLootTracker v1.0.0

plugins/TotalLootTracker.dll

Decompiled 10 hours 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+68b39bf6208625f3a2adacd935ce0508d0c828bc")]
[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]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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]
	[Microsoft.CodeAnalysis.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]
	[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 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; }

		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).");
			((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
	{
		[CompilerGenerated]
		private sealed class <DelayedAddEnemyValuable>d__21 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public EnemyValuable enemyValuable;

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

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

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

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

			private bool MoveNext()
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(0.5f);
					<>1__state = 1;
					return true;
				case 1:
				{
					<>1__state = -1;
					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 + "."));
						return false;
					}
					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");
					return false;
				}
				}
			}

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

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

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

			private object <>2__current;

			public ExtractionPoint extractionPoint;

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

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

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

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

			private bool MoveNext()
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Expected O, but got Unknown
				//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_0052: Unknown result type (might be due to invalid IL or missing references)
				//IL_0054: Invalid comparison between Unknown and I4
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 1;
					return true;
				case 1:
				{
					<>1__state = -1;
					State value = Traverse.Create((object)extractionPoint).Field<State>("currentState").Value;
					if ((int)value != 6)
					{
						TotalLootTracker.Logger.LogDebug((object)"DelayedCaptureExtractionTotal(): State changed from Extracting, aborting.");
						return false;
					}
					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 -= _extractionDollarTotal;
					if (_extractionDollarTotal > 0f)
					{
						_extractionLabelCoroutine = ((MonoBehaviour)TotalLootTracker.Instance).StartCoroutine(ShowExtractionAmount(_extractionDollarTotal));
					}
					UpdateLabel(_totalLoot, "DelayedCaptureExtractionTotal");
					return false;
				}
				}
			}

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

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

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

			private object <>2__current;

			private float <fadeDuration>5__2;

			private float <elapsed>5__3;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0056: Unknown result type (might be due to invalid IL or missing references)
				//IL_005c: Expected O, but got Unknown
				//IL_00bd: 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_00e3: Expected O, but got Unknown
				//IL_0147: Unknown result type (might be due to invalid IL or missing references)
				//IL_0086: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
				{
					<>1__state = -1;
					if ((Object)(object)_damageLabel == (Object)null)
					{
						return false;
					}
					float value = TotalLootTracker.LabelHoldDuration.Value;
					<fadeDuration>5__2 = 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);
					<>2__current = (object)new WaitForSeconds(value);
					<>1__state = 1;
					return true;
				}
				case 1:
					<>1__state = -1;
					<elapsed>5__3 = 0f;
					break;
				case 2:
					<>1__state = -1;
					break;
				}
				if (<elapsed>5__3 < <fadeDuration>5__2)
				{
					<elapsed>5__3 += Time.deltaTime;
					((Graphic)_damageLabel.labelTMP).color = new Color(1f, 0f, 0f, Mathf.Lerp(1f, 0f, <elapsed>5__3 / <fadeDuration>5__2));
					<>2__current = null;
					<>1__state = 2;
					return true;
				}
				((Component)_damageLabel).gameObject.SetActive(false);
				_damageAccumulated = 0f;
				_damageLabelCoroutine = null;
				return false;
			}

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

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

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

			private object <>2__current;

			public float amount;

			private float <fadeDuration>5__2;

			private float <elapsed>5__3;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0056: Unknown result type (might be due to invalid IL or missing references)
				//IL_0135: Unknown result type (might be due to invalid IL or missing references)
				//IL_0073: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d1: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
				{
					<>1__state = -1;
					if ((Object)(object)_extractionAmountLabel == (Object)null)
					{
						return false;
					}
					float value = TotalLootTracker.LabelHoldDuration.Value;
					<fadeDuration>5__2 = 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);
					<>2__current = (object)new WaitForSeconds(value);
					<>1__state = 1;
					return true;
				}
				case 1:
					<>1__state = -1;
					<elapsed>5__3 = 0f;
					break;
				case 2:
					<>1__state = -1;
					break;
				}
				if (<elapsed>5__3 < <fadeDuration>5__2)
				{
					<elapsed>5__3 += Time.deltaTime;
					((Graphic)_extractionAmountLabel.labelTMP).color = new Color(0f, 1f, 0f, Mathf.Lerp(1f, 0f, <elapsed>5__3 / <fadeDuration>5__2));
					<>2__current = null;
					<>1__state = 2;
					return true;
				}
				((Component)_extractionAmountLabel).gameObject.SetActive(false);
				_extractionLabelCoroutine = null;
				return false;
			}

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

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

		private static 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 const int StartingX = 135;

		private const string TotalLootPrefix = "Loot Left: ";

		[HarmonyPostfix]
		[HarmonyPatch(typeof(ExtractionPoint), "ActivateTheFirstExtractionPointAutomaticallyWhenAPlayerLeaveTruck")]
		private static void PlayerLeaveTruck_Postfix(ExtractionPoint __instance)
		{
			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));
			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)
			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);
			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));
			}
		}

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

		[HarmonyPostfix]
		[HarmonyPatch(typeof(ExtractionPoint), "ExtractionPointSurplusRPC")]
		private static void ExtractionPointSurplusRPC_Postfix(int surplus, bool ___taxReturn)
		{
			if (surplus > 0 && ___taxReturn)
			{
				TotalLootTracker.Logger.LogInfo((object)$"ExtractionPointSurplusRPC_Postfix: surplus bag worth ${surplus} added to total");
				_totalLoot += surplus;
				UpdateLabel(_totalLoot, "ExtractionPointSurplusRPC_Postfix");
			}
		}

		[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));
			}
		}

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

		[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");
		}

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

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

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

		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);
		}
	}
}