Decompiled source of Cyber Grind Roulette v1.0.0

randomgrind.dll

Decompiled an hour ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("randomgrind")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("randomgrind")]
[assembly: AssemblyTitle("randomgrind")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace CyberGrindRoulette
{
	[BepInPlugin("com.custom.cybergrindroulette", "Cyber Grind Roulette", "1.7.1")]
	public class Plugin : BaseUnityPlugin
	{
		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			Harmony val = new Harmony("com.custom.cybergrindroulette");
			val.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Cyber Grind Roulette 1.7.1 loaded!");
		}
	}
	public enum WaveModifier
	{
		None,
		ZeroGravity,
		FloorIsLava,
		PriorityTarget,
		AirSuperiority,
		Bloodlust,
		SniperDuel,
		RicochetArena,
		ParryHunt,
		BlackHole,
		GlassCannon,
		ArenaDecay,
		WeaponEmbargo
	}
	public static class RouletteManager
	{
		public const int TotalModifiersCount = 12;

		public static int WavesPlayedInRun = 0;

		public static bool HardModeActive = false;

		public static readonly HashSet<WaveModifier> PlayedModifiersInRun = new HashSet<WaveModifier>();

		public static readonly List<WaveModifier> ActiveModifiers = new List<WaveModifier>();

		private static readonly List<WaveModifier> ModifierDeck = new List<WaveModifier>();

		public static Vector3 DefaultGravity = new Vector3(0f, -40f, 0f);

		public static bool GravitySaved = false;

		public static bool PlayerInZeroG = false;

		public static readonly HashSet<int> FloatingEnemyIds = new HashSet<int>();

		public static float LavaHitCooldown = 0f;

		public static bool WaitingForPriorityTarget = false;

		public static EnemyIdentifier PriorityEnemy = null;

		public static GameObject PriorityBeacon = null;

		public static float PriorityTimer = 0f;

		public static float HardDamageTickTimer = 0f;

		public static float BloodDrainTimer = 0f;

		public static readonly Dictionary<int, int> RocketBounces = new Dictionary<int, int>();

		public static GameObject ActiveBlackHole = null;

		public static GameObject CachedBlackHolePrefab = null;

		public static float ShockwaveCooldown = 0f;

		public static bool IsShockwaveActive = false;

		public static bool DecayInitialized = false;

		public static float TotalWavePower = 0f;

		public static readonly List<Vector2Int> DecayOrder = new List<Vector2Int>();

		public static int CollapsedBlocksCount = 0;

		public static readonly HashSet<int> CollapsedCubeIds = new HashSet<int>();

		public static int BlockedWeaponSlot = 0;

		public static string BlockedWeaponName = "";

		public static GameObject CornerHudCanvasObj = null;

		public static Text CornerHudText = null;

		public static string CurrentHudHeader = "";

		public static string CurrentHudDescription = "";

		public static float HudRefreshTimer = 0f;

		private static readonly HashSet<EnemyType> HeavyEnemies = new HashSet<EnemyType>
		{
			(EnemyType)0,
			(EnemyType)4,
			(EnemyType)5,
			(EnemyType)2,
			(EnemyType)7,
			(EnemyType)33,
			(EnemyType)34,
			(EnemyType)26,
			(EnemyType)19,
			(EnemyType)18,
			(EnemyType)29,
			(EnemyType)38,
			(EnemyType)40
		};

		public static bool HasModifier(WaveModifier mod)
		{
			return ActiveModifiers.Contains(mod);
		}

		public static bool IsHeavyEnemy(EnemyType type)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return HeavyEnemies.Contains(type);
		}

		public static float GetEnemyPowerWeight(EnemyIdentifier eid)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Expected I4, but got Unknown
			if ((Object)(object)eid == (Object)null)
			{
				return 1f;
			}
			EnemyType enemyType = eid.enemyType;
			EnemyType val = enemyType;
			switch ((int)val)
			{
			case 1:
			case 3:
			case 13:
				return 1.5f;
			case 6:
			case 12:
			case 14:
			case 15:
			case 21:
			case 31:
				return 3f;
			case 4:
			case 9:
			case 20:
			case 39:
				return 5f;
			case 0:
			case 5:
			case 7:
			case 26:
			case 33:
			case 34:
			case 38:
			case 41:
				return 8f;
			case 2:
			case 18:
			case 19:
			case 29:
				return 15f;
			default:
				return 4f;
			}
		}

		private static void RefillDeck()
		{
			ModifierDeck.Clear();
			for (int i = 1; i <= 12; i++)
			{
				ModifierDeck.Add((WaveModifier)i);
			}
			for (int j = 0; j < ModifierDeck.Count; j++)
			{
				WaveModifier value = ModifierDeck[j];
				int index = Random.Range(j, ModifierDeck.Count);
				ModifierDeck[j] = ModifierDeck[index];
				ModifierDeck[index] = value;
			}
		}

		private static WaveModifier DrawNextFromDeck(HashSet<WaveModifier> exclude)
		{
			if (ModifierDeck.Count == 0)
			{
				RefillDeck();
			}
			for (int i = 0; i < ModifierDeck.Count; i++)
			{
				if (!exclude.Contains(ModifierDeck[i]))
				{
					WaveModifier result = ModifierDeck[i];
					ModifierDeck.RemoveAt(i);
					return result;
				}
			}
			WaveModifier result2 = ModifierDeck[0];
			ModifierDeck.RemoveAt(0);
			return result2;
		}

		public static void EnsureCornerHud()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_007c: 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_0092: Expected O, but got Unknown
			//IL_00c5: 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_00fb: 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)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Expected O, but got Unknown
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)CornerHudCanvasObj != (Object)null) || !((Object)(object)CornerHudText != (Object)null))
			{
				CornerHudCanvasObj = new GameObject("CyberGrindRouletteCornerHUD");
				Object.DontDestroyOnLoad((Object)(object)CornerHudCanvasObj);
				Canvas val = CornerHudCanvasObj.AddComponent<Canvas>();
				val.renderMode = (RenderMode)0;
				val.sortingOrder = 100;
				CanvasScaler val2 = CornerHudCanvasObj.AddComponent<CanvasScaler>();
				val2.uiScaleMode = (ScaleMode)1;
				val2.referenceResolution = new Vector2(1920f, 1080f);
				GameObject val3 = new GameObject("RoulettePanel");
				val3.transform.SetParent(CornerHudCanvasObj.transform, false);
				Image val4 = val3.AddComponent<Image>();
				((Graphic)val4).color = new Color(0.05f, 0.05f, 0.08f, 0.68f);
				RectTransform component = val3.GetComponent<RectTransform>();
				component.anchorMin = new Vector2(1f, 1f);
				component.anchorMax = new Vector2(1f, 1f);
				component.pivot = new Vector2(1f, 1f);
				component.anchoredPosition = new Vector2(-24f, -24f);
				component.sizeDelta = new Vector2(560f, 130f);
				GameObject val5 = new GameObject("RouletteText");
				val5.transform.SetParent(val3.transform, false);
				CornerHudText = val5.AddComponent<Text>();
				Font builtinResource = Resources.GetBuiltinResource<Font>("Arial.ttf");
				if ((Object)(object)builtinResource != (Object)null)
				{
					CornerHudText.font = builtinResource;
				}
				CornerHudText.fontSize = 19;
				CornerHudText.fontStyle = (FontStyle)1;
				CornerHudText.alignment = (TextAnchor)5;
				((Graphic)CornerHudText).color = new Color(1f, 0.88f, 0.25f, 1f);
				CornerHudText.supportRichText = true;
				Shadow val6 = val5.AddComponent<Shadow>();
				val6.effectColor = new Color(0f, 0f, 0f, 0.95f);
				val6.effectDistance = new Vector2(2f, -2f);
				RectTransform component2 = val5.GetComponent<RectTransform>();
				component2.anchorMin = Vector2.zero;
				component2.anchorMax = Vector2.one;
				component2.offsetMin = new Vector2(14f, 8f);
				component2.offsetMax = new Vector2(-14f, -8f);
			}
		}

		public static void SetCornerHud(string header, string desc, bool visible)
		{
			EnsureCornerHud();
			CurrentHudHeader = header;
			CurrentHudDescription = desc;
			if ((Object)(object)CornerHudCanvasObj != (Object)null)
			{
				CornerHudCanvasObj.SetActive(visible);
			}
			UpdateCornerHudText();
		}

		public static void UpdateCornerHudText()
		{
			if ((Object)(object)CornerHudText == (Object)null || (Object)(object)CornerHudCanvasObj == (Object)null || !CornerHudCanvasObj.activeSelf)
			{
				return;
			}
			string text = "";
			if (HasModifier(WaveModifier.PriorityTarget))
			{
				if (WaitingForPriorityTarget)
				{
					text = "\n<color=#FF4444>ПОИСК ЦЕЛИ...</color>";
				}
				else if ((Object)(object)PriorityEnemy != (Object)null && !PriorityEnemy.dead)
				{
					int num = Mathf.CeilToInt(Mathf.Max(0f, PriorityTimer));
					string text2 = ((object)Unsafe.As<EnemyType, EnemyType>(ref PriorityEnemy.enemyType)/*cast due to .constrained prefix*/).ToString().ToUpper();
					text = ((num <= 0) ? "\n<color=#FF2222>ВРЕМЯ ВЫШЛО! ИДЁТ ЖЁСТКИЙ УРОН</color>" : ("\n<color=#FF4444>ЦЕЛЬ [" + text2 + "]: " + num + " СЕК</color>"));
				}
				else
				{
					text = "\n<color=#55FF55>ЦЕЛЬ УНИЧТОЖЕНА</color>";
				}
			}
			CornerHudText.text = CurrentHudHeader + "\n<size=15><color=#E0E0E0>" + CurrentHudDescription + "</color></size>" + text;
		}

		public static void ResetAll(bool resetRunProgress = false)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			if (GravitySaved)
			{
				Physics.gravity = DefaultGravity;
			}
			PlayerInZeroG = false;
			FloatingEnemyIds.Clear();
			LavaHitCooldown = 0f;
			if ((Object)(object)PriorityBeacon != (Object)null)
			{
				Object.Destroy((Object)(object)PriorityBeacon);
				PriorityBeacon = null;
			}
			WaitingForPriorityTarget = false;
			PriorityEnemy = null;
			PriorityTimer = 0f;
			HardDamageTickTimer = 0f;
			BloodDrainTimer = 0f;
			RocketBounces.Clear();
			if ((Object)(object)ActiveBlackHole != (Object)null)
			{
				Object.Destroy((Object)(object)ActiveBlackHole);
				ActiveBlackHole = null;
			}
			ShockwaveCooldown = 0f;
			IsShockwaveActive = false;
			DecayInitialized = false;
			TotalWavePower = 0f;
			DecayOrder.Clear();
			CollapsedBlocksCount = 0;
			CollapsedCubeIds.Clear();
			BlockedWeaponSlot = 0;
			BlockedWeaponName = "";
			ActiveModifiers.Clear();
			if (resetRunProgress)
			{
				WavesPlayedInRun = 0;
				HardModeActive = false;
				PlayedModifiersInRun.Clear();
				ModifierDeck.Clear();
			}
			SetCornerHud("", "", visible: false);
		}

		private static void SetupWeaponEmbargo()
		{
			GunControl instance = MonoSingleton<GunControl>.Instance;
			List<int> list = new List<int>();
			if ((Object)(object)instance != (Object)null && instance.slots != null)
			{
				for (int i = 1; i <= 5; i++)
				{
					if (instance.slots.Count >= i && instance.slots[i - 1] != null && instance.slots[i - 1].Count > 0)
					{
						list.Add(i);
					}
				}
			}
			if (list.Count == 0)
			{
				list.Add(Random.Range(1, 6));
			}
			BlockedWeaponSlot = list[Random.Range(0, list.Count)];
			switch (BlockedWeaponSlot)
			{
			case 1:
				BlockedWeaponName = "РЕВОЛЬВЕР";
				break;
			case 2:
				BlockedWeaponName = "ДРОБОВИК";
				break;
			case 3:
				BlockedWeaponName = "ГВОЗДЕМЁТ";
				break;
			case 4:
				BlockedWeaponName = "РЕЛЬСОТРОН";
				break;
			case 5:
				BlockedWeaponName = "РАКЕТНИЦА";
				break;
			default:
				BlockedWeaponName = "СЛОТ " + BlockedWeaponSlot;
				break;
			}
			if (!((Object)(object)instance != (Object)null) || instance.currentSlotIndex != BlockedWeaponSlot)
			{
				return;
			}
			for (int j = 1; j <= 5; j++)
			{
				if (j != BlockedWeaponSlot && instance.slots.Count >= j && instance.slots[j - 1].Count > 0)
				{
					instance.SwitchWeapon(j, (int?)null, false, false, false);
					break;
				}
			}
		}

		private static void GetModifierInfo(WaveModifier mod, EndlessGrid grid, out string title, out string desc)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			title = "";
			desc = "";
			switch (mod)
			{
			case WaveModifier.ZeroGravity:
				Physics.gravity = Vector3.zero;
				PlayerInZeroG = true;
				if ((Object)(object)MonoSingleton<NewMovement>.Instance != (Object)null && (Object)(object)MonoSingleton<NewMovement>.Instance.rb != (Object)null)
				{
					Vector3 velocity = MonoSingleton<NewMovement>.Instance.rb.velocity;
					MonoSingleton<NewMovement>.Instance.rb.velocity = new Vector3(velocity.x, Mathf.Max(velocity.y, 14f), velocity.z);
				}
				title = "АБСОЛЮТНАЯ НЕВЕСОМОСТЬ";
				desc = "3D-ПОЛЁТ • CTRL ОТКЛЮЧЁН • МЕЛКИЕ ВРАГИ ЛЕТАЮТ • КРЮК В ЦЕНТР";
				break;
			case WaveModifier.FloorIsLava:
				title = "ПОЛ — ЭТО ЛАВА";
				desc = "ЛЮБОЕ КАСАНИЕ ПОЛА = 10 HP УРОНА И ПОДБРОС";
				break;
			case WaveModifier.PriorityTarget:
				WaitingForPriorityTarget = true;
				title = "ПРИОРИТЕТНАЯ ЦЕЛЬ";
				desc = "УБЕЙ ПОМЕЧЕННОГО ВРАГА ДО КОНЦА ТАЙМЕРА";
				break;
			case WaveModifier.AirSuperiority:
				title = "ВОЗДУШНОЕ ПРЕВОСХОДСТВО";
				desc = "+35% УРОНА В ВОЗДУХЕ • -20% УРОНА НА ЗЕМЛЕ";
				break;
			case WaveModifier.Bloodlust:
				title = "ЖАЖДА КРОВИ";
				desc = "НЕТ СЕРОГО УРОНА И x1.5 ЛЕЧЕНИЕ • -6 HP В СЕКУНДУ";
				break;
			case WaveModifier.SniperDuel:
				title = "СНАЙПЕРСКАЯ ДУЭЛЬ";
				desc = "ДАЛЬНИЙ БОЙ (>20м): УРОН x2 • БЛИЖНИЙ (<12м): УРОН x0.5";
				break;
			case WaveModifier.RicochetArena:
				title = "РИКОШЕТНАЯ АРЕНА";
				desc = "РАКЕТЫ И СНАРЯДЫ ОТСКАКИВАЮТ ОТ СТЕН И ПОЛА";
				break;
			case WaveModifier.ParryHunt:
				title = "ОХОТА ЗА ПАРИРОВАНИЕМ";
				desc = "-40% УРОН ПУШЕК • ПАРИРОВАНИЕ СОЗДАЁТ УДАРНУЮ ВОЛНУ";
				break;
			case WaveModifier.BlackHole:
				SpawnArenaBlackHole(grid);
				title = "СИНГУЛЯРНОСТЬ";
				desc = "УСКОРЕННАЯ В 2 РАЗА ЧЁРНАЯ ДЫРА ПРЕСЛЕДУЕТ V1";
				break;
			case WaveModifier.GlassCannon:
				title = "ХРУСТАЛЬНАЯ ПУШКА";
				desc = "УРОН x2 ДЛЯ ВСЕХ • ЖЁСТКИЙ УРОН ОТКЛЮЧЁН";
				break;
			case WaveModifier.ArenaDecay:
				InitArenaDecay();
				title = "РАСПАД АРЕНЫ";
				desc = "АРЕНА ОБРУШАЕТСЯ ОТ ЦЕНТРА ПО МЕРЕ УНИЧТОЖЕНИЯ СИЛ ВРАГОВ";
				break;
			case WaveModifier.WeaponEmbargo:
				SetupWeaponEmbargo();
				title = "ОРУЖЕЙНОЕ ЭМБАРГО";
				desc = "ОТКЛЮЧЕНО: " + BlockedWeaponName + " • УРОН ОСТАЛЬНЫХ ПУШЕК +25%";
				break;
			}
		}

		public static void OnWaveStarted(EndlessGrid grid)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if (!GravitySaved)
			{
				DefaultGravity = Physics.gravity;
				GravitySaved = true;
			}
			ResetAll();
			WavesPlayedInRun++;
			if (WavesPlayedInRun == 1)
			{
				string text = "ВОЛНА 1: ОБЫЧНАЯ";
				string text2 = "РУЛЕТКА УСЛОЖНЕНИЙ СТАРТУЕТ СО 2-Й ВОЛНЫ";
				SetCornerHud(text, text2, visible: true);
				if ((Object)(object)MonoSingleton<HudMessageReceiver>.Instance != (Object)null)
				{
					MonoSingleton<HudMessageReceiver>.Instance.SendHudMessage(text + " (" + text2 + ")", "", "", 0, true, false, true);
				}
				return;
			}
			if (!HardModeActive && PlayedModifiersInRun.Count >= 12)
			{
				HardModeActive = true;
			}
			int num = ((!HardModeActive) ? 1 : 2);
			HashSet<WaveModifier> hashSet = new HashSet<WaveModifier>();
			List<string> list = new List<string>();
			List<string> list2 = new List<string>();
			for (int i = 0; i < num; i++)
			{
				WaveModifier waveModifier = DrawNextFromDeck(hashSet);
				hashSet.Add(waveModifier);
				ActiveModifiers.Add(waveModifier);
				PlayedModifiersInRun.Add(waveModifier);
				GetModifierInfo(waveModifier, grid, out var title, out var desc);
				list.Add(title);
				list2.Add(desc);
			}
			string text3 = (HardModeActive ? "<color=#FF5555>[УСЛОЖНЁННЫЙ РЕЖИМ]</color> " : "");
			string text4 = string.Join(" + ", list);
			string desc2 = string.Join("\n", list2);
			string header = text3 + "ВОЛНА " + grid.currentWave + ": " + text4;
			SetCornerHud(header, desc2, visible: true);
			if ((Object)(object)MonoSingleton<HudMessageReceiver>.Instance != (Object)null)
			{
				string text5 = (HardModeActive ? "[УСЛОЖНЁННЫЙ РЕЖИМ] " : "");
				MonoSingleton<HudMessageReceiver>.Instance.SendHudMessage(text5 + "ВОЛНА " + grid.currentWave + ": " + text4 + "\n" + string.Join(" | ", list2), "", "", 0, true, false, true);
			}
		}

		private static void InitArenaDecay()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			DecayInitialized = false;
			TotalWavePower = 0f;
			CollapsedBlocksCount = 0;
			CollapsedCubeIds.Clear();
			DecayOrder.Clear();
			for (int i = 0; i < 16; i++)
			{
				for (int j = 0; j < 16; j++)
				{
					DecayOrder.Add(new Vector2Int(i, j));
				}
			}
			DecayOrder.Sort(delegate(Vector2Int a, Vector2Int b)
			{
				//IL_0011: 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_004b: 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)
				float num = Vector2.Distance(new Vector2((float)((Vector2Int)(ref a)).x, (float)((Vector2Int)(ref a)).y), new Vector2(7.5f, 7.5f)) + Random.Range(-0.45f, 0.45f);
				float value = Vector2.Distance(new Vector2((float)((Vector2Int)(ref b)).x, (float)((Vector2Int)(ref b)).y), new Vector2(7.5f, 7.5f)) + Random.Range(-0.45f, 0.45f);
				return num.CompareTo(value);
			});
		}

		public static void UpdateArenaDecay(EndlessGrid grid)
		{
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Invalid comparison between Unknown and I4
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Invalid comparison between Unknown and I4
			if ((Object)(object)grid == (Object)null || grid.cubes == null)
			{
				return;
			}
			EnemyIdentifier[] array = Object.FindObjectsOfType<EnemyIdentifier>();
			if (array == null)
			{
				return;
			}
			if (!DecayInitialized)
			{
				if (grid.enemyAmount <= 0 || grid.enemyAmount >= 900)
				{
					return;
				}
				float num = 0f;
				int num2 = 0;
				EnemyIdentifier[] array2 = array;
				foreach (EnemyIdentifier val in array2)
				{
					if ((Object)(object)val != (Object)null && !val.dead && (int)val.enemyType != 21)
					{
						num += GetEnemyPowerWeight(val);
						num2++;
					}
				}
				if (num2 > 0)
				{
					TotalWavePower = Mathf.Max(num, 1f);
					DecayInitialized = true;
				}
				return;
			}
			float num3 = 0f;
			EnemyIdentifier[] array3 = array;
			foreach (EnemyIdentifier val2 in array3)
			{
				if ((Object)(object)val2 != (Object)null && !val2.dead && (int)val2.enemyType != 21)
				{
					num3 += GetEnemyPowerWeight(val2);
				}
			}
			float num4 = Mathf.Clamp01(1f - num3 / TotalWavePower);
			int num5 = Mathf.FloorToInt(230.4f);
			int num6 = Mathf.FloorToInt((float)num5 * num4);
			if (num6 <= CollapsedBlocksCount)
			{
				return;
			}
			grid.MakeGridDynamic();
			while (CollapsedBlocksCount < num6 && CollapsedBlocksCount < DecayOrder.Count)
			{
				Vector2Int val3 = DecayOrder[CollapsedBlocksCount];
				CollapsedBlocksCount++;
				if (grid.cubes[((Vector2Int)(ref val3)).x] != null && (Object)(object)grid.cubes[((Vector2Int)(ref val3)).x][((Vector2Int)(ref val3)).y] != (Object)null)
				{
					EndlessCube val4 = grid.cubes[((Vector2Int)(ref val3)).x][((Vector2Int)(ref val3)).y];
					CollapsedCubeIds.Add(((Object)val4).GetInstanceID());
				}
			}
		}

		private static void SpawnArenaBlackHole(EndlessGrid grid)
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)CachedBlackHolePrefab == (Object)null)
			{
				BlackHoleProjectile[] array = Resources.FindObjectsOfTypeAll<BlackHoleProjectile>();
				BlackHoleProjectile[] array2 = array;
				foreach (BlackHoleProjectile val in array2)
				{
					if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).gameObject != (Object)null)
					{
						CachedBlackHolePrefab = ((Component)val).gameObject;
						break;
					}
				}
			}
			if ((Object)(object)CachedBlackHolePrefab != (Object)null && (Object)(object)grid != (Object)null)
			{
				Vector3 val2 = ((Component)grid).transform.position + new Vector3(37.5f, 22f, 37.5f);
				ActiveBlackHole = Object.Instantiate<GameObject>(CachedBlackHolePrefab, val2, Quaternion.identity);
				BlackHoleProjectile component = ActiveBlackHole.GetComponent<BlackHoleProjectile>();
				if ((Object)(object)component != (Object)null)
				{
					component.speed *= 2f;
					component.Activate();
				}
			}
		}

		public static void TryPickPriorityTarget(EndlessGrid grid)
		{
			//IL_00d0: 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_0070: Invalid comparison between Unknown and I4
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Expected O, but got Unknown
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			if (!WaitingForPriorityTarget || (Object)(object)grid == (Object)null)
			{
				return;
			}
			EnemyIdentifier[] array = Object.FindObjectsOfType<EnemyIdentifier>();
			List<EnemyIdentifier> list = new List<EnemyIdentifier>();
			if (array != null)
			{
				EnemyIdentifier[] array2 = array;
				foreach (EnemyIdentifier val in array2)
				{
					if ((Object)(object)val != (Object)null && !val.dead && ((Component)val).gameObject.activeInHierarchy && (int)val.enemyType != 21)
					{
						list.Add(val);
					}
				}
			}
			if (list.Count == 0)
			{
				return;
			}
			WaitingForPriorityTarget = false;
			PriorityEnemy = list[Random.Range(0, list.Count)];
			PriorityTimer = (IsHeavyEnemy(PriorityEnemy.enemyType) ? 30f : 15f);
			Shader val2 = Shader.Find("Unlit/Color");
			Renderer[] componentsInChildren = ((Component)PriorityEnemy).GetComponentsInChildren<Renderer>();
			if (componentsInChildren != null && (Object)(object)val2 != (Object)null)
			{
				Renderer[] array3 = componentsInChildren;
				foreach (Renderer val3 in array3)
				{
					if ((Object)(object)val3 != (Object)null && (Object)(object)val3.material != (Object)null)
					{
						val3.material.color = new Color(1f, 0.2f, 0.2f, 1f);
						if (val3.material.HasProperty("_EmissiveColor"))
						{
							val3.material.SetColor("_EmissiveColor", Color.red);
						}
					}
				}
			}
			PriorityBeacon = new GameObject("PriorityTargetHoloMarker");
			PriorityBeacon.transform.SetParent(((Component)PriorityEnemy).transform);
			PriorityBeacon.transform.localPosition = Vector3.up * 5.5f;
			HoloMarkerAnimator holoMarkerAnimator = PriorityBeacon.AddComponent<HoloMarkerAnimator>();
			if ((Object)(object)holoMarkerAnimator != (Object)null)
			{
				holoMarkerAnimator.BuildVisuals();
			}
			UpdateCornerHudText();
		}
	}
	public class HoloMarkerAnimator : MonoBehaviour
	{
		private Transform outerDiamond;

		private Transform innerDiamond;

		private float timePassed = 0f;

		private readonly List<Material> createdMaterials = new List<Material>();

		public void BuildVisuals()
		{
			//IL_0037: 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_0077: 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_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Expected O, but got Unknown
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Expected O, but got Unknown
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			Shader val = Shader.Find("Unlit/Color");
			GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)3);
			Object.Destroy((Object)(object)val2.GetComponent<Collider>());
			val2.transform.SetParent(((Component)this).transform);
			val2.transform.localPosition = Vector3.zero;
			val2.transform.localScale = new Vector3(2.4f, 2.4f, 2.4f);
			val2.transform.localRotation = Quaternion.Euler(45f, 0f, 45f);
			Renderer component = val2.GetComponent<Renderer>();
			if ((Object)(object)component != (Object)null)
			{
				Material val3 = new Material(val);
				val3.color = new Color(1f, 0.1f, 0.1f, 1f);
				component.material = val3;
				createdMaterials.Add(val3);
			}
			outerDiamond = val2.transform;
			GameObject val4 = GameObject.CreatePrimitive((PrimitiveType)3);
			Object.Destroy((Object)(object)val4.GetComponent<Collider>());
			val4.transform.SetParent(((Component)this).transform);
			val4.transform.localPosition = Vector3.zero;
			val4.transform.localScale = new Vector3(1.4f, 1.4f, 1.4f);
			val4.transform.localRotation = Quaternion.Euler(45f, 45f, 0f);
			Renderer component2 = val4.GetComponent<Renderer>();
			if ((Object)(object)component2 != (Object)null)
			{
				Material val5 = new Material(val);
				val5.color = new Color(1f, 0.9f, 0.1f, 1f);
				component2.material = val5;
				createdMaterials.Add(val5);
			}
			innerDiamond = val4.transform;
			GameObject val6 = GameObject.CreatePrimitive((PrimitiveType)2);
			Object.Destroy((Object)(object)val6.GetComponent<Collider>());
			val6.transform.SetParent(((Component)this).transform);
			val6.transform.localPosition = new Vector3(0f, 25f, 0f);
			val6.transform.localScale = new Vector3(0.22f, 25f, 0.22f);
			Renderer component3 = val6.GetComponent<Renderer>();
			if ((Object)(object)component3 != (Object)null)
			{
				Material val7 = new Material(val);
				val7.color = new Color(1f, 0.25f, 0.1f, 1f);
				component3.material = val7;
				createdMaterials.Add(val7);
			}
			Light val8 = ((Component)this).gameObject.AddComponent<Light>();
			val8.color = new Color(1f, 0.2f, 0.05f);
			val8.range = 25f;
			val8.intensity = 5f;
		}

		private void Update()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: 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)
			timePassed += Time.deltaTime;
			((Component)this).transform.localPosition = Vector3.up * (5.5f + Mathf.Sin(timePassed * 4f) * 0.5f);
			if ((Object)(object)outerDiamond != (Object)null)
			{
				outerDiamond.Rotate(Vector3.up, 120f * Time.deltaTime, (Space)0);
			}
			if ((Object)(object)innerDiamond != (Object)null)
			{
				innerDiamond.Rotate(Vector3.up, -220f * Time.deltaTime, (Space)0);
			}
		}

		private void OnDestroy()
		{
			for (int i = 0; i < createdMaterials.Count; i++)
			{
				if ((Object)(object)createdMaterials[i] != (Object)null)
				{
					Object.Destroy((Object)(object)createdMaterials[i]);
				}
			}
			createdMaterials.Clear();
		}
	}
	[HarmonyPatch(typeof(EndlessCube))]
	public static class EndlessCubeRoulettePatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("Update")]
		public static bool UpdatePrefix(EndlessCube __instance)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)null)
			{
				return true;
			}
			if (RouletteManager.HasModifier(WaveModifier.ArenaDecay) && RouletteManager.CollapsedCubeIds.Contains(((Object)__instance).GetInstanceID()))
			{
				Vector3 val = default(Vector3);
				((Vector3)(ref val))..ctor(((Component)__instance).transform.position.x, -160f, ((Component)__instance).transform.position.z);
				((Component)__instance).transform.position = Vector3.MoveTowards(((Component)__instance).transform.position, val, 48f * Time.deltaTime);
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(EndlessGrid))]
	public static class EndlessGridRoulettePatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("OnTriggerEnter")]
		public static void OnTriggerEnterPrefix(Collider other)
		{
			if ((Object)(object)other != (Object)null && ((Component)other).CompareTag("Player"))
			{
				RouletteManager.ResetAll(resetRunProgress: true);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("NextWave")]
		public static void NextWavePostfix(EndlessGrid __instance)
		{
			RouletteManager.OnWaveStarted(__instance);
		}

		[HarmonyPostfix]
		[HarmonyPatch("Update")]
		public static void UpdatePostfix(EndlessGrid __instance)
		{
			//IL_00d7: 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_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			if (RouletteManager.ShockwaveCooldown > 0f)
			{
				RouletteManager.ShockwaveCooldown -= Time.deltaTime;
			}
			if ((Object)(object)MonoSingleton<OptionsManager>.Instance != (Object)null && MonoSingleton<OptionsManager>.Instance.paused)
			{
				return;
			}
			NewMovement instance = MonoSingleton<NewMovement>.Instance;
			if ((Object)(object)instance == (Object)null || instance.dead)
			{
				return;
			}
			RouletteManager.HudRefreshTimer -= Time.deltaTime;
			if (RouletteManager.HudRefreshTimer <= 0f)
			{
				RouletteManager.HudRefreshTimer = 0.25f;
				RouletteManager.UpdateCornerHudText();
			}
			if (RouletteManager.HasModifier(WaveModifier.ZeroGravity))
			{
				if (!RouletteManager.PlayerInZeroG)
				{
					RouletteManager.PlayerInZeroG = true;
					Physics.gravity = Vector3.zero;
				}
				float y = ((Component)__instance).transform.position.y;
				float num = y + 65f;
				GameObject[] spawnedEnemies = __instance.GetSpawnedEnemies();
				GameObject[] array = spawnedEnemies;
				foreach (GameObject val in array)
				{
					if ((Object)(object)val == (Object)null)
					{
						continue;
					}
					EnemyIdentifier componentInChildren = val.GetComponentInChildren<EnemyIdentifier>();
					if ((Object)(object)componentInChildren == (Object)null || componentInChildren.dead || RouletteManager.IsHeavyEnemy(componentInChildren.enemyType))
					{
						continue;
					}
					int instanceID = ((Object)val).GetInstanceID();
					Rigidbody componentInChildren2 = val.GetComponentInChildren<Rigidbody>();
					if (!RouletteManager.FloatingEnemyIds.Contains(instanceID))
					{
						RouletteManager.FloatingEnemyIds.Add(instanceID);
						NavMeshAgent componentInChildren3 = val.GetComponentInChildren<NavMeshAgent>();
						if ((Object)(object)componentInChildren3 != (Object)null && ((Behaviour)componentInChildren3).enabled)
						{
							((Behaviour)componentInChildren3).enabled = false;
						}
						GroundCheckEnemy componentInChildren4 = val.GetComponentInChildren<GroundCheckEnemy>();
						if ((Object)(object)componentInChildren4 != (Object)null)
						{
							componentInChildren4.ForceOff();
						}
						if ((Object)(object)componentInChildren2 != (Object)null)
						{
							componentInChildren2.useGravity = false;
							if (!componentInChildren2.isKinematic)
							{
								componentInChildren2.constraints = (RigidbodyConstraints)0;
								componentInChildren2.velocity += Vector3.up * Random.Range(9f, 15f) + Random.insideUnitSphere * 3f;
								componentInChildren2.angularVelocity = Random.insideUnitSphere * 4f;
							}
						}
					}
					if (!((Object)(object)componentInChildren2 != (Object)null) || componentInChildren2.isKinematic)
					{
						continue;
					}
					componentInChildren2.useGravity = false;
					if (val.transform.position.y > num)
					{
						Vector3 velocity = componentInChildren2.velocity;
						if (velocity.y > -12f)
						{
							componentInChildren2.velocity = new Vector3(velocity.x * 0.92f, -18f, velocity.z * 0.92f);
						}
					}
				}
			}
			if (RouletteManager.HasModifier(WaveModifier.FloorIsLava))
			{
				if (RouletteManager.LavaHitCooldown > 0f)
				{
					RouletteManager.LavaHitCooldown -= Time.deltaTime;
				}
				if ((Object)(object)instance.gc != (Object)null && instance.gc.onGround && RouletteManager.LavaHitCooldown <= 0f)
				{
					RouletteManager.LavaHitCooldown = 0.45f;
					instance.GetHurt(10, false, 1f, false, false, 0.25f, false);
					if ((Object)(object)instance.rb != (Object)null)
					{
						Vector3 velocity2 = instance.rb.velocity;
						instance.rb.velocity = new Vector3(velocity2.x, 32f, velocity2.z);
					}
				}
			}
			if (RouletteManager.HasModifier(WaveModifier.PriorityTarget))
			{
				if (RouletteManager.WaitingForPriorityTarget)
				{
					RouletteManager.TryPickPriorityTarget(__instance);
				}
				else if ((Object)(object)RouletteManager.PriorityEnemy != (Object)null)
				{
					if (RouletteManager.PriorityEnemy.dead)
					{
						if ((Object)(object)RouletteManager.PriorityBeacon != (Object)null)
						{
							Object.Destroy((Object)(object)RouletteManager.PriorityBeacon);
							RouletteManager.PriorityBeacon = null;
						}
						RouletteManager.PriorityEnemy = null;
						RouletteManager.UpdateCornerHudText();
						if ((Object)(object)MonoSingleton<HudMessageReceiver>.Instance != (Object)null)
						{
							MonoSingleton<HudMessageReceiver>.Instance.SendHudMessage("ПРИОРИТЕТНАЯ ЦЕЛЬ УНИЧТОЖЕНА!", "", "", 0, true, false, true);
						}
					}
					else
					{
						RouletteManager.PriorityTimer -= Time.deltaTime;
						if (RouletteManager.PriorityTimer <= 0f)
						{
							RouletteManager.HardDamageTickTimer -= Time.deltaTime;
							if (RouletteManager.HardDamageTickTimer <= 0f)
							{
								RouletteManager.HardDamageTickTimer = 1f;
								instance.antiHp = Mathf.Min(99f, instance.antiHp + 5f);
							}
						}
					}
				}
			}
			if (RouletteManager.HasModifier(WaveModifier.Bloodlust))
			{
				if (instance.antiHp > 0f)
				{
					instance.antiHp = 0f;
				}
				if (instance.hp > 10)
				{
					RouletteManager.BloodDrainTimer += Time.deltaTime;
					if (RouletteManager.BloodDrainTimer >= 0.5f)
					{
						RouletteManager.BloodDrainTimer = 0f;
						instance.hp = Mathf.Max(10, instance.hp - 3);
					}
				}
			}
			if (RouletteManager.HasModifier(WaveModifier.GlassCannon) && instance.antiHp > 0f)
			{
				instance.antiHp = 0f;
			}
			if (RouletteManager.HasModifier(WaveModifier.ArenaDecay))
			{
				RouletteManager.UpdateArenaDecay(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(GunControl))]
	public static class GunControlRoulettePatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("SwitchWeapon")]
		public static bool SwitchWeaponPrefix(GunControl __instance, ref int targetSlotIndex, bool cycleSlot)
		{
			if (!RouletteManager.HasModifier(WaveModifier.WeaponEmbargo) || RouletteManager.BlockedWeaponSlot <= 0)
			{
				return true;
			}
			int blockedWeaponSlot = RouletteManager.BlockedWeaponSlot;
			if (cycleSlot)
			{
				if (targetSlotIndex == blockedWeaponSlot)
				{
					targetSlotIndex++;
					if (targetSlotIndex > 5)
					{
						targetSlotIndex = 1;
					}
				}
				return true;
			}
			if (targetSlotIndex == blockedWeaponSlot)
			{
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch("ForceWeapon")]
		public static bool ForceWeaponPrefix(GunControl __instance, GameObject weapon)
		{
			if (!RouletteManager.HasModifier(WaveModifier.WeaponEmbargo) || RouletteManager.BlockedWeaponSlot <= 0 || (Object)(object)weapon == (Object)null)
			{
				return true;
			}
			if (__instance.slotDict != null && __instance.slotDict.TryGetValue(weapon, out var value) && value + 1 == RouletteManager.BlockedWeaponSlot)
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(HookArm))]
	public static class HookArmRoulettePatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("FixedUpdate")]
		public static void FixedUpdatePostfix(HookArm __instance)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Invalid comparison between Unknown and I4
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: 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_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			if (!RouletteManager.HasModifier(WaveModifier.ZeroGravity) || !RouletteManager.PlayerInZeroG || (int)__instance.state != 3)
			{
				return;
			}
			EnemyIdentifier value = Traverse.Create((object)__instance).Field("caughtEid").GetValue<EnemyIdentifier>();
			if ((Object)(object)value == (Object)null || value.dead || RouletteManager.IsHeavyEnemy(value.enemyType))
			{
				return;
			}
			NewMovement instance = MonoSingleton<NewMovement>.Instance;
			if ((Object)(object)instance == (Object)null || (Object)(object)instance.rb == (Object)null)
			{
				return;
			}
			Rigidbody val = ((Component)value).GetComponent<Rigidbody>();
			if ((Object)(object)val == (Object)null)
			{
				val = ((Component)value).GetComponentInChildren<Rigidbody>();
			}
			if ((Object)(object)val != (Object)null && !val.isKinematic)
			{
				NavMeshAgent componentInChildren = ((Component)value).GetComponentInChildren<NavMeshAgent>();
				if ((Object)(object)componentInChildren != (Object)null && ((Behaviour)componentInChildren).enabled)
				{
					((Behaviour)componentInChildren).enabled = false;
				}
				GroundCheckEnemy componentInChildren2 = ((Component)value).GetComponentInChildren<GroundCheckEnemy>();
				if ((Object)(object)componentInChildren2 != (Object)null)
				{
					componentInChildren2.ForceOff();
				}
				val.useGravity = false;
				Vector3 position = ((Component)instance).transform.position;
				Vector3 position2 = ((Component)val).transform.position;
				Vector3 val2 = position2 - position;
				Vector3 normalized = ((Vector3)(ref val2)).normalized;
				float num = 35f;
				instance.rb.velocity = normalized * num;
				val.velocity = -normalized * num;
			}
		}
	}
	[HarmonyPatch(typeof(EnemyIdentifier))]
	public static class EnemyRoulettePatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("DeliverDamage")]
		public static void DeliverDamagePrefix(EnemyIdentifier __instance, ref float multiplier)
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)null || __instance.dead || (Object)(object)MonoSingleton<NewMovement>.Instance == (Object)null)
			{
				return;
			}
			if (RouletteManager.HasModifier(WaveModifier.AirSuperiority))
			{
				bool flag = (Object)(object)MonoSingleton<NewMovement>.Instance.gc != (Object)null && MonoSingleton<NewMovement>.Instance.gc.onGround;
				multiplier *= (flag ? 0.8f : 1.35f);
			}
			if (RouletteManager.HasModifier(WaveModifier.SniperDuel))
			{
				float num = Vector3.Distance(((Component)MonoSingleton<NewMovement>.Instance).transform.position, ((Component)__instance).transform.position);
				if (num >= 20f)
				{
					multiplier *= 2f;
				}
				else if (num <= 12f)
				{
					multiplier *= 0.5f;
				}
			}
			if (RouletteManager.HasModifier(WaveModifier.ParryHunt) && !RouletteManager.IsShockwaveActive)
			{
				multiplier *= 0.6f;
			}
			if (RouletteManager.HasModifier(WaveModifier.GlassCannon))
			{
				multiplier *= 2f;
			}
			if (RouletteManager.HasModifier(WaveModifier.WeaponEmbargo))
			{
				multiplier *= 1.25f;
			}
		}
	}
	[HarmonyPatch(typeof(Grenade))]
	public static class GrenadeRoulettePatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		public static void StartPostfix(Grenade __instance)
		{
			if (__instance.rocket && !__instance.enemy && RouletteManager.HasModifier(WaveModifier.SniperDuel))
			{
				__instance.rocketSpeed *= 1.5f;
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("Collision", new Type[]
		{
			typeof(Collider),
			typeof(Vector3)
		})]
		public static bool CollisionPrefix(Grenade __instance, Collider other, Vector3 velocity)
		{
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: 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_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			if (!RouletteManager.HasModifier(WaveModifier.RicochetArena) || !__instance.rocket || __instance.enemy || (Object)(object)other == (Object)null)
			{
				return true;
			}
			int layer = ((Component)other).gameObject.layer;
			if (layer == 8 || layer == 24)
			{
				int instanceID = ((Object)__instance).GetInstanceID();
				int value = 0;
				RouletteManager.RocketBounces.TryGetValue(instanceID, out value);
				if (value < 4 && (Object)(object)__instance.rb != (Object)null)
				{
					RouletteManager.RocketBounces[instanceID] = value + 1;
					Vector3 val = ((((Vector3)(ref velocity)).sqrMagnitude > 0.01f) ? ((Vector3)(ref velocity)).normalized : ((Component)__instance).transform.forward);
					RaycastHit val2 = default(RaycastHit);
					if (Physics.Raycast(((Component)__instance).transform.position - val * 1.5f, val, ref val2, 5f, LayerMask.op_Implicit(LayerMaskDefaults.Get((LMD)1))))
					{
						Vector3 val3 = Vector3.Reflect(val, ((RaycastHit)(ref val2)).normal);
						Vector3 normalized = ((Vector3)(ref val3)).normalized;
						((Component)__instance).transform.forward = normalized;
						__instance.rb.velocity = normalized * __instance.rocketSpeed;
						return false;
					}
				}
			}
			return true;
		}

		[HarmonyPostfix]
		[HarmonyPatch("OnDestroy")]
		public static void OnDestroyPostfix(Grenade __instance)
		{
			RouletteManager.RocketBounces.Remove(((Object)__instance).GetInstanceID());
		}
	}
	[HarmonyPatch(typeof(Punch))]
	public static class PunchRoulettePatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Parry")]
		public static void ParryPostfix()
		{
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: 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_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			if (!RouletteManager.HasModifier(WaveModifier.ParryHunt) || RouletteManager.ShockwaveCooldown > 0f || RouletteManager.IsShockwaveActive)
			{
				return;
			}
			NewMovement instance = MonoSingleton<NewMovement>.Instance;
			if ((Object)(object)instance == (Object)null || instance.dead)
			{
				return;
			}
			RouletteManager.ShockwaveCooldown = 0.25f;
			RouletteManager.IsShockwaveActive = true;
			try
			{
				instance.FullStamina();
				EnemyIdentifier[] array = Object.FindObjectsOfType<EnemyIdentifier>();
				if (array == null)
				{
					return;
				}
				EnemyIdentifier[] array2 = array;
				foreach (EnemyIdentifier val in array2)
				{
					if ((Object)(object)val != (Object)null && !val.dead && ((Component)val).gameObject.activeInHierarchy)
					{
						float num = Vector3.Distance(((Component)instance).transform.position, ((Component)val).transform.position);
						if (num <= 18f)
						{
							Vector3 val2 = ((Component)val).transform.position - ((Component)instance).transform.position;
							Vector3 val3 = ((Vector3)(ref val2)).normalized + Vector3.up * 0.8f;
							val.DeliverDamage(((Component)val).gameObject, val3 * 15000f, ((Component)val).transform.position, 4f, false, 0f, (GameObject)null, false, false);
						}
					}
				}
			}
			finally
			{
				RouletteManager.IsShockwaveActive = false;
			}
		}
	}
	[HarmonyPatch(typeof(NewMovement))]
	public static class PlayerRoulettePatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("Update")]
		public static void UpdatePrefix(NewMovement __instance)
		{
			if (RouletteManager.HasModifier(WaveModifier.ZeroGravity) && RouletteManager.PlayerInZeroG && __instance.sliding)
			{
				__instance.StopSlide();
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("StartSlide")]
		public static bool StartSlidePrefix()
		{
			if (RouletteManager.HasModifier(WaveModifier.ZeroGravity) && RouletteManager.PlayerInZeroG)
			{
				return false;
			}
			return true;
		}

		[HarmonyPostfix]
		[HarmonyPatch("Dodge")]
		public static void DodgePostfix(NewMovement __instance)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			if (RouletteManager.HasModifier(WaveModifier.ZeroGravity) && RouletteManager.PlayerInZeroG && (Object)(object)__instance.rb != (Object)null && (Object)(object)MonoSingleton<CameraController>.Instance != (Object)null)
			{
				Vector3 velocity = __instance.rb.velocity;
				float magnitude = ((Vector3)(ref velocity)).magnitude;
				__instance.rb.velocity = ((Component)MonoSingleton<CameraController>.Instance).transform.forward * Mathf.Max(magnitude, 45f);
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("GetHealth")]
		public static void GetHealthPrefix(ref int health)
		{
			if (RouletteManager.HasModifier(WaveModifier.Bloodlust) && health > 0 && health < 900)
			{
				health = Mathf.RoundToInt((float)health * 1.5f);
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("GetHurt")]
		public static void GetHurtPrefix(ref int damage, ref float hardDamageMultiplier)
		{
			if (RouletteManager.HasModifier(WaveModifier.GlassCannon) && damage > 0)
			{
				damage *= 2;
				hardDamageMultiplier = 0f;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("GetHurt")]
		public static void GetHurtPostfix(NewMovement __instance)
		{
			if (__instance.dead)
			{
				RouletteManager.ResetAll(resetRunProgress: true);
			}
		}
	}
}