Decompiled source of Empress SuperHot Arena v1.1.1

EmpressSuperHotArena.dll

Decompiled 3 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using REPOLib.Modules;
using REPOLib.Objects.Sdk;
using TMPro;
using Unity.AI.Navigation;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Empress.REPO.SuperHotArena
{
	internal static class ArenaAccess
	{
		private delegate void ModuleSetAllChecklistDelegate(Module module);

		private delegate void LevelGeneratorGenerateDoneDelegate(LevelGenerator instance, PhotonMessageInfo info);

		private static readonly FieldInfo EnvironmentSetupDoneField = AccessTools.Field(typeof(EnvironmentDirector), "SetupDone");

		private static readonly FieldInfo EnvironmentMainCameraField = AccessTools.Field(typeof(EnvironmentDirector), "MainCamera");

		private static readonly FieldInfo EnvironmentAmbientColorField = AccessTools.Field(typeof(EnvironmentDirector), "AmbientColor");

		private static readonly FieldInfo EnvironmentAmbientColorNewField = AccessTools.Field(typeof(EnvironmentDirector), "AmbientColorNew");

		private static readonly FieldInfo EnvironmentAmbientColorPreviousField = AccessTools.Field(typeof(EnvironmentDirector), "AmbientColorPrevious");

		private static readonly FieldInfo EnvironmentAmbientColorAdaptationField = AccessTools.Field(typeof(EnvironmentDirector), "AmbientColorAdaptation");

		private static readonly FieldInfo EnvironmentAmbientColorAdaptationNewField = AccessTools.Field(typeof(EnvironmentDirector), "AmbientColorAdaptationNew");

		private static readonly FieldInfo EnvironmentAmbientColorAdaptationPreviousField = AccessTools.Field(typeof(EnvironmentDirector), "AmbientColorAdaptationPrevious");

		private static readonly FieldInfo EnvironmentDarkAdaptationLerpField = AccessTools.Field(typeof(EnvironmentDirector), "DarkAdaptationLerp");

		private static readonly FieldInfo EnvironmentFogColorField = AccessTools.Field(typeof(EnvironmentDirector), "FogColor");

		private static readonly FieldInfo EnvironmentFogColorNewField = AccessTools.Field(typeof(EnvironmentDirector), "FogColorNew");

		private static readonly FieldInfo EnvironmentFogColorPreviousField = AccessTools.Field(typeof(EnvironmentDirector), "FogColorPrevious");

		private static readonly FieldInfo EnvironmentFogStartDistanceField = AccessTools.Field(typeof(EnvironmentDirector), "FogStartDistance");

		private static readonly FieldInfo EnvironmentFogStartDistanceNewField = AccessTools.Field(typeof(EnvironmentDirector), "FogStartDistanceNew");

		private static readonly FieldInfo EnvironmentFogStartDistancePreviousField = AccessTools.Field(typeof(EnvironmentDirector), "FogStartDistancePrevious");

		private static readonly FieldInfo EnvironmentFogEndDistanceField = AccessTools.Field(typeof(EnvironmentDirector), "FogEndDistance");

		private static readonly FieldInfo EnvironmentFogEndDistanceNewField = AccessTools.Field(typeof(EnvironmentDirector), "FogEndDistanceNew");

		private static readonly FieldInfo EnvironmentFogEndDistancePreviousField = AccessTools.Field(typeof(EnvironmentDirector), "FogEndDistancePrevious");

		private static readonly FieldInfo LevelGeneratorAllPlayersReadyField = AccessTools.Field(typeof(LevelGenerator), "AllPlayersReady");

		private static readonly FieldInfo LevelGeneratorEnemyReadyField = AccessTools.Field(typeof(LevelGenerator), "EnemyReady");

		private static readonly FieldInfo LevelGeneratorModulesSpawnedField = AccessTools.Field(typeof(LevelGenerator), "ModulesSpawned");

		private static readonly FieldInfo LevelGeneratorPlayerSpawnedField = AccessTools.Field(typeof(LevelGenerator), "playerSpawned");

		private static readonly FieldInfo RunManagerLevelPreviousField = AccessTools.Field(typeof(RunManager), "levelPrevious");

		private static readonly FieldInfo PlayerControllerInputDisableTimerField = AccessTools.Field(typeof(PlayerController), "InputDisableTimer");

		private static readonly FieldInfo PlayerAvatarIsDisabledField = AccessTools.Field(typeof(PlayerAvatar), "isDisabled");

		private static readonly FieldInfo PlayerAvatarDeadSetField = AccessTools.Field(typeof(PlayerAvatar), "deadSet");

		private static readonly FieldInfo ValuableDirectorSetupCompleteField = AccessTools.Field(typeof(ValuableDirector), "setupComplete");

		private static readonly FieldInfo ValuableDirectorValuablesSpawnedField = AccessTools.Field(typeof(ValuableDirector), "valuablesSpawned");

		private static readonly FieldInfo RoundDirectorExtractionPointsField = AccessTools.Field(typeof(RoundDirector), "extractionPoints");

		private static readonly FieldInfo RoundDirectorExtractionPointsCompletedField = AccessTools.Field(typeof(RoundDirector), "extractionPointsCompleted");

		private static readonly FieldInfo RoundDirectorExtractionPointListField = AccessTools.Field(typeof(RoundDirector), "extractionPointList");

		private static readonly FieldInfo LoadingUiLevelAnimationCompletedField = AccessTools.Field(typeof(LoadingUI), "levelAnimationCompleted");

		private static readonly FieldInfo LevelPointInStartRoomField = AccessTools.Field(typeof(LevelPoint), "inStartRoom");

		private static readonly FieldInfo PlayerAvatarSteamIdField = AccessTools.Field(typeof(PlayerAvatar), "steamID");

		private static readonly FieldInfo PlayerAvatarIsLocalField = AccessTools.Field(typeof(PlayerAvatar), "isLocal");

		private static readonly FieldInfo ItemAttributesInstanceNameField = AccessTools.Field(typeof(ItemAttributes), "instanceName");

		private static readonly FieldInfo ItemAttributesHasIconField = AccessTools.Field(typeof(ItemAttributes), "hasIcon");

		private static readonly FieldInfo ItemBatteryLifeIntField = AccessTools.Field(typeof(ItemBattery), "batteryLifeInt");

		private static readonly FieldInfo ItemGunBatteryField = AccessTools.Field(typeof(ItemGun), "itemBattery");

		private static readonly FieldInfo ModuleSetupDoneField = AccessTools.Field(typeof(Module), "SetupDone");

		private static readonly FieldInfo ModuleStartRoomField = AccessTools.Field(typeof(Module), "StartRoom");

		private static readonly FieldInfo ModuleGridXField = AccessTools.Field(typeof(Module), "GridX");

		private static readonly FieldInfo ModuleGridYField = AccessTools.Field(typeof(Module), "GridY");

		private static readonly MethodInfo ModuleSetAllChecklistMethod = AccessTools.Method(typeof(Module), "SetAllChecklist", (Type[])null, (Type[])null);

		private static readonly MethodInfo LevelGeneratorGenerateDoneMethod = AccessTools.Method(typeof(LevelGenerator), "GenerateDone", new Type[1] { typeof(PhotonMessageInfo) }, (Type[])null);

		private static readonly ModuleSetAllChecklistDelegate ModuleSetAllChecklistCall = CreateDelegate<ModuleSetAllChecklistDelegate>(ModuleSetAllChecklistMethod);

		private static readonly LevelGeneratorGenerateDoneDelegate LevelGeneratorGenerateDoneCall = CreateDelegate<LevelGeneratorGenerateDoneDelegate>(LevelGeneratorGenerateDoneMethod);

		public static void SetEnvironmentFog(EnvironmentDirector director, Color color, float startDistance, float endDistance)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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)
			SetField(EnvironmentFogColorField, director, color);
			SetField(EnvironmentFogColorNewField, director, color);
			SetField(EnvironmentFogColorPreviousField, director, color);
			SetField(EnvironmentFogStartDistanceField, director, startDistance);
			SetField(EnvironmentFogStartDistanceNewField, director, startDistance);
			SetField(EnvironmentFogStartDistancePreviousField, director, startDistance);
			SetField(EnvironmentFogEndDistanceField, director, endDistance);
			SetField(EnvironmentFogEndDistanceNewField, director, endDistance);
			SetField(EnvironmentFogEndDistancePreviousField, director, endDistance);
		}

		public static void SetEnvironmentAmbient(EnvironmentDirector director, Color ambient, Color adaptation)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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)
			SetField(EnvironmentAmbientColorField, director, ambient);
			SetField(EnvironmentAmbientColorNewField, director, ambient);
			SetField(EnvironmentAmbientColorPreviousField, director, ambient);
			SetField(EnvironmentAmbientColorAdaptationField, director, adaptation);
			SetField(EnvironmentAmbientColorAdaptationNewField, director, adaptation);
			SetField(EnvironmentAmbientColorAdaptationPreviousField, director, adaptation);
		}

		public static void SetEnvironmentDarkAdaptation(EnvironmentDirector director, float value)
		{
			SetField(EnvironmentDarkAdaptationLerpField, director, value);
		}

		public static Camera GetEnvironmentMainCamera(EnvironmentDirector director)
		{
			return Get<Camera>(EnvironmentMainCameraField, director);
		}

		public static void SetEnvironmentMainCamera(EnvironmentDirector director, Camera camera)
		{
			SetField(EnvironmentMainCameraField, director, camera);
		}

		public static void SetEnvironmentSetupDone(EnvironmentDirector director, bool value)
		{
			SetField(EnvironmentSetupDoneField, director, value);
		}

		public static void SetAllPlayersReady(LevelGenerator generator, bool value)
		{
			SetField(LevelGeneratorAllPlayersReadyField, generator, value);
		}

		public static bool GetAllPlayersReady(LevelGenerator generator)
		{
			return GetBool(LevelGeneratorAllPlayersReadyField, generator);
		}

		public static void SetEnemyReady(LevelGenerator generator, bool value)
		{
			SetField(LevelGeneratorEnemyReadyField, generator, value);
		}

		public static void SetModulesSpawned(LevelGenerator generator, int value)
		{
			SetField(LevelGeneratorModulesSpawnedField, generator, value);
		}

		public static void SetPlayerSpawnedCount(LevelGenerator generator, int value)
		{
			SetField(LevelGeneratorPlayerSpawnedField, generator, value);
		}

		public static int GetPlayerSpawnedCount(LevelGenerator generator)
		{
			return GetInt(LevelGeneratorPlayerSpawnedField, generator);
		}

		public static void SetLevelPrevious(RunManager manager, Level level)
		{
			SetField(RunManagerLevelPreviousField, manager, level);
		}

		public static float GetInputDisableTimer(PlayerController controller)
		{
			return GetFloat(PlayerControllerInputDisableTimerField, controller);
		}

		public static bool GetIsDisabled(PlayerAvatar avatar)
		{
			return GetBool(PlayerAvatarIsDisabledField, avatar);
		}

		public static bool GetDeadSet(PlayerAvatar avatar)
		{
			return GetBool(PlayerAvatarDeadSetField, avatar);
		}

		public static void SetValuableSetupComplete(ValuableDirector director, bool value)
		{
			SetField(ValuableDirectorSetupCompleteField, director, value);
		}

		public static void SetValuableValuablesSpawned(ValuableDirector director, bool value)
		{
			SetField(ValuableDirectorValuablesSpawnedField, director, value);
		}

		public static void ResetRoundExtraction(RoundDirector director)
		{
			SetField(RoundDirectorExtractionPointsField, director, 0);
			SetField(RoundDirectorExtractionPointsCompletedField, director, 0);
			Get<List<GameObject>>(RoundDirectorExtractionPointListField, director)?.Clear();
		}

		public static bool GetLevelAnimationCompleted(LoadingUI ui)
		{
			return GetBool(LoadingUiLevelAnimationCompletedField, ui);
		}

		public static void ConfigureStartRoomModule(Module module, int gridX, int gridY)
		{
			ModuleSetAllChecklistCall?.Invoke(module);
			SetField(ModuleSetupDoneField, module, true);
			SetField(ModuleStartRoomField, module, true);
			SetField(ModuleGridXField, module, gridX);
			SetField(ModuleGridYField, module, gridY);
		}

		public static void MarkLevelPointInStartRoom(LevelPoint point, bool value)
		{
			SetField(LevelPointInStartRoomField, point, value);
		}

		public static bool GetIsLocal(PlayerAvatar avatar)
		{
			return GetBool(PlayerAvatarIsLocalField, avatar);
		}

		public static string GetSteamId(PlayerAvatar avatar)
		{
			if (PlayerAvatarSteamIdField == null || (Object)(object)avatar == (Object)null)
			{
				return string.Empty;
			}
			return (PlayerAvatarSteamIdField.GetValue(avatar) as string) ?? string.Empty;
		}

		public static string GetItemInstanceName(ItemAttributes attributes)
		{
			if (ItemAttributesInstanceNameField == null || (Object)(object)attributes == (Object)null)
			{
				return string.Empty;
			}
			return (ItemAttributesInstanceNameField.GetValue(attributes) as string) ?? string.Empty;
		}

		public static bool GetItemHasIcon(ItemAttributes attributes)
		{
			return GetBool(ItemAttributesHasIconField, attributes);
		}

		public static void SetItemBatteryLifeInt(ItemBattery battery, int value)
		{
			SetField(ItemBatteryLifeIntField, battery, value);
		}

		public static ItemBattery GetGunBattery(ItemGun gun)
		{
			return Get<ItemBattery>(ItemGunBatteryField, gun);
		}

		public static void GenerateDone(LevelGenerator generator)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if (LevelGeneratorGenerateDoneCall != null)
			{
				LevelGeneratorGenerateDoneCall(generator, default(PhotonMessageInfo));
			}
		}

		private static T Get<T>(FieldInfo field, object instance) where T : class
		{
			if (field == null || instance == null)
			{
				return null;
			}
			return field.GetValue(instance) as T;
		}

		private static bool GetBool(FieldInfo field, object instance)
		{
			if (field == null || instance == null)
			{
				return false;
			}
			object value = field.GetValue(instance);
			bool flag = default(bool);
			int num;
			if (value is bool)
			{
				flag = (bool)value;
				num = 1;
			}
			else
			{
				num = 0;
			}
			return (byte)((uint)num & (flag ? 1u : 0u)) != 0;
		}

		private static int GetInt(FieldInfo field, object instance)
		{
			if (field == null || instance == null)
			{
				return 0;
			}
			object value = field.GetValue(instance);
			if (value is int)
			{
				return (int)value;
			}
			return 0;
		}

		private static float GetFloat(FieldInfo field, object instance)
		{
			if (field == null || instance == null)
			{
				return 0f;
			}
			object value = field.GetValue(instance);
			if (value is float)
			{
				return (float)value;
			}
			return 0f;
		}

		private static void SetField(FieldInfo field, object instance, object value)
		{
			if (!(field == null) && instance != null)
			{
				field.SetValue(instance, value);
			}
		}

		private static TDelegate CreateDelegate<TDelegate>(MethodInfo method) where TDelegate : Delegate
		{
			if (method == null)
			{
				return null;
			}
			return AccessTools.MethodDelegate<TDelegate>(method, (object)null, true);
		}
	}
	internal static class ArenaAssets
	{
		private const string BundleName = "empresssuperhotassets";

		private const string MusicBundleName = "empresssuperhotarenamusic";

		private static readonly Dictionary<string, AudioClip> Clips = new Dictionary<string, AudioClip>();

		private static readonly Dictionary<string, AudioClip> MusicClips = new Dictionary<string, AudioClip>();

		private static AssetBundle _bundle;

		private static AssetBundle _musicBundle;

		private static GameObject _pistolEnemy;

		private static GameObject _shotgunEnemy;

		private static bool _initialized;

		private static bool _musicInitialized;

		public static bool HasPrefabs
		{
			get
			{
				if (!((Object)(object)_pistolEnemy != (Object)null))
				{
					return (Object)(object)_shotgunEnemy != (Object)null;
				}
				return true;
			}
		}

		public static bool HasMusic => MusicClips.Count > 0;

		public static void Initialize(string pluginDirectory, ManualLogSource log)
		{
			if (_initialized)
			{
				return;
			}
			_initialized = true;
			string text = ResolveBundlePath(pluginDirectory);
			if (text == null || !File.Exists(text))
			{
				log.LogWarning((object)"Empress SuperHot Arena asset bundle not found beside DLL. Falling back to procedural enemies.");
				return;
			}
			_bundle = AssetBundle.LoadFromFile(text);
			if ((Object)(object)_bundle == (Object)null)
			{
				log.LogWarning((object)("Empress SuperHot Arena could not load asset bundle at " + text));
				return;
			}
			_pistolEnemy = _bundle.LoadAsset<GameObject>("EmpressSuperHotPistolEnemy");
			_shotgunEnemy = _bundle.LoadAsset<GameObject>("EmpressSuperHotShotgunEnemy");
			string[] allAssetNames = _bundle.GetAllAssetNames();
			foreach (string text2 in allAssetNames)
			{
				AudioClip val = _bundle.LoadAsset<AudioClip>(text2);
				if (!((Object)(object)val == (Object)null))
				{
					RegisterClip(text2, val);
					RegisterClip(Path.GetFileNameWithoutExtension(text2), val);
					RegisterClip(((Object)val).name, val);
				}
			}
			int num = (((Object)(object)_pistolEnemy != (Object)null) ? 1 : 0) + (((Object)(object)_shotgunEnemy != (Object)null) ? 1 : 0);
			log.LogInfo((object)("Empress SuperHot Arena loaded " + num + " enemy prefab(s) and " + Clips.Count + " audio entries."));
		}

		public static void InitializeMusic(string pluginDirectory, ManualLogSource log)
		{
			if (_musicInitialized)
			{
				return;
			}
			_musicInitialized = true;
			string text = ResolveMusicBundlePath(pluginDirectory);
			if (text == null || !File.Exists(text))
			{
				log.LogWarning((object)"Empress SuperHot Arena music bundle (empresssuperhotarenamusic) not found beside DLL. Level will be silent.");
				return;
			}
			_musicBundle = AssetBundle.LoadFromFile(text);
			if ((Object)(object)_musicBundle == (Object)null)
			{
				log.LogWarning((object)("Empress SuperHot Arena could not load music bundle at " + text));
				return;
			}
			string[] allAssetNames = _musicBundle.GetAllAssetNames();
			foreach (string text2 in allAssetNames)
			{
				AudioClip val = _musicBundle.LoadAsset<AudioClip>(text2);
				if (!((Object)(object)val == (Object)null))
				{
					RegisterMusic(text2, val);
					RegisterMusic(Path.GetFileNameWithoutExtension(text2), val);
					RegisterMusic(((Object)val).name, val);
				}
			}
			log.LogInfo((object)("Empress SuperHot Arena loaded " + MusicClips.Count + " music entries."));
		}

		public static GameObject GetEnemyPrefab(int id)
		{
			if ((Object)(object)_shotgunEnemy != (Object)null && id % 4 == 3)
			{
				return _shotgunEnemy;
			}
			if ((Object)(object)_pistolEnemy != (Object)null)
			{
				return _pistolEnemy;
			}
			return _shotgunEnemy;
		}

		public static AudioClip GetClip(string name)
		{
			if (!Clips.TryGetValue(Key(name), out var value))
			{
				return null;
			}
			return value;
		}

		public static AudioClip GetMusicClip(string name)
		{
			if (!MusicClips.TryGetValue(Key(name), out var value))
			{
				return null;
			}
			return value;
		}

		public static void Play(string name, Vector3 position, float volume = 1f)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			AudioClip clip = GetClip(name);
			if (!((Object)(object)clip == (Object)null))
			{
				AudioSource.PlayClipAtPoint(clip, position, Mathf.Clamp01(volume));
			}
		}

		private static string ResolveBundlePath(string pluginDirectory)
		{
			string[] array = new string[3]
			{
				Path.Combine(pluginDirectory, "empresssuperhotassets"),
				Path.Combine(pluginDirectory ?? string.Empty, "SuperHot", "empresssuperhotassets"),
				Path.Combine(Path.GetDirectoryName(pluginDirectory) ?? pluginDirectory ?? string.Empty, "empresssuperhotassets")
			};
			for (int i = 0; i < array.Length; i++)
			{
				if (File.Exists(array[i]))
				{
					return array[i];
				}
			}
			return array[0];
		}

		private static string ResolveMusicBundlePath(string pluginDirectory)
		{
			string[] array = new string[3]
			{
				Path.Combine(pluginDirectory, "empresssuperhotarenamusic"),
				Path.Combine(pluginDirectory ?? string.Empty, "Music", "empresssuperhotarenamusic"),
				Path.Combine(Path.GetDirectoryName(pluginDirectory) ?? pluginDirectory ?? string.Empty, "empresssuperhotarenamusic")
			};
			for (int i = 0; i < array.Length; i++)
			{
				if (File.Exists(array[i]))
				{
					return array[i];
				}
			}
			return array[0];
		}

		private static void RegisterClip(string name, AudioClip clip)
		{
			string text = Key(name);
			if (!string.IsNullOrEmpty(text) && !Clips.ContainsKey(text))
			{
				Clips.Add(text, clip);
			}
		}

		private static void RegisterMusic(string name, AudioClip clip)
		{
			string text = Key(name);
			if (!string.IsNullOrEmpty(text) && !MusicClips.ContainsKey(text))
			{
				MusicClips.Add(text, clip);
			}
		}

		private static string Key(string name)
		{
			if (!string.IsNullOrEmpty(name))
			{
				return name.ToLowerInvariant().Replace("\\", "/").Replace(" ", "_")
					.Replace("-", "_");
			}
			return string.Empty;
		}
	}
	internal sealed class ArenaBullet : MonoBehaviour
	{
		private static Material _playerTracerMaterial;

		private static Material _enemyTracerMaterial;

		private Vector3 _direction;

		private Vector3 _targetPosition;

		private float _life;

		private float _speed;

		private int _damage;

		private bool _visualOnly;

		public static void FireTracer(Vector3 origin, Vector3 direction, Vector3 endPoint)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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)
			ArenaBullet arenaBullet = CreateBullet(origin, direction, 0.1f, 0.28f, _playerTracerMaterial ?? (_playerTracerMaterial = CreateMaterial(Color.white)));
			arenaBullet._direction = ((Vector3)(ref direction)).normalized;
			arenaBullet._targetPosition = endPoint;
			arenaBullet._life = 1.4f;
			arenaBullet._speed = 48f;
			arenaBullet._visualOnly = true;
		}

		public static void FireDamaging(Vector3 origin, Vector3 direction, int damage)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			ArenaBullet arenaBullet = CreateBullet(origin, direction, 0.14f, 0.22f, _enemyTracerMaterial ?? (_enemyTracerMaterial = CreateMaterial(new Color(1f, 0.3f, 0.5f))));
			arenaBullet._direction = ((Vector3)(ref direction)).normalized;
			arenaBullet._life = 4f;
			arenaBullet._speed = 24f;
			arenaBullet._damage = damage;
			arenaBullet._visualOnly = false;
		}

		private void Update()
		{
			//IL_00a3: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_0060: 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)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: 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_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			if (_life <= 0f)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			if (_visualOnly)
			{
				float num = Mathf.Max(0.015f, _speed * Time.deltaTime);
				((Component)this).transform.position = Vector3.MoveTowards(((Component)this).transform.position, _targetPosition, num);
				if (Vector3.Distance(((Component)this).transform.position, _targetPosition) <= 0.05f)
				{
					Object.Destroy((Object)(object)((Component)this).gameObject);
				}
				else
				{
					_life -= Time.deltaTime;
				}
				return;
			}
			float num2 = _speed * Time.deltaTime;
			int num3 = LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()) | LayerMask.GetMask(new string[1] { "Player" });
			RaycastHit val = default(RaycastHit);
			if (Physics.SphereCast(((Component)this).transform.position, 0.08f, _direction, ref val, num2, num3, (QueryTriggerInteraction)1))
			{
				PlayerAvatar componentInParent = ((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<PlayerAvatar>();
				if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent.playerHealth != (Object)null && !ArenaAccess.GetIsDisabled(componentInParent) && !ArenaAccess.GetDeadSet(componentInParent))
				{
					componentInParent.playerHealth.HurtOther(_damage, ((RaycastHit)(ref val)).point, false, -1, false);
				}
				((Component)this).transform.position = ((RaycastHit)(ref val)).point;
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
			else
			{
				Transform transform = ((Component)this).transform;
				transform.position += _direction * num2;
				_life -= Time.deltaTime;
			}
		}

		private static ArenaBullet CreateBullet(Vector3 origin, Vector3 direction, float radius, float trailTime, Material material)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = GameObject.CreatePrimitive((PrimitiveType)1);
			((Object)obj).name = "Empress Arena Bullet";
			obj.layer = 2;
			obj.transform.position = origin;
			obj.transform.rotation = Quaternion.LookRotation(((Vector3)(ref direction)).normalized, Vector3.up) * Quaternion.Euler(90f, 0f, 0f);
			obj.transform.localScale = new Vector3(radius, radius * 3.5f, radius);
			Collider component = obj.GetComponent<Collider>();
			if ((Object)(object)component != (Object)null)
			{
				component.enabled = false;
			}
			Renderer component2 = obj.GetComponent<Renderer>();
			if ((Object)(object)component2 != (Object)null)
			{
				component2.sharedMaterial = material;
			}
			TrailRenderer obj2 = obj.AddComponent<TrailRenderer>();
			obj2.time = trailTime;
			obj2.startWidth = radius * 1.1f;
			obj2.endWidth = 0f;
			((Renderer)obj2).sharedMaterial = material;
			return obj.AddComponent<ArenaBullet>();
		}

		private static Material CreateMaterial(Color color)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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)
			Material val = new Material(Shader.Find("Standard"));
			val.color = color;
			if (val.HasProperty("_EmissionColor"))
			{
				val.EnableKeyword("_EMISSION");
				val.SetColor("_EmissionColor", color * 3.5f);
			}
			return val;
		}
	}
	internal enum EnemyKind : byte
	{
		Standard,
		Teleporter,
		Boss
	}
	internal sealed class ArenaEnemy : MonoBehaviour
	{
		private static Material _bodyMaterial;

		private static Material _accentMaterial;

		private static Material _faceMaterial;

		private static Material _deadMaterial;

		private int _health;

		private bool _dying;

		private float _deathTimer;

		private float _fireTimer;

		private float _pathRefreshTimer;

		private float _strafeTimer;

		private float _strafeSign;

		private float _stuckTimer;

		private float _reseatCooldown;

		private Vector3 _deathStartScale;

		private Vector3 _spawnPoint;

		private Vector3 _patrolTarget;

		private Vector3 _lastPosition;

		private Vector3 _remoteTargetPosition;

		private Quaternion _remoteTargetRotation;

		private bool _hasRemoteTarget;

		private bool _remoteAiming;

		private bool _remoteMoving;

		private bool _hasPatrolTarget;

		private bool _visualFromPrefab;

		private bool _wasAiming;

		private bool _remote;

		private EnemyKind _kind;

		private float _teleportTimer;

		private NavMeshAgent _agent;

		private NavMeshPath _path;

		private Renderer[] _renderers;

		private CapsuleCollider _hitCollider;

		private Transform _muzzle;

		private Animator _animator;

		public int Id { get; private set; }

		public bool Dead { get; private set; }

		public bool Remote => _remote;

		public EnemyKind Kind => _kind;

		public bool LastAiming { get; private set; }

		public bool LastMoving { get; private set; }

		public Vector3 AimPoint => ((Component)this).transform.position + Vector3.up * ((_kind == EnemyKind.Boss) ? 4.35f : 1.45f);

		public static ArenaEnemy Create(int id, EnemyKind kind, Vector3 position, Quaternion rotation, int health, Transform holder)
		{
			//IL_0000: 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_0056: Expected O, but got Unknown
			//IL_006c: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_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)
			//IL_013f: 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)
			if (!TryFindNearestNavMeshPoint(position, out var hit))
			{
				return null;
			}
			GameObject enemyPrefab = ArenaAssets.GetEnemyPrefab(id);
			GameObject val = new GameObject("Empress Arena Enemy " + id + " [" + kind.ToString() + "]");
			val.transform.SetParent(holder, false);
			val.transform.position = ((NavMeshHit)(ref hit)).position;
			val.transform.rotation = rotation;
			if (kind == EnemyKind.Boss)
			{
				val.transform.localScale = Vector3.one * 3f;
			}
			if ((Object)(object)enemyPrefab != (Object)null)
			{
				AttachPrefabVisual(enemyPrefab, val.transform);
			}
			ArenaEnemy arenaEnemy = val.AddComponent<ArenaEnemy>();
			arenaEnemy.Id = id;
			arenaEnemy._kind = kind;
			arenaEnemy._health = Mathf.Max(1, health);
			arenaEnemy._spawnPoint = ((NavMeshHit)(ref hit)).position;
			arenaEnemy._lastPosition = ((NavMeshHit)(ref hit)).position;
			arenaEnemy._visualFromPrefab = (Object)(object)enemyPrefab != (Object)null;
			arenaEnemy._teleportTimer = ((kind == EnemyKind.Teleporter) ? Random.Range(3.5f, 6f) : 0f);
			if ((Object)(object)enemyPrefab != (Object)null)
			{
				arenaEnemy.PreparePrefabVisual();
			}
			else
			{
				arenaEnemy.BuildProceduralVisual();
			}
			arenaEnemy.ApplyKindVisual();
			if (!arenaEnemy.ConfigureAgent(((NavMeshHit)(ref hit)).position))
			{
				Object.Destroy((Object)(object)val);
				return null;
			}
			arenaEnemy._fireTimer = Random.Range(0.6f, 1.8f);
			ArenaAssets.Play("enemy_spawn", ((NavMeshHit)(ref hit)).position, 0.7f);
			return arenaEnemy;
		}

		public static ArenaEnemy CreateRemote(int id, EnemyKind kind, Vector3 position, Quaternion rotation, Transform holder)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_005e: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_00c8: 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_00cf: 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_00d6: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			GameObject enemyPrefab = ArenaAssets.GetEnemyPrefab(id);
			GameObject val = new GameObject("Empress Arena Enemy " + id + " [" + kind.ToString() + "] (Remote)");
			val.transform.SetParent(holder, false);
			val.transform.position = position;
			val.transform.rotation = rotation;
			if (kind == EnemyKind.Boss)
			{
				val.transform.localScale = Vector3.one * 3f;
			}
			if ((Object)(object)enemyPrefab != (Object)null)
			{
				AttachPrefabVisual(enemyPrefab, val.transform);
			}
			ArenaEnemy arenaEnemy = val.AddComponent<ArenaEnemy>();
			arenaEnemy.Id = id;
			arenaEnemy._kind = kind;
			arenaEnemy._remote = true;
			arenaEnemy._health = 1;
			arenaEnemy._spawnPoint = position;
			arenaEnemy._lastPosition = position;
			arenaEnemy._remoteTargetPosition = position;
			arenaEnemy._remoteTargetRotation = rotation;
			arenaEnemy._hasRemoteTarget = true;
			arenaEnemy._visualFromPrefab = (Object)(object)enemyPrefab != (Object)null;
			if ((Object)(object)enemyPrefab != (Object)null)
			{
				arenaEnemy.PreparePrefabVisual();
			}
			else
			{
				arenaEnemy.BuildProceduralVisual();
			}
			arenaEnemy.ApplyKindVisual();
			ArenaAssets.Play("enemy_spawn", position, 0.6f);
			return arenaEnemy;
		}

		private void ApplyKindVisual()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			if (_kind == EnemyKind.Teleporter)
			{
				ApplyTint(new Color(0.25f, 0.55f, 1f));
			}
		}

		private void ApplyTint(Color tint)
		{
			//IL_003b: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			if (_renderers == null)
			{
				return;
			}
			for (int i = 0; i < _renderers.Length; i++)
			{
				Renderer val = _renderers[i];
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				Material[] materials = val.materials;
				foreach (Material val2 in materials)
				{
					if (!((Object)(object)val2 == (Object)null))
					{
						val2.color = tint;
						if (val2.HasProperty("_EmissionColor"))
						{
							val2.EnableKeyword("_EMISSION");
							val2.SetColor("_EmissionColor", tint * 2.5f);
						}
					}
				}
				val.materials = materials;
			}
		}

		public void ApplyRemoteTransform(Vector3 position, Quaternion rotation, bool aiming, bool moving)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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)
			if (!Dead && !_dying)
			{
				if (Vector3.Distance(((Component)this).transform.position, position) > 4f)
				{
					((Component)this).transform.position = position;
					((Component)this).transform.rotation = rotation;
				}
				_remoteTargetPosition = position;
				_remoteTargetRotation = rotation;
				_remoteAiming = aiming;
				_remoteMoving = moving;
				_hasRemoteTarget = true;
			}
		}

		public void ApplyRemoteDeath(Vector3 direction)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			if (!Dead)
			{
				Die(direction);
			}
		}

		private static void AttachPrefabVisual(GameObject prefab, Transform root)
		{
			//IL_002f: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			bool activeSelf = prefab.activeSelf;
			prefab.SetActive(false);
			GameObject obj = Object.Instantiate<GameObject>(prefab, root, false);
			prefab.SetActive(activeSelf);
			((Object)obj).name = ((Object)prefab).name;
			obj.transform.localPosition = Vector3.zero;
			obj.transform.localRotation = Quaternion.identity;
			obj.transform.localScale = Vector3.one;
			DisableImportedAgents(obj);
			obj.SetActive(true);
			LiftVisualToGround(obj);
		}

		private static void DisableImportedAgents(GameObject root)
		{
			MonoBehaviour[] componentsInChildren = root.GetComponentsInChildren<MonoBehaviour>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				if ((Object)(object)componentsInChildren[i] != (Object)null)
				{
					((Behaviour)componentsInChildren[i]).enabled = false;
				}
			}
			NavMeshAgent[] componentsInChildren2 = root.GetComponentsInChildren<NavMeshAgent>(true);
			for (int j = 0; j < componentsInChildren2.Length; j++)
			{
				if ((Object)(object)componentsInChildren2[j] != (Object)null)
				{
					((Behaviour)componentsInChildren2[j]).enabled = false;
				}
			}
			NavMeshObstacle[] componentsInChildren3 = root.GetComponentsInChildren<NavMeshObstacle>(true);
			for (int k = 0; k < componentsInChildren3.Length; k++)
			{
				if ((Object)(object)componentsInChildren3[k] != (Object)null)
				{
					((Behaviour)componentsInChildren3[k]).enabled = false;
				}
			}
		}

		private static void LiftVisualToGround(GameObject visual)
		{
			//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)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
			Renderer[] componentsInChildren = visual.GetComponentsInChildren<Renderer>(true);
			if (componentsInChildren.Length == 0)
			{
				return;
			}
			Bounds bounds = componentsInChildren[0].bounds;
			for (int i = 1; i < componentsInChildren.Length; i++)
			{
				if ((Object)(object)componentsInChildren[i] != (Object)null)
				{
					((Bounds)(ref bounds)).Encapsulate(componentsInChildren[i].bounds);
				}
			}
			float num = (((Object)(object)visual.transform.parent != (Object)null) ? (visual.transform.parent.position.y + 0.02f) : 0.02f) - ((Bounds)(ref bounds)).min.y;
			if (Mathf.Abs(num) > 0.001f)
			{
				Transform transform = visual.transform;
				transform.position += Vector3.up * num;
			}
		}

		private void Update()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			if (_dying)
			{
				TickDeathAnimation();
			}
			else if (_remote && _hasRemoteTarget)
			{
				((Component)this).transform.position = Vector3.Lerp(((Component)this).transform.position, _remoteTargetPosition, Time.deltaTime * 12f);
				((Component)this).transform.rotation = Quaternion.RotateTowards(((Component)this).transform.rotation, _remoteTargetRotation, 540f * Time.deltaTime);
				Animate(_remoteAiming, _remoteMoving);
			}
		}

		private void TickDeathAnimation()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			_deathTimer += Time.unscaledDeltaTime;
			float num = Mathf.Clamp01(_deathTimer / 0.55f);
			float num2 = num * num * (3f - 2f * num);
			((Component)this).transform.localScale = Vector3.Lerp(_deathStartScale, Vector3.zero, num2);
			if (_renderers != null)
			{
				for (int i = 0; i < _renderers.Length; i++)
				{
					Renderer val = _renderers[i];
					if (!((Object)(object)val == (Object)null))
					{
						Material material = val.material;
						if ((Object)(object)material != (Object)null && material.HasProperty("_Color"))
						{
							material.color = Color.Lerp(material.color, Color.black, num2);
						}
					}
				}
			}
			if (num >= 1f)
			{
				((Component)this).gameObject.SetActive(false);
			}
		}

		public void TickCombat(float range)
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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_0098: 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_005a: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			if (Dead || _dying || _remote || !EnsureAgentOnNavMesh())
			{
				return;
			}
			PlayerAvatar val = FindClosestTarget(range * 2f);
			Vector3 velocity;
			if ((Object)(object)val == (Object)null)
			{
				Patrol();
				int moving;
				if ((Object)(object)_agent != (Object)null)
				{
					velocity = _agent.velocity;
					moving = ((((Vector3)(ref velocity)).sqrMagnitude > 0.05f) ? 1 : 0);
				}
				else
				{
					moving = 0;
				}
				Animate(aiming: false, (byte)moving != 0);
				return;
			}
			Vector3 val2 = (((Component)val).transform.position - ((Component)this).transform.position).WithY(0f);
			float magnitude = ((Vector3)(ref val2)).magnitude;
			float num = ((_kind == EnemyKind.Boss) ? 3.4f : 1.6f);
			if (magnitude < num)
			{
				TouchPlayer(val);
				return;
			}
			MoveToward(((Component)val).transform.position);
			UpdateTeleport(val);
			FaceMovementDirection();
			int num2;
			if ((Object)(object)_agent != (Object)null)
			{
				velocity = _agent.velocity;
				num2 = ((((Vector3)(ref velocity)).sqrMagnitude > 0.05f) ? 1 : 0);
			}
			else
			{
				num2 = 0;
			}
			bool moving2 = (byte)num2 != 0;
			Animate(aiming: false, moving2);
		}

		private void UpdateTeleport(PlayerAvatar target)
		{
			//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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: 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)
			//IL_00d1: 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)
			if (_kind != EnemyKind.Teleporter || (Object)(object)target == (Object)null || (Object)(object)_agent == (Object)null || !((Behaviour)_agent).isActiveAndEnabled || !_agent.isOnNavMesh)
			{
				return;
			}
			_teleportTimer -= Time.deltaTime;
			if (!(_teleportTimer > 0f))
			{
				_teleportTimer = Random.Range(4.5f, 8f);
				Vector2 insideUnitCircle = Random.insideUnitCircle;
				Vector2 val = ((Vector2)(ref insideUnitCircle)).normalized * Random.Range(5.5f, 10f);
				NavMeshHit val2 = default(NavMeshHit);
				if (NavMesh.SamplePosition(((Component)target).transform.position + new Vector3(val.x, 0f, val.y), ref val2, 4f, -1))
				{
					_agent.Warp(((NavMeshHit)(ref val2)).position);
					ArenaAssets.Play("crystal_hit", ((NavMeshHit)(ref val2)).position, 0.55f);
				}
			}
		}

		public void Hurt(int damage, Vector3 direction)
		{
			//IL_004a: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			if (Dead || _remote)
			{
				return;
			}
			_health -= Mathf.Max(1, damage);
			if (_health > 0)
			{
				ArenaAssets.Play("crystal_hit", ((Component)this).transform.position, 0.8f);
				return;
			}
			Die(direction);
			ArenaRuntime instance = ArenaRuntime.Instance;
			if ((Object)(object)instance != (Object)null)
			{
				instance.BroadcastEnemyDeath(this, direction);
			}
		}

		private void Die(Vector3 direction)
		{
			//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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			Dead = true;
			_dying = true;
			_deathTimer = 0f;
			_deathStartScale = ((Component)this).transform.localScale;
			if ((Object)(object)_agent != (Object)null)
			{
				if (((Behaviour)_agent).isActiveAndEnabled && _agent.isOnNavMesh)
				{
					_agent.isStopped = true;
					_agent.ResetPath();
				}
				((Behaviour)_agent).enabled = false;
			}
			if ((Object)(object)_hitCollider != (Object)null)
			{
				((Collider)_hitCollider).enabled = false;
			}
			TriggerAnimator("death");
			ArenaAssets.Play("crystal_death", ((Component)this).transform.position);
			ArenaAssets.Play("crystal_crush", ((Component)this).transform.position, 0.7f);
			Vector3 val = direction.WithY(0f);
			if (((Vector3)(ref val)).sqrMagnitude > 0.001f)
			{
				Transform transform = ((Component)this).transform;
				transform.position += ((Vector3)(ref val)).normalized * 0.35f;
			}
			if (_renderers == null)
			{
				return;
			}
			for (int i = 0; i < _renderers.Length; i++)
			{
				if ((Object)(object)_renderers[i] != (Object)null)
				{
					_renderers[i].sharedMaterial = _deadMaterial;
				}
			}
		}

		private bool EnsureAgentOnNavMesh()
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_agent != (Object)null && ((Behaviour)_agent).isActiveAndEnabled && _agent.isOnNavMesh)
			{
				return true;
			}
			_reseatCooldown -= Time.deltaTime;
			if (_reseatCooldown > 0f)
			{
				return false;
			}
			_reseatCooldown = 0.5f;
			return ConfigureAgent(((Component)this).transform.position);
		}

		private void MoveToward(Vector3 destination)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Invalid comparison between Unknown and I4
			//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_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_agent == (Object)null || !((Behaviour)_agent).isActiveAndEnabled || !_agent.isOnNavMesh)
			{
				return;
			}
			if (_path == null)
			{
				_path = new NavMeshPath();
			}
			NavMeshHit val = default(NavMeshHit);
			if (!NavMesh.SamplePosition(destination, ref val, 2.5f, -1))
			{
				return;
			}
			Vector3 position = ((NavMeshHit)(ref val)).position;
			_agent.speed = 2.85f;
			_agent.acceleration = 24f;
			_agent.angularSpeed = 720f;
			_agent.isStopped = false;
			_pathRefreshTimer -= Time.deltaTime;
			if (_pathRefreshTimer <= 0f || !_agent.hasPath || Vector3.Distance(_agent.destination, position) > 1f)
			{
				if (_agent.CalculatePath(position, _path) && (int)_path.status != 2)
				{
					_agent.SetPath(_path);
				}
				_pathRefreshTimer = 0.18f;
			}
			if (Vector3.Distance(((Component)this).transform.position, _lastPosition) < 0.01f * _agent.speed * Time.deltaTime)
			{
				_stuckTimer += Time.deltaTime;
			}
			else
			{
				_stuckTimer = 0f;
			}
			if (_stuckTimer > 1.5f)
			{
				_stuckTimer = 0f;
				NavMeshHit val2 = default(NavMeshHit);
				if (NavMesh.SamplePosition(((Component)this).transform.position, ref val2, 4f, -1))
				{
					_agent.Warp(((NavMeshHit)(ref val2)).position);
				}
			}
			_lastPosition = ((Component)this).transform.position;
		}

		private void StrafeAround(PlayerAvatar target)
		{
			//IL_008a: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: 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_00d1: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: 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_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)target == (Object)null || (Object)(object)_agent == (Object)null || !((Behaviour)_agent).isActiveAndEnabled || !_agent.isOnNavMesh)
			{
				return;
			}
			_strafeTimer -= Time.deltaTime;
			if (_strafeTimer <= 0f)
			{
				_strafeTimer = Random.Range(1.4f, 2.6f);
				_strafeSign = ((Random.value < 0.5f) ? (-1f) : 1f);
			}
			Vector3 val = (((Component)target).transform.position - ((Component)this).transform.position).WithY(0f);
			if (((Vector3)(ref val)).sqrMagnitude < 0.001f)
			{
				return;
			}
			Vector3 val2 = Vector3.Cross(Vector3.up, ((Vector3)(ref val)).normalized);
			NavMeshHit val3 = default(NavMeshHit);
			if (NavMesh.SamplePosition(((Component)this).transform.position + val2 * _strafeSign * 2.5f, ref val3, 1.5f, -1))
			{
				_agent.isStopped = false;
				_agent.speed = 1.85f;
				if (_pathRefreshTimer <= 0f || Vector3.Distance(_agent.destination, ((NavMeshHit)(ref val3)).position) > 0.5f)
				{
					_agent.SetDestination(((NavMeshHit)(ref val3)).position);
					_pathRefreshTimer = 0.2f;
				}
			}
		}

		private void Patrol()
		{
			//IL_007b: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_agent == (Object)null) && ((Behaviour)_agent).isActiveAndEnabled && _agent.isOnNavMesh)
			{
				_agent.speed = 1.4f;
				_agent.angularSpeed = 360f;
				_agent.isStopped = false;
				NavMeshHit val = default(NavMeshHit);
				if ((!_hasPatrolTarget || Vector3.Distance(((Component)this).transform.position, _patrolTarget) < 1.2f) && NavMesh.SamplePosition(_spawnPoint + new Vector3(Random.Range(-4.5f, 4.5f), 0f, Random.Range(-4.5f, 4.5f)), ref val, 2f, -1))
				{
					_patrolTarget = ((NavMeshHit)(ref val)).position;
					_hasPatrolTarget = true;
					_agent.SetDestination(_patrolTarget);
				}
				FaceMovementDirection();
			}
		}

		private void TouchPlayer(PlayerAvatar target)
		{
			//IL_0056: 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)
			if (!((Object)(object)target == (Object)null) && !((Object)(object)target.playerHealth == (Object)null) && !ArenaAccess.GetIsDisabled(target) && !ArenaAccess.GetDeadSet(target))
			{
				int num = ((EmpressSuperHotArenaPlugin.Settings != null) ? Mathf.Max(1, EmpressSuperHotArenaPlugin.Settings.EnemyTouchDamage.Value) : 10);
				target.playerHealth.HurtOther(num, ((Component)target).transform.position, false, -1, false);
				Hurt(999, ((Component)this).transform.forward);
			}
		}

		private void FaceMovementDirection()
		{
			//IL_002f: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: 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_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_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_agent == (Object)null) && ((Behaviour)_agent).isActiveAndEnabled && _agent.isOnNavMesh)
			{
				Vector3 val = _agent.desiredVelocity.WithY(0f);
				if (((Vector3)(ref val)).sqrMagnitude < 0.01f && _agent.hasPath)
				{
					val = (_agent.steeringTarget - ((Component)this).transform.position).WithY(0f);
				}
				if (!(((Vector3)(ref val)).sqrMagnitude < 0.01f))
				{
					Quaternion val2 = Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up);
					((Component)this).transform.rotation = Quaternion.RotateTowards(((Component)this).transform.rotation, val2, 360f * Time.deltaTime);
				}
			}
		}

		private PlayerAvatar FindClosestTarget(float range)
		{
			//IL_0083: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			List<PlayerAvatar> list = new List<PlayerAvatar>();
			foreach (PlayerAvatar item in SemiFunc.PlayerGetList())
			{
				if (!((Object)(object)item == (Object)null) && !ArenaAccess.GetIsDisabled(item) && !ArenaAccess.GetDeadSet(item))
				{
					list.Add(item);
				}
			}
			if (list.Count == 0)
			{
				return null;
			}
			PlayerAvatar val = list[Mathf.Abs(Id) % list.Count];
			if (Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position) <= range)
			{
				return val;
			}
			PlayerAvatar result = null;
			float num = range;
			for (int i = 0; i < list.Count; i++)
			{
				float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)list[i]).transform.position);
				if (num2 < num)
				{
					result = list[i];
					num = num2;
				}
			}
			return result;
		}

		private bool ConfigureAgent(Vector3 anchor)
		{
			//IL_0000: 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_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Expected O, but got Unknown
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			if (!TryFindNearestNavMeshPoint(anchor, out var hit))
			{
				return false;
			}
			_agent = ((Component)this).GetComponent<NavMeshAgent>();
			if ((Object)(object)_agent == (Object)null)
			{
				_agent = ((Component)this).gameObject.AddComponent<NavMeshAgent>();
			}
			float num = ((_kind == EnemyKind.Boss) ? 3f : 1f);
			float speed = ((_kind == EnemyKind.Boss) ? 1.6f : 2.4f);
			float num2 = ((_kind == EnemyKind.Boss) ? 3.4f : 1.6f);
			_agent.speed = speed;
			_agent.acceleration = 24f;
			_agent.angularSpeed = 480f;
			_agent.stoppingDistance = Mathf.Max(0.4f, num2 - 0.6f);
			_agent.radius = 0.45f * num;
			_agent.height = 2.05f * num;
			_agent.baseOffset = 0f;
			_agent.updatePosition = true;
			_agent.updateRotation = false;
			_agent.updateUpAxis = false;
			_agent.autoBraking = true;
			_agent.autoRepath = true;
			_agent.autoTraverseOffMeshLink = true;
			_agent.obstacleAvoidanceType = (ObstacleAvoidanceType)4;
			_agent.avoidancePriority = 50 + Id % 10;
			((Component)this).transform.position = ((NavMeshHit)(ref hit)).position;
			if (!((Behaviour)_agent).enabled)
			{
				((Behaviour)_agent).enabled = true;
			}
			if (!_agent.Warp(((NavMeshHit)(ref hit)).position))
			{
				return false;
			}
			if (!_agent.isOnNavMesh)
			{
				return false;
			}
			_path = new NavMeshPath();
			_pathRefreshTimer = 0f;
			_lastPosition = ((Component)this).transform.position;
			return true;
		}

		private void PreparePrefabVisual()
		{
			int layer = LayerMask.NameToLayer("Enemy");
			SetLayerRecursive(((Component)this).gameObject, layer);
			Rigidbody val = ((Component)this).GetComponent<Rigidbody>();
			if ((Object)(object)val == (Object)null)
			{
				val = ((Component)this).gameObject.AddComponent<Rigidbody>();
			}
			val.isKinematic = true;
			val.useGravity = false;
			EnsureHitCollider();
			_animator = ((Component)this).GetComponentInChildren<Animator>(true);
			if ((Object)(object)_animator != (Object)null)
			{
				((Behaviour)_animator).enabled = true;
				_animator.speed = 1f;
				_animator.applyRootMotion = false;
				_animator.cullingMode = (AnimatorCullingMode)0;
				_animator.updateMode = (AnimatorUpdateMode)0;
				_animator.Rebind();
				_animator.Update(0f);
			}
			_muzzle = FindChildByName(((Component)this).transform, "Muzzle");
			_renderers = ((Component)this).GetComponentsInChildren<Renderer>(true);
			for (int i = 0; i < _renderers.Length; i++)
			{
				if ((Object)(object)_renderers[i] != (Object)null)
				{
					_renderers[i].enabled = true;
				}
			}
		}

		private void BuildProceduralVisual()
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: 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_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: 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_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: 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_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Expected O, but got Unknown
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			EnsureMaterials();
			int layer = LayerMask.NameToLayer("Enemy");
			SetLayerRecursive(((Component)this).gameObject, layer);
			Rigidbody obj = ((Component)this).gameObject.AddComponent<Rigidbody>();
			obj.isKinematic = true;
			obj.useGravity = false;
			EnsureHitCollider();
			AddPart("Body", (PrimitiveType)1, new Vector3(0f, 1f, 0f), new Vector3(0.6f, 0.95f, 0.6f), _bodyMaterial, layer);
			AddPart("Head", (PrimitiveType)0, new Vector3(0f, 1.7f, 0f), new Vector3(0.46f, 0.46f, 0.46f), _bodyMaterial, layer);
			AddPart("Visor", (PrimitiveType)3, new Vector3(0f, 1.72f, 0.22f), new Vector3(0.34f, 0.1f, 0.05f), _faceMaterial, layer);
			AddPart("Chest Light", (PrimitiveType)3, new Vector3(0f, 1.15f, 0.28f), new Vector3(0.22f, 0.22f, 0.04f), _accentMaterial, layer);
			AddPart("Left Arm", (PrimitiveType)1, new Vector3(-0.46f, 1.15f, 0.14f), new Vector3(0.2f, 0.6f, 0.2f), _bodyMaterial, layer).transform.localRotation = Quaternion.Euler(72f, 0f, 18f);
			AddPart("Right Arm", (PrimitiveType)1, new Vector3(0.46f, 1.15f, 0.14f), new Vector3(0.2f, 0.6f, 0.2f), _bodyMaterial, layer).transform.localRotation = Quaternion.Euler(72f, 0f, -18f);
			AddPart("Left Leg", (PrimitiveType)1, new Vector3(-0.2f, 0.32f, 0f), new Vector3(0.22f, 0.68f, 0.22f), _bodyMaterial, layer);
			AddPart("Right Leg", (PrimitiveType)1, new Vector3(0.2f, 0.32f, 0f), new Vector3(0.22f, 0.68f, 0.22f), _bodyMaterial, layer);
			GameObject val = new GameObject("Muzzle");
			val.transform.SetParent(((Component)this).transform, false);
			val.transform.localPosition = new Vector3(0.36f, 1.18f, 0.42f);
			val.transform.localRotation = Quaternion.identity;
			_muzzle = val.transform;
			_renderers = ((Component)this).GetComponentsInChildren<Renderer>(true);
		}

		private void EnsureHitCollider()
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			_hitCollider = ((Component)this).GetComponent<CapsuleCollider>();
			if ((Object)(object)_hitCollider == (Object)null)
			{
				_hitCollider = ((Component)this).gameObject.AddComponent<CapsuleCollider>();
			}
			_hitCollider.center = new Vector3(0f, 0.95f, 0f);
			_hitCollider.height = 1.95f;
			_hitCollider.radius = 0.42f;
			((Collider)_hitCollider).isTrigger = false;
			((Collider)_hitCollider).enabled = true;
		}

		private GameObject AddPart(string name, PrimitiveType type, Vector3 localPosition, Vector3 localScale, Material material, int layer)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.CreatePrimitive(type);
			((Object)val).name = name;
			val.transform.SetParent(((Component)this).transform, false);
			val.transform.localPosition = localPosition;
			val.transform.localScale = localScale;
			if (layer >= 0)
			{
				val.layer = layer;
			}
			Collider component = val.GetComponent<Collider>();
			if ((Object)(object)component != (Object)null)
			{
				Object.Destroy((Object)(object)component);
			}
			Renderer component2 = val.GetComponent<Renderer>();
			if ((Object)(object)component2 != (Object)null && (Object)(object)material != (Object)null)
			{
				component2.sharedMaterial = material;
			}
			return val;
		}

		private void Animate(bool aiming, bool moving)
		{
			LastAiming = aiming;
			LastMoving = moving;
			if (!((Object)(object)_animator == (Object)null))
			{
				if (aiming && !_wasAiming)
				{
					TriggerAnimator("EnterAttack");
				}
				_wasAiming = aiming;
				SetAnimatorBool("InstantSwitchToAim", aiming);
				SetAnimatorFloat("Velocity", moving ? 1f : 0f);
				SetAnimatorFloat("Speed", moving ? 1.6f : 0f);
				SetAnimatorFloat("Direction", 0f);
				SetAnimatorFloat("Rotation", 0f);
				SetAnimatorFloat("AimMoveAngle", 0f);
				SetAnimatorFloat("ShootSpeedup", Mathf.Lerp(1f, 1.4f, Mathf.Clamp01(Time.timeScale)));
			}
		}

		private void SetAnimatorFloat(string name, float value)
		{
			if ((Object)(object)_animator != (Object)null && HasParameter(name, (AnimatorControllerParameterType)1))
			{
				_animator.SetFloat(name, value);
			}
		}

		private void SetAnimatorBool(string name, bool value)
		{
			if ((Object)(object)_animator != (Object)null && HasParameter(name, (AnimatorControllerParameterType)4))
			{
				_animator.SetBool(name, value);
			}
		}

		private void TriggerAnimator(string name)
		{
			if ((Object)(object)_animator != (Object)null && HasParameter(name, (AnimatorControllerParameterType)9))
			{
				_animator.SetTrigger(name);
			}
		}

		private bool HasParameter(string name, AnimatorControllerParameterType type)
		{
			//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)
			if ((Object)(object)_animator == (Object)null || (Object)(object)_animator.runtimeAnimatorController == (Object)null)
			{
				return false;
			}
			AnimatorControllerParameter[] parameters = _animator.parameters;
			foreach (AnimatorControllerParameter val in parameters)
			{
				if (val.name == name && val.type == type)
				{
					return true;
				}
			}
			return false;
		}

		private static Transform FindChildByName(Transform root, string name)
		{
			Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				if (((Object)componentsInChildren[i]).name == name)
				{
					return componentsInChildren[i];
				}
			}
			return null;
		}

		private static void SetLayerRecursive(GameObject root, int layer)
		{
			if (layer >= 0)
			{
				Transform[] componentsInChildren = root.GetComponentsInChildren<Transform>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					((Component)componentsInChildren[i]).gameObject.layer = layer;
				}
			}
		}

		private static bool TryFindNearestNavMeshPoint(Vector3 position, out NavMeshHit hit)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			float[] array = new float[5] { 4f, 8f, 16f, 32f, 64f };
			for (int i = 0; i < array.Length; i++)
			{
				if (NavMesh.SamplePosition(position, ref hit, array[i], -1))
				{
					return true;
				}
			}
			hit = default(NavMeshHit);
			return false;
		}

		private static void EnsureMaterials()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Expected O, but got Unknown
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: 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_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Expected O, but got Unknown
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Expected O, but got Unknown
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_bodyMaterial != (Object)null))
			{
				Shader obj = Shader.Find("Standard");
				_bodyMaterial = new Material(obj);
				_bodyMaterial.color = new Color(0.04f, 0.05f, 0.08f);
				if (_bodyMaterial.HasProperty("_Metallic"))
				{
					_bodyMaterial.SetFloat("_Metallic", 0.6f);
				}
				if (_bodyMaterial.HasProperty("_Glossiness"))
				{
					_bodyMaterial.SetFloat("_Glossiness", 0.65f);
				}
				if (_bodyMaterial.HasProperty("_EmissionColor"))
				{
					_bodyMaterial.EnableKeyword("_EMISSION");
					_bodyMaterial.SetColor("_EmissionColor", new Color(0.05f, 0.18f, 0.32f) * 0.8f);
				}
				_accentMaterial = new Material(obj);
				_accentMaterial.color = new Color(1f, 0.18f, 0.35f);
				if (_accentMaterial.HasProperty("_EmissionColor"))
				{
					_accentMaterial.EnableKeyword("_EMISSION");
					_accentMaterial.SetColor("_EmissionColor", new Color(1f, 0.3f, 0.5f) * 3.2f);
				}
				_faceMaterial = new Material(obj);
				_faceMaterial.color = new Color(0.12f, 0.85f, 1f);
				if (_faceMaterial.HasProperty("_EmissionColor"))
				{
					_faceMaterial.EnableKeyword("_EMISSION");
					_faceMaterial.SetColor("_EmissionColor", new Color(0.32f, 0.95f, 1f) * 3.6f);
				}
				_deadMaterial = new Material(obj);
				_deadMaterial.color = Color.black;
			}
		}
	}
	internal static class VectorExtensions
	{
		public static Vector3 WithY(this Vector3 value, float y)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			value.y = y;
			return value;
		}
	}
	internal static class ArenaLevelRegistry
	{
		private static readonly FieldRef<LevelContent, Level> LevelContentLevelRef = AccessTools.FieldRefAccess<LevelContent, Level>("_level");

		private static readonly FieldRef<LevelContent, List<GameObject>> LevelContentStartRoomsRef = AccessTools.FieldRefAccess<LevelContent, List<GameObject>>("_startRooms");

		private static readonly FieldRef<LevelContent, List<GameObject>> LevelContentModulesNormal1Ref = AccessTools.FieldRefAccess<LevelContent, List<GameObject>>("_modulesNormal1");

		private static readonly FieldRef<LevelContent, List<GameObject>> LevelContentModulesNormal2Ref = AccessTools.FieldRefAccess<LevelContent, List<GameObject>>("_modulesNormal2");

		private static readonly FieldRef<LevelContent, List<GameObject>> LevelContentModulesNormal3Ref = AccessTools.FieldRefAccess<LevelContent, List<GameObject>>("_modulesNormal3");

		private static readonly FieldRef<LevelContent, List<GameObject>> LevelContentModulesPassage1Ref = AccessTools.FieldRefAccess<LevelContent, List<GameObject>>("_modulesPassage1");

		private static readonly FieldRef<LevelContent, List<GameObject>> LevelContentModulesPassage2Ref = AccessTools.FieldRefAccess<LevelContent, List<GameObject>>("_modulesPassage2");

		private static readonly FieldRef<LevelContent, List<GameObject>> LevelContentModulesPassage3Ref = AccessTools.FieldRefAccess<LevelContent, List<GameObject>>("_modulesPassage3");

		private static readonly FieldRef<LevelContent, List<GameObject>> LevelContentModulesDeadEnd1Ref = AccessTools.FieldRefAccess<LevelContent, List<GameObject>>("_modulesDeadEnd1");

		private static readonly FieldRef<LevelContent, List<GameObject>> LevelContentModulesDeadEnd2Ref = AccessTools.FieldRefAccess<LevelContent, List<GameObject>>("_modulesDeadEnd2");

		private static readonly FieldRef<LevelContent, List<GameObject>> LevelContentModulesDeadEnd3Ref = AccessTools.FieldRefAccess<LevelContent, List<GameObject>>("_modulesDeadEnd3");

		private static readonly FieldRef<LevelContent, List<GameObject>> LevelContentModulesExtraction1Ref = AccessTools.FieldRefAccess<LevelContent, List<GameObject>>("_modulesExtraction1");

		private static readonly FieldRef<LevelContent, List<GameObject>> LevelContentModulesExtraction2Ref = AccessTools.FieldRefAccess<LevelContent, List<GameObject>>("_modulesExtraction2");

		private static readonly FieldRef<LevelContent, List<GameObject>> LevelContentModulesExtraction3Ref = AccessTools.FieldRefAccess<LevelContent, List<GameObject>>("_modulesExtraction3");

		private static readonly FieldRef<LevelContent, GameObject> LevelContentConnectObjectRef = AccessTools.FieldRefAccess<LevelContent, GameObject>("_connectObject");

		private static readonly FieldRef<LevelContent, GameObject> LevelContentBlockObjectRef = AccessTools.FieldRefAccess<LevelContent, GameObject>("_blockObject");

		public static Level RegisterArenaLevel()
		{
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: 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)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			Level val = ScriptableObject.CreateInstance<Level>();
			((Object)val).name = "Level - Empress SuperHot Arena";
			val.NarrativeName = "Empress SuperHot Arena";
			LevelValuables val2 = ScriptableObject.CreateInstance<LevelValuables>();
			((Object)val2).name = "Valuables - Empress SuperHot Arena";
			val2.tiny = new List<PrefabRef>();
			val2.small = new List<PrefabRef>();
			val2.medium = new List<PrefabRef>();
			val2.big = new List<PrefabRef>();
			val2.wide = new List<PrefabRef>();
			val2.tall = new List<PrefabRef>();
			val2.veryTall = new List<PrefabRef>();
			SetLevelField(val, "ModuleAmount", 0);
			SetLevelField(val, "PassageMaxAmount", 0);
			SetLevelField(val, "HasEnemies", false);
			SetLevelField(val, "ValuablePresets", new List<LevelValuables> { val2 });
			SetLevelField(val, "AmbiencePresets", new List<LevelAmbience>());
			SetLevelField(val, "FogColor", (object)new Color(0.015f, 0.03f, 0.06f));
			SetLevelField(val, "FogStartDistance", 5f);
			SetLevelField(val, "FogEndDistance", 70f);
			SetLevelField(val, "AmbientColor", (object)new Color(0.05f, 0.18f, 0.27f));
			SetLevelField(val, "AmbientColorAdaptation", (object)new Color(0.02f, 0.06f, 0.11f));
			SetLevelField(val, "ColorTemperature", -8f);
			SetLevelField(val, "ColorFilter", (object)new Color(0.78f, 0.95f, 1f, 1f));
			SetLevelField(val, "BloomIntensity", 6.5f);
			SetLevelField(val, "BloomThreshold", 0.78f);
			SetLevelField(val, "VignetteColor", (object)new Color(0.01f, 0.03f, 0.06f, 1f));
			SetLevelField(val, "VignetteIntensity", 0.32f);
			SetLevelField(val, "VignetteSmoothness", 0.78f);
			SetLevelField(val, "DiscordIcon", "level");
			EnsureLevelFieldInstance(val, "LoadingGraphic01");
			EnsureLevelFieldInstance(val, "LoadingGraphic02");
			EnsureLevelFieldInstance(val, "LoadingGraphic03");
			EnsureLevelFieldInstance(val, "ConnectObject");
			EnsureLevelFieldInstance(val, "BlockObject");
			LevelContent val3 = ScriptableObject.CreateInstance<LevelContent>();
			((Object)val3).name = "Empress SuperHot Arena Content";
			LevelContentLevelRef.Invoke(val3) = val;
			LevelContentStartRoomsRef.Invoke(val3) = new List<GameObject>();
			LevelContentModulesNormal1Ref.Invoke(val3) = new List<GameObject>();
			LevelContentModulesNormal2Ref.Invoke(val3) = new List<GameObject>();
			LevelContentModulesNormal3Ref.Invoke(val3) = new List<GameObject>();
			LevelContentModulesPassage1Ref.Invoke(val3) = new List<GameObject>();
			LevelContentModulesPassage2Ref.Invoke(val3) = new List<GameObject>();
			LevelContentModulesPassage3Ref.Invoke(val3) = new List<GameObject>();
			LevelContentModulesDeadEnd1Ref.Invoke(val3) = new List<GameObject>();
			LevelContentModulesDeadEnd2Ref.Invoke(val3) = new List<GameObject>();
			LevelContentModulesDeadEnd3Ref.Invoke(val3) = new List<GameObject>();
			LevelContentModulesExtraction1Ref.Invoke(val3) = new List<GameObject>();
			LevelContentModulesExtraction2Ref.Invoke(val3) = new List<GameObject>();
			LevelContentModulesExtraction3Ref.Invoke(val3) = new List<GameObject>();
			LevelContentConnectObjectRef.Invoke(val3) = null;
			LevelContentBlockObjectRef.Invoke(val3) = null;
			Levels.RegisterLevel(val3);
			return val;
		}

		private static void SetLevelField(Level level, string fieldName, object value)
		{
			FieldInfo fieldInfo = AccessTools.Field(typeof(Level), fieldName);
			if (!(fieldInfo == null) && value != null && fieldInfo.FieldType.IsInstanceOfType(value))
			{
				fieldInfo.SetValue(level, value);
			}
		}

		private static void EnsureLevelFieldInstance(Level level, string fieldName)
		{
			FieldInfo fieldInfo = AccessTools.Field(typeof(Level), fieldName);
			if (!(fieldInfo == null) && fieldInfo.FieldType.IsClass && !(fieldInfo.FieldType == typeof(string)) && fieldInfo.GetValue(level) == null)
			{
				object uninitializedObject = FormatterServices.GetUninitializedObject(fieldInfo.FieldType);
				fieldInfo.SetValue(level, uninitializedObject);
			}
		}
	}
	[HarmonyPatch(typeof(RunManager), "SetRunLevel")]
	internal static class ArenaPatchRunManagerSetRunLevel
	{
		private static void Postfix(RunManager __instance)
		{
			if (EmpressSuperHotArenaPlugin.Settings != null && EmpressSuperHotArenaPlugin.Settings.ForceArenaLevel.Value && !((Object)(object)EmpressSuperHotArenaPlugin.ArenaLevel == (Object)null))
			{
				__instance.levelCurrent = EmpressSuperHotArenaPlugin.ArenaLevel;
			}
		}
	}
	[HarmonyPatch(typeof(LevelGenerator), "Generate")]
	internal static class ArenaPatchLevelGeneratorGenerate
	{
		private static bool Prefix(LevelGenerator __instance, ref IEnumerator __result)
		{
			if (!EmpressSuperHotArenaPlugin.IsArenaLevel(Object.op_Implicit((Object)(object)RunManager.instance) ? RunManager.instance.levelCurrent : null))
			{
				return true;
			}
			__result = ArenaRuntime.EnsureHost().GenerateArenaLevel(__instance);
			return false;
		}
	}
	[HarmonyPatch(typeof(LevelPoint), "NavMeshCheck")]
	internal static class ArenaPatchLevelPointNavMeshCheck
	{
		private static bool Prefix(ref IEnumerator __result)
		{
			if (!EmpressSuperHotArenaPlugin.IsArenaLevel(Object.op_Implicit((Object)(object)RunManager.instance) ? RunManager.instance.levelCurrent : null))
			{
				return true;
			}
			__result = ArenaRuntime.EmptyCoroutine();
			return false;
		}
	}
	[HarmonyPatch(typeof(EnvironmentDirector), "Setup")]
	internal static class ArenaPatchEnvironmentDirectorSetup
	{
		private static bool Prefix(EnvironmentDirector __instance)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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_0056: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)LevelGenerator.Instance))
			{
				return true;
			}
			Level level = LevelGenerator.Instance.Level;
			if (!Object.op_Implicit((Object)(object)level) || !EmpressSuperHotArenaPlugin.IsArenaLevel(level))
			{
				return true;
			}
			ArenaAccess.SetEnvironmentFog(__instance, level.FogColor, level.FogStartDistance, level.FogEndDistance);
			ArenaAccess.SetEnvironmentAmbient(__instance, level.AmbientColor, level.AmbientColorAdaptation);
			RenderSettings.fogColor = level.FogColor;
			RenderSettings.fogStartDistance = level.FogStartDistance;
			RenderSettings.fogEndDistance = level.FogEndDistance;
			RenderSettings.ambientLight = level.AmbientColor;
			Camera val = ArenaAccess.GetEnvironmentMainCamera(__instance);
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = Camera.main;
				ArenaAccess.SetEnvironmentMainCamera(__instance, val);
			}
			if (Object.op_Implicit((Object)(object)val))
			{
				val.backgroundColor = RenderSettings.fogColor;
				val.farClipPlane = RenderSettings.fogEndDistance + 4f;
			}
			ArenaAccess.SetEnvironmentDarkAdaptation(__instance, 0.1f);
			ArenaAccess.SetEnvironmentSetupDone(__instance, value: true);
			return false;
		}
	}
	[HarmonyPatch(typeof(LoadingUI), "LevelAnimationStart")]
	internal static class ArenaPatchLoadingUiLevelAnimationStart
	{
		private static void Postfix(LoadingUI __instance)
		{
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			if (EmpressSuperHotArenaPlugin.IsArenaLevel(Object.op_Implicit((Object)(object)LevelGenerator.Instance) ? LevelGenerator.Instance.Level : null))
			{
				if ((Object)(object)__instance.levelNumberText != (Object)null)
				{
					((TMP_Text)__instance.levelNumberText).text = "LEVEL " + ((!((Object)(object)RunManager.instance != (Object)null)) ? 1 : (RunManager.instance.levelsCompleted + 1));
					((Graphic)__instance.levelNumberText).color = new Color(0.36f, 0.94f, 1f);
					((Component)__instance.levelNumberText).gameObject.SetActive(true);
					((TMP_Text)__instance.levelNumberText).transform.SetAsLastSibling();
				}
				if ((Object)(object)__instance.levelNameText != (Object)null)
				{
					((TMP_Text)__instance.levelNameText).text = "Empress SuperHot Arena";
					((Graphic)__instance.levelNameText).color = new Color(1f, 0.4f, 0.55f);
					((Component)__instance.levelNameText).gameObject.SetActive(true);
					((TMP_Text)__instance.levelNameText).transform.SetAsLastSibling();
				}
			}
		}
	}
	[HarmonyPatch(typeof(ItemGun), "Shoot")]
	internal static class ArenaPatchItemGunShoot
	{
		private static void Postfix(ItemGun __instance, bool __result)
		{
			if (__result)
			{
				ArenaRuntime instance = ArenaRuntime.Instance;
				if ((Object)(object)instance != (Object)null && instance.Active)
				{
					instance.HandlePlayerShot(__instance);
				}
			}
		}
	}
	[HarmonyPatch(typeof(ItemManager), "TurnOffIconLights")]
	internal static class ArenaPatchItemManagerTurnOffIconLights
	{
		private static bool Prefix(ItemManager __instance, ref IEnumerator __result)
		{
			if (!EmpressSuperHotArenaPlugin.IsArenaLevel(Object.op_Implicit((Object)(object)RunManager.instance) ? RunManager.instance.levelCurrent : null))
			{
				return true;
			}
			__result = SafeTurnOffIconLights(__instance);
			return false;
		}

		private static IEnumerator SafeTurnOffIconLights(ItemManager itemManager)
		{
			if ((Object)(object)itemManager.itemIconLights == (Object)null)
			{
				yield break;
			}
			if (SemiFunc.RunIsShop() || SemiFunc.MenuLevel())
			{
				itemManager.itemIconLights.SetActive(false);
				yield break;
			}
			while ((Object)(object)LevelGenerator.Instance == (Object)null || !LevelGenerator.Instance.Generated)
			{
				yield return (object)new WaitForSeconds(0.2f);
			}
			while (itemManager.spawnedItems != null)
			{
				itemManager.spawnedItems.RemoveAll((ItemAttributes item) => (Object)(object)item == (Object)null);
				bool flag = false;
				for (int i = 0; i < itemManager.spawnedItems.Count; i++)
				{
					ItemAttributes val = itemManager.spawnedItems[i];
					if ((Object)(object)val != (Object)null && !ArenaAccess.GetItemHasIcon(val))
					{
						flag = true;
						break;
					}
				}
				if (!flag)
				{
					break;
				}
				yield return (object)new WaitForSeconds(0.2f);
			}
			itemManager.itemIconLights.SetActive(false);
		}
	}
	internal sealed class ArenaRuntime : MonoBehaviour
	{
		private const float ArenaWidth = 36f;

		private const float ArenaDepth = 36f;

		private const float ArenaHeight = 8f;

		private const float WallThickness = 0.8f;

		private const float FloorThickness = 0.6f;

		private readonly List<ArenaEnemy> _enemies = new List<ArenaEnemy>();

		private readonly Dictionary<int, ArenaEnemy> _enemyById = new Dictionary<int, ArenaEnemy>();

		private readonly List<Vector3> _enemySpawnAnchors = new List<Vector3>();

		private readonly List<Light> _arenaLights = new List<Light>();

		private readonly ArenaWeaponService _weaponService = new ArenaWeaponService();

		private int _spawnToken;

		private float _transformBroadcastTimer;

		private AudioSource _musicSource;

		private Transform _arenaRoot;

		private Transform _enemyHolder;

		private Vector3 _playerSpawnAnchor;

		private bool _active;

		private bool _cleared;

		private float _exitTimer;

		private int _sceneHandle = -1;

		private LevelGenerator _generator;

		private int _arenaLevelNumber;

		private readonly Dictionary<int, int> _gunAssignments = new Dictionary<int, int>();

		private PhysGrabObject _localGun;

		private float _grabRetryTimer;

		public static ArenaRuntime Instance { get; private set; }

		public bool Active => _active;

		public static ArenaRuntime EnsureHost()
		{
			//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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			if ((Object)(object)Instance != (Object)null)
			{
				return Instance;
			}
			GameObject val = new GameObject("Empress SuperHot Arena Runtime");
			val.transform.parent = null;
			((Object)val).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)val);
			Instance = val.AddComponent<ArenaRuntime>();
			return Instance;
		}

		public static IEnumerator EmptyCoroutine()
		{
			yield break;
		}

		private void Awake()
		{
			Instance = this;
			EnsureMusicSource();
		}

		private void EnsureMusicSource()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			if (!((Object)(object)_musicSource != (Object)null))
			{
				GameObject val = new GameObject("Empress Arena Music");
				val.transform.SetParent(((Component)this).transform, false);
				_musicSource = val.AddComponent<AudioSource>();
				_musicSource.playOnAwake = false;
				_musicSource.loop = true;
				_musicSource.spatialBlend = 0f;
				_musicSource.volume = 0.3f;
				_musicSource.priority = 0;
			}
		}

		private void StartMusic()
		{
			EnsureMusicSource();
			if ((Object)(object)_musicSource == (Object)null)
			{
				return;
			}
			AudioClip val = ArenaAssets.GetMusicClip("UwU") ?? ArenaAssets.GetMusicClip("uwu");
			if (!((Object)(object)val == (Object)null))
			{
				if ((Object)(object)_musicSource.clip != (Object)(object)val)
				{
					_musicSource.clip = val;
				}
				_musicSource.volume = 0.3f;
				if (!_musicSource.isPlaying)
				{
					_musicSource.Play();
				}
			}
		}

		private void StopMusic()
		{
			if ((Object)(object)_musicSource != (Object)null && _musicSource.isPlaying)
			{
				_musicSource.Stop();
			}
		}

		private void Update()
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Invalid comparison between Unknown and I4
			HandleSceneTransition();
			if (!_active)
			{
				return;
			}
			if (!EmpressSuperHotArenaPlugin.IsArenaLevel(Object.op_Implicit((Object)(object)RunManager.instance) ? RunManager.instance.levelCurrent : null))
			{
				Deactivate();
				return;
			}
			if ((Object)(object)LevelGenerator.Instance != (Object)null && LevelGenerator.Instance.Generated && (Object)(object)GameDirector.instance != (Object)null && (int)GameDirector.instance.currentState == 2 && IsLoadingFinished() && ArenaAccess.GetAllPlayersReady(LevelGenerator.Instance))
			{
				UpdateEnemies();
				_weaponService.Update();
				MaybeBroadcastTransforms();
				TryGrabLocalGun();
			}
			CheckClear();
			AdvanceAfterClear();
		}

		private void LateUpdate()
		{
			if (_active && Time.timeScale != 1f)
			{
				Time.timeScale = 1f;
			}
		}

		private bool IsLoadingFinished()
		{
			LoadingUI instance = LoadingUI.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return true;
			}
			if (((Component)instance).gameObject.activeInHierarchy)
			{
				return false;
			}
			return ArenaAccess.GetLevelAnimationCompleted(instance);
		}

		public void HandlePlayerShot(ItemGun gun)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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_0056: 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)
			//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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: 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_0105: 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_013f: 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_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: 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)
			if (!_active || (Object)(object)gun == (Object)null)
			{
				return;
			}
			Transform obj = (((Object)(object)gun.gunMuzzle != (Object)null) ? gun.gunMuzzle : ((Component)gun).transform);
			Vector3 position = obj.position;
			Vector3 val = obj.forward;
			if (((Vector3)(ref val)).sqrMagnitude <= 0.001f)
			{
				val = Vector3.forward;
			}
			val = ((Vector3)(ref val)).normalized;
			float num = Mathf.Max(10f, gun.gunRange);
			int num2 = LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct());
			float num3 = num;
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(position, val, ref val2, num, num2, (QueryTriggerInteraction)1))
			{
				num3 = ((RaycastHit)(ref val2)).distance;
			}
			int num4 = LayerMask.NameToLayer("Enemy");
			int num5 = ((num4 >= 0) ? (1 << num4) : 0);
			ArenaEnemy arenaEnemy = null;
			float num6 = num3;
			RaycastHit val3 = default(RaycastHit);
			if (num5 != 0 && Physics.Raycast(position, val, ref val3, num3, num5, (QueryTriggerInteraction)1))
			{
				ArenaEnemy componentInParent = ((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent<ArenaEnemy>();
				if ((Object)(object)componentInParent != (Object)null && !componentInParent.Dead)
				{
					arenaEnemy = componentInParent;
					num6 = ((RaycastHit)(ref val3)).distance;
				}
			}
			Vector3 val4 = position + val * (((Object)(object)arenaEnemy != (Object)null) ? num6 : num3);
			if ((Object)(object)arenaEnemy != (Object)null)
			{
				if (SemiFunc.IsMasterClientOrSingleplayer())
				{
					arenaEnemy.Hurt(999, val);
				}
				else
				{
					RequestEnemyHit(arenaEnemy.Id, val);
				}
			}
			Vector3 val5 = val4 - position;
			ArenaBullet.FireTracer(position, ((Vector3)(ref val5)).normalized, val4);
		}

		public IEnumerator GenerateArenaLevel(LevelGenerator generator)
		{
			_generator = generator;
			EmpressSuperHotArenaPlugin.EnsurePhotonEventHooked();
			yield return (object)new WaitForSeconds(0.2f);
			if (!SemiFunc.IsMultiplayer())
			{
				ArenaAccess.SetAllPlayersReady(generator, value: true);
			}
			while (!ArenaAccess.GetAllPlayersReady(generator))
			{
				generator.State = (LevelState)1;
				yield return (object)new WaitForSeconds(0.1f);
			}
			yield return (object)new WaitForSeconds(0.2f);
			generator.Level = RunManager.instance.levelCurrent;
			ArenaAccess.SetLevelPrevious(RunManager.instance, generator.Level);
			generator.Generated = false;
			ArenaAccess.SetEnemyReady(generator, value: true);
			ArenaAccess.SetModulesSpawned(generator, 0);
			ArenaAccess.SetPlayerSpawnedCount(generator, 0);
			generator.LevelPathPoints = new List<LevelPoint>();
			generator.LevelPathTruck = null;
			if (Object.op_Implicit((Object)(object)ValuableDirector.instance))
			{
				ArenaAccess.SetValuableSetupComplete(ValuableDirector.instance, value: true);
				ArenaAccess.SetValuableValuablesSpawned(ValuableDirector.instance, value: true);
			}
			if (Object.op_Implicit((Object)(object)RoundDirector.instance))
			{
				ArenaAccess.ResetRoundExtraction(RoundDirector.instance);
			}
			generator.State = (LevelState)3;
			BuildArena(generator);
			ArenaRuntime arenaRuntime = this;
			Scene activeScene = SceneManager.GetActiveScene();
			arenaRuntime._sceneHandle = ((Scene)(ref activeScene)).handle;
			yield return (object)new WaitForSeconds(0.2f);
			if (Object.op_Implicit((Object)(object)EnvironmentDirector.Instance))
			{
				EnvironmentDirector.Instance.Setup();
			}
			if (Object.op_Implicit((Object)(object)PostProcessing.Instance))
			{
				PostProcessing.Instance.Setup();
			}
			if (Object.op_Implicit((Object)(object)LevelMusic.instance))
			{
				LevelMusic.instance.Setup();
			}
			if (Object.op_Implicit((Object)(object)ConstantMusic.instance))
			{
				ConstantMusic.instance.Setup();
			}
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				NavMeshSurface component = ((Component)generator).GetComponent<NavMeshSurface>();
				if ((Object)(object)component != (Object)null)
				{
					component.collectObjects = (CollectObjects)0;
					component.useGeometry = (NavMeshCollectGeometry)1;
					component.layerMask = LayerMask.op_Implicit(-1);
					component.defaultArea = 0;
				}
				generator.NavMeshSetup();
				yield return null;
				while ((Object)(object)GameDirector.instance == (Object)null || GameDirector.instance.PlayerList.Count == 0)
				{
					generator.State = (L