Decompiled source of CybergrindPowerups v1.2.0

CybergrindPowerups.dll

Decompiled 2 weeks 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 BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Notiffy.API;
using PluginConfig.API;
using PluginConfig.API.Fields;
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("CybergrindPowerups")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CybergrindPowerups")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ccbdd6f0-7249-4d79-9587-2c2fa81d9d51")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
public static class EnemyList
{
	public static List<EnemyType> AllEnemies = new List<EnemyType>
	{
		(EnemyType)3,
		(EnemyType)13,
		(EnemyType)14,
		(EnemyType)15,
		(EnemyType)6,
		(EnemyType)1,
		(EnemyType)20,
		(EnemyType)4,
		(EnemyType)0,
		(EnemyType)7,
		(EnemyType)2,
		(EnemyType)5,
		(EnemyType)26,
		(EnemyType)12,
		(EnemyType)9,
		(EnemyType)21,
		(EnemyType)31,
		(EnemyType)33,
		(EnemyType)34,
		(EnemyType)19,
		(EnemyType)39,
		(EnemyType)40,
		(EnemyType)38,
		(EnemyType)41
	};
}
public class EnemySettings
{
	public BoolField enabled;

	public IntField requiredCount;

	public EnemySettings(ConfigPanel panel, EnemyType enemy)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Invalid comparison between Unknown and I4
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: 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_0027: Invalid comparison between Unknown and I4
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Invalid comparison between Unknown and I4
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Invalid comparison between Unknown and I4
		//IL_007a: 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_009d: Expected O, but got Unknown
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Invalid comparison between Unknown and I4
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Invalid comparison between Unknown and I4
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Invalid comparison between Unknown and I4
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Invalid comparison between Unknown and I4
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Invalid comparison between Unknown and I4
		//IL_0044: 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_0059: Expected I4, but got Unknown
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Expected O, but got Unknown
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Invalid comparison between Unknown and I4
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Invalid comparison between Unknown and I4
		string text = (((int)enemy == 19) ? "Sisyphean Insurrectionist" : GetEnemyDisplayName(enemy));
		bool flag = false;
		EnemyType val = enemy;
		EnemyType val2 = val;
		if ((int)val2 <= 19)
		{
			if ((int)val2 != 5)
			{
				if ((int)val2 == 19)
				{
					flag = true;
				}
			}
			else
			{
				flag = true;
			}
		}
		else if ((int)val2 != 20)
		{
			if ((int)val2 != 26)
			{
				switch (val2 - 39)
				{
				case 1:
					flag = true;
					break;
				case 2:
					flag = true;
					break;
				case 0:
					flag = true;
					break;
				}
			}
			else
			{
				flag = true;
			}
		}
		else
		{
			flag = true;
		}
		enabled = new BoolField(panel, GetEnemyDisplayName(enemy), ((object)(EnemyType)(ref enemy)).ToString().ToLower(), flag);
		int num = 1;
		EnemyType val3 = enemy;
		EnemyType val4 = val3;
		if ((int)val4 <= 19)
		{
			if ((int)val4 != 5)
			{
				if ((int)val4 == 19)
				{
					num = 2;
				}
			}
			else
			{
				num = 2;
			}
		}
		else if ((int)val4 != 20)
		{
			if ((int)val4 == 39)
			{
				num = 2;
			}
		}
		else
		{
			num = 2;
		}
		requiredCount = new IntField(panel, GetEnemyDisplayName(enemy) + " Count", ((object)(EnemyType)(ref enemy)).ToString().ToLower() + "_required_count", num);
	}

	private string GetEnemyDisplayName(EnemyType enemy)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Invalid comparison between Unknown and I4
		EnemyType val = enemy;
		EnemyType val2 = val;
		if ((int)val2 == 19)
		{
			return "Sisyphean";
		}
		return ((object)(EnemyType)(ref enemy)).ToString();
	}
}
public enum SpawnMode
{
	OnPlayer,
	OnEnemySpawn
}
[BepInPlugin("CybergrindPowerups", "Cybergrind Powerups", "1.1.0")]
public class Plugin : BaseUnityPlugin
{
	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static IntValueChangeEventDelegate <>9__13_0;

