Decompiled source of MirroredStageVariants v1.2.4

plugins/MirroredStageVariants/MirroredStageVariants.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HG.Reflection;
using HarmonyLib;
using IL.RoR2;
using Microsoft.CodeAnalysis;
using MirroredStageVariants.Components;
using MirroredStageVariants.ModCompatibility;
using MirroredStageVariants.Patches;
using MirroredStageVariants.Utils;
using Mono.Cecil;
using Mono.Cecil.Cil;
using Mono.Collections.Generic;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using MonoMod.Utils;
using On.RoR2;
using On.RoR2.CameraModes;
using On.RoR2.UI;
using R2API.Utils;
using Rewired;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.CameraModes;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: NetworkCompatibility(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MirroredStageVariants")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+d25bf8ee1aa1619f001b0924b2db2692b9816e6a")]
[assembly: AssemblyProduct("MirroredStageVariants")]
[assembly: AssemblyTitle("MirroredStageVariants")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MirroredStageVariants
{
	internal static class Assets
	{
		private interface IAssetReference
		{
			Object Asset { get; set; }
		}

		private class AssetLoadOperation
		{
			public string AssetName { get; }

			public AssetBundleRequest LoadRequest { get; }

			public IAssetReference AssetReference { get; }

			public bool IsDone => ((AsyncOperation)LoadRequest).isDone;

			public AssetLoadOperation(string assetName, AssetBundleRequest loadRequest, IAssetReference assetReference)
			{
				AssetName = assetName;
				LoadRequest = loadRequest ?? throw new ArgumentNullException("loadRequest");
				AssetReference = assetReference ?? throw new ArgumentNullException("assetReference");
				base..ctor();
			}

			public void Update()
			{
				if (((AsyncOperation)LoadRequest).isDone)
				{
					Object asset = LoadRequest.asset;
					if (!Object.op_Implicit(asset))
					{
						Log.Error("Missing asset '" + AssetName + "', check editor export!", "X:\\Git\\RoR2\\MirroredStageVariants\\VS\\MirroredStageVariants\\Assets.cs", "Update", 36);
					}
					else
					{
						AssetReference.Asset = asset;
					}
				}
			}
		}

		private class AssetReference<T> : IAssetReference where T : Object
		{
			public T Asset;

			Object IAssetReference.Asset
			{
				get
				{
					return (Object)(object)Asset;
				}
				set
				{
					Asset = (T)(object)value;
				}
			}
		}

		private static readonly AssetReference<Material> _mirrorMaterialRef = new AssetReference<Material>();

		private static readonly AssetReference<Shader> _mirrorOverlayShaderRef = new AssetReference<Shader>();

		public static Material MirrorMaterial => _mirrorMaterialRef.Asset;

		public static Shader MirrorOverlayShader => _mirrorOverlayShaderRef.Asset;

		[SystemInitializer(new Type[] { })]
		private static IEnumerator Init()
		{
			string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)Main.Instance).Info.Location), "mirror_assets");
			if (!File.Exists(text))
			{
				Log.Error("Assets file not found, expected path: " + text, "X:\\Git\\RoR2\\MirroredStageVariants\\VS\\MirroredStageVariants\\Assets.cs", "Init", 73);
				yield break;
			}
			AssetBundleCreateRequest assetBundleLoad = AssetBundle.LoadFromFileAsync(text);
			while (!((AsyncOperation)assetBundleLoad).isDone)
			{
				yield return null;
			}
			AssetBundle assetBundle = assetBundleLoad.assetBundle;
			if (!Object.op_Implicit((Object)(object)assetBundle))
			{
				Log.Error("Failed to load asset bundle", "X:\\Git\\RoR2\\MirroredStageVariants\\VS\\MirroredStageVariants\\Assets.cs", "Init", 90);
				yield break;
			}
			List<AssetLoadOperation> loadOperations = new List<AssetLoadOperation>
			{
				getLoadOperation<Material>("Mirror", _mirrorMaterialRef),
				getLoadOperation<Shader>("MirrorOverlay", _mirrorOverlayShaderRef)
			};
			while (loadOperations.Count > 0)
			{
				for (int num = loadOperations.Count - 1; num >= 0; num--)
				{
					AssetLoadOperation assetLoadOperation = loadOperations[num];
					assetLoadOperation.Update();
					if (assetLoadOperation.IsDone)
					{
						loadOperations.RemoveAt(num);
					}
				}
				yield return null;
			}
			AssetLoadOperation getLoadOperation<T>(string name, AssetReference<T> dest) where T : Object
			{
				return new AssetLoadOperation(name, assetBundle.LoadAssetAsync<T>(name), dest);
			}
		}
	}
	internal static class Commands
	{
		public static bool? OverrideStageIsMirrored { get; private set; }

		[ConCommand(commandName = "msv_force_all", helpText = "Sets or clears mirror override [mirrored/normal/random]")]
		private static void CCOverrideStageIsMirrored(ConCommandArgs args)
		{
			if (((ConCommandArgs)(ref args)).Count < 1)
			{
				if (OverrideStageIsMirrored.HasValue)
				{
					Debug.Log((object)("All stages forced " + (OverrideStageIsMirrored.Value ? "mirrored" : "normal")));
				}
				else
				{
					Debug.Log((object)"No active override");
				}
				return;
			}
			bool? flag;
			switch (((ConCommandArgs)(ref args)).GetArgString(0).ToLower())
			{
			case "mirrored":
			case "mirror":
			case "m":
				flag = true;
				break;
			case "normal":
			case "n":
				flag = false;
				break;
			default:
				flag = null;
				break;
			}
			bool? flag2 = flag;
			if (OverrideStageIsMirrored != flag2)
			{
				OverrideStageIsMirrored = flag2;
				if (OverrideStageIsMirrored.HasValue)
				{
					Debug.Log((object)("All stages forced " + (OverrideStageIsMirrored.Value ? "mirrored" : "normal")));
				}
				else
				{
					Debug.Log((object)"All stages mirrored override cleared");
				}
			}
		}
	}
	internal static class Log
	{
		internal static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		private static string getLogPrefix(string callerPath, string callerMemberName, int callerLineNumber)
		{
			int num = callerPath.LastIndexOf("MirroredStageVariants\\");
			if (num >= 0)
			{
				callerPath = callerPath.Substring(num + "MirroredStageVariants\\".Length);
			}
			return $"{callerPath}:{callerLineNumber} ({callerMemberName}) ";
		}

		internal static void Error(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogError((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Error_NoCallerPrefix(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogFatal((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Fatal_NoCallerPrefix(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogInfo((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Info_NoCallerPrefix(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogMessage((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Message_NoCallerPrefix(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogWarning((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Warning_NoCallerPrefix(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInPlugin("Gorakh.MirroredStageVariants", "MirroredStageVariants", "1.2.4")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Main : BaseUnityPlugin
	{
		public const string PluginGUID = "Gorakh.MirroredStageVariants";

		public const string PluginAuthor = "Gorakh";

		public const string PluginName = "MirroredStageVariants";

		public const string PluginVersion = "1.2.4";

		internal static Main Instance { get; private set; }

		public static ConfigEntry<float> MirrorChance { get; private set; }

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

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

		private void Awake()
		{
			Stopwatch stopwatch = Stopwatch.StartNew();
			Log.Init(((BaseUnityPlugin)this).Logger);
			Instance = SingletonHelper.Assign<Main>(Instance, this);
			initConfigs(((BaseUnityPlugin)this).Config);
			MirrorAudioPatch.Apply();
			InvertScreenCoordinatesPatch.Apply();
			InvertInputPatch.Apply();
			InvertScreenBlurPatch.Apply();
			InvertDamageNumberPositionsPatch.Apply();
			InvertTypewriteTextControllerPatch.Apply();
			HideStunEffect.Apply();
			stopwatch.Stop();
			Log.Message_NoCallerPrefix($"Initialized in {stopwatch.Elapsed.TotalSeconds:F2}s");
		}

		private void OnDestroy()
		{
			MirrorAudioPatch.Undo();
			InvertScreenCoordinatesPatch.Undo();
			InvertInputPatch.Undo();
			InvertScreenBlurPatch.Undo();
			InvertDamageNumberPositionsPatch.Undo();
			InvertTypewriteTextControllerPatch.Undo();
			HideStunEffect.Undo();
			Instance = SingletonHelper.Unassign<Main>(Instance, this);
		}

		private static void initConfigs(ConfigFile file)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			MirrorChance = file.Bind<float>("General", "Mirror Chance", 50f, new ConfigDescription("The percent chance that any given stage will be mirrored", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
			MirrorNonStages = file.Bind<bool>("General", "Mirror Non-Stages", true, "If non-stage scenes (menu, cutscenes) should be mirrored, if enabled, they are always mirrored, if disabled, they are never mirrored.");
			MirrorHiddenRealms = file.Bind<bool>("General", "Mirror Hidden Realms", true, "If stages outside the normal stage one through five rotation can be mirrored.");
			if (RiskOfOptionsCompat.IsEnabled)
			{
				RiskOfOptionsCompat.AddConfigOptions();
			}
		}
	}
}
namespace MirroredStageVariants.Utils
{
	public static class CameraEvents
	{
		[CompilerGenerated]
		private static CameraCallback m_OnPreCull;

		[CompilerGenerated]
		private static CameraCallback m_OnPreRender;

		[CompilerGenerated]
		private static CameraCallback m_OnPostRender;

		public static event CameraCallback OnPreCull
		{
			[CompilerGenerated]
			add
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Expected O, but got Unknown
				CameraCallback val = CameraEvents.m_OnPreCull;
				CameraCallback val2;
				do
				{
					val2 = val;
					CameraCallback value2 = (CameraCallback)Delegate.Combine((Delegate?)(object)val2, (Delegate?)(object)value);
					val = Interlocked.CompareExchange(ref CameraEvents.m_OnPreCull, value2, val2);
				}
				while (val != val2);
			}
			[CompilerGenerated]
			remove
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Expected O, but got Unknown
				CameraCallback val = CameraEvents.m_OnPreCull;
				CameraCallback val2;
				do
				{
					val2 = val;
					CameraCallback value2 = (CameraCallback)Delegate.Remove((Delegate?)(object)val2, (Delegate?)(object)value);
					val = Interlocked.CompareExchange(ref CameraEvents.m_OnPreCull, value2, val2);
				}
				while (val != val2);
			}
		}

		public static event CameraCallback OnPreRender
		{
			[CompilerGenerated]
			add
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Expected O, but got Unknown
				CameraCallback val = CameraEvents.m_OnPreRender;
				CameraCallback val2;
				do
				{
					val2 = val;
					CameraCallback value2 = (CameraCallback)Delegate.Combine((Delegate?)(object)val2, (Delegate?)(object)value);
					val = Interlocked.CompareExchange(ref CameraEvents.m_OnPreRender, value2, val2);
				}
				while (val != val2);
			}
			[CompilerGenerated]
			remove
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Expected O, but got Unknown
				CameraCallback val = CameraEvents.m_OnPreRender;
				CameraCallback val2;
				do
				{
					val2 = val;
					CameraCallback value2 = (CameraCallback)Delegate.Remove((Delegate?)(object)val2, (Delegate?)(object)value);
					val = Interlocked.CompareExchange(ref CameraEvents.m_OnPreRender, value2, val2);
				}
				while (val != val2);
			}
		}

		public static event CameraCallback OnPostRender
		{
			[CompilerGenerated]
			add
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Expected O, but got Unknown
				CameraCallback val = CameraEvents.m_OnPostRender;
				CameraCallback val2;
				do
				{
					val2 = val;
					CameraCallback value2 = (CameraCallback)Delegate.Combine((Delegate?)(object)val2, (Delegate?)(object)value);
					val = Interlocked.CompareExchange(ref CameraEvents.m_OnPostRender, value2, val2);
				}
				while (val != val2);
			}
			[CompilerGenerated]
			remove
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Expected O, but got Unknown
				CameraCallback val = CameraEvents.m_OnPostRender;
				CameraCallback val2;
				do
				{
					val2 = val;
					CameraCallback value2 = (CameraCallback)Delegate.Remove((Delegate?)(object)val2, (Delegate?)(object)value);
					val = Interlocked.CompareExchange(ref CameraEvents.m_OnPostRender, value2, val2);
				}
				while (val != val2);
			}
		}

		static CameraEvents()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			Camera.onPreCull = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPreCull, (Delegate?)(CameraCallback)delegate(Camera cam)
			{
				CameraCallback onPreCull = CameraEvents.OnPreCull;
				if (onPreCull != null)
				{
					onPreCull.Invoke(cam);
				}
			});
			Camera.onPreRender = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPreRender, (Delegate?)(CameraCallback)delegate(Camera cam)
			{
				CameraCallback onPreRender = CameraEvents.OnPreRender;
				if (onPreRender != null)
				{
					onPreRender.Invoke(cam);
				}
			});
			Camera.onPostRender = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPostRender, (Delegate?)(CameraCallback)delegate(Camera cam)
			{
				CameraCallback onPostRender = CameraEvents.OnPostRender;
				if (onPostRender != null)
				{
					onPostRender.Invoke(cam);
				}
			});
		}
	}
	public static class CameraUtils
	{
		public static bool ShouldRenderObjectAsMirrored(this Camera camera, GameObject obj)
		{
			if (StageMirrorController.CurrentlyIsMirrored && (camera.cullingMask & (1 << obj.layer)) != 0)
			{
				if (Object.op_Implicit((Object)(object)((Component)camera).GetComponent<MirrorCamera>()))
				{
					return true;
				}
				UICamera val = default(UICamera);
				CameraRigController val2 = ((!((Component)camera).TryGetComponent<UICamera>(ref val)) ? ((Component)camera).GetComponentInParent<CameraRigController>() : val.cameraRigController);
				if (Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)val2.sceneCam) && Object.op_Implicit((Object)(object)((Component)val2.sceneCam).GetComponent<MirrorCamera>()))
				{
					return true;
				}
			}
			return false;
		}
	}
	internal static class CommonShaderIDs
	{
		public static readonly int _SwapCount = Shader.PropertyToID("_SwapCount");

		public static readonly int _SwapPositions = Shader.PropertyToID("_SwapPositions");

		public static readonly int _SwapSizes = Shader.PropertyToID("_SwapSizes");

		public static readonly int _InputTex = Shader.PropertyToID("_InputTex");

		public static readonly int _OverlayTex = Shader.PropertyToID("_OverlayTex");
	}
	public static class CoordinateUtils
	{
		public static float GetInvertedScreenXCoordinate(float coordinate, Rect space)
		{
			float xMin = ((Rect)(ref space)).xMin;
			float xMax = ((Rect)(ref space)).xMax;
			return Util.Remap(coordinate, xMin, xMax, xMax, xMin);
		}

		public static void InvertScreenXCoordinate(ref float coordinate, Rect space)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			coordinate = GetInvertedScreenXCoordinate(coordinate, space);
		}

		public static Vector2 Remap(Vector2 value, Rect inputSpace, Rect outputSpace)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			float num = Util.Remap(value.x, ((Rect)(ref inputSpace)).xMin, ((Rect)(ref inputSpace)).xMax, ((Rect)(ref outputSpace)).xMin, ((Rect)(ref outputSpace)).xMax);
			float num2 = Util.Remap(value.y, ((Rect)(ref inputSpace)).yMin, ((Rect)(ref inputSpace)).yMax, ((Rect)(ref outputSpace)).yMin, ((Rect)(ref outputSpace)).yMax);
			return new Vector2(num, num2);
		}
	}
	public static class TransformExtensions
	{
		public static Matrix4x4 GlobalTransformationFromLocal(this Transform transform, Matrix4x4 localTransformation)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			return transform.localToWorldMatrix * localTransformation * transform.worldToLocalMatrix;
		}

		public static IEnumerable<Transform> GetAllChildrenRecursive(this Transform transform)
		{
			yield return transform;
			for (int i = 0; i < transform.childCount; i++)
			{
				foreach (Transform item in transform.GetChild(i).GetAllChildrenRecursive())
				{
					yield return item;
				}
			}
		}
	}
}
namespace MirroredStageVariants.Patches
{
	internal static class CostTextMirrorFix
	{
		[SystemInitializer(new Type[] { })]
		private static void Init()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Common/VFX/CostHologramContent.prefab");
			val.Completed += delegate(AsyncOperationHandle<GameObject> handle)
			{
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				handle.Result.AddComponent<ScaleOnAwakeIfMirrored>().ScaleMultiplier = new Vector3(-1f, 1f, 1f);
			};
		}
	}
	internal static class HideStunEffect
	{
		private static TextMeshPro _stunVfxText;

		public static void Apply()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)_stunVfxText))
			{
				setTextVisibility(enabled: false);
				return;
			}
			AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Common/VFX/StunVfx.prefab");
			val.Completed += delegate(AsyncOperationHandle<GameObject> handle)
			{
				_stunVfxText = handle.Result.GetComponentInChildren<TextMeshPro>();
				setTextVisibility(enabled: false);
			};
		}

		public static void Undo()
		{
			setTextVisibility(enabled: true);
			_stunVfxText = null;
		}

		private static void setTextVisibility(bool enabled)
		{
			if (Object.op_Implicit((Object)(object)_stunVfxText))
			{
				((Behaviour)_stunVfxText).enabled = enabled;
			}
		}
	}
	internal static class InvertDamageNumberPositionsPatch
	{
		private static readonly List<MonoBehaviour> _addedComponents = new List<MonoBehaviour>();

		public static void Apply()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Core/DamageNumberManager.prefab");
			val.Completed += delegate(AsyncOperationHandle<GameObject> handle)
			{
				FlipParticleSystemIfMirrored item2 = handle.Result.AddComponent<FlipParticleSystemIfMirrored>();
				_addedComponents.Add((MonoBehaviour)(object)item2);
			};
			AsyncOperationHandle<GameObject> val2 = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/CritGlassesVoid/CritGlassesVoidExecuteEffect.prefab");
			val2.Completed += delegate(AsyncOperationHandle<GameObject> handle)
			{
				Transform val3 = handle.Result.transform.Find("FakeDamageNumbers");
				if (Object.op_Implicit((Object)(object)val3))
				{
					FlipParticleSystemIfMirrored item = ((Component)val3).gameObject.AddComponent<FlipParticleSystemIfMirrored>();
					_addedComponents.Add((MonoBehaviour)(object)item);
				}
				else
				{
					Log.Error("Failed to find fake damage number emitter on CritGlassesVoidExecuteEffect", "X:\\Git\\RoR2\\MirroredStageVariants\\VS\\MirroredStageVariants\\Patches\\InvertDamageNumberPositionsPatch.cs", "Apply", 39);
				}
			};
		}

		public static void Undo()
		{
			foreach (MonoBehaviour addedComponent in _addedComponents)
			{
				Object.Destroy((Object)(object)addedComponent);
			}
			_addedComponents.Clear();
		}
	}
	internal static class InvertInputPatch
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_CollectLookInput <0>__CameraModeBase_CollectLookInput;

			public static Manipulator <1>__PlayerCharacterMasterController_Update;

			public static <>A{00000001}<Vector2> <2>__tryMirrorMoveInput;
		}

		public static void Apply()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			object obj = <>O.<0>__CameraModeBase_CollectLookInput;
			if (obj == null)
			{
				hook_CollectLookInput val = CameraModeBase_CollectLookInput;
				<>O.<0>__CameraModeBase_CollectLookInput = val;
				obj = (object)val;
			}
			CameraModeBase.CollectLookInput += (hook_CollectLookInput)obj;
			object obj2 = <>O.<1>__PlayerCharacterMasterController_Update;
			if (obj2 == null)
			{
				Manipulator val2 = PlayerCharacterMasterController_Update;
				<>O.<1>__PlayerCharacterMasterController_Update = val2;
				obj2 = (object)val2;
			}
			PlayerCharacterMasterController.Update += (Manipulator)obj2;
		}

		public static void Undo()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			object obj = <>O.<0>__CameraModeBase_CollectLookInput;
			if (obj == null)
			{
				hook_CollectLookInput val = CameraModeBase_CollectLookInput;
				<>O.<0>__CameraModeBase_CollectLookInput = val;
				obj = (object)val;
			}
			CameraModeBase.CollectLookInput -= (hook_CollectLookInput)obj;
			object obj2 = <>O.<1>__PlayerCharacterMasterController_Update;
			if (obj2 == null)
			{
				Manipulator val2 = PlayerCharacterMasterController_Update;
				<>O.<1>__PlayerCharacterMasterController_Update = val2;
				obj2 = (object)val2;
			}
			PlayerCharacterMasterController.Update -= (Manipulator)obj2;
		}

		private static void CameraModeBase_CollectLookInput(orig_CollectLookInput orig, CameraModeBase self, ref CameraModeContext context, out CollectLookInputResult result)
		{
			orig.Invoke(self, ref context, ref result);
			if (StageMirrorController.CurrentlyIsMirrored)
			{
				result.lookInput.x *= -1f;
			}
		}

		private static void PlayerCharacterMasterController_Update(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			ILCursor[] array = default(ILCursor[]);
			if (new ILCursor(il).TryFindNext(ref array, new Func<Instruction, bool>[3]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo<Player>((Expression<Action<Player>>)((Player _) => _.GetAxis(0)))),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo<Player>((Expression<Action<Player>>)((Player _) => _.GetAxis(0)))),
				(Instruction x) => ILPatternMatchingExt.MatchCall(x, (MethodBase)AccessTools.DeclaredConstructor(typeof(Vector2), new Type[2]
				{
					typeof(float),
					typeof(float)
				}, false))
			}))
			{
				ILCursor val = array[2];
				int index = val.Index + 1;
				int moveInputLocalIndex = -1;
				if (val.TryGotoPrev(new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdloca(x, ref moveInputLocalIndex)
				}))
				{
					val.Index = index;
					if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
					{
						(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<InputBankTest>(x, "SetRawMoveStates")
					}))
					{
						Log.Error("Failed to find raw move state call", "X:\\Git\\RoR2\\MirroredStageVariants\\VS\\MirroredStageVariants\\Patches\\InvertInputPatch.cs", "PlayerCharacterMasterController_Update", 58);
					}
					val.Emit(OpCodes.Ldloca, moveInputLocalIndex);
					val.EmitDelegate<<>A{00000001}<Vector2>>((<>A{00000001}<Vector2>)tryMirrorMoveInput);
				}
				else
				{
					Log.Error("Failed to find move input local index", "X:\\Git\\RoR2\\MirroredStageVariants\\VS\\MirroredStageVariants\\Patches\\InvertInputPatch.cs", "PlayerCharacterMasterController_Update", 73);
				}
			}
			else
			{
				Log.Error("Failed to find patch location", "X:\\Git\\RoR2\\MirroredStageVariants\\VS\\MirroredStageVariants\\Patches\\InvertInputPatch.cs", "PlayerCharacterMasterController_Update", 78);
			}
			static void tryMirrorMoveInput(ref Vector2 moveInput)
			{
				if (StageMirrorController.CurrentlyIsMirrored)
				{
					moveInput.x *= -1f;
				}
			}
		}
	}
	internal static class InvertScreenBlurPatch
	{
		public static void Apply()
		{
		}

		public static void Undo()
		{
		}
	}
	internal static class InvertScreenCoordinatesPatch
	{
		private delegate Vector3 ScreenCoordinateDelegate(Camera self, Vector3 position, MonoOrStereoscopicEye eye);

		private delegate Ray ScreenRayDelegate(Camera self, Vector2 pos, MonoOrStereoscopicEye eye);

		private static Hook Camera_WorldToScreenPoint_Hook;

		private static Hook Camera_WorldToViewportPoint_Hook;

		private static Hook Camera_ViewportToWorldPoint_Hook;

		private static Hook Camera_ScreenToWorldPoint_Hook;

		private static Hook Camera_ViewportPointToRay_Hook;

		private static Hook Camera_ScreenPointToRay_Hook;

		public static void Apply()
		{
			//IL_0029: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Expected O, but got Unknown
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Expected O, but got Unknown
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Expected O, but got Unknown
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Expected O, but got Unknown
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Expected O, but got Unknown
			Camera_WorldToScreenPoint_Hook = new Hook((Expression<Action>)(() => ((Camera)null).WorldToScreenPoint(default(Vector3), (MonoOrStereoscopicEye)0)), (Delegate)new Func<ScreenCoordinateDelegate, Camera, Vector3, MonoOrStereoscopicEye, Vector3>(invertPixelCoordinateResult));
			Camera_WorldToViewportPoint_Hook = new Hook((Expression<Action>)(() => ((Camera)null).WorldToViewportPoint(default(Vector3), (MonoOrStereoscopicEye)0)), (Delegate)new Func<ScreenCoordinateDelegate, Camera, Vector3, MonoOrStereoscopicEye, Vector3>(invertNormalizedCoordinateResult));
			Camera_ScreenToWorldPoint_Hook = new Hook((Expression<Action>)(() => ((Camera)null).ScreenToWorldPoint(default(Vector3), (MonoOrStereoscopicEye)0)), (Delegate)new Func<ScreenCoordinateDelegate, Camera, Vector3, MonoOrStereoscopicEye, Vector3>(invertPixelCoordinateInput));
			Camera_ViewportToWorldPoint_Hook = new Hook((Expression<Action>)(() => ((Camera)null).ViewportToWorldPoint(default(Vector3), (MonoOrStereoscopicEye)0)), (Delegate)new Func<ScreenCoordinateDelegate, Camera, Vector3, MonoOrStereoscopicEye, Vector3>(invertNormalizedCoordinateInput));
			Camera_ScreenPointToRay_Hook = new Hook((Expression<Action>)(() => ((Camera)null).ScreenPointToRay(default(Vector2), (MonoOrStereoscopicEye)0)), (Delegate)new Func<ScreenRayDelegate, Camera, Vector2, MonoOrStereoscopicEye, Ray>(invertRayPixelCoordinateInput));
			Camera_ViewportPointToRay_Hook = new Hook((Expression<Action>)(() => ((Camera)null).ViewportPointToRay(default(Vector2), (MonoOrStereoscopicEye)0)), (Delegate)new Func<ScreenRayDelegate, Camera, Vector2, MonoOrStereoscopicEye, Ray>(invertRayNormalizedCoordinateInput));
		}

		public static void Undo()
		{
			Hook camera_WorldToScreenPoint_Hook = Camera_WorldToScreenPoint_Hook;
			if (camera_WorldToScreenPoint_Hook != null)
			{
				camera_WorldToScreenPoint_Hook.Undo();
			}
			Hook camera_WorldToViewportPoint_Hook = Camera_WorldToViewportPoint_Hook;
			if (camera_WorldToViewportPoint_Hook != null)
			{
				camera_WorldToViewportPoint_Hook.Undo();
			}
			Hook camera_ViewportToWorldPoint_Hook = Camera_ViewportToWorldPoint_Hook;
			if (camera_ViewportToWorldPoint_Hook != null)
			{
				camera_ViewportToWorldPoint_Hook.Undo();
			}
			Hook camera_ScreenToWorldPoint_Hook = Camera_ScreenToWorldPoint_Hook;
			if (camera_ScreenToWorldPoint_Hook != null)
			{
				camera_ScreenToWorldPoint_Hook.Undo();
			}
			Hook camera_ViewportPointToRay_Hook = Camera_ViewportPointToRay_Hook;
			if (camera_ViewportPointToRay_Hook != null)
			{
				camera_ViewportPointToRay_Hook.Undo();
			}
			Hook camera_ScreenPointToRay_Hook = Camera_ScreenPointToRay_Hook;
			if (camera_ScreenPointToRay_Hook != null)
			{
				camera_ScreenPointToRay_Hook.Undo();
			}
		}

		private static bool isMirrored(Camera camera)
		{
			if (StageMirrorController.CurrentlyIsMirrored)
			{
				return Object.op_Implicit((Object)(object)((Component)camera).GetComponent<MirrorCamera>());
			}
			return false;
		}

		private static Vector3 invertPixelCoordinateResult(ScreenCoordinateDelegate orig, Camera self, Vector3 position, MonoOrStereoscopicEye eye)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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)
			Vector3 result = orig(self, position, eye);
			if (isMirrored(self))
			{
				CoordinateUtils.InvertScreenXCoordinate(ref result.x, self.pixelRect);
			}
			return result;
		}

		private static Vector3 invertPixelCoordinateInput(ScreenCoordinateDelegate orig, Camera self, Vector3 position, MonoOrStereoscopicEye eye)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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_0010: Unknown result type (might be due to invalid IL or missing references)
			if (isMirrored(self))
			{
				CoordinateUtils.InvertScreenXCoordinate(ref position.x, self.pixelRect);
			}
			return orig(self, position, eye);
		}

		private static Vector3 invertNormalizedCoordinateResult(ScreenCoordinateDelegate orig, Camera self, Vector3 position, MonoOrStereoscopicEye eye)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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)
			Vector3 result = orig(self, position, eye);
			if (isMirrored(self))
			{
				CoordinateUtils.InvertScreenXCoordinate(ref result.x, self.rect);
			}
			return result;
		}

		private static Vector3 invertNormalizedCoordinateInput(ScreenCoordinateDelegate orig, Camera self, Vector3 position, MonoOrStereoscopicEye eye)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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_0010: Unknown result type (might be due to invalid IL or missing references)
			if (isMirrored(self))
			{
				CoordinateUtils.InvertScreenXCoordinate(ref position.x, self.rect);
			}
			return orig(self, position, eye);
		}

		private static Ray invertRayPixelCoordinateInput(ScreenRayDelegate orig, Camera self, Vector2 pos, MonoOrStereoscopicEye eye)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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_0010: Unknown result type (might be due to invalid IL or missing references)
			if (isMirrored(self))
			{
				CoordinateUtils.InvertScreenXCoordinate(ref pos.x, self.pixelRect);
			}
			return orig(self, pos, eye);
		}

		private static Ray invertRayNormalizedCoordinateInput(ScreenRayDelegate orig, Camera self, Vector2 pos, MonoOrStereoscopicEye eye)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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_0010: Unknown result type (might be due to invalid IL or missing references)
			if (isMirrored(self))
			{
				CoordinateUtils.InvertScreenXCoordinate(ref pos.x, self.rect);
			}
			return orig(self, pos, eye);
		}
	}
	internal static class InvertTypewriteTextControllerPatch
	{
		[DisallowMultipleComponent]
		private class InvertTypewriterInfo : MonoBehaviour
		{
			public static InvertTypewriterInfo Current;

			public TextMeshProUGUI[] InvertedLabels;
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Start <0>__AssignStageToken_Start;

			public static hook_SetTypingTime <1>__TypewriteTextController_SetTypingTime;

			public static Manipulator <2>__TypewriteTextController_SetTypingTime_UpdateCurrentLabel;

			public static Func<TextMeshProUGUI, bool> <3>__shouldMirrorLabel;

			public static Action<TMP_Text, int> <4>__setVisibleCharactersMirrored;
		}

		private static ILHook TypewriteTextController_SetTypingTime_UpdateCurrentLabel_Hook;

		public static void Apply()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//IL_0088: 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_0093: Expected O, but got Unknown
			object obj = <>O.<0>__AssignStageToken_Start;
			if (obj == null)
			{
				hook_Start val = AssignStageToken_Start;
				<>O.<0>__AssignStageToken_Start = val;
				obj = (object)val;
			}
			AssignStageToken.Start += (hook_Start)obj;
			object obj2 = <>O.<1>__TypewriteTextController_SetTypingTime;
			if (obj2 == null)
			{
				hook_SetTypingTime val2 = TypewriteTextController_SetTypingTime;
				<>O.<1>__TypewriteTextController_SetTypingTime = val2;
				obj2 = (object)val2;
			}
			TypewriteTextController.SetTypingTime += (hook_SetTypingTime)obj2;
			MethodInfo methodInfo = AccessTools.GetDeclaredMethods(typeof(TypewriteTextController)).FirstOrDefault((MethodInfo m) => m.Name.StartsWith("<SetTypingTime>g__UpdateCurrentLabel|"));
			if ((object)methodInfo != null)
			{
				object obj3 = <>O.<2>__TypewriteTextController_SetTypingTime_UpdateCurrentLabel;
				if (obj3 == null)
				{
					Manipulator val3 = TypewriteTextController_SetTypingTime_UpdateCurrentLabel;
					<>O.<2>__TypewriteTextController_SetTypingTime_UpdateCurrentLabel = val3;
					obj3 = (object)val3;
				}
				TypewriteTextController_SetTypingTime_UpdateCurrentLabel_Hook = new ILHook((MethodBase)methodInfo, (Manipulator)obj3);
			}
			else
			{
				Log.Error("Failed to find local function UpdateCurrentLabel", "X:\\Git\\RoR2\\MirroredStageVariants\\VS\\MirroredStageVariants\\Patches\\InvertTypewriteTextControllerPatch.cs", "Apply", 34);
			}
		}

		public static void Undo()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			object obj = <>O.<0>__AssignStageToken_Start;
			if (obj == null)
			{
				hook_Start val = AssignStageToken_Start;
				<>O.<0>__AssignStageToken_Start = val;
				obj = (object)val;
			}
			AssignStageToken.Start -= (hook_Start)obj;
			object obj2 = <>O.<1>__TypewriteTextController_SetTypingTime;
			if (obj2 == null)
			{
				hook_SetTypingTime val2 = TypewriteTextController_SetTypingTime;
				<>O.<1>__TypewriteTextController_SetTypingTime = val2;
				obj2 = (object)val2;
			}
			TypewriteTextController.SetTypingTime -= (hook_SetTypingTime)obj2;
			ILHook typewriteTextController_SetTypingTime_UpdateCurrentLabel_Hook = TypewriteTextController_SetTypingTime_UpdateCurrentLabel_Hook;
			if (typewriteTextController_SetTypingTime_UpdateCurrentLabel_Hook != null)
			{
				typewriteTextController_SetTypingTime_UpdateCurrentLabel_Hook.Dispose();
			}
			TypewriteTextController_SetTypingTime_UpdateCurrentLabel_Hook = null;
		}

		private static void AssignStageToken_Start(orig_Start orig, AssignStageToken self)
		{
			((Component)self).gameObject.AddComponent<InvertTypewriterInfo>().InvertedLabels = (TextMeshProUGUI[])(object)new TextMeshProUGUI[2] { self.titleText, self.subtitleText };
			orig.Invoke(self);
		}

		private static void TypewriteTextController_SetTypingTime(orig_SetTypingTime orig, TypewriteTextController self, float typingTime)
		{
			InvertTypewriterInfo.Current = ((Component)self).GetComponent<InvertTypewriterInfo>();
			try
			{
				orig.Invoke(self, typingTime);
			}
			finally
			{
				InvertTypewriterInfo.Current = null;
			}
		}

		private static void TypewriteTextController_SetTypingTime_UpdateCurrentLabel(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ParameterDefinition val2 = null;
			TypeDefinition val3 = null;
			Enumerator<ParameterDefinition> enumerator = ((MethodReference)il.Method).Parameters.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					ParameterDefinition current = enumerator.Current;
					TypeReference elementType = ((ParameterReference)current).ParameterType.GetElementType();
					if (((MemberReference)elementType).Name.StartsWith("<>c__DisplayClass") && ((MemberReference)elementType).DeclaringType != null && Extensions.Is((MemberReference)(object)((MemberReference)elementType).DeclaringType, (MemberInfo)typeof(TypewriteTextController)))
					{
						TypeDefinition val4 = Extensions.SafeResolve(elementType);
						if (val4 != null)
						{
							val3 = val4;
							val2 = current;
							break;
						}
					}
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
			if (val2 == null)
			{
				Log.Error("Failed to find locals parameter", "X:\\Git\\RoR2\\MirroredStageVariants\\VS\\MirroredStageVariants\\Patches\\InvertTypewriteTextControllerPatch.cs", "TypewriteTextController_SetTypingTime_UpdateCurrentLabel", 97);
				return;
			}
			FieldDefinition val5 = Extensions.FindField(val3, "currentLabel");
			if (val5 == null || !Extensions.Is((MemberReference)(object)((FieldReference)val5).FieldType, (MemberInfo)typeof(TextMeshProUGUI)))
			{
				Log.Error("Failed to find currentLabel local field", "X:\\Git\\RoR2\\MirroredStageVariants\\VS\\MirroredStageVariants\\Patches\\InvertTypewriteTextControllerPatch.cs", "TypewriteTextController_SetTypingTime_UpdateCurrentLabel", 104);
			}
			else if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.DeclaredPropertySetter(typeof(TMP_Text), "maxVisibleCharacters"))
			}))
			{
				ILLabel val6 = val.DefineLabel();
				ILLabel val7 = val.DefineLabel();
				val.Emit(OpCodes.Ldarg, val2);
				val.Emit(OpCodes.Ldfld, (FieldReference)(object)val5);
				val.EmitDelegate<Func<TextMeshProUGUI, bool>>((Func<TextMeshProUGUI, bool>)shouldMirrorLabel);
				val.Emit(OpCodes.Brtrue, (object)val6);
				int index = val.Index;
				val.Index = index + 1;
				val.Emit(OpCodes.Br, (object)val7);
				val.MarkLabel(val6);
				val.MoveAfterLabels();
				val.EmitDelegate<Action<TMP_Text, int>>((Action<TMP_Text, int>)setVisibleCharactersMirrored);
				val.MarkLabel(val7);
			}
			else
			{
				Log.Error("Failed to find patch location", "X:\\Git\\RoR2\\MirroredStageVariants\\VS\\MirroredStageVariants\\Patches\\InvertTypewriteTextControllerPatch.cs", "TypewriteTextController_SetTypingTime_UpdateCurrentLabel", 142);
			}
			static void setVisibleCharactersMirrored(TMP_Text label, int maxVisibleCharacters)
			{
				label.firstVisibleCharacter = label.text.Length - maxVisibleCharacters;
			}
			static bool shouldMirrorLabel(TextMeshProUGUI label)
			{
				if (StageMirrorController.CurrentlyIsMirrored && Object.op_Implicit((Object)(object)InvertTypewriterInfo.Current))
				{
					return Array.IndexOf(InvertTypewriterInfo.Current.InvertedLabels, label) != -1;
				}
				return false;
			}
		}
	}
	internal static class MirrorAudioPatch
	{
		private delegate int SetObjectPositionDelegate(ulong akObjectId, Vector3 position, Vector3 forward, Vector3 up);

		private class AkObjectData
		{
			public readonly ulong Id;

			public readonly GameObject GameObject;

			public readonly AkGameObj AkObj;

			public Vector3 Position { get; private set; }

			public Vector3 Forward { get; private set; }

			public Vector3 Up { get; private set; }

			public AkObjectData(ulong id, GameObject gameObject)
			{
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Unknown result type (might be due to invalid IL or missing references)
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_005c: Unknown result type (might be due to invalid IL or missing references)
				//IL_008f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: Unknown result type (might be due to invalid IL or missing references)
				Id = id;
				GameObject = gameObject;
				AkObj = gameObject.GetComponent<AkGameObj>();
				Transform transform = gameObject.transform;
				Position = (Object.op_Implicit((Object)(object)AkObj) ? AkObj.GetPosition() : transform.position);
				Forward = (Object.op_Implicit((Object)(object)AkObj) ? AkObj.GetForward() : transform.forward);
				Up = (Object.op_Implicit((Object)(object)AkObj) ? AkObj.GetUpward() : transform.up);
			}

			private bool tryGetListenerMirrorTransformation(out Matrix4x4 mirrorTransform)
			{
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: 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_0078: Unknown result type (might be due to invalid IL or missing references)
				MirrorCamera mirrorCamera = default(MirrorCamera);
				foreach (AkAudioListener item in (Object.op_Implicit((Object)(object)AkObj) && !AkObj.IsUsingDefaultListeners) ? AkObj.ListenerList : ((BaseListenerList)AkAudioListener.DefaultListeners).ListenerList)
				{
					if (((Component)item).TryGetComponent<MirrorCamera>(ref mirrorCamera))
					{
						mirrorTransform = mirrorCamera.MirrorAroundCameraTransformation;
						return true;
					}
				}
				mirrorTransform = Matrix4x4.identity;
				return false;
			}

			public void UpdatePosition(Vector3 position, Vector3 forward, Vector3 up)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				Position = position;
				Forward = forward;
				Up = up;
			}

			public void GetMirrorPosition(out Vector3 position, out Vector3 forward, out Vector3 up)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0058: Unknown result type (might be due to invalid IL or missing references)
				//IL_005d: 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)
				position = Position;
				forward = Forward;
				up = Up;
				if (tryGetListenerMirrorTransformation(out var mirrorTransform))
				{
					position = ((Matrix4x4)(ref mirrorTransform)).MultiplyPoint(position);
					forward = ((Matrix4x4)(ref mirrorTransform)).MultiplyVector(forward);
					up = ((Matrix4x4)(ref mirrorTransform)).MultiplyVector(up);
				}
			}

			public AKRESULT UpdateMirrorPosition()
			{
				//IL_0036: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				GetMirrorPosition(out var position, out var forward, out var up);
				if (_origSetPosition == null)
				{
					Log.Error("Missing set position function", "X:\\Git\\RoR2\\MirroredStageVariants\\VS\\MirroredStageVariants\\Patches\\MirrorAudioPatch.cs", "UpdateMirrorPosition", 86);
					return (AKRESULT)2;
				}
				return (AKRESULT)_origSetPosition(Id, position, forward, up);
			}
		}

		private delegate void orig_AkSoundEngine_PostRegisterGameObjUserHook(AKRESULT result, GameObject gameObject, ulong id);

		private delegate void orig_AkSoundEngine_PostUnregisterGameObjUserHook(AKRESULT result, GameObject gameObject, ulong id);

		private delegate void orig_AkSoundEngine_ClearRegisteredGameObjects();

		private static SetObjectPositionDelegate _origSetPosition;

		private static readonly List<IDetour> _audioEngineHooks = new List<IDetour>();

		private static readonly Dictionary<ulong, AkObjectData> _akObjects = new Dictionary<ulong, AkObjectData>();

		public static void Apply()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_0059: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Expected O, but got Unknown
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Expected O, but got Unknown
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Expected O, but got Unknown
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Expected O, but got Unknown
			NativeDetour val = new NativeDetour((MethodBase)SymbolExtensions.GetMethodInfo((Expression<Action>)(() => AkSoundEnginePINVOKE.CSharp_SetObjectPosition(0uL, default(Vector3), default(Vector3), default(Vector3)))), (MethodBase)SymbolExtensions.GetMethodInfo((Expression<Action>)(() => AkSoundEngine_SetObjectPosition(0uL, default(Vector3), default(Vector3), default(Vector3)))));
			_origSetPosition = val.GenerateTrampoline<SetObjectPositionDelegate>();
			_audioEngineHooks.Add((IDetour)(object)val);
			_audioEngineHooks.Add((IDetour)new Hook((MethodBase)SymbolExtensions.GetMethodInfo((Expression<Action>)(() => AkSoundEngine.PostRegisterGameObjUserHook((AKRESULT)0, (GameObject)null, 0uL))), (Delegate)new Action<orig_AkSoundEngine_PostRegisterGameObjUserHook, AKRESULT, GameObject, ulong>(AkSoundEngine_PostRegisterGameObjUserHook)));
			_audioEngineHooks.Add((IDetour)new Hook((MethodBase)SymbolExtensions.GetMethodInfo((Expression<Action>)(() => AkSoundEngine.PostUnregisterGameObjUserHook((AKRESULT)0, (GameObject)null, 0uL))), (Delegate)new Action<orig_AkSoundEngine_PostUnregisterGameObjUserHook, AKRESULT, GameObject, ulong>(AkSoundEngine_PostUnregisterGameObjUserHook)));
			_audioEngineHooks.Add((IDetour)new Hook((MethodBase)SymbolExtensions.GetMethodInfo((Expression<Action>)(() => AkSoundEngine.ClearRegisteredGameObjects())), (Delegate)new Action<orig_AkSoundEngine_ClearRegisteredGameObjects>(AkSoundEngine_ClearRegisteredGameObjects)));
			MirrorCamera.OnMirrorTransformationChanged += onCameraMirrorTransformationChanged;
		}

		public static void Undo()
		{
			foreach (IDetour audioEngineHook in _audioEngineHooks)
			{
				((IDisposable)audioEngineHook)?.Dispose();
			}
			_audioEngineHooks.Clear();
			_origSetPosition = null;
			_akObjects.Clear();
			MirrorCamera.OnMirrorTransformationChanged -= onCameraMirrorTransformationChanged;
		}

		private static void onCameraMirrorTransformationChanged()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			foreach (AkObjectData value in _akObjects.Values)
			{
				value.UpdateMirrorPosition();
			}
		}

		private static void AkSoundEngine_PostRegisterGameObjUserHook(orig_AkSoundEngine_PostRegisterGameObjUserHook orig, AKRESULT result, GameObject gameObject, ulong id)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			orig(result, gameObject, id);
			if ((int)result == 1 && Object.op_Implicit((Object)(object)gameObject) && !_akObjects.ContainsKey(id))
			{
				_akObjects.Add(id, new AkObjectData(id, gameObject));
			}
		}

		private static void AkSoundEngine_PostUnregisterGameObjUserHook(orig_AkSoundEngine_PostUnregisterGameObjUserHook orig, AKRESULT result, GameObject gameObject, ulong id)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			orig(result, gameObject, id);
			if ((int)result == 1)
			{
				_akObjects.Remove(id);
			}
		}

		private static void AkSoundEngine_ClearRegisteredGameObjects(orig_AkSoundEngine_ClearRegisteredGameObjects orig)
		{
			orig();
			_akObjects.Clear();
		}

		private static int AkSoundEngine_SetObjectPosition(ulong akObjectId, Vector3 position, Vector3 forward, Vector3 up)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_0010: 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_0012: Unknown result type (might be due to invalid IL or missing references)
			if (_akObjects.TryGetValue(akObjectId, out var value))
			{
				value.UpdatePosition(position, forward, up);
				value.GetMirrorPosition(out position, out forward, out up);
			}
			return _origSetPosition(akObjectId, position, forward, up);
		}
	}
	internal class MirrorEffectsPatch
	{
		[SystemInitializer(new Type[] { typeof(EffectCatalog) })]
		private static void Init()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Invalid comparison between Unknown and I4
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			List<TMP_Text> list = new List<TMP_Text>();
			for (EffectIndex val = (EffectIndex)0; (int)val < EffectCatalog.effectCount; val = (EffectIndex)(val + 1))
			{
				EffectDef effectDef = EffectCatalog.GetEffectDef(val);
				if (effectDef == null)
				{
					continue;
				}
				GameObject prefab = effectDef.prefab;
				if (!Object.op_Implicit((Object)(object)prefab))
				{
					continue;
				}
				list.Clear();
				prefab.GetComponentsInChildren<TMP_Text>(list);
				foreach (TMP_Text item in list)
				{
					if (((Component)item).gameObject.layer == LayerIndex.uiWorldSpace.intVal && !Object.op_Implicit((Object)(object)((Component)item).GetComponent<MirrorTextLabelIfMirrored>()))
					{
						((Component)item).gameObject.AddComponent<MirrorTextLabelIfMirrored>();
					}
				}
			}
		}
	}
}
namespace MirroredStageVariants.ModCompatibility
{
	internal static class RiskOfOptionsCompat
	{
		public static bool IsEnabled => Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");

