Decompiled source of Master Hand Boss v1.0.0

BepInEx\plugins\Empress-MasterHand\EmpressFinalHand.dll

Decompiled 11 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.Networking;
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("EmpressFinalHand")]
[assembly: AssemblyTitle("EmpressFinalHand")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Empress.REPO.FinalHand
{
	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 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 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 Final Hand";
			val.NarrativeName = "Empress Final Hand";
			LevelValuables val2 = ScriptableObject.CreateInstance<LevelValuables>();
			((Object)val2).name = "Valuables - Empress Final Hand";
			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 Final Hand 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 (EmpressFinalHandPlugin.Settings != null && EmpressFinalHandPlugin.Settings.ForceArenaLevel.Value && !((Object)(object)EmpressFinalHandPlugin.ArenaLevel == (Object)null))
			{
				__instance.levelCurrent = EmpressFinalHandPlugin.ArenaLevel;
			}
		}
	}
	[HarmonyPatch(typeof(LevelGenerator), "Generate")]
	internal static class ArenaPatchLevelGeneratorGenerate
	{
		private static bool Prefix(LevelGenerator __instance, ref IEnumerator __result)
		{
			if (!EmpressFinalHandPlugin.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 (!EmpressFinalHandPlugin.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) || !EmpressFinalHandPlugin.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_00e7: 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)
			if (!EmpressFinalHandPlugin.IsArenaLevel(Object.op_Implicit((Object)(object)LevelGenerator.Instance) ? LevelGenerator.Instance.Level : null))
			{
				FinalHandLoadingScreen.Hide(__instance);
				return;
			}
			FinalHandLoadingScreen.Show(__instance);
			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 Final Hand";
				((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(LoadingUI), "StopLoading")]
	internal static class ArenaPatchLoadingUiStopLoading
	{
		private static void Prefix(LoadingUI __instance)
		{
			FinalHandLoadingScreen.Hide(__instance);
		}
	}
	[HarmonyPatch(typeof(LoadingUI), "PlayTurn")]
	internal static class ArenaPatchLoadingUiPlayTurn
	{
		[HarmonyPriority(800)]
		private static bool Prefix()
		{
			return !FinalHandLoadingScreen.OwnsCurrentLoading();
		}
	}
	[HarmonyPatch(typeof(LoadingUI), "PlayRevUp")]
	internal static class ArenaPatchLoadingUiPlayRevUp
	{
		[HarmonyPriority(800)]
		private static bool Prefix()
		{
			return !FinalHandLoadingScreen.OwnsCurrentLoading();
		}
	}
	[HarmonyPatch(typeof(LoadingUI), "PlayCrash")]
	internal static class ArenaPatchLoadingUiPlayCrash
	{
		[HarmonyPriority(800)]
		private static bool Prefix()
		{
			return !FinalHandLoadingScreen.OwnsCurrentLoading();
		}
	}
	[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 (!EmpressFinalHandPlugin.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 num = 0; num < itemManager.spawnedItems.Count; num++)
				{
					ItemAttributes val = itemManager.spawnedItems[num];
					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 PlatformWidth = 34f;

		private const float PlatformDepth = 26f;

		private const float PlatformThickness = 1.2f;

		private const float DeathPlaneY = -8f;

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

		private readonly ArenaWeaponService _weaponService = new ArenaWeaponService();

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

		private AudioSource _musicSource;

		private Transform _arenaRoot;

		private Transform _bossHolder;

		private HandBoss _boss;

		private Vector3 _platformCenter;

		private bool _active;

		private bool _won;

		private float _exitTimer;

		private float _bossBroadcastTimer;

		private int _sceneHandle = -1;

		private LevelGenerator _generator;

		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 Final Hand 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 Final Hand 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 musicClip = HandAudio.MusicClip;
			if (!((Object)(object)musicClip == (Object)null))
			{
				if ((Object)(object)_musicSource.clip != (Object)(object)musicClip)
				{
					_musicSource.clip = musicClip;
				}
				HandAudio.ConfigureMusicSource(_musicSource);
				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 (!EmpressFinalHandPlugin.IsArenaLevel(Object.op_Implicit((Object)(object)RunManager.instance) ? RunManager.instance.levelCurrent : null))
			{
				Deactivate();
			}
			else
			{
				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))
				{
					return;
				}
				float deltaTime = Time.deltaTime;
				bool flag = SemiFunc.IsMasterClientOrSingleplayer();
				if (_boss != null)
				{
					if (flag)
					{
						_boss.HostTick(deltaTime, PlayablePlayers());
						BroadcastBossState(deltaTime);
					}
					else
					{
						_boss.ClientTick(deltaTime);
					}
				}
				_weaponService.Update();
				TryGrabLocalGun();
				KeepOnPlatform();
				RefillLocalEnergy();
				StartMusic();
				if (flag)
				{
					CheckWin();
					AdvanceAfterWin(deltaTime);
				}
			}
		}

		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_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: 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_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_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			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(40f, 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);
			HandWeakSpot handWeakSpot = null;
			float num6 = num3;
			RaycastHit val3 = default(RaycastHit);
			if (num5 != 0 && Physics.Raycast(position, val, ref val3, num3 + 200f, num5, (QueryTriggerInteraction)1))
			{
				HandWeakSpot componentInParent = ((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent<HandWeakSpot>();
				if ((Object)(object)componentInParent != (Object)null && !componentInParent.Destroyed)
				{
					handWeakSpot = componentInParent;
					num6 = ((RaycastHit)(ref val3)).distance;
				}
			}
			Vector3 val4 = position + val * num6;
			if ((Object)(object)handWeakSpot != (Object)null)
			{
				if (SemiFunc.IsMasterClientOrSingleplayer())
				{
					if (_boss != null)
					{
						_boss.RegisterHit(handWeakSpot.Index);
					}
				}
				else
				{
					EmpressFinalHandPlugin.RaiseBossHit(handWeakSpot.Index);
				}
			}
			Vector3 val5 = val4 - position;
			ArenaBullet.FireTracer(position, ((Vector3)(ref val5)).normalized, val4);
		}

		public IEnumerator GenerateArenaLevel(LevelGenerator generator)
		{
			_generator = generator;
			EmpressFinalHandPlugin.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 = (LevelState)12;
					yield return (object)new WaitForSeconds(0.1f);
				}
				generator.PlayerSpawn();
				yield return null;
				while (ArenaAccess.GetPlayerSpawnedCount(generator) < GameDirector.instance.PlayerList.Count)
				{
					generator.State = (LevelState)13;
					yield return (object)new WaitForSeconds(0.1f);
				}
				if (SemiFunc.IsMultiplayer())
				{
					generator.PhotonView.RPC("GenerateDone", (RpcTarget)3, Array.Empty<object>());
				}
				else
				{
					ArenaAccess.GenerateDone(generator);
				}
			}
			else
			{
				while (!generator.Generated)
				{
					yield return (object)new WaitForSeconds(0.1f);
				}
			}
			yield return (object)new WaitForSeconds(0.4f);
			Activate();
		}

		private void Activate()
		{
			_active = true;
			_won = false;
			_exitTimer = 0f;
			_weaponService.Activate();
			StartMusic();
			SpawnBoss();
		}

		private void Deactivate()
		{
			if (_active)
			{
				_active = false;
				_won = false;
				_exitTimer = 0f;
				_weaponService.Reset();
				_gunAssignments.Clear();
				_localGun = null;
				if (_boss != null)
				{
					_boss.Dispose();
				}
				_boss = null;
				StopMusic();
			}
		}

		private void HandleSceneTransition()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			int handle = ((Scene)(ref activeScene)).handle;
			if (handle != _sceneHandle)
			{
				_sceneHandle = handle;
				_arenaRoot = null;
				_bossHolder = null;
				_generator = null;
				_active = false;
				_won = false;
				_exitTimer = 0f;
				_spawnLocations.Clear();
				_weaponService.Reset();
				_gunAssignments.Clear();
				_localGun = null;
				if (_boss != null)
				{
					_boss.Dispose();
				}
				_boss = null;
				StopMusic();
			}
		}

		private void SpawnBoss()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if (_boss == null && !((Object)(object)_bossHolder == (Object)null))
			{
				_boss = HandBoss.Create(_bossHolder, _platformCenter, EmpressFinalHandPlugin.Settings.WeakSpotHealth.Value);
			}
		}

		private void BroadcastBossState(float dt)
		{
			if (SemiFunc.IsMultiplayer() && _boss != null)
			{
				_bossBroadcastTimer -= dt;
				if (!(_bossBroadcastTimer > 0f))
				{
					_bossBroadcastTimer = 0.08f;
					EmpressFinalHandPlugin.RaiseBossState(_boss.GetState());
				}
			}
		}

		internal void ReceiveBossState(object[] data)
		{
			if (!SemiFunc.IsMasterClientOrSingleplayer() && _boss != null)
			{
				_boss.ApplyState(data);
			}
		}

		internal void ReceiveBossHit(int index)
		{
			if (SemiFunc.IsMasterClientOrSingleplayer() && _boss != null)
			{
				_boss.RegisterHit(index);
			}
		}

		private void CheckWin()
		{
			if (!_won && _boss != null && _boss.DeathComplete)
			{
				_won = true;
				_exitTimer = Mathf.Max(1f, EmpressFinalHandPlugin.Settings.ExitDelaySeconds.Value);
				AwardVictory();
				EmpressFinalHandPlugin.Log.LogInfo((object)"Empress Final Hand boss destroyed. Transitioning shortly.");
			}
		}

		private void AwardVictory()
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			int num = Random.Range(40, 51);
			SemiFunc.StatSetRunCurrency(SemiFunc.StatGetRunCurrency() + num);
			SemiFunc.StatSetRunTotalHaul(SemiFunc.StatGetRunTotalHaul() + num);
			if ((Object)(object)CurrencyUI.instance != (Object)null)
			{
				CurrencyUI.instance.FetchCurrency();
			}
			SemiFunc.UIFocusText("THE HAND IS DESTROYED\nTeam earns $" + num + "K", new Color(1f, 0.4f, 0.5f), Color.white, 5f);
		}

		private void AdvanceAfterWin(float dt)
		{
			if (!_won || _exitTimer > 900f)
			{
				return;
			}
			_exitTimer -= dt;
			if (!(_exitTimer > 0f))
			{
				_exitTimer = 999f;
				Time.timeScale = 1f;
				if ((Object)(object)RunManager.instance != (Object)null && EmpressFinalHandPlugin.IsArenaLevel(RunManager.instance.levelCurrent))
				{
					RunManager.instance.ChangeLevel(true, false, (ChangeLevelType)0);
				}
			}
		}

		private void KeepOnPlatform()
		{
			//IL_0016: 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_0043: 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_0052: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			PlayerController instance = PlayerController.instance;
			if (!((Object)(object)instance == (Object)null) && !(((Component)instance).transform.position.y >= _platformCenter.y + -8f))
			{
				Vector3 val = ((_spawnLocations.Count > 0) ? _spawnLocations[Random.Range(0, _spawnLocations.Count)] : (_platformCenter + Vector3.up * 0.5f));
				val += Vector3.up * 0.5f;
				((Component)instance).transform.position = val;
				if ((Object)(object)instance.rb != (Object)null)
				{
					instance.rb.position = val;
					instance.rb.velocity = Vector3.zero;
				}
			}
		}

		private void RefillLocalEnergy()
		{
			PlayerController instance = PlayerController.instance;
			if ((Object)(object)instance != (Object)null)
			{
				instance.EnergyCurrent = instance.EnergyStart;
			}
		}

		private List<PlayerAvatar> PlayablePlayers()
		{
			List<PlayerAvatar> list = new List<PlayerAvatar>();
			if ((Object)(object)GameDirector.instance != (Object)null && GameDirector.instance.PlayerList != null)
			{
				for (int i = 0; i < GameDirector.instance.PlayerList.Count; i++)
				{
					PlayerAvatar val = GameDirector.instance.PlayerList[i];
					if ((Object)(object)val != (Object)null && !ArenaAccess.GetIsDisabled(val) && !ArenaAccess.GetDeadSet(val))
					{
						list.Add(val);
					}
				}
			}
			return list;
		}

		public void AssignLocalGun(PhysGrabObject grab)
		{
			_localGun = grab;
			_grabRetryTimer = 0f;
		}

		internal void ReceiveGunAssigned(int avatarViewId, int gunViewId)
		{
			_gunAssignments[avatarViewId] = gunViewId;
		}

		private void TryGrabLocalGun()
		{
			_grabRetryTimer -= Time.unscaledDeltaTime;
			if (_grabRetryTimer > 0f)
			{
				return;
			}
			_grabRetryTimer = 0.3f;
			PhysGrabObject val = ResolveLocalGun();
			if (!((Object)(object)val == (Object)null))
			{
				PhysGrabber instance = PhysGrabber.instance;
				if (!((Object)(object)instance == (Object)null))
				{
					instance.OverrideGrab(val, 0.45f, false);
				}
			}
		}

		private PhysGrabObject ResolveLocalGun()
		{
			if ((Object)(object)_localGun != (Object)null)
			{
				return _localGun;
			}
			if (!SemiFunc.IsMultiplayer())
			{
				return null;
			}
			PlayerController instance = PlayerController.instance;
			PlayerAvatar val = (((Object)(object)instance != (Object)null) ? instance.playerAvatarScript : null);
			if ((Object)(object)val == (Object)null || (Object)(object)val.photonView == (Object)null)
			{
				return null;
			}
			int viewID = val.photonView.ViewID;
			if (!_gunAssignments.TryGetValue(viewID, out var value))
			{
				return null;
			}
			PhotonView val2 = PhotonView.Find(value);
			if ((Object)(object)val2 == (Object)null)
			{
				return null;
			}
			PhysGrabObject val3 = ((Component)val2).GetComponent<PhysGrabObject>() ?? ((Component)val2).GetComponentInChildren<PhysGrabObject>(true);
			if ((Object)(object)val3 != (Object)null)
			{
				_localGun = val3;
			}
			return val3;
		}

		private void BuildArena(LevelGenerator generator)
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			//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_00f2: 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_012e: 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_016e: Expected O, but got Unknown
			if ((Object)(object)generator.LevelParent != (Object)null)
			{
				for (int num = generator.LevelParent.transform.childCount - 1; num >= 0; num--)
				{
					Object.Destroy((Object)(object)((Component)generator.LevelParent.transform.GetChild(num)).gameObject);
				}
			}
			_spawnLocations.Clear();
			GameObject val = new GameObject("Empress Final Hand Root");
			val.transform.SetParent(generator.LevelParent.transform, false);
			_arenaRoot = val.transform;
			_platformCenter = val.transform.position;
			GameObject val2 = new GameObject("Empress Final Hand Module");
			val2.transform.SetParent(val.transform, false);
			val2.AddComponent<PhotonView>().ObservedComponents = new List<Component>();
			ArenaAccess.ConfigureStartRoomModule(val2.AddComponent<Module>(), 0, 0);
			val2.AddComponent<StartRoom>();
			GameObject val3 = new GameObject("Empress Final Hand Room Volume");
			val3.transform.SetParent(val2.transform, false);
			RoomVolume roomVolume = val3.AddComponent<RoomVolume>();
			BoxCollider obj = val3.AddComponent<BoxCollider>();
			((Collider)obj).isTrigger = true;
			obj.size = new Vector3(74f, 60f, 66f);
			obj.center = new Vector3(0f, 20f, 0f);
			ArenaMaterials.EnsureCreated();
			BuildPlatform(val2.transform);
			BuildLights(val2.transform);
			BuildSpawnPoints(val2.transform, roomVolume, generator);
			GameObject val4 = new GameObject("Empress Final Hand Boss");
			val4.transform.SetParent(val.transform, false);
			_bossHolder = val4.transform;
		}

		private void BuildPlatform(Transform parent)
		{
			//IL_0015: 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_004e: 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_0095: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: 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_015c: 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_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			CreateBox(parent, "Platform", new Vector3(0f, -0.6f, 0f), new Vector3(34f, 1.2f, 26f), ArenaMaterials.FloorMaterial);
			CreateBox(parent, "Platform Underside", new Vector3(0f, -2.7f, 0f), new Vector3(30f, 2.4f, 22f), ArenaMaterials.PillarMaterial);
			float num = 0.5f;
			CreateDecoration(parent, "Edge North", new Vector3(0f, 0.06f, 13f - num * 0.5f), new Vector3(34f, 0.12f, num), ArenaMaterials.TrimMaterial);
			CreateDecoration(parent, "Edge South", new Vector3(0f, 0.06f, -13f + num * 0.5f), new Vector3(34f, 0.12f, num), ArenaMaterials.TrimMaterial);
			CreateDecoration(parent, "Edge East", new Vector3(17f - num * 0.5f, 0.06f, 0f), new Vector3(num, 0.12f, 26f), ArenaMaterials.TrimMaterial);
			CreateDecoration(parent, "Edge West", new Vector3(-17f + num * 0.5f, 0.06f, 0f), new Vector3(num, 0.12f, 26f), ArenaMaterials.TrimMaterial);
			float num2 = Mathf.Floor(3.4f) * 5f;
			for (float num3 = 0f - num2; num3 <= num2 + 0.01f; num3 += 5f)
			{
				CreateDecoration(parent, "Grid X", new Vector3(num3, 0.04f, 0f), new Vector3(0.06f, 0.02f, 25f), ArenaMaterials.GridMaterial);
			}
			float num4 = Mathf.Floor(2.6f) * 5f;
			for (float num5 = 0f - num4; num5 <= num4 + 0.01f; num5 += 5f)
			{
				CreateDecoration(parent, "Grid Z", new Vector3(0f, 0.04f, num5), new Vector3(33f, 0.02f, 0.06f), ArenaMaterials.GridMaterial);
			}
		}

		private void BuildLights(Transform parent)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: 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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_007d: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Empress Final Hand Key Light");
			val.transform.SetParent(parent, false);
			val.transform.localRotation = Quaternion.Euler(58f, 20f, 0f);
			Light obj = val.AddComponent<Light>();
			obj.type = (LightType)1;
			obj.color = new Color(0.6f, 0.7f, 1f);
			obj.intensity = 0.85f;
			GameObject val2 = new GameObject("Empress Final Hand Rim Light");
			val2.transform.SetParent(parent, false);
			val2.transform.localPosition = new Vector3(0f, 16f, 0f);
			Light obj2 = val2.AddComponent<Light>();
			obj2.type = (LightType)2;
			obj2.color = new Color(1f, 0.35f, 0.5f);
			obj2.intensity = 2.4f;
			obj2.range = 44f;
		}

		private void BuildSpawnPoints(Transform parent, RoomVolume roomVolume, LevelGenerator generator)
		{
			//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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_00a3: 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_00bb: 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_00cd: 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_00da: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: 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)
			Vector3[] array = (Vector3[])(object)new Vector3[6]
			{
				new Vector3(-4f, 0.3f, -9f),
				new Vector3(0f, 0.3f, -9f),
				new Vector3(4f, 0.3f, -9f),
				new Vector3(-4f, 0.3f, -6f),
				new Vector3(0f, 0.3f, -6f),
				new Vector3(4f, 0.3f, -6f)
			};
			foreach (Vector3 val in array)
			{
				GameObject val2 = new GameObject("Empress Final Hand Spawn");
				val2.transform.SetParent(parent, false);
				val2.transform.localPosition = val;
				val2.transform.localRotation = Quaternion.LookRotation(Vector3.forward, Vector3.up);
				val2.AddComponent<SpawnPoint>();
				_spawnLocations.Add(_arenaRoot.TransformPoint(val));
			}
			LevelPoint val3 = CreateLevelPoint(parent, roomVolume, generator, new Vector3(0f, 0.3f, -7.5f), truck: true);
			LevelPoint val4 = CreateLevelPoint(parent, roomVolume, generator, new Vector3(0f, 0.3f, 0f), truck: false);
			val3.ConnectedPoints = new List<LevelPoint> { val4 };
			val4.ConnectedPoints = new List<LevelPoint> { val3 };
		}

		private static LevelPoint CreateLevelPoint(Transform parent, RoomVolume roomVolume, LevelGenerator generator, Vector3 localPosition, bool truck)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Empress Final Hand Level Point")
			{
				layer = LayerMask.NameToLayer("Other")
			};
			val.transform.SetParent(parent, false);
			val.transform.localPosition = localPosition;
			SphereCollider obj = val.AddComponent<SphereCollider>();
			((Collider)obj).isTrigger = true;
			obj.radius = 0.35f;
			LevelPoint obj2 = val.AddComponent<LevelPoint>();
			obj2.ConnectedPoints = new List<LevelPoint>();
			obj2.Room = roomVolume;
			obj2.Truck = truck;
			obj2.ModuleConnect = false;
			ArenaAccess.MarkLevelPointInStartRoom(obj2, value: true);
			if (generator.LevelPathPoints == null)
			{
				generator.LevelPathPoints = new List<LevelPoint>();
			}
			return obj2;
		}

		private static GameObject CreateBox(Transform parent, string name, Vector3 position, Vector3 size, Material material)
		{
			//IL_0020: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3);
			((Object)obj).name = name;
			obj.transform.SetParent(parent, false);
			obj.transform.localPosition = position;
			obj.transform.localRotation = Quaternion.identity;
			obj.transform.localScale = size;
			MeshRenderer component = obj.GetComponent<MeshRenderer>();
			if ((Object)(object)component != (Object)null && (Object)(object)material != (Object)null)
			{
				((Renderer)component).sharedMaterial = material;
			}
			return obj;
		}

		private static GameObject CreateDecoration(Transform parent, string name, Vector3 position, Vector3 size, Material material)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = CreateBox(parent, name, position, size, material);
			Collider component = obj.GetComponent<Collider>();
			if ((Object)(object)component != (Object)null)
			{
				Object.Destroy((Object)(object)component);
			}
			return obj;
		}
	}
	internal static class ArenaMaterials
	{
		public static Material FloorMaterial { get; private set; }

		public static Material TrimMaterial { get; private set; }

		public static Material GridMaterial { get; private set; }

		public static Material PillarMaterial { get; private set; }

		public static void EnsureCreated()
		{
			//IL_0028: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: 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_00c0: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)FloorMaterial != (Object)null))
			{
				Shader shader = Shader.Find("Standard");
				FloorMaterial = CreateMaterial(shader, new Color(0.03f, 0.04f, 0.07f), new Color(0.04f, 0.1f, 0.2f), 0.5f, 0.7f, 0.3f);
				TrimMaterial = CreateMaterial(shader, new Color(0.92f, 0.18f, 0.42f), new Color(1f, 0.3f, 0.55f), 3.4f, 1f, 0.2f);
				GridMaterial = CreateMaterial(shader, new Color(0.1f, 0.4f, 0.75f), new Color(0.14f, 0.55f, 0.95f), 2f, 1f, 0.18f);
				PillarMaterial = CreateMaterial(shader, new Color(0.02f, 0.02f, 0.04f), Color.black, 0f, 0.4f, 0.2f);
			}
		}

		private static Material CreateMaterial(Shader shader, Color baseColor, Color emissionColor, float emissionStrength, float smoothness, float metallic)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			Material val = new Material(shader);
			val.color = baseColor;
			if (val.HasProperty("_Glossiness"))
			{
				val.SetFloat("_Glossiness", Mathf.Clamp01(smoothness));
			}
			if (val.HasProperty("_Metallic"))
			{
				val.SetFloat("_Metallic", Mathf.Clamp01(metallic));
			}
			if (emissionStrength > 0f && val.HasProperty("_EmissionColor"))
			{
				val.EnableKeyword("_EMISSION");
				val.SetColor("_EmissionColor", emissionColor * emissionStrength);
				val.globalIlluminationFlags = (MaterialGlobalIlluminationFlags)1;
			}
			return val;
		}
	}
	internal sealed class ArenaWeaponService
	{
		private sealed class Loadout
		{
			public PlayerAvatar Avatar;

			public string SteamId;

			public string InstanceName;

			public int Spot;

			public ItemGun Gun;

			public ItemAttributes Attributes;

			public PhysGrabObject GrabObject;
		}

		private readonly Dictionary<string, Loadout> _loadouts = new Dictionary<string, Loadout>(StringComparer.Ordinal);

		private float _retryTimer;

		private bool _active;

		public void Activate()
		{
			_active = true;
			_retryTimer = 0f;
		}

		public void Reset()
		{
			_active = false;
			_retryTimer = 0f;
			_loadouts.Clear();
		}

		public void Update()
		{
			if (!_active || !SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			_retryTimer -= Time.unscaledDeltaTime;
			if (_retryTimer > 0f)
			{
				MaintainExisting();
				return;
			}
			_retryTimer = 1.5f;
			StatsManager instance = StatsManager.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return;
			}
			Item val = FindHandgunItem(instance);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			PrefabRef prefab = val.prefab;
			if (prefab == null)
			{
				return;
			}
			string resourcePath = prefab.ResourcePath;
			GameObject prefab2 = prefab.Prefab;
			if (string.IsNullOrEmpty(resourcePath) && (Object)(object)prefab2 == (Object)null)
			{
				return;
			}
			GameDirector instance2 = GameDirector.instance;
			if ((Object)(object)instance2 == (Object)null || instance2.PlayerList == null)
			{
				return;
			}
			foreach (PlayerAvatar player in instance2.PlayerList)
			{
				if ((Object)(object)player == (Object)null)
				{
					continue;
				}
				string steamId = ArenaAccess.GetSteamId(player);
				if (string.IsNullOrEmpty(steamId))
				{
					continue;
				}
				if (_loadouts.TryGetValue(steamId, out var value) && (Object)(object)value.Gun != (Object)null)
				{
					MaintainLoadout(value);
					continue;
				}
				if (value == null)
				{
					value = new Loadout
					{
						Avatar = player,
						SteamId = steamId
					};
					_loadouts[steamId] = value;
				}
				TrySpawnAndEquip(value, val, prefab, resourcePath, prefab2, instance);
			}
		}

		private void MaintainExisting()
		{
			foreach (Loadout value in _loadouts.Values)
			{
				if (!((Object)(object)value.Gun == (Object)null))
				{
					MaintainLoadout(value);
				}
			}
		}

		private void TrySpawnAndEquip(Loadout loadout, Item handgun, PrefabRef prefab, string resourcePath, GameObject prefabObject, StatsManager stats)
		{
			//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_003e: 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_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_0059: 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_0068: 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)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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_003d: 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_00da: 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)
			PlayerAvatar avatar = loadout.Avatar;
			if ((Object)(object)avatar == (Object)null)
			{
				return;
			}
			Transform transform = ((Component)avatar).transform;
			Vector3 forward = transform.forward;
			forward.y = 0f;
			if (((Vector3)(ref forward)).sqrMagnitude < 0.001f)
			{
				forward = Vector3.forward;
			}
			Vector3 val = transform.position + ((Vector3)(ref forward)).normalized * 0.8f + Vector3.up * 0.8f;
			Quaternion val2 = Quaternion.LookRotation(((Vector3)(ref forward)).normalized, Vector3.up);
			int num = FindFreeSpotForPlayer(stats, loadout.SteamId);
			if (num < 0)
			{
				return;
			}
			string text = PredictNextInstanceName(stats, ((Object)handgun).name);
			stats.SetBatteryLevel(text, 100);
			ReserveInventorySpot(stats, PunManager.instance, loadout.SteamId, text, num);
			GameObject val3 = null;
			if (SemiFunc.IsMultiplayer() && !string.IsNullOrEmpty(resourcePath))
			{
				val3 = PhotonNetwork.InstantiateRoomObject(resourcePath, val, val2, (byte)0, (object[])null);
			}
			else if ((Object)(object)prefabObject != (Object)null)
			{
				val3 = Object.Instantiate<GameObject>(prefabObject, val, val2);
			}
			if ((Object)(object)val3 == (Object)null)
			{
				return;
			}
			loadout.Gun = val3.GetComponent<ItemGun>() ?? val3.GetComponentInChildren<ItemGun>(true);
			if (!((Object)(object)loadout.Gun == (Object)null))
			{
				loadout.Attributes = val3.GetComponent<ItemAttributes>() ?? val3.GetComponentInChildren<ItemAttributes>(true);
				loadout.GrabObject = val3.GetComponent<PhysGrabObject>() ?? val3.GetComponentInChildren<PhysGrabObject>(true);
				loadout.InstanceName = text;
				loadout.Spot = num;
				PunManager instance = PunManager.instance;
				if ((Object)(object)instance != (Object)null && (Object)(object)loadout.Attributes != (Object)null)
				{
					instance.SetItemName(text, loadout.Attributes, PhotonViewId((Component)(object)loadout.Attributes));
				}
				ItemEquippable val4 = val3.GetComponent<ItemEquippable>() ?? val3.GetComponentInChildren<ItemEquippable>(true);
				if ((Object)(object)val4 != (Object)null)
				{
					val4.RequestEquip(num, PhotonViewId((Component)(object)avatar));
				}
				ConfigureGun(loadout.Gun);
				ChargeGun(loadout, stats);
				AnnounceGunAssignment(loadout, avatar);
			}
		}

		private void MaintainLoadout(Loadout loadout)
		{
			if ((Object)(object)loadout.Avatar == (Object)null || (Object)(object)loadout.Gun == (Object)null)
			{
				return;
			}
			ItemAttributes attributes = loadout.Attributes;
			if ((Object)(object)attributes != (Object)null)
			{
				string itemInstanceName = ArenaAccess.GetItemInstanceName(attributes);
				if (!string.IsNullOrEmpty(itemInstanceName))
				{
					loadout.InstanceName = itemInstanceName;
				}
			}
			ConfigureGun(loadout.Gun);
			ChargeGun(loadout, StatsManager.instance);
			AnnounceGunAssignment(loadout, loadout.Avatar);
		}

		private static void ConfigureGun(ItemGun gun)
		{
			if (!((Object)(object)gun == (Object)null))
			{
				gun.shootCooldown = 0.12f;
				gun.shootTime = 0.04f;
				gun.batteryDrain = 0f;
				gun.batteryDrainFullBar = false;
			}
		}

		private static void ChargeGun(Loadout loadout, StatsManager stats)
		{
			if (!((Object)(object)loadout.Gun == (Object)null))
			{
				if ((Object)(object)stats != (Object)null && !string.IsNullOrEmpty(loadout.InstanceName))
				{
					stats.SetBatteryLevel(loadout.InstanceName, 100);
				}
				ItemBattery val = ArenaAccess.GetGunBattery(loadout.Gun) ?? ((Component)loadout.Gun).GetComponent<ItemBattery>();
				if (!((Object)(object)val == (Object)null))
				{
					val.batteryLife = 100f;
					ArenaAccess.SetItemBatteryLifeInt(val, val.batteryBars);
				}
			}
		}

		private void AnnounceGunAssignment(Loadout loadout, PlayerAvatar avatar)
		{
			if ((Object)(object)loadout.GrabObject == (Object)null || (Object)(object)avatar == (Object)null)
			{
				return;
			}
			ArenaRuntime instance = ArenaRuntime.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				return;
			}
			if (ArenaAccess.GetIsLocal(avatar))
			{
				instance.AssignLocalGun(loadout.GrabObject);
			}
			if (SemiFunc.IsMultiplayer() && !((Object)(object)avatar.photonView == (Object)null) && !((Object)(object)loadout.GrabObject == (Object)null))
			{
				PhotonView component = ((Component)loadout.GrabObject).GetComponent<PhotonView>();
				if (!((Object)(object)component == (Object)null))
				{
					EmpressFinalHandPlugin.RaiseGunAssigned(avatar.photonView.ViewID, component.ViewID);
				}
			}
		}

		private static int FindFreeSpotForPlayer(StatsManager stats, string steamId)
		{
			for (int i = 0; i < 3; i++)
			{
				Dictionary<string, int> dictionary = i switch
				{
					1 => stats.playerInventorySpot2Taken, 
					0 => stats.playerInventorySpot1Taken, 
					_ => stats.playerInventorySpot3Taken, 
				};
				if (dictionary == null)
				{
					return i;
				}
				if (!dictionary.TryGetValue(steamId, out var value) || value == 0)
				{
					return i;
				}
			}
			return -1;
		}

		private static string PredictNextInstanceName(StatsManager stats, string itemName)
		{
			int num = 1;
			Dictionary<string, int> item = stats.item;
			if (item == null)
			{
				return itemName + "/" + num;
			}
			foreach (string key in item.Keys)
			{
				if (!string.IsNullOrEmpty(key) && key.Contains("/"))
				{
					string[] array = key.Split('/');
					if (array.Length == 2 && !(array[0] != itemName) && int.TryParse(array[1], out var result) && result >= num)
					{
						num = result + 1;
					}
				}
			}
			return itemName + "/" + num;
		}

		private static void ReserveInventorySpot(StatsManager stats, PunManager pun, string steamId, string instanceName, int spot)
		{
			string text = spot switch
			{
				1 => "playerInventorySpot2", 
				0 => "playerInventorySpot1", 
				_ => "playerInventorySpot3", 
			};
			int hashCode = instanceName.GetHashCode();
			stats.DictionaryUpdateValue(text, steamId, hashCode);
			if ((Object)(object)pun != (Object)null)
			{
				pun.UpdateStat(text, steamId, hashCode);
			}
			((Dictionary<string, int>)(spot switch
			{
				1 => stats.playerInventorySpot2Taken, 
				0 => stats.playerInventorySpot1Taken, 
				_ => stats.playerInventorySpot3Taken, 
			}))?.Remove(steamId);
		}

		private static Item FindHandgunItem(StatsManager stats)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Invalid comparison between Unknown and I4
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Invalid comparison between Unknown and I4
			Dictionary<string, Item> itemDictionary = stats.itemDictionary;
			if (itemDictionary == null)
			{
				return null;
			}
			foreach (KeyValuePair<string, Item> item in itemDictionary)
			{
				Item value = item.Value;
				if (!((Object)(object)value == (Object)null) && !value.disabled && (int)value.itemType == 9)
				{
					string obj = item.Key ?? string.Empty;
					string text = value.itemName ?? string.Empty;
					string text2 = ((Object)value).name ?? string.Empty;
					if (obj.IndexOf("handgun", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("handgun", StringComparison.OrdinalIgnoreCase) >= 0 || text2.IndexOf("handgun", StringComparison.OrdinalIgnoreCase) >= 0)
					{
						return value;
					}
				}
			}
			foreach (KeyValuePair<string, Item> item2 in itemDictionary)
			{
				Item value2 = item2.Value;
				if ((Object)(object)value2 != (Object)null && !value2.disabled && (int)value2.itemType == 9)
				{
					return value2;
				}
			}
			return null;
		}

		private static int PhotonViewId(Component component)
		{
			if ((Object)(object)component == (Object)null)
			{
				return -1;
			}
			PhotonView component2 = component.GetComponent<PhotonView>();
			if (!((Object)(object)component2 != (Object)null))
			{
				return -1;
			}
			return component2.ViewID;
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.empress.repo.finalhand", "Empress Final Hand", "1.0.0")]
	public sealed class EmpressFinalHandPlugin : BaseUnityPlugin
	{
		public const string PluginGuid = "com.empress.repo.finalhand";

		public const string PluginName = "Empress Final Hand";

		public const string PluginVersion = "1.0.0";

		public const string ArenaLevelName = "Level - Empress Final Hand";

		public const string ArenaDisplayName = "Empress Final Hand";

		internal const byte BossStateEventCode = 190;

		internal const byte BossHitEventCode = 191;

		internal const byte GunAssignedEventCode = 192;

		private static bool _photonEventsHooked;

		private Harmony _harmony;

		internal static EmpressFinalHandPlugin Instance { get; private set; }

		internal static ManualLogSource Log { get; private set; }

		internal static ArenaSettings Settings { get; private set; }

		internal static Level ArenaLevel { get; private set; }

		private void Awake()
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			Settings = new ArenaSettings(((BaseUnityPlugin)this).Config);
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			ArenaLevel = ArenaLevelRegistry.RegisterArenaLevel();
			string? directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			_harmony = new Harmony("com.empress.repo.finalhand");
			_harmony.PatchAll(typeof(EmpressFinalHandPlugin).Assembly);
			ArenaRuntime.EnsureHost();
			HandAudio.Initialize(directoryName, (MonoBehaviour)(object)ArenaRuntime.Instance, ((BaseUnityPlugin)this).Logger);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Empress Final Hand v1.0.0 loaded. Level registered: Level - Empress Final Hand");
		}

		internal static bool IsArenaLevel(Level level)
		{
			if ((Object)(object)level != (Object)null)
			{
				return ((Object)level).name == "Level - Empress Final Hand";
			}
			return false;
		}

		private void OnDestroy()
		{
			RemovePhotonEventHook();
		}

		internal static void EnsurePhotonEventHooked()
		{
			if (!_photonEventsHooked)
			{
				LoadBalancingClient networkingClient = PhotonNetwork.NetworkingClient;
				if (networkingClient != null)
				{
					networkingClient.EventReceived -= OnPhotonEvent;
					networkingClient.EventReceived += OnPhotonEvent;
					_photonEventsHooked = true;
				}
			}
		}

		internal static void RemovePhotonEventHook()
		{
			if (_photonEventsHooked)
			{
				LoadBalancingClient networkingClient = PhotonNetwork.NetworkingClient;
				if (networkingClient != null)
				{
					networkingClient.EventReceived -= OnPhotonEvent;
				}
				_photonEventsHooked = false;
			}
		}

		private static void OnPhotonEvent(EventData ev)
		{
			ArenaRuntime instance = ArenaRuntime.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				return;
			}
			switch (ev.Code)
			{
			case 190:
				if (ev.CustomData is object[] data)
				{
					instance.ReceiveBossState(data);
				}
				break;
			case 191:
				if (ev.CustomData is object[] array2 && array2.Length >= 1 && array2[0] is int index)
				{
					instance.ReceiveBossHit(index);
				}
				break;
			case 192:
				if (ev.CustomData is object[] array && array.Length >= 2 && array[0] is int avatarViewId && array[1] is int gunViewId)
				{
					instance.ReceiveGunAssigned(avatarViewId, gunViewId);
				}
				break;
			}
		}

		internal static void RaiseBossState(object[] data)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			RaisePhotonEvent(190, data, (ReceiverGroup)0, (EventCaching)0, SendOptions.SendUnreliable);
		}

		internal static void RaiseBossHit(int index)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			RaisePhotonEvent(191, new object[1] { index }, (ReceiverGroup)2, (EventCaching)0, SendOptions.SendReliable);
		}

		internal static void RaiseGunAssigned(int avatarViewId, int gunViewId)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			RaisePhotonEvent(192, new object[2] { avatarViewId, gunViewId }, (ReceiverGroup)1, (EventCaching)4, SendOptions.SendReliable);
		}

		internal static void ClearArenaPhotonCache()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if (PhotonNetwork.InRoom)
			{
				RaiseEventOptions val = new RaiseEventOptions
				{
					CachingOption = (EventCaching)6
				};
				PhotonNetwork.RaiseEvent((byte)192, (object)null, val, SendOptions.SendReliable);
			}
		}

		private static void RaisePhotonEvent(byte code, object[] payload, ReceiverGroup receivers, EventCaching caching, SendOptions sendOptions)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			EnsurePhotonEventHooked();
			if (PhotonNetwork.InRoom)
			{
				RaiseEventOptions val = new RaiseEventOptions
				{
					Receivers = receivers,
					CachingOption = caching
				};
				PhotonNetwork.RaiseEvent(code, (object)payload, val, sendOptions);
			}
		}
	}
	internal sealed class ArenaSettings
	{
		public readonly ConfigEntry<bool> ForceArenaLevel;

		public readonly ConfigEntry<int> WeakSpotHealth;

		public readonly ConfigEntry<float> ExitDelaySeconds;

		public ArenaSettings(ConfigFile config)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			ForceArenaLevel = config.Bind<bool>("Debug", "ForceArenaLevel", false, "Forces every real run level to load the Empress Final Hand arena. Useful for testing.");
			WeakSpotHealth = config.Bind<int>("Boss", "WeakSpotHealth", 8, new ConfigDescription("Handgun shots needed to destroy each of the 5 red weak spots.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 40), Array.Empty<object>()));
			ExitDelaySeconds = config.Bind<float>("Boss", "ExitDelaySeconds", 6f, new ConfigDescription("Seconds after the hand is destroyed before the level transitions away.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 30f), Array.Empty<object>()));
		}
	}
	internal sealed class FinalHandLoadingScreen : MonoBehaviour
	{
		private static readonly Color BackgroundA = new Color(0.01f, 0.012f, 0.03f, 1f);

		private static readonly Color BackgroundB = new Color(0.05f, 0.015f, 0.07f, 1f);

		private static readonly Color Accent = new Color(1f, 0.28f, 0.42f, 0.5f);

		private static bool _active;

		private static float _muteUntilRealtime;

		private static Sprite _handSprite;

		private GameObject _root;

		private Image _background;

		private Image _hand;

		private RectTransform _handRect;

		private readonly Image[] _streaks = (Image[])(object)new Image[6];

		private readonly RectTransform[] _streakRects = (RectTransform[])(object)new RectTransform[6];

		private float _time;

		private const int Tile = 8;

		public static void Show(LoadingUI ui)
		{
			if (!((Object)(object)ui == (Object)null))
			{
				FinalHandLoadingScreen finalHandLoadingScreen = ((Component)ui).GetComponent<FinalHandLoadingScreen>();
				if ((Object)(object)finalHandLoadingScreen == (Object)null)
				{
					finalHandLoadingScreen = ((Component)ui).gameObject.AddComponent<FinalHandLoadingScreen>();
				}
				finalHandLoadingScreen.ShowInternal(ui);
			}
		}

		public static void Hide(LoadingUI ui)
		{
			if (!((Object)(object)ui == (Object)null))
			{
				FinalHandLoadingScreen component = ((Component)ui).GetComponent<FinalHandLoadingScreen>();
				if ((Object)(object)component != (Object)null)
				{
					component.HideInternal();
				}
			}
		}

		public static bool OwnsCurrentLoading()
		{
			if (_active || Time.realtimeSinceStartup < _muteUntilRealtime)
			{
				return true;
			}
			Level val = null;
			if (Object.op_Implicit((Object)(object)LevelGenerator.Instance))
			{
				val = LevelGenerator.Instance.Level;
			}
			if (!Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)RunManager.instance))
			{
				val = RunManager.instance.levelCurrent;
			}
			return EmpressFinalHandPlugin.IsArenaLevel(val);
		}

		private void ShowInternal(LoadingUI ui)
		{
			EnsureBuilt(((Component)ui).transform);
			ClearGraphic(ui.loadingGraphic01);
			ClearGraphic(ui.loadingGraphic02);
			ClearGraphic(ui.loadingGraphic03);
			_time = 0f;
			_active = true;
			_muteUntilRealtime = Time.realtimeSinceStartup + 18f;
			_root.SetActive(true);
			_root.transform.SetAsLastSibling();
			if ((Object)(object)ui.levelNumberText != (Object)null)
			{
				BringToFront(((TMP_Text)ui.levelNumberText).transform);
			}
			if ((Object)(object)ui.levelNameText != (Object)null)
			{
				BringToFront(((TMP_Text)ui.levelNameText).transform);
			}
		}

		private void BringToFront(Transform target)
		{
			if (!((Object)(object)target == (Object)null) && !((Object)(object)_root == (Object)null))
			{
				Transform parent = _root.transform.parent;
				Transform val = target;
				while ((Object)(object)val.parent != (Object)null && (Object)(object)val.parent != (Object)(object)parent)
				{
					val = val.parent;
				}
				if ((Object)(object)val.parent == (Object)(object)parent)
				{
					val.SetAsLastSibling();
				}
				target.SetAsLastSibling();
			}
		}

		private void HideInternal()
		{
			_active = false;
			_muteUntilRealtime = Time.realtimeSinceStartup + 1.5f;
			if ((Object)(object)_root != (Object)null)
			{
				_root.SetActive(false);
			}
		}

		private void Update()
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_root == (Object)null || !_root.activeSelf)
			{
				return;
			}
			if (!OwnsCurrentLoading())
			{
				_active = false;
				_root.SetActive(false);
				return;
			}
			_time += Time.unscaledDeltaTime;
			float num = 0.5f + Mathf.Sin(_time * 2.2f) * 0.5f;
			((Graphic)_background).color = Color.Lerp(BackgroundA, BackgroundB, num);
			float num2 = Mathf.Clamp01(_time / 0.7f);
			float num3 = 1f - (1f - num2) * (1f - num2);
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(780f, -180f);
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(0f, 120f);
			float num4 = Mathf.Sin(_time * 1.8f) * 12f;
			_handRect.anchoredPosition = Vector2.Lerp(val, val2, num3) + new Vector2(0f, num4 * num3);
			((Transform)_handRect).localRotation = Quaternion.Euler(0f, 0f, Mathf.Lerp(-40f, Mathf.Sin(_time * 1.4f) * 4f, num3));
			float num5 = Mathf.Lerp(0.4f, 1f, num3) + Mathf.Sin(_time * 5f) * 0.02f * num3;
			((Transform)_handRect).localScale = new Vector3(num5, num5, 1f);
			for (int i = 0; i < _streakRects.Length; i++)
			{
				RectTransform obj = _streakRects[i];
				Vector2 anchoredPosition = obj.anchoredPosition;
				anchoredPosition.x -= Time.unscaledDeltaTime * (220f + (float)i * 70f);
				if (anchoredPosition.x < -700f)
				{
					anchoredPosition.x = 700f;
				}
				obj.anchoredPosition = anchoredPosition;
			}
		}

		private void EnsureBuilt(Transform parent)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: 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_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_root != (Object)null))
			{
				_root = CreateObject("Empress Final Hand Loading", parent);
				Stretch(_root.GetComponent<RectTransform>());
				_background = _root.AddComponent<Image>();
				((Graphic)_background).raycastTarget = false;
				((Graphic)_background).color = BackgroundA;
				for (int i = 0; i < _streaks.Length; i++)
				{
					Image val = CreateImage("Empress Streak", _root.transform, Accent);
					RectTransform rectTransform = ((Graphic)val).rectTransform;
					rectTransform.anchorMin = new Vector2(0.5f, 0.5f);
					rectTransform.anchorMax = new Vector2(0.5f, 0.5f);
					rectTransform.pivot = new Vector2(0.5f, 0.5f);
					rectTransform.sizeDelta = new Vector2(240f + (float)i * 60f, (i % 2 == 0) ? 4f : 2f);
					rectTransform.anchoredPosition = new Vector2(DeterministicRange(i, -600f, 600f), -260f + (float)i * 95f);
					_streaks[i] = val;
					_streakRects[i] = rectTransform;
				}
				_hand = CreateImage("Empress Hand Glyph", _root.transform, Color.white);
				_hand.sprite = GetHandSprite();
				_hand.preserveAspect = true;
				_handRect = ((Graphic)_hand).rectTransform;
				_handRect.anchorMin = new Vector2(0.5f, 0.5f);
				_handRect.anchorMax = new Vector2(0.5f, 0.5f);
				_handRect.pivot = new Vector2(0.5f, 0.5f);
				_handRect.sizeDelta = new Vector2(320f, 300f);
				_handRect.anchoredPosition = Vector2.zero;
				_root.SetActive(false);
			}
		}

		private static Sprite GetHandSprite()
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (mig