Decompiled source of King Of The Coral Kin v1.0.3

KingOfTheCoralKin.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using HutongGames.PlayMaker;
using HutongGames.PlayMaker.Actions;
using Microsoft.CodeAnalysis;
using Silksong.FsmUtil;
using TeamCherry.Localization;
using UnityEngine;
using UnityEngine.SceneManagement;

[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("KingOfTheCoralKin")]
[assembly: AssemblyConfiguration("release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+0086cc18d0e10168b0b0039ffd4907282292b23c")]
[assembly: AssemblyProduct("KingOfTheCoralKin")]
[assembly: AssemblyTitle("KingOfTheCoralKin")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace KingOfTheCoralKin
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("io.github.kingofthecoralkin", "KingOfTheCoralKin", "0.1.0")]
	public class KingOfTheCoralKinPlugin : BaseUnityPlugin
	{
		private static class SpikePools
		{
			private static readonly List<GameObject> longSpear = new List<GameObject>();

			private static readonly List<GameObject> uppercutSpear = new List<GameObject>();

			private static readonly List<GameObject> airSpear = new List<GameObject>();

			public static List<GameObject> getReleveantPool()
			{
				return coralSpikeFSMState switch
				{
					CoralSpikeState.UPPERCUT => uppercutSpear, 
					CoralSpikeState.JAB => longSpear, 
					CoralSpikeState.AIRJAB => airSpear, 
					_ => null, 
				};
			}

			public static void resetPools()
			{
				longSpear.Clear();
				uppercutSpear.Clear();
				airSpear.Clear();
			}
		}

		private enum CoralSpikeState
		{
			UPPERCUT,
			JAB,
			AIRJAB
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass30_0
		{
			public string eventName;

			internal bool <ForceNextState>b__0(FsmTransition t)
			{
				return t.EventName == eventName;
			}
		}

		[CompilerGenerated]
		private sealed class <DisableClone>d__28 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public GameObject clone;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <DisableClone>d__28(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(3f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					clone.SetActive(false);
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <DisableCrossCooldown>d__33 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <DisableCrossCooldown>d__33(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(3f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					crossCooldown = false;
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <DisableCrossed>d__32 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <DisableCrossed>d__32(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(1.5f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					crossed = false;
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <DisableScheduledCoralRain>d__35 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <DisableScheduledCoralRain>d__35(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					scheduledCoralRain = false;
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <DisableThreeSpiked>d__34 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <DisableThreeSpiked>d__34(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(0.5f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					threeSpiked = false;
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <FadeTeleport>d__29 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <FadeTeleport>d__29(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					GameCameras.instance.cameraFadeFSM.SetState("Scene Fade Out");
					<>2__current = (object)new WaitForSeconds(1.5f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					GameCameras.instance.cameraFadeFSM.SetState("Scene Fade In");
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <ForceNextState>d__30 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public string eventName;

			public float delay;

			public FsmState state;

			private <>c__DisplayClass30_0 <>8__1;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <ForceNextState>d__30(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>8__1 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>8__1 = new <>c__DisplayClass30_0();
					<>8__1.eventName = eventName;
					<>2__current = (object)new WaitForSeconds(delay);
					<>1__state = 1;
					return true;
				case 1:
				{
					<>1__state = -1;
					FsmTransition val = ((IEnumerable<FsmTransition>)state.Transitions).FirstOrDefault((Func<FsmTransition, bool>)((FsmTransition t) => t.EventName == <>8__1.eventName));
					if (val != null)
					{
						state.Fsm.SetState(val.ToState);
					}
					return false;
				}
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <ScheduleNextState>d__31 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public float duration;

			public string stateName;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <ScheduleNextState>d__31(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(duration);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					bossControlFSM.SetState(stateName);
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <SpawnSpike>d__27 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public float delay;

			public GameObject go;

			public Vector3 direction;

			public int distance;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <SpawnSpike>d__27(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Expected O, but got Unknown
				//IL_0055: 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_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_0087: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
				//IL_0101: Unknown result type (might be due to invalid IL or missing references)
				//IL_010b: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(delay);
					<>1__state = 1;
					return true;
				case 1:
				{
					<>1__state = -1;
					GameObject newSpike = GetNewSpike(go);
					newSpike.transform.position = go.transform.position + direction * (float)distance;
					newSpike.transform.rotation = go.transform.rotation;
					newSpike.transform.localScale = go.transform.localScale;
					if (coralSpikeFSMState == CoralSpikeState.JAB)
					{
						Extensions.FlipLocalScale(newSpike.transform, true, false, false);
						newSpike.transform.position = new Vector3((newSpike.transform.position.x > 50f) ? 16.57f : 94.27f, newSpike.transform.position.y, newSpike.transform.position.z);
					}
					newSpike.SetActive(true);
					((MonoBehaviour)Instance).StartCoroutine(DisableClone(newSpike));
					return false;
				}
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <Start>d__21 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <Start>d__21(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(2f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					Harmony.CreateAndPatchAll(typeof(Language_Get_Patch), (string)null);
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private static bool inCoralMemory;

		private static bool teleportToBoss;

		private static bool disableContactDamage;

		private static HeroController? hornet;

		private static PlayMakerFSM? bossControlFSM;

		private static CoralSpikeState coralSpikeFSMState;

		private static bool P2;

		private static bool P3;

		private static bool scheduledCoralRain;

		private static int groundHits;

		private static bool crossed;

		private static bool threeSpiked;

		private static bool crossCooldown;

		public const string Id = "io.github.kingofthecoralkin";

		private static KingOfTheCoralKinPlugin Instance { get; set; }

		public static string Name => "KingOfTheCoralKin";

		public static string Version => "0.1.0";

		private void Awake()
		{
			Instance = this;
			teleportToBoss = ((BaseUnityPlugin)this).Config.Bind<bool>("King Of The Coral Kin", "TeleportOnSuperDash", true, "If true, the silksoar will take hornet directly up to the boss, skipping everything else").Value;
			disableContactDamage = ((BaseUnityPlugin)this).Config.Bind<bool>("King Of The Coral Kin", "DisableContactDamage", true, "If true, the boss contact damage will be disabled").Value;
			Harmony.CreateAndPatchAll(typeof(KingOfTheCoralKinPlugin), (string)null);
			SceneManager.sceneLoaded += sceneLoadSetup;
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Plugin " + Name + " (io.github.kingofthecoralkin) has loaded!"));
		}

		private void FixedUpdate()
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			if (inCoralMemory && hornet.cState.superDashing && teleportToBoss)
			{
				string activeStateName = GameCameras.instance.cameraFadeFSM.ActiveStateName;
				if ((!(activeStateName == "Scene Fade Out") && !(activeStateName == "Scene Fade In")) || 1 == 0)
				{
					((MonoBehaviour)Instance).StartCoroutine(FadeTeleport());
				}
				float y = hornet.transform.position.y;
				if (y > 40f && y < 50f)
				{
					hornet.transform.position = new Vector3(55.2f, 500f, 0.004f);
				}
			}
		}

		[IteratorStateMachine(typeof(<Start>d__21))]
		public IEnumerator Start()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Start>d__21(0);
		}

		[HarmonyPatch(typeof(ActivateGameObject), "OnEnter")]
		private static void Postfix(ActivateGameObject __instance)
		{
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: 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_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			if (!inCoralMemory || (Object)(object)__instance.activatedGameObject == (Object)null)
			{
				return;
			}
			GameObject activatedGameObject = __instance.activatedGameObject;
			if (!((Object)activatedGameObject).name.StartsWith("Coral_spear_long"))
			{
				return;
			}
			switch (coralSpikeFSMState)
			{
			case CoralSpikeState.UPPERCUT:
				((MonoBehaviour)Instance).StartCoroutine(SpawnSpike(activatedGameObject, P2 ? 8 : 10, Vector3.right, 0.05f));
				((MonoBehaviour)Instance).StartCoroutine(SpawnSpike(activatedGameObject, P2 ? (-8) : (-10), Vector3.right, 0.05f));
				if (P2)
				{
					((MonoBehaviour)Instance).StartCoroutine(SpawnSpike(activatedGameObject, 16, Vector3.right, 0.2f));
					((MonoBehaviour)Instance).StartCoroutine(SpawnSpike(activatedGameObject, -16, Vector3.right, 0.2f));
					((MonoBehaviour)Instance).StartCoroutine(SpawnSpike(activatedGameObject, 24, Vector3.right, 0.3f));
					((MonoBehaviour)Instance).StartCoroutine(SpawnSpike(activatedGameObject, -24, Vector3.right, 0.3f));
				}
				if (P3 && !threeSpiked)
				{
					threeSpiked = true;
					((MonoBehaviour)Instance).StartCoroutine(SpawnSpike(activatedGameObject, Extensions.GetRandomElement<int>(new int[2] { 4, -4 }), Vector3.right, 0.1f));
					((MonoBehaviour)Instance).StartCoroutine(DisableThreeSpiked());
				}
				break;
			case CoralSpikeState.JAB:
			{
				GameObject newSpike2 = GetNewSpike(activatedGameObject);
				newSpike2.transform.position = activatedGameObject.transform.position;
				newSpike2.transform.rotation = activatedGameObject.transform.rotation;
				newSpike2.transform.localScale = activatedGameObject.transform.localScale;
				newSpike2.SetActive(true);
				((MonoBehaviour)Instance).StartCoroutine(DisableClone(newSpike2));
				activatedGameObject.SetActive(false);
				if (!crossed)
				{
					((MonoBehaviour)Instance).StartCoroutine(SpawnSpike(activatedGameObject, P2 ? Extensions.GetRandomElement<int>(new int[2] { 4, 8 }) : 8, Vector3.up, 0.1f));
				}
				else
				{
					crossed = false;
					((MonoBehaviour)Instance).StartCoroutine(SpawnSpike(activatedGameObject, 8, Vector3.up, 0.1f));
				}
				break;
			}
			case CoralSpikeState.AIRJAB:
			{
				GameObject newSpike = GetNewSpike(activatedGameObject);
				newSpike.transform.position = activatedGameObject.transform.position;
				newSpike.transform.rotation = activatedGameObject.transform.rotation;
				newSpike.transform.localScale = activatedGameObject.transform.localScale;
				newSpike.SetActive(true);
				((MonoBehaviour)Instance).StartCoroutine(DisableClone(newSpike));
				((MonoBehaviour)Instance).StartCoroutine(SpawnSpike(activatedGameObject, P2 ? 11 : 12, Vector3.right, 0.05f));
				((MonoBehaviour)Instance).StartCoroutine(SpawnSpike(activatedGameObject, P2 ? (-11) : (-12), Vector3.right, 0.05f));
				if (P2)
				{
					((MonoBehaviour)Instance).StartCoroutine(SpawnSpike(activatedGameObject, 22, Vector3.right, 0.2f));
					((MonoBehaviour)Instance).StartCoroutine(SpawnSpike(activatedGameObject, -22, Vector3.right, 0.2f));
					((MonoBehaviour)Instance).StartCoroutine(SpawnSpike(activatedGameObject, 33, Vector3.right, 0.3f));
					((MonoBehaviour)Instance).StartCoroutine(SpawnSpike(activatedGameObject, -33, Vector3.right, 0.3f));
				}
				if (P3)
				{
					((MonoBehaviour)Instance).StartCoroutine(SpawnSpike(activatedGameObject, Extensions.GetRandomElement<int>(new int[2] { 5, -5 }), Vector3.right, 0.1f));
				}
				break;
			}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(FsmState), "OnEnter")]
		private static void OnFsmStateEntered(FsmState __instance)
		{
			//IL_0506: Unknown result type (might be due to invalid IL or missing references)
			if (!inCoralMemory)
			{
				return;
			}
			string name = __instance.name;
			if (name == null)
			{
				return;
			}
			switch (name.Length)
			{
			case 7:
				switch (name[0])
				{
				case 'D':
					if (!(name == "Drop In"))
					{
						break;
					}
					bossControlFSM = __instance.Fsm.FsmComponent;
					if (disableContactDamage)
					{
						DamageHero[] componentsInChildren = ((Component)bossControlFSM).gameObject.GetComponentsInChildren<DamageHero>(true);
						for (int i = 0; i < componentsInChildren.Length; i++)
						{
							Object.Destroy((Object)(object)componentsInChildren[i]);
						}
					}
					setupBossValues();
					P2 = (P3 = false);
					scheduledCoralRain = false;
					groundHits = 0;
					SpikePools.resetPools();
					break;
				case 'P':
					if (name == "P3 Roar")
					{
						((MonoBehaviour)Instance).StartCoroutine(ScheduleNextState(Extensions.GetRandomElement<string>(new string[4] { "UC Antic", "Air Jab Aim", "Cross Antic", "Jab Dir" }), 1f));
					}
					break;
				case 'C':
					if (name == "Cross 2")
					{
						crossed = true;
						crossCooldown = true;
						((MonoBehaviour)Instance).StartCoroutine(DisableCrossed());
						((MonoBehaviour)Instance).StartCoroutine(DisableCrossCooldown());
						((MonoBehaviour)Instance).StartCoroutine(ForceNextState(__instance, "CROSS CHOP", 0.05f));
					}
					break;
				}
				break;
			case 11:
				switch (name[0])
				{
				default:
					return;
				case 'H':
					if (name == "Hornet Dead")
					{
						P2 = (P3 = false);
						scheduledCoralRain = false;
						groundHits = 0;
						crossed = false;
						SpikePools.resetPools();
					}
					return;
				case 'C':
					if (name == "Cross Antic" && crossCooldown)
					{
						PlayMakerFSM val = bossControlFSM;
						val.SetState(coralSpikeFSMState switch
						{
							CoralSpikeState.UPPERCUT => (Random.value < 0.5f) ? "Air Jab Aim" : "Jab Dir", 
							CoralSpikeState.JAB => (Random.value < 0.5f) ? "Air Jab Aim" : "UC Antic", 
							CoralSpikeState.AIRJAB => (Random.value < 0.5f) ? "UC Antic" : "Jab Dir", 
							_ => null, 
						});
						crossCooldown = false;
					}
					return;
				case 'S':
					break;
				}
				if (!(name == "Shoot Antic"))
				{
					break;
				}
				goto IL_04a2;
			case 13:
				switch (name[0])
				{
				case 'D':
					if (name == "Death Stagger")
					{
						inCoralMemory = false;
						P2 = (P3 = false);
						scheduledCoralRain = false;
						groundHits = 0;
						crossed = false;
						SpikePools.resetPools();
						((MonoBehaviour)Instance).StopAllCoroutines();
					}
					break;
				case 'A':
					if (name == "Air Jab Antic")
					{
						coralSpikeFSMState = CoralSpikeState.AIRJAB;
					}
					break;
				}
				break;
			case 2:
				switch (name[1])
				{
				case '2':
					if (name == "P2" && !P2)
					{
						P2 = true;
						((MonoBehaviour)Instance).StartCoroutine(ForceNextState(__instance, "PHASE ROAR", 0f));
					}
					break;
				case '3':
					if (name == "P3" && !P3)
					{
						P3 = true;
						((MonoBehaviour)Instance).StartCoroutine(ForceNextState(__instance, "PHASE ROAR", 0f));
					}
					break;
				}
				break;
			case 9:
				switch (name[0])
				{
				default:
					return;
				case 'J':
					if (name == "Jab Antic")
					{
						if (coralSpikeFSMState == CoralSpikeState.JAB)
						{
							bossControlFSM.SetState(Extensions.GetRandomElement<string>(new string[3] { "Cross Antic", "Air Jab Aim", "UC Antic" }));
						}
						else
						{
							coralSpikeFSMState = CoralSpikeState.JAB;
						}
					}
					return;
				case 'S':
					break;
				}
				if (!(name == "Shoot Pos"))
				{
					break;
				}
				goto IL_04a2;
			case 8:
				if (name == "UC Antic")
				{
					if (coralSpikeFSMState == CoralSpikeState.UPPERCUT)
					{
						bossControlFSM.SetState("Air Jab Aim");
					}
					else
					{
						coralSpikeFSMState = CoralSpikeState.UPPERCUT;
					}
				}
				break;
			case 10:
				if (name == "Ground Hit")
				{
					if (groundHits >= 2)
					{
						groundHits = 0;
					}
					else
					{
						((MonoBehaviour)Instance).StartCoroutine(ScheduleNextState("Ground Hit", 0.35f));
					}
					groundHits++;
				}
				break;
			case 5:
			{
				if (!(name == "Antic") || !((Object)__instance.Fsm.FsmComponent).name.StartsWith("Coral Spike"))
				{
					break;
				}
				PlayMakerFSM fsmComponent = __instance.Fsm.FsmComponent;
				if (P3)
				{
					((MonoBehaviour)Instance).StartCoroutine(ScheduleNextState("Air Jab Aim", 1.2f));
					if (((Component)fsmComponent).transform.position.y > 557f)
					{
						Object.Destroy((Object)(object)((Component)fsmComponent).gameObject);
					}
					if (!scheduledCoralRain)
					{
						scheduledCoralRain = true;
						((MonoBehaviour)Instance).StartCoroutine(ScheduleNextState("Ground Hit", 0.2f));
						((MonoBehaviour)Instance).StartCoroutine(DisableScheduledCoralRain());
					}
				}
				break;
			}
			case 3:
			case 4:
			case 6:
			case 12:
				break;
				IL_04a2:
				bossControlFSM.SetState("P3");
				break;
			}
		}

		private static void sceneLoadSetup(Scene scene, LoadSceneMode mode)
		{
			if (((Scene)(ref scene)).name != "Memory_Coral_Tower")
			{
				inCoralMemory = false;
				return;
			}
			inCoralMemory = true;
			hornet = HeroController.instance;
			PlayerData.instance.encounteredCoralKing = true;
		}

		private static GameObject GetNewSpike(GameObject go)
		{
			List<GameObject> releveantPool = SpikePools.getReleveantPool();
			GameObject val = null;
			bool flag = false;
			for (int i = 0; i < releveantPool.Count; i++)
			{
				if (!releveantPool[i].activeSelf)
				{
					val = releveantPool[i];
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				val = Object.Instantiate<GameObject>(go, go.transform.parent);
				GameObject obj = val;
				((Object)obj).name = ((Object)obj).name + "_POOLED";
				releveantPool.Add(val);
			}
			return val;
		}

		private static void setupBossValues()
		{
			Object.Destroy((Object)(object)FSMUtility.LocateMyFSM(((Component)bossControlFSM).gameObject, "Stun Control"));
			FsmUtil.GetFirstActionOfType<SetFloatValue>(bossControlFSM, "P1").floatVariable = FsmFloat.op_Implicit(0f);
			FsmUtil.GetFirstActionOfType<SetFloatValue>(bossControlFSM, "P1").floatValue = FsmFloat.op_Implicit(0f);
			FsmUtil.GetFirstActionOfType<SetFloatValue>(bossControlFSM, "P2").floatVariable = FsmFloat.op_Implicit(0f);
			FsmUtil.GetFirstActionOfType<SetFloatValue>(bossControlFSM, "P2").floatValue = FsmFloat.op_Implicit(0f);
			FsmUtil.GetFirstActionOfType<SetFloatValue>(bossControlFSM, "P3").floatVariable = FsmFloat.op_Implicit(0f);
			FsmUtil.GetFirstActionOfType<SetFloatValue>(bossControlFSM, "P3").floatValue = FsmFloat.op_Implicit(0f);
			FsmUtil.GetFirstActionOfType<FloatOperator>(bossControlFSM, "Roar Recover").float1 = FsmFloat.op_Implicit(0.5f);
			FsmUtil.GetFirstActionOfType<Wait>(bossControlFSM, "Jab 2").time = FsmFloat.op_Implicit(0.5f);
			FsmUtil.GetFirstActionOfType<Wait>(bossControlFSM, "Uppercut 2").time = FsmFloat.op_Implicit(0.5f);
			FsmUtil.GetFirstActionOfType<Wait>(bossControlFSM, "Cross 2").time = FsmFloat.op_Implicit(0.5f);
			FsmUtil.GetFirstActionOfType<Wait>(bossControlFSM, "Air Jab 2").time = FsmFloat.op_Implicit(0.5f);
			FsmUtil.GetFirstActionOfType<Wait>(bossControlFSM, "Cross Followup 2").time = FsmFloat.op_Implicit(0.5f);
			FsmUtil.GetFirstActionOfType<Wait>(bossControlFSM, "Ground Hit").time = FsmFloat.op_Implicit(0.5f);
			FsmUtil.GetLastActionOfType<Wait>(bossControlFSM, "Ground Hit").time = FsmFloat.op_Implicit(0.5f);
			FsmUtil.GetFirstActionOfType<Wait>(bossControlFSM, "Followup Pause").time = FsmFloat.op_Implicit(0f);
		}

		[IteratorStateMachine(typeof(<SpawnSpike>d__27))]
		private static IEnumerator SpawnSpike(GameObject go, int distance, Vector3 direction, float delay)
		{
			//IL_0015: 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)
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <SpawnSpike>d__27(0)
			{
				go = go,
				distance = distance,
				direction = direction,
				delay = delay
			};
		}

		[IteratorStateMachine(typeof(<DisableClone>d__28))]
		private static IEnumerator DisableClone(GameObject clone)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DisableClone>d__28(0)
			{
				clone = clone
			};
		}

		[IteratorStateMachine(typeof(<FadeTeleport>d__29))]
		private static IEnumerator FadeTeleport()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <FadeTeleport>d__29(0);
		}

		[IteratorStateMachine(typeof(<ForceNextState>d__30))]
		private static IEnumerator ForceNextState(FsmState state, string eventName, float delay)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ForceNextState>d__30(0)
			{
				state = state,
				eventName = eventName,
				delay = delay
			};
		}

		[IteratorStateMachine(typeof(<ScheduleNextState>d__31))]
		private static IEnumerator ScheduleNextState(string stateName, float duration)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ScheduleNextState>d__31(0)
			{
				stateName = stateName,
				duration = duration
			};
		}

		[IteratorStateMachine(typeof(<DisableCrossed>d__32))]
		private static IEnumerator DisableCrossed()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DisableCrossed>d__32(0);
		}

		[IteratorStateMachine(typeof(<DisableCrossCooldown>d__33))]
		private static IEnumerator DisableCrossCooldown()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DisableCrossCooldown>d__33(0);
		}

		[IteratorStateMachine(typeof(<DisableThreeSpiked>d__34))]
		private static IEnumerator DisableThreeSpiked()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DisableThreeSpiked>d__34(0);
		}

		[IteratorStateMachine(typeof(<DisableScheduledCoralRain>d__35))]
		private static IEnumerator DisableScheduledCoralRain()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DisableScheduledCoralRain>d__35(0);
		}
	}
	[HarmonyPatch(typeof(Language), "Get")]
	[HarmonyPatch(new Type[]
	{
		typeof(string),
		typeof(string)
	})]
	public static class Language_Get_Patch
	{
		private static void Postfix(string key, string sheetTitle, ref string __result)
		{
			if (key == "CORAL_KING_SUPER")
			{
				__result = "King Of The";
			}
			if (key == "CORAL_KING_MAIN")
			{
				__result = "Coral Kin";
			}
		}
	}
}