Decompiled source of CyberGrindDeathcatcherSoftlockFix v1.0.1

CyberGrindDeathcatcherSoftlockFix.dll

Decompiled 5 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CyberGrindDeathcatcherSoftlockFix")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("CyberGrind Deathcatcher Softlock Fix")]
[assembly: AssemblyTitle("CyberGrindDeathcatcherSoftlockFix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.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 CyberGrindDeathcatcherSoftlockFix
{
	[BepInPlugin("CyberGrindDeathcatcherSoftlockFix", "CyberGrind Deathcatcher Softlock Fix", "1.0.1")]
	[Harmony]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		private void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Harmony val = new Harmony("CyberGrindDeathcatcherSoftlockFix");
			val.PatchAll();
			Logger.LogInfo((object)"Plugin CyberGrindDeathcatcherSoftlockFix is loaded!");
		}

		[HarmonyPatch(typeof(EndlessGrid), "WaveProgressCheck")]
		[HarmonyPostfix]
		private static void ActivateDeathcatchersIfNothingLeft(EndlessGrid __instance)
		{
			if (__instance.endlessEvents.Count <= 0)
			{
				return;
			}
			int num = 0;
			for (int num2 = __instance.endlessEvents.Count - 1; num2 >= 0; num2--)
			{
				if (Object.op_Implicit((Object)(object)((Component)__instance.endlessEvents[num2]).GetComponentInChildren<Deathcatcher>()))
				{
					num++;
				}
			}
			if (num <= 0)
			{
				return;
			}
			int num3 = __instance.enemyAmount - __instance.anw.deadEnemies;
			if (num < num3 || __instance.endlessEvents.Count <= 0)
			{
				return;
			}
			for (int num4 = __instance.endlessEvents.Count - 1; num4 >= 0; num4--)
			{
				Deathcatcher componentInChildren = ((Component)__instance.endlessEvents[num4]).GetComponentInChildren<Deathcatcher>();
				if (Object.op_Implicit((Object)(object)componentInChildren))
				{
					Logger.LogInfo((object)$"Activated Deathcatcher (index {num4}, id {((Object)componentInChildren).GetInstanceID()})");
					__instance.endlessEvents[num4].onActivate.Invoke("");
					__instance.endlessEvents.RemoveAt(num4);
				}
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "CyberGrindDeathcatcherSoftlockFix";

		public const string PLUGIN_NAME = "CyberGrind Deathcatcher Softlock Fix";

		public const string PLUGIN_VERSION = "1.0.1";
	}
}