Decompiled source of BillionNemesis v1.2.0

BillionNemesis.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using BillionNemesis.Func;
using Configgy;
using Discord;
using HarmonyLib;
using Logic;
using Microsoft.CodeAnalysis;
using SpawnerArmExtras;
using Steamworks;
using TMPro;
using ULTRAKILL.Cheats;
using ULTRAKILL.Enemy;
using ULTRAKILL.Portal;
using ULTRAKILL.Portal.Geometry;
using Unity.AI.Navigation;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.AddressableAssets;
using UnityEngine.Animations.Rigging;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BillionNemesis")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.2.0+226148a6e036e54b0ef5078efa0cfa518c16aceb")]
[assembly: AssemblyProduct("Billion Nemesis")]
[assembly: AssemblyTitle("BillionNemesis")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.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 BillionNemesis
{
	[BepInPlugin("billy.billionnemesis", "Billion Nemesis", "1.2.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private ConfigBuilder config;

		[Configgable("", "Enable Billion Nemesis", 0, "Lets you enable or disable the custom enemy encounters. If you're currently in a level, changing this will require a level restart")]
		public static ConfigToggle IsEnabled = new ConfigToggle(true);

		public static bool IsPatched = false;

		public const string NemesisColorHex = "ff00af";

		public static bool ForceDefaultLevelPath = false;

		public static Dictionary<string, Transform> ObjectsLookedUpThisScene = new Dictionary<string, Transform>();

		public static bool DisableEnemyVertexLighting = false;

		private static readonly Harmony Harmony = new Harmony("billy.billionnemesis");

		internal static ManualLogSource Logger;

		public void Awake()
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Harmony.PatchAll();
			Logger.LogInfo((object)"Plugin BillionNemesis is almost loaded!");
			SceneManager.activeSceneChanged += SceneManagerActiveSceneChanged;
			SceneManager.sceneLoaded += SceneManagerSceneLoaded;
			LevelAssets.GetAssets();
			config = new ConfigBuilder("billy.billionnemesis", "Billion Nemesis");
			ConfigToggle isEnabled = IsEnabled;
			((ConfigValueElement<bool>)(object)isEnabled).OnValueChanged = (Action<bool>)Delegate.Combine(((ConfigValueElement<bool>)(object)isEnabled).OnValueChanged, new Action<bool>(EnabledValueChanged));
			config.BuildAll();
			Logger.LogInfo((object)"Plugin BillionNemesis is loadedest!");
		}

		public static void EnabledValueChanged(bool v)
		{
			RankStuff.UpdateRanksAndColors();
			ChangeMainMenuTitle();
		}

		public static void SceneManagerActiveSceneChanged(Scene arg0, Scene arg1)
		{
			ResetSceneVariables();
			if (Util.IsEnabled())
			{
				LevelPatching.TryRunLevelPatch();
			}
		}

		public static void ResetSceneVariables()
		{
			IsPatched = false;
			ObjectsLookedUpThisScene = new Dictionary<string, Transform>();
			DisableEnemyVertexLighting = false;
			TeleportOnCondition.GlobalConditions = new Dictionary<int, List<TeleportCondition>>();
			VariableDelay.AllDelays = new Dictionary<string, float>();
		}

		public static void SceneManagerSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			ChangeMainMenuTitle();
			if (SceneHelper.CurrentScene != "Bootstrap" && SceneHelper.CurrentScene != "Intro" && SceneHelper.CurrentScene != "Main Menu")
			{
				SpawnMenuPatch.MakeAllSpawnables();
			}
			LevelAssets.SetUpCustomEnemyPlaceholders();
		}

		public static void ChangeMainMenuTitle()
		{
			if (SceneHelper.CurrentScene != "Main Menu")
			{
				return;
			}
			string text = "\n<color=#ff00af>(NEMESIS)</color>";
			Transform val = GeneralFuncs.FindInactive("Canvas/Chapter Select/Title (2)");
			TextMeshProUGUI val2 = ((val != null) ? ((Component)val).GetComponent<TextMeshProUGUI>() : null);
			if ((Object)(object)val2 == (Object)null)
			{
				return;
			}
			if (Util.IsEnabled())
			{
				if (!((TMP_Text)val2).text.Contains(text))
				{
					((TMP_Text)val2).text = ((TMP_Text)val2).text + text;
					((TMP_Text)val2).verticalAlignment = (VerticalAlignmentOptions)256;
				}
			}
			else
			{
				((TMP_Text)val2).text = ((TMP_Text)val2).text.Replace(text, "");
				((TMP_Text)val2).verticalAlignment = (VerticalAlignmentOptions)512;
			}
		}
	}
	public static class ChangedInfo
	{
		public static string[] ChangedChapters = new string[1] { "Prelude" };

		public static string[] ChangedLayers = new string[2] { "Overture", "Layer 1 Limbo" };

		public static int[] ChangedLevels = new int[9] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };

		public static string[] ChangedLevelScenes = new string[9] { "Level 0-1", "Level 0-2", "Level 0-3", "Level 0-4", "Level 0-5", "Level 1-1", "Level 1-2", "Level 1-3", "Level 1-4" };

		public static int[] LevelsWithoutSecrets = new int[2] { 5, 9 };

		public static Dictionary<int, float> LevelTitleLineSpacing = new Dictionary<int, float>();

		public static Dictionary<string, string> NewLevelNames = new Dictionary<string, string>
		{
			["INTO THE FIRE"] = "UNTO THE CORE",
			["THE MEATGRINDER"] = "THE BACKBURNER",
			["DOUBLE DOWN"] = "<size=150%>UP</size> THE ANTE",
			["A ONE-MACHINE ARMY"] = "DELTA P",
			["CERBERUS"] = "the Kiln",
			["HEART OF THE SUNRISE"] = "HARMED TO DEMISE",
			["THE BURNING WORLD"] = "BLOOD ON THE LEAVES",
			["HALLS OF SACRED REMAINS"] = "DANCE OF THE KNIGHTS",
			["CLAIR DE LUNE"] = "O FORTUNA"
		};

		public static Dictionary<string, string> PlainLevelNames = new Dictionary<string, string> { ["<size=150%>UP</size> THE ANTE"] = "UP THE ANTE" };
	}
	public class DontCatch : MonoBehaviour
	{
	}
	public class DontEnrage : MonoBehaviour
	{
	}
	[HarmonyPatch(typeof(Drone), "Enrage")]
	public class DroneDontEnragePatch
	{
		public static bool Prefix(Drone __instance)
		{
			DontEnrage component = ((Component)__instance).GetComponent<DontEnrage>();
			if ((Object)(object)component != (Object)null && ((Behaviour)component).enabled)
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(V2), "Enrage", new Type[] { typeof(string) })]
	public class V2DontEnragePatch
	{
		public static bool Prefix(string enrageName, V2 __instance)
		{
			DontEnrage component = ((Component)__instance).GetComponent<DontEnrage>();
			if ((Object)(object)component != (Object)null && ((Behaviour)component).enabled)
			{
				return false;
			}
			return true;
		}
	}
	public class EnemyBlockBreakables : MonoBehaviour
	{
		public EnemyIdentifier eid;

		public void Awake()
		{
			eid = ((Component)this).GetComponent<EnemyIdentifier>();
		}

		public void Start()
		{
			BreakableAllower[] array = Object.FindObjectsByType<BreakableAllower>((FindObjectsInactive)1, (FindObjectsSortMode)0);
			BreakableAllower[] array2 = array;
			foreach (BreakableAllower breakableAllower in array2)
			{
				breakableAllower.enemyBlocks.Add(this);
			}
		}
	}
	public class MoveTo : MonoBehaviour
	{
		public float speed = 20f;

		public Transform targetTransform = null;

		public bool removeOnDeath = true;

		public float delay = -1f;

		public float delayProgress = 0f;

		public bool moveX = true;

		public bool moveY = true;

		public bool moveZ = true;

		public float targetX = 0f;

		public float targetY = 0f;

		public float targetZ = 0f;

		public MoveTo MoveXYZ(bool moveX = true, bool moveY = true, bool moveZ = true)
		{
			this.moveX = moveX;
			this.moveY = moveY;
			this.moveZ = moveZ;
			return this;
		}

		public MoveTo TargetXYZ(float targetX = 0f, float targetY = 0f, float targetZ = 0f)
		{
			this.targetX = targetX;
			this.targetY = targetY;
			this.targetZ = targetZ;
			return this;
		}

		public void Update()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)targetTransform == (Object)null))
			{
				if (delayProgress < delay)
				{
					delayProgress += Time.deltaTime;
					return;
				}
				Vector3 position = targetTransform.position;
				targetTransform.position = new Vector3(moveX ? Mathf.MoveTowards(position.x, targetX, speed * Time.deltaTime) : position.x, moveY ? Mathf.MoveTowards(position.y, targetY, speed * Time.deltaTime) : position.y, moveZ ? Mathf.MoveTowards(position.z, targetZ, speed * Time.deltaTime) : position.z);
			}
		}

		public void Start()
		{
			SaveForPuppet();
		}

		public void SaveForPuppet()
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			EnemyIdentifier componentInChildren = ((Component)this).GetComponentInChildren<EnemyIdentifier>();
			if ((Object)(object)componentInChildren == (Object)null)
			{
				return;
			}
			GameObject[] activateOnDeath = componentInChildren.activateOnDeath;
			foreach (GameObject val in activateOnDeath)
			{
				if (((Object)val).name == "MoveTo")
				{
					return;
				}
			}
			GameObject val2 = new GameObject("MoveTo");
			MoveTo newMover = val2.AddComponent<MoveTo>();
			CopyValuesTo(newMover);
			Util.ArrayAdd(ref componentInChildren.activateOnDeath, val2);
		}

		public void CopyValuesTo(MoveTo newMover)
		{
			newMover.speed = speed;
			newMover.targetTransform = targetTransform;
			newMover.removeOnDeath = removeOnDeath;
			newMover.MoveXYZ(moveX, moveY, moveZ);
			newMover.TargetXYZ(targetX, targetY, targetZ);
		}
	}
	[HarmonyPatch(typeof(EnemyIdentifier), "ProcessDeath")]
	public class DeathPatch
	{
		public static void Prefix(EnemyIdentifier __instance)
		{
			MoveTo component = ((Component)__instance).GetComponent<MoveTo>();
			if ((Object)(object)component != (Object)null && component.removeOnDeath)
			{
				Object.Destroy((Object)(object)component);
			}
		}
	}
	public class NemesisEnemy
	{
		private Transform _transform;

		public EnemyIdentifier eid = null;

		public Enemy enemy = null;

		public Transform transform
		{
			get
			{
				return _transform;
			}
			set
			{
				_transform = value;
				name = ((Object)value).name;
				UpdateEidAndEnemy();
			}
		}

		public GameObject gameObject
		{
			get
			{
				return ((Component)_transform).gameObject;
			}
			set
			{
				transform = value.transform;
			}
		}

		public Transform parent
		{
			get
			{
				return _transform.parent;
			}
			set
			{
				_transform.parent = value;
			}
		}

		public string name
		{
			get
			{
				return ((Object)_transform).name;
			}
			set
			{
				((Object)_transform).name = value;
			}
		}

		public NemesisEnemy(Transform newTransform)
		{
			transform = newTransform;
		}

		public NemesisEnemy(GameObject newGameObject)
		{
			gameObject = newGameObject;
		}

		public void UpdateEidAndEnemy()
		{
			eid = ((Component)transform).GetComponentInChildren<EnemyIdentifier>(true);
			enemy = ((Component)transform).GetComponentInChildren<Enemy>(true);
		}
	}
	public class ParentPuppetTo : MonoBehaviour
	{
		public string objectName = "";

		public void Start()
		{
			SaveForPuppet();
		}

		public void SaveForPuppet()
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			EnemyIdentifier componentInChildren = ((Component)this).GetComponentInChildren<EnemyIdentifier>();
			if ((Object)(object)componentInChildren == (Object)null)
			{
				return;
			}
			GameObject[] activateOnDeath = componentInChildren.activateOnDeath;
			foreach (GameObject val in activateOnDeath)
			{
				if (((Object)val).name == "ParentPuppetTo")
				{
					return;
				}
			}
			GameObject val2 = new GameObject("ParentPuppetTo");
			ParentPuppetTo parentPuppetTo = val2.AddComponent<ParentPuppetTo>();
			parentPuppetTo.objectName = objectName;
			Util.ArrayAdd(ref componentInChildren.activateOnDeath, val2);
		}
	}
	public class PowerStayClose : MonoBehaviour
	{
		public float distanceLimit = 22.5f;
	}
	[HarmonyPatch(typeof(Power), "FixedUpdate")]
	public class PowerStayClosePatch
	{
		public static void Postfix(Power __instance)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			PowerStayClose component = ((Component)__instance).GetComponent<PowerStayClose>();
			if (!((Object)(object)component == (Object)null) && !(Vector3.Distance(((Component)__instance).transform.position, ((Component)MonoSingleton<NewMovement>.Instance).transform.position) <= component.distanceLimit))
			{
				__instance.Teleport(true, false, false, false, false, true);
			}
		}
	}
	public class StatueSpeed : MonoBehaviour
	{
		public float multiplier = 1.2f;
	}
	[HarmonyPatch(typeof(StatueFake), "Start")]
	public class StatueFakePatch
	{
		public static void Postfix(StatueFake __instance)
		{
			StatueSpeed component = ((Component)__instance).GetComponent<StatueSpeed>();
			if (!((Object)(object)component == (Object)null))
			{
				Animator anim = __instance.anim;
				anim.speed *= component.multiplier;
			}
		}
	}
	public class StopEnemyMovement : MonoBehaviour
	{
		public bool stopWalking = false;

		public bool stopDashing = true;

		public NavMeshAgent nma;

		public static bool CheckDash(Component __instance)
		{
			StopEnemyMovement component = __instance.GetComponent<StopEnemyMovement>();
			if (component != null && ((Behaviour)component).enabled && component != null && component.stopDashing)
			{
				return false;
			}
			return true;
		}

		public void Awake()
		{
			nma = ((Component)this).GetComponent<NavMeshAgent>();
		}

		public void Start()
		{
			SaveForPuppet();
		}

		public void SaveForPuppet()
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			EnemyIdentifier component = ((Component)this).GetComponent<EnemyIdentifier>();
			if ((Object)(object)component == (Object)null)
			{
				return;
			}
			GameObject[] activateOnDeath = component.activateOnDeath;
			foreach (GameObject val in activateOnDeath)
			{
				if (((Object)val).name == "StopEnemyMovement")
				{
					return;
				}
			}
			GameObject val2 = new GameObject("StopEnemyMovement");
			StopEnemyMovement newStopper = val2.AddComponent<StopEnemyMovement>();
			CopyValuesTo(newStopper);
			Util.ArrayAdd(ref component.activateOnDeath, val2);
		}

		public void FixedUpdate()
		{
			if (stopWalking && (Object)(object)nma != (Object)null && ((Behaviour)nma).enabled)
			{
				((Behaviour)nma).enabled = false;
			}
		}

		public void CopyValuesTo(StopEnemyMovement newStopper)
		{
			newStopper.stopWalking = stopWalking;
			newStopper.stopDashing = stopDashing;
		}
	}
	[HarmonyPatch(typeof(StatueBoss))]
	public class CerberusMovementPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(StatueBoss), "Tackle")]
		[HarmonyPriority(700)]
		public static bool TacklePrefix(StatueBoss __instance)
		{
			//IL_001e: 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)
			bool flag = StopEnemyMovement.CheckDash((Component)(object)__instance);
			if (!flag)
			{
				__instance.inAction = true;
				if (Vector3.Distance(((Component)__instance).transform.position, __instance.targetPlanePos) >= 9f)
				{
					__instance.Throw();
				}
				else
				{
					__instance.Stomp();
				}
			}
			return flag;
		}
	}
	[HarmonyPatch(typeof(Drone))]
	public class DroneMovementPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(Drone), "Dodge", new Type[] { typeof(Vector3) })]
		[HarmonyPriority(700)]
		public static bool DodgePrefix(Drone __instance)
		{
			return StopEnemyMovement.CheckDash((Component)(object)__instance);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Drone), "ProcessTargeting")]
		[HarmonyPriority(700)]
		public static bool ProcessTargetingPrefix(Drone __instance)
		{
			return StopEnemyMovement.CheckDash((Component)(object)__instance);
		}
	}
	public class TeleportOnCondition : MonoBehaviour
	{
		public bool processPassively = false;

		public bool processIfEnemyDead = false;

		public bool onDeadcaught = true;

		public bool returnOnFirstSuccess = false;

		public TeleportCondition[] conditions = Array.Empty<TeleportCondition>();

		public EnemyIdentifier eid = null;

		public int globalConditionKey = -1;

		public static Dictionary<int, List<TeleportCondition>> GlobalConditions = new Dictionary<int, List<TeleportCondition>>();

		public void Configure(bool processPassively = true, bool processIfEnemyDead = false, bool onDeadcaught = true, bool returnOnFirstSuccess = false)
		{
			this.processPassively = processPassively;
			this.processIfEnemyDead = processIfEnemyDead;
			this.onDeadcaught = onDeadcaught;
			this.returnOnFirstSuccess = returnOnFirstSuccess;
		}

		public TeleportCondition AddCondition(Vector3 moveVector, bool isMoveVectorAbsolute = false, bool ignoreAbsoluteMoveVectorZeroAxes = false)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			TeleportCondition teleportCondition = new TeleportCondition(moveVector, isMoveVectorAbsolute, ignoreAbsoluteMoveVectorZeroAxes);
			Util.ArrayAdd(ref conditions, teleportCondition);
			if (globalConditionKey != -1)
			{
				if (!GlobalConditions.ContainsKey(globalConditionKey))
				{
					GlobalConditions[globalConditionKey] = new List<TeleportCondition>();
				}
				GlobalConditions[globalConditionKey].Add(teleportCondition);
			}
			return teleportCondition;
		}

		public void Awake()
		{
			eid = ((Component)this).GetComponentInChildren<EnemyIdentifier>();
			ReaddConditionsToClonedEnemy();
		}

		public void ReaddConditionsToClonedEnemy()
		{
			if (globalConditionKey != -1 && GlobalConditions.ContainsKey(globalConditionKey) && GlobalConditions[globalConditionKey] != null)
			{
				Util.ArrayAdd(ref conditions, GlobalConditions[globalConditionKey].ToArray());
				ChangeAxisTargetsToPuppet(conditions, ((Component)this).transform);
			}
		}

		public void Start()
		{
			SaveForPuppet();
		}

		public void SaveForPuppet()
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			if ((Object)(object)eid == (Object)null)
			{
				return;
			}
			GameObject[] activateOnDeath = eid.activateOnDeath;
			foreach (GameObject val in activateOnDeath)
			{
				if (((Object)val).name == "TeleportOnCondition")
				{
					return;
				}
			}
			GameObject val2 = new GameObject("TeleportOnCondition");
			TeleportOnCondition newTeleport = val2.AddComponent<TeleportOnCondition>();
			CopyValuesTo(newTeleport);
			Util.ArrayAdd(ref eid.activateOnDeath, val2);
		}

		public void FixedUpdate()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			bool flag = !processIfEnemyDead && ((Object)(object)eid == (Object)null || eid.dead);
			if (!(!processPassively || flag))
			{
				((Component)this).transform.position = CheckConditions(((Component)this).transform.position, conditions, returnOnFirstSuccess);
			}
		}

		public static Vector3 CheckConditions(Vector3 moveTargetPosition, TeleportCondition[] conditions, bool returnOnFirstSuccess = false)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			foreach (TeleportCondition teleportCondition in conditions)
			{
				if (teleportCondition != null && teleportCondition.CheckCondition())
				{
					moveTargetPosition = Teleport(teleportCondition, moveTargetPosition);
					if (returnOnFirstSuccess)
					{
						return moveTargetPosition;
					}
				}
			}
			return moveTargetPosition;
		}

		public static Vector3 Teleport(TeleportCondition condition, Vector3 moveTargetPosition)
		{
			//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_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_001f: 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_003a: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_0094: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			Vector3 moveVector = condition.moveVector;
			if (!condition.isMoveVectorAbsolute)
			{
				moveTargetPosition += moveVector;
				return moveTargetPosition;
			}
			if (!condition.ignoreAbsoluteMoveVectorZeroAxes)
			{
				moveTargetPosition = moveVector;
				return moveTargetPosition;
			}
			((Vector3)(ref moveTargetPosition))..ctor((moveVector.x != 0f) ? moveVector.x : moveTargetPosition.x, (moveVector.y != 0f) ? moveVector.y : moveTargetPosition.y, (moveVector.z != 0f) ? moveVector.z : moveTargetPosition.z);
			return moveTargetPosition;
		}

		public static void ChangeAxisTargetsToPuppet(TeleportCondition[] conditions, Transform puppet)
		{
			foreach (TeleportCondition teleportCondition in conditions)
			{
				TeleportConditionAxis[] conditionAxes = teleportCondition.conditionAxes;
				foreach (TeleportConditionAxis teleportConditionAxis in conditionAxes)
				{
					if (teleportConditionAxis.canChangeTargetToPuppet)
					{
						teleportConditionAxis.checkTarget = puppet;
					}
				}
			}
		}

		public void CopyValuesTo(TeleportOnCondition newTeleport)
		{
			newTeleport.Configure(processPassively, processIfEnemyDead, onDeadcaught, returnOnFirstSuccess);
			newTeleport.conditions = conditions;
			newTeleport.eid = eid;
		}
	}
	public class TeleportCondition
	{
		public TeleportConditionAxis[] conditionAxes = Array.Empty<TeleportConditionAxis>();

		public Vector3 moveVector = Vector3.zero;

		public bool isMoveVectorAbsolute = false;

		public bool ignoreAbsoluteMoveVectorZeroAxes = false;

		public bool Success { get; private set; }

		public TeleportCondition(Vector3 moveVector, bool isMoveVectorAbsolute = false, bool ignoreAbsoluteMoveVectorZeroAxes = false)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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)
			Success = false;
			this.moveVector = moveVector;
			this.isMoveVectorAbsolute = isMoveVectorAbsolute;
			this.ignoreAbsoluteMoveVectorZeroAxes = ignoreAbsoluteMoveVectorZeroAxes;
		}

		public TeleportConditionAxis AddAxis(Transform checkTarget, char axis = 'y', float value = -25f, bool greater = false, bool orEqual = true, bool useLastTargetPositionIfNull = true, bool canChangeTargetToPuppet = true)
		{
			TeleportConditionAxis teleportConditionAxis = new TeleportConditionAxis(checkTarget, axis, value, greater, orEqual, useLastTargetPositionIfNull, canChangeTargetToPuppet);
			Util.ArrayAdd(ref conditionAxes, teleportConditionAxis);
			return teleportConditionAxis;
		}

		public bool CheckCondition()
		{
			TeleportConditionAxis[] array = conditionAxes;
			foreach (TeleportConditionAxis teleportConditionAxis in array)
			{
				if (teleportConditionAxis != null && !teleportConditionAxis.CheckAxis())
				{
					Success = false;
					return Success;
				}
			}
			Success = true;
			return Success;
		}
	}
	public class TeleportConditionAxis
	{
		public Transform checkTarget;

		public Vector3 lastTargetPosition;

		public char axis = 'y';

		public float value = -25f;

		public bool greater = false;

		public bool orEqual = true;

		public bool useLastTargetPositionIfNull = true;

		public bool canChangeTargetToPuppet = true;

		public bool Success { get; private set; }

		public TeleportConditionAxis(Transform checkTarget, char axis = 'y', float value = -25f, bool greater = false, bool orEqual = true, bool useLastTargetPositionIfNull = true, bool canChangeTargetToPuppet = true)
		{
			Success = false;
			this.checkTarget = checkTarget;
			this.axis = axis;
			this.value = value;
			this.greater = greater;
			this.orEqual = orEqual;
			this.useLastTargetPositionIfNull = useLastTargetPositionIfNull;
			this.canChangeTargetToPuppet = canChangeTargetToPuppet;
			if (axis != 'x' && axis != 'y' && axis != 'z')
			{
				Plugin.Logger.LogWarning((object)$"(new) TeleportConditionAxis must have axis 'x', 'y' or 'z', not {axis}. Resetting to 'y'");
				this.axis = 'y';
			}
		}

		public bool CheckAxis()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)checkTarget == (Object)null && !useLastTargetPositionIfNull)
			{
				return false;
			}
			if ((Object)(object)checkTarget != (Object)null)
			{
				lastTargetPosition = checkTarget.position;
			}
			bool success;
			switch (axis)
			{
			case 'x':
				success = CheckX();
				break;
			case 'y':
				success = CheckY();
				break;
			case 'z':
				success = CheckZ();
				break;
			default:
				Plugin.Logger.LogWarning((object)$"(FixedUpdate) TeleportConditionAxis must have axis 'x', 'y' or 'z', not {axis}. Resetting to 'y'");
				axis = 'y';
				success = CheckY();
				break;
			}
			Success = success;
			return Success;
		}

		public bool CheckX()
		{
			bool flag = ((!greater) ? (lastTargetPosition.x < value) : (lastTargetPosition.x > value));
			if (orEqual)
			{
				flag = flag || lastTargetPosition.x == value;
			}
			return flag;
		}

		public bool CheckY()
		{
			bool flag = ((!greater) ? (lastTargetPosition.y < value) : (lastTargetPosition.y > value));
			if (orEqual)
			{
				flag = flag || lastTargetPosition.y == value;
			}
			return flag;
		}

		public bool CheckZ()
		{
			bool flag = ((!greater) ? (lastTargetPosition.z < value) : (lastTargetPosition.z > value));
			if (orEqual)
			{
				flag = flag || lastTargetPosition.z == value;
			}
			return flag;
		}
	}
	public class TeleportToPlayer : MonoBehaviour
	{
		public bool onSpawn = true;
	}
	[HarmonyPatch(typeof(EnemyIdentifier), "Start")]
	public class TeleportToPlayerPatch
	{
		public static void Postfix(EnemyIdentifier __instance)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			TeleportToPlayer component = ((Component)__instance).GetComponent<TeleportToPlayer>();
			if ((Object)(object)component == (Object)null || !component.onSpawn)
			{
				return;
			}
			((Component)__instance).transform.position = ((Component)MonoSingleton<NewMovement>.Instance).transform.position;
			Power component2 = ((Component)__instance).GetComponent<Power>();
			if ((Object)(object)component2 != (Object)null)
			{
				component2.sinceLastVision = TimeSince.op_Implicit(0f);
				TargetDataRef val = default(TargetDataRef);
				if (component2.vision.TrySee(component2.targetQuery, ref val))
				{
					component2.lastTargetData = TargetDataExtensions.ToData(val);
					component2.targetHandle = component2.lastTargetData.handle;
				}
				else
				{
					component2.targetHandle = null;
				}
			}
		}
	}
	public class V2Common : MonoBehaviour
	{
		public bool bossVersion = false;
	}
	[HarmonyPatch(typeof(V2))]
	public class V2CommonPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(V2), "Start")]
		public static void StartPostfix(V2 __instance)
		{
			V2Common component = ((Component)__instance).GetComponent<V2Common>();
			if (!((Object)(object)component == (Object)null))
			{
				__instance.bossVersion = component.bossVersion;
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(V2), "BeginEscape")]
		public static void BeginEscapePrefix(V2 __instance)
		{
			V2Common component = ((Component)__instance).GetComponent<V2Common>();
			if ((Object)(object)component == (Object)null)
			{
				return;
			}
			Enemy component2 = ((Component)__instance).GetComponent<Enemy>();
			if (!((Object)(object)component2 == (Object)null))
			{
				ActivateNextWave componentInParent = ((Component)component2).GetComponentInParent<ActivateNextWave>();
				if (componentInParent != null)
				{
					componentInParent.AddDeadEnemy();
				}
			}
		}
	}
	[HarmonyPatch(typeof(CancerousRodent))]
	public class CancerousRodentPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(CancerousRodent), "DeathEnd")]
		public static bool DeathEndPrefix(CancerousRodent __instance)
		{
			if (!Util.IsPatched())
			{
				return true;
			}
			if (__instance.enemy.musicRequested)
			{
				MonoSingleton<MusicManager>.Instance.PlayCleanMusic();
			}
			if ((Object)(object)((Component)__instance).gameObject != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)__instance).gameObject);
			}
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(CancerousRodent), "OnDisable")]
		public static void OnDisablePrefix(CancerousRodent __instance)
		{
			__instance.enemy = ((Component)__instance).GetComponent<Enemy>();
		}
	}
	[HarmonyPatch]
	public class DeadcaughtEnemyPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(Deathcatcher), "EnemyDeath")]
		public static bool EnemyDeathPrefix(EnemyIdentifier eid, Deathcatcher __instance)
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Invalid comparison between Unknown and I4
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Expected O, but got Unknown
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			if (!Util.IsPatched())
			{
				return true;
			}
			if ((Object)(object)eid == (Object)null)
			{
				Debug.LogWarning((object)"EnemyIdentifier is null. Cannot track death.");
				return false;
			}
			DontCatch component = ((Component)eid).gameObject.GetComponent<DontCatch>();
			if ((Object)(object)component != (Object)null && ((Behaviour)component).enabled)
			{
				return false;
			}
			Debug.Log((object)("EnemyDeath called for " + ((Object)eid).name));
			if (!__instance.canRespawnIdols && (int)eid.enemyType == 21)
			{
				return false;
			}
			EnemyTracker instance = MonoSingleton<EnemyTracker>.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				Debug.LogWarning((object)"EnemyTracker instance not found. Cannot track enemy death.");
				return false;
			}
			if (!instance.spawnedEnemies.TryGetValue(((Object)eid).GetInstanceID(), out var value))
			{
				Debug.LogWarning((object)("Enemy " + ((Object)eid).name + " not found in spawned enemies. Cannot track death."));
				return false;
			}
			TeleportOnCondition teleportOnCondition = null;
			GameObject[] activateOnDeath = eid.activateOnDeath;
			foreach (GameObject val in activateOnDeath)
			{
				if (!(((Object)val).name != "TeleportOnCondition"))
				{
					teleportOnCondition = val.GetComponent<TeleportOnCondition>();
				}
			}
			CaughtEnemy val2 = new CaughtEnemy(eid, value);
			if (!__instance.deadCaughtEnemies.Contains(val2))
			{
				Debug.Log((object)$"Tracking death of enemy {eid} at position {val2.position} with rotation {val2.rotation}");
				__instance.deadCaughtEnemies.Add(val2);
				if ((Object)(object)teleportOnCondition != (Object)null && teleportOnCondition.onDeadcaught)
				{
					val2.position = TeleportOnCondition.CheckConditions(val2.position, teleportOnCondition.conditions, teleportOnCondition.returnOnFirstSuccess);
				}
			}
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(CaughtEnemy), "UpdatePuppet")]
		public static void UpdatePuppetPrefix(GameObject newPuppet, CaughtEnemy __instance)
		{
			if (!Util.IsPatched())
			{
				return;
			}
			if (newPuppet != null)
			{
				Transform parent = newPuppet.transform.parent;
				if (((parent != null) ? new bool?(((Object)parent).name.Contains("DeathcatcherCase")) : null).GetValueOrDefault())
				{
					Transform parent2 = newPuppet.transform.parent;
					if ((Object)(object)((parent2 != null) ? parent2.parent : null) != (Object)null)
					{
						newPuppet.transform.SetParent(newPuppet.transform.parent.parent);
					}
				}
			}
			ReaddComponents(newPuppet, __instance.original, __instance);
			if (((Object)newPuppet).name.Contains("Very Cancerous Rodent"))
			{
				ScreenDistortionField componentInChildren = newPuppet.GetComponentInChildren<ScreenDistortionField>(true);
				if (componentInChildren != null)
				{
					((Component)componentInChildren).gameObject.SetActive(false);
				}
				Rigidbody component = newPuppet.GetComponent<Rigidbody>();
				if (component != null)
				{
					component.isKinematic = true;
				}
			}
		}

		public static void ReaddComponents(GameObject puppet, EnemyIdentifier original, CaughtEnemy __instance)
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			GameObject[] activateOnDeath = original.activateOnDeath;
			foreach (GameObject val in activateOnDeath)
			{
				switch (((Object)val).name)
				{
				case "ParentPuppetTo":
				{
					ParentPuppetTo component2 = val.GetComponent<ParentPuppetTo>();
					ParentPuppetTo orAddComponent2 = GameObjectExtensions.GetOrAddComponent<ParentPuppetTo>(puppet);
					orAddComponent2.objectName = component2.objectName;
					if (orAddComponent2.objectName != "")
					{
						Vector3 localScale = puppet.transform.localScale;
						Transform val2 = puppet.transform.parent.Find(orAddComponent2.objectName);
						if ((Object)(object)val2 != (Object)null)
						{
							puppet.transform.SetParent(val2);
						}
						puppet.transform.localScale = localScale;
					}
					break;
				}
				case "StopEnemyMovement":
				{
					StopEnemyMovement component3 = val.GetComponent<StopEnemyMovement>();
					StopEnemyMovement orAddComponent3 = GameObjectExtensions.GetOrAddComponent<StopEnemyMovement>(puppet);
					component3.CopyValuesTo(orAddComponent3);
					break;
				}
				case "MoveTo":
				{
					MoveTo component4 = val.GetComponent<MoveTo>();
					MoveTo orAddComponent4 = GameObjectExtensions.GetOrAddComponent<MoveTo>(puppet);
					component4.CopyValuesTo(orAddComponent4);
					break;
				}
				case "TeleportOnCondition":
				{
					TeleportOnCondition component = val.GetComponent<TeleportOnCondition>();
					TeleportOnCondition orAddComponent = GameObjectExtensions.GetOrAddComponent<TeleportOnCondition>(puppet);
					component.CopyValuesTo(orAddComponent);
					if (orAddComponent.onDeadcaught)
					{
						TeleportOnCondition.ChangeAxisTargetsToPuppet(orAddComponent.conditions, puppet.transform);
						__instance.position = TeleportOnCondition.CheckConditions(__instance.position, orAddComponent.conditions, orAddComponent.returnOnFirstSuccess);
					}
					puppet.transform.position = __instance.position;
					break;
				}
				}
			}
		}
	}
	[HarmonyPatch(typeof(HurtZone), "Start")]
	public class GoopCloudPatch
	{
		public static void Postfix(HurtZone __instance)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			if (Util.IsPatched() && (Object)(object)((Component)__instance).transform.parent != (Object)null && ((Object)((Component)__instance).transform.parent).name.Contains("GoopCloud"))
			{
				__instance.affected = (AffectedSubjects)1;
			}
		}
	}
	[HarmonyPatch]
	public class GroundWavePatch
	{
		[HarmonyPatch(typeof(GroundWave), "FixedUpdate")]
		public static bool FixedUpdatePrefix(GroundWave __instance, bool __runOriginal)
		{
			//IL_002f: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			if (!Util.IsPatched())
			{
				return true;
			}
			if (!__instance.isTraversingLink || !__runOriginal)
			{
				return false;
			}
			Vector3 val = __instance.traversalVelocity * Time.fixedDeltaTime;
			Transform transform = ((Component)__instance).transform;
			transform.position += val;
			if (((Vector3)(ref __instance.traversalVelocity)).sqrMagnitude > 0.001f)
			{
				((Component)__instance).transform.rotation = Quaternion.LookRotation(((Vector3)(ref __instance.traversalVelocity)).normalized, Vector3.up);
			}
			if (Object.op_Implicit((Object)(object)__instance.rb))
			{
				__instance.rb.position = ((Component)__instance).transform.position;
				__instance.rb.rotation = ((Component)__instance).transform.rotation;
			}
			if (__instance.hasCrossed)
			{
				__instance.postTeleportDistance += ((Vector3)(ref val)).magnitude;
				if (__instance.postTeleportDistance >= 2f)
				{
					__instance.isTraversingLink = false;
					((Behaviour)__instance.nma).enabled = true;
					__instance.nma.Warp(((Component)__instance).transform.position);
					__instance.nma.velocity = __instance.traversalVelocity;
					if ((Object)(object)__instance.nma != (Object)null && ((Behaviour)__instance.nma).enabled)
					{
						__instance.nma.SetDestination(__instance.target.GetNavPoint());
					}
				}
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(MirrorReaper), "Death")]
	public class MirrorReaperPatch
	{
		public static void Prefix(MirrorReaper __instance)
		{
			if (Util.IsPatched())
			{
				((Behaviour)((Component)__instance).GetComponent<RigBuilder>()).enabled = false;
			}
		}
	}
	[HarmonyPatch(typeof(Power), "Awake")]
	public class PowerPatch
	{
		public static bool Prefix(Power __instance)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			if (!Util.IsPatched())
			{
				return true;
			}
			__instance.anim = ((Component)__instance).GetComponent<Animator>();
			__instance.eid = ((Component)__instance).GetComponent<EnemyIdentifier>();
			__instance.rb = ((Component)__instance).GetComponent<Rigidbody>();
			__instance.mach = ((Component)__instance).GetComponent<Enemy>();
			__instance.environmentMask = LayerMaskDefaults.Get((LMD)1);
			__instance.ensims = ((Component)__instance).GetComponentsInChildren<EnemySimplifier>();
			__instance.aud = ((Component)__instance).GetComponent<AudioSource>();
			if (__instance.voicePitch == -1f)
			{
				__instance.voicePitch = Random.Range(0.95f, 1.05f);
			}
			if (__instance.originalPosition == Vector3.zero)
			{
				__instance.originalPosition = ((Component)__instance).transform.position;
			}
			if (Object.op_Implicit((Object)(object)__instance.stabEffect))
			{
				__instance.stabParticle = __instance.stabEffect.GetComponentInChildren<ParticleSystem>();
				__instance.stabTrail = __instance.stabEffect.GetComponentInChildren<TrailRenderer>();
				__instance.stabAudio = __instance.stabEffect.GetComponentInChildren<AudioSource>();
			}
			if ((Object)(object)__instance.physicsArm == (Object)null)
			{
				__instance.physicsArm = new GameObject("Nemesis PowerPhysicsArm").transform;
			}
			__instance.physicsArm.SetParent(((Component)__instance).transform.parent);
			return false;
		}
	}
	[HarmonyPatch(typeof(PhysicalShockwave), "CreatePortalReplicas")]
	public class ShockwavePatch
	{
		public static bool Prefix(PhysicalShockwave __instance)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between Unknown and I4
			if (Util.IsPatched() && (int)__instance.enemyType == 2)
			{
				return false;
			}
			return true;
		}
	}
	public class SwordsmachineAddANW : MonoBehaviour
	{
		public void Add()
		{
			ActivateNextWave component = ((Component)this).GetComponent<ActivateNextWave>();
			component.deadEnemies++;
		}
	}
	[HarmonyPatch(typeof(SwordsMachine), "TeleportAway")]
	public class SwordsMachinePatch
	{
		public static bool Prefix(SwordsMachine __instance)
		{
			//IL_0029: 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_004f: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
			if (!Util.IsPatched())
			{
				return true;
			}
			BossHealthBar component = ((Component)__instance).GetComponent<BossHealthBar>();
			component.DisappearBar();
			new Vector3(((Component)__instance).transform.position.x, ((Component)__instance).transform.position.y + 1.5f, ((Component)__instance).transform.position.z);
			__instance.teleportEffect.SetActive(true);
			__instance.teleportEffect.transform.SetParent((Transform)null, true);
			((Component)__instance).gameObject.SetActive(false);
			SwordsMachine[] componentsInChildren = ((Component)__instance.secondPhasePosTarget).GetComponentsInChildren<SwordsMachine>();
			if (componentsInChildren.Length != 0)
			{
				SwordsMachine[] array = componentsInChildren;
				SwordsMachine[] array2 = array;
				foreach (SwordsMachine val in array2)
				{
					((Component)val).gameObject.SetActive(false);
					Object.Destroy((Object)(object)((Component)val).gameObject);
				}
			}
			((Component)__instance).transform.position = __instance.secondPhasePosTarget.position;
			((Component)__instance).transform.parent = __instance.secondPhasePosTarget;
			__instance.eid.spawnIn = true;
			((Component)__instance).gameObject.SetActive(true);
			((Behaviour)component).enabled = true;
			__instance.secondPhasePosTarget = null;
			SwordsmachineAddANW[] array3 = Object.FindObjectsByType<SwordsmachineAddANW>((FindObjectsInactive)1, (FindObjectsSortMode)0);
			SwordsmachineAddANW[] array4 = array3;
			foreach (SwordsmachineAddANW swordsmachineAddANW in array4)
			{
				swordsmachineAddANW.Add();
			}
			CheckPointPatch.InheritCheckpointRooms(__instance.cpToReset);
			__instance.cpToReset.UpdateRooms();
			return false;
		}
	}
	public class ActionOnEnable : MonoBehaviour
	{
		public UnityEvent unityEvent = new UnityEvent();

		public bool activated = false;

		public bool oneTime = true;

		public void OnEnable()
		{
			if (!oneTime || !activated)
			{
				UnityEvent obj = unityEvent;
				if (obj != null)
				{
					obj.Invoke();
				}
				activated = true;
				if (!oneTime)
				{
					((Component)this).gameObject.SetActive(false);
				}
			}
		}
	}
	public class ArenaDelay : MonoBehaviour
	{
		public float delay = 1f;

		public ActivateArena target = null;
	}
	public class ArenaLink : MonoBehaviour
	{
		public ActivateArena[] linkedArenas = Array.Empty<ActivateArena>();

		public bool delete = true;

		public bool activated = false;

		public ArenaLink unclonedSelf = null;

		public void Update()
		{
			if (activated)
			{
				return;
			}
			ActivateArena[] array = linkedArenas;
			foreach (ActivateArena val in array)
			{
				if ((Object)(object)val != (Object)null && val.activated)
				{
					OnArenaActivated(val);
					break;
				}
			}
		}

		public void OnArenaActivated(ActivateArena arenaActivated = null)
		{
			ActivateArena[] array = linkedArenas;
			foreach (ActivateArena val in array)
			{
				bool flag = (Object)(object)arenaActivated != (Object)null && (Object)(object)val == (Object)(object)arenaActivated;
				if (!((Object)(object)val == (Object)null || flag))
				{
					if (delete)
					{
						Object.Destroy((Object)(object)val);
					}
					else
					{
						val.Activate();
					}
				}
			}
			activated = true;
			if ((Object)(object)unclonedSelf != (Object)null && (Object)(object)unclonedSelf != (Object)(object)this)
			{
				unclonedSelf.OnArenaActivated();
			}
		}
	}
	public class ArenaStatusNotInParent : MonoBehaviour
	{
		public ArenaStatus astat = null;

		public void Awake()
		{
			ActivateArena component = ((Component)this).GetComponent<ActivateArena>();
			if ((Object)(object)component != (Object)null && (Object)(object)component.astat == (Object)null)
			{
				component.astat = astat;
			}
		}
	}
	public class ArenaStatusUpdater : MonoBehaviour
	{
		public int statusValue = 1;

		public bool isAdditive = false;

		public ArenaStatus arenaStatus = null;

		public bool oneTime = true;

		public bool activated = false;

		public void OnEnable()
		{
			if (!((Object)(object)arenaStatus == (Object)null) && (!oneTime || !activated))
			{
				if (isAdditive)
				{
					ArenaStatus obj = arenaStatus;
					obj.currentStatus += statusValue;
				}
				else
				{
					arenaStatus.currentStatus = statusValue;
				}
				activated = true;
			}
		}
	}
	public class AudioOnEnable : MonoBehaviour
	{
		public AudioSource audioSource;

		public void OnEnable()
		{
			if (!((Object)(object)audioSource == (Object)null))
			{
				audioSource.Play();
			}
		}
	}
	public class BackAndForth : MonoBehaviour
	{
		public float speed = 10f;

		public float startZ = 0f;

		public float endZ = -40f;

		public bool forward = true;

		public void FixedUpdate()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: 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_0020: 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)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			Vector3 localPosition = ((Component)this).transform.localPosition;
			Vector3 val = default(Vector3);
			if (forward)
			{
				((Vector3)(ref val))..ctor(localPosition.x, localPosition.y, endZ);
				((Component)this).transform.localPosition = Vector3.MoveTowards(localPosition, val, speed * Time.deltaTime);
			}
			else
			{
				((Vector3)(ref val))..ctor(localPosition.x, localPosition.y, startZ);
				((Component)this).transform.localPosition = Vector3.MoveTowards(localPosition, val, speed * Time.deltaTime);
			}
			if (((Component)this).transform.localPosition == val)
			{
				forward = !forward;
			}
		}

		public BackAndForth Configure(float speed = 10f, float startZ = 0f, float endZ = -40f)
		{
			this.speed = speed;
			this.startZ = startZ;
			this.endZ = endZ;
			return this;
		}
	}
	public class BeamDelayHelper : MonoBehaviour
	{
		public float chargeUpTimeToSubtract = 0f;

		public bool subtracted = false;

		public ObjectActivator objectActivator = null;

		public void Subtract()
		{
			if (!subtracted)
			{
				ObjectActivator obj = objectActivator;
				obj.delay -= chargeUpTimeToSubtract;
				subtracted = true;
			}
		}
	}
	public class BreakParticlePlaceholder : MonoBehaviour
	{
		public void OnEnable()
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}
	public class CheckPointActivator : MonoBehaviour
	{
		public CheckPoint checkpoint;

		public void OnEnable()
		{
			if (!((Object)(object)checkpoint == (Object)null))
			{
				checkpoint.activated = false;
				checkpoint.SetForceOff(false);
				checkpoint.SetInvisibility(false);
				checkpoint.ActivateCheckPoint();
			}
		}
	}
	public class CheckPointConstantOff : MonoBehaviour
	{
		public CheckPoint checkpoint;

		public void FixedUpdate()
		{
			if (!((Object)(object)checkpoint == (Object)null) && !checkpoint.forceOff)
			{
				checkpoint.SetForceOff(true);
				checkpoint.SetInvisibility(true);
				checkpoint.unteleportable = true;
			}
		}
	}
	public class CheckPointToUpdate : MonoBehaviour
	{
		public Dictionary<int, GameObject> rooms = new Dictionary<int, GameObject>();
	}
	public class CheckPointTurnOn : MonoBehaviour
	{
		public CheckPoint checkpoint;

		public void OnEnable()
		{
			if (!((Object)(object)checkpoint == (Object)null))
			{
				checkpoint.activated = false;
				checkpoint.SetForceOff(false);
			}
		}

		public void OnDisable()
		{
			if (!((Object)(object)checkpoint == (Object)null))
			{
				checkpoint.SetForceOff(true);
			}
		}
	}
	public class InheritRoomExceptions : MonoBehaviour
	{
		public string[] roomNames = Array.Empty<string>();
	}
	public class DoorAltarHelper : MonoBehaviour
	{
		public Door door = null;

		public ItemPlaceZone[] itemPlaceZones = Array.Empty<ItemPlaceZone>();

		public bool reversed = false;

		public bool playerInArena = false;

		public void Update()
		{
			if (!playerInArena && !((Object)(object)door == (Object)null))
			{
				ProcessDoor(CheckShouldUnlock());
			}
		}

		public bool CheckShouldUnlock()
		{
			bool flag = true;
			bool flag2 = true;
			ItemPlaceZone[] array = itemPlaceZones;
			foreach (ItemPlaceZone val in array)
			{
				bool flag3 = (val.acceptedItemPlaced && !reversed) || (!val.acceptedItemPlaced && reversed);
				if (flag2)
				{
					flag = flag3;
					flag2 = false;
				}
				else if (flag3 != flag)
				{
					flag = reversed;
					break;
				}
			}
			return flag;
		}

		public void ProcessDoor(bool shouldUnlock)
		{
			if (shouldUnlock && door.locked)
			{
				door.Unlock();
				door.Open(false, true);
			}
			else if (!shouldUnlock && !door.locked)
			{
				door.Lock();
				door.Close(false);
			}
		}
	}
	public class DoorConstantLocker : MonoBehaviour
	{
		public Door door;

		public bool unlockOnDisable = true;

		public void FixedUpdate()
		{
			if (!((Object)(object)door == (Object)null) && !door.locked)
			{
				door.Lock();
			}
		}

		public void OnDisable()
		{
			if (!((Object)(object)door == (Object)null) && unlockOnDisable)
			{
				door.Unlock();
			}
		}
	}
	public class BreakableAllower : MonoBehaviour
	{
		public Breakable breakable;

		public List<EnemyBlockBreakables> enemyBlocks = new List<EnemyBlockBreakables>();

		public void FixedUpdate()
		{
			if ((Object)(object)breakable == (Object)null)
			{
				return;
			}
			List<EnemyBlockBreakables> list = new List<EnemyBlockBreakables>();
			foreach (EnemyBlockBreakables enemyBlock in enemyBlocks)
			{
				if ((Object)(object)enemyBlock == (Object)null || !((Behaviour)enemyBlock).enabled || (Object)(object)enemyBlock.eid == (Object)null || enemyBlock.eid.Dead)
				{
					list.Add(enemyBlock);
					Object.Destroy((Object)(object)enemyBlock);
				}
				else if (!enemyBlock.eid.Dead)
				{
					breakable.broken = true;
					RemoveEnemyBlocks(list);
					return;
				}
			}
			breakable.broken = false;
			RemoveEnemyBlocks(list);
		}

		public void RemoveEnemyBlocks(List<EnemyBlockBreakables> toRemove)
		{
			foreach (EnemyBlockBreakables item in toRemove)
			{
				enemyBlocks.Remove(item);
			}
		}
	}
	public class DontManipulateLight : MonoBehaviour
	{
		public Light targetLight;
	}
	public class LightManipulator : MonoBehaviour
	{
		public float multiplier = 0.125f;

		public int dimmedCounter = 0;

		public bool invertColors = true;

		public bool ignoreEnemies = true;

		public void OnEnable()
		{
			DimLights();
		}

		public void DimLights(bool reversed = false)
		{
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: 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_00e7: Unknown result type (might be due to invalid IL or missing references)
			Light[] array = Object.FindObjectsByType<Light>((FindObjectsInactive)1, (FindObjectsSortMode)0);
			Light[] array2 = array;
			foreach (Light val in array2)
			{
				if (ignoreEnemies && ((Object)(object)((Component)val).GetComponentInChildren<EnemyIdentifier>() != (Object)null || (Object)(object)((Component)val).GetComponentInParent<EnemyIdentifier>() != (Object)null))
				{
					continue;
				}
				DontManipulateLight component = ((Component)val).GetComponent<DontManipulateLight>();
				if (!((Object)(object)component != (Object)null) || !((Behaviour)component).enabled || !((Object)(object)component.targetLight == (Object)(object)val))
				{
					val.intensity *= ((!reversed) ? multiplier : (1f / multiplier));
					if (invertColors)
					{
						val.color = new Color(1f - val.color.r, 1f - val.color.g, 1f - val.color.b);
					}
				}
			}
			dimmedCounter += ((!reversed) ? 1 : (-1));
			if (invertColors)
			{
				Color fogColor = RenderSettings.fogColor;
				RenderSettings.fogColor = new Color(1f - fogColor.r, 1f - fogColor.g, 1f - fogColor.b);
			}
		}

		public LightManipulator Configure(float multiplier = 0.125f, bool invertColors = true, bool ignoreEnemies = true)
		{
			this.multiplier = multiplier;
			this.invertColors = invertColors;
			this.ignoreEnemies = ignoreEnemies;
			return this;
		}
	}
	public class MusicSlower : MonoBehaviour
	{
		public float multiplier = 0.1f;

		public int slowedCounter = 0;

		public bool isGradualPitch = false;

		public float gradualPitchSpeed = 0.2f;

		public float gradualPitchMultiplierTarget = 1.25f;

		public Dictionary<int, float> gradualPitchOriginals = new Dictionary<int, float>();

		public bool gradualPitchOriginalsSet = false;

		public void OnEnable()
		{
			Slow();
		}

		public void Slow(bool reversed = false)
		{
			if (!((Object)(object)MonoSingleton<MusicManager>.Instance == (Object)null))
			{
				AudioSource[] allThemes = MonoSingleton<MusicManager>.Instance.allThemes;
				foreach (AudioSource val in allThemes)
				{
					float num = AudioSourceExtensions.GetPitch(val) * ((!reversed) ? multiplier : (1f / multiplier));
					AudioSourceExtensions.SetPitch(val, num);
				}
				slowedCounter += ((!reversed) ? 1 : (-1));
			}
		}

		public void Update()
		{
			if (!isGradualPitch || (Object)(object)MonoSingleton<MusicManager>.Instance == (Object)null)
			{
				return;
			}
			bool flag = true;
			AudioSource[] allThemes = MonoSingleton<MusicManager>.Instance.allThemes;
			foreach (AudioSource val in allThemes)
			{
				int key = Array.IndexOf(MonoSingleton<MusicManager>.Instance.allThemes, val);
				if (!gradualPitchOriginalsSet)
				{
					gradualPitchOriginals[key] = AudioSourceExtensions.GetPitch(val);
				}
				float num = Mathf.MoveTowards(AudioSourceExtensions.GetPitch(val), gradualPitchOriginals[key] * gradualPitchMultiplierTarget, gradualPitchSpeed * Time.deltaTime);
				AudioSourceExtensions.SetPitch(val, num);
				if (AudioSourceExtensions.GetPitch(val) != gradualPitchOriginals[key] * gradualPitchMultiplierTarget)
				{
					flag = false;
				}
			}
			if (!gradualPitchOriginalsSet)
			{
				gradualPitchOriginalsSet = true;
			}
			if (flag)
			{
				isGradualPitch = false;
			}
		}

		public void GradualPitchChange(float gradualPitchMultiplierTarget = 1.25f, float gradualPitchSpeed = 0.2f)
		{
			isGradualPitch = true;
			this.gradualPitchMultiplierTarget = gradualPitchMultiplierTarget;
			this.gradualPitchSpeed = gradualPitchSpeed;
			gradualPitchOriginalsSet = false;
		}
	}
	public class GravitySwitcher : MonoBehaviour
	{
		public Vector3 direction = new Vector3(0f, -40f, 0f);

		public bool instant = false;

		public bool transformCamera = true;

		public bool oneTime = true;

		public bool activated = false;

		public void OnEnable()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if (!activated || !oneTime)
			{
				NewMovement instance = MonoSingleton<NewMovement>.Instance;
				if (instance != null)
				{
					instance.SwitchGravity(direction, instant, transformCamera);
				}
				activated = true;
			}
		}
	}
	public class NoElectricityChecker : MonoBehaviour
	{
		public GameObject toActivate = null;

		public void OnTriggerEnter(Collider other)
		{
			if (Util.IsPatched() && ((Component)other).gameObject.CompareTag("Player") && !GeneralFuncs.PlayerHasElectricWeapon())
			{
				toActivate.SetActive(true);
				((Component)this).gameObject.SetActive(false);
				AttributeChecker componentInChildren = ((Component)((Component)this).transform.parent).GetComponentInChildren<AttributeChecker>();
				if (componentInChildren != null)
				{
					((Component)componentInChildren).gameObject.SetActive(false);
				}
			}
		}
	}
	public class NoElectricityCheckerSetup : MonoBehaviour
	{
		public bool finished = false;

		public void Start()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			if (!finished)
			{
				GameObject toActivate = ((Component)this).GetComponent<AttributeChecker>().toActivate;
				GameObject val = Object.Instantiate<GameObject>(((Component)this).gameObject, ((Component)this).transform.parent);
				val.transform.localPosition = new Vector3(0f, 2.5f, 0f);
				GameObjectExtensions.GetOrAddComponent<NoElectricityChecker>(val).toActivate = toActivate;
				val.layer = LayerMask.NameToLayer("Invisible");
				((Object)val).name = "NoElectricityChecker";
				Object.Destroy((Object)(object)val.GetComponent<NoElectricityCheckerSetup>());
				finished = true;
			}
		}
	}
	public class NoOcclusionCulling : MonoBehaviour
	{
		public void Start()
		{
			NewMovement instance = MonoSingleton<NewMovement>.Instance;
			if (instance != null)
			{
				instance.cc.cam.useOcclusionCulling = false;
			}
		}
	}
	[HarmonyPatch(typeof(NewMovement), "Respawn")]
	public class NoOcclusionCullingPatch
	{
		public static void Postfix(NewMovement __instance)
		{
			NoOcclusionCulling component = ((Component)__instance).GetComponent<NoOcclusionCulling>();
			if (!((Object)(object)component == (Object)null))
			{
				__instance.cc.cam.useOcclusionCulling = false;
			}
		}
	}
	public class ObacReadier : MonoBehaviour
	{
		public ObjectActivationCheck obac;

		public bool makeReady = true;

		public bool undoOnDisable = false;

		public void OnEnable()
		{
			ObjectActivationCheck obj = obac;
			if (obj != null)
			{
				obj.readyToActivate = makeReady;
			}
		}

		public void OnDisable()
		{
			if (undoOnDisable)
			{
				ObjectActivationCheck obj = obac;
				if (obj != null)
				{
					obj.readyToActivate = !makeReady;
				}
			}
		}
	}
	public class PortalBlocker : MonoBehaviour
	{
		public bool unblock = false;

		public string portalPath = "Portal In";

		public bool entry = true;

		public bool exit = true;

		public void OnEnable()
		{
			Block(unblock);
		}

		public void Block(bool unblock = false)
		{
			Transform obj = GeneralFuncs.FindInactive(portalPath);
			Portal val = ((obj != null) ? ((Component)obj).GetComponent<Portal>() : null);
			if (entry)
			{
				PortalFuncs.SetPortalEntry(val, unblock, unblock);
			}
			if (exit)
			{
				PortalFuncs.SetPortalExit(val, unblock, unblock);
			}
			if (entry && exit)
			{
				((Component)val).gameObject.SetActive(unblock);
				((Component)val.exit).gameObject.SetActive(unblock);
			}
		}
	}
	public class SimpleScrollingText : MonoBehaviour
	{
		public TMP_Text text;

		public float secondsBetweenLetters = 0.025f;

		public int totalCharacters;

		public bool running = true;

		public bool finished = false;

		public float cooldown = 0f;

		public bool isLevelName = false;

		public string stringLevelName = null;

		public TMP_Text textLevelName;

		public void Start()
		{
			if (text == null)
			{
				text = ((Component)this).GetComponent<TMP_Text>();
			}
			Reset();
		}

		public void Reset()
		{
			text.ForceMeshUpdate(true, true);
			totalCharacters = text.textInfo.characterCount;
			text.maxVisibleCharacters = 0;
		}

		public void Update()
		{
			if (!((Component)this).gameObject.activeInHierarchy || !running || finished)
			{
				return;
			}
			cooldown += Time.deltaTime;
			if (!(cooldown < secondsBetweenLetters))
			{
				cooldown -= secondsBetweenLetters;
				TMP_Text obj = text;
				obj.maxVisibleCharacters += 1;
				if (isLevelName)
				{
					int length = Mathf.Min(2 + GetLastVisibleLetterIndex(), stringLevelName.Length);
					textLevelName.text = stringLevelName.Substring(0, length);
				}
				if (text.maxVisibleCharacters >= totalCharacters)
				{
					finished = true;
					running = false;
				}
			}
		}

		public int GetLastVisibleLetterIndex()
		{
			//IL_002a: 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_0030: 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)
			int result = -1;
			for (int num = text.textInfo.characterCount - 1; num >= 0; num--)
			{
				TMP_CharacterInfo val = text.textInfo.characterInfo[num];
				if (val.isVisible)
				{
					result = val.index;
					break;
				}
			}
			return result;
		}
	}
	public class SimpleScrollingTextActivator : MonoBehaviour
	{
		public SimpleScrollingText simpleScrollingText;

		public void OnEnable()
		{
			simpleScrollingText.running = true;
		}

		public void OnDisable()
		{
			simpleScrollingText.running = false;
		}
	}
	public class VariableDelay : MonoBehaviour
	{
		public static Dictionary<string, float> AllDelays = new Dictionary<string, float>();

		public Component targetComponent = null;

		public string delayName = "";

		public void Activate()
		{
			Component val = targetComponent;
			Component val2 = val;
			if (!(val2 is ArenaDelay arenaDelay))
			{
				ObjectActivator val3 = (ObjectActivator)(object)((val2 is ObjectActivator) ? val2 : null);
				if (val3 != null)
				{
					val3.delay = AllDelays[delayName];
				}
			}
			else
			{
				arenaDelay.delay = AllDelays[delayName];
			}
		}

		public static void ActivateAll(string delayName)
		{
			VariableDelay[] array = Object.FindObjectsByType<VariableDelay>((FindObjectsInactive)1, (FindObjectsSortMode)0);
			VariableDelay[] array2 = array;
			foreach (VariableDelay variableDelay in array2)
			{
				if (!(variableDelay.delayName != delayName))
				{
					variableDelay.Activate();
				}
			}
		}
	}
	[HarmonyPatch(typeof(ActivateArena), "Activate")]
	public class ActivateArenaPatch
	{
		public static bool Prefix(ActivateArena __instance)
		{
			if (!Util.IsPatched())
			{
				return true;
			}
			if (DisableEnemySpawns.DisableArenaTriggers || __instance.activated)
			{
				return false;
			}
			__instance.activated = true;
			if (!__instance.onlyWave && !__instance.forEnemy)
			{
				MonoSingleton<MusicManager>.Instance.ArenaMusicStart(true);
			}
			float num = -1f;
			ArenaDelay[] components = ((Component)__instance).GetComponents<ArenaDelay>();
			ArenaDelay[] array = components;
			foreach (ArenaDelay arenaDelay in array)
			{
				if (!((Object)(object)arenaDelay.target != (Object)(object)__instance))
				{
					num = arenaDelay.delay;
					break;
				}
			}
			if (__instance.doors.Length != 0)
			{
				Door[] doors = __instance.doors;
				Door[] array2 = doors;
				foreach (Door val in array2)
				{
					if (!((Object)(object)val == (Object)null))
					{
						if (!((Component)val).gameObject.activeSelf)
						{
							((Component)val).gameObject.SetActive(true);
						}
						DoorAltarHelper componentInChildren = ((Component)val).GetComponentInChildren<DoorAltarHelper>();
						if (componentInChildren != null)
						{
							componentInChildren.playerInArena = true;
						}
						val.Lock();
					}
				}
				if (__instance.enemies.Length != 0)
				{
					if (num < 0f)
					{
						((MonoBehaviour)__instance).Invoke("SpawnEnemy", 1f);
					}
					else
					{
						((MonoBehaviour)__instance).Invoke("SpawnEnemy", num);
					}
				}
				else
				{
					Object.Destroy((Object)(object)__instance);
				}
			}
			else if (__instance.enemies.Length != 0)
			{
				if (num < 0f)
				{
					__instance.SpawnEnemy();
				}
				else
				{
					((MonoBehaviour)__instance).Invoke("SpawnEnemy", num);
				}
			}
			else
			{
				Object.Destroy((Object)(object)__instance);
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(ActivateNextWave))]
	public class ActivateNextWavePatch
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(ActivateNextWave), "FixedUpdate")]
		public static bool FixedUpdatePrefix(ActivateNextWave __instance)
		{
			if (!Util.IsPatched())
			{
				return true;
			}
			if (__instance.deadEnemies < 0)
			{
				__instance.deadEnemies = 0;
			}
			if (__instance.activated || __instance.deadEnemies < __instance.enemyCount)
			{
				return false;
			}
			__instance.activated = true;
			if (__instance.lastWave)
			{
				((MonoBehaviour)__instance).Invoke("EndWaves", (float)((!__instance.noActivationDelay) ? 1 : 0));
				if (!__instance.forEnemies)
				{
					MonoSingleton<TimeController>.Instance.SlowDown(0.15f);
				}
				return false;
			}
			if (__instance.toActivate.Length != 0)
			{
				GameObject[] toActivate = __instance.toActivate;
				GameObject[] array = toActivate;
				foreach (GameObject val in array)
				{
					if (val != null)
					{
						val.SetActive(true);
					}
				}
			}
			if (__instance.doors.Length != 0)
			{
				Door[] doors = __instance.doors;
				Door[] array2 = doors;
				foreach (Door val2 in array2)
				{
					if (!((Object)(object)val2 != (Object)null))
					{
						continue;
					}
					DoorAltarHelper componentInChildren = ((Component)val2).GetComponentInChildren<DoorAltarHelper>();
					if (componentInChildren != null)
					{
						componentInChildren.playerInArena = false;
					}
					val2.Unlock();
					if (componentInChildren != null)
					{
						Door door = componentInChildren.door;
						if (door != null)
						{
							door.Open(false, true);
						}
					}
				}
			}
			((MonoBehaviour)__instance).Invoke("SpawnEnemy", (float)((!__instance.noActivationDelay) ? 1 : 0));
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(ActivateNextWave), "EndWaves")]
		public static bool EndWavesPrefix(ActivateNextWave __instance)
		{
			if (!Util.IsPatched())
			{
				return true;
			}
			if (__instance.toActivate.Length != 0 && !__instance.objectsActivated)
			{
				GameObject[] toActivate = __instance.toActivate;
				GameObject[] array = toActivate;
				foreach (GameObject val in array)
				{
					if (val != null)
					{
						val.SetActive(true);
					}
				}
				__instance.objectsActivated = true;
				__instance.EndWaves();
			}
			else if (__instance.currentDoor < __instance.doors.Length)
			{
				Door val2 = __instance.doors[__instance.currentDoor];
				DoorAltarHelper componentInChildren = ((Component)val2).GetComponentInChildren<DoorAltarHelper>();
				if (componentInChildren != null)
				{
					componentInChildren.playerInArena = false;
				}
				val2.Unlock();
				if ((Object)(object)val2 == (Object)(object)__instance.doorForward && (Object)(object)__instance.doorForward != (Object)null)
				{
					val2.Open(false, true);
				}
				else if ((Object)(object)componentInChildren?.door == (Object)(object)val2)
				{
					val2.Open(false, true);
				}
				__instance.currentDoor++;
				((MonoBehaviour)__instance).Invoke("EndWaves", 0.1f);
			}
			else
			{
				if (!__instance.forEnemies)
				{
					MonoSingleton<MusicManager>.Instance.ArenaMusicEnd();
					__instance.slowDown = 1f;
				}
				if (__instance.killChallenge)
				{
					MonoSingleton<ChallengeManager>.Instance.ChallengeDone();
				}
				Object.Destroy((Object)(object)__instance);
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(CheckPoint))]
	public class CheckPointPatch
	{
		[CompilerGenerated]
		private sealed class <UpdateRooms>d__1 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public CheckPoint __instance;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Expected O, but got Unknown
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_0073: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					__instance.i = 0;
					__instance.UpdateRooms();
					<>2__current = (object)new WaitForSeconds(0.1f);
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					return false;
				}
			}

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

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

		[HarmonyPostfix]
		[HarmonyPatch(typeof(CheckPoint), "Start")]
		public static void StartPostfix(CheckPoint __instance)
		{
			if (!Util.IsPatched())
			{
				return;
			}
			InheritRoomExceptions component = ((Component)__instance).GetComponent<InheritRoomExceptions>();
			if ((Object)(object)component != (Object)null)
			{
				string[] roomNames = component.roomNames;
				foreach (string item in roomNames)
				{
					if (__instance.inheritNames.Contains(item))
					{
						int index = __instance.inheritNames.IndexOf(item);
						__instance.roomsToInherit.RemoveAt(index);
						__instance.inheritNames.RemoveAt(index);
						__instance.inheritParents.RemoveAt(index);
						break;
					}
				}
			}
			CheckPointToUpdate component2 = ((Component)__instance).GetComponent<CheckPointToUpdate>();
			if ((Object)(object)component2 == (Object)null || __instance.defaultRooms.Count == 0)
			{
				return;
			}
			foreach (int key in component2.rooms.Keys)
			{
				__instance.defaultRooms[key] = component2.rooms[key];
			}
			((MonoBehaviour)__instance).StartCoroutine(UpdateRooms(__instance));
		}

		[IteratorStateMachine(typeof(<UpdateRooms>d__1))]
		public static IEnumerator UpdateRooms(CheckPoint __instance)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <UpdateRooms>d__1(0)
			{
				__instance = __instance
			};
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(CheckPoint), "ResetRoom")]
		public static bool ResetRoomPrefix(CheckPoint __instance)
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_0393: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Invalid comparison between Unknown and I4
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0409: Unknown result type (might be due to invalid IL or missing references)
			//IL_040f: Unknown result type (might be due to invalid IL or missing references)
			//IL_043b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0446: Unknown result type (might be due to invalid IL or missing references)
			//IL_0450: Unknown result type (might be due to invalid IL or missing references)
			//IL_0455: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c7: Invalid comparison between Unknown and I4
			//IL_04e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0513: Unknown result type (might be due to invalid IL or missing references)
			//IL_053f: Unknown result type (might be due to invalid IL or missing references)
			if (!Util.IsPatched())
			{
				return true;
			}
			if ((Object)(object)__instance.newRooms[__instance.i] != (Object)null && (Object)(object)__instance.defaultRooms[__instance.i] != (Object)null)
			{
				Vector3 position = __instance.newRooms[__instance.i].transform.position;
				__instance.newRooms[__instance.i].SetActive(false);
				Object.Destroy((Object)(object)__instance.newRooms[__instance.i]);
				__instance.newRooms[__instance.i] = Object.Instantiate<GameObject>(__instance.defaultRooms[__instance.i], position, __instance.defaultRooms[__instance.i].transform.rotation, __instance.defaultRooms[__instance.i].transform.parent);
				__instance.newRooms[__instance.i].SetActive(true);
				Bonus[] componentsInChildren = __instance.newRooms[__instance.i].GetComponentsInChildren<Bonus>(true);
				if (componentsInChildren != null && componentsInChildren.Length != 0)
				{
					Bonus[] array = componentsInChildren;
					for (int i = 0; i < array.Length; i++)
					{
						array[i].UpdateStatsManagerReference();
					}
				}
			}
			if (__instance.i + 1 < __instance.defaultRooms.Count)
			{
				__instance.i++;
				__instance.ResetRoom();
				return false;
			}
			if (Object.op_Implicit((Object)(object)__instance.toActivate))
			{
				__instance.toActivate.SetActive(true);
			}
			UnityEvent onRestart = __instance.onRestart;
			if (onRestart != null)
			{
				onRestart.Invoke();
			}
			if (!__instance.activated)
			{
				__instance.activated = true;
				if (Object.op_Implicit((Object)(object)__instance.graphic))
				{
					__instance.graphic.SetActive(false);
				}
			}
			__instance.player.transform.position = ((Component)__instance).transform.position + ((Component)__instance).transform.up * 1.25f;
			Rigidbody component = __instance.player.GetComponent<Rigidbody>();
			component.velocity = Vector3.zero;
			if ((Object)(object)__instance.nm == (Object)null)
			{
				__instance.nm = MonoSingleton<NewMovement>.Instance;
			}
			CameraController cc = __instance.nm.cc;
			PhysicsExtensions.SetCustomGravityMode(__instance.nm.rb, false);
			cc.gravityRotation = Quaternion.identity;
			Vector3 gravity = Physics.gravity;
			cc.gravityVec = ((Vector3)(ref gravity)).normalized;
			cc.rotationOffset = Quaternion.identity;
			cc.transitionRotationZ = 0f;
			cc.transitionRotationZSmooth = 0f;
			cc.tiltRotationZ = 0f;
			cc.tiltRotationZSmooth = 0f;
			Quaternion rotation = ((Component)__instance).transform.rotation;
			float num = ((Quaternion)(ref rotation)).eulerAngles.y + 0.01f + __instance.additionalSpawnRotation;
			if (Object.op_Implicit((Object)(object)__instance.player) && Object.op_Implicit((Object)(object)__instance.player.transform.parent) && ((Component)__instance.player.transform.parent).gameObject.CompareTag("Moving"))
			{
				float num2 = num;
				rotation = __instance.player.transform.parent.rotation;
				num = num2 - ((Quaternion)(ref rotation)).eulerAngles.y;
			}
			if ((int)MonoSingleton<PlayerTracker>.Instance.playerType == 0)
			{
				cc.ResetCamera(num, 0f);
			}
			else
			{
				MonoSingleton<PlatformerMovement>.Instance.ResetCamera(num, 0f);
			}
			cc.ApplyRotations(false);
			PhysicsExtensions.SetCustomGravity(__instance.nm.rb, __instance.gravity);
			PhysicsExtensions.SetCustomGravityMode(__instance.nm.rb, true);
			__instance.nm.gc.heavyFall = false;
			cc.Transform(Matrix4x4.identity, (Vector3?)__instance.gravity, (Quaternion?)null);
			MonoSingleton<CameraController>.Instance.activated = true;
			component.position = ((Component)__instance).transform.position + ((Component)__instance).transform.up * 1.25f;
			if (!((Behaviour)__instance.nm).enabled)
			{
				((Behaviour)__instance.nm).enabled = true;
			}
			__instance.nm.Respawn();
			__instance.nm.GetHealth(0, true, false, true);
			__instance.nm.cc.StopShake();
			__instance.nm.ActivatePlayer();
			if ((int)MonoSingleton<PlayerTracker>.Instance.playerType == 1)
			{
				((Component)MonoSingleton<PlatformerMovement>.Instance).transform.position = ((Component)__instance).transform.position;
				MonoSingleton<PlatformerMovement>.Instance.rb.velocity = Vector3.zero;
				MonoSingleton<PlatformerMovement>.Instance.playerModel.rotation = ((Component)__instance).transform.rotation;
				if (__instance.additionalSpawnRotation != 0f)
				{
					MonoSingleton<PlatformerMovement>.Instance.playerModel.Rotate(Vector3.up, __instance.additionalSpawnRotation);
				}
				((Component)MonoSingleton<PlatformerMovement>.Instance).gameObject.SetActive(true);
				MonoSingleton<PlatformerMovement>.Instance.SnapCamera();
				MonoSingleton<PlatformerMovement>.Instance.Respawn();
				MonoSingleton<CrateCounter>.Instance.ResetUnsavedStuff();
			}
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(CheckPoint), "UpdateRooms")]
		public static void UpdateRoomsPrefix(CheckPoint __instance)
		{
			if (!((Object)(object)__instance.defaultRooms[__instance.i].GetComponent<GoreZone>() != (Object)null))
			{
				if (__instance.i + 1 < __instance.defaultRooms.Count)
				{
					__instance.i++;
					__instance.UpdateRooms();
				}
				else
				{
					__instance.i = 0;
				}
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(CheckPoint), "ActivateCheckPoint")]
		public static bool ActivateCheckPointPrefix(CheckPoint __instance)
		{
			//IL_008f: 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_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			if (!Util.IsPatched())
			{
				return true;
			}
			__instance.sm = MonoSingleton<StatsManager>.Instance;
			__instance.inDuringResetSafety = false;
			if (Object.op_Implicit((Object)(object)__instance.sm.currentCheckPoint) && (Object)(object)__instance.sm.currentCheckPoint != (Object)(object)__instance)
			{
				MonoSingleton<NewMovement>.Instance.sameCheckpointRestarts = 0;
				if (__instance.sm.currentCheckPoint.resetOnGetOtherCheckpoint)
				{
					__instance.sm.currentCheckPoint.ReactivateCheckpoint();
				}
			}
			__instance.gravity = PhysicsExtensions.GetGravityVector(MonoSingleton<NewMovement>.Instance.rb);
			__instance.sm.currentCheckPoint = __instance;
			__instance.activated = true;
			if (!__instance.invisible && __instance.activateEffect.RuntimeKeyIsValid())
			{
				Object.Instantiate<GameObject>(AddressablesExtensions.ToAsset(__instance.activateEffect), MonoSingleton<PlayerTracker>.Instance.GetPlayer().position, Quaternion.identity);
			}
			if (Object.op_Implicit((Object)(object)__instance.graphic))
			{
				__instance.graphic.SetActive(false);
			}
			if (Object.op_Implicit((Object)(object)MonoSingleton<PlatformerMovement>.Instance))
			{
				MonoSingleton<CrateCounter>.Instance.SaveStuff();
			}
			if (Object.op_Implicit((Object)(object)MonoSingleton<MapVarManager>.Instance))
			{
				MonoSingleton<MapVarManager>.Instance.StashStore();
			}
			__instance.stylePoints = __instance.sm.stylePoints;
			__instance.restartKills = 0;
			if (Object.op_Implicit((Object)(object)MonoSingleton<ChallengeManager>.Instance))
			{
				__instance.challengeAlreadyFailed = MonoSingleton<ChallengeManager>.Instance.challengeFailed;
			}
			if (Object.op_Implicit((Object)(object)MonoSingleton<ChallengeManager>.Instance))
			{
				__instance.challengeAlreadyDone = MonoSingleton<ChallengeManager>.Instance.challengeDone;
			}
			if (!__instance.firstTime)
			{
				__instance.defaultRooms.Clear();
				__instance.newRooms.Clear();
				if (__instance.rooms.Length != 0)
				{
					GameObject[] rooms = __instance.rooms;
					GameObject[] array = rooms;
					foreach (GameObject val in array)
					{
						__instance.roomsToInherit.Add(val);
						__instance.inheritNames.Add(((Object)val).name);
						__instance.inheritParents.Add(val.transform.parent);
					}
					__instance.rooms = (GameObject[])(object)new GameObject[0];
				}
			}
			if ((Object)(object)__instance.shud == (Object)null)
			{
				__instance.shud = MonoSingleton<StyleHUD>.Instance;
			}
			InheritCheckpointRooms(__instance);
			MonoSingleton<BloodsplatterManager>.Instance.SaveBloodstains();
			__instance.firstTime = false;
			return false;
		}

		public static void InheritCheckpointRooms(CheckPoint __instance)
		{
			if (__instance.roomsToInherit.Count == 0)
			{
				return;
			}
			for (int i = 0; i < __instance.roomsToInherit.Count; i++)
			{
				string text = __instance.inheritNames[i];
				text = text.Replace("(Clone)", "");
				GameObject val = null;
				if (!((Object)(object)__instance.inheritParents[i] == (Object)null))
				{
					for (int num = __instance.inheritParents[i].childCount - 1; num >= 0; num--)
					{
						GameObject gameObject = ((Component)__instance.inheritParents[i].GetChild(num)).gameObject;
						if (((Object)gameObject).name.Replace("(Clone)", "") == text)
						{
							if ((Object)(object)val == (Object)null)
							{
								val = gameObject;
							}
							else
							{
								Object.Destroy((Object)(object)gameObject);
							}
						}
					}
				}
				if ((Object)(object)val != (Object)null && (Object)(object)val.GetComponent<GoreZone>() != (Object)null)
				{
					__instance.InheritRoom(val);
				}
			}
		}
	}
	[HarmonyPatch(typeof(ItemPlaceZone))]
	public class ItemPlaceZonePatch
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(ItemPlaceZone), "CheckItem")]
		public static bool CheckItemPrefix(bool prelim, ItemPlaceZone __instance)
		{
			//IL_0030: 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_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0456: Unknown result type (might be due to invalid IL or missing references)
			//IL_0464: Unknown result type (might be due to invalid IL or missing references)
			//IL_046b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0472: Unknown result type (might be due to invalid IL or missing references)
			//IL_0477: Unknown result type (might be due to invalid IL or missing references)
			//IL_0503: Unknown result type (might be due to invalid IL or missing references)
			//IL_0508: Unknown result type (might be due to invalid IL or missing references)
			if (!Util.IsPatched())
			{
				return true;
			}
			ItemIdentifier componentInChildren = ((Component)__instance).GetComponentInChildren<ItemIdentifier>();
			GameObject[] activateOnSuccess;
			Door[] doors;
			InstantiateObject[] altarElements;
			if ((Object)(object)componentInChildren != (Object)null)
			{
				if (componentInChildren.itemType == __instance.acceptedItemType)
				{
					if (!prelim && !__instance.hideEffects && !__instance.acceptedItemPlaced)
					{
						if (Object.op_Implicit((Object)(object)__instance.elementChangeEffect))
						{
							__instance.elementChangeEffect.Play();
						}
						if (Object.op_Implicit((Object)(object)__instance.soundOnActivated))
						{
							Object.Instantiate<AudioSource>(__instance.soundOnActivated, ((Component)__instance).transform.position, Quaternion.identity);
						}
					}
					__instance.acceptedItemPlaced = true;
					componentInChildren.ipz = __instance;
					if (!__instance.hideEffects)
					{
						((Component)componentInChildren).SendMessage("OnCorrectUse", (SendMessageOptions)1);
					}
					activateOnSuccess = __instance.activateOnSuccess;
					for (int i = 0; i < activateOnSuccess.Length; i++)
					{
						activateOnSuccess[i].SetActive(true);
					}
					activateOnSuccess = __instance.deactivateOnSuccess;
					for (int j = 0; j < activateOnSuccess.Length; j++)
					{
						activateOnSuccess[j].SetActive(false);
					}
					doors = __instance.doors;
					foreach (Door val in doors)
					{
						DoorAltarHelper componentInChildren2 = ((Component)val).GetComponentInChildren<DoorAltarHelper>();
						if ((Object)(object)componentInChildren2 == (Object)null)
						{
							val.Open(false, true);
						}
					}
					doors = __instance.reverseDoors;
					foreach (Door val2 in doors)
					{
						DoorAltarHelper componentInChildren3 = ((Component)val2).GetComponentInChildren<DoorAltarHelper>();
						if ((Object)(object)componentInChildren3 == (Object)null)
						{
							val2.Close(false);
						}
					}
					if (!__instance.hideEffects)
					{
						altarElements = __instance.altarElements;
						InstantiateObject[] array = altarElements;
						foreach (InstantiateObject val3 in array)
						{
							((Component)val3).gameObject.SetActive(true);
							if (!prelim && ((Component)val3).gameObject.activeInHierarchy)
							{
								val3.Instantiate();
							}
						}
					}
					if (!prelim)
					{
						ArenaStatus[] arenaStatuses = __instance.arenaStatuses;
						foreach (ArenaStatus obj in arenaStatuses)
						{
							obj.currentStatus++;
						}
						arenaStatuses = __instance.reverseArenaStatuses;
						foreach (ArenaStatus obj2 in arenaStatuses)
						{
							obj2.currentStatus--;
						}
					}
				}
				else
				{
					activateOnSuccess = __instance.activateOnFailure;
					for (int num2 = 0; num2 < activateOnSuccess.Length; num2++)
					{
						activateOnSuccess[num2].SetActive(true);
					}
				}
				if (Object.op_Implicit((Object)(object)__instance.col))
				{
					__instance.col.enabled = false;
				}
				return false;
			}
			if (Object.op_Implicit((Object)(object)__instance.col))
			{
				__instance.col.enabled = true;
			}
			if (!prelim && !__instance.acceptedItemPlaced)
			{
				return false;
			}
			activateOnSuccess = __instance.activateOnSuccess;
			for (int num3 = 0; num3 < activateOnSuccess.Length; num3++)
			{
				activateOnSuccess[num3].SetActive(false);
			}
			activateOnSuccess = __instance.activateOnFailure;
			for (int num4 = 0; num4 < activateOnSuccess.Length; num4++)
			{
				activateOnSuccess[num4].SetActive(false);
			}
			activateOnSuccess = __instance.deactivateOnSuccess;
			for (int num5 = 0; num5 < activateOnSuccess.Length; num5++)
			{
				activateOnSuccess[num5].SetActive(true);
			}
			doors = __instance.doors;
			Door[] array2 = doors;
			foreach (Door val4 in array2)
			{
				DoorAltarHelper componentInChildren4 = ((Component)val4).GetComponentInChildren<DoorAltarHelper>();
				if ((Object)(object)componentInChildren4 == (Object)null && ((int)val4.doorType != 0 || ((Component)val4).transform.localPosition != val4.closedPos))
				{
					val4.Close(false);
				}
			}
			doors = __instance.reverseDoors;
			Door[] array3 = doors;
			foreach (Door val5 in array3)
			{
				DoorAltarHelper componentInChildren5 = ((Component)val5).GetComponentInChildren<DoorAltarHelper>();
				if ((Object)(object)componentInChildren5 == (Object)null && ((int)val5.doorType != 0 || ((Component)val5).transform.localPosition != val5.closedPos + val5.openPos))
				{
					val5.Open(false, true);
				}
			}
			if (!prelim)
			{
				__instance.acceptedItemPlaced = false;
				if (!__instance.hideEffects)
				{
					if (Object.op_Implicit((Object)(object)__instance.elementChangeEffect))
					{
						__instance.elementChangeEffect.Play();
					}
					if (Object.op_Implicit((Object)(object)__instance.soundOnDeactivated))
					{
						Object.Instantiate<AudioSource>(__instance.soundOnDeactivated, ((Component)__instance).transform.position, Quaternion.identity);
					}
				}
				ArenaStatus[] arenaStatuses2 = __instance.arenaStatuses;
				foreach (ArenaStatus obj3 in arenaStatuses2)
				{
					obj3.currentStatus--;
				}
				arenaStatuses2 = __instance.reverseArenaStatuses;
				foreach (ArenaStatus obj4 in arenaStatuses2)
				{
					obj4.currentStatus++;
				}
			}
			altarElements = __instance.altarElements;
			for (int num10 = 0; num10 < altarElements.Length; num10++)
			{
				((Component)altarElements[num10]).gameObject.SetActive(false);
			}
			return false;
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	public class LeaderboardPatch
	{
		public static bool Prefix(ref bool __result)
		{
			if (!Util.IsPatched())
			{
				return true;
			}
			__result = false;
			return false;
		}
	}
	[HarmonyPatch(typeof(StatsManager), "SendInfo")]
	public class SendInfoPatch
	{
		public static void Postfix()
		{
			Plugin.Logger.LogWarning((object)("Score submitted: " + LeaderboardController.CanSubmitScores));
		}
	}
	[HarmonyPatch(typeof(GetMissionName), "GetMissionNameOnly")]
	public class GetMissionNamePatch
	{
		public static void Postfix(int missionNum, ref string __result)
		{
			if (!Util.IsEnabled() || !ChangedInfo.ChangedLevels.Contains(missionNum))
			{
				return;
			}
			__result += " <color=#ff00af>(NEMESIS)</color>";
			foreach (string key in ChangedInfo.NewLevelNames.Keys)
			{
				if (!__result.Contains(key))
				{
					continue;
				}
				__result = __result.Replace(key, ChangedInfo.NewLevelNames[key]);
				break;
			}
		}
	}
	[HarmonyPatch(typeof(MapInfoBase), "Awake")]
	public class MapInfoBasePatch
	{
		public static void Postfix(MapInfoBase __instance)
		{
			if (!Util.IsEnabled() || !ChangedInfo.ChangedLevelScenes.Contains(SceneHelper.CurrentScene))
			{
				return;
			}
			__instance.levelName += " <color=#ff00af>(NEMESIS)</color>";
			foreach (string key in ChangedInfo.NewLevelNames.Keys)
			{
				if (!__instance.levelName.Contains(key))
				{
					continue;
				}
				__instance.levelName = __instance.levelName.Replace(key, ChangedInfo.NewLevelNames[key]);
				break;
			}
		}
	}
	[HarmonyPatch(typeof(StockMapInfo), "Awake")]
	public class StockMapInfoPatch
	{
		public static void Postfix(StockMapInfo __instance)
		{
			if (!Util.IsEnabled() || !ChangedInfo.ChangedLevelScenes.Contains(SceneHelper.CurrentScene))
			{
				return;
			}
			__instance.assets.LargeText += " (NEMESIS)";
			foreach (string key in ChangedInfo.NewLevelNames.Keys)
			{
				if (!__instance.assets.LargeText.Contains(key))
				{
					continue;
				}
				__instance.assets.LargeText = __instance.assets.LargeText.Replace(key, ChangedInfo.NewLevelNames[key]);
				break;
			}
		}
	}
	[HarmonyPatch(typeof(LevelStats), "Start")]
	public class LevelStatsPatch
	{
		public static void Postfix(LevelStats __instance)
		{
			if (!Util.IsEnabled() || !ChangedInfo.ChangedLevelScenes.Contains(SceneHelper.CurrentScene))
			{
				return;
			}
			__instance.levelName.text = __instance.levelName.text.Replace("(NEMESIS)", "<color=#ff00af>(NEMESIS)</color>");
			foreach (string key in ChangedInfo.NewLevelNames.Keys)
			{
				if (!__instance.levelName.text.Contains(key))
				{
					continue;
				}
				__instance.levelName.text = __instance.levelName.text.Replace(key, ChangedInfo.NewLevelNames[key]);
				break;
			}
		}
	}
	[HarmonyPatch]
	public class LevelNamePopupPatch
	{
		[CompilerGenerated]
		private sealed class <NewShowNameText>d__2 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public LevelNamePopup __instance;

			private SimpleScrollingText <sst>5__1;

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

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

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

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

			private bool MoveNext()
			{
				//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ea: Expected O, but got Unknown
				//IL_014d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0157: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<sst>5__1 = ComponentExtensions.GetOrAddComponent<SimpleScrollingText>((Component)(object)__instance.nameText);
					<sst>5__1.running = false;
					<sst>5__1.text = __instance.nameText;
					((Component)<sst>5__1).GetComponent<TMP_Text>().text = __instance.nameString;
					<sst>5__1.Reset();
					<sst>5__1.secondsBetweenLetters = 0.015f;
					__instance.countTime = true;
					__instance.currentLetter = 0;
					AudioSourceExtensions.Play(__instance.aud, true);
					<sst>5__1.running = true;
					goto IL_00fb;
				case 1:
					<>1__state = -1;
					goto IL_00fb;
				case 2:
					{
						<>1__state = -1;
						__instance.fadingOut = true;
						__instance.nameAppearRoutine = null;
						return false;
					}
					IL_00fb:
					if (!<sst>5__1.finished)
					{
						<>2__current = (object)new WaitForSeconds(0.015f);
						<>1__state = 1;
						return true;
					}
					__instance.currentLetter = __instance.nameString.Length + 1;