Decompiled source of CybergrindBosses v0.0.0

CybergrindBosses.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Nyxpiri.ULTRAKILL.NyxLib;
using Nyxpiri.ULTRAKILL.NyxLib.EnemyTypes;
using Nyxpiri.Unity.Collections;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;

[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: AssemblyVersion("0.0.0.0")]
namespace Nyxpiri.ULTRAKILL.CybergrindBosses;

public static class Assets
{
	internal static void Initialize()
	{
	}
}
public class BlackholeModifier : MonoBehaviour
{
	[HarmonyPatch(typeof(BlackHoleProjectile), "OnTriggerEnter")]
	public static class BlackHoleProjectileOnTriggerEnterPatch
	{
		public static bool Prefix(BlackHoleProjectile __instance, Collider other)
		{
			if (!Cheats.Enabled)
			{
				return true;
			}
			BlackholeModifier component = ((Component)__instance).GetComponent<BlackholeModifier>();
			if ((Object)(object)component == (Object)null)
			{
				return true;
			}
			if (!__instance.enemy || __instance.target == null)
			{
				return true;
			}
			if (!__instance.target.IsTargetTransform(((Component)other).gameObject.transform))
			{
				return true;
			}
			__instance.Explode();
			NewMovement instance = MonoSingleton<NewMovement>.Instance;
			if (instance.hp > component.KillThreshold)
			{
				int num = Mathf.Min(component.Damage, instance.hp - 1);
				instance.GetHurt(num, true, 1f, false, false, 0.35f, false);
				instance.ForceAntiHP((float)(100 - instance.hp), false, false, true, false);
			}
			else
			{
				instance.GetHurt(component.KillThreshold, true, 1f, false, false, 0.35f, false);
			}
			return false;
		}

		public static void Postfix(BlackHoleProjectile __instance, Collider other)
		{
		}
	}

	public int KillThreshold = 10;

	public int Damage = 99;

	public float RescaleOnStart = 1f;

	public float SpeedScalar = 1f;

	public BlackHoleProjectile BlackHole { get; private set; } = null;


	protected void Start()
	{
		//IL_0015: 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)
		BlackHole = ((Component)this).GetComponent<BlackHoleProjectile>();
		Transform transform = ((Component)this).transform;
		transform.localScale *= RescaleOnStart;
		BlackHoleProjectile blackHole = BlackHole;
		blackHole.speed *= SpeedScalar;
	}
}
[ConfigureSingleton(/*Could not decode attribute arguments.*/)]
public class BossSpawner : MonoSingleton<BossSpawner>
{
	private int _bossWaveCooldown = 0;

	private BossPicker _bossPicker = new BossPicker();

	private float spawnTimer = 0f;

	private RegistrationTracker FakeFallRegistrator;

	public bool IsBossWave => Cheats.IsCheatEnabled("nyxpiri.cybergrind-bosses") && (_bossWaveCooldown <= 0 || !Options.UseBossWaveCooldown.Value);

	protected void Start()
	{
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Expected O, but got Unknown
		FakeFallRegistrator = new RegistrationTracker((Func<bool>)delegate
		{
			MonoSingleton<CyberArena>.Instance.EnableFakeFall();
			return true;
		}, (Func<bool>)delegate
		{
			MonoSingleton<CyberArena>.Instance.DisableFakeFall();
			return true;
		});
	}