		internal void <Awake>b__13_0(IntValueChangeEvent changeEvent)
		{
			int value = OrbSpawnChance.value;
			if (value < 0)
			{
				OrbSpawnChance.value = 0;
			}
			else if (value > 100)
			{
				OrbSpawnChance.value = 100;
			}
		}
	}

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

		private object <>2__current;

		public Plugin <>4__this;

		private int <dualWieldAttempts>5__1;

		private int <redSoulAttempts>5__2;

		private GameObject[] <allObjects>5__3;

		private GameObject[] <>s__4;

		private int <>s__5;

		private GameObject <obj>5__6;

		private DualWieldPickup <pickup>5__7;

		private SpawnableObject[] <spawnables>5__8;

		private SpawnableObject[] <>s__9;

		private int <>s__10;

		private SpawnableObject <s>5__11;

		private string <name>5__12;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<allObjects>5__3 = null;
			<>s__4 = null;
			<obj>5__6 = null;
			<pickup>5__7 = null;
			<spawnables>5__8 = null;
			<>s__9 = null;
			<s>5__11 = null;
			<name>5__12 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Expected O, but got Unknown
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				goto IL_0052;
			case 1:
				<>1__state = -1;
				goto IL_0052;
			case 2:
				<>1__state = -1;
				goto IL_01a1;
			case 3:
				{
					<>1__state = -1;
					goto IL_0326;
				}
				IL_0052:
				if ((Object)(object)GameStateManager.Instance == (Object)null)
				{
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				<dualWieldAttempts>5__1 = 0;
				goto IL_01a9;
				IL_032e:
				if (!((Object)(object)RedSoulOrbSpawnable == (Object)null) || <redSoulAttempts>5__2 >= 30)
				{
					break;
				}
				<redSoulAttempts>5__2++;
				<spawnables>5__8 = Resources.FindObjectsOfTypeAll<SpawnableObject>();
				<>s__9 = <spawnables>5__8;
				for (<>s__10 = 0; <>s__10 < <>s__9.Length; <>s__10++)
				{
					<s>5__11 = <>s__9[<>s__10];
					if (!((Object)(object)<s>5__11 == (Object)null))
					{
						<name>5__12 = ((!string.IsNullOrEmpty(<s>5__11.objectName)) ? <s>5__11.objectName : ((Object)<s>5__11).name);
						if (<name>5__12 == "Red Soul Orb")
						{
							RedSoulOrbSpawnable = <s>5__11;
							Log.LogInfo((object)"[SUCCESS] Cached Red Soul Orb");
							break;
						}
						<name>5__12 = null;
						<s>5__11 = null;
					}
				}
				<>s__9 = null;
				if ((Object)(object)RedSoulOrbSpawnable == (Object)null)
				{
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 3;
					return true;
				}
				goto IL_0326;
				IL_01a9:
				if ((Object)(object)RuntimeDualWieldPrefab == (Object)null && <dualWieldAttempts>5__1 < 30)
				{
					<dualWieldAttempts>5__1++;
					<allObjects>5__3 = Resources.FindObjectsOfTypeAll<GameObject>();
					<>s__4 = <allObjects>5__3;
					for (<>s__5 = 0; <>s__5 < <>s__4.Length; <>s__5++)
					{
						<obj>5__6 = <>s__4[<>s__5];
						if (!((Object)(object)<obj>5__6 == (Object)null) && ((Object)<obj>5__6).name.Contains("DualWield"))
						{
							<pickup>5__7 = <obj>5__6.GetComponent<DualWieldPickup>();
							if (!((Object)(object)<pickup>5__7 == (Object)null))
							{
								RuntimeDualWieldPrefab = Object.Instantiate<GameObject>(<obj>5__6);
								Object.DontDestroyOnLoad((Object)(object)RuntimeDualWieldPrefab);
								RuntimeDualWieldPrefab.SetActive(false);
								Log.LogInfo((object)"[SUCCESS] Cached Dual Wield Orb");
								break;
							}
						}
					}
					<>s__4 = null;
					if ((Object)(object)RuntimeDualWieldPrefab == (Object)null)
					{
						<>2__current = (object)new WaitForSeconds(1f);
						<>1__state = 2;
						return true;
					}
					goto IL_01a1;
				}
				if ((Object)(object)RuntimeDualWieldPrefab == (Object)null)
				{
					Log.LogError((object)"[ERROR] Failed to cache Dual Wield Orb");
				}
				<redSoulAttempts>5__2 = 0;
				goto IL_032e;
				IL_01a1:
				<allObjects>5__3 = null;
				goto IL_01a9;
				IL_0326:
				<spawnables>5__8 = null;
				goto IL_032e;
			}
			if ((Object)(object)RedSoulOrbSpawnable == (Object)null)
			{
				Log.LogError((object)"[ERROR] Failed to cache Red Soul Orb");
			}
			if ((Object)(object)RuntimeDualWieldPrefab != (Object)null && (Object)(object)RedSoulOrbSpawnable != (Object)null)
			{
				Log.LogInfo((object)"[SUCCESS] Both Powerups cached");
			}
			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 ManualLogSource Log;

	public static Plugin Instance;

	public static BoolField EnableDualWieldOrb;

	public static BoolField EnableRedSoulOrb;

	public static BoolField EnableOrbSpawnChance;

	public static IntField OrbSpawnChance;

	public static EnumField<SpawnMode> SpawnModeSetting;

	public static GameObject RuntimeDualWieldPrefab;

	public static SpawnableObject RedSoulOrbSpawnable;

	public static List<GameObject> SpawnedPowerups = new List<GameObject>();

	public static Dictionary<EnemyType, EnemySettings> EnemyConfigs = new Dictionary<EnemyType, EnemySettings>();

	public static PluginConfigurator PluginConfigInstance;

	public static void ShowNotification(string title, string message)
	{
		NotificationSystem.NotifySend(title, message, (Sprite)null, "", (Urgency)1, "Cybergrind Powerups", 0u, (Dictionary<string, string>)null, -1);
	}

	private void Awake()
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Expected O, but got Unknown
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Expected O, but got Unknown
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Expected O, but got Unknown
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Expected O, but got Unknown
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Expected O, but got Unknown
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Expected O, but got Unknown
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Expected O, but got Unknown
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Expected O, but got Unknown
		//IL_016b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0170: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Expected O, but got Unknown
		//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
		Instance = this;
		Log = ((BaseUnityPlugin)this).Logger;
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Cybergrind Powerups loaded!");
		Harmony val = new Harmony("CybergrindPowerups");
		((BaseUnityPlugin)this).Logger.LogInfo((object)"[RUNNER] Created successfully");
		val.PatchAll();
		((MonoBehaviour)this).StartCoroutine(CachePowerups());
		PluginConfigInstance = PluginConfigurator.Create("Cybergrind Powerups", "Cybergrind Powerups default config");
		string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
		string iconWithURL = "file:///" + Path.Combine(directoryName, "icon.png").Replace("\\", "/");
		PluginConfigInstance.SetIconWithURL(iconWithURL);
		ConfigPanel val2 = new ConfigPanel(PluginConfigInstance.rootPanel, "Powerup Settings", "powerup_settings");
		ConfigPanel val3 = new ConfigPanel(PluginConfigInstance.rootPanel, "Spawn Settings", "spawn_settings");
		ConfigPanel panel = new ConfigPanel(PluginConfigInstance.rootPanel, "Enemy Settings", "enemy_settings");
		EnableDualWieldOrb = new BoolField(val2, "Dual Wield power-up", "enable_dual_wield_orb", true);
		EnableRedSoulOrb = new BoolField(val2, "Red Soul Orb power-up", "enable_red_soul_orb", true);
		EnableOrbSpawnChance = new BoolField(val2, "Enable Orb Spawn Chance", "enable_orb_spawn_chance", true);
		OrbSpawnChance = new IntField(val2, "Orb Spawn Chance (%)", "orb_spawn_chance", 33);
		IntField orbSpawnChance = OrbSpawnChance;
		object obj = <>c.<>9__13_0;
		if (obj == null)
		{
			IntValueChangeEventDelegate val4 = delegate
			{
				int value = OrbSpawnChance.value;
				if (value < 0)
				{
					OrbSpawnChance.value = 0;
				}
				else if (value > 100)
				{
					OrbSpawnChance.value = 100;
				}
			};
			<>c.<>9__13_0 = val4;
			obj = (object)val4;
		}
		orbSpawnChance.onValueChange += (IntValueChangeEventDelegate)obj;
		if (OrbSpawnChance.value < 0)
		{
			OrbSpawnChance.value = 0;
		}
		if (OrbSpawnChance.value > 100)
		{
			OrbSpawnChance.value = 100;
		}
		SpawnModeSetting = new EnumField<SpawnMode>(val3, "Power-up Spawn Mode", "spawn_mode", SpawnMode.OnEnemySpawn);
		foreach (EnemyType allEnemy in EnemyList.AllEnemies)
		{
			EnemyConfigs[allEnemy] = new EnemySettings(panel, allEnemy);
		}
	}

	private void Update()
	{
		WaveTracker.Update();
	}

	[IteratorStateMachine(typeof(<CachePowerups>d__15))]
	private IEnumerator CachePowerups()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <CachePowerups>d__15(0)
		{
			<>4__this = this
		};
	}
}
public static class PowerupSpawner
{
	public static void SpawnDualWield(Vector3 position)
	{
		//IL_0028: 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)
		if ((Object)(object)Plugin.RuntimeDualWieldPrefab == (Object)null)
		{
			Plugin.Log.LogError((object)"[POWERUP] Runtime DualWield is NULL");
			return;
		}
		GameObject val = Object.Instantiate<GameObject>(Plugin.RuntimeDualWieldPrefab, position, Quaternion.identity);
		Plugin.SpawnedPowerups.Add(val);
		val.SetActive(true);
		Plugin.Log.LogInfo((object)"[POWERUP] Spawned Dual Wield Orb");
	}

