Decompiled source of Bowser Boss Battle v1.0.0

BepInEx/plugins/Omniscye-EmpressBowser/EmpressBowser.dll

Decompiled 4 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.Rendering;
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("EmpressBowser")]
[assembly: AssemblyTitle("EmpressBowser")]
[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.Bowser
{
	internal static class BowserAccess
	{
		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 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 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 FieldInfo PhysGrabObjectGrabDisableTimerField = AccessTools.Field(typeof(PhysGrabObject), "grabDisableTimer");

		private static readonly FieldInfo ImpactDetectorIsNotValuableField = AccessTools.Field(typeof(PhysGrabObjectImpactDetector), "isNotValuable");

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

		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 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 void SetGrabDisableTimer(PhysGrabObject grab, float value)
		{
			SetField(PhysGrabObjectGrabDisableTimerField, grab, value);
		}

		public static void SetImpactDetectorNotValuable(PhysGrabObjectImpactDetector detector, bool value)
		{
			SetField(ImpactDetectorIsNotValuableField, detector, value);
		}

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

		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 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 BowserArenaInfo
	{
		public Transform Root;

		public Transform BossHolder;

		public Vector3 Center;

		public float PlatformRadius;

		public float PlatformY;

		public float LavaY;

		public readonly List<Vector3> SpawnPositions = new List<Vector3>();

		public readonly List<Light> FlickerLights = new List<Light>();

		public Material LavaMaterial;
	}
	internal static class BowserArena
	{
		public const float PlatformRadius = 15.5f;

		public const float LavaDepth = 2.2f;

		private static Material _rockMat;

		private static Material _rockDarkMat;

		private static Material _lavaMat;

		private static Material _lavaDeepMat;

		private static Material _crackMat;

		private static Material _emberMat;

		public static BowserArenaInfo Build(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_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: 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);
				}
			}
			EnsureMaterials();
			BowserArenaInfo bowserArenaInfo = new BowserArenaInfo();
			GameObject val = new GameObject("Empress Bowser Root");
			val.transform.SetParent(generator.LevelParent.transform, false);
			bowserArenaInfo.Root = val.transform;
			bowserArenaInfo.Center = val.transform.position;
			bowserArenaInfo.PlatformRadius = 15.5f;
			bowserArenaInfo.PlatformY = bowserArenaInfo.Center.y;
			bowserArenaInfo.LavaY = bowserArenaInfo.Center.y - 2.2f;
			GameObject val2 = new GameObject("Empress Bowser Module");
			val2.transform.SetParent(val.transform, false);
			val2.AddComponent<PhotonView>().ObservedComponents = new List<Component>();
			BowserAccess.ConfigureStartRoomModule(val2.AddComponent<Module>(), 0, 0);
			val2.AddComponent<StartRoom>();
			GameObject val3 = new GameObject("Empress Bowser 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(101f, 70f, 101f);
			obj.center = new Vector3(0f, 22f, 0f);
			BuildPlatform(val2.transform, bowserArenaInfo);
			BuildLava(val2.transform, bowserArenaInfo);
			BuildRocks(val2.transform, bowserArenaInfo);
			BuildLighting(val2.transform, bowserArenaInfo);
			BuildEmbers(val2.transform, bowserArenaInfo);
			BuildSpawnPoints(val2.transform, roomVolume, generator, bowserArenaInfo);
			GameObject val4 = new GameObject("Empress Bowser Boss Holder");
			val4.transform.SetParent(val.transform, false);
			bowserArenaInfo.BossHolder = val4.transform;
			return bowserArenaInfo;
		}

		private static void BuildPlatform(Transform parent, BowserArenaInfo info)
		{
			//IL_0033: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)obj).name = "Bowser Platform";
			obj.transform.SetParent(parent, false);
			obj.transform.localPosition = new Vector3(0f, -0.75f, 0f);
			obj.transform.localScale = new Vector3(31f, 0.75f, 31f);
			((Renderer)obj.GetComponent<MeshRenderer>()).sharedMaterial = _rockMat;
			Object.Destroy((Object)(object)obj.GetComponent<Collider>());
			obj.AddComponent<MeshCollider>().convex = false;
			GameObject obj2 = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)obj2).name = "Bowser Platform Core";
			obj2.transform.SetParent(parent, false);
			obj2.transform.localPosition = new Vector3(0f, -2.4f, 0f);
			obj2.transform.localScale = new Vector3(26.35f, 1.4f, 26.35f);
			((Renderer)obj2.GetComponent<MeshRenderer>()).sharedMaterial = _rockDarkMat;
			Object.Destroy((Object)(object)obj2.GetComponent<Collider>());
			int num = 26;
			Vector3 localPosition = default(Vector3);
			for (int i = 0; i < num; i++)
			{
				float num2 = (float)i / (float)num * MathF.PI * 2f;
				((Vector3)(ref localPosition))..ctor(Mathf.Cos(num2) * 15.15f, 0.18f, Mathf.Sin(num2) * 15.15f);
				GameObject obj3 = GameObject.CreatePrimitive((PrimitiveType)3);
				((Object)obj3).name = "Rim Rock";
				obj3.transform.SetParent(parent, false);
				obj3.transform.localPosition = localPosition;
				obj3.transform.localRotation = Quaternion.Euler(Random.Range(-14f, 14f), num2 * 57.29578f + Random.Range(-20f, 20f), Random.Range(-14f, 14f));
				obj3.transform.localScale = new Vector3(Random.Range(0.9f, 1.7f), Random.Range(0.5f, 1.1f), Random.Range(0.9f, 1.6f));
				((Renderer)obj3.GetComponent<MeshRenderer>()).sharedMaterial = _rockDarkMat;
				Object.Destroy((Object)(object)obj3.GetComponent<Collider>());
			}
			int num3 = 34;
			for (int j = 0; j < num3; j++)
			{
				float num4 = (float)j / (float)num3 * MathF.PI * 2f;
				float num5 = 14.15f;
				GameObject obj4 = GameObject.CreatePrimitive((PrimitiveType)3);
				((Object)obj4).name = "Lava Crack";
				obj4.transform.SetParent(parent, false);
				obj4.transform.localPosition = new Vector3(Mathf.Cos(num4) * num5, 0.02f, Mathf.Sin(num4) * num5);
				obj4.transform.localRotation = Quaternion.Euler(0f, num4 * 57.29578f + 90f, 0f);
				obj4.transform.localScale = new Vector3(2.55f, 0.045f, 0.24f);
				((Renderer)obj4.GetComponent<MeshRenderer>()).sharedMaterial = _crackMat;
				Object.Destroy((Object)(object)obj4.GetComponent<Collider>());
			}
		}

		private static void BuildLava(Transform parent, BowserArenaInfo info)
		{
			//IL_0033: 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_00b4: 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)
			GameObject obj = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)obj).name = "Bowser Lava";
			obj.transform.SetParent(parent, false);
			obj.transform.localPosition = new Vector3(0f, -2.2f, 0f);
			obj.transform.localScale = new Vector3(95f, 0.2f, 95f);
			((Renderer)obj.GetComponent<MeshRenderer>()).sharedMaterial = _lavaMat;
			Object.Destroy((Object)(object)obj.GetComponent<Collider>());
			info.LavaMaterial = _lavaMat;
			GameObject obj2 = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)obj2).name = "Bowser Lava Deep";
			obj2.transform.SetParent(parent, false);
			obj2.transform.localPosition = new Vector3(0f, -2.8000002f, 0f);
			obj2.transform.localScale = new Vector3(120f, 0.2f, 120f);
			((Renderer)obj2.GetComponent<MeshRenderer>()).sharedMaterial = _lavaDeepMat;
			Object.Destroy((Object)(object)obj2.GetComponent<Collider>());
		}

		private static void BuildRocks(Transform parent, BowserArenaInfo info)
		{
			//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_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			Vector3[] array = (Vector3[])(object)new Vector3[5]
			{
				new Vector3(-7.5f, 0f, 5.5f),
				new Vector3(8.2f, 0f, 4.2f),
				new Vector3(-5.2f, 0f, -7.8f),
				new Vector3(6.4f, 0f, -8.4f),
				new Vector3(0.5f, 0f, 9.6f)
			};
			for (int i = 0; i < array.Length; i++)
			{
				GameObject obj = GameObject.CreatePrimitive((PrimitiveType)0);
				((Object)obj).name = "Cover Boulder";
				obj.transform.SetParent(parent, false);
				float num = Random.Range(1.9f, 2.7f);
				obj.transform.localPosition = array[i] + new Vector3(0f, num * 0.32f, 0f);
				obj.transform.localRotation = Random.rotation;
				obj.transform.localScale = new Vector3(num, num * 0.78f, num);
				((Renderer)obj.GetComponent<MeshRenderer>()).sharedMaterial = _rockDarkMat;
			}
			int num2 = 6;
			for (int j = 0; j < num2; j++)
			{
				float num3 = ((float)j / (float)num2 + 0.07f) * MathF.PI * 2f;
				float num4 = 15.5f + Random.Range(5f, 10f);
				float num5 = Random.Range(7f, 13f);
				GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
				((Object)val).name = "Basalt Pillar";
				val.transform.SetParent(parent, false);
				val.transform.localPosition = new Vector3(Mathf.Cos(num3) * num4, -2.2f + num5 * 0.4f, Mathf.Sin(num3) * num4);
				val.transform.localRotation = Quaternion.Euler(Random.Range(-7f, 7f), Random.Range(0f, 360f), Random.Range(-7f, 7f));
				val.transform.localScale = new Vector3(Random.Range(1.7f, 3f), num5, Random.Range(1.7f, 3f));
				((Renderer)val.GetComponent<MeshRenderer>()).sharedMaterial = _rockDarkMat;
				Object.Destroy((Object)(object)val.GetComponent<Collider>());
				if (j % 2 == 0)
				{
					GameObject val2 = new GameObject("Pillar Flame Light");
					val2.transform.SetParent(val.transform, false);
					val2.transform.localPosition = new Vector3(0f, 0.56f, 0f);
					Light val3 = val2.AddComponent<Light>();
					val3.type = (LightType)2;
					val3.color = new Color(1f, 0.5f, 0.14f);
					val3.intensity = 2.6f;
					val3.range = 22f;
					info.FlickerLights.Add(val3);
				}
			}
		}

		private static void BuildLighting(Transform parent, BowserArenaInfo info)
		{
			//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_00b9: 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_00ef: 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_0111: 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)
			GameObject val = new GameObject("Empress Bowser Key Light");
			val.transform.SetParent(parent, false);
			val.transform.localRotation = Quaternion.Euler(62f, -28f, 0f);
			Light obj = val.AddComponent<Light>();
			obj.type = (LightType)1;
			obj.color = new Color(0.55f, 0.42f, 0.4f);
			obj.intensity = 0.55f;
			GameObject val2 = new GameObject("Empress Bowser Lava Glow");
			val2.transform.SetParent(parent, false);
			val2.transform.localPosition = new Vector3(0f, -1f, 0f);
			Light val3 = val2.AddComponent<Light>();
			val3.type = (LightType)2;
			val3.color = new Color(1f, 0.42f, 0.1f);
			val3.intensity = 2.9f;
			val3.range = 70f;
			info.FlickerLights.Add(val3);
			GameObject val4 = new GameObject("Empress Bowser Rim Light");
			val4.transform.SetParent(parent, false);
			val4.transform.localPosition = new Vector3(0f, 18f, 0f);
			Light obj2 = val4.AddComponent<Light>();
			obj2.type = (LightType)2;
			obj2.color = new Color(1f, 0.28f, 0.12f);
			obj2.intensity = 1.9f;
			obj2.range = 52f;
		}

		private static void BuildEmbers(Transform parent, BowserArenaInfo info)
		{
			//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_0036: 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_0042: 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_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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: 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_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Empress Bowser Embers");
			val.transform.SetParent(parent, false);
			val.transform.localPosition = new Vector3(0f, -1.6f, 0f);
			ParticleSystem obj = val.AddComponent<ParticleSystem>();
			MainModule main = obj.main;
			((MainModule)(ref main)).loop = true;
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(3f, 6f);
			((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.7f, 2.1f);
			((MainModule)(ref main)).startSize = new MinMaxCurve(0.05f, 0.17f);
			((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(1f, 0.55f, 0.12f, 0.9f), new Color(1f, 0.25f, 0.05f, 0.85f));
			((MainModule)(ref main)).maxParticles = 500;
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			EmissionModule emission = obj.emission;
			((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(42f);
			ShapeModule shape = obj.shape;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)10;
			((ShapeModule)(ref shape)).radius = 31.5f;
			((ShapeModule)(ref shape)).rotation = new Vector3(90f, 0f, 0f);
			VelocityOverLifetimeModule velocityOverLifetime = obj.velocityOverLifetime;
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true;
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = new MinMaxCurve(1.1f, 2.6f);
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = new MinMaxCurve(-0.4f, 0.4f);
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = new MinMaxCurve(-0.4f, 0.4f);
			((Renderer)val.GetComponent<ParticleSystemRenderer>()).sharedMaterial = _emberMat;
		}

		private static void BuildSpawnPoints(Transform parent, RoomVolume roomVolume, LevelGenerator generator, BowserArenaInfo info)
		{
			//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(-3.6f, 0.3f, -11.9f),
				new Vector3(0f, 0.3f, -12.3f),
				new Vector3(3.6f, 0.3f, -11.9f),
				new Vector3(-2f, 0.3f, -9.9f),
				new Vector3(2f, 0.3f, -9.9f),
				new Vector3(0f, 0.3f, -9.1f)
			};
			foreach (Vector3 val in array)
			{
				GameObject val2 = new GameObject("Empress Bowser Spawn");
				val2.transform.SetParent(parent, false);
				val2.transform.localPosition = val;
				val2.transform.localRotation = Quaternion.LookRotation(Vector3.forward, Vector3.up);
				val2.AddComponent<SpawnPoint>();
				info.SpawnPositions.Add(info.Root.TransformPoint(val));
			}
			LevelPoint val3 = CreateLevelPoint(parent, roomVolume, generator, new Vector3(0f, 0.3f, -10.9f), 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 Bowser 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;
			BowserAccess.MarkLevelPointInStartRoom(obj2, value: true);
			if (generator.LevelPathPoints == null)
			{
				generator.LevelPathPoints = new List<LevelPoint>();
			}
			return obj2;
		}

		private static void EnsureMaterials()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected O, but got Unknown
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Expected O, but got Unknown
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Expected O, but got Unknown
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_rockMat != (Object)null))
			{
				Shader val = Shader.Find("Standard");
				_rockMat = new Material(val)
				{
					color = new Color(0.11f, 0.085f, 0.08f)
				};
				_rockMat.SetFloat("_Glossiness", 0.18f);
				_rockMat.SetFloat("_Metallic", 0.05f);
				_rockDarkMat = new Material(val)
				{
					color = new Color(0.055f, 0.045f, 0.05f)
				};
				_rockDarkMat.SetFloat("_Glossiness", 0.12f);
				_rockDarkMat.SetFloat("_Metallic", 0.04f);
				_lavaMat = new Material(val)
				{
					color = new Color(1f, 0.36f, 0.05f)
				};
				_lavaMat.EnableKeyword("_EMISSION");
				_lavaMat.SetColor("_EmissionColor", new Color(1f, 0.32f, 0.03f) * 2.6f);
				_lavaMat.globalIlluminationFlags = (MaterialGlobalIlluminationFlags)1;
				_lavaDeepMat = new Material(val)
				{
					color = new Color(0.6f, 0.12f, 0.02f)
				};
				_lavaDeepMat.EnableKeyword("_EMISSION");
				_lavaDeepMat.SetColor("_EmissionColor", new Color(0.7f, 0.12f, 0.02f) * 1.4f);
				_crackMat = new Material(val)
				{
					color = new Color(1f, 0.42f, 0.08f)
				};
				_crackMat.EnableKeyword("_EMISSION");
				_crackMat.SetColor("_EmissionColor", new Color(1f, 0.4f, 0.06f) * 3.2f);
				_emberMat = new Material(Shader.Find("Particles/Standard Unlit") ?? val);
				if (_emberMat.HasProperty("_Color"))
				{
					_emberMat.SetColor("_Color", new Color(1f, 0.5f, 0.1f, 0.9f));
				}
				if (_emberMat.HasProperty("_EmissionColor"))
				{
					_emberMat.EnableKeyword("_EMISSION");
					_emberMat.SetColor("_EmissionColor", new Color(1f, 0.45f, 0.08f) * 2f);
				}
			}
		}
	}
	internal static class BowserAudio
	{
		private static readonly Dictionary<string, AudioClip> Clips = new Dictionary<string, AudioClip>();

		private static AudioSource _sfx;

		private static AudioSource _action;

		private static AudioSource _loop;

		private static MonoBehaviour _runner;

		private static Coroutine _fade;

		private static bool _started;

		private static bool _sfxRouted;

		private static bool _actionRouted;

		private static bool _loopRouted;

		private static bool _musicRouted;

		public static AudioClip MusicClip
		{
			get
			{
				if (!Clips.TryGetValue("bowser_music", out var value))
				{
					return null;
				}
				return value;
			}
		}

		public static void Initialize(string directory, MonoBehaviour runner, ManualLogSource log)
		{
			//IL_003f: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			if (!_started && !((Object)(object)runner == (Object)null) && !string.IsNullOrEmpty(directory) && Directory.Exists(directory))
			{
				_started = true;
				_runner = runner;
				if ((Object)(object)_sfx == (Object)null)
				{
					GameObject val = new GameObject("Empress Bowser SFX");
					val.transform.SetParent(((Component)runner).transform, false);
					_sfx = val.AddComponent<AudioSource>();
					_sfx.playOnAwake = false;
					_sfx.spatialBlend = 0f;
					_sfx.volume = 1f;
					_sfx.priority = 0;
				}
				if ((Object)(object)_action == (Object)null)
				{
					GameObject val2 = new GameObject("Empress Bowser Action SFX");
					val2.transform.SetParent(((Component)runner).transform, false);
					_action = val2.AddComponent<AudioSource>();
					_action.playOnAwake = false;
					_action.spatialBlend = 0f;
					_action.loop = false;
					_action.priority = 0;
				}
				if ((Object)(object)_loop == (Object)null)
				{
					GameObject val3 = new GameObject("Empress Bowser Loop SFX");
					val3.transform.SetParent(((Component)runner).transform, false);
					_loop = val3.AddComponent<AudioSource>();
					_loop.playOnAwake = false;
					_loop.spatialBlend = 0f;
					_loop.loop = true;
					_loop.priority = 0;
				}
				runner.StartCoroutine(LoadAll(directory, log));
			}
		}

		private static IEnumerator LoadAll(string directory, ManualLogSource log)
		{
			string[] files = Directory.GetFiles(directory, "*.ogg", SearchOption.TopDirectoryOnly);
			for (int i = 0; i < files.Length; i++)
			{
				yield return LoadOne(files[i], log);
			}
			if (log != null)
			{
				log.LogInfo((object)("Empress Bowser loaded " + Clips.Count + " sound(s). Music: " + ((Object)(object)MusicClip != (Object)null)));
			}
		}

		private static IEnumerator LoadOne(string path, ManualLogSource log)
		{
			string text = "file:///" + path.Replace("\\", "/");
			UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(text, (AudioType)14);
			try
			{
				yield return request.SendWebRequest();
				if (!string.IsNullOrEmpty(request.error))
				{
					if (log != null)
					{
						log.LogWarning((object)("Empress Bowser could not load " + Path.GetFileName(path) + ": " + request.error));
					}
					yield break;
				}
				AudioClip content = DownloadHandlerAudioClip.GetContent(request);
				if ((Object)(object)content == (Object)null)
				{
					yield break;
				}
				((Object)content).name = Path.GetFileNameWithoutExtension(path);
				Clips[((Object)content).name.ToLowerInvariant().TrimEnd('.')] = content;
			}
			finally
			{
				((IDisposable)request)?.Dispose();
			}
		}

		public static void Play(string key, float volumeScale = 1f)
		{
			if (Clips.TryGetValue(key, out var value) && !((Object)(object)value == (Object)null) && !((Object)(object)_sfx == (Object)null))
			{
				RouteSfx();
				float num = 1f;
				if (EmpressBowserPlugin.Settings != null)
				{
					num = EmpressBowserPlugin.Settings.SfxVolume.Value;
				}
				_sfx.PlayOneShot(value, Mathf.Clamp01(num * volumeScale));
			}
		}

		public static void PlayFirst(float volumeScale, params string[] keys)
		{
			for (int i = 0; i < keys.Length; i++)
			{
				if (Clips.ContainsKey(keys[i]))
				{
					Play(keys[i], volumeScale);
					break;
				}
			}
		}

		public static void PlayAction(string key, float volumeScale = 1f)
		{
			if (!((Object)(object)_action == (Object)null) && Clips.TryGetValue(key, out var value) && !((Object)(object)value == (Object)null))
			{
				StopFade();
				RouteAction();
				float num = ((EmpressBowserPlugin.Settings != null) ? EmpressBowserPlugin.Settings.SfxVolume.Value : 0.85f);
				_action.Stop();
				_action.clip = value;
				_action.volume = Mathf.Clamp01(num * volumeScale);
				_action.Play();
			}
		}

		public static void PlayActionFirst(float volumeScale, params string[] keys)
		{
			for (int i = 0; i < keys.Length; i++)
			{
				if (Clips.ContainsKey(keys[i]))
				{
					PlayAction(keys[i], volumeScale);
					break;
				}
			}
		}

		public static void PlayLoop(string key, float pitch, float volumeScale = 1f)
		{
			if (!((Object)(object)_loop == (Object)null) && Clips.TryGetValue(key, out var value) && !((Object)(object)value == (Object)null))
			{
				RouteLoop();
				float num = ((EmpressBowserPlugin.Settings != null) ? EmpressBowserPlugin.Settings.SfxVolume.Value : 0.85f);
				_loop.pitch = pitch;
				_loop.volume = Mathf.Clamp01(num * volumeScale);
				if ((Object)(object)_loop.clip != (Object)(object)value)
				{
					_loop.clip = value;
				}
				if (!_loop.isPlaying)
				{
					_loop.Play();
				}
			}
		}

		public static void StopLoop()
		{
			if ((Object)(object)_loop != (Object)null && _loop.isPlaying)
			{
				_loop.Stop();
			}
		}

		private static void RouteLoop()
		{
			if (!_loopRouted && !((Object)(object)_loop == (Object)null) && !((Object)(object)AudioManager.instance == (Object)null) && !((Object)(object)AudioManager.instance.SoundMasterGroup == (Object)null))
			{
				_loop.outputAudioMixerGroup = AudioManager.instance.SoundMasterGroup;
				_loopRouted = true;
			}
		}

		public static void FadeAction(float seconds)
		{
			if (!((Object)(object)_action == (Object)null) && _action.isPlaying)
			{
				StopFade();
				if ((Object)(object)_runner != (Object)null)
				{
					_fade = _runner.StartCoroutine(FadeRoutine(seconds));
				}
				else
				{
					_action.Stop();
				}
			}
		}

		private static IEnumerator FadeRoutine(float seconds)
		{
			float start = _action.volume;
			float elapsed = 0f;
			while (elapsed < seconds && _action.isPlaying)
			{
				elapsed += Time.deltaTime;
				_action.volume = Mathf.Lerp(start, 0f, elapsed / seconds);
				yield return null;
			}
			_action.Stop();
			_fade = null;
		}

		private static void StopFade()
		{
			if (_fade != null && (Object)(object)_runner != (Object)null)
			{
				_runner.StopCoroutine(_fade);
			}
			_fade = null;
		}

		private static void RouteSfx()
		{
			if (!_sfxRouted && !((Object)(object)_sfx == (Object)null) && !((Object)(object)AudioManager.instance == (Object)null) && !((Object)(object)AudioManager.instance.SoundMasterGroup == (Object)null))
			{
				_sfx.outputAudioMixerGroup = AudioManager.instance.SoundMasterGroup;
				_sfxRouted = true;
			}
		}

		private static void RouteAction()
		{
			if (!_actionRouted && !((Object)(object)_action == (Object)null) && !((Object)(object)AudioManager.instance == (Object)null) && !((Object)(object)AudioManager.instance.SoundMasterGroup == (Object)null))
			{
				_action.outputAudioMixerGroup = AudioManager.instance.SoundMasterGroup;
				_actionRouted = true;
			}
		}

		public static void ConfigureMusicSource(AudioSource source)
		{
			if (!((Object)(object)source == (Object)null))
			{
				source.volume = ((EmpressBowserPlugin.Settings != null) ? EmpressBowserPlugin.Settings.MusicVolume.Value : 0.25f);
				if (!_musicRouted && !((Object)(object)AudioManager.instance == (Object)null) && !((Object)(object)AudioManager.instance.MusicMasterGroup == (Object)null))
				{
					source.outputAudioMixerGroup = AudioManager.instance.MusicMasterGroup;
					_musicRouted = true;
				}
			}
		}
	}
	internal static class BowserActions
	{
		public const byte FireballSpawn = 1;

		public const byte PoundImpact = 2;

		public const byte KnockPulse = 3;

		public const byte ThrowHit = 4;

		public const byte Recovered = 5;

		public const byte Death = 6;

		public const byte LavaBomb = 7;

		public const byte StarSpawn = 8;

		public const byte StarPickup = 9;
	}
	internal sealed class BowserBoss
	{
		private const int StateIntro = 0;

		private const int StateIdle = 1;

		private const int StateMove = 2;

		private const int StateFire = 3;

		private const int StateBalls = 4;

		private const int StatePound = 5;

		private const int StateCharge = 6;

		private const int StateSwipe = 7;

		private const int StateVulnerable = 8;

		private const int StateGrabbed = 9;

		private const int StateThrown = 10;

		private const int StateReturn = 11;

		private const int StateDying = 12;

		private const int StateDone = 13;

		private const int StateWaiting = 14;

		private static readonly string[] AnimNames = new string[33]
		{
			"Wait", "Move", "FireBeamSign", "FireBeamStart", "FireBeam", "FireBeamEnd", "ThrowBallSign", "ThrowBallStart", "ThrowBall", "ThrowBallEnd",
			"HipDropSign", "HipDropStart", "HipDrop", "HipDropLand", "HipDropLandEnd", "AttackTailSign", "AttackTailStart", "AttackTail", "AttackTailEnd", "JumpSign",
			"JumpStart", "Jump", "JumpEnd", "Swoon", "DamageL", "DamageR", "DamageCollide", "DownLand", "DownLandEnd", "Die",
			"Angry", "SurpriseAngry", "Surprise"
		};

		private const int AnimWait = 0;

		private const int AnimMove = 1;

		private const int AnimFireSign = 2;

		private const int AnimFireStart = 3;

		private const int AnimFireLoop = 4;

		private const int AnimFireEnd = 5;

		private const int AnimBallSign = 6;

		private const int AnimBall = 8;

		private const int AnimBallEnd = 9;

		private const int AnimPoundSign = 10;

		private const int AnimPoundStart = 11;

		private const int AnimPoundAir = 12;

		private const int AnimPoundLand = 13;

		private const int AnimPoundLandEnd = 14;

		private const int AnimSwipeStart = 16;

		private const int AnimSwipe = 17;

		private const int AnimSwipeEnd = 18;

		private const int AnimJump = 21;

		private const int AnimJumpEnd = 22;

		private const int AnimSwoon = 23;

		private const int AnimCollide = 26;

		private const int AnimDownLand = 27;

		private const int AnimDie = 29;

		private const int AnimAngry = 30;

		private const int AnimRage = 31;

		private BowserRuntime _runtime;

		private BowserArenaInfo _arena;

		private Transform _root;

		private GameObject _model;

		private Animator _animator;

		private Transform _tailBone;

		private Transform _headBone;

		private Transform _mouthBone;

		private Renderer[] _renderers;

		private float _modelYOffset;

		private float _groundFix;

		private float _poseGroundOffset;

		private ParticleSystem _fireParticles;

		private Light _fireLight;

		private Transform _fireAnchor;

		private GameObject _tailGlow;

		private Light _tailGlowLight;

		private PhysGrabObject _tail;

		private Rigidbody _tailRb;

		private Vector3 _pos;

		private float _yaw;

		private Vector3 _renderPos;

		private float _renderYaw;

		private Vector3 _lastGrabDirection;

		private int _state;

		private int _animId;

		private float _animSpeed = 1f;

		private int _phase = 1;

		private int _hits;

		private bool _tailWindow;

		private bool _fireActive;

		private bool _raged;

		private float _timer;

		private float _sub;

		private float _grace;

		private float _attackCooldown = 2.5f;

		private float _swipeCooldown;

		private float _fireTick;

		private float _windowRemaining;

		private float _rageTimer;

		private int _rainBombsLeft;

		private float _rainBombTimer;

		private bool _lavaRainDone;

		private int _ballsLeft;

		private float _ballTimer;

		private Vector3 _from;

		private Vector3 _target;

		private Vector3 _chargeDir;

		private Vector3 _splash;

		private readonly HashSet<PlayerAvatar> _chargeVictims = new HashSet<PlayerAvatar>();

		public bool DeathComplete { get; private set; }

		public int Hits => _hits;

		public int Phase => _phase;

		public bool HasTail => (Object)(object)_tail != (Object)null;

		public PhysGrabObject Tail => _tail;

		public Vector3 SplashPoint => _splash;

		private float SpeedScale => (1f + 0.14f * (float)(_phase - 1)) * (_raged ? 1.2f : 1f);

		public static BowserBoss Create(BowserRuntime runtime, BowserArenaInfo arena)
		{
			BowserBoss bowserBoss = new BowserBoss();
			bowserBoss._runtime = runtime;
			bowserBoss._arena = arena;
			bowserBoss.Build();
			return bowserBoss;
		}

		private void Build()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0067: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Empress Bowser");
			val.transform.SetParent(_arena.BossHolder, false);
			_root = val.transform;
			_model = BowserModel.CreateInstance(_root);
			if ((Object)(object)_model != (Object)null)
			{
				float num = BowserModel.ComputeScale(_model);
				_model.transform.localScale = Vector3.one * num;
				Bounds val2 = BowserModel.ComputeBounds(_model);
				_modelYOffset = _root.position.y - ((Bounds)(ref val2)).min.y;
				_model.transform.localPosition = new Vector3(0f, _modelYOffset, 0f);
				_animator = _model.GetComponentInChildren<Animator>(true);
				_tailBone = BowserModel.FindTailBone(_model);
				_headBone = BowserModel.FindBone(_model, "head", deepest: false);
				_mouthBone = BowserModel.FindBone(_model, "mouth", deepest: false);
				_renderers = _model.GetComponentsInChildren<Renderer>(false);
				SkinnedMeshRenderer[] componentsInChildren = _model.GetComponentsInChildren<SkinnedMeshRenderer>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					componentsInChildren[i].updateWhenOffscreen = true;
				}
				BuildFireAnchor();
				BuildTailGlow();
				_model.SetActive(false);
			}
			else
			{
				EmpressBowserPlugin.Log.LogError((object)"Empress Bowser model unavailable, fight cannot start.");
			}
			_state = 14;
			_pos = _arena.Center + Vector3.up * 26f;
			_yaw = 180f;
			_renderPos = _pos;
			_renderYaw = _yaw;
			_lastGrabDirection = Forward();
			_timer = 0f;
			SetAnim(0, 1f);
			Apply(0.5f);
		}

		public void BeginIntro()
		{
			if (_state == 14)
			{
				_state = 0;
				_timer = 0f;
				_sub = 0f;
				SetAnim(21, 1f);
				IntroCue();
			}
		}

		private void IntroCue()
		{
			//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)
			SemiFunc.UIFocusText("BOWSER\nDodge his attacks, grab the glowing tail, throw him into the lava!", new Color(1f, 0.55f, 0.15f), Color.white, 6f);
		}

		private void BuildFireAnchor()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: 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_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Expected O, but got Unknown
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Expected O, but got Unknown
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Expected O, but got Unknown
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Empress Bowser Fire Anchor");
			Transform val2 = (((Object)(object)_root != (Object)null) ? _root : _model.transform);
			val.transform.SetParent(val2, false);
			_fireAnchor = val.transform;
			_fireParticles = val.AddComponent<ParticleSystem>();
			MainModule main = _fireParticles.main;
			((MainModule)(ref main)).loop = true;
			((MainModule)(ref main)).playOnAwake = false;
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.5f, 0.85f);
			((MainModule)(ref main)).startSpeed = new MinMaxCurve(13f, 17f);
			((MainModule)(ref main)).startSize = new MinMaxCurve(0.5f, 1.5f);
			((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(1f, 0.75f, 0.15f, 0.95f), new Color(1f, 0.3f, 0.04f, 0.9f));
			((MainModule)(ref main)).maxParticles = 700;
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			EmissionModule emission = _fireParticles.emission;
			((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(150f);
			ShapeModule shape = _fireParticles.shape;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4;
			((ShapeModule)(ref shape)).angle = 16f;
			((ShapeModule)(ref shape)).radius = 0.28f;
			SizeOverLifetimeModule sizeOverLifetime = _fireParticles.sizeOverLifetime;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, AnimationCurve.Linear(0f, 0.55f, 1f, 1.8f));
			ColorOverLifetimeModule colorOverLifetime = _fireParticles.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			Gradient val3 = new Gradient();
			val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[3]
			{
				new GradientColorKey(new Color(1f, 0.85f, 0.3f), 0f),
				new GradientColorKey(new Color(1f, 0.35f, 0.05f), 0.45f),
				new GradientColorKey(new Color(0.25f, 0.05f, 0.02f), 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[3]
			{
				new GradientAlphaKey(0.95f, 0f),
				new GradientAlphaKey(0.75f, 0.6f),
				new GradientAlphaKey(0f, 1f)
			});
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(val3);
			ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>();
			Shader val4 = Shader.Find("Particles/Standard Unlit");
			((Renderer)component).sharedMaterial = new Material(((Object)(object)val4 != (Object)null) ? val4 : Shader.Find("Standard"));
			GameObject val5 = new GameObject("Fire Light");
			val5.transform.SetParent(val.transform, false);
			val5.transform.localPosition = new Vector3(0f, 0f, 2.4f);
			_fireLight = val5.AddComponent<Light>();
			_fireLight.type = (LightType)2;
			_fireLight.color = new Color(1f, 0.5f, 0.1f);
			_fireLight.intensity = 0f;
			_fireLight.range = 18f;
			_fireParticles.Stop(true, (ParticleSystemStopBehavior)0);
		}

		private void BuildTailGlow()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Expected O, but got Unknown
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Expected O, but got Unknown
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_tailBone == (Object)null))
			{
				_tailGlow = new GameObject("Empress Bowser Tail Glow");
				_tailGlow.transform.SetParent(_tailBone, false);
				ParticleSystem obj = _tailGlow.AddComponent<ParticleSystem>();
				MainModule main = obj.main;
				((MainModule)(ref main)).loop = true;
				((MainModule)(ref main)).playOnAwake = true;
				((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(0.7f);
				((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.4f, 1.3f);
				((MainModule)(ref main)).startSize = new MinMaxCurve(0.07f, 0.2f);
				((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(1f, 0.9f, 0.35f, 1f), new Color(1f, 0.7f, 0.1f, 1f));
				((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
				EmissionModule emission = obj.emission;
				((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(46f);
				ShapeModule shape = obj.shape;
				((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
				((ShapeModule)(ref shape)).radius = 0.55f;
				ParticleSystemRenderer component = _tailGlow.GetComponent<ParticleSystemRenderer>();
				Shader val = Shader.Find("Particles/Standard Unlit");
				((Renderer)component).sharedMaterial = new Material(((Object)(object)val != (Object)null) ? val : Shader.Find("Standard"));
				GameObject val2 = new GameObject("Tail Light");
				val2.transform.SetParent(_tailGlow.transform, false);
				_tailGlowLight = val2.AddComponent<Light>();
				_tailGlowLight.type = (LightType)2;
				_tailGlowLight.color = new Color(1f, 0.82f, 0.25f);
				_tailGlowLight.intensity = 2.4f;
				_tailGlowLight.range = 7f;
				_tailGlow.SetActive(false);
			}
		}

		public void AssignTail(PhysGrabObject tail)
		{
			_tail = tail;
			_tailRb = (((Object)(object)tail != (Object)null) ? ((Component)tail).GetComponent<Rigidbody>() : null);
			BowserTail.Sanitize(tail);
		}

		private int ScaleDamage(int damage)
		{
			float num = (1f + 0.12f * (float)(_phase - 1)) * ((EmpressBowserPlugin.Settings != null) ? EmpressBowserPlugin.Settings.DamageScale.Value : 1f);
			return Mathf.Max(1, Mathf.RoundToInt((float)damage * num));
		}

		private float WindowSeconds(float typeScale)
		{
			float num = ((EmpressBowserPlugin.Settings != null) ? EmpressBowserPlugin.Settings.GrabWindowSeconds.Value : 6f);
			float num2 = ((_phase == 1) ? 1f : ((_phase == 2) ? 0.85f : 0.7f));
			return num * num2 * typeScale;
		}

		public void HostTick(float dt, List<PlayerAvatar> players)
		{
			if (_state == 13)
			{
				return;
			}
			_attackCooldown -= dt * SpeedScale;
			_swipeCooldown -= dt;
			if (_rageTimer > 0f)
			{
				_rageTimer -= dt;
				if (_rageTimer <= 0f)
				{
					_raged = false;
				}
			}
			if (_rainBombsLeft > 0 && _state != 12 && _state != 13)
			{
				_rainBombTimer -= dt;
				if (_rainBombTimer <= 0f)
				{
					_rainBombTimer = 0.16f;
					_rainBombsLeft--;
					LaunchRainBomb(players);
				}
			}
			switch (_state)
			{
			case 0:
				TickIntro(dt);
				break;
			case 1:
				TickIdle(dt, players);
				break;
			case 2:
				TickMove(dt, players);
				break;
			case 3:
				TickFire(dt, players);
				break;
			case 4:
				TickBalls(dt, players);
				break;
			case 5:
				TickPound(dt, players);
				break;
			case 6:
				TickCharge(dt, players);
				break;
			case 7:
				TickSwipe(dt, players);
				break;
			case 8:
				TickVulnerable(dt);
				break;
			case 10:
				TickThrown(dt);
				break;
			case 11:
				TickReturn(dt);
				break;
			case 12:
				TickDying(dt);
				break;
			}
			HostTail();
			Apply(dt);
		}

		private void TickIntro(float dt)
		{
			//IL_0027: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			_timer += dt;
			float num = Mathf.Clamp01(_timer / 1.35f);
			_pos = Vector3.Lerp(_arena.Center + Vector3.up * 20f, _arena.Center, num * num);
			if (_timer >= 1.35f && _timer < 1.4f && _sub < 0.5f)
			{
				_sub = 1f;
				Action(3, _pos.x, _pos.y, _pos.z, 6f, 9f);
				SetAnim(22, 1f);
			}
			if (_timer >= 1.9f && _sub < 1.5f)
			{
				_sub = 2f;
				SetAnim(30, 1f);
			}
			if (_timer >= 4f)
			{
				_sub = 0f;
				_timer = 0f;
				_grace = 1.5f;
				_attackCooldown = 1.2f;
				_state = 1;
				SetAnim(0, 1f);
			}
		}

		private void TickIdle(float dt, List<PlayerAvatar> players)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			PlayerAvatar val = Nearest(players);
			if ((Object)(object)val != (Object)null)
			{
				FaceToward(((Component)val).transform.position, dt, 120f);
			}
			if (_grace > 0f)
			{
				_grace -= dt;
			}
			else if ((Object)(object)val != (Object)null && _swipeCooldown <= 0f && FlatDistance(_pos, ((Component)val).transform.position) < 4.6f)
			{
				BeginSwipe();
			}
			else if (!(_attackCooldown > 0f) && !((Object)(object)val == (Object)null))
			{
				ChooseAttack(players, val);
			}
		}

		private void ChooseAttack(List<PlayerAvatar> players, PlayerAvatar target)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			float num = FlatDistance(_pos, ((Component)target).transform.position);
			if (num > 13f && Random.value < 0.55f)
			{
				BeginMove(target);
				return;
			}
			float num2 = ((num <= 13.5f) ? 3f : 0f);
			float num3 = 3f;
			float num4 = ((num <= 15f) ? 2.6f : 0f);
			float num5 = ((_phase >= 2) ? 2.8f : 0f);
			float num6 = num2 + num3 + num4 + num5;
			float num7 = Random.value * num6;
			if (num7 < num2)
			{
				BeginFire();
			}
			else if (num7 < num2 + num3)
			{
				BeginBalls();
			}
			else if (num7 < num2 + num3 + num4)
			{
				BeginPound(players);
			}
			else
			{
				BeginCharge(target);
			}
		}

		private void BeginMove(PlayerAvatar target)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			_state = 2;
			_timer = 0f;
			Vector3 val = ((Component)target).transform.position - _pos;
			val.y = 0f;
			Vector3 point = ((Component)target).transform.position - ((Vector3)(ref val)).normalized * 8f;
			_target = ClampToArena(point, 2.2f);
			SetAnim(1, SpeedScale);
		}

		private void TickMove(float dt, List<PlayerAvatar> players)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			_timer += dt;
			Vector3 val = _target - _pos;
			val.y = 0f;
			float num = 3.4f * SpeedScale * dt;
			if (((Vector3)(ref val)).magnitude <= num || _timer > 4.5f)
			{
				_state = 1;
				_attackCooldown = 0.35f;
				SetAnim(0, 1f);
			}
			else
			{
				_pos += ((Vector3)(ref val)).normalized * num;
				FaceToward(_pos + val, dt, 200f);
			}
		}

		private void BeginFire()
		{
			_state = 3;
			_timer = 0f;
			_sub = 0f;
			_fireTick = 0f;
			SetAnim(2, 1f);
		}

		private void TickFire(float dt, List<PlayerAvatar> players)
		{
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			_timer += dt;
			PlayerAvatar val = Nearest(players);
			if (_sub < 0.5f)
			{
				if (_timer >= 1.05f)
				{
					_sub = 1f;
					_timer = 0f;
					SetAnim(3, 1f);
				}
			}
			else if (_sub < 1.5f)
			{
				if (_timer >= 0.5f)
				{
					_sub = 2f;
					_timer = 0f;
					_fireActive = true;
					SetAnim(4, 1f);
				}
			}
			else if (_sub < 2.5f)
			{
				if ((Object)(object)val != (Object)null)
				{
					FaceToward(((Component)val).transform.position, dt, 34f + 6f * (float)_phase);
				}
				_fireTick -= dt;
				if (_fireTick <= 0f)
				{
					_fireTick = 0.45f;
					DamageCone(players, 15.5f, 42f, ScaleDamage(8));
				}
				if (_timer >= 3.4f)
				{
					_sub = 3f;
					_timer = 0f;
					_fireActive = false;
					SetAnim(5, 1f);
				}
			}
			else if (_timer >= 0.8f)
			{
				BeginVulnerable(1f);
			}
		}

		private void BeginBalls()
		{
			_state = 4;
			_timer = 0f;
			_sub = 0f;
			_ballsLeft = 1 + _phase * 2;
			_ballTimer = 0f;
			SetAnim(6, 1f);
		}

		private void TickBalls(float dt, List<PlayerAvatar> players)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			_timer += dt;
			PlayerAvatar val = Nearest(players);
			if ((Object)(object)val != (Object)null)
			{
				FaceToward(((Component)val).transform.position, dt, 90f);
			}
			if (_sub < 0.5f)
			{
				if (_timer >= 0.85f)
				{
					_sub = 1f;
					_timer = 0f;
					SetAnim(8, 1.1f);
				}
			}
			else if (_ballsLeft > 0)
			{
				_ballTimer -= dt;
				if (_ballTimer <= 0f)
				{
					_ballTimer = 0.52f;
					_ballsLeft--;
					ThrowFireball(players);
				}
			}
			else if (_sub < 1.5f)
			{
				_sub = 2f;
				_timer = 0f;
				SetAnim(9, 1f);
			}
			else if (_timer >= 0.7f)
			{
				_state = 1;
				_attackCooldown = Random.Range(1.4f, 2.4f) / SpeedScale;
				SetAnim(0, 1f);
			}
		}

		private void ThrowFireball(List<PlayerAvatar> players)
		{
			//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_0045: 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_0072: 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_001f: 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_002e: 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_0077: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: 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_00d1: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			PlayerAvatar val = RandomAlive(players);
			Vector3 val2 = MouthPosition();
			Vector3 val3 = (((Object)(object)val != (Object)null) ? (((Component)val).transform.position + new Vector3(Random.Range(-1.3f, 1.3f), 0f, Random.Range(-1.3f, 1.3f))) : ClampToArena(_pos + Forward() * 9f, 2f));
			float num = 1.35f;
			Vector3 val4 = val3 - val2;
			float num2 = 14f;
			Vector3 val5 = val4 / num;
			val5.y = (val3.y - val2.y) / num + 0.5f * num2 * num;
			Action(1, val2.x, val2.y, val2.z, val5.x, val5.y, val5.z);
		}

		private void BeginPound(List<PlayerAvatar> players)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			PlayerAvatar val = RandomAlive(players);
			_state = 5;
			_timer = 0f;
			_sub = 0f;
			_from = _pos;
			Vector3 point = (((Object)(object)val != (Object)null) ? ((Component)val).transform.position : _arena.Center);
			_target = ClampToArena(point, 2f);
			SetAnim(11, 1f);
		}

		private void TickPound(float dt, List<PlayerAvatar> players)
		{
			//IL_006f: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: 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)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			_timer += dt;
			if (_sub < 0.5f)
			{
				if (_timer >= 0.42f)
				{
					_sub = 1f;
					_timer = 0f;
					SetAnim(12, 1f);
				}
			}
			else if (_sub < 1.5f)
			{
				float num = Mathf.Clamp01(_timer / 1.05f);
				Vector3 pos = Vector3.Lerp(_from, _target, num);
				pos.y = Mathf.Lerp(_from.y, _target.y, num) + Mathf.Sin(num * MathF.PI) * 6f;
				_pos = pos;
				FaceToward(_target + (_target - _from), dt, 250f);
				if (num >= 1f)
				{
					_sub = 2f;
					_timer = 0f;
					_pos = _target;
					SetAnim(13, 1f);
					Action(2, _pos.x, _pos.y, _pos.z);
					DamageNear(players, _pos, 5.2f, ScaleDamage(25));
				}
			}
			else if (_sub < 2.5f)
			{
				if (_timer >= 0.55f)
				{
					_sub = 3f;
					_timer = 0f;
					SetAnim(14, 1f);
				}
			}
			else if (_timer >= 0.6f)
			{
				BeginVulnerable(0.75f);
			}
		}

		private void BeginCharge(PlayerAvatar target)
		{
			//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)
			_state = 6;
			_timer = 0f;
			_sub = 0f;
			_chargeVictims.Clear();
			_target = ((Component)target).transform.position;
			SetAnim(31, 1f);
		}

		private void TickCharge(float dt, List<PlayerAvatar> players)
		{
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			_timer += dt;
			if (_sub < 0.5f)
			{
				FaceToward(_target, dt, 160f);
				if (_timer >= 0.95f)
				{
					_sub = 1f;
					_timer = 0f;
					Vector3 val = _target - _pos;
					val.y = 0f;
					_chargeDir = ((((Vector3)(ref val)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val)).normalized : Forward());
					SetAnim(1, 2.3f);
				}
				return;
			}
			float num = 15f * SpeedScale;
			_pos += _chargeDir * num * dt;
			_yaw = Mathf.Atan2(_chargeDir.x, _chargeDir.z) * 57.29578f;
			for (int i = 0; i < players.Count; i++)
			{
				PlayerAvatar val2 = players[i];
				if (!((Object)(object)val2 == (Object)null) && !_chargeVictims.Contains(val2) && FlatDistance(_pos, ((Component)val2).transform.position) < 2.9f)
				{
					_chargeVictims.Add(val2);
					HurtPlayer(val2, ScaleDamage(28));
					Action(3, _pos.x, _pos.y, _pos.z, 4.2f, 13f);
				}
			}
			if (FlatDistance(_arena.Center, _pos) >= _arena.PlatformRadius - 1.7f || _timer > 3.5f)
			{
				_pos = ClampToArena(_pos, 1.6f);
				_sub = 2f;
				_timer = 0f;
				SetAnim(26, 1f);
				Action(3, _pos.x, _pos.y, _pos.z, 4.5f, 10f);
				BeginVulnerable(1.05f);
			}
		}

		private void BeginSwipe()
		{
			_state = 7;
			_timer = 0f;
			_sub = 0f;
			_swipeCooldown = 5.5f;
			SetAnim(16, 1.15f);
		}

		private void TickSwipe(float dt, List<PlayerAvatar> players)
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			_timer += dt;
			if (_sub < 0.5f)
			{
				if (_timer >= 0.35f)
				{
					_sub = 1f;
					_timer = 0f;
					SetAnim(17, 1.15f);
				}
			}
			else if (_sub < 1.5f)
			{
				if (_timer >= 0.34f && _sub < 1.25f)
				{
					_sub = 1.3f;
					DamageNear(players, _pos, 4.8f, ScaleDamage(16));
					Action(3, _pos.x, _pos.y, _pos.z, 5.5f, 12f);
				}
				if (_timer >= 0.85f)
				{
					_sub = 2f;
					_timer = 0f;
					SetAnim(18, 1f);
				}
			}
			else if (_timer >= 0.5f)
			{
				_state = 1;
				_attackCooldown = Random.Range(0.8f, 1.6f) / SpeedScale;
				SetAnim(0, 1f);
			}
		}

		private void BeginVulnerable(float typeScale)
		{
			_state = 8;
			_timer = 0f;
			_windowRemaining = WindowSeconds(typeScale);
			_tailWindow = true;
			_fireActive = false;
			_pos.y = _arena.PlatformY;
			_renderPos.y = Mathf.Min(_renderPos.y, _arena.PlatformY + 0.4f);
			SetAnim(27, 1f);
		}

		private void TickVulnerable(float dt)
		{
			_windowRemaining -= dt;
			_pos.y = Mathf.MoveTowards(_pos.y, _arena.PlatformY, 12f * dt);
			if (BowserTail.IsGrabbed(_tail))
			{
				BeginLaunch();
			}
			else if (_windowRemaining <= 0f)
			{
				EndWindow();
			}
		}

		private void BeginLaunch()
		{
			//IL_0021: 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_0026: 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_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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			Vector3 proxy = (((Object)(object)_tail != (Object)null) ? ((Component)_tail).transform.position : _pos);
			Vector3 val = GrabDirection(proxy, PrimaryGrabber());
			val.y = 0f;
			if (((Vector3)(ref val)).sqrMagnitude < 0.01f)
			{
				val = Forward();
			}
			val = (_lastGrabDirection = ((Vector3)(ref val)).normalized);
			_from = _pos;
			Vector3 target = _arena.Center + val * (_arena.PlatformRadius + 7.5f);
			target.y = _arena.LavaY;
			_target = target;
			_state = 10;
			_tailWindow = false;
			_timer = 0f;
			SetAnim(26, 1f);
			BowserAudio.PlayFirst(1f, "bowser_hurt");
			if ((Object)(object)_tail != (Object)null)
			{
				BowserTail.LockGrab(_tail);
			}
		}

		private void EndWindow()
		{
			_tailWindow = false;
			_state = 1;
			_attackCooldown = 1.1f / SpeedScale;
			SetAnim(30, 1f);
		}

		private void TickThrown(float dt)
		{
			//IL_0023: 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_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_006c: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: 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_0157: 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_0161: Unknown result type (might be due to invalid IL or missing references)
			_timer += dt;
			float num = 1.55f;
			float num2 = Mathf.Clamp01(_timer / num);
			Vector3 pos = Vector3.Lerp(_from, _target, num2);
			pos.y = Mathf.Lerp(_from.y, _target.y, num2) + Mathf.Sin(num2 * MathF.PI) * 10f;
			_pos = pos;
			_yaw += 460f * dt;
			if (!(num2 < 1f))
			{
				_hits++;
				_splash = new Vector3(_pos.x, _arena.LavaY, _pos.z);
				Action(4, _hits, _splash.x, _splash.y, _splash.z);
				ParkTail();
				int num3 = ((EmpressBowserPlugin.Settings != null) ? EmpressBowserPlugin.Settings.ThrowsToWin.Value : 3);
				if (_hits >= num3)
				{
					_state = 12;
					_timer = 0f;
					_pos = _splash + Vector3.up * 1.4f;
					SetAnim(29, 1f);
					Action(6, _splash.x, _splash.y, _splash.z);
				}
				else
				{
					_state = 11;
					_timer = 0f;
					_sub = 0f;
					_pos = _splash + Vector3.down * 5f;
				}
			}
		}

		private void ParkTail()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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)
			if (!((Object)(object)_tailRb == (Object)null))
			{
				_tailRb.velocity = Vector3.zero;
				_tailRb.angularVelocity = Vector3.zero;
				_tailRb.position = _arena.Center + Vector3.down * 30f;
			}
		}

		private PhysGrabber PrimaryGrabber()
		{
			if ((Object)(object)_tail == (Object)null || _tail.playerGrabbing == null)
			{
				return null;
			}
			for (int num = _tail.playerGrabbing.Count - 1; num >= 0; num--)
			{
				PhysGrabber val = _tail.playerGrabbing[num];
				if ((Object)(object)val != (Object)null && val.grabbed)
				{
					return val;
				}
			}
			return null;
		}

		private Vector3 GrabDirection(Vector3 proxy, PhysGrabber grabber)
		{
			//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_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_002e: 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)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: 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_008c: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)grabber != (Object)null && (Object)(object)grabber.playerAvatar != (Object)null)
			{
				Vector3 val = proxy - ((Component)grabber.playerAvatar).transform.position;
				val.y = 0f;
				if (((Vector3)(ref val)).sqrMagnitude > 0.04f)
				{
					return ((Vector3)(ref val)).normalized;
				}
				Transform val2 = (((Object)(object)grabber.playerAvatar.localCamera != (Object)null) ? grabber.playerAvatar.localCamera.GetOverrideTransform() : ((Component)grabber).transform);
				if ((Object)(object)val2 != (Object)null)
				{
					Vector3 forward = val2.forward;
					forward.y = 0f;
					if (((Vector3)(ref forward)).sqrMagnitude > 0.04f)
					{
						return ((Vector3)(ref forward)).normalized;
					}
				}
			}
			if ((Object)(object)_tailBone != (Object)null)
			{
				Vector3 val3 = _root.position - _tailBone.position;
				val3.y = 0f;
				if (((Vector3)(ref val3)).sqrMagnitude > 0.04f)
				{
					return ((Vector3)(ref val3)).normalized;
				}
			}
			if (!(((Vector3)(ref _lastGrabDirection)).sqrMagnitude > 0.04f))
			{
				return Forward();
			}
			return ((Vector3)(ref _lastGrabDirection)).normalized;
		}

		private void TickReturn(float dt)
		{
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: 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_0066: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			_timer += dt;
			if (_sub < 0.5f)
			{
				if (_timer >= 2.6f)
				{
					_sub = 1f;
					_timer = 0f;
					_from = new Vector3(_splash.x, _arena.LavaY - 1f, _splash.z);
					_target = _arena.Center;
					SetAnim(21, 1f);
				}
			}
			else if (_sub < 1.5f)
			{
				float num = Mathf.Clamp01(_timer / 1.35f);
				Vector3 pos = Vector3.Lerp(_from, _target, num);
				pos.y = Mathf.Lerp(_from.y, _target.y, num) + Mathf.Sin(num * MathF.PI) * 9f;
				_pos = pos;
				if (num >= 1f)
				{
					_sub = 2f;
					_timer = 0f;
					_phase = Mathf.Min(_hits + 1, 3);
					_raged = true;
					_rageTimer = 12f;
					Action(5, _phase);
					SetAnim(30, 1f);
					if (_phase >= 3 && !_lavaRainDone)
					{
						_lavaRainDone = true;
						_rainBombsLeft = 9;
						_rainBombTimer = 0.5f;
					}
				}
			}
			else if (_timer >= 1.4f)
			{
				_state = 1;
				_attackCooldown = 0.9f;
				SetAnim(0, 1f);
			}
		}

		private void TickDying(float dt)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			_timer += dt;
			_pos += Vector3.down * 0.75f * dt;
			_yaw += dt * 14f;
			if (_timer >= 5f)
			{
				_state = 13;
				DeathComplete = true;
			}
		}

		private void LaunchRainBomb(List<PlayerAvatar> players)
		{
			//IL_005a: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			PlayerAvatar val = ((Random.value < 0.55f) ? RandomAlive(players) : null);
			Vector3 val2;
			if ((Object)(object)val != (Object)null)
			{
				val2 = ((Component)val).transform.position + new Vector3(Random.Range(-2.5f, 2.5f), 0f, Random.Range(-2.5f, 2.5f));
			}
			else
			{
				Vector2 val3 = Random.insideUnitCircle * (_arena.PlatformRadius * 0.85f);
				val2 = _arena.Center + new Vector3(val3.x, 0f, val3.y);
			}
			float num = Mathf.Clamp(val2.x, _arena.Center.x - _arena.PlatformRadius, _arena.Center.x + _arena.PlatformRadius);
			float num2 = Mathf.Clamp(val2.z, _arena.Center.z - _arena.PlatformRadius, _arena.Center.z + _arena.PlatformRadius);
			Action(7, num, num2);
		}

		private void HostTail()
		{
			//IL_005b: 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_006a: Unknown result