	protected void OnEnable()
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		Cybergrind.PostCybergrindNextWave += new CybergrindPostNextWaveEventHandler(NextWave);
		MonoSingleton<CyberArena>.Instance.OnEnemySpawningFinished += OnEnemySpawningFinished;
	}

	protected void OnDisable()
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		Cybergrind.PostCybergrindNextWave -= new CybergrindPostNextWaveEventHandler(NextWave);
		MonoSingleton<CyberArena>.Instance.OnEnemySpawningFinished -= OnEnemySpawningFinished;
	}

	private void NextWave(EventMethodCancelInfo cancelInfo, EndlessGrid endlessGrid)
	{
		_bossPicker.ShouldFakeFall = false;
		if (!Cheats.IsCheatDisabled("nyxpiri.cybergrind-bosses"))
		{
			FakeFallRegistrator.Unregister();
			if (IsBossWave)
			{
				_bossPicker.SolveBossesToSpawn(endlessGrid);
				_bossWaveCooldown = Random.Range(Options.BossWaveCooldownMin.Value, Options.BossWaveCooldownMax.Value + 1);
			}
			else
			{
				_bossPicker.TypesToSpawn.Clear();
				_bossWaveCooldown--;
			}
			_bossPicker.UpdateForceFakeFallCooldown();
			if (_bossPicker.ShouldFakeFall)
			{
				spawnTimer = 100f;
			}
			else
			{
				spawnTimer = 0.3f;
			}
			if (IsBossWave || !Options.OnlyCountBossWavesTowardsBossCooldowns.Value)
			{
				_bossPicker.UpdateBossCooldowns();
			}
		}
	}

	private void OnEnemySpawningFinished(CyberArena arena)
	{
		if (!Cheats.IsCheatDisabled("nyxpiri.cybergrind-bosses") && _bossPicker.ShouldFakeFall)
		{
			SetupFakeFall(arena);
		}
	}

	private void BigHarmlessExplosionAt(Vector3 position)
	{
		//IL_0006: 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)
		GameObject val = Object.Instantiate<GameObject>(Assets.ExplosionPrefab, position, Quaternion.identity);
		ExplosionAdditions component = val.GetComponent<ExplosionAdditions>();
		component.Harmless = true;
		component.ExplosionScale = 20f;
		component.ExplosionSpeedScale = 20f;
		component.ExplosionPushScale = 0f;
		val.SetActive(true);
		foreach (AudioSource audio in component.Audios)
		{
			audio.maxDistance *= 100f;
			audio.volume *= 1.2f;
		}
	}

	private void SetupFakeFall(CyberArena arena)
	{
		//IL_0022: 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)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		EnemyComponents[] componentsInChildren = ((Component)arena.Grid).GetComponentsInChildren<EnemyComponents>();
		int points = 0;
		Dictionary<AEnemyType, int> spawnCostIncreases = new Dictionary<AEnemyType, int>();
		FakeFallRegistrator.Register();
		BigHarmlessExplosionAt(CyberArena.HorizontalCenter);
		BigHarmlessExplosionAt(CyberArena.HorizontalCenter);
		MonoSingleton<CyberArena>.Instance.DisableGeometry();
		List<(AEnemyType, Options.EnemyAttributes)> list = new List<(AEnemyType, Options.EnemyAttributes)>();
		foreach (KeyValuePair<AEnemyType, Options.EnemyAttributes> enemiesAttribute in Options.EnemiesAttributes)
		{
			if (enemiesAttribute.Value.CanSpawnInFakeFall.Value && enemiesAttribute.Value.FakeFallSpawnCost.Value > 0 && (Object)(object)EnemyPrefabDatabase.GetPrefab(enemiesAttribute.Key) != (Object)null)
			{
				list.Add((enemiesAttribute.Key, enemiesAttribute.Value));
			}
		}
		EnemyComponents[] array = componentsInChildren;
		foreach (EnemyComponents val in array)
		{
			Options.EnemyAttributes enemyAttributes = Options.EnemiesAttributes[MonoSingleton<EnemyTypeDB>.Instance.GetVanillaType(val.Eid.enemyType)];
			if (!enemyAttributes.CanSpawnInFakeFall.Value)
			{
				points += enemyAttributes.FakeFallDespawnValue.Value;
				SpawnFakeFallEnemy(list, ref points, spawnCostIncreases);
				val.Eid.InstaKill();
				val.InstaDestroy();
			}
		}
		for (int j = 0; j < 100; j++)
		{
			if (!SpawnFakeFallEnemy(list, ref points, spawnCostIncreases))
			{
				break;
			}
		}
		spawnTimer = 0.3f;
	}

	private bool SpawnFakeFallEnemy(List<(AEnemyType, Options.EnemyAttributes)> spawnables, ref int points, Dictionary<AEnemyType, int> spawnCostIncreases)
	{
		//IL_00c1: 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_00df: 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_00e9: 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)
		(AEnemyType, Options.EnemyAttributes)? tuple = null;
		int num = 0;
		foreach (var spawnable in spawnables)
		{
			spawnCostIncreases.TryAdd(spawnable.Item1, 0);
			Options.EnemyAttributes item = spawnable.Item2;
			AEnemyType item2 = spawnable.Item1;
			int value = item.FakeFallSpawnCost.Value;
			if (value > num && points >= value + spawnCostIncreases[spawnable.Item1])
			{
				tuple = spawnable;
				num = value;
			}
		}
		if (!tuple.HasValue)
		{
			return false;
		}
		GameObject val = EnemyPrefabDatabase.TrySpawnAt(tuple.Value.Item1, Vector3.Scale(Random.insideUnitSphere * 30f, new Vector3(1f, 0f, 1f)) + CyberArena.HorizontalCenter, Quaternion.identity, ((Component)MonoSingleton<EndlessGrid>.Instance).transform, true);
		EnemyComponents componentInChildren = val.GetComponentInChildren<EnemyComponents>();
		componentInChildren.Eid.dontCountAsKills = false;
		Collider[] componentsInChildren = ((Component)componentInChildren).GetComponentsInChildren<Collider>();
		Collider[] array = componentsInChildren;
		foreach (Collider val2 in array)
		{
			((Component)val2).gameObject.AddComponent<IgnoreDeathZones>();
		}
		points -= num;
		spawnCostIncreases[tuple.Value.Item1] += tuple.Value.Item2.FakeFallSpawnCostIncreasePerSpawn.Value;
		EndlessGrid instance = MonoSingleton<EndlessGrid>.Instance;
		instance.enemyAmount++;
		EndlessGrid instance2 = MonoSingleton<EndlessGrid>.Instance;
		instance2.tempEnemyAmount++;
		return true;
	}

	protected void FixedUpdate()
	{
		//IL_003e: 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_00df: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_015f: Expected I4, but got Unknown
		//IL_033a: Unknown result type (might be due to invalid IL or missing references)
		//IL_033b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01da: Unknown result type (might be due to invalid IL or missing references)
		//IL_01df: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_023a: Unknown result type (might be due to invalid IL or missing references)
		//IL_023f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0244: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0201: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_029b: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0309: Unknown result type (might be due to invalid IL or missing references)
		//IL_030e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0313: Unknown result type (might be due to invalid IL or missing references)
		//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01af: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01be: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0279: Unknown result type (might be due to invalid IL or missing references)
		//IL_027e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0283: 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_02c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0328: Unknown result type (might be due to invalid IL or missing references)
		//IL_032d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0332: Unknown result type (might be due to invalid IL or missing references)
		//IL_034f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0354: Unknown result type (might be due to invalid IL or missing references)
		//IL_035e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0363: Unknown result type (might be due to invalid IL or missing references)
		//IL_0368: Unknown result type (might be due to invalid IL or missing references)
		//IL_0372: Unknown result type (might be due to invalid IL or missing references)
		//IL_0377: Unknown result type (might be due to invalid IL or missing references)
		//IL_0347: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		//IL_0165: Invalid comparison between Unknown and I4
		//IL_037c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0434: Unknown result type (might be due to invalid IL or missing references)
		//IL_043b: Invalid comparison between Unknown and I4
		//IL_063d: Unknown result type (might be due to invalid IL or missing references)
		//IL_063e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0448: Unknown result type (might be due to invalid IL or missing references)
		//IL_044f: Invalid comparison between Unknown and I4
		//IL_07dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_07e3: Invalid comparison between Unknown and I4
		//IL_0784: Unknown result type (might be due to invalid IL or missing references)
		//IL_0789: Unknown result type (might be due to invalid IL or missing references)
		//IL_079d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0806: Unknown result type (might be due to invalid IL or missing references)
		//IL_080b: Unknown result type (might be due to invalid IL or missing references)
		//IL_081f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0483: Unknown result type (might be due to invalid IL or missing references)
		//IL_048a: Invalid comparison between Unknown and I4
		//IL_0467: Unknown result type (might be due to invalid IL or missing references)
		//IL_055d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0564: Invalid comparison between Unknown and I4
		//IL_04a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d1: Invalid comparison between Unknown and I4
		//IL_0574: Unknown result type (might be due to invalid IL or missing references)
		//IL_061b: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_05f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_05f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0600: Unknown result type (might be due to invalid IL or missing references)
		//IL_0605: Unknown result type (might be due to invalid IL or missing references)
		if (Cheats.IsCheatDisabled("nyxpiri.cybergrind-bosses") || !MonoSingleton<CyberArena>.Instance.GenerationFinished)
		{
			return;
		}
		spawnTimer -= Time.fixedDeltaTime;
		Vector3 val = Vector3.zero;
		if ((_bossPicker.ShouldFakeFall && !MonoSingleton<CyberArena>.Instance.FakeFallActive) || !(spawnTimer <= 0f))
		{
			return;
		}
		spawnTimer = 0.25f;
		if (_bossPicker.TypesToSpawn.Count == 0)
		{
			return;
		}
		AEnemyType val2 = _bossPicker.TypesToSpawn.Dequeue();
		GameObject val3 = null;
		EnemyType? vanillaEnumValue = val2.VanillaEnumValue;
		EnemyType? val4 = vanillaEnumValue;
		if (val4.HasValue)
		{
			EnemyType valueOrDefault = val4.GetValueOrDefault();
			switch (valueOrDefault - 8)
			{
			default:
				if ((int)valueOrDefault == 42)
				{
					val3 = ((Component)EnemyVariants.GeryonPrefab).gameObject;
				}
				break;
			case 8:
				val3 = EnemyPrefabDatabase.GetPrefab((EnemyType)16);
				val = MonoSingleton<CyberArena>.Instance.FloorCenter + Vector3.up * 8f;
				break;
			case 20:
				val3 = EnemyPrefabDatabase.GetPrefab((EnemyType)28);
				val = MonoSingleton<CyberArena>.Instance.FloorCenter + Vector3.up * 16f;
				break;
			case 0:
				val3 = EnemyPrefabDatabase.GetPrefab((EnemyType)8);
				val = CyberArena.RandomOneByOne.GetValueOrDefault(Vector3.zero);
				break;
			case 14:
				val3 = EnemyPrefabDatabase.GetPrefab((EnemyType)22);
				val = CyberArena.RandomOneByOne.GetValueOrDefault(Vector3.zero);
				break;
			case 9:
				val3 = EnemyPrefabDatabase.GetPrefab((EnemyType)17);
				break;
			case 22:
				val3 = EnemyPrefabDatabase.GetPrefab((EnemyType)30);
				break;
			case 10:
				val3 = EnemyPrefabDatabase.GetPrefab((EnemyType)18);
				val = CyberArena.RandomOneByOne.GetValueOrDefault(Vector3.zero);
				break;
			case 3:
				val3 = EnemyVariants.CorpseOfKingMinosPrefab;
				break;
			case 19:
				val3 = ((Component)EnemyVariants.LeviathanPrefab).gameObject;
				break;
			case 21:
				val3 = EnemyPrefabDatabase.GetPrefab((EnemyType)29);
				val = CyberArena.RandomTwoByTwo.GetValueOrDefault(Vector3.zero);
				break;
			case 15:
				val3 = EnemyPrefabDatabase.GetPrefab((EnemyType)23);
				val = CyberArena.RandomOneByOne.GetValueOrDefault(Vector3.zero);
				break;
			case 24:
				val3 = EnemyPrefabDatabase.GetPrefab((EnemyType)32);
				val = CyberArena.RandomThreeByThree.GetValueOrDefault(Vector3.zero);
				break;
			case 16:
				val3 = EnemyPrefabDatabase.GetPrefab((EnemyType)24);
				val = CyberArena.RandomTwoByTwo.GetValueOrDefault(Vector3.zero);
				break;
			case 17:
				val3 = EnemyPrefabDatabase.GetPrefab((EnemyType)25);
				val = CyberArena.RandomTwoByTwo.GetValueOrDefault(Vector3.zero);
				break;
			case 27:
				val = CyberArena.RandomThreeByThree.GetValueOrDefault(CyberArena.RandomTwoByTwo.Value);
				break;
			case 1:
			case 2:
			case 4:
			case 5:
			case 6:
			case 7:
			case 11:
			case 12:
			case 13:
			case 18:
			case 23:
			case 25:
			case 26:
				break;
			}
		}
		GameObject val5 = null;
		val = ((val == Vector3.zero) ? (MonoSingleton<CyberArena>.Instance.FloorCenter + Vector3.up * 10f + Vector3.forward * 10f) : val);
		bool value = Options.EnemyEntries[val2].ShowBossBar.Value;
		if ((Object)(object)val3 != (Object)null)
		{
			val5 = Object.Instantiate<GameObject>(val3, ((Component)MonoSingleton<EndlessGrid>.Instance).gameObject.transform);
			Log.Debug($"done spawning prefab for type {val2}");
			EnemyComponents componentInChildren = val5.GetComponentInChildren<EnemyComponents>();
			((Component)componentInChildren).gameObject.AddComponent<GrindBoss>();
			val5.SetActive(true);
			EnemyIdentifier eid = componentInChildren.Eid;
			componentInChildren.Health *= Options.EnemyEntries[val2].HealthScalar.Value;
			eid.BossBar(value);
			if ((int)val2.VanillaEnumValue.GetValueOrDefault() == 17 || (int)val2.VanillaEnumValue.GetValueOrDefault() == 30)
			{
				val5.transform.position = MonoSingleton<CyberArena>.Instance.FloorCenter;
			}
			else if ((int)val2.VanillaEnumValue.GetValueOrDefault() == 11)
			{
				val5.transform.position = MonoSingleton<CyberArena>.Instance.FloorCenter + Vector3.right * 175f + Vector3.down * 600f;
				BoxCollider[] componentsInChildren = val5.GetComponentsInChildren<BoxCollider>();
				BoxCollider[] array = componentsInChildren;
				foreach (BoxCollider val6 in array)
				{
					((Collider)val6).enabled = (Object)(object)((Component)val6).GetComponent<Rigidbody>() != (Object)null;
				}
				Collider[] componentsInChildren2 = val5.GetComponentsInChildren<Collider>(true);
				Collider[] array2 = componentsInChildren2;
				foreach (Collider val7 in array2)
				{
					GameObjectExtensions.GetOrAddComponent<IgnoreDeathZones>(((Component)val7).gameObject);
				}
			}
			else if ((int)val2.VanillaEnumValue.GetValueOrDefault() == 27)
			{
				val5.transform.position = val;
				Collider[] componentsInChildren3 = val5.GetComponentsInChildren<Collider>(true);
				Collider[] array3 = componentsInChildren3;
				foreach (Collider val8 in array3)
				{
					GameObjectExtensions.GetOrAddComponent<IgnoreDeathZones>(((Component)val8).gameObject);
				}
				LeviathanController component = val5.GetComponent<LeviathanController>();
			}
			else if ((int)val2.VanillaEnumValue.GetValueOrDefault() == 42)
			{
				val5.transform.position = val + Vector3.back * 125f + Vector3.up * 40f;
			}
			else
			{
				val5.transform.position = val;
			}
		}
		else if (val2 == EnemyVariants.TundraAgonyType)
		{
			GameObject val9 = EnemyVariants.SpawnAgonyAndTundra(val, Quaternion.identity, ((Component)MonoSingleton<EndlessGrid>.Instance).transform);
			EnemyComponents[] componentsInChildren4 = val9.GetComponentsInChildren<EnemyComponents>();
			EnemyComponents[] array4 = componentsInChildren4;
			foreach (EnemyComponents val10 in array4)
			{
				val10.Health *= Options.EnemyEntries[val2].HealthScalar.Value;
				GrindBoss grindBoss = ((Component)val10.Eid).gameObject.AddComponent<GrindBoss>();
				val10.ResetHealthInfo();
				val10.Eid.BossBar(value);
				grindBoss.IsTundraAgony = true;
			}
			Transform[] array5 = (Transform[])(object)new Transform[val9.transform.childCount];
			for (int m = 0; m < val9.transform.childCount; m++)
			{
				array5[m] = val9.transform.GetChild(m);
			}
			Transform[] array6 = array5;
			foreach (Transform val11 in array6)
			{
				val11.parent = ((Component)MonoSingleton<EndlessGrid>.Instance).transform;
			}
			Object.Destroy((Object)(object)val9);
		}
		else if (val2 == EnemyVariants.BloodTree)
		{
			BloodFiller val12 = Object.Instantiate<BloodFiller>(EnemyVariants.BloodTreePrefab, CyberArena.RandomTwoByTwo.GetValueOrDefault(MonoSingleton<CyberArena>.Instance.FloorCenter), Quaternion.Euler(-90f, 0f, 0f), ((Component)MonoSingleton<EndlessGrid>.Instance).transform);
			((Component)val12).gameObject.AddComponent<GrindTree>();
			((Component)val12).gameObject.SetActive(true);
		}
		else if ((int)val2.VanillaEnumValue.GetValueOrDefault() == 35)
		{
			val3 = EnemyVariants.CentaurSecurityPrefab;
			GameObject val13 = Object.Instantiate<GameObject>(EnemyVariants.CentaurSecurityPrefab, CyberArena.RandomThreeByThree.GetValueOrDefault(MonoSingleton<CyberArena>.Instance.FloorCenter), Quaternion.Euler(0f, 0f, 0f), ((Component)MonoSingleton<EndlessGrid>.Instance).transform);
			val13.AddComponent<GrindSecurity>();
			val13.SetActive(true);
		}
	}
}
[ConfigureSingleton(/*Could not decode attribute arguments.*/)]
[DefaultExecutionOrder(-10000)]
public class CyberArena : MonoSingleton<CyberArena>
{
	public delegate void GenerationFinishedEventHandler(CyberArena arena);

	public delegate void EnemySpawningFinishedEventHandler(CyberArena arena);

	public static FieldAccess<EndlessGrid, int> incompletePrefabsFA = new FieldAccess<EndlessGrid, int>("incompletePrefabs", BindingFlags.Instance | BindingFlags.NonPublic);

	public static FieldAccess<EndlessGrid, int> incompleteBlocksFA = new FieldAccess<EndlessGrid, int>("incompleteBlocks", BindingFlags.Instance | BindingFlags.NonPublic);

	private List<Vector3> _threeByThrees = new List<Vector3>();

	private List<Vector3> _twoByTwos = new List<Vector3>();

	private List<Vector3> _oneByOnes = new List<Vector3>();

	private bool _initialSpawn;

	private bool _enemySpawningFinished;

	private float _enableZapperTimer;

	private bool _geometryDisabled = false;

	public static Vector3 HorizontalCenter => new Vector3(0f, 0f, 62.5f);

	public Vector3 FloorCenter { get; private set; } = HorizontalCenter;


	public bool GenerationFinished { get; private set; } = false;


	public EndlessGrid Grid { get; private set; } = null;


	public GameObject FakeFallGo { get; private set; }

	public static IReadOnlyList<Vector3> ThreeByThrees => MonoSingleton<CyberArena>.Instance._threeByThrees;

	public static IReadOnlyList<Vector3> TwoByTwos => MonoSingleton<CyberArena>.Instance._twoByTwos;

	public static IReadOnlyList<Vector3> OneByOnes => MonoSingleton<CyberArena>.Instance._oneByOnes;