	public static void SpawnRedSoulOrb(Vector3 position)
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Plugin.RedSoulOrbSpawnable == (Object)null)
		{
			Plugin.Log.LogError((object)"[POWERUP] RedSoulOrbSpawnable is NULL");
			return;
		}
		GameObject val = Object.Instantiate<GameObject>(Plugin.RedSoulOrbSpawnable.gameObject, position, Quaternion.identity);
		Plugin.SpawnedPowerups.Add(val);
		val.SetActive(true);
		Plugin.Log.LogInfo((object)"[POWERUP] Spawned Red Soul Orb");
	}
}
[HarmonyPatch(typeof(EndlessGrid))]
[HarmonyPatch("SpawnOnGrid")]
public class SpawnHook
{
	public static void Postfix(GameObject __result, bool enemy)
	{
		//IL_002d: 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)
		if (enemy && !((Object)(object)__result == (Object)null))
		{
			EnemyIdentifier componentInChildren = __result.GetComponentInChildren<EnemyIdentifier>();
			if (!((Object)(object)componentInChildren == (Object)null))
			{
				WaveTracker.RegisterEnemy(componentInChildren.enemyType, ((Component)componentInChildren).transform.position);
			}
		}
	}
}
public static class WaveTracker
{
	[CompilerGenerated]
	private sealed class <DelayedGutterCheck>d__9 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		private EnemyIdentifier[] <enemies>5__1;

