Decompiled source of NoReaperInCybergrind v1.0.0

NoMirrorReaperCybergrind.dll

Decompiled 5 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("NoMirrorReaperCybergrind")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NoMirrorReaperCybergrind")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c0540e75-ef89-4a2e-b5cd-8de9582cbfbd")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("winter.nomirrorreaper.il", "No Mirror Reaper Cybergrind Final", "16.4")]
public class NoMirrorReaperFinal : BaseUnityPlugin
{
	[CompilerGenerated]
	private sealed class <KillMirrorReaperSafely>d__3 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public EnemyIdentifier enemy;

		public NoMirrorReaperFinal <>4__this;

		private EndlessGrid <grid>5__1;

		private ActivateNextWave <anw>5__2;

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

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

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

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

		private bool MoveNext()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Invalid comparison between Unknown and I4
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(0.5f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				if ((Object)(object)enemy == (Object)null || enemy.dead)
				{
					return false;
				}
				if ((int)enemy.enemyType != 41)
				{
					return false;
				}
				enemy.Death();
				<>2__current = (object)new WaitForSeconds(1.5f);
				<>1__state = 2;
				return true;
			case 2:
			{
				<>1__state = -1;
				if ((Object)(object)enemy == (Object)null)
				{
					return false;
				}
				if (!enemy.dead)
				{
					ManualLogSource log = Log;
					if (log != null)
					{
						log.LogInfo((object)"MirrorReaper resurrected after Death(), incrementing counter manually");
					}
					<grid>5__1 = MonoSingleton<EndlessGrid>.Instance;
					if ((Object)(object)<grid>5__1 != (Object)null)
					{
						ref ActivateNextWave reference = ref <anw>5__2;
						object? value = AccessTools.Field(typeof(EndlessGrid), "anw").GetValue(<grid>5__1);
						reference = (ActivateNextWave)((value is ActivateNextWave) ? value : null);
						if ((Object)(object)<anw>5__2 != (Object)null)
						{
							ActivateNextWave obj = <anw>5__2;
							obj.deadEnemies++;
						}
						<anw>5__2 = null;
					}
					<grid>5__1 = null;
				}
				ManualLogSource log2 = Log;
				if (log2 != null)
				{
					log2.LogInfo((object)"Destroying MirrorReaper GameObject");
				}
				Object.Destroy((Object)(object)((Component)enemy).gameObject);
				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();
		}
	}

	public static NoMirrorReaperFinal Instance;

	public static ManualLogSource Log;

	private void Awake()
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		Instance = this;
		Log = ((BaseUnityPlugin)this).Logger;
		new Harmony("winter.nomirrorreaper.final").PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"No Mirror Reaper Cybergrind Final loaded.");
	}

	[IteratorStateMachine(typeof(<KillMirrorReaperSafely>d__3))]
	public IEnumerator KillMirrorReaperSafely(EnemyIdentifier enemy)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <KillMirrorReaperSafely>d__3(0)
		{
			<>4__this = this,
			enemy = enemy
		};
	}
}
[HarmonyPatch(typeof(EndlessGrid), "SpawnOnGrid")]
internal class Patch_SpawnOnGrid
{
	private static void Postfix(GameObject __result, bool enemy)
	{
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Invalid comparison between Unknown and I4
		if (!enemy || (Object)(object)__result == (Object)null)
		{
			return;
		}
		EnemyIdentifier componentInChildren = __result.GetComponentInChildren<EnemyIdentifier>(true);
		if (!((Object)(object)componentInChildren == (Object)null) && (int)componentInChildren.enemyType == 41)
		{
			ManualLogSource log = NoMirrorReaperFinal.Log;
			if (log != null)
			{
				log.LogInfo((object)"MirrorReaper detected in SpawnOnGrid, starting coroutine");
			}
			NoMirrorReaperFinal instance = NoMirrorReaperFinal.Instance;
			if (instance != null)
			{
				((MonoBehaviour)instance).StartCoroutine(NoMirrorReaperFinal.Instance.KillMirrorReaperSafely(componentInChildren));
			}
		}
	}
}