	public static Vector3? RandomOneByOne => (OneByOnes.Count > 0) ? new Vector3?(OneByOnes[Random.Range(0, OneByOnes.Count)]) : null;

	public static Vector3? RandomTwoByTwo => (TwoByTwos.Count > 0) ? new Vector3?(TwoByTwos[Random.Range(0, TwoByTwos.Count)]) : null;

	public static Vector3? RandomThreeByThree => (ThreeByThrees.Count > 0) ? new Vector3?(ThreeByThrees[Random.Range(0, ThreeByThrees.Count)]) : null;

	public DeathZone ZapperDeathZone { get; private set; } = null;


	public bool ZapperDisabled { get; private set; } = false;


	public bool FakeFallActive { get; private set; } = false;


	public List<GameObject> FakeFallHookPoints { get; private set; } = new List<GameObject>();


	public event GenerationFinishedEventHandler OnGenerationFinished;

	public event EnemySpawningFinishedEventHandler OnEnemySpawningFinished;

	public void DisableGeometry()
	{
		//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)
		Assert.IsTrue(Cheats.Enabled, "");
		_geometryDisabled = true;
		for (int i = 0; i < Grid.cubes.Length; i++)
		{
			EndlessCube[] array = Grid.cubes[i];
			EndlessCube[] array2 = array;
			foreach (EndlessCube val in array2)
			{
				Transform transform = ((Component)val).transform;
				transform.position += Vector3.down * 250f;
			}
		}
		FieldAccess<EndlessGrid, GameObject> val2 = default(FieldAccess<EndlessGrid, GameObject>);
		val2..ctor("combinedGridStaticObject", BindingFlags.Instance | BindingFlags.NonPublic);
		val2.GetValue(Grid).SetActive(false);
		FieldAccess<EndlessGrid, List<CyberPooledPrefab>> val3 = default(FieldAccess<EndlessGrid, List<CyberPooledPrefab>>);
		val3..ctor("jumpPadPool", BindingFlags.Instance | BindingFlags.NonPublic);
		FieldAccess<EndlessGrid, List<GameObject>> val4 = default(FieldAccess<EndlessGrid, List<GameObject>>);
		val4..ctor("spawnedPrefabs", BindingFlags.Instance | BindingFlags.NonPublic);
		List<CyberPooledPrefab> value = val3.GetValue(Grid);
		List<GameObject> value2 = val4.GetValue(Grid);
		DisableZapper();
		foreach (CyberPooledPrefab item in value)
		{
			((Component)item).gameObject.SetActive(false);
		}
		foreach (GameObject item2 in value2)
		{
			if ((Object)(object)item2.GetComponentInChildren<EndlessStairs>() != (Object)null)
			{
				item2.SetActive(false);
			}
		}
	}

	private void EnableZapperIn(float seconds)
	{
		_enableZapperTimer = seconds;
	}

	private void EnableZapper()
	{
		ZapperDisabled = false;
		((Behaviour)ZapperDeathZone).enabled = true;
		((Renderer)((Component)ZapperDeathZone).gameObject.GetComponent<MeshRenderer>()).enabled = true;
	}

	private void DisableZapper()
	{
		ZapperDisabled = true;
		EnforceZapperDisable();
	}

	private void EnforceZapperDisable()
	{
		if (ZapperDisabled)
		{
			((Behaviour)ZapperDeathZone).enabled = false;
			((Renderer)((Component)ZapperDeathZone).gameObject.GetComponent<MeshRenderer>()).enabled = false;
		}
	}

	protected void Awake()
	{
		Grid = ((Component)this).GetComponent<EndlessGrid>();
		EnsureFakeFallZoneExists();
	}

	protected void Start()
	{
		DeathZone[] array = Object.FindObjectsOfType<DeathZone>();
		DeathZone[] array2 = array;
		foreach (DeathZone val in array2)
		{
			if (((Object)((Component)val).gameObject).name == "Cube")
			{
				ZapperDeathZone = val;
			}
		}
		if (!Cheats.IsCheatDisabled("nyxpiri.cybergrind-bosses"))
		{
			EnsureFakeFallHookPointsExist();
		}
	}

	private void EnsureFakeFallZoneExists()
	{
		//IL_0034: 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_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: 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_008c: Unknown result type (might be due to invalid IL or missing references)
		if (!Cheats.IsCheatDisabled("nyxpiri.cybergrind-bosses") && (Object)(object)FakeFallGo == (Object)null)
		{
			FakeFallGo = Object.Instantiate<GameObject>(((Component)EnemyVariants.FakeFallZone).gameObject, HorizontalCenter, Quaternion.identity, ((Component)this).transform);
			FakeFallGo.SetActive(false);
			BoxCollider component = FakeFallGo.GetComponent<BoxCollider>();
			Vector3 size = component.size;
			((Vector3)(ref size)).Scale(new Vector3(100f, 1f, 100f));
			component.size = size;
			FakeFallZone component2 = FakeFallGo.GetComponent<FakeFallZone>();
			component2.heightControlAmount = 30f;
		}
	}

	private void EnsureFakeFallHookPointsExist()
	{
		//IL_002d: 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_003c: 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_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: 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_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)
		//IL_008e: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		if (!Cheats.IsCheatDisabled("nyxpiri.cybergrind-bosses") && FakeFallHookPoints.Count == 0)
		{
			Vector3 val = Vector3.forward * 65f;
			int num = 5;
			for (int i = 0; i < num; i++)
			{
				val.y = 20f;
				Vector3 val2 = Quaternion.Euler(new Vector3(0f, Mathf.Lerp(0f, 360f, (float)i / (float)num), 0f)) * val;
				GameObject item = Object.Instantiate<GameObject>(HookPoints.SlingshotHookPoint, HorizontalCenter + val2, Quaternion.identity, ((Component)MonoSingleton<EndlessGrid>.Instance).transform);
				FakeFallHookPoints.Add(item);
			}
			num = 3;
			for (int j = 0; j < num; j++)
			{
				val.y = 0f;
				Vector3 val3 = Quaternion.Euler(new Vector3(0f, Mathf.Lerp(0f, 360f, (float)j / (float)num), 0f)) * val;
				GameObject item2 = Object.Instantiate<GameObject>(HookPoints.SlingshotHookPoint, HorizontalCenter + val3, Quaternion.identity, ((Component)MonoSingleton<EndlessGrid>.Instance).transform);
				FakeFallHookPoints.Add(item2);
			}
		}
	}

	protected void OnEnable()
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Expected O, but got Unknown
		Cybergrind.PreCybergrindNextWave += new CybergrindPreNextWaveEventHandler(PreNextWave);
		Cybergrind.PostCybergrindNextWave += new CybergrindPostNextWaveEventHandler(NextWave);
	}

	private void PreNextWave(EventMethodCanceler canceler, EndlessGrid endlessGrid)
	{
		if (!Cheats.IsCheatDisabled("nyxpiri.cybergrind-bosses") && _geometryDisabled)
		{
			_geometryDisabled = false;
		}
	}

	protected void OnDisable()
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Expected O, but got Unknown
		Cybergrind.PreCybergrindNextWave -= new CybergrindPreNextWaveEventHandler(PreNextWave);
		Cybergrind.PostCybergrindNextWave -= new CybergrindPostNextWaveEventHandler(NextWave);
	}

	public void EnableFakeFall()
	{
		if (Cheats.IsCheatDisabled("nyxpiri.cybergrind-bosses") || FakeFallActive)
		{
			return;
		}
		EnsureFakeFallZoneExists();
		EnsureFakeFallHookPointsExist();
		FakeFallActive = true;
		FakeFallGo.SetActive(true);
		foreach (GameObject fakeFallHookPoint in FakeFallHookPoints)
		{
			fakeFallHookPoint.SetActive(true);
		}
	}

	public void DisableFakeFall()
	{
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: 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_006e: 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_00c3: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
		if (Cheats.IsCheatDisabled("nyxpiri.cybergrind-bosses") || !FakeFallActive)
		{
			return;
		}
		FakeFallActive = false;
		FakeFallGo.SetActive(false);
		EnableZapperIn(2f);
		Vector3 val = HorizontalCenter - ((Component)MonoSingleton<NewMovement>.Instance).transform.position;
		Transform transform = ((Component)MonoSingleton<NewMovement>.Instance).transform;
		transform.position += val;
		foreach (EnemyIdentifier enemy in MonoSingleton<EnemyTracker>.Instance.enemies)
		{
			if (!((Object)(object)enemy == (Object)null))
			{
				GameObject rootGameObject = ((Component)enemy).GetComponent<EnemyComponents>().RootGameObject;
				Transform transform2 = rootGameObject.transform;
				transform2.position += val;
			}
		}
		foreach (GameObject fakeFallHookPoint in FakeFallHookPoints)
		{
			fakeFallHookPoint.SetActive(false);
		}
	}

	private void NextWave(EventMethodCancelInfo cancelInfo, EndlessGrid endlessGrid)
	{
		if (!Cheats.IsCheatDisabled("nyxpiri.cybergrind-bosses"))
		{
			_initialSpawn = true;
			GenerationFinished = false;
			_enemySpawningFinished = false;
			if (ZapperDisabled)
			{
				EnableZapperIn(0.5f);
			}
		}
	}

	protected void Update()
	{
		if (!Cheats.IsCheatDisabled("nyxpiri.cybergrind-bosses"))
		{
		}
	}

	protected void FixedUpdate()
	{
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: 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 (Cheats.IsCheatDisabled("nyxpiri.cybergrind-bosses") || !Cybergrind.IsActive)
		{
			return;
		}
		if (ZapperDisabled && _enableZapperTimer > 0f)
		{
			_enableZapperTimer -= Time.fixedDeltaTime;
			if (_enableZapperTimer <= 0f)
			{
				EnableZapper();
			}
		}
		EnforceZapperDisable();
		int value = incompletePrefabsFA.GetValue(MonoSingleton<EndlessGrid>.Instance);
		int value2 = incompleteBlocksFA.GetValue(MonoSingleton<EndlessGrid>.Instance);
		if (value2 <= 0 && value <= 0)
		{
			if (_initialSpawn)
			{
				_initialSpawn = false;
				RaycastHit val = default(RaycastHit);
				Physics.SphereCast(HorizontalCenter + Vector3.up * 200f, 2f, Vector3.down, ref val, float.PositiveInfinity, 16777216);
				FloorCenter = (((Object)(object)((RaycastHit)(ref val)).collider != (Object)null) ? ((RaycastHit)(ref val)).point : HorizontalCenter);
				UpdateSpawnPositions();
				GenerationFinished = true;
				this.OnGenerationFinished?.Invoke(this);
			}
			if (!_enemySpawningFinished && Grid.enemyAmount != 999)
			{
				_enemySpawningFinished = true;
				this.OnEnemySpawningFinished?.Invoke(this);
			}
		}
	}

	private void UpdateSpawnPositions()
	{
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		_oneByOnes.Clear();
		_twoByTwos.Clear();
		_threeByThrees.Clear();
		for (int i = 0; i < Grid.cubes.Length; i++)
		{
			for (int j = 0; j < Grid.cubes[i].Length; j++)
			{
				if (Grid.cubes[i][j].blockedByPrefab)
				{
					continue;
				}
				_oneByOnes.Add(GetCubeTopCenter(Grid.cubes[i][j]));
				Vector3? val = TestForSpawnPosition(2, 2, i, j);
				if (val.HasValue)
				{
					_twoByTwos.Add(val.Value);
					Vector3? val2 = TestForSpawnPosition(3, 3, i, j);
					if (val2.HasValue)
					{
						_threeByThrees.Add(val2.Value);
					}
				}
			}
		}
	}

	private Vector3? TestForSpawnPosition(int sizeI, int sizeJ, int iStart, int jStart)
	{
		//IL_00eb: 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)
		//IL_00f3: 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_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: 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_016e: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: 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)
		List<Vector3> list = new List<Vector3>(sizeI * sizeJ);
		for (int i = iStart; i < iStart + sizeI; i++)
		{
			for (int j = jStart; j < jStart + sizeJ; j++)
			{
				if (Grid.cubes.Length <= i)
				{
					return null;
				}
				if (Grid.cubes[i].Length <= j)
				{
					return null;
				}
				if (Grid.cubes[i][j].blockedByPrefab)
				{
					return null;
				}
				list.Add(GetCubeTopCenter(Grid.cubes[i][j]));
			}
		}
		Vector3 val = Vector3.zero;
		float y = list[0].y;
		foreach (Vector3 item in list)
		{
			val += item;
			if (Mathf.Abs(item.y - y) > 0.5f)
			{
				return null;
			}
		}
		return val / (float)list.Count;
	}

	private Vector3 GetCubeTopCenter(EndlessCube endlessCube)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: 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_0025: 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_002b: Unknown result type (might be due to invalid IL or missing references)
		return ((Component)endlessCube).transform.position + new Vector3(0f, 25f, 0f);
	}
}
public class GrindBoss : MonoBehaviour
{
	public class AutoDeactivate : MonoBehaviour
	{
		protected void OnEnable()
		{
			((Component)this).gameObject.SetActive(false);
		}
	}

