Decompiled source of SpawnTracker v0.5.6

SpawnTracker.dll

Decompiled 3 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Assets.Scripts.Inventory__Items__Pickups.Items;
using Assets.Scripts.Saves___Serialization.Progression.Stats;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("MEGABONK_SIMPLE_MOD")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Template Mod")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+5360c382e35981c829048db9ab7a511214c62ba5")]
[assembly: AssemblyProduct("MEGABONK_SIMPLE_MOD")]
[assembly: AssemblyTitle("MEGABONK_SIMPLE_MOD")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.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 MEGABONK_SIMPLE_MOD
{
	[BepInPlugin("Antiparty_SpawnLogger", "SpawnLogger", "0.5.4")]
	public class Plugin : BasePlugin
	{
		public const string MODNAME = "SpawnLogger";

		public const string AUTHOR = "Antiparty";

		public const string GUID = "Antiparty_SpawnLogger";

		public const string VERSION = "0.5.4";

		public static ManualLogSource log;

		public static bool disableTracker;

		public Plugin()
		{
			log = ((BasePlugin)this).Log;
		}

		public override void Load()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Expected O, but got Unknown
			ManualLogSource val = log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(14, 3, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Loading ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("SpawnLogger");
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" v");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("0.5.4");
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" by ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("Antiparty");
			}
			val.LogInfo(val2);
			Harmony val3 = new Harmony("Antiparty_SpawnLogger");
			val3.PatchAll();
			ManualLogSource val4 = log;
			val2 = new BepInExInfoLogInterpolatedStringHandler(21, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("SpawnLogger");
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" loaded successfully!");
			}
			val4.LogInfo(val2);
		}
	}
	public static class OverlayManager
	{
		public static GameObject overlayObject;

		public static void CreateOverlay()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			if ((Object)(object)overlayObject != (Object)null)
			{
				overlayObject.SetActive(true);
				return;
			}
			ClassInjector.RegisterTypeInIl2Cpp<ChestOverlay>();
			overlayObject = new GameObject("ChestOverlay");
			Object.DontDestroyOnLoad((Object)(object)overlayObject);
			overlayObject.AddComponent<ChestOverlay>();
			Plugin.log.LogInfo((object)"[OverlayManager] Created overlay GUI");
		}

		public static void HideOverlay()
		{
			if ((Object)(object)overlayObject != (Object)null)
			{
				overlayObject.SetActive(false);
				Plugin.log.LogInfo((object)"[OverlayManager] Overlay hidden.");
			}
		}

		public static void DestroyOverlay()
		{
			if ((Object)(object)overlayObject != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)overlayObject);
				overlayObject = null;
			}
		}

		public static void SafeCleanup()
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			try
			{
				HideOverlay();
				ChestTracker.Reset();
				ShadyGuyTracker.Reset();
				ChargeShrineTracker.Reset();
				Plugin.disableTracker = true;
				ChargeShrineTracker.IsRoundActive = false;
				GameManagerPatches.roundStarted = false;
				Plugin.log.LogInfo((object)"[OverlayManager] All trackers reset and overlay hidden.");
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(37, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[OverlayManager] SafeCleanup failed: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				log.LogError(val);
			}
		}
	}
	public static class ChestTracker
	{
		public static int totalChests;

		public static int unopenedChests;

		public static void Reset()
		{
			totalChests = 0;
			unopenedChests = 0;
		}
	}
	public static class ShadyGuyTracker
	{
		public static int total;

		public static int interacted;

		public static int disappeared;

		public static void Reset()
		{
			total = 0;
			interacted = 0;
			disappeared = 0;
		}
	}
	public static class ChargeShrineTracker
	{
		public static int ActiveShrineCount;

		public static bool IsRoundActive;

		public static int interacted;

		public static int total;

		public static void Reset()
		{
			ActiveShrineCount = 0;
			interacted = 0;
		}
	}
	public class ChestOverlay : MonoBehaviour
	{
		private GUIStyle textStyle;

		private GUIStyle boxStyle;

		private Rect boxRect;

		private Texture2D bgTex;

		private bool stylesReady = false;

		private void OnGUI()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			if (!stylesReady)
			{
				SetupStyles();
				stylesReady = true;
			}
			GUI.BeginGroup(boxRect, GUIContent.none, boxStyle);
			try
			{
				DrawShadowedLabel(new Rect(10f, 8f, 230f, 25f), $"Chests: {ChestTracker.unopenedChests}/{ChestTracker.totalChests}");
				DrawShadowedLabel(new Rect(10f, 32f, 230f, 25f), $"ShadyGuys: {ShadyGuyTracker.disappeared}/{ShadyGuyTracker.total}");
				DrawShadowedLabel(new Rect(10f, 56f, 230f, 25f), $"Shrines: {ChargeShrineTracker.ActiveShrineCount}/{ChargeShrineTracker.total}");
				if (ChestTracker.totalChests == 0 && ShadyGuyTracker.total == 0 && ChargeShrineTracker.ActiveShrineCount == 0)
				{
					DrawShadowedLabel(new Rect(10f, 80f, 230f, 25f), "Waiting for spawns...");
				}
			}
			finally
			{
				GUI.EndGroup();
			}
		}

		private void SetupStyles()
		{
			//IL_000c: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_003a: 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_0052: Expected O, but got Unknown
			//IL_006e: 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_009a: Expected O, but got Unknown
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Expected O, but got Unknown
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			textStyle = new GUIStyle(GUI.skin.label)
			{
				fontSize = 20,
				fontStyle = (FontStyle)1,
				alignment = (TextAnchor)0
			};
			textStyle.normal.textColor = Color.white;
			bgTex = new Texture2D(1, 1);
			bgTex.SetPixel(0, 0, new Color(0f, 0f, 0f, 0.5f));
			bgTex.Apply();
			boxStyle = new GUIStyle(GUI.skin.box);
			boxStyle.normal.background = bgTex;
			boxStyle.border = new RectOffset();
			boxStyle.border.left = 6;
			boxStyle.border.right = 6;
			boxStyle.border.top = 6;
			boxStyle.border.bottom = 6;
			boxRect = new Rect(10f, (float)Screen.height * 0.8f, 250f, 130f);
		}

		private void DrawShadowedLabel(Rect position, string text)
		{
			//IL_001e: 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_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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)
			if (textStyle != null)
			{
				Color textColor = textStyle.normal.textColor;
				textStyle.normal.textColor = Color.black;
				GUI.Label(new Rect(((Rect)(ref position)).x + 2f, ((Rect)(ref position)).y + 2f, ((Rect)(ref position)).width, ((Rect)(ref position)).height), text, textStyle);
				textStyle.normal.textColor = textColor;
				GUI.Label(position, text, textStyle);
			}
		}

		private void OnDisable()
		{
			OverlayManager.SafeCleanup();
		}

		private void OnDestroy()
		{
			OverlayManager.SafeCleanup();
		}
	}
	[HarmonyPatch(typeof(SpawnInteractables))]
	[HarmonyPatch(typeof(SpawnInteractables))]
	public static class SpawnInteractablesPatches
	{
		private static bool overlaySpawned;

		[HarmonyPostfix]
		[HarmonyPatch("SpawnChests")]
		public static void Postfix_SpawnChests()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			if (!Plugin.disableTracker || ChargeShrineTracker.IsRoundActive)
			{
				int numChestsPerStage = SpawnInteractables.numChestsPerStage;
				ChestTracker.totalChests += numChestsPerStage;
				ChestTracker.unopenedChests += numChestsPerStage;
				ManualLogSource log = Plugin.log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(30, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SpawnLogger] Chests spawned: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(numChestsPerStage);
				}
				log.LogInfo(val);
				if (!overlaySpawned || (Object)(object)Object.FindObjectOfType<ChestOverlay>() == (Object)null)
				{
					overlaySpawned = true;
					ClassInjector.RegisterTypeInIl2Cpp<ChestOverlay>();
					GameObject val2 = new GameObject("ChestOverlay");
					Object.DontDestroyOnLoad((Object)(object)val2);
					val2.AddComponent<ChestOverlay>();
					Plugin.log.LogInfo((object)"[SpawnLogger] Chest overlay GUI spawned.");
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("SpawnShrines")]
		public static void Postfix_SpawnShrines()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			if (!Plugin.disableTracker || ChargeShrineTracker.IsRoundActive)
			{
				int numShrines = SpawnInteractables.numShrines;
				ManualLogSource log = Plugin.log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(31, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SpawnLogger] Shrines spawned: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(numShrines);
				}
				log.LogInfo(val);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("SpawnShit")]
		public static void Postfix_SpawnShit()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			if (!Plugin.disableTracker || ChargeShrineTracker.IsRoundActive)
			{
				int numChestsPerStage = SpawnInteractables.numChestsPerStage;
				int numShrines = SpawnInteractables.numShrines;
				ManualLogSource log = Plugin.log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(43, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SpawnLogger] Totals -> Chests: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(numChestsPerStage);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", Shrines: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(numShrines);
				}
				log.LogInfo(val);
			}
		}
	}
	[HarmonyPatch(typeof(TrackStats))]
	public static class TrackStatsPatches
	{
		[HarmonyPostfix]
		[HarmonyPatch("OnChestOpened")]
		public static void Postfix_OnChestOpened()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			if (!Plugin.disableTracker || ChargeShrineTracker.IsRoundActive)
			{
				ChestTracker.unopenedChests = Mathf.Max(0, ChestTracker.unopenedChests - 1);
				ManualLogSource log = Plugin.log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(49, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ChestTracker] Chest opened! Remaining unopened: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(ChestTracker.unopenedChests);
				}
				log.LogInfo(val);
			}
		}
	}
	[HarmonyPatch(typeof(InteractableShadyGuy))]
	public static class ShadyGuyPatches
	{
		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		public static void Postfix_Start(InteractableShadyGuy __instance)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			if (!Plugin.disableTracker || ChargeShrineTracker.IsRoundActive)
			{
				ShadyGuyTracker.total++;
				ManualLogSource log = Plugin.log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(41, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ShadyGuy] Spawned new ShadyGuy (Total: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(ShadyGuyTracker.total);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")");
				}
				log.LogInfo(val);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("Interact")]
		public static void Postfix_Interact(InteractableShadyGuy __instance, ref bool __result)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			if ((!Plugin.disableTracker || ChargeShrineTracker.IsRoundActive) && __result)
			{
				ShadyGuyTracker.interacted++;
				ManualLogSource log = Plugin.log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(40, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ShadyGuy] Interacted with ShadyGuy! (");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(ShadyGuyTracker.interacted);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("/");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(ShadyGuyTracker.total);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")");
				}
				log.LogInfo(val);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("Disappear")]
		public static void Postfix_Disappear(InteractableShadyGuy __instance)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			if (!Plugin.disableTracker || ChargeShrineTracker.IsRoundActive)
			{
				ManualLogSource log = Plugin.log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(44, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ShadyGuy] A ShadyGuy disappeared (Rarity: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<EItemRarity>(__instance.rarity);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")");
				}
				log.LogInfo(val);
				ShadyGuyTracker.disappeared++;
			}
		}
	}
	[HarmonyPatch]
	public static class ChargeShrineStartPatch
	{
		private static MethodBase TargetMethod()
		{
			Type type = AccessTools.TypeByName("ChargeShrine");
			return AccessTools.Method(type, "Start", (Type[])null, (Type[])null);
		}

		private static void Postfix()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			if (!Plugin.disableTracker || ChargeShrineTracker.IsRoundActive)
			{
				ChargeShrineTracker.ActiveShrineCount++;
				ChargeShrineTracker.total++;
				ManualLogSource log = Plugin.log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(60, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ShrineTracker] A Charge Shrine was counted! Total Shrines: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(ChargeShrineTracker.ActiveShrineCount);
				}
				log.LogInfo(val);
			}
		}
	}
	[HarmonyPatch]
	public static class ChargeShrineCompletePatch
	{
		private static MethodBase TargetMethod()
		{
			Type type = AccessTools.TypeByName("ChargeShrine");
			return AccessTools.Method(type, "Complete", (Type[])null, (Type[])null);
		}

		private static void Postfix()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			if (!Plugin.disableTracker || ChargeShrineTracker.IsRoundActive)
			{
				ChargeShrineTracker.ActiveShrineCount = Mathf.Max(0, ChargeShrineTracker.ActiveShrineCount - 1);
				ManualLogSource log = Plugin.log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(58, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ShrineTracker] A Charge Shrine was completed! Remaining: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(ChargeShrineTracker.ActiveShrineCount);
				}
				log.LogInfo(val);
			}
		}
	}
	[HarmonyPatch(typeof(GameManager))]
	public static class GameManagerPatches
	{
		public static bool roundStarted;

		[HarmonyPostfix]
		[HarmonyPatch("StartPlaying")]
		public static void Postfix_StartPlaying()
		{
			if (!roundStarted)
			{
				ResetAllTrackers();
				Plugin.disableTracker = false;
				ChargeShrineTracker.IsRoundActive = true;
				roundStarted = true;
				Plugin.log.LogInfo((object)"[SpawnLogger] Round started via StartPlaying: Tracking enabled.");
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("TryInit")]
		public static void Postfix_TryInit()
		{
			if (!roundStarted)
			{
				ResetAllTrackers();
				Plugin.disableTracker = false;
				ChargeShrineTracker.IsRoundActive = true;
				roundStarted = true;
				Plugin.log.LogInfo((object)"[SpawnLogger] Round started via TryInit: Tracking enabled.");
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("CreateInstances")]
		public static void Postfix_CreateInstances()
		{
			if (!roundStarted)
			{
				ResetAllTrackers();
				Plugin.disableTracker = false;
				ChargeShrineTracker.IsRoundActive = true;
				roundStarted = true;
				Plugin.log.LogInfo((object)"[SpawnLogger] Round started via CreateInstances: Tracking enabled.");
			}
		}

		private static void ResetAllTrackers()
		{
			ChestTracker.Reset();
			ShadyGuyTracker.Reset();
			ChargeShrineTracker.Reset();
		}
	}
	[HarmonyPatch(typeof(GameManager), "OnDied")]
	public static class Patch_GameManager_OnDied
	{
		private static void Postfix()
		{
			Plugin.disableTracker = true;
			ChargeShrineTracker.IsRoundActive = false;
			ChestTracker.Reset();
			ShadyGuyTracker.Reset();
			ChargeShrineTracker.Reset();
			GameManagerPatches.roundStarted = false;
			Plugin.log.LogInfo((object)"[SpawnLogger] Player died: Tracking paused and counters reset.");
		}
	}
	[HarmonyPatch(typeof(GameManager), "OnDestroy")]
	public static class Patch_GameManager_OnDestroy
	{
		private static void Postfix()
		{
			Plugin.log.LogInfo((object)"[SpawnLogger] GameManager destroyed — hiding overlay and resetting trackers.");
			OverlayManager.SafeCleanup();
		}
	}
	[HarmonyPatch]
	public static class SpawnPlayerPortal_StartPortal
	{
		private static MethodBase TargetMethod()
		{
			Type type = AccessTools.TypeByName("SpawnPlayerPortal");
			return AccessTools.Method(type, "StartPortal", (Type[])null, (Type[])null);
		}

		private static void Postfix()
		{
			ChargeShrineTracker.IsRoundActive = true;
			Plugin.disableTracker = false;
			GameManagerPatches.roundStarted = true;
			Plugin.log.LogInfo((object)"[SpawnLogger] Stage Start/Next Stage/Restart Stage: Shrines reset, tracking enabled.");
		}
	}
}