		private EnemyIdentifier[] <>s__2;

		private int <>s__3;

		private EnemyIdentifier <enemy>5__4;

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

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

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

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

		private bool MoveNext()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Invalid comparison between Unknown and I4
			//IL_00d7: 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)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(5f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				if (orbTriggeredThisWave)
				{
					return false;
				}
				<enemies>5__1 = Object.FindObjectsOfType<EnemyIdentifier>(true);
				<>s__2 = <enemies>5__1;
				for (<>s__3 = 0; <>s__3 < <>s__2.Length; <>s__3++)
				{
					<enemy>5__4 = <>s__2[<>s__3];
					if (!((Object)(object)<enemy>5__4 == (Object)null) && ((int)<enemy>5__4.enemyType == 33 || (int)<enemy>5__4.enemyType == 34))
					{
						Plugin.Log.LogInfo((object)"[DELAYED CHECK] Found gutter enemy");
						CheckDelayedGutterSpawn(<enemy>5__4.enemyType, ((Component)<enemy>5__4).transform.position);
						return false;
					}
				}
				<>s__2 = null;
				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 Dictionary<EnemyType, int> CurrentWaveEnemies = new Dictionary<EnemyType, int>();

	private static int lastWave = -1;

	private static EndlessGrid cachedGrid;