	private EnemyComponents Enemy = null;

	private FieldAccess<SisyphusPrime, float> sisyPrimeOriginalHpFA = new FieldAccess<SisyphusPrime, float>("originalHp", BindingFlags.Instance | BindingFlags.NonPublic);

	private FieldAccess<MinosPrime, bool> minosPrimeinActionFA = new FieldAccess<MinosPrime, bool>("inAction", BindingFlags.Instance | BindingFlags.NonPublic);

	private FieldAccess<MinosPrime, bool> minosPrimegravityInActionFA = new FieldAccess<MinosPrime, bool>("gravityInAction", BindingFlags.Instance | BindingFlags.NonPublic);

	private FieldAccess<V2, float> V2DistancePatienceFA = new FieldAccess<V2, float>("distancePatience", BindingFlags.Instance | BindingFlags.NonPublic);

	private FieldAccess<EnemyIdentifier, string> OverrideFullNameFA = new FieldAccess<EnemyIdentifier, string>("overrideFullName", BindingFlags.Instance | BindingFlags.NonPublic);

	private FieldAccess<GabrielBase, bool> GabrielBaseBossVersionFA = new FieldAccess<GabrielBase, bool>("bossVersion", BindingFlags.Instance | BindingFlags.NonPublic);

	private int remainingBoostHelpers = 0;

	private FixedTimeStamp lastBoostHelperTimestamp = default(FixedTimeStamp);

	private bool _levAlreadySecondPhasing = false;

	private FixedTimeStamp _levSecondPhaseRequestTimestamp = default(FixedTimeStamp);

	private float symbioteSavePhase1Speed = 0f;

	private float symbioteSavePhase2Speed = 0f;

	private bool addDeadEnemyCalled = false;

	private SwordsMachine sm;

	private LeviathanController lev;

	private V2 v2;

	private MinosPrime minosP;

	private SisyphusPrime sisyprime;

	private GabrielBase garbage;

	private FleshPrison prison;

	private Geryon gery;

	private MinosBoss minos;

	private FixedTimeStamp symbioteSaveStart;

	private FixedTimeStamp waitingToDestroyTimestamp;

	private float waitingToDestroyTime = -1f;

	private bool leviathanSecondPhaseEventCalled = false;

	private float levSpawnHookPointsTimer = -1f;

	private float levDestroyFloorTimer = -1f;

	private float levDeathLaunchPlayerTimer = -1f;

	private float _verticalShiftVelocity = 0f;

	private Vector3 _minosTargetPos;

	public bool IsTundraAgony { get; internal set; }

	public EnemyComponents Symbiote { get; private set; }

	public SwordsMachine SymbioteSm { get; private set; }

	public Rigidbody SymbioteRb { get; private set; }

	public List<GameObject> GameObjectsToDestroy { get; private set; } = new List<GameObject>();


	public int RemainingEnemies => MonoSingleton<EndlessGrid>.Instance.enemyAmount - ((Component)MonoSingleton<EndlessGrid>.Instance).GetComponent<ActivateNextWave>().deadEnemies;

	protected void Awake()
	{
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Expected O, but got Unknown
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Expected O, but got Unknown
		v2 = ((Component)this).GetComponentInChildren<V2>();
		sm = ((Component)this).GetComponent<SwordsMachine>();
		Enemy = ((Component)this).GetComponent<EnemyComponents>();
		Enemy.Eid.dontCountAsKills = true;
		Enemy.PreDeath += new PreDeathEventHandler(PreDeath);
		Enemy.PostDeath += new PostDeathEventHandler(PostDeath);
		Enemy.AvoidHealthBasedSlowDown = true;
		GameObject rootGameObject = Enemy.RootGameObject;
		Collider[] componentsInChildren = rootGameObject.GetComponentsInChildren<Collider>();
		Collider[] array = componentsInChildren;
		foreach (Collider val in array)
		{
			GameObjectExtensions.GetOrAddComponent<IgnoreDeathZones>(((Component)val).gameObject);
		}
		if ((Object)(object)v2 != (Object)null && v2.secondEncounter)
		{
			string text = "V2... 2!";
			switch (Random.Range(0, 100))
			{
			}
			OverrideFullNameFA.SetValue(((Component)v2).gameObject.GetComponent<EnemyIdentifier>(), text);
		}
	}