		[MethodImpl(MethodImplOptions.NoInlining)]
		public static void AddConfigOptions()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Expected O, but got Unknown
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			ModSettingsManager.AddOption((BaseOption)new StepSliderOption(Main.MirrorChance, new StepSliderConfig
			{
				formatString = "{0}%",
				min = 0f,
				max = 100f,
				increment = 0.1f
			}), "Gorakh.MirroredStageVariants", "Mirrored Stage Variants");
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(Main.MirrorNonStages), "Gorakh.MirroredStageVariants", "Mirrored Stage Variants");
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(Main.MirrorHiddenRealms), "Gorakh.MirroredStageVariants", "Mirrored Stage Variants");
			ModSettingsManager.SetModDescription("Options for Mirrored Stage Variants", "Gorakh.MirroredStageVariants", "Mirrored Stage Variants");
			FileInfo fileInfo = null;
			DirectoryInfo directoryInfo = new DirectoryInfo(Path.GetDirectoryName(((BaseUnityPlugin)Main.Instance).Info.Location));
			do
			{
				FileInfo[] files = directoryInfo.GetFiles("icon.png", SearchOption.TopDirectoryOnly);
				if (files != null && files.Length != 0)
				{
					fileInfo = files[0];
					break;
				}
				directoryInfo = directoryInfo.Parent;
			}
			while (directoryInfo != null && directoryInfo.Exists && !string.Equals(directoryInfo.Name, "plugins", StringComparison.OrdinalIgnoreCase));
			if (fileInfo != null)
			{
				Texture2D val = new Texture2D(256, 256);
				if (ImageConversion.LoadImage(val, File.ReadAllBytes(fileInfo.FullName)))
				{
					Sprite obj = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
					((Object)obj).name = "MirroredStageVariantsIcon";
					ModSettingsManager.SetModIcon(obj, "Gorakh.MirroredStageVariants", "Mirrored Stage Variants");
				}
			}
		}
	}
}
namespace MirroredStageVariants.Components
{
	[DisallowMultipleComponent]
	public class FlipParticleSystemIfMirrored : MonoBehaviour
	{
		private ParticleSystemRenderer _particleRenderer;

