Decompiled source of BossRush v1.0.0

plugins/Boss Rush.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BossRush;
using HarmonyLib;
using PluginConfig.API;
using PluginConfig.API.Fields;
using PluginConfig.API.Functionals;
using TMPro;
using UnityEngine;
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: AssemblyTitle("Trigger_Visualizer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Trigger_Visualizer")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("93460be9-9b66-4628-9b90-ffac43331ea0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")]
[assembly: AssemblyVersion("1.0.0.0")]
[HarmonyPatch]
public static class PatchesAll
{
	public static bool V2Dead;

	[HarmonyPostfix]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	private static void ScoresSubmission(ref bool __result)
	{
		__result &= !Plugin.main.rushing;
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(FinalRank), "SetInfo")]
	private static void RankExtra(FinalRank __instance)
	{
		if (Plugin.main.rushing)
		{
			TMP_Text extraInfo = __instance.extraInfo;
			extraInfo.text += "- <color=#ffda75>BROKEN BOSS RUSH ENEMY</color>\n";
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(FinalRank), "SetRank")]
	private static void RankColor(FinalRank __instance)
	{
		//IL_0035: 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)
		if (Plugin.main.rushing)
		{
			((Graphic)((Component)__instance.totalRank.transform.parent).GetComponent<Image>()).color = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)136, (byte)0, byte.MaxValue));
			__instance.totalRank.text = "-";
		}
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(OptionsMenuToManager), "RestartCheckpoint")]
	private static bool RestartCheckpoint(OptionsMenuToManager __instance)
	{
		if (Plugin.main.rushing)
		{
			MonoSingleton<HudMessageReceiver>.Instance.SendHudMessage("You cannot restart checkpoint while in a boss rush!", "", "", 0, false, false, true);
			return false;
		}
		return true;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(OptionsMenuToManager), "RestartMission")]
	private static bool RestartMission(OptionsMenuToManager __instance)
	{
		if (Plugin.main.rushing)
		{
			MonoSingleton<HudMessageReceiver>.Instance.SendHudMessage("You cannot restart mission while in a boss rush!", "", "", 0, false, false, true);
			return false;
		}
		return true;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(OptionsMenuToManager), "RestartMissionNoConfirm")]
	private static bool RestartMissionNoConfirm(OptionsMenuToManager __instance)
	{
		if (Plugin.main.rushing)
		{
			MonoSingleton<HudMessageReceiver>.Instance.SendHudMessage("You cannot restart mission while in a boss rush!", "", "", 0, false, false, true);
			return false;
		}
		return true;
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(V2), "Die")]
	private static void V2Death(V2 __instance)
	{
		if (Plugin.main.rushing)
		{
			V2Dead = true;
		}
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(EnemyIdentifier), "DeliverDamage")]
	private static bool DeliverDamageInsta(EnemyIdentifier __instance)
	{
		if (!Plugin.deadcoinV2Disabled)
		{
			return true;
		}
		V2 val = default(V2);
		if (Plugin.main.rushing && ((Component)__instance).TryGetComponent<V2>(ref val) && val.inIntro)
		{
			MonoSingleton<HudMessageReceiver>.Instance.SendHudMessage("You cannot deadcoin V2 in a boss rush!", "", "", 0, false, false, true);
			return false;
		}
		return true;
	}
}
namespace BossRush;

public class Boss
{
	public Type bossComponent;

	public Vector3 position;

	public string level;

	public string name;