	protected void Start()
	{
		//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01df: Expected O, but got Unknown
		//IL_0258: Unknown result type (might be due to invalid IL or missing references)
		//IL_025d: 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_0293: Expected O, but got Unknown
		if (Cheats.Enabled)
		{
			remainingBoostHelpers = Options.MaxGenericBoostHelpersPerEnemy.Value;
			garbage = ((Component)this).GetComponentInChildren<GabrielBase>();
			prison = ((Component)this).GetComponentInChildren<FleshPrison>();
			lev = ((Component)this).GetComponent<LeviathanController>();
			sisyprime = ((Component)this).GetComponent<SisyphusPrime>();
			minosP = ((Component)this).GetComponent<MinosPrime>();
			minos = ((Component)this).GetComponent<MinosBoss>();
			gery = ((Component)this).GetComponent<Geryon>();
			if ((Object)(object)garbage != (Object)null)
			{
				GabrielBaseBossVersionFA.SetValue(garbage, false);
				((MonoBehaviour)((Component)this).GetComponent<GabrielVoice>()).Invoke("Taunt", Random.Range(0.1f, 0.5f));
			}
			if ((Object)(object)minosP != (Object)null)
			{
				MonoSingleton<SubtitleController>.Instance.DisplaySubtitle("WEAK", (AudioSource)null, false);
				((Component)minosP).GetComponent<AudioSource>().clip = minosP.phaseChangeVoice;
				AudioSourceExtensions.SetPitch(((Component)minosP).GetComponent<AudioSource>(), 1f);
				AudioSourceExtensions.Play(((Component)minosP).GetComponent<AudioSource>(), true);
			}
			if ((Object)(object)sisyprime != (Object)null)
			{
				sisyprime.Taunt();
			}
			if (IsTundraAgony)
			{
				Assert.IsNotNull((Object)(object)Enemy, "");
				Assert.IsNotNull((Object)(object)((Component)Enemy).GetComponent<Enemy>(), "");
				Assert.IsNotNull((Object)(object)((Component)Enemy).GetComponent<Enemy>().symbiote, "");
				Symbiote = ((Component)((Component)Enemy).GetComponent<Enemy>().symbiote).GetComponent<EnemyComponents>();
				SymbioteSm = ((Component)Symbiote).GetComponent<SwordsMachine>();
			}
			if ((Object)(object)minos != (Object)null)
			{
				GameObject val = new GameObject();
				val.transform.parent = ((Component)this).transform;
				val.SetActive(false);
				minos.blackHole = Object.Instantiate<GameObject>(minos.blackHole.gameObject, val.transform);
				BlackholeModifier blackholeModifier = minos.blackHole.AddComponent<BlackholeModifier>();
				blackholeModifier.RescaleOnStart = 0.4f;
				blackholeModifier.Damage = 50;
				blackholeModifier.KillThreshold = 5;
				_minosTargetPos = ((Component)this).transform.position;
			}
			if ((Object)(object)prison != (Object)null && (Object)(object)prison.blackHole != (Object)null)
			{
				GameObject val2 = new GameObject();
				val2.transform.parent = ((Component)this).transform;
				val2.SetActive(false);
				prison.blackHole = Object.Instantiate<GameObject>(prison.blackHole.gameObject, val2.transform);
				BlackholeModifier blackholeModifier2 = prison.blackHole.AddComponent<BlackholeModifier>();
				blackholeModifier2.RescaleOnStart = 1f;
				blackholeModifier2.Damage = 50;
				blackholeModifier2.KillThreshold = 5;
			}
			if ((Object)(object)gery != (Object)null)
			{
				FieldAccess<Geryon, Transform> val3 = default(FieldAccess<Geryon, Transform>);
				val3..ctor("rotateAround", BindingFlags.Instance | BindingFlags.NonPublic);
				((Component)gery).gameObject.AddComponent<GeryonTweaks>();
			}
			GroundCheckEnemy componentInChildren = ((Component)this).GetComponentInChildren<GroundCheckEnemy>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				componentInChildren.cols.Clear();
			}
		}
	}

	protected void FixedUpdate()
	{
		//IL_0085: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_05b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: Unknown result type (might be due to invalid IL or missing references)
		//IL_0185: Unknown result type (might be due to invalid IL or missing references)
		//IL_0187: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ac: 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_01ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01da: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f0: 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)
		//IL_0200: Unknown result type (might be due to invalid IL or missing references)
		//IL_020a: Unknown result type (might be due to invalid IL or missing references)
		//IL_020f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0250: Unknown result type (might be due to invalid IL or missing references)
		//IL_0261: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_0635: Unknown result type (might be due to invalid IL or missing references)
		//IL_063a: Unknown result type (might be due to invalid IL or missing references)
		//IL_040a: 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_0439: Unknown result type (might be due to invalid IL or missing references)
		//IL_043e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0448: Unknown result type (might be due to invalid IL or missing references)
		//IL_044d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0452: Unknown result type (might be due to invalid IL or missing references)
		//IL_045c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0461: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b2d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0523: Unknown result type (might be due to invalid IL or missing references)
		//IL_0528: Unknown result type (might be due to invalid IL or missing references)
		//IL_0552: Unknown result type (might be due to invalid IL or missing references)
		//IL_0557: Unknown result type (might be due to invalid IL or missing references)
		//IL_0561: Unknown result type (might be due to invalid IL or missing references)
		//IL_0566: Unknown result type (might be due to invalid IL or missing references)
		//IL_056b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0575: Unknown result type (might be due to invalid IL or missing references)
		//IL_057a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b49: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b4f: Invalid comparison between Unknown and I4
		//IL_0b5c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b62: Invalid comparison between Unknown and I4
		//IL_0b6f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b76: Invalid comparison between Unknown and I4
		//IL_0bb4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bbb: Invalid comparison between Unknown and I4
		//IL_0bfc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c01: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c0c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c11: Unknown result type (might be due to invalid IL or missing references)
		//IL_0af4: Unknown result type (might be due to invalid IL or missing references)
		//IL_097c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0981: Unknown result type (might be due to invalid IL or missing references)
		//IL_098b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0995: Unknown result type (might be due to invalid IL or missing references)
		//IL_099a: Unknown result type (might be due to invalid IL or missing references)
		//IL_07d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_07de: Unknown result type (might be due to invalid IL or missing references)
		//IL_07e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_07f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_07f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_080f: Unknown result type (might be due to invalid IL or missing references)
		//IL_081a: Unknown result type (might be due to invalid IL or missing references)
		//IL_085b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0866: Unknown result type (might be due to invalid IL or missing references)
		//IL_0876: Unknown result type (might be due to invalid IL or missing references)
		//IL_087b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0880: Unknown result type (might be due to invalid IL or missing references)
		//IL_088b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0895: Unknown result type (might be due to invalid IL or missing references)
		//IL_089a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c9a: Unknown result type (might be due to invalid IL or missing references)
		if (!Cheats.Enabled)
		{
			return;
		}
		if ((Object)(object)v2 != (Object)null)
		{
			float value = V2DistancePatienceFA.GetValue(v2);
			value = Mathf.Min(value, 4.5f);
			V2DistancePatienceFA.SetValue(v2, value);
		}
		Enemy.Eid.dontCountAsKills = true;
		float num = 5f;
		if ((Object)(object)sisyprime != (Object)null)
		{
			num = Mathf.Clamp(MonoSingleton<NewMovement>.Instance.Position.y - 5f, -110f, num);
		}
		if ((Object)(object)minosP != (Object)null)
		{
			num = Mathf.Clamp(MonoSingleton<NewMovement>.Instance.Position.y - 5f, -110f, num);
		}
		Vector3 val2;
		if (!Enemy.Eid.Dead && ((Component)Enemy).transform.position.y < num && remainingBoostHelpers > 0 && ((FixedTimeStamp)(ref lastBoostHelperTimestamp)).TimeSince > 0.75 && (Object)(object)garbage == (Object)null)
		{
			Rigidbody component = ((Component)Enemy).GetComponent<Rigidbody>();
			if ((Object)(object)component != (Object)null && (Object)(object)minosP == (Object)null && (Object)(object)sisyprime == (Object)null)
			{
				Vector3 position = ((Component)component).transform.position;
				Vector3 val = position;
				((Vector3)(ref val)).Scale(new Vector3(1f, 0f, 1f));
				val2 = component.velocity;
				((Vector3)(ref val2)).Scale(new Vector3(1f, 0f, 1f));
				float num2 = Vector3.Distance(CyberArena.HorizontalCenter, val);
				Vector3 val3 = Vector3.up * 80f;
				val2 = CyberArena.HorizontalCenter - val;
				component.velocity = val3 + ((Vector3)(ref val2)).normalized * num2 * 0.25f;
				((FixedTimeStamp)(ref lastBoostHelperTimestamp)).UpdateToNow();
				if ((Object)(object)v2 != (Object)null)
				{
					EnemyComponents component2 = ((Component)v2).GetComponent<EnemyComponents>();
					EnemyUtils.ApplyDamage(component2.Eid, Vector3.zero, ((Component)component2.Eid).transform.position, (float)Options.V2FallOffArenaDamage.Value, 1f, (GameObject)null, true);
					GameObject val4 = Object.Instantiate<GameObject>(Assets.ExplosionPrefab, ((Component)this).transform.parent);
					val4.transform.position = ((Component)this).transform.position + Vector3.down;
					Explosion componentInChildren = val4.GetComponentInChildren<Explosion>();
					componentInChildren.ignite = false;
					componentInChildren.harmless = true;
					componentInChildren.damage = 0;
					componentInChildren.pushForceMultiplier = 0f;
					componentInChildren.friendlyFire = true;
					val4.SetActive(true);
				}
				else if (IsTundraAgony && (Object)(object)Symbiote != (Object)null && !Symbiote.Eid.Dead)
				{
					((Component)Symbiote).GetComponent<GrindBoss>().RequestSymbioteSave();
				}
				else
				{
					remainingBoostHelpers--;
				}
			}
			GameObject prefab = EnemyPrefabDatabase.GetPrefab((EnemyType)21);
			Idol component3 = prefab.GetComponent<Idol>();
			FieldAccess<Idol, GameObject> val5 = default(FieldAccess<Idol, GameObject>);
			val5..ctor("deathParticle", BindingFlags.Instance | BindingFlags.NonPublic);
			GameObject value2 = val5.GetValue(component3);
			if ((Object)(object)sisyprime != (Object)null && ((FixedTimeStamp)(ref lastBoostHelperTimestamp)).TimeSince > 0.45 && !Enemy.Eid.dead)
			{
				if (Enemy.Eid.health > (float)Options.SisyphusPrimeFallOffArenaDamage.Value)
				{
					Enemy.Eid.SimpleDamage((float)Options.SisyphusPrimeFallOffArenaDamage.Value);
					GameObject val6 = Object.Instantiate<GameObject>(value2, ((Component)this).transform.position, Quaternion.identity, ((Component)MonoSingleton<EndlessGrid>.Instance).transform);
					val6.SetActive(true);
					((Component)sisyprime).transform.position = CyberArena.HorizontalCenter + Vector3.up * 100f + Vector3.forward * 20f;
					((FixedTimeStamp)(ref lastBoostHelperTimestamp)).UpdateToNow();
				}
				else
				{
					Enemy.Eid.InstaKill();
				}
			}
			else if ((Object)(object)minosP != (Object)null && ((FixedTimeStamp)(ref lastBoostHelperTimestamp)).TimeSince > 0.45 && !Enemy.Eid.dead)
			{
				if (Enemy.Eid.health > (float)Options.MinosPrimeFallOffArenaDamage.Value)
				{
					Enemy.Eid.SimpleDamage((float)Options.MinosPrimeFallOffArenaDamage.Value);
					GameObject val7 = Object.Instantiate<GameObject>(value2, ((Component)this).transform.position, Quaternion.identity, ((Component)MonoSingleton<EndlessGrid>.Instance).transform);
					val7.SetActive(true);
					((Component)minosP).transform.position = CyberArena.HorizontalCenter + Vector3.up * 100f + Vector3.forward * 20f;
					((FixedTimeStamp)(ref lastBoostHelperTimestamp)).UpdateToNow();
				}
				else
				{
					Enemy.Eid.InstaKill();
				}
			}
		}
		if (((Component)Enemy).transform.position.y < -5f && IsTundraAgony)
		{
			Enemy.Eid.InstaKill();
		}
		if ((Object)(object)v2 != (Object)null && v2.isEnraged)
		{
			v2.UnEnrage();
		}
		if ((Object)(object)v2 != (Object)null)
		{
			val2 = ((Component)v2).transform.position;
			if (((Vector3)(ref val2)).magnitude > 350f && !Enemy.Eid.Dead)
			{
				((Component)v2).GetComponent<EnemyIdentifier>().InstaKill();
				MonoSingleton<StyleHUD>.Instance.AddPoints(10, "STRANDED", (GameObject)null, (EnemyIdentifier)null, -1, "", "");
			}
		}
		if (((FixedTimeStamp)(ref symbioteSaveStart)).TimeSince < 4.0)
		{
			if (Enemy.Eid.Dead || (Object)(object)Symbiote == (Object)null || Symbiote.Eid.Dead)
			{
				return;
			}
			if (!(sm?.downed).GetValueOrDefault(true))
			{
				sm.Knockdown(false, false, false, true);
			}
			if (!(SymbioteSm?.downed).GetValueOrDefault(true))
			{
				SymbioteSm.Knockdown(false, false, false, true);
			}
			if (Enemy.Health <= 0.5f)
			{
				Enemy.Eid.InstaKill();
			}
			if (((FixedTimeStamp)(ref symbioteSaveStart)).TimeSince < 2.0)
			{
				Transform transform = ((Component)SymbioteRb).transform;
				transform.position += Vector3.up * symbioteSavePhase1Speed * Time.fixedDeltaTime;
				symbioteSavePhase2Speed = Vector3.Distance(((Component)SymbioteRb).transform.position, ((Component)this).transform.position) * 2.75f;
			}
			else if (((FixedTimeStamp)(ref symbioteSaveStart)).TimeSince > 3.0)
			{
				Transform transform2 = ((Component)SymbioteRb).transform;
				transform2.position += Vector3.Normalize(((Component)this).transform.position - ((Component)SymbioteRb).transform.position) * symbioteSavePhase2Speed * Time.fixedDeltaTime;
			}
			Machine component4 = ((Component)this).GetComponent<Machine>();
			FieldAccess<Machine, bool> val8 = default(FieldAccess<Machine, bool>);
			val8..ctor("healing", BindingFlags.Instance | BindingFlags.NonPublic);
			if (val8.GetValue(component4))
			{
				val8.SetValue(component4, false);
			}
		}
		if ((Object)(object)lev != (Object)null)
		{
			if (RemainingEnemies <= 1)
			{
				if (!lev.secondPhase && lev.readyForSecondPhase && ((FixedTimeStamp)(ref _levSecondPhaseRequestTimestamp)).TimeSince > 1.0)
				{
					lev.SubAttackOver();
				}
				else if (!lev.secondPhase && lev.readyForSecondPhase)
				{
					Transform transform3 = ((Component)lev).transform;
					transform3.position += Vector3.down * 35f * Time.fixedDeltaTime;
				}
				LeviathanSecondPhase();
			}
			if (levSpawnHookPointsTimer > 0f)
			{
				levSpawnHookPointsTimer -= Time.fixedDeltaTime;
				if (levSpawnHookPointsTimer <= 0f)
				{
					levSpawnHookPointsTimer = -1f;
					LeviathanSpawnHookPoints();
					LevSecondPhaseLaunchPlayerUp();
				}
			}
			if (levDestroyFloorTimer > 0f)
			{
				levDestroyFloorTimer -= Time.fixedDeltaTime;
				if (levDestroyFloorTimer <= 0f)
				{
					levDestroyFloorTimer = -1f;
					DestroyFloor();
				}
			}
			if (levDeathLaunchPlayerTimer > 0f)
			{
				levDeathLaunchPlayerTimer -= Time.fixedDeltaTime;
				if (levDeathLaunchPlayerTimer <= 0f)
				{
					levDeathLaunchPlayerTimer = -1f;
					Collider[] componentsInChildren = ((Component)lev).gameObject.GetComponentsInChildren<Collider>();
					Collider[] array = componentsInChildren;
					foreach (Collider val9 in array)
					{
						val9.enabled = false;
					}
					LevDeathLaunchPlayer();
					BigHarmlessExplosionAt(((Component)lev.head).transform.position);
				}
			}
		}
		if ((Object)(object)v2 != (Object)null)
		{
			v2.dontEnrage = true;
		}
		if (((Component)Enemy).transform.position.y < -15f && ((int)Enemy.Eid.enemyType == 7 || (int)Enemy.Eid.enemyType == 8 || (int)Enemy.Eid.enemyType == 22))
		{
			Enemy.Eid.InstaKill();
		}
		if (Enemy.Eid.Dead && (int)Enemy.Eid.enemyType == 11 && ((FixedTimeStamp)(ref waitingToDestroyTimestamp)).TimeSince > 0.2)
		{
			_verticalShiftVelocity -= Time.fixedDeltaTime * 60f;
			Transform transform4 = ((Component)this).transform;
			transform4.position += Vector3.up * _verticalShiftVelocity;
		}
		if ((Object)(object)sisyprime != (Object)null)
		{
			sisyPrimeOriginalHpFA.SetValue(sisyprime, 0f);
		}
		if (waitingToDestroyTime > 0f && ((FixedTimeStamp)(ref waitingToDestroyTimestamp)).TimeSince > (double)waitingToDestroyTime)
		{
			if ((Object)(object)lev != (Object)null)
			{
				BigHarmlessExplosionAt(((Component)lev.head).transform.position);
			}
			if ((Object)(object)gery != (Object)null)
			{
				BloodBomb(24, 34f);
			}
			if ((Object)(object)sisyprime != (Object)null)
			{
				BloodBomb(6, 4f);
			}
			if ((Object)(object)minosP != (Object)null)
			{
				BloodBomb(6, 4f);
			}
			Enemy.InstaDestroy();
		}
	}

	private void BloodBomb(int iterations, float range)
	{
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: 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_0066: Unknown result type (might be due to invalid IL or missing references)
		GoreZone val = GoreZone.ResolveGoreZone(((Component)this).transform);
		Bloodsplatter val2 = default(Bloodsplatter);
		for (int i = 0; i < iterations; i++)
		{
			GameObject gore = MonoSingleton<BloodsplatterManager>.Instance.GetGore((GoreType)0, false, false, false, ((Component)this).GetComponent<EnemyIdentifier>(), false);
			if (!Object.op_Implicit((Object)(object)gore))
			{
				break;
			}
			gore.transform.position = ((Component)this).transform.position + Random.insideUnitSphere * Random.Range(0f, range);
			if ((Object)(object)val.goreZone != (Object)null)
			{
				gore.transform.SetParent(val.goreZone, true);
			}
			gore.SetActive(true);
			if (gore.TryGetComponent<Bloodsplatter>(ref val2))
			{
				val2.GetReady();
			}
		}
	}

	private void BigHarmlessExplosionAt(Vector3 position)
	{
		//IL_0006: 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)
		GameObject val = Object.Instantiate<GameObject>(Assets.ExplosionPrefab, position, Quaternion.identity);
		ExplosionAdditions component = val.GetComponent<ExplosionAdditions>();
		component.Harmless = true;
		component.ExplosionScale = 20f;
		component.ExplosionSpeedScale = 10f;
		component.ExplosionPushScale = 0f;
		val.SetActive(true);
		foreach (AudioSource audio in component.Audios)
		{
			audio.maxDistance *= 100f;
			audio.volume *= 1.2f;
		}
	}

	private void LeviathanSecondPhase()
	{
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Expected O, but got Unknown
		if (_levAlreadySecondPhasing)
		{
			return;
		}
		((FixedTimeStamp)(ref _levSecondPhaseRequestTimestamp)).UpdateToNow();
		_levAlreadySecondPhasing = true;
		lev.phaseChangeHealth = 10000f;
		lev.onEnterSecondPhase.onActivate.AddListener((UnityAction)delegate
		{
			//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)
			if (!leviathanSecondPhaseEventCalled)
			{
				leviathanSecondPhaseEventCalled = true;
				Enemy stat = lev.stat;
				stat.health *= 0.5f;
				GameObject val = Object.Instantiate<GameObject>(Assets.ExplosionPrefab, CyberArena.HorizontalCenter, Quaternion.identity);
				ExplosionAdditions component = val.GetComponent<ExplosionAdditions>();
				component.Harmless = true;
				component.ExplosionScale = 20f;
				component.ExplosionSpeedScale = 10f;
				component.ExplosionPushScale = 0f;
				val.SetActive(true);
				foreach (AudioSource audio in component.Audios)
				{
					audio.maxDistance *= 100f;
					audio.volume *= 1.2f;
				}
				levDestroyFloorTimer = 0.2f;
				levSpawnHookPointsTimer = 0.35f;
			}
		});
	}

	private static void DestroyFloor()
	{
		MonoSingleton<CyberArena>.Instance.DisableGeometry();
	}

	private static void LevSecondPhaseLaunchPlayerUp()
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		if (((Component)MonoSingleton<NewMovement>.Instance).transform.position.y < 50f)
		{
			MonoSingleton<NewMovement>.Instance.gc.heavyFall = false;
		}
		MonoSingleton<NewMovement>.Instance.LaunchUp(75f);
	}

	private void LeviathanSpawnHookPoints()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: 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_0050: 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_0056: 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_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: 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)
		Vector3 val = Vector3.forward * 65f;
		int num = 4;
		for (int i = 0; i < num; i++)
		{
			val.y = 60f;
			Vector3 val2 = Quaternion.Euler(new Vector3(0f, Mathf.Lerp(0f, 360f, ((float)i + -0.5f) / (float)num), 0f)) * val;
			GameObject val3 = Object.Instantiate<GameObject>(HookPoints.SlingshotHookPoint, ((Component)lev.head).transform.position + val2, Quaternion.identity, ((Component)MonoSingleton<EndlessGrid>.Instance).transform);
			val3.SetActive(true);
			GameObjectsToDestroy.Add(val3);
		}
	}

	protected void OnEnable()
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		Cybergrind.PreCybergrindNextWave += new CybergrindPreNextWaveEventHandler(OnNextWave);
	}

	protected void OnDisable()
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		Cybergrind.PreCybergrindNextWave -= new CybergrindPreNextWaveEventHandler(OnNextWave);
	}

	protected void OnNextWave(EventMethodCanceler canceler, EndlessGrid endlessGrid)
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Invalid comparison between Unknown and I4
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Invalid comparison between Unknown and I4
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Invalid comparison between Unknown and I4
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Invalid comparison between Unknown and I4
		if (((int)Enemy.Eid.enemyType != 27 && (int)Enemy.Eid.enemyType != 11 && (int)Enemy.Eid.enemyType != 27 && (int)Enemy.Eid.enemyType != 27) || !Enemy.Eid.Dead)
		{
			Enemy.InstaDestroy();
		}
	}

	private void RequestSymbioteSave()
	{
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		if (!Enemy.Eid.Dead && !(((FixedTimeStamp)(ref symbioteSaveStart)).TimeSince < 3.0))
		{
			SymbioteRb = ((Component)SymbioteSm).GetComponent<Rigidbody>();
			symbioteSavePhase1Speed = Mathf.Abs(((Component)SymbioteRb).transform.position.y - (((Component)this).transform.position.y + 20f)) * 0.8f;
			SymbioteRb.isKinematic = true;
			SwordsMachine obj = sm;
			if (obj != null)
			{
				obj.Knockdown(false, false, true, false);
			}
			((FixedTimeStamp)(ref symbioteSaveStart)).UpdateToNow();
		}
	}

	protected void OnDestroy()
	{
		foreach (GameObject item in GameObjectsToDestroy)
		{
			Object.Destroy((Object)(object)item);
		}
	}

	private void PreDeath(EventMethodCanceler canceler, bool instakill)
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Invalid comparison between Unknown and I4
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Invalid comparison between Unknown and I4
		if ((int)Enemy.Eid.enemyType == 27)
		{
			waitingToDestroyTime = 3.5f;
			((FixedTimeStamp)(ref waitingToDestroyTimestamp)).UpdateToNow();
			levDeathLaunchPlayerTimer = 0.4f;
		}
		if ((int)Enemy.Eid.enemyType == 11)
		{
			waitingToDestroyTime = 1.75f;
			((FixedTimeStamp)(ref waitingToDestroyTimestamp)).UpdateToNow();
		}
		if ((Object)(object)sisyprime != (Object)null)
		{
			waitingToDestroyTime = 0.5f;
			((FixedTimeStamp)(ref waitingToDestroyTimestamp)).UpdateToNow();
		}
		if ((Object)(object)minosP != (Object)null)
		{
			waitingToDestroyTime = 0.8f;
			((FixedTimeStamp)(ref waitingToDestroyTimestamp)).UpdateToNow();
		}
		if ((Object)(object)gery != (Object)null)
		{
			waitingToDestroyTime = 0.6f;
			((FixedTimeStamp)(ref waitingToDestroyTimestamp)).UpdateToNow();
		}
	}

	private void LevDeathLaunchPlayer()
	{
		//IL_000b: 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_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_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: 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_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		if (((Component)MonoSingleton<NewMovement>.Instance).transform.position.y < 75f && lev.secondPhase)
		{
			MonoSingleton<NewMovement>.Instance.gc.heavyFall = false;
		}
		if (((Component)MonoSingleton<NewMovement>.Instance).transform.position.y < 120f && lev.secondPhase)
		{
			Vector3 position = ((Component)MonoSingleton<NewMovement>.Instance).transform.position;
			((Vector3)(ref position)).Scale(new Vector3(1f, 0f, 1f));
			NewMovement instance = MonoSingleton<NewMovement>.Instance;
			Vector3 val = Vector3.up * 100f;
			Vector3 val2 = CyberArena.HorizontalCenter - position;
			val2 = val + ((Vector3)(ref val2)).normalized * (Vector3.Distance(CyberArena.HorizontalCenter, position) * 0.4f);
			instance.Launch(((Vector3)(ref val2)).normalized, Vector3.Distance(CyberArena.HorizontalCenter, position) * 0.65f, true);
		}
	}

	private void PostDeath(EventMethodCancelInfo cancelInfo, bool instakill)
	{
		if (!addDeadEnemyCalled)
		{
			addDeadEnemyCalled = true;
			((Component)MonoSingleton<EndlessGrid>.Instance).GetComponent<ActivateNextWave>().AddDeadEnemy();
		}
	}
}
[BepInPlugin("nyxpiri.ultrakill.cybergrind-bosses", "Cybergrind Bosses", "0.0.0")]
[BepInProcess("ULTRAKILL.exe")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class CybergrindBosses : BaseUnityPlugin
{
	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static OnSceneWasLoadedEventHandler <>9__0_0;

		public static Action<ToggleCheat> <>9__2_0;

		public static Action<ToggleCheat, CheatsManager> <>9__2_1;

		internal void <Awake>b__0_0(Scene scene, string levelName, string unitySceneName)
		{
			if ((Object)(object)MonoSingleton<EndlessGrid>.Instance != (Object)null)
			{
				GameObjectExtensions.GetOrAddComponent<CyberArena>(((Component)MonoSingleton<EndlessGrid>.Instance).gameObject);
				GameObjectExtensions.GetOrAddComponent<BossSpawner>(((Component)MonoSingleton<EndlessGrid>.Instance).gameObject);
			}
		}

		internal void <RegisterCheats>b__2_0(ToggleCheat cheat)
		{
		}

		internal void <RegisterCheats>b__2_1(ToggleCheat cheat, CheatsManager cheatsManager)
		{
		}
	}

	public const string CheatID = "nyxpiri.cybergrind-bosses";

	protected void Awake()
	{
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Expected O, but got Unknown
		//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_0051: Expected O, but got Unknown
		Log.Initialize(((BaseUnityPlugin)this).Logger);
		Options.Initialize((BaseUnityPlugin)(object)this);
		Assets.Initialize();
		EnemyVariants.Initialize();
		Cheats.ReadyForCheatRegistration += new ReadyForCheatRegistrationEventHandler(RegisterCheats);
		object obj = <>c.<>9__0_0;
		if (obj == null)
		{
			OnSceneWasLoadedEventHandler val = delegate
			{
				if ((Object)(object)MonoSingleton<EndlessGrid>.Instance != (Object)null)
				{
					GameObjectExtensions.GetOrAddComponent<CyberArena>(((Component)MonoSingleton<EndlessGrid>.Instance).gameObject);
					GameObjectExtensions.GetOrAddComponent<BossSpawner>(((Component)MonoSingleton<EndlessGrid>.Instance).gameObject);
				}
			};
			<>c.<>9__0_0 = val;
			obj = (object)val;
		}
		ScenesEvents.OnSceneWasLoaded += (OnSceneWasLoadedEventHandler)obj;
		Harmony.CreateAndPatchAll(((object)this).GetType().Assembly, (string)null);
	}

	private void RegisterCheats(CheatsManager cheatsManager)
	{
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Expected O, but got Unknown
		cheatsManager.RegisterCheat((ICheat)new ToggleCheat("Cybergrind Bosses", "nyxpiri.cybergrind-bosses", (Action<ToggleCheat>)delegate
		{
		}, (Action<ToggleCheat, CheatsManager>)delegate
		{
		}), "CYBERGRIND");
	}

	protected void Start()
	{
	}

	protected void FixedUpdate()
	{
	}

	protected void Update()
	{
	}

	protected void LateUpdate()
	{
	}
}
[HarmonyPatch(typeof(EndlessGrid), "GetEnemies")]
public static class EndlessGridGetEnemiesPatch
{
	public static bool Prefix(EndlessGrid __instance)
	{
		return true;
	}