		private bool _isFlipped;

		private void Awake()
		{
			_particleRenderer = ((Component)this).GetComponent<ParticleSystemRenderer>();
		}

		private void OnEnable()
		{
			updateIsFlipped();
		}

		private void FixedUpdate()
		{
			updateIsFlipped();
		}

		private void updateIsFlipped()
		{
			bool currentlyIsMirrored = StageMirrorController.CurrentlyIsMirrored;
			setFlipped(currentlyIsMirrored);
		}

		private void setFlipped(bool flipped)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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)
			if (_isFlipped != flipped)
			{
				_isFlipped = flipped;
				if (Object.op_Implicit((Object)(object)_particleRenderer))
				{
					Vector3 flip = _particleRenderer.flip;
					flip.x = (_isFlipped ? 1f : 0f);
					_particleRenderer.flip = flip;
				}
			}
		}
	}
	internal class MirrorCamera : MonoBehaviour
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_Awake <>9__0_0;

			internal void <Init>b__0_0(orig_Awake orig, SceneCamera self)
			{
				orig.Invoke(self);
				((Component)self).gameObject.AddComponent<MirrorCamera>();
			}
		}

		private Matrix4x4 _mirrorAroundCameraTransformation = Matrix4x4.identity;

		public Matrix4x4 MirrorAroundCameraTransformation
		{
			get
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				return _mirrorAroundCameraTransformation;
			}
			private set
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				if (!((Matrix4x4)(ref _mirrorAroundCameraTransformation)).Equals(value))
				{
					_mirrorAroundCameraTransformation = value;
					MirrorCamera.OnMirrorTransformationChanged?.Invoke();
				}
			}
		}

		public static event Action OnMirrorTransformationChanged;

		[SystemInitializer(new Type[] { })]
		private static void Init()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			object obj = <>c.<>9__0_0;
			if (obj == null)
			{
				hook_Awake val = delegate(orig_Awake orig, SceneCamera self)
				{
					orig.Invoke(self);
					((Component)self).gameObject.AddComponent<MirrorCamera>();
				};
				<>c.<>9__0_0 = val;
				obj = (object)val;
			}
			SceneCamera.Awake += (hook_Awake)obj;
		}

		private void OnEnable()
		{
			recalculateMirrorTransformation();
		}

		private void Update()
		{
			recalculateMirrorTransformation();
		}

		private void recalculateMirrorTransformation()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			if (StageMirrorController.CurrentlyIsMirrored)
			{
				MirrorAroundCameraTransformation = ((Component)this).transform.GlobalTransformationFromLocal(Matrix4x4.Scale(new Vector3(-1f, 1f, 1f)));
			}
			else
			{
				MirrorAroundCameraTransformation = Matrix4x4.identity;
			}
		}

		private void OnRenderImage(RenderTexture source, RenderTexture destination)
		{
			Material mirrorMaterial = Assets.MirrorMaterial;
			if (StageMirrorController.CurrentlyIsMirrored && Object.op_Implicit((Object)(object)mirrorMaterial))
			{
				Graphics.Blit((Texture)(object)source, destination, mirrorMaterial);
			}
			else
			{
				Graphics.Blit((Texture)(object)source, destination);
			}
		}
	}
	[DisallowMultipleComponent]
	public class MirrorTextLabelIfMirrored : MonoBehaviour
	{
		private bool _isRenderingAsMirrored;

		private Vector3 _originalScale;

		private void OnEnable()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			CameraEvents.OnPreRender += new CameraCallback(onPreRender);
			CameraEvents.OnPostRender += new CameraCallback(onPostRender);
		}

		private void OnDisable()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			CameraEvents.OnPreRender -= new CameraCallback(onPreRender);
			CameraEvents.OnPostRender -= new CameraCallback(onPostRender);
		}

		private void onPreRender(Camera cam)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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)
			_isRenderingAsMirrored = cam.ShouldRenderObjectAsMirrored(((Component)this).gameObject);
			if (_isRenderingAsMirrored)
			{
				_originalScale = ((Component)this).transform.localScale;
				Vector3 originalScale = _originalScale;
				originalScale.x *= -1f;
				((Component)this).transform.localScale = originalScale;
			}
		}

		private void onPostRender(Camera cam)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			if (_isRenderingAsMirrored)
			{
				((Component)this).transform.localScale = _originalScale;
				_isRenderingAsMirrored = false;
			}
		}
	}
	[DefaultExecutionOrder(-1)]
	public class ScaleOnAwakeIfMirrored : MonoBehaviour
	{
		public Vector3 ScaleMultiplier = Vector3.one;

		private void Awake()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//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)
			if (StageMirrorController.CurrentlyIsMirrored)
			{
				((Component)this).transform.localScale = Vector3.Scale(((Component)this).transform.localScale, ScaleMultiplier);
			}
		}
	}
	public class StageMirrorController : MonoBehaviour
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_OnEnable <>9__0_0;

			internal void <Init>b__0_0(orig_OnEnable orig, Stage self)
			{
				orig.Invoke(self);
				if (!Object.op_Implicit((Object)(object)((Component)self).GetComponent<StageMirrorController>()))
				{
					((Component)self).gameObject.AddComponent<StageMirrorController>();
				}
			}
		}

		private static StageMirrorController _instance;

		public static StageMirrorController Instance => _instance;

		public static bool CurrentlyIsMirrored
		{
			get
			{
				if (!CanMirrorScene(SceneCatalog.mostRecentSceneDef))
				{
					return false;
				}
				if (!Object.op_Implicit((Object)(object)_instance))
				{
					return Main.MirrorNonStages.Value;
				}
				if (Commands.OverrideStageIsMirrored.HasValue)
				{
					return Commands.OverrideStageIsMirrored.Value;
				}
				return _instance.IsMirrored;
			}
		}

		public bool IsMirrored { get; private set; }

		[SystemInitializer(new Type[] { })]
		private static void Init()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			object obj = <>c.<>9__0_0;
			if (obj == null)
			{
				hook_OnEnable val = delegate(orig_OnEnable orig, Stage self)
				{
					orig.Invoke(self);
					if (!Object.op_Implicit((Object)(object)((Component)self).GetComponent<StageMirrorController>()))
					{
						((Component)self).gameObject.AddComponent<StageMirrorController>();
					}
				};
				<>c.<>9__0_0 = val;
				obj = (object)val;
			}
			Stage.OnEnable += (hook_OnEnable)obj;
		}

		public static bool CanMirrorScene(SceneDef scene)
		{
			if (!Object.op_Implicit((Object)(object)scene))
			{
				return false;
			}
			string cachedName = scene.cachedName;
			if (cachedName == "lobby" || cachedName == "logbook")
			{
				return false;
			}
			if (Main.MirrorHiddenRealms.Value)
			{
				return true;
			}
			if (scene.stageOrder > 0)
			{
				return scene.stageOrder <= Run.stagesPerLoop;
			}
			return false;
		}

		private void OnEnable()
		{
			SingletonHelper.Assign<StageMirrorController>(ref _instance, this);
		}

		private void OnDisable()
		{
			SingletonHelper.Unassign<StageMirrorController>(ref _instance, this);
		}

		private void Awake()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			Xoroshiro128Plus val = RoR2Application.rng;
			Run instance = Run.instance;
			if (Object.op_Implicit((Object)(object)instance))
			{
				val = new Xoroshiro128Plus(((NetworkServer.active && NetworkServer.dontListen) ? instance.seed : ((ulong)instance.NetworkstartTimeUtc._binaryValue)) ^ Hash128.Compute(SceneCatalog.mostRecentSceneDef.cachedName).u64_0);
				for (int i = 0; i < instance.stageClearCount; i++)
				{
					val.Next();
				}
			}
			IsMirrored = val.nextNormalizedFloat <= Main.MirrorChance.Value / 100f;
		}
	}
}