	private static bool orbTriggeredThisWave = false;

	private static bool rollAttemptedThisWave = false;

	public static void Update()
	{
		if ((Object)(object)cachedGrid == (Object)null)
		{
			cachedGrid = Object.FindObjectOfType<EndlessGrid>();
		}
		if ((Object)(object)cachedGrid == (Object)null || cachedGrid.currentWave == lastWave)
		{
			return;
		}
		lastWave = cachedGrid.currentWave;
		CurrentWaveEnemies.Clear();
		orbTriggeredThisWave = false;
		rollAttemptedThisWave = false;
		if ((Object)(object)Plugin.Instance != (Object)null)
		{
			((MonoBehaviour)Plugin.Instance).StartCoroutine(DelayedGutterCheck());
			Plugin.Log.LogInfo((object)"[DELAYED CHECK] Coroutine started");
		}
		else
		{
			Plugin.Log.LogError((object)"[DELAYED CHECK] Plugin Instance is NULL");
		}
		foreach (GameObject spawnedPowerup in Plugin.SpawnedPowerups)
		{
			if ((Object)(object)spawnedPowerup != (Object)null)
			{
				Object.Destroy((Object)(object)spawnedPowerup);
			}
		}
		Plugin.SpawnedPowerups.Clear();
		Plugin.Log.LogInfo((object)("[CybergrindPowerups] New Wave: " + lastWave));
	}