	public static void Postfix(EndlessGrid __instance)
	{
		__instance.tempEnemyAmount += BossPicker.EnemyAmountToAdd;
		BossPicker.EnemyAmountToAdd = 0;
	}
}
internal static class Log
{
	private static ManualLogSource _logger;

	internal static void Initialize(ManualLogSource logger)
	{
		Assert.IsNull((object)_logger, "Log.Initialize called when _logger wasn't null?");
		_logger = logger;
	}

	public static void Fatal(object data)
	{
		_logger.LogFatal(data);
	}

	public static void Error(object data)
	{
		_logger.LogError(data);
	}

	public static void Warning(object data)
	{
		_logger.LogWarning(data);
	}

	public static void Message(object data)
	{
		_logger.LogMessage(data);
	}

	public static void Info(object data)
	{
		_logger.LogInfo(data);
	}

	public static void Debug(object data)
	{
		if (Options.LogDebugInfo.Value)
		{
			_logger.LogDebug(data);
		}
	}
}
public class BossPicker
{
	public static FieldAccess<EndlessGrid, int> pointsFi = new FieldAccess<EndlessGrid, int>("points", BindingFlags.Instance | BindingFlags.NonPublic);

	public bool ShouldFakeFall = false;

	private int _wavesSinceFakeFall = 0;