	public bool closestCheckpoint = true;
}
[BepInPlugin("com.ultrakill.temp.bossrush", "Boss Rush", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	public enum StartingEnemy
	{
		SwordsMachine,
		Cerberus,
		HideousMass,
		V2_Fight1,
		Gabriel_Fight1,
		V2_Fight2,
		Leviathan,
		Gabriel_Fight2,
		Minotaur,
		EarthMover,
		MinosPrime,
		SisyphusPrime
	}

	[CompilerGenerated]
	private sealed class <>c__DisplayClass23_0
	{
		public bool sceneLoaded;

		internal void <LoadBossLevel>b__0(Scene scene, LoadSceneMode mode)
		{
			sceneLoaded = true;
		}

		internal bool <LoadBossLevel>b__1()
		{
			return sceneLoaded;
		}
	}

	[CompilerGenerated]
	private sealed class <>c__DisplayClass27_0
	{
		public bool dead;

		public Plugin <>4__this;

		internal bool <WaitForDeath>b__1()
		{
			return dead || <>4__this.currentEid.Dead || <>4__this.currentEid.dead || <>4__this.skip || PatchesAll.V2Dead || MonoSingleton<NewMovement>.Instance.dead;
		}
	}

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

		private object <>2__current;

		public Vector3 pos;

		public Plugin <>4__this;

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

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

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

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

		private bool MoveNext()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>4__this.checkpoint = <>4__this.FindNearestCheckpoint(pos);
				<>4__this.checkpoint.SetInvisibility(true);
				<>4__this.checkpoint.ActivateCheckPoint();
				MonoSingleton<OptionsManager>.Instance.RestartCheckpoint();
				MonoSingleton<StatsManager>.Instance.currentCheckPoint = null;
				<>4__this.checkpoint.SetInvisibility(false);
				<>2__current = (object)new WaitForSeconds(0.5f);
				<>1__state = 1;
				return true;
			case 1:
			{
				<>1__state = -1;
				<>4__this.DisableCheckpoint(<>4__this.checkpoint);
				Transform transform = ((Component)MonoSingleton<NewMovement>.Instance).transform;
				transform.position -= ((Component)<>4__this.checkpoint).transform.forward * 8.5f;
				<>4__this.SetBlockVisible(visible: false);
				<>4__this.walking = true;
				<>2__current = (object)new WaitForSeconds(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();
		}
	}

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

		private object <>2__current;

		public Boss b;

		public Plugin <>4__this;

		private <>c__DisplayClass23_0 <>8__1;

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

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

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

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

		private bool MoveNext()
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>8__1 = new <>c__DisplayClass23_0();
				SceneHelper.LoadSceneAsync("Level " + b.level, false);
				<>8__1.sceneLoaded = false;
				SceneManager.sceneLoaded += delegate
				{
					<>8__1.sceneLoaded = true;
				};
				<>2__current = (object)new WaitUntil((Func<bool>)(() => <>8__1.sceneLoaded));
				<>1__state = 1;
				return true;
			case 1:
				<>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();
		}
	}

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

		private object <>2__current;

		public Boss b;

		public Plugin <>4__this;

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

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

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

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

		private bool MoveNext()
		{
			//IL_005b: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Expected O, but got Unknown
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
			{
				<>1__state = -1;
				<>4__this.waiting = true;
				<>4__this.SetBlockVisible(visible: true);
				Rigidbody rb = MonoSingleton<NewMovement>.Instance.rb;
				rb.velocity += Vector3.down * 1500f;
				<>2__current = (object)new WaitForSeconds(1.2f);
				<>1__state = 1;
				return true;
			}
			case 1:
			{
				<>1__state = -1;
				<>4__this.InitSceneArenaMaker(b);
				if (b.closestCheckpoint)
				{
					((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.ActivateRoom(b.position));
				}
				else
				{
					<>4__this.SetBlockVisible(visible: false);
				}
				LevelNamePopup instance = MonoSingleton<LevelNamePopup>.Instance;
				if (instance != null)
				{
					instance.CustomNameAppear("BOSS RUSH | " + b.level, b.name.ToUpper());
				}
				<>4__this.b = b;
				SceneHelper.DismissBlockers();
				MonoSingleton<OnLevelStart>.Instance.StartLevel(true, true);
				SceneHelper.DismissBlockers();
				if (b.closestCheckpoint)
				{
					<>2__current = (object)new WaitUntil((Func<bool>)(() => (Object)(object)MonoSingleton<StatsManager>.Instance.currentCheckPoint == (Object)(object)<>4__this.checkpoint));
					<>1__state = 2;
					return true;
				}
				goto IL_0187;
			}
			case 2:
				<>1__state = -1;
				goto IL_0187;
			case 3:
				{
					<>1__state = -1;
					<>4__this.waiting = false;
					<>4__this.walking = false;
					MonoSingleton<NewMovement>.Instance.ReactivateMovement();
					MonoSingleton<CameraController>.Instance.activated = true;
					return false;
				}
				IL_0187:
				<>2__current = (object)new WaitForSeconds(0.06f);
				<>1__state = 3;
				return true;
			}
		}

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

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

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

		private object <>2__current;

		public Plugin <>4__this;

		private int <i>5__1;

		private Boss <b>5__2;

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

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

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

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

		private bool MoveNext()
		{
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				PatchesAll.V2Dead = false;
				<>4__this.rushing = true;
				<i>5__1 = (int)<>4__this.starting.value;
				break;
			case 1:
				<>1__state = -1;
				<>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.SetupBossArena(<b>5__2));
				<>1__state = 2;
				return true;
			case 2:
				<>1__state = -1;
				<>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.WaitForDeath(<b>5__2));
				<>1__state = 3;
				return true;
			case 3:
				<>1__state = -1;
				<>4__this.skip = false;
				<b>5__2 = null;
				<i>5__1++;
				break;
			}
			if (<i>5__1 < <>4__this.bosses.Count)
			{
				<b>5__2 = <>4__this.bosses[<i>5__1];
				<>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.LoadBossLevel(<b>5__2));
				<>1__state = 1;
				return true;
			}
			return false;
		}

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

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

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

		private object <>2__current;

		public Boss b;

		public Plugin <>4__this;

		private <>c__DisplayClass27_0 <>8__1;

		private EnemyIdentifier <closest>5__2;

		private float <closestDist>5__3;

		private Object[] <>s__4;

		private int <>s__5;

		private Object <comp>5__6;

		private EnemyIdentifier <eid>5__7;

		private float <dist>5__8;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>8__1 = null;
			<closest>5__2 = null;
			<>s__4 = null;
			<comp>5__6 = null;
			<eid>5__7 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Expected O, but got Unknown
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: 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_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Expected O, but got Unknown
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Expected O, but got Unknown
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				break;
			case 1:
			{
				<>1__state = -1;
				<>4__this.currentEid.onDeath.RemoveListener(new UnityAction(listener));
				Enemy machine = <>4__this.currentEid.machine;
				if (machine != null)
				{
					machine.onDeath.RemoveListener(new UnityAction(listener));
				}
				if (<>8__1.dead || <>4__this.currentEid.Dead || <>4__this.currentEid.dead)
				{
					return false;
				}
				<>8__1 = null;
				<closest>5__2 = null;
				break;
			}
			}
			<>8__1 = new <>c__DisplayClass27_0();
			<>8__1.<>4__this = <>4__this;
			<closest>5__2 = null;
			<closestDist>5__3 = float.MaxValue;
			<>s__4 = Object.FindObjectsOfType(b.bossComponent, true);
			for (<>s__5 = 0; <>s__5 < <>s__4.Length; <>s__5++)
			{
				<comp>5__6 = <>s__4[<>s__5];
				<eid>5__7 = ((Component)<comp>5__6).GetComponent<EnemyIdentifier>();
				if (!((Object)(object)<eid>5__7 == (Object)null))
				{
					<dist>5__8 = Vector3.Distance(((Component)<comp>5__6).transform.position, b.position);
					if (<dist>5__8 < <closestDist>5__3)
					{
						<closestDist>5__3 = <dist>5__8;
						<closest>5__2 = <eid>5__7;
					}
					<eid>5__7 = null;
					<comp>5__6 = null;
				}
			}
			<>s__4 = null;
			if ((Object)(object)<closest>5__2 == (Object)null || MonoSingleton<NewMovement>.Instance.dead)
			{
				return false;
			}
			<>4__this.currentEid = <closest>5__2;
			<>8__1.dead = false;
			<>4__this.currentEid.onDeath.AddListener(new UnityAction(listener));
			Enemy machine2 = <>4__this.currentEid.machine;
			if (machine2 != null)
			{
				machine2.onDeath.AddListener(new UnityAction(listener));
			}
			<>2__current = (object)new WaitUntil((Func<bool>)(() => <>8__1.dead || <>8__1.<>4__this.currentEid.Dead || <>8__1.<>4__this.currentEid.dead || <>8__1.<>4__this.skip || PatchesAll.V2Dead || MonoSingleton<NewMovement>.Instance.dead));
			<>1__state = 1;
			return true;
			void listener()
			{
				((<>c__DisplayClass27_0)this).dead = true;
			}
		}

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

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

	public static Plugin main;

	public List<Boss> bosses = new List<Boss>
	{
		new Boss
		{
			level = "0-3",
			name = "SWORDS MACHINE",
			bossComponent = typeof(SwordsMachine),
			position = new Vector3(-71.02f, 91.5f, 315.04f)
		},
		new Boss
		{
			level = "0-5",
			name = "CERBERUS",
			bossComponent = typeof(StatueBoss),
			position = new Vector3(167.19f, -4.5f, 382.06f)
		},
		new Boss
		{
			level = "1-3",
			name = "HIDEOUS MASS",
			bossComponent = typeof(Mass),
			position = new Vector3(0.02f, -9.75f, 381.75f)
		},
		new Boss
		{
			level = "1-4",
			name = "V2 - FIGHT 1",
			bossComponent = typeof(V2),
			position = new Vector3(-0.02f, -15.5f, 565.35f)
		},
		new Boss
		{
			level = "3-2",
			name = "GABRIEL - FIGHT 1",
			bossComponent = typeof(GabrielBase),
			position = new Vector3(0f, -159.49f, 310.77f)
		},
		new Boss
		{
			level = "4-4",
			name = "V2 - FIGHT 2",
			bossComponent = typeof(V2),
			position = new Vector3(117.85f, 665f, 348.53f)
		},
		new Boss
		{
			level = "5-4",
			name = "LEVIATHAN",
			bossComponent = typeof(LeviathanController),
			position = new Vector3(641.25f, 692f, 484f)
		},
		new Boss
		{
			level = "6-2",
			name = "GABRIEL - FIGHT 2",
			bossComponent = typeof(GabrielBase),
			position = new Vector3(-149.03f, 11.5f, 350.18f)
		},
		new Boss
		{
			level = "7-1",
			name = "MINOTAUR",
			bossComponent = typeof(Minotaur),
			position = new Vector3(-242.54f, -112.5f, 322.65f)
		},
		new Boss
		{
			level = "7-4",
			name = "EARTHMOVER",
			bossComponent = typeof(TempSpider),
			position = new Vector3(0f, -4.82f, 344.24f),
			closestCheckpoint = false
		},
		new Boss
		{
			level = "P-1",
			name = "MINOS PRIME && FLESH PRISON",
			bossComponent = typeof(MinosPrime),
			position = new Vector3(341.64f, -597f, 110.25f)
		},
		new Boss
		{
			level = "P-2",
			name = "SISYPHUS PRIME && FLESH PANOPTICON",
			bossComponent = typeof(SisyphusPrime),
			position = new Vector3(-101.96f, -39.75f, -428.55f)
		}
	};

	public bool skip;

	public Boss b;

	public bool rushing;

	public bool debug = false;

	private bool waiting;

	private bool walking;

	private CheckPoint checkpoint;

	private EnemyIdentifier currentEid;

	private Traverse movementTraverse;

	private GameObject blockCustom;

	private FileStream stream;

	private string lastLvl;

	private EnumField<StartingEnemy> starting;

	public static bool deadcoinV2Disabled;

	public void Awake()
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		SceneManager.sceneLoaded += delegate
		{
			if (SceneHelper.CurrentScene == "Main Menu")
			{
				FinishRush();
			}
			movementTraverse = null;
			MakeBlockCustom();
		};
		new Harmony("com.ultrakill.temp.bossrush").PatchAll();
		main = this;
		MakePluginConfig();
		if (debug)
		{
			stream = new FileStream("D:\\SteamLibrary\\steamapps\\common\\ULTRAKILL\\BOSSRUSH_REPORT.txt", FileMode.Create, FileAccess.Write, FileShare.Read);
		}
		Log("Boss Rush loaded!");
	}

	private void MakePluginConfig()
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Expected O, but got Unknown
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Expected O, but got Unknown
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Expected O, but got Unknown
		PluginConfigurator val = PluginConfigurator.Create("Boss Rush", "com.ultrakill.temp.bossrush");
		val.SetIconWithURL("https://static.vecteezy.com/system/resources/previews/026/134/645/non_2x/red-arrow-graph-drop-arrow-down-with-on-red-background-money-losing-stock-crisis-and-finance-concept-vector.jpg");
		ConfigDivision val2 = new ConfigDivision(val.rootPanel, "bossrush");
		starting = new EnumField<StartingEnemy>((ConfigPanel)(object)val2, "Starting Boss", "startingBoss", StartingEnemy.SwordsMachine);
		ButtonField val3 = new ButtonField((ConfigPanel)(object)val2, "Start Boss Rush", "startBoshRush");
		val3.onClick += (OnClick)delegate
		{
			((MonoBehaviour)this).StartCoroutine(StartBossRush());
		};
	}

	public void Update()
	{
		if (waiting)
		{
			MonoSingleton<CameraController>.Instance.activated = false;
			MonoSingleton<NewMovement>.Instance.DeactivateMovement();
		}
		if (walking)
		{
			UpdateWalking();
		}
	}

	public void OnGUI()
	{
		if (!debug)
		{
			return;
		}
		GUILayout.BeginVertical(GUI.skin.box, Array.Empty<GUILayoutOption>());
		if (debug)
		{
			GUILayout.Label("-- Debug -- ", Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Report Boss", Array.Empty<GUILayoutOption>()))
			{
				Report();
			}
		}
		GUILayout.EndVertical();
	}

	private void OnApplicationQuit()
	{
		stream?.Close();
	}

	[IteratorStateMachine(typeof(<StartBossRush>d__22))]
	private IEnumerator StartBossRush()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <StartBossRush>d__22(0)
		{
			<>4__this = this
		};
	}

	[IteratorStateMachine(typeof(<LoadBossLevel>d__23))]
	private IEnumerator LoadBossLevel(Boss b)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <LoadBossLevel>d__23(0)
		{
			<>4__this = this,
			b = b
		};
	}

	private void InitSceneArenaMaker(Boss b)
	{
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		switch (b.level)
		{
		case "P-2":
			return;
		case "1-4":
		{
			Door ignore = FindNearestDoor(b.position, null);
			Door val = FindNearestDoor(b.position, ignore);
			Door[] array = Object.FindObjectsOfType<Door>();
			foreach (Door val2 in array)
			{
				if (!((Object)(object)val2 == (Object)(object)val))
				{
					val2.Lock();
				}
			}
			return;
		}
		}
		Door val3 = FindNearestDoor(b.position, null);
		Door[] array2 = Object.FindObjectsOfType<Door>();
		foreach (Door val4 in array2)
		{
			if (!((Object)(object)val4 == (Object)(object)val3))
			{
				val4.Lock();
			}
		}
	}

	[IteratorStateMachine(typeof(<SetupBossArena>d__25))]
	private IEnumerator SetupBossArena(Boss b)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <SetupBossArena>d__25(0)
		{
			<>4__this = this,
			b = b
		};
	}

	[IteratorStateMachine(typeof(<ActivateRoom>d__26))]
	private IEnumerator ActivateRoom(Vector3 pos)
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <ActivateRoom>d__26(0)
		{
			<>4__this = this,
			pos = pos
		};
	}

	[IteratorStateMachine(typeof(<WaitForDeath>d__27))]
	private IEnumerator WaitForDeath(Boss b)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <WaitForDeath>d__27(0)
		{
			<>4__this = this,
			b = b
		};
	}

	private void FinishRush()
	{
		((MonoBehaviour)this).StopAllCoroutines();
		rushing = false;
		b = null;
	}

	private CheckPoint FindNearestCheckpoint(Vector3 pos)
	{
		//IL_001b: 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)
		CheckPoint result = null;
		float num = float.MaxValue;
		CheckPoint[] array = Object.FindObjectsOfType<CheckPoint>(true);
		foreach (CheckPoint val in array)
		{
			float num2 = Vector3.Distance(pos, ((Component)val).transform.position);
			if (num2 < num)
			{
				num = num2;
				result = val;
			}
		}
		return result;
	}

	private Door FindNearestDoor(Vector3 pos, Door ignore)
	{
		//IL_002b: 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)
		Door result = null;
		float num = float.MaxValue;
		Door[] array = Object.FindObjectsOfType<Door>(true);
		foreach (Door val in array)
		{
			if (!((Object)(object)val == (Object)(object)ignore))
			{
				float num2 = Vector3.Distance(pos, ((Component)val).transform.position);
				if (num2 < num)
				{
					num = num2;
					result = val;
				}
			}
		}
		return result;
	}

	private void DisableCheckpoint(CheckPoint cp)
	{
		Traverse val = Traverse.Create((object)cp);
		val.Field("activated").SetValue((object)false);
		GameObject value = val.Field("graphic").GetValue<GameObject>();
		if ((Object)(object)value != (Object)null)
		{
			value.SetActive(true);
		}
		if ((Object)(object)MonoSingleton<StatsManager>.Instance.currentCheckPoint == (Object)(object)cp)
		{
			MonoSingleton<StatsManager>.Instance.currentCheckPoint = null;
		}
	}

	private void UpdateWalking()
	{
		//IL_0029: 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_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)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		if (movementTraverse == null)
		{
			movementTraverse = Traverse.Create((object)MonoSingleton<NewMovement>.Instance);
		}
		Vector3 val = ((Component)checkpoint).transform.position - ((Component)MonoSingleton<NewMovement>.Instance).transform.position;
		val.y = 0f;
		movementTraverse.Field("inputDir").SetValue((object)((Vector3)(ref val)).normalized);
	}

	private void MakeBlockCustom()
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: 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_0079: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			GameObject val = (GameObject)Traverse.Create((object)MonoSingleton<SceneHelper>.Instance).Field("loadingBlocker").GetValue();
			if ((Object)(object)val == (Object)null)
			{
				Log("Blocker is null");
				return;
			}
			blockCustom = Object.Instantiate<GameObject>(val);
			Image componentInChildren = blockCustom.GetComponentInChildren<Image>();
			((Graphic)componentInChildren).color = new Color(((Graphic)componentInChildren).color.r, ((Graphic)componentInChildren).color.g, ((Graphic)componentInChildren).color.b, 1f);
			blockCustom.SetActive(false);
		}
		catch (Exception ex)
		{
			Log("Error making custom blocker: " + ex.ToString());
		}
	}

	private void SetBlockVisible(bool visible)
	{
		if ((Object)(object)blockCustom == (Object)null)
		{
			MakeBlockCustom();
		}
		blockCustom.SetActive(visible);
	}

	public void Report()
	{
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		string text = StockMapInfo.Instance.assets.LargeText.Split(new char[1] { ':' })[0];
		if (lastLvl != text)
		{
			WriteLine(text + ":");
		}
		lastLvl = text;
		WriteLine("    Boss Name: " + GetBossName());
		WriteLine($"    Player Position: {MonoSingleton<NewMovement>.Instance.Position}");
	}

	private string GetBossName()
	{
		EnemyIdentifier[] array = Object.FindObjectsOfType<EnemyIdentifier>(true);
		foreach (EnemyIdentifier val in array)
		{
			if (val.isBoss)
			{
				return val.FullName;
			}
		}
		EnemyScript[] array2 = Object.FindObjectsOfType<EnemyScript>(true);
		BossHealthBar val3 = default(BossHealthBar);
		foreach (EnemyScript val2 in array2)
		{
			if (((Component)val2).TryGetComponent<BossHealthBar>(ref val3))
			{
				return ((object)val2).GetType().Name;
			}
			FieldInfo[] fields = ((object)val2).GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (FieldInfo fieldInfo in fields)
			{
				if (fieldInfo.FieldType == typeof(BossHealthBar))
				{
					return ((object)val2).GetType().Name;
				}
			}
		}
		return "Not Found";
	}

	private void WriteLine(string text)
	{
		byte[] bytes = new UTF8Encoding(encoderShouldEmitUTF8Identifier: true).GetBytes(text + "\n");
		stream.Write(bytes, 0, bytes.Length);
		stream.Flush();
	}

	public static void Log(string msg)
	{
		((BaseUnityPlugin)main).Logger.LogMessage((object)msg);
	}
}
public static class PluginInfo
{
	public const string Name = "Boss Rush";

	public const string Version = "1.0.0";

	public const string Creator = "Temp";

	public const string GUID = "com.ultrakill.temp.bossrush";
}