	public static void RegisterEnemy(EnemyType type, Vector3 enemyPosition)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: 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)
		//IL_0031: 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)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		if (!CurrentWaveEnemies.ContainsKey(type))
		{
			CurrentWaveEnemies[type] = 0;
		}
		CurrentWaveEnemies[type]++;
		CheckEnemyConditions(type, enemyPosition);
	}

	private static void CheckEnemyConditions(EnemyType type, Vector3 enemyPosition)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Invalid comparison between Unknown and I4
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: 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_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_0278: Unknown result type (might be due to invalid IL or missing references)
		//IL_027d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0287: Unknown result type (might be due to invalid IL or missing references)
		//IL_028c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0291: Unknown result type (might be due to invalid IL or missing references)
		//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0318: Unknown result type (might be due to invalid IL or missing references)
		string text = ((object)(EnemyType)(ref type)).ToString();
		if ((int)type == 19)
		{
			text = "Insurrectionist";
		}
		if (orbTriggeredThisWave || rollAttemptedThisWave || !Plugin.EnemyConfigs.ContainsKey(type))
		{
			return;
		}
		EnemySettings enemySettings = Plugin.EnemyConfigs[type];
		if (!enemySettings.enabled.value || !CurrentWaveEnemies.ContainsKey(type))
		{
			return;
		}
		int num = CurrentWaveEnemies[type];
		int num2 = enemySettings.requiredCount.value;
		if (num2 < 1)
		{
			num2 = 1;
			enemySettings.requiredCount.value = 1;
		}
		if (num != num2)
		{
			return;
		}
		rollAttemptedThisWave = true;
		if (Plugin.EnableOrbSpawnChance.value)
		{
			int num3 = Random.Range(0, 100);
			if (num3 >= Plugin.OrbSpawnChance.value)
			{
				Plugin.Log.LogInfo((object)("[ROLL FAILED] " + num3 + "/" + Plugin.OrbSpawnChance.value));
				Plugin.ShowNotification("Roll Failed", text + " failed the spawn roll (" + num3 + "/" + Plugin.OrbSpawnChance.value + ")");
				return;
			}
			Plugin.Log.LogInfo((object)("[ROLL SUCCESS] " + num3 + "/" + Plugin.OrbSpawnChance.value));
			Plugin.ShowNotification("Roll Success", text + " passed the spawn roll (" + num3 + "/" + Plugin.OrbSpawnChance.value + ")");
		}
		orbTriggeredThisWave = true;
		Plugin.Log.LogInfo((object)("[ORB CONDITION MET] " + ((object)(EnemyType)(ref type)).ToString() + " reached count " + num));
		Vector3 position;
		if (Plugin.SpawnModeSetting.value == SpawnMode.OnPlayer)
		{
			position = ((Component)MonoSingleton<NewMovement>.Instance).transform.position + Vector3.up * 2f;
		}
		else
		{
			if (Plugin.SpawnModeSetting.value != SpawnMode.OnEnemySpawn)
			{
				Plugin.Log.LogInfo((object)"[POWERUP] No spawn mode enabled");
				return;
			}
			position = enemyPosition + Vector3.up * 2f;
		}
		if (Plugin.EnableDualWieldOrb.value)
		{
			PowerupSpawner.SpawnDualWield(position);
			Plugin.ShowNotification("Power-up Spawned", text + " spawned Dual Wield Orb");
		}
		if (Plugin.EnableRedSoulOrb.value)
		{
			PowerupSpawner.SpawnRedSoulOrb(position);
			Plugin.ShowNotification("Power-up Spawned", text + " spawned Red Soul Orb");
		}
	}

	private static Vector3 GetRandomEnemySpawnPosition()
	{
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: 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)
		//IL_005c: 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)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)cachedGrid == (Object)null)
		{
			cachedGrid = Object.FindObjectOfType<EndlessGrid>();
		}
		if ((Object)(object)cachedGrid == (Object)null)
		{
			return ((Component)MonoSingleton<NewMovement>.Instance).transform.position;
		}
		return ((Component)cachedGrid).transform.position + Vector3.up * 3f;
	}

	[IteratorStateMachine(typeof(<DelayedGutterCheck>d__9))]
	private static IEnumerator DelayedGutterCheck()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <DelayedGutterCheck>d__9(0);
	}

	private static void CheckDelayedGutterSpawn(EnemyType type, Vector3 enemyPosition)
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: 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)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		if (orbTriggeredThisWave || !Plugin.EnemyConfigs.ContainsKey(type))
		{
			return;
		}
		EnemySettings enemySettings = Plugin.EnemyConfigs[type];
		if (!enemySettings.enabled.value)
		{
			return;
		}
		int num = Random.Range(0, 100);
		if (Plugin.EnableOrbSpawnChance.value && num >= Plugin.OrbSpawnChance.value)
		{
			Plugin.Log.LogInfo((object)"[GUTTER ROLL FAILED]");
			return;
		}
		orbTriggeredThisWave = true;
		Plugin.Log.LogInfo((object)"[GUTTER FOUND]");
		Vector3 position = ((Plugin.SpawnModeSetting.value != 0) ? (enemyPosition + Vector3.up * 2f) : (((Component)MonoSingleton<NewMovement>.Instance).transform.position + Vector3.up * 2f));
		if (Plugin.EnableDualWieldOrb.value)
		{
			PowerupSpawner.SpawnDualWield(position);
		}
		if (Plugin.EnableRedSoulOrb.value)
		{
			PowerupSpawner.SpawnRedSoulOrb(position);
		}
		Plugin.ShowNotification("Delayed Spawn", ((object)(EnemyType)(ref type)).ToString() + " triggered power-up spawn");
	}
}