	private int _currentFakeFallDelay = -10;

	private Dictionary<AEnemyType, int> SpawnCooldowns = new Dictionary<AEnemyType, int>();

	private Dictionary<AEnemyType, int> SpawnCostBoosts = new Dictionary<AEnemyType, int>();

	public Queue<AEnemyType> TypesToSpawn { get; private set; } = new Queue<AEnemyType>();


	public HashSet<AEnemyType> SpawnedLastWave { get; private set; } = new HashSet<AEnemyType>();


	internal static int EnemyAmountToAdd { get; set; } = 0;


	private void Reset()
	{
		SpawnCooldowns.Clear();
		TypesToSpawn.Clear();
		EnemyAmountToAdd = 0;
	}

	public void SolveBossesToSpawn(EndlessGrid endlessGrid)
	{
		//IL_053d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0544: Invalid comparison between Unknown and I4
		//IL_0556: Unknown result type (might be due to invalid IL or missing references)
		//IL_055d: Invalid comparison between Unknown and I4
		Assert.IsTrue(Cheats.Enabled, "");
		if (_currentFakeFallDelay < 0)
		{
			_currentFakeFallDelay = Random.Range(Options.ForcedFakeFallDelayMinWaves.Value, Options.ForcedFakeFallDelayMaxWaves.Value);
		}
		EnemyAmountToAdd = 0;
		TypesToSpawn.Clear();
		int currentWave = endlessGrid.currentWave;
		int value = pointsFi.GetValue(endlessGrid);
		int num = Mathf.FloorToInt((float)value * Options.PointsRatioAllocatedToBosses.Value);
		int num2 = num;
		int num3 = 0;
		int num4 = 0;
		Dictionary<AEnemyType, int> dictionary = new Dictionary<AEnemyType, int>();
		Log.Debug($"---------- deciding bosses to spawn with {num2} points (allPoints = {value}) -------------");
		bool flag = false;
		bool flag2 = true;
		SpawnedLastWave.Clear();
		if (Options.UseForcedFakeFall.Value && currentWave >= Options.ForcedFakeFallMinWave.Value && _wavesSinceFakeFall >= _currentFakeFallDelay)
		{
			flag = true;
			Log.Debug("Forcing fake fall!");
		}
		List<KeyValuePair<AEnemyType, Options.EnemyEntry>> list = Options.EnemyEntries.ToList();
		HashSet<AEnemyType> hashSet = new HashSet<AEnemyType>();
		for (int i = 0; i < Options.BossPickerIterations.Value; i++)
		{
			bool flag3 = (float)i >= (float)Options.BossPickerIterations.Value / 2f;
			CollectionSorting.Shuffle<KeyValuePair<AEnemyType, Options.EnemyEntry>>((IList<KeyValuePair<AEnemyType, Options.EnemyEntry>>)list);
			foreach (KeyValuePair<AEnemyType, Options.EnemyEntry> item in list)
			{
				Options.EnemyEntry value2 = item.Value;
				Log.Debug($"{item.Key} being TESTED to spawn");
				SpawnCostBoosts.TryAdd(item.Key, 0);
				SpawnCooldowns.TryAdd(item.Key, 0);
				if (!value2.Enabled.Value)
				{
					Log.Debug($"{item.Key} DENIED on the basis of being not enabled");
					continue;
				}
				if (SpawnCooldowns[item.Key] > 0)
				{
					Log.Debug($"{item.Key} DENIED on the basis of wave cooldown {SpawnCooldowns[item.Key]}");
					continue;
				}
				if (currentWave < value2.SpawnWave.Value)
				{
					Log.Debug($"{item.Key} DENIED on the basis of wave {currentWave} being less than {value2.SpawnWave.Value}");
					continue;
				}
				if (!flag3)
				{
					float num5 = Mathf.Clamp(NyxMath.InverseNormalizeToRange((float)SpawnCooldowns[item.Key], -10f, 0f), 0.2f, 1f);
					if (Random.Range(0f, 1f) > num5)
					{
						Log.Debug($"{item.Key} DENIED on the basis of choose odds {num5}, 'cooldown' {SpawnCooldowns[item.Key]}");
						continue;
					}
				}
				dictionary.TryAdd(item.Key, 0);
				int value3 = value2.SpawnCost.Value;
				int num6 = value3 + num3 + dictionary[item.Key] + SpawnCostBoosts[item.Key];
				float num7 = NyxMath.NormalizeToRange((float)SpawnCostBoosts[item.Key], 0f, (float)item.Value.IndividualPersistentSpawnCostBoostMax.Value);
				int num8 = (int)((float)value3 * value2.SpawnCostSpentScalar.Value) + num4;
				if (item.Value.IndividualPersistentSpawnCostBoostMax.Value == 0)
				{
					num7 = 0f;
				}
				if (Random.Range(0f, 1f) < num7 || hashSet.Contains(item.Key))
				{
					Log.Debug($"{item.Key} DENIED on the basis of {num7} rng roll not working out for it");
					continue;
				}
				float num9 = (int)((float)value3 * value2.SpawnCostBonusScalar.Value);
				float num10 = num6;
				num10 *= value2.SpawnCostRequirementScalar.Value;
				foreach (AEnemyType item2 in TypesToSpawn)
				{
					Options.EnemyEntry enemyEntry = Options.EnemyEntries[item2];
					int value4 = enemyEntry.SpawnCost.Value;
					float num11 = (float)value4 + ((float)num3 + num9) + (float)dictionary[item2] + (float)SpawnCostBoosts[item2];
					float num12 = (float)num6 * enemyEntry.SpawnCostRequirementScalar.Value;
					if (num10 < num12)
					{
						Log.Debug($"{item.Key} opting to use {num12} as the spawn cost requirement due to previously queued to be spawned type ({item2})");
					}
					num10 = Math.Max(num10, num12);
				}
				if ((float)num2 < num10)
				{
					Log.Debug($"{item.Key} DENIED on the basis of {num2} being less than {num10}");
					continue;
				}
				if (((int)item.Key.VanillaEnumValue.GetValueOrDefault() == 30 || (int)item.Key.VanillaEnumValue.GetValueOrDefault() == 17) && (TypesToSpawn.Contains(MonoSingleton<EnemyTypeDB>.Instance.GetVanillaType((EnemyType)30)) || TypesToSpawn.Contains(MonoSingleton<EnemyTypeDB>.Instance.GetVanillaType((EnemyType)17))))
				{
					Log.Debug($"{item.Key} DENIED on the basis of conflicting type being intended to spawn");
					continue;
				}
				Options.EnemyAttributes enemyAttributes = Options.EnemiesAttributes.GetValueOrDefault(item.Key, null);
				if (enemyAttributes == null)
				{
					enemyAttributes = Options.EnemiesAttributes[MonoSingleton<EnemyTypeDB>.Instance.GetVanillaType((EnemyType)3)];
					Log.Warning($"{item.Key} doesn't have an attributes entry, falling back to Filth attributes entry");
				}
				if (!enemyAttributes.CanSpawnInFakeFall.Value)
				{
					if (!flag && flag2)
					{
						Log.Debug($"{item.Key} selected and canBeFakeFall is true yet isFakeFall is false, can no longer be fake fall.");
						flag2 = false;
					}
					else if (flag)
					{
						continue;
					}
				}
				if (item.Key == MonoSingleton<EnemyTypeDB>.Instance.GetVanillaType((EnemyType)42) && flag2)
				{
					Log.Debug("Geryon selected, we shall fake fall.");
					flag = true;
				}
				else if (item.Key == MonoSingleton<EnemyTypeDB>.Instance.GetVanillaType((EnemyType)42) && !flag2)
				{
					Log.Debug("Geryon tried but we can't be fake fall, no fake fall");
					continue;
				}
				SpawnedLastWave.Add(item.Key);
				num2 -= num8;
				num3 += (int)num9;
				num4 += (int)((float)(int)((float)value3 * value2.SpawnCostBonusScalar.Value) * value2.SpawnCostBonusSpentScalar.Value);
				dictionary[item.Key] += value2.IndividualCostIncreasePerSpawn.Value;
				TypesToSpawn.Enqueue(item.Key);
				EnemyAmountToAdd++;
				if (item.Key == EnemyVariants.TundraAgonyType)
				{
					EnemyAmountToAdd++;
				}
				ShouldFakeFall = flag;
				Log.Debug($"adding type {item.Key} to types to spawn for a cost of {num8} leaving {num2} points left (spawnCostBonus: {num3}, spawnCostBonusSpent: {num4})");
			}
		}
		if (ShouldFakeFall)
		{
			Log.Debug($"ShouldFakeFall will == true, _wavesSinceFakeFall: {_wavesSinceFakeFall}, _currentFakeFallDelay: {_currentFakeFallDelay}");
			_currentFakeFallDelay = Random.Range(Options.ForcedFakeFallDelayMinWaves.Value, Options.ForcedFakeFallDelayMaxWaves.Value);
			_wavesSinceFakeFall = 0;
			Log.Debug($"ShouldFakeFall == true, _wavesSinceFakeFall: {_wavesSinceFakeFall}, _currentFakeFallDelay: {_currentFakeFallDelay}");
		}
		foreach (AEnemyType item3 in TypesToSpawn)
		{
			SpawnCostBoosts[item3] += Options.EnemyEntries[item3].IndividualPersistentSpawnCostBoost.Value;
			SpawnCostBoosts[item3] = Math.Clamp(SpawnCostBoosts[item3], 0, Options.EnemyEntries[item3].IndividualPersistentSpawnCostBoostMax.Value);
			SpawnCooldowns[item3] = Options.EnemyEntries[item3].SpawnCooldown.Value;
		}
		pointsFi.SetValue(endlessGrid, value - (num - num2));
		Log.Debug($"--------- should spawn {TypesToSpawn.Count} bosses -------------");
	}

	internal void UpdateForceFakeFallCooldown()
	{
		_wavesSinceFakeFall++;
	}

