Decompiled source of FlashTime v1.0.2

plugins/FlashTime.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.IO;
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 Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("BellaModsGames")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("FlashTime")]
[assembly: AssemblyTitle("FlashTime")]
[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 FlashTime
{
	[BepInPlugin("com.BellaModsGames.flashtime", "Flash Time", "1.0.7")]
	public class FlashSpeedMod : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(PlayerController))]
		private static class PlayerControllerPatches
		{
			[HarmonyPatch("Update")]
			[HarmonyPrefix]
			private static void Update_Prefix(PlayerController __instance)
			{
				//IL_0092: 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_0157: Unknown result type (might be due to invalid IL or missing references)
				//IL_02af: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
				//IL_030f: Unknown result type (might be due to invalid IL or missing references)
				//IL_039b: Unknown result type (might be due to invalid IL or missing references)
				//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
				if (!originalValuesCaptured && (Object)(object)__instance != (Object)null)
				{
					CaptureOriginalPlayerValues(__instance);
				}
				if (!originalValuesCaptured)
				{
					return;
				}
				if (toggleKey == null || speedBoostKey == null || enableSlowMotion == null || slowMotionKey == null || slowMotionTimeScale == null)
				{
					if (Time.frameCount % 300 == 0)
					{
						ManualLogSource? staticLogger = StaticLogger;
						if (staticLogger != null)
						{
							staticLogger.LogWarning((object)"Config value(s) missing in Update_Prefix");
						}
					}
					return;
				}
				bool flag = false;
				if (Input.GetKey(toggleKey.Value))
				{
					if (!wasToggleKeyPressed)
					{
						isFlashSystemEnabled = !isFlashSystemEnabled;
						ManualLogSource? staticLogger2 = StaticLogger;
						if (staticLogger2 != null)
						{
							staticLogger2.LogInfo((object)("Flash Time system " + (isFlashSystemEnabled ? "enabled" : "disabled")));
						}
						wasToggleKeyPressed = true;
						flag = true;
						if (!isFlashSystemEnabled)
						{
							RestoreOriginalPlayerState(__instance, forceRestore: true);
						}
					}
				}
				else
				{
					wasToggleKeyPressed = false;
				}
				IsFlashActive = isFlashSystemEnabled && Input.GetKey(speedBoostKey.Value);
				if (isFlashSystemEnabled && enableSlowMotion.Value && IsFlashActive && Input.GetKey(slowMotionKey.Value))
				{
					if (!isSlowMotionActive)
					{
						Time.timeScale = slowMotionTimeScale.Value;
						isSlowMotionActive = true;
						timeScaleIsModified = true;
						ManualLogSource? staticLogger3 = StaticLogger;
						if (staticLogger3 != null)
						{
							staticLogger3.LogDebug((object)"Slow motion activated.");
						}
					}
				}
				else if (isSlowMotionActive)
				{
					Time.timeScale = originalTimeScale;
					isSlowMotionActive = false;
					timeScaleIsModified = false;
					ManualLogSource? staticLogger4 = StaticLogger;
					if (staticLogger4 != null)
					{
						staticLogger4.LogDebug((object)"Slow motion deactivated.");
					}
				}
				if (timeScaleIsModified && (!isFlashSystemEnabled || !IsFlashActive))
				{
					if (Time.timeScale != originalTimeScale)
					{
						ManualLogSource? staticLogger5 = StaticLogger;
						if (staticLogger5 != null)
						{
							staticLogger5.LogWarning((object)"Resetting potentially stuck timescale.");
						}
					}
					Time.timeScale = originalTimeScale;
					timeScaleIsModified = false;
					isSlowMotionActive = false;
				}
				if (!flag)
				{
					return;
				}
				if (isFlashSystemEnabled)
				{
					if ((Object)(object)effectPrefab != (Object)null && (Object)(object)__instance != (Object)null)
					{
						if ((Object)(object)effectInstance == (Object)null)
						{
							effectInstance = Object.Instantiate<GameObject>(effectPrefab, ((Component)__instance).transform.position, ((Component)__instance).transform.rotation);
							((Object)effectInstance).name = "FlashTime_EffectInstance";
							effectInstance.transform.SetParent(((Component)__instance).transform, false);
							effectInstance.transform.localPosition = Vector3.zero;
							effectInstance.transform.localRotation = Quaternion.identity;
							effectInstance.SetActive(true);
							ManualLogSource? staticLogger6 = StaticLogger;
							if (staticLogger6 != null)
							{
								staticLogger6.LogInfo((object)"Instantiated and activated Flash effects.");
							}
						}
						else if (!effectInstance.activeSelf)
						{
							if ((Object)(object)effectInstance.transform.parent != (Object)(object)((Component)__instance).transform)
							{
								effectInstance.transform.SetParent(((Component)__instance).transform, false);
								effectInstance.transform.localPosition = Vector3.zero;
								effectInstance.transform.localRotation = Quaternion.identity;
							}
							effectInstance.SetActive(true);
							ManualLogSource? staticLogger7 = StaticLogger;
							if (staticLogger7 != null)
							{
								staticLogger7.LogDebug((object)"Re-activating Flash effects.");
							}
						}
					}
					else if ((Object)(object)effectPrefab == (Object)null)
					{
						ManualLogSource? staticLogger8 = StaticLogger;
						if (staticLogger8 != null)
						{
							staticLogger8.LogWarning((object)"Cannot activate effects: Prefab not loaded.");
						}
					}
				}
				else if ((Object)(object)effectInstance != (Object)null && effectInstance.activeSelf)
				{
					ManualLogSource? staticLogger9 = StaticLogger;
					if (staticLogger9 != null)
					{
						staticLogger9.LogInfo((object)"Deactivating Flash effects due to system toggle.");
					}
					effectInstance.SetActive(false);
				}
			}

			[HarmonyPatch("FixedUpdate")]
			[HarmonyPrefix]
			private static bool FixedUpdate_Prefix(PlayerController __instance)
			{
				if (!originalValuesCaptured && (Object)(object)__instance != (Object)null)
				{
					CaptureOriginalPlayerValues(__instance);
				}
				if (!originalValuesCaptured)
				{
					return true;
				}
				if (flashSpeedMultiplier == null)
				{
					if (Time.frameCount % 300 == 0)
					{
						ManualLogSource? staticLogger = StaticLogger;
						if (staticLogger != null)
						{
							staticLogger.LogWarning((object)"Config value(s) missing in FixedUpdate_Prefix");
						}
					}
					return true;
				}
				if (IsFlashActive)
				{
					if (!speedIsModified)
					{
						__instance.MoveSpeed = originalMoveSpeed * flashSpeedMultiplier.Value;
						__instance.SprintSpeed = originalSprintSpeed * flashSpeedMultiplier.Value;
						__instance.SprintAcceleration = 10f;
						__instance.EnergySprintDrain = 0f;
						speedIsModified = true;
						ManualLogSource? staticLogger2 = StaticLogger;
						if (staticLogger2 != null)
						{
							staticLogger2.LogDebug((object)"Applying Flash speed!");
						}
					}
				}
				else if (speedIsModified)
				{
					RestoreOriginalPlayerState(__instance);
					ManualLogSource? staticLogger3 = StaticLogger;
					if (staticLogger3 != null)
					{
						staticLogger3.LogDebug((object)"Restoring original speed in FixedUpdate.");
					}
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(CameraAim))]
		private static class CameraAimPatches
		{
			[HarmonyPatch("Update")]
			[HarmonyPrefix]
			private static bool Update_Prefix(CameraAim __instance)
			{
				//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
				if (isSlowMotionActive && slowMotionTimeScale != null && slowMotionLookMultiplier != null && slowMotionTimeScale.Value > 0f)
				{
					try
					{
						float num = SemiFunc.InputMouseX();
						float num2 = SemiFunc.InputMouseY();
						float num3 = 1f / slowMotionTimeScale.Value;
						float num4 = __instance.AimSpeedMouse * num3 * slowMotionLookMultiplier.Value;
						float num5 = __instance.AimSpeedMouse * num3 * slowMotionLookMultiplier.Value;
						__instance.aimHorizontal += num * num4;
						__instance.aimVertical += (0f - num2) * num5;
						__instance.aimVertical = Mathf.Clamp(__instance.aimVertical, -70f, 80f);
						((Component)__instance).transform.localRotation = Quaternion.Euler(__instance.aimVertical, __instance.aimHorizontal, 0f);
						return false;
					}
					catch (Exception ex)
					{
						ManualLogSource? staticLogger = StaticLogger;
						if (staticLogger != null)
						{
							staticLogger.LogError((object)("Error during slow motion camera update: " + ex.Message));
						}
						return true;
					}
				}
				return true;
			}
		}

		public static ConfigEntry<float>? normalSpeedMultiplier;

		public static ConfigEntry<float>? flashSpeedMultiplier;

		public static ConfigEntry<KeyCode>? speedBoostKey;

		public static ConfigEntry<KeyCode>? toggleKey;

		public static ConfigEntry<bool>? enableSlowMotion;

		public static ConfigEntry<float>? slowMotionTimeScale;

		public static ConfigEntry<KeyCode>? slowMotionKey;

		public static ConfigEntry<float>? slowMotionLookMultiplier;

		private ManualLogSource? modLogger;

		private static float originalMoveSpeed;

		private static float originalSprintSpeed;

		private static float originalSprintAcceleration;

		private static float originalEnergyDrain;

		private static float originalTimeScale;

		private static bool originalValuesCaptured;

		public static bool isFlashSystemEnabled;

		private static bool wasToggleKeyPressed;

		public static bool isSlowMotionActive;

		private static bool speedIsModified;

		private static bool timeScaleIsModified;

		private static AssetBundle? effectsBundle;

		private static GameObject? effectPrefab;

		private static GameObject? effectInstance;

		private const string EffectsBundleName = "effectsbundle";

		private const string EffectPrefabName = "FlashEffectPrefab";

		public static ManualLogSource? StaticLogger { get; private set; }

		public static FlashSpeedMod? Instance { get; private set; }

		public static bool IsFlashActive { get; private set; }

		private void Awake()
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Expected O, but got Unknown
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Expected O, but got Unknown
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Expected O, but got Unknown
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			modLogger = Logger.CreateLogSource("Flash Time");
			StaticLogger = modLogger;
			normalSpeedMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Movement", "Normal Speed Multiplier", 1f, new ConfigDescription("Base movement speed multiplier", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 2f), Array.Empty<object>()));
			flashSpeedMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Movement", "Flash Speed Multiplier", 3f, new ConfigDescription("Speed multiplier when using Flash powers", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 6f), Array.Empty<object>()));
			speedBoostKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "Speed Boost Key", (KeyCode)304, "Key to activate Flash speed");
			toggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "Toggle Flash System", (KeyCode)120, "Key to toggle Flash system on/off");
			enableSlowMotion = ((BaseUnityPlugin)this).Config.Bind<bool>("Slow Motion", "Enable Slow Motion", true, "Enable slow motion feature while using Flash speed");
			slowMotionTimeScale = ((BaseUnityPlugin)this).Config.Bind<float>("Slow Motion", "Slow Motion Time Scale", 0.2f, new ConfigDescription("Time scale when slow motion is active (lower = slower)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 0.5f), Array.Empty<object>()));
			slowMotionKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "Slow Motion Key", (KeyCode)324, "Key to activate slow motion (while using Flash speed)");
			slowMotionLookMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Slow Motion", "Look Sensitivity Multiplier", 0.3f, new ConfigDescription("Additional look sensitivity multiplier during slow motion", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), Array.Empty<object>()));
			originalTimeScale = Time.timeScale;
			LoadEffectsBundle();
			Harmony val = new Harmony("com.BellaModsGames.flashtime");
			val.PatchAll();
			SceneManager.sceneLoaded += OnSceneLoaded;
			modLogger.LogInfo((object)$"Flash Time v{((BaseUnityPlugin)this).Info.Metadata.Version} initialized!");
			modLogger.LogInfo((object)$"Toggle Key: {toggleKey?.Value}, Boost Key: {speedBoostKey?.Value}, SlowMo Key: {slowMotionKey?.Value}");
		}

		private void LoadEffectsBundle()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				ManualLogSource? obj = modLogger;
				if (obj != null)
				{
					obj.LogError((object)"Cannot load effects: Mod Instance is null.");
				}
				return;
			}
			string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)Instance).Info.Location);
			if (string.IsNullOrEmpty(directoryName))
			{
				ManualLogSource? obj2 = modLogger;
				if (obj2 != null)
				{
					obj2.LogError((object)"Cannot load effects: Could not determine plugin directory.");
				}
				return;
			}
			string text = Path.Combine(directoryName, "effectsbundle");
			ManualLogSource? obj3 = modLogger;
			if (obj3 != null)
			{
				obj3.LogInfo((object)("Attempting to load effects bundle from: " + text));
			}
			if (!File.Exists(text))
			{
				ManualLogSource? obj4 = modLogger;
				if (obj4 != null)
				{
					obj4.LogError((object)("Effects bundle not found: " + text + ". Visual effects will be disabled."));
				}
				return;
			}
			try
			{
				effectsBundle = AssetBundle.LoadFromFile(text);
				if ((Object)(object)effectsBundle == (Object)null)
				{
					ManualLogSource? obj5 = modLogger;
					if (obj5 != null)
					{
						obj5.LogError((object)("Failed to load AssetBundle: " + text));
					}
					return;
				}
				effectPrefab = effectsBundle.LoadAsset<GameObject>("FlashEffectPrefab");
				if ((Object)(object)effectPrefab == (Object)null)
				{
					ManualLogSource? obj6 = modLogger;
					if (obj6 != null)
					{
						obj6.LogError((object)"Failed to load prefab 'FlashEffectPrefab' from bundle 'effectsbundle'. Visual effects will be disabled.");
					}
				}
				else
				{
					ManualLogSource? obj7 = modLogger;
					if (obj7 != null)
					{
						obj7.LogInfo((object)"Successfully loaded effect prefab 'FlashEffectPrefab'.");
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? obj8 = modLogger;
				if (obj8 != null)
				{
					obj8.LogError((object)("Error loading effects bundle or prefab: " + ex.Message + "\n" + ex.StackTrace));
				}
				if ((Object)(object)effectsBundle != (Object)null)
				{
					effectsBundle.Unload(true);
					effectsBundle = null;
				}
				effectPrefab = null;
			}
		}

		private static void CaptureOriginalPlayerValues(PlayerController player)
		{
			if ((Object)(object)player == (Object)null)
			{
				ManualLogSource? staticLogger = StaticLogger;
				if (staticLogger != null)
				{
					staticLogger.LogWarning((object)"Attempted to capture values from a null PlayerController.");
				}
				return;
			}
			originalMoveSpeed = player.MoveSpeed;
			originalSprintSpeed = player.SprintSpeed;
			originalSprintAcceleration = player.SprintAcceleration;
			originalEnergyDrain = player.EnergySprintDrain;
			originalValuesCaptured = true;
			ManualLogSource? staticLogger2 = StaticLogger;
			if (staticLogger2 != null)
			{
				staticLogger2.LogInfo((object)$"Captured original player values: Move={originalMoveSpeed}, Sprint={originalSprintSpeed}, Accel={originalSprintAcceleration}, Drain={originalEnergyDrain}");
			}
		}

		public static void RestoreOriginalPlayerState(PlayerController? player = null, bool forceRestore = false)
		{
			if ((Object)(object)player == (Object)null)
			{
				player = Object.FindObjectOfType<PlayerController>();
			}
			if ((Object)(object)player != (Object)null)
			{
				if (originalValuesCaptured)
				{
					if (speedIsModified || forceRestore)
					{
						player.MoveSpeed = originalMoveSpeed;
						player.SprintSpeed = originalSprintSpeed;
						player.SprintAcceleration = originalSprintAcceleration;
						player.EnergySprintDrain = originalEnergyDrain;
						ManualLogSource? staticLogger = StaticLogger;
						if (staticLogger != null)
						{
							staticLogger.LogInfo((object)"Player speed values restored to original.");
						}
						speedIsModified = false;
					}
				}
				else
				{
					ManualLogSource? staticLogger2 = StaticLogger;
					if (staticLogger2 != null)
					{
						staticLogger2.LogWarning((object)"Cannot restore player speed: Original values were never captured.");
					}
				}
			}
			else if (speedIsModified)
			{
				ManualLogSource? staticLogger3 = StaticLogger;
				if (staticLogger3 != null)
				{
					staticLogger3.LogWarning((object)"Could not find PlayerController instance to restore speed state.");
				}
				speedIsModified = false;
			}
			if (timeScaleIsModified || forceRestore)
			{
				if (Time.timeScale != originalTimeScale)
				{
					Time.timeScale = originalTimeScale;
					ManualLogSource? staticLogger4 = StaticLogger;
					if (staticLogger4 != null)
					{
						staticLogger4.LogInfo((object)$"Time scale restored to original ({originalTimeScale}).");
					}
				}
				timeScaleIsModified = false;
			}
			IsFlashActive = false;
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			ManualLogSource? staticLogger = StaticLogger;
			if (staticLogger != null)
			{
				staticLogger.LogInfo((object)("Scene loaded: " + ((Scene)(ref scene)).name + ". Forcing restore of player state."));
			}
			originalValuesCaptured = false;
			PlayerController val = Object.FindObjectOfType<PlayerController>();
			if ((Object)(object)val != (Object)null)
			{
				CaptureOriginalPlayerValues(val);
			}
			RestoreOriginalPlayerState(val, forceRestore: true);
			if (!((Object)(object)effectInstance != (Object)null))
			{
				return;
			}
			if ((Object)(object)val != (Object)null)
			{
				ManualLogSource? staticLogger2 = StaticLogger;
				if (staticLogger2 != null)
				{
					staticLogger2.LogInfo((object)"Re-parenting effect instance to new player controller.");
				}
				effectInstance.transform.SetParent(((Component)val).transform, false);
				effectInstance.transform.localPosition = Vector3.zero;
				effectInstance.transform.localRotation = Quaternion.identity;
				if (effectInstance.activeSelf)
				{
					effectInstance.SetActive(false);
				}
			}
			else
			{
				ManualLogSource? staticLogger3 = StaticLogger;
				if (staticLogger3 != null)
				{
					staticLogger3.LogWarning((object)"PlayerController not found in new scene, destroying effect instance.");
				}
				Object.Destroy((Object)(object)effectInstance);
				effectInstance = null;
			}
		}

		private void OnDisable()
		{
			ManualLogSource? staticLogger = StaticLogger;
			if (staticLogger != null)
			{
				staticLogger.LogInfo((object)"Flash Time mod disabling. Restoring original player state and cleaning up effects.");
			}
			RestoreOriginalPlayerState(null, forceRestore: true);
			SceneManager.sceneLoaded -= OnSceneLoaded;
			ManualLogSource? staticLogger2 = StaticLogger;
			if (staticLogger2 != null)
			{
				staticLogger2.LogInfo((object)"Unsubscribed from sceneLoaded event.");
			}
			if ((Object)(object)effectInstance != (Object)null)
			{
				Object.Destroy((Object)(object)effectInstance);
				effectInstance = null;
				ManualLogSource? staticLogger3 = StaticLogger;
				if (staticLogger3 != null)
				{
					staticLogger3.LogInfo((object)"Destroyed effect instance.");
				}
			}
			if ((Object)(object)effectsBundle != (Object)null)
			{
				effectsBundle.Unload(false);
				effectsBundle = null;
				ManualLogSource? staticLogger4 = StaticLogger;
				if (staticLogger4 != null)
				{
					staticLogger4.LogInfo((object)"Unloaded effects bundle.");
				}
			}
		}

		private void OnDestroy()
		{
			ManualLogSource? staticLogger = StaticLogger;
			if (staticLogger != null)
			{
				staticLogger.LogInfo((object)"Flash Time mod destroying. Restoring original player state and cleaning up effects.");
			}
			RestoreOriginalPlayerState(null, forceRestore: true);
			SceneManager.sceneLoaded -= OnSceneLoaded;
			if ((Object)(object)effectInstance != (Object)null)
			{
				Object.Destroy((Object)(object)effectInstance);
				effectInstance = null;
				ManualLogSource? staticLogger2 = StaticLogger;
				if (staticLogger2 != null)
				{
					staticLogger2.LogInfo((object)"Destroyed effect instance.");
				}
			}
			if ((Object)(object)effectsBundle != (Object)null)
			{
				effectsBundle.Unload(false);
				effectsBundle = null;
				ManualLogSource? staticLogger3 = StaticLogger;
				if (staticLogger3 != null)
				{
					staticLogger3.LogInfo((object)"Unloaded effects bundle.");
				}
			}
		}
	}
}