	internal void UpdateBossCooldowns()
	{
		Dictionary<AEnemyType, int> dictionary = new Dictionary<AEnemyType, int>(SpawnCooldowns);
		foreach (AEnemyType key in SpawnCooldowns.Keys)
		{
			if (!SpawnedLastWave.Contains(key))
			{
				dictionary[key]--;
			}
		}
		Dictionary<AEnemyType, int> dictionary2 = new Dictionary<AEnemyType, int>(SpawnCostBoosts);
		foreach (AEnemyType key2 in SpawnCostBoosts.Keys)
		{
			if (!SpawnedLastWave.Contains(key2) && SpawnCooldowns.GetValueOrDefault(key2, 0) <= 0)
			{
				dictionary2[key2] -= Options.EnemyEntries[key2].IndividualPersistentSpawnCostBoostDecay.Value;
				dictionary2[key2] = Math.Max(dictionary2[key2], 0);
			}
		}
		SpawnCooldowns = dictionary;
		SpawnCostBoosts = dictionary2;
	}
}
public static class EnemyVariants
{
	public static AEnemyType TundraAgonyType = (AEnemyType)new VanillaEnemyType("SWORDSMACHINE \"AGONY\" AND \"TUNDRA\"", "TundraAndAgony", (EnemyType)7);

	public static AEnemyType BloodTree = (AEnemyType)new VanillaEnemyType("Blood Tree", "BloodTree");

	public static LeviathanController LeviathanPrefab = null;

	public static GameObject CorpseOfKingMinosPrefab = null;

	public static GameObject CentaurSecurityPrefab = null;

	public static BloodFiller BloodTreePrefab = null;

	private static GameObject prefabHolder = null;

	public static Geryon GeryonPrefab = null;

	public static FakeFallZone FakeFallZone = null;

	public static GameObject FakeFallZoneHud = null;

	public static GameObject SpawnAgonyAndTundra(Vector3 position, Quaternion rotation, Transform parent)
	{
		//IL_0006: 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)
		return EnemyPrefabDatabase.TrySpawnAt(TundraAgonyType, position, rotation, parent, true);
	}

	internal static void Initialize()
	{
		LevelQuickLoader.AddQuickLoadLevel("Level 2-4");
		LevelQuickLoader.AddQuickLoadLevel("Level 1-3");
		LevelQuickLoader.AddQuickLoadLevel("Level 5-4");
		LevelQuickLoader.AddQuickLoadLevel("Level 7-3");
		LevelQuickLoader.AddQuickLoadLevel("Level 7-4");
		LevelQuickLoader.AddQuickLoadLevel("Level 8-4");
		Assets.AddAssetPicker<MinosBoss>((Func<MinosBoss, bool>)delegate(MinosBoss minos)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			if (prefabHolder == null)
			{
				prefabHolder = new GameObject();
			}
			Object.DontDestroyOnLoad((Object)(object)prefabHolder);
			prefabHolder.SetActive(false);
			CorpseOfKingMinosPrefab = Object.Instantiate<GameObject>(((Component)minos).gameObject, prefabHolder.transform);
			MinosBoss component3 = CorpseOfKingMinosPrefab.GetComponent<MinosBoss>();
			component3.parryChallenge = false;
			return true;
		});
		Assets.AddAssetPicker<CombinedBossBar>((Func<CombinedBossBar, bool>)delegate(CombinedBossBar bb)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			if (prefabHolder == null)
			{
				prefabHolder = new GameObject();
			}
			Object.DontDestroyOnLoad((Object)(object)prefabHolder);
			prefabHolder.SetActive(false);
			if (((Object)((Component)bb).gameObject).name != "SecuritySystem")
			{
				return false;
			}
			if (SceneHelper.CurrentScene != "Level 7-4")
			{
				return false;
			}
			CentaurSecurityPrefab = Object.Instantiate<GameObject>(((Component)bb).gameObject, prefabHolder.transform);
			return true;
		});
		Assets.AddAssetPicker<Geryon>((Func<Geryon, bool>)delegate(Geryon geryon)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			if (prefabHolder == null)
			{
				prefabHolder = new GameObject();
			}
			Object.DontDestroyOnLoad((Object)(object)prefabHolder);
			prefabHolder.SetActive(false);
			GeryonPrefab = Object.Instantiate<Geryon>(geryon, prefabHolder.transform);
			return true;
		});
		Assets.AddAssetPicker<FakeFallZone>((Func<FakeFallZone, bool>)delegate(FakeFallZone ffz)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			if (prefabHolder == null)
			{
				prefabHolder = new GameObject();
			}
			Object.DontDestroyOnLoad((Object)(object)prefabHolder);
			prefabHolder.SetActive(false);
			FakeFallZone = Object.Instantiate<FakeFallZone>(ffz, prefabHolder.transform);
			return true;
		});
		Assets.AddAssetPicker<BloodFiller>((Func<BloodFiller, bool>)delegate(BloodFiller bf)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			if (prefabHolder == null)
			{
				prefabHolder = new GameObject();
			}
			Object.DontDestroyOnLoad((Object)(object)prefabHolder);
			prefabHolder.SetActive(false);
			if (!((Object)((Component)bf).gameObject).name.Contains("ideTree"))
			{
				return false;
			}
			BloodTreePrefab = Object.Instantiate<BloodFiller>(bf, prefabHolder.transform);
			bf.onFullyFilled = new UltrakillEvent();
			((Component)BloodTreePrefab).gameObject.SetActive(false);
			return true;
		});
		Assets.AddAssetPicker<LeviathanController>((Func<LeviathanController, bool>)delegate(LeviathanController leviathan)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			if (prefabHolder == null)
			{
				prefabHolder = new GameObject();
			}
			Object.DontDestroyOnLoad((Object)(object)prefabHolder);
			prefabHolder.SetActive(false);
			LeviathanPrefab = Object.Instantiate<LeviathanController>(leviathan, prefabHolder.transform);
			LeviathanPrefab.phaseChangeHealth = -10f;
			LeviathanPrefab.tailAddHealth = ((Component)LeviathanPrefab).GetComponent<Enemy>().health * 0.5f;
			return true;
		});
		Assets.AddAssetPicker<SwordsMachine>((Func<SwordsMachine, bool>)delegate(SwordsMachine sm)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			Enemy component = ((Component)sm).GetComponent<Enemy>();
			if ((Object)(object)component.symbiote == (Object)null)
			{
				return false;
			}
			string text = "SwordsMachine Tundra";
			string text2 = "SwordsMachine Agony";
			EnemyIdentifier component2 = ((Component)component).GetComponent<EnemyIdentifier>();
			if (((Object)component2).name == text || ((Object)component2).name == text2)
			{
				GameObject val = new GameObject();
				val.SetActive(false);
				GameObject val2 = null;
				GameObject val3 = null;
				if (((Object)component2).name == text)
				{
					val2 = Object.Instantiate<GameObject>(((Component)component).gameObject, val.transform);
					val3 = Object.Instantiate<GameObject>(((Component)component.symbiote).gameObject, val.transform);
				}
				else if (((Object)component2).name == text2)
				{
					val3 = Object.Instantiate<GameObject>(((Component)component).gameObject, val.transform);
					val2 = Object.Instantiate<GameObject>(((Component)component.symbiote).gameObject, val.transform);
				}
				val2.transform.localPosition = Vector3.zero;
				val3.transform.localPosition = Vector3.zero;
				val2.GetComponent<Enemy>().symbiote = val3.GetComponent<Enemy>();
				val3.GetComponent<Enemy>().symbiote = val2.GetComponent<Enemy>();
				val2.SetActive(true);
				val3.SetActive(true);
				Object.DontDestroyOnLoad((Object)(object)val);
				EnemyPrefabDatabase.Instance.RegisterPrefab(TundraAgonyType, val);
				return true;
			}
			return false;
		});
	}
}
public class GeryonTweaks : MonoBehaviour
{
	[HarmonyPatch(typeof(Geryon), "PickAttack")]
	public static class GeryonPickAttackPatch
	{
		public static bool Prefix(Geryon __instance)
		{
			if (!Cheats.Enabled)
			{
				return true;
			}
			GeryonTweaks component = ((Component)__instance).GetComponent<GeryonTweaks>();
			if ((Object)(object)component != (Object)null)
			{
				return component.PrePickAttack();
			}
			return true;
		}

		public static void Postfix(Geryon __instance)
		{
		}
	}

	private Geryon _gery = null;

	private GameObject rotateAroundGo = null;

	private EnemyIdentifier eid = null;

	private FieldAccess<Geryon, bool> inActionFA = new FieldAccess<Geryon, bool>("inAction", BindingFlags.Instance | BindingFlags.NonPublic);

	private FieldAccess<Geryon, float> originalHealthFA = new FieldAccess<Geryon, float>("originalHealth", BindingFlags.Instance | BindingFlags.NonPublic);

	private FieldAccess<Geryon, float> playerPushBackerCooldownFA = new FieldAccess<Geryon, float>("playerPushBackerCooldown", BindingFlags.Instance | BindingFlags.NonPublic);

	private FieldAccess<Geryon, float> cooldownFA = new FieldAccess<Geryon, float>("cooldown", BindingFlags.Instance | BindingFlags.NonPublic);

	private FieldAccess<Geryon, float> minimumAroundDistanceFA = new FieldAccess<Geryon, float>("minimumAroundDistance", BindingFlags.Instance | BindingFlags.NonPublic);

	private FieldAccess<Geryon, float> maximumAroundDistanceFA = new FieldAccess<Geryon, float>("maximumAroundDistance", BindingFlags.Instance | BindingFlags.NonPublic);

	private FieldAccess<Geryon, GameObject> playerBlockerShieldFA = new FieldAccess<Geryon, GameObject>("playerBlockerShield", BindingFlags.Instance | BindingFlags.NonPublic);

	private FieldAccess<Geryon, Transform> rotateAroundFA = new FieldAccess<Geryon, Transform>("rotateAround", BindingFlags.Instance | BindingFlags.NonPublic);

	private MethodInfo WaveClap = typeof(Geryon).GetMethod("WaveClap", BindingFlags.Instance | BindingFlags.NonPublic);

	private MethodInfo BowForward = typeof(Geryon).GetMethod("BowForward", BindingFlags.Instance | BindingFlags.NonPublic);

	private FixedTimeStamp _distancePreventionWaveClapTimestamp = default(FixedTimeStamp);

	protected void Awake()
	{
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Expected O, but got Unknown
		_gery = ((Component)this).GetComponent<Geryon>();
		eid = ((Component)this).GetComponent<EnemyIdentifier>();
		Collider[] componentsInChildren = playerBlockerShieldFA.GetValue(_gery).GetComponentsInChildren<Collider>();
		Collider[] array = componentsInChildren;
		foreach (Collider val in array)
		{
			val.enabled = false;
		}
		minimumAroundDistanceFA.SetValue(_gery, 82f);
		maximumAroundDistanceFA.SetValue(_gery, 92f);
		originalHealthFA.SetValue(_gery, eid.health);
		rotateAroundGo = new GameObject();
		rotateAroundGo.transform.parent = ((Component)this).transform;
		rotateAroundFA.SetValue(_gery, rotateAroundGo.transform);
	}

	protected void Start()
	{
		originalHealthFA.SetValue(_gery, eid.health);
	}

	protected void FixedUpdate()
	{
		//IL_0022: 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_0039: 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_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)
		playerPushBackerCooldownFA.SetValue(_gery, 99f);
		Vector3 position = ((Component)MonoSingleton<NewMovement>.Instance).transform.position;
		((Vector3)(ref position)).Scale(new Vector3(1f, 0f, 1f));
		rotateAroundGo.transform.position = NyxMa