Decompiled source of SilkenSisters v0.4.7

SilkenSisters.dll

Decompiled 7 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using HutongGames.PlayMaker;
using HutongGames.PlayMaker.Actions;
using Microsoft.CodeAnalysis;
using PrepatcherPlugin;
using SilkenSisters.Behaviors;
using SilkenSisters.Patches;
using SilkenSisters.Utils;
using Silksong.AssetHelper.ManagedAssets;
using Silksong.DataManager;
using Silksong.FsmUtil;
using Silksong.UnityHelper.Extensions;
using TeamCherry.Localization;
using UnityEngine;
using UnityEngine.Events;
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("SilkenSisters")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.4.7.0")]
[assembly: AssemblyInformationalVersion("0.4.7+c49bb8fbf82deb8d58b2e0262d63a13df04f7e88")]
[assembly: AssemblyProduct("SilkenSisters")]
[assembly: AssemblyTitle("SilkenSisters")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/al3ks1s/SilkenSisters")]
[assembly: NeutralResourcesLanguage("EN")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.4.7.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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")]
	[Microsoft.CodeAnalysis.Embedded]
	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")]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace Microsoft.CodeAnalysis
{
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace SilkenSisters
{
	public class SaveData
	{
		public bool laceMourned { get; set; }
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("io.github.al3ks1s.silkensisters", "SilkenSisters", "0.4.7")]
	public class SilkenSisters : BaseUnityPlugin, ISaveDataMod<SaveData>, IRawSaveDataMod
	{
		[CompilerGenerated]
		private sealed class <WaitAndPatch>d__33 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public SilkenSisters <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Expected O, but got Unknown
				int num = <>1__state;
				SilkenSisters silkenSisters = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(10f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					silkenSisters._langagepatches = 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();
			}
		}

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

			private object <>2__current;

			public SilkenSisters <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0127: Unknown result type (might be due to invalid IL or missing references)
				//IL_020c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0216: Expected O, but got Unknown
				//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				SilkenSisters silkenSisters = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = ((MonoBehaviour)silkenSisters).StartCoroutine(silkenSisters.assetManager.CacheObjects());
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (!isMemory() && canSetupMemoryFight())
					{
						Log.LogDebug((object)"[preloadOrgan] Is not memory and all requirements met, setting things up");
						silkenSisters.setupDeepMemoryZone();
					}
					else if (!isMemory() && canSetupNormalFight())
					{
						Log.LogDebug((object)"[preloadOrgan] Setting up normal fight");
						silkenSisters.setupNormalFight();
					}
					else
					{
						Log.LogDebug((object)$"[preloadOrgan] Scene info: canSetup?:{canSetupMemoryFight()}, isMemory?:{isMemory()}");
						if (!isMemory() && !canSetupMemoryFight() && !canSetupNormalFight())
						{
							Log.LogDebug((object)"[preloadOrgan] Displaying the info prompt");
							silkenSisters.infoPromptInstance = ManagedAssetExtensions.InstantiateAsset<GameObject>(silkenSisters.assetManager.sceneCache, "infoPromptCache");
							silkenSisters.infoPromptInstance.AddComponent<InfoPrompt>();
							silkenSisters.infoPromptInstance.SetActive(true);
						}
					}
					if (PlayerDataAccess.defeatedPhantom)
					{
						silkenSisters.phantomBossScene = UnityExtensions.FindGameObject(SceneManager.GetActiveScene(), "Boss Scene");
						GameObject obj = UnityExtensions.FindChild(instance.phantomBossScene, "Return Mask");
						GameObject val2 = UnityExtensions.FindChild(instance.phantomBossScene, "Return Mask/Death Pin");
						Extensions.SetPosition3D(obj.transform, 84.4431f, 107.719f, 3.5096f);
						Extensions.SetRotationZ(obj.transform, 2.1319f);
						Extensions.SetPosition3D(val2.transform, 83.7081f, 107.4613f, 3.5106f);
						Extensions.SetRotationZ(val2.transform, 239.2857f);
					}
					if (canSetupLaceInteraction())
					{
						silkenSisters.phantomBossScene = UnityExtensions.FindGameObject(SceneManager.GetActiveScene(), "Boss Scene");
						silkenSisters.laceNPCInstance = ManagedAssetExtensions.InstantiateAsset<GameObject>(silkenSisters.assetManager.sceneCache, "laceNPCCache");
						silkenSisters.laceNPCInstance.AddComponent<LaceMourning>();
						silkenSisters.laceNPCInstance.SetActive(true);
					}
					<>2__current = (object)new WaitForSeconds(0.2f);
					<>1__state = 2;
					return true;
				case 2:
				{
					<>1__state = -1;
					GameObject val = GameObject.Find("Deep Memory Enter Black(Clone)");
					if ((Object)(object)val != (Object)null)
					{
						Log.LogDebug((object)"[preloadOrgan] Deleting leftover memory effect");
						Object.Destroy((Object)(object)val);
					}
					val = GameObject.Find("Deep Memory Pre Enter Effect(Clone)");
					if ((Object)(object)val != (Object)null)
					{
						Extensions.SetPosition2D(val.transform, -100f, -100f);
					}
					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();
			}
		}

		public static SilkenSisters instance;

		private SaveData _saveData = new SaveData();

		internal AssetManager assetManager = new AssetManager();

		internal SilkenSistersConfig configManager = new SilkenSistersConfig();

		public FsmState ExitMemoryCache;

		public GameObject silkflies;

		public GameObject laceNPCInstance;

		public FsmOwnerDefault laceNPCFSMOwner;

		public GameObject laceBossInstance;

		public GameObject laceBossSceneInstance;

		public FsmOwnerDefault laceBossFSMOwner;

		public FsmOwnerDefault phantomBossFSMOwner;

		public GameObject challengeDialogInstance;

		public GameObject wakeupPointInstance;

		public GameObject respawnPointInstance;

		public GameObject deepMemoryInstance;

		public GameObject infoPromptInstance;

		public GameObject syncedFightSwapLeverInstance;

		public GameObject phantomBossScene;

		public FsmOwnerDefault phantomBossSceneFSMOwner;

		public static GameObject hornet;

		public static FsmOwnerDefault hornetFSMOwner;

		public static ConstrainPosition hornetConstrain;

		internal static ManualLogSource Log;

		internal Harmony _utilitypatches;

		internal Harmony _langagepatches;

		internal Harmony _encounterpatches;

		internal Harmony _debugatches;

		public const string Id = "io.github.al3ks1s.silkensisters";

		public SaveData SaveData
		{
			get
			{
				return _saveData;
			}
			[param: AllowNull]
			set
			{
				_saveData = value ?? new SaveData();
			}
		}

		public static string Name => "SilkenSisters";

		public static string Version => "0.4.7";

		private void Awake()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			instance = this;
			Log = new ManualLogSource("SilkenSisters");
			Logger.Sources.Add((ILogSource)(object)Log);
			configManager.BindConfig(((BaseUnityPlugin)this).Config);
			assetManager.RequestAssets();
			SceneManager.sceneLoaded += onSceneLoaded;
			_encounterpatches = Harmony.CreateAndPatchAll(typeof(EncounterPatches), (string)null);
			_utilitypatches = Harmony.CreateAndPatchAll(typeof(UtilityPatches), (string)null);
			((MonoBehaviour)this).StartCoroutine(WaitAndPatch());
			Log.LogMessage((object)"Plugin loaded and initialized");
		}

		private void OnDestroy()
		{
			clearInstances();
			assetManager.ClearCache();
			_langagepatches.UnpatchSelf();
			_encounterpatches.UnpatchSelf();
			_utilitypatches.UnpatchSelf();
		}

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

		public static bool canSetupLaceInteraction()
		{
			//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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			ManualLogSource log = Log;
			string[] obj = new string[6] { "[CanSetupLaceInteraction] Scene:", null, null, null, null, null };
			Scene activeScene = SceneManager.GetActiveScene();
			obj[1] = ((Scene)(ref activeScene)).name;
			obj[2] = " ";
			obj[3] = $"DefeatedLace2:{PlayerDataAccess.defeatedLaceTower} ";
			obj[4] = $"DefeatedPhantom:{PlayerDataAccess.defeatedPhantom} ";
			obj[5] = $"Act3:{PlayerDataAccess.blackThreadWorld}";
			log.LogDebug((object)string.Concat(obj));
			activeScene = SceneManager.GetActiveScene();
			if (((Scene)(ref activeScene)).name == "Organ_01" && !PlayerDataAccess.defeatedLaceTower && PlayerDataAccess.defeatedPhantom && !PlayerDataAccess.blackThreadWorld && !instance.SaveData.laceMourned)
			{
				return false;
			}
			return false;
		}

		public static bool canSetupMemoryFight()
		{
			//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_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)
			ManualLogSource log = Log;
			string[] obj = new string[7] { "[CanSetup] Scene:", null, null, null, null, null, null };
			Scene activeScene = SceneManager.GetActiveScene();
			obj[1] = ((Scene)(ref activeScene)).name;
			obj[2] = " ";
			obj[3] = $"DefeatedLace2:{PlayerDataAccess.defeatedLaceTower} ";
			obj[4] = $"DefeatedPhantom:{PlayerDataAccess.defeatedPhantom} ";
			obj[5] = $"Act3:{PlayerDataAccess.blackThreadWorld} ";
			obj[6] = $"Needolin:{PlayerDataAccess.hasNeedolinMemoryPowerup}";
			log.LogDebug((object)string.Concat(obj));
			activeScene = SceneManager.GetActiveScene();
			if (((Scene)(ref activeScene)).name == "Organ_01" && PlayerDataAccess.defeatedLaceTower && PlayerDataAccess.defeatedPhantom && PlayerDataAccess.blackThreadWorld)
			{
				return PlayerDataAccess.hasNeedolinMemoryPowerup;
			}
			return false;
		}

		public static bool canSetupNormalFight()
		{
			//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_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)
			ManualLogSource log = Log;
			string[] obj = new string[7] { "[CanSetup] Scene:", null, null, null, null, null, null };
			Scene activeScene = SceneManager.GetActiveScene();
			obj[1] = ((Scene)(ref activeScene)).name;
			obj[2] = " ";
			obj[3] = $"DefeatedLace1:{PlayerDataAccess.defeatedLace1} ";
			obj[4] = $"DefeatedLace2:{PlayerDataAccess.defeatedLaceTower} ";
			obj[5] = $"DefeatedPhantom:{PlayerDataAccess.defeatedPhantom} ";
			obj[6] = $"Act3:{PlayerDataAccess.blackThreadWorld}";
			log.LogDebug((object)string.Concat(obj));
			activeScene = SceneManager.GetActiveScene();
			if (((Scene)(ref activeScene)).name == "Organ_01" && !PlayerDataAccess.defeatedLace1 && !PlayerDataAccess.defeatedLaceTower && !PlayerDataAccess.defeatedPhantom)
			{
				return !PlayerDataAccess.blackThreadWorld;
			}
			return false;
		}

		public static bool isMemory()
		{
			//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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			ManualLogSource log = Log;
			string[] obj = new string[6] { "[isMemory] Scene:", null, null, null, null, null };
			Scene activeScene = SceneManager.GetActiveScene();
			obj[1] = ((Scene)(ref activeScene)).name;
			obj[2] = " ";
			obj[3] = $"DefeatedPhantom:{PlayerDataAccess.defeatedPhantom} ";
			obj[4] = $"Act3:{PlayerDataAccess.blackThreadWorld} ";
			obj[5] = $"Needolin:{PlayerDataAccess.hasNeedolinMemoryPowerup}";
			log.LogDebug((object)string.Concat(obj));
			activeScene = SceneManager.GetActiveScene();
			if (((Scene)(ref activeScene)).name == "Organ_01" && !PlayerDataAccess.defeatedPhantom && !PlayerDataAccess.blackThreadWorld)
			{
				return PlayerDataAccess.hasNeedolinMemoryPowerup;
			}
			return false;
		}

		private void onSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			Log.LogDebug((object)$"[onSceneLoaded] Scene loaded : {((Scene)(ref scene)).name}, active scene : {SceneManager.GetActiveScene()}, Path:{((Scene)(ref scene)).path}");
			if (((Scene)(ref scene)).name == "Organ_01")
			{
				Log.LogDebug((object)"[onSceneLoaded] Organ Detected, preloading");
				FindHornet();
				((MonoBehaviour)this).StartCoroutine(preloadOrgan());
			}
			else
			{
				Log.LogDebug((object)"[onSceneLoaded] Scene is not organ, clearing instances");
				clearInstances();
			}
			if (((Scene)(ref scene)).name == "Quit_To_Menu")
			{
				PlayerDataVariableEvents.OnGetBool -= PrepatcherUtils.SilkenSisterMonitor;
				clearInstances();
				assetManager.ClearCache();
			}
		}

		[IteratorStateMachine(typeof(<preloadOrgan>d__39))]
		private IEnumerator preloadOrgan()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <preloadOrgan>d__39(0)
			{
				<>4__this = this
			};
		}

		private void clearInstances()
		{
			laceNPCInstance = null;
			laceNPCFSMOwner = null;
			silkflies = null;
			laceBossInstance = null;
			laceBossSceneInstance = null;
			laceBossFSMOwner = null;
			challengeDialogInstance = null;
			deepMemoryInstance = null;
			phantomBossScene = null;
			phantomBossSceneFSMOwner = null;
			phantomBossFSMOwner = null;
			infoPromptInstance = null;
			syncedFightSwapLeverInstance = null;
			if ((Object)(object)wakeupPointInstance != (Object)null)
			{
				Object.Destroy((Object)(object)wakeupPointInstance);
				wakeupPointInstance = null;
			}
			if ((Object)(object)respawnPointInstance != (Object)null)
			{
				Object.Destroy((Object)(object)respawnPointInstance);
				respawnPointInstance = null;
			}
		}

		public void setupNormalFight()
		{
			//IL_0010: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_0062: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected O, but got Unknown
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected O, but got Unknown
			Log.LogDebug((object)"[setupFight] Trying to register phantom");
			phantomBossScene = UnityExtensions.FindGameObject(SceneManager.GetActiveScene(), "Boss Scene");
			Log.LogDebug((object)$"[setupFight] {phantomBossScene}");
			phantomBossSceneFSMOwner = new FsmOwnerDefault
			{
				gameObject = FsmGameObject.op_Implicit(phantomBossScene),
				OwnerOption = (OwnerDefaultOption)1
			};
			phantomBossFSMOwner = new FsmOwnerDefault
			{
				gameObject = FsmGameObject.op_Implicit(UnityExtensions.FindChild(phantomBossScene, "Phantom")),
				OwnerOption = (OwnerDefaultOption)1
			};
			laceBossSceneInstance = ManagedAssetExtensions.InstantiateAsset<GameObject>(assetManager.sceneCache, "lace1BossSceneCache");
			Component[] components = laceBossSceneInstance.GetComponents(typeof(DeactivateIfPlayerdataTrue));
			for (int i = 0; i < components.Length; i++)
			{
				((Behaviour)(DeactivateIfPlayerdataTrue)components[i]).enabled = false;
			}
			laceBossSceneInstance.AddComponent<Lace1Scene>();
			laceBossSceneInstance.SetActive(true);
			laceBossInstance = UnityExtensions.FindChild(laceBossSceneInstance, "Lace Boss1");
			laceBossInstance.SetActive(false);
			laceBossInstance.AddComponent<Lace1>();
			laceBossFSMOwner = new FsmOwnerDefault
			{
				gameObject = FsmGameObject.op_Implicit(laceBossInstance),
				OwnerOption = (OwnerDefaultOption)1
			};
			laceNPCInstance = ManagedAssetExtensions.InstantiateAsset<GameObject>(assetManager.sceneCache, "laceNPCCache");
			laceNPCInstance.AddComponent<LaceNPC>();
			laceNPCInstance.SetActive(true);
			Log.LogDebug((object)$"[setupFight] Trying to set up phantom : phantom available? {(Object)(object)phantomBossScene != (Object)null}");
			phantomBossScene.AddComponent<PhantomScene>();
			UnityExtensions.FindChild(phantomBossScene, "Phantom").AddComponent<PhantomBoss>();
		}

		public void setupMemoryFight()
		{
			//IL_0010: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_0062: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected O, but got Unknown
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Expected O, but got Unknown
			Log.LogDebug((object)"[setupFight] Trying to register phantom");
			phantomBossScene = UnityExtensions.FindGameObject(SceneManager.GetActiveScene(), "Boss Scene");
			Log.LogDebug((object)$"[setupFight] {phantomBossScene}");
			phantomBossSceneFSMOwner = new FsmOwnerDefault
			{
				gameObject = FsmGameObject.op_Implicit(phantomBossScene),
				OwnerOption = (OwnerDefaultOption)1
			};
			phantomBossFSMOwner = new FsmOwnerDefault
			{
				gameObject = FsmGameObject.op_Implicit(UnityExtensions.FindChild(phantomBossScene, "Phantom")),
				OwnerOption = (OwnerDefaultOption)1
			};
			challengeDialogInstance = ManagedAssetExtensions.InstantiateAsset<GameObject>(assetManager.sceneCache, "challengeDialogCache");
			challengeDialogInstance.AddComponent<ChallengeRegion>();
			challengeDialogInstance.SetActive(true);
			laceBossSceneInstance = ManagedAssetExtensions.InstantiateAsset<GameObject>(assetManager.sceneCache, "lace2BossSceneCache");
			laceBossSceneInstance.AddComponent<Lace2Scene>();
			laceBossSceneInstance.SetActive(true);
			laceBossInstance = UnityExtensions.FindChild(laceBossSceneInstance, "Lace Boss2 New");
			laceBossInstance.SetActive(false);
			laceBossInstance.AddComponent<Lace2>();
			((Behaviour)(DeactivateIfPlayerdataTrue)laceBossInstance.GetComponent(typeof(DeactivateIfPlayerdataTrue))).enabled = false;
			laceBossFSMOwner = new FsmOwnerDefault
			{
				gameObject = FsmGameObject.op_Implicit(laceBossInstance),
				OwnerOption = (OwnerDefaultOption)1
			};
			laceBossInstance.SetActive(true);
			laceNPCInstance = ManagedAssetExtensions.InstantiateAsset<GameObject>(assetManager.sceneCache, "laceNPCCache");
			laceNPCInstance.AddComponent<LaceNPC>();
			laceNPCInstance.SetActive(true);
			Log.LogDebug((object)$"[setupFight] Trying to set up phantom : phantom available? {(Object)(object)phantomBossScene != (Object)null}");
			Log.LogDebug((object)$"[setupFight] {phantomBossScene}");
			phantomBossScene.AddComponent<PhantomScene>();
			UnityExtensions.FindChild(phantomBossScene, "Phantom").AddComponent<PhantomBoss>();
			phantomBossScene.AddComponent<SyncControl>();
		}

		private void setupDeepMemoryZone()
		{
			Log.LogDebug((object)$"{PlayerDataAccess.defeatedCoralKing}, {PlayerDataAccess.defeatedCoralKing}");
			deepMemoryInstance = ManagedAssetExtensions.InstantiateAsset<GameObject>(assetManager.sceneCache, "deepMemoryCache");
			deepMemoryInstance.SetActive(false);
			deepMemoryInstance.AddComponent<DeepMemory>();
			deepMemoryInstance.GetComponent<TestGameObjectActivator>().playerDataTest.TestGroups[0].Tests[0].FieldName = "defeatedPhantom";
			deepMemoryInstance.GetComponent<TestGameObjectActivator>().playerDataTest.TestGroups[0].Tests[0].BoolValue = false;
			deepMemoryInstance.SetActive(true);
			if ((Object)(object)wakeupPointInstance == (Object)null)
			{
				Log.LogDebug((object)"[setupDeepMemoryZone] Setting up memory wake point");
				wakeupPointInstance = ManagedAssetExtensions.InstantiateAsset<GameObject>(assetManager.sceneCache, "wakeupPointCache");
				wakeupPointInstance.SetActive(false);
				wakeupPointInstance.AddComponent<WakeUpMemory>();
				Object.DontDestroyOnLoad((Object)(object)wakeupPointInstance);
			}
			if ((Object)(object)respawnPointInstance == (Object)null)
			{
				Log.LogDebug((object)"[setupDeepMemoryZone] Setting respawn point");
				UnityExtensions.FindChild(deepMemoryInstance, "door_wakeOnGround");
				respawnPointInstance = Object.Instantiate<GameObject>(UnityExtensions.FindChild(deepMemoryInstance, "door_wakeOnGround"));
				respawnPointInstance.SetActive(false);
				respawnPointInstance.AddComponent<WakeUpRespawn>();
				Object.DontDestroyOnLoad((Object)(object)respawnPointInstance);
			}
			syncedFightSwapLeverInstance = ManagedAssetExtensions.InstantiateAsset<GameObject>(assetManager.sceneCache, "syncedFightSwapLeverCache");
			syncedFightSwapLeverInstance.AddComponent<FightSelectionLever>();
		}

		public void FindHornet()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			if (!((Object)(object)hornet == (Object)null) || !((Object)(object)HeroController.instance != (Object)null))
			{
				return;
			}
			hornet = ((Component)HeroController.instance).gameObject;
			if ((Object)(object)hornet != (Object)null)
			{
				hornetFSMOwner = new FsmOwnerDefault();
				hornetFSMOwner.OwnerOption = (OwnerDefaultOption)1;
				hornetFSMOwner.GameObject = FsmGameObject.op_Implicit(hornet);
				if ((Object)(object)hornet.GetComponent<ConstrainPosition>() == (Object)null)
				{
					hornetConstrain = hornet.AddComponent<ConstrainPosition>();
					hornetConstrain.SetXMax(96.727f);
					hornetConstrain.SetXMin(72.323f);
					hornetConstrain.constrainX = true;
					hornetConstrain.constrainY = false;
					((Behaviour)hornetConstrain).enabled = false;
				}
			}
		}

		private void Update()
		{
			//IL_000b: 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)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKey(configManager.modifierKey.Value) && Input.GetKeyDown((KeyCode)121))
			{
				PlayerDataAccess.defeatedPhantom = true;
				PlayerDataAccess.defeatedLaceTower = true;
				PlayerDataAccess.blackThreadWorld = true;
				PlayerDataAccess.hasNeedolinMemoryPowerup = true;
				ManualLogSource log = Log;
				string[] obj = new string[7] { "[CanSetup] Scene:", null, null, null, null, null, null };
				Scene activeScene = SceneManager.GetActiveScene();
				obj[1] = ((Scene)(ref activeScene)).name;
				obj[2] = " ";
				obj[3] = $"DefeatedLace2:{PlayerDataAccess.defeatedLaceTower} ";
				obj[4] = $"DefeatedPhantom:{PlayerDataAccess.defeatedPhantom} ";
				obj[5] = $"Act3:{PlayerDataAccess.blackThreadWorld} ";
				obj[6] = $"Needolin:{PlayerDataAccess.hasNeedolinMemoryPowerup}";
				log.LogWarning((object)string.Concat(obj));
			}
		}

		[Conditional("DEBUG")]
		private void CheckDebugKeybinds()
		{
			//IL_0037: 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_00c3: 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_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: 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_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_041f: Unknown result type (might be due to invalid IL or missing references)
			//IL_045b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0497: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_050f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0594: Unknown result type (might be due to invalid IL or missing references)
			//IL_054b: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_060b: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0649: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_070a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0775: Unknown result type (might be due to invalid IL or missing references)
			//IL_0873: Unknown result type (might be due to invalid IL or missing references)
			//IL_07bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_08cc: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKey((KeyCode)306) && Input.GetKeyDown((KeyCode)256))
			{
				((PlayMakerFSM)UnityExtensions.FindChild(phantomBossScene, "Phantom").GetComponent(typeof(PlayMakerFSM))).SetState("Phase Parry Bait");
			}
			if (Input.GetKey((KeyCode)306) && Input.GetKeyDown((KeyCode)257))
			{
				((PlayMakerFSM)UnityExtensions.FindChild(phantomBossScene, "Phantom").GetComponent(typeof(PlayMakerFSM))).SetState("Phase Defense Parry");
			}
			if (Input.GetKey((KeyCode)306) && Input.GetKeyDown((KeyCode)258))
			{
				((PlayMakerFSM)UnityExtensions.FindChild(phantomBossScene, "Phantom").GetComponent(typeof(PlayMakerFSM))).SetState("Evade Antic");
			}
			if (Input.GetKey((KeyCode)306) && Input.GetKeyDown((KeyCode)259))
			{
				((PlayMakerFSM)UnityExtensions.FindChild(phantomBossScene, "Phantom").GetComponent(typeof(PlayMakerFSM))).SetState("Run To Lace");
			}
			if (Input.GetKey((KeyCode)306) && Input.GetKeyDown((KeyCode)260))
			{
				((PlayMakerFSM)UnityExtensions.FindChild(phantomBossScene, "Phantom").GetComponent(typeof(PlayMakerFSM))).SetState("Parry Antic");
			}
			if (Input.GetKey((KeyCode)306) && Input.GetKeyDown((KeyCode)261))
			{
				((PlayMakerFSM)UnityExtensions.FindChild(phantomBossScene, "Phantom").GetComponent(typeof(PlayMakerFSM))).SetState("G Throw Antic");
			}
			if (Input.GetKey((KeyCode)306) && Input.GetKeyDown((KeyCode)262))
			{
				((PlayMakerFSM)UnityExtensions.FindChild(phantomBossScene, "Phantom").GetComponent(typeof(PlayMakerFSM))).SetState("Set A Throw");
			}
			if (Input.GetKey((KeyCode)306) && Input.GetKeyDown((KeyCode)263))
			{
				((PlayMakerFSM)UnityExtensions.FindChild(phantomBossScene, "Phantom").GetComponent(typeof(PlayMakerFSM))).SetState("A Throw Aim");
			}
			if (Input.GetKey((KeyCode)306) && Input.GetKeyDown((KeyCode)264))
			{
				((PlayMakerFSM)UnityExtensions.FindChild(phantomBossScene, "Phantom").GetComponent(typeof(PlayMakerFSM))).SetState("Normal Dragoon");
			}
			if (Input.GetKey((KeyCode)306) && Input.GetKeyDown((KeyCode)265))
			{
				((PlayMakerFSM)UnityExtensions.FindChild(phantomBossScene, "Phantom").GetComponent(typeof(PlayMakerFSM))).SetState("Dragoon Rage");
			}
			if (Input.GetKey((KeyCode)306) && Input.GetKeyDown((KeyCode)270))
			{
				((PlayMakerFSM)UnityExtensions.FindChild(phantomBossScene, "Phantom").GetComponent(typeof(PlayMakerFSM))).SetState("Phase Antic");
			}
			if (Input.GetKey((KeyCode)305) && Input.GetKeyDown((KeyCode)256))
			{
				((PlayMakerFSM)laceBossInstance.GetComponent(typeof(PlayMakerFSM))).SetState("Charge Antic");
			}
			if (Input.GetKey((KeyCode)305) && Input.GetKeyDown((KeyCode)257))
			{
				((PlayMakerFSM)laceBossInstance.GetComponent(typeof(PlayMakerFSM))).SetState("J Slash Antic");
			}
			if (Input.GetKey((KeyCode)305) && Input.GetKeyDown((KeyCode)258))
			{
				((PlayMakerFSM)laceBossInstance.GetComponent(typeof(PlayMakerFSM))).SetState("Evade");
			}
			if (Input.GetKey((KeyCode)305) && Input.GetKeyDown((KeyCode)259))
			{
				((PlayMakerFSM)laceBossInstance.GetComponent(typeof(PlayMakerFSM))).SetState("Counter Antic");
			}
			if (Input.GetKey((KeyCode)305) && Input.GetKeyDown((KeyCode)260))
			{
				((PlayMakerFSM)laceBossInstance.GetComponent(typeof(PlayMakerFSM))).SetState("ComboSlash 1");
			}
			if (Input.GetKey((KeyCode)305) && Input.GetKeyDown((KeyCode)261))
			{
				((PlayMakerFSM)laceBossInstance.GetComponent(typeof(PlayMakerFSM))).SetState("CrossSlash Aim");
			}
			if (Input.GetKey((KeyCode)305) && Input.GetKeyDown((KeyCode)262))
			{
				((PlayMakerFSM)laceBossInstance.GetComponent(typeof(PlayMakerFSM))).SetState("Tele Out");
			}
			if (Input.GetKey((KeyCode)305) && Input.GetKeyDown((KeyCode)263))
			{
				((PlayMakerFSM)laceBossInstance.GetComponent(typeof(PlayMakerFSM))).SetState("Hop To Phantom");
			}
			if (Input.GetKey((KeyCode)305) && Input.GetKeyDown((KeyCode)264))
			{
				((PlayMakerFSM)laceBossInstance.GetComponent(typeof(PlayMakerFSM))).SetState("Tele Out Defense");
			}
			if (Input.GetKey((KeyCode)305) && Input.GetKeyDown((KeyCode)265))
			{
				((PlayMakerFSM)laceBossInstance.GetComponent(typeof(PlayMakerFSM))).SetState("Tele Out Bait");
			}
			if (Input.GetKey((KeyCode)305) && Input.GetKeyDown((KeyCode)112))
			{
				FsmUtil.GetFsm(laceNPCInstance, "Control").SetState("Lock Hornet");
			}
			if (Input.GetKey(configManager.modifierKey.Value) && Input.GetKeyDown((KeyCode)104))
			{
				hornet.transform.position = new Vector3(90.45f, 105f, 0.004f);
			}
			if (Input.GetKey(configManager.modifierKey.Value) && Input.GetKeyDown((KeyCode)259))
			{
				laceBossInstance.GetComponent<HealthManager>().hp = 1;
			}
			if (Input.GetKey(configManager.modifierKey.Value) && Input.GetKeyDown((KeyCode)257))
			{
				UnityExtensions.FindChild(phantomBossScene, "Phantom").GetComponent<HealthManager>().hp = 1;
			}
			if (Input.GetKey(configManager.modifierKey.Value) && Input.GetKeyDown((KeyCode)111))
			{
				PlayerDataVariableEvents.OnGetBool += PrepatcherUtils.SilkenSisterMonitor;
				SceneManager.LoadSceneAsync("Organ_01", (LoadSceneMode)0).completed += delegate
				{
					//IL_002a: Unknown result type (might be due to invalid IL or missing references)
					GameManager._instance.ForceCurrentSceneIsMemory(true);
					setupMemoryFight();
					hornet.transform.position = new Vector3(90.45f, 105f, 0.004f);
				};
			}
			if (Input.GetKey(configManager.modifierKey.Value) && Input.GetKeyDown((KeyCode)117))
			{
				PlayerDataAccess.defeatedPhantom = true;
				PlayerDataAccess.blackThreadWorld = true;
				HeroController.instance.RefillSilkToMaxSilent();
				SceneManager.LoadSceneAsync("Organ_01", (LoadSceneMode)0).completed += delegate
				{
				};
			}
			if (Input.GetKey(configManager.modifierKey.Value) && Input.GetKeyDown((KeyCode)107))
			{
				PlayerDataAccess.defeatedPhantom = true;
				PlayerDataAccess.blackThreadWorld = false;
				PlayerDataAccess.defeatedLaceTower = false;
				HeroController.instance.RefillSilkToMaxSilent();
				SceneManager.LoadSceneAsync("Organ_01", (LoadSceneMode)0).completed += delegate
				{
				};
			}
			Scene activeScene;
			if (Input.GetKey(configManager.modifierKey.Value) && Input.GetKeyDown((KeyCode)112))
			{
				PlayerDataAccess.defeatedPhantom = true;
				PlayerDataAccess.defeatedLaceTower = true;
				PlayerDataAccess.blackThreadWorld = true;
				PlayerDataAccess.hasNeedolinMemoryPowerup = true;
				ManualLogSource log = Log;
				string[] obj = new string[7] { "[CanSetup] Scene:", null, null, null, null, null, null };
				activeScene = SceneManager.GetActiveScene();
				obj[1] = ((Scene)(ref activeScene)).name;
				obj[2] = " ";
				obj[3] = $"DefeatedLace2:{PlayerDataAccess.defeatedLaceTower} ";
				obj[4] = $"DefeatedPhantom:{PlayerDataAccess.defeatedPhantom} ";
				obj[5] = $"Act3:{PlayerDataAccess.blackThreadWorld} ";
				obj[6] = $"Needolin:{PlayerDataAccess.hasNeedolinMemoryPowerup}";
				log.LogWarning((object)string.Concat(obj));
				SceneManager.LoadSceneAsync("Organ_01", (LoadSceneMode)0).completed += delegate
				{
				};
			}
			if (Input.GetKey(configManager.modifierKey.Value) && Input.GetKeyDown((KeyCode)108))
			{
				PlayerDataAccess.defeatedPhantom = false;
				PlayerDataAccess.defeatedLace1 = false;
				PlayerDataAccess.defeatedLaceTower = false;
				PlayerDataAccess.blackThreadWorld = false;
				PlayerDataAccess.hasNeedolinMemoryPowerup = false;
				PlayerDataAccess.encounteredLace1 = false;
				ManualLogSource log2 = Log;
				string[] obj2 = new string[6] { "[CanSetup] Scene:", null, null, null, null, null };
				activeScene = SceneManager.GetActiveScene();
				obj2[1] = ((Scene)(ref activeScene)).name;
				obj2[2] = " ";
				obj2[3] = $"DefeatedLace2:{PlayerDataAccess.defeatedLaceTower} ";
				obj2[4] = $"DefeatedPhantom:{PlayerDataAccess.defeatedPhantom} ";
				obj2[5] = $"Act3:{PlayerDataAccess.blackThreadWorld}";
				log2.LogWarning((object)string.Concat(obj2));
				SceneManager.LoadSceneAsync("Organ_01", (LoadSceneMode)0).completed += delegate
				{
				};
			}
		}
	}
}
namespace SilkenSisters.Utils
{
	internal class AssetManager
	{
		[CompilerGenerated]
		private sealed class <CacheObjects>d__5 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public AssetManager <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				int num = <>1__state;
				AssetManager assetManager = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = assetManager.sceneCache.Load();
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>2__current = assetManager.audioClipCache.Load();
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					<>2__current = assetManager.prefabCache.Load();
					<>1__state = 3;
					return true;
				case 3:
					<>1__state = -1;
					<>2__current = assetManager.audioClipTableCache.Load();
					<>1__state = 4;
					return true;
				case 4:
				{
					<>1__state = -1;
					GameObject obj = ManagedAssetExtensions.InstantiateAsset<GameObject>(assetManager.sceneCache, "coralBossSceneCache");
					PlayMakerFSM fsmPreprocessed = FsmUtil.GetFsmPreprocessed(obj, "Control");
					SilkenSisters.instance.ExitMemoryCache = FsmUtil.GetState(fsmPreprocessed, "Exit Memory");
					Object.Destroy((Object)(object)obj);
					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();
			}
		}

		internal ManagedAssetGroup<GameObject> sceneCache;

		internal ManagedAssetGroup<AudioClip> audioClipCache;

		internal ManagedAssetGroup<GameObject> prefabCache;

		internal ManagedAssetGroup<RandomAudioClipTable> audioClipTableCache;

		internal void RequestAssets()
		{
			sceneCache = ManagedAssetGroup<GameObject>.RequestAndCreate(new Dictionary<string, SceneAssetInfo<GameObject>>
			{
				{
					"laceNPCCache",
					new SceneAssetInfo<GameObject>("Coral_19", "Encounter Scene Control/Lace Meet/Lace NPC Blasted Bridge")
				},
				{
					"lace2BossSceneCache",
					new SceneAssetInfo<GameObject>("Song_Tower_01", "Boss Scene")
				},
				{
					"lace1BossSceneCache",
					new SceneAssetInfo<GameObject>("Bone_East_12", "Boss Scene")
				},
				{
					"silkfliesCache",
					new SceneAssetInfo<GameObject>("Bone_East_12", "Boss Scene/Silkflies")
				},
				{
					"syncedFightSwapLeverCache",
					new SceneAssetInfo<GameObject>("Bone_East_12", "dock_pipe_trapdoor")
				},
				{
					"challengeDialogCache",
					new SceneAssetInfo<GameObject>("Cradle_03", "Boss Scene/Intro Sequence")
				},
				{
					"wakeupPointCache",
					new SceneAssetInfo<GameObject>("Memory_Coral_Tower", "Door Get Up")
				},
				{
					"coralBossSceneCache",
					new SceneAssetInfo<GameObject>("Memory_Coral_Tower", "Boss Scene")
				},
				{
					"deepMemoryCache",
					new SceneAssetInfo<GameObject>("Coral_Tower_01", "Memory Group")
				},
				{
					"infoPromptCache",
					new SceneAssetInfo<GameObject>("Arborium_01", "Inspect Region")
				}
			}, (Dictionary<string, NonSceneAssetInfo<GameObject>>)null);
			audioClipCache = ManagedAssetGroup<AudioClip>.RequestAndCreate((Dictionary<string, SceneAssetInfo<AudioClip>>)null, new Dictionary<string, NonSceneAssetInfo<AudioClip>>
			{
				{
					"phantomSing",
					new NonSceneAssetInfo<AudioClip>("sfxstatic_assets_areaorgan", "Assets/Audio/HornetVoices/Phantom/NewTake/Phantom-2-Sing.wav")
				},
				{
					"laceSpeak",
					new NonSceneAssetInfo<AudioClip>("sfxstatic_assets_laceboss", "Assets/Audio/Voices/Lace_Silksong/Lace_weak_talk_01.wav")
				},
				{
					"laceSpeak2",
					new NonSceneAssetInfo<AudioClip>("sfxstatic_assets_laceboss", "Assets/Audio/Voices/Lace_Silksong/Lace_talk_haughty_04.wav")
				},
				{
					"laceScoff",
					new NonSceneAssetInfo<AudioClip>("sfxstatic_assets_laceboss", "Assets/Audio/Voices/Lace_Silksong/Lace_short_attack_grunt_03.wav")
				},
				{
					"laceWail",
					new NonSceneAssetInfo<AudioClip>("sfxstatic_assets_laceboss", "Assets/Audio/Voices/Lace_Silksong/Lace_wail_short_02.wav")
				},
				{
					"laceLaugh",
					new NonSceneAssetInfo<AudioClip>("sfxstatic_assets_laceboss", "Assets/Audio/Voices/Lace_Silksong/Lace_long_laugh_04.wav")
				},
				{
					"laceStance",
					new NonSceneAssetInfo<AudioClip>("sfxstatic_assets_laceboss", "Assets/Audio/SFX/HornetEnemy/Lace/lace_prepare_stance.wav")
				},
				{
					"laceBackstep",
					new NonSceneAssetInfo<AudioClip>("sfxstatic_assets_laceboss", "Assets/Audio/SFX/HornetEnemy/Lace/lace_back_or_forward_step_2.wav")
				},
				{
					"laceCharge",
					new NonSceneAssetInfo<AudioClip>("sfxstatic_assets_laceboss", "Assets/Audio/SFX/HornetEnemy/Lace/lace_horizontal_dash.wav")
				},
				{
					"laceWake",
					new NonSceneAssetInfo<AudioClip>("sfxstatic_assets_shared", "Assets/Audio/SFX/HornetEnemy/Trobbio/trobbio_jump.wav")
				},
				{
					"laceTeleOut",
					new NonSceneAssetInfo<AudioClip>("sfxstatic_assets_areasong", "Assets/Audio/SFX/Enemy/Bosses/Mantis Lords/mantis_lord_misc_jump_2.wav")
				},
				{
					"laceTeleIn",
					new NonSceneAssetInfo<AudioClip>("sfxstatic_assets_areaclover", "Assets/Audio/SFX/HornetEnemy/grasshopper_slasher_dash_1.wav")
				},
				{
					"hornetSword",
					new NonSceneAssetInfo<AudioClip>("sfxstatic_assets_shared", "Assets/Audio/SFX/sword_5.wav")
				},
				{
					"hornetParry",
					new NonSceneAssetInfo<AudioClip>("sfxstatic_assets_shared", "Assets/Audio/SFX/Enemy/Bosses/Hornet/hornet_parry_prepare.wav")
				},
				{
					"miscRumble",
					new NonSceneAssetInfo<AudioClip>("sfxstatic_assets_shared", "Assets/Audio/SFX/Props/misc_rumble_impact.wav")
				},
				{
					"focusReady",
					new NonSceneAssetInfo<AudioClip>("herosfxstatic_assets_all", "Assets/Audio/SFX/Heroes/Knight/focus_ready.wav")
				}
			});
			prefabCache = ManagedAssetGroup<GameObject>.RequestAndCreate((Dictionary<string, SceneAssetInfo<GameObject>>)null, new Dictionary<string, NonSceneAssetInfo<GameObject>> { 
			{
				"AudioPlayerActor",
				new NonSceneAssetInfo<GameObject>("globalpoolprefabs_assets_all", "Assets/Audio/Audio Player Actor.prefab")
			} });
			audioClipTableCache = ManagedAssetGroup<RandomAudioClipTable>.RequestAndCreate((Dictionary<string, SceneAssetInfo<RandomAudioClipTable>>)null, new Dictionary<string, NonSceneAssetInfo<RandomAudioClipTable>>
			{
				{
					"LaceWail",
					new NonSceneAssetInfo<RandomAudioClipTable>("sfxdynamic_assets_laceboss", "Assets/Audio/Voices/Lace_Silksong/Lace_wail_short.asset")
				},
				{
					"LaceGrunt",
					new NonSceneAssetInfo<RandomAudioClipTable>("sfxdynamic_assets_laceboss", "Assets/Audio/Voices/Lace_Silksong/lace_grunt.asset")
				},
				{
					"LaceWeakTalk",
					new NonSceneAssetInfo<RandomAudioClipTable>("sfxdynamic_assets_laceboss", "Assets/Audio/Voices/Lace_Silksong/Lace_defeated_talk_final.asset")
				},
				{
					"LaceSpeak",
					new NonSceneAssetInfo<RandomAudioClipTable>("sfxdynamic_assets_laceboss", "Assets/Audio/Voices/Lace_Silksong/lace_battle_admonish.asset")
				},
				{
					"LaceAttack",
					new NonSceneAssetInfo<RandomAudioClipTable>("sfxdynamic_assets_laceboss", "Assets/Audio/Voices/Lace_Silksong/lace_attack_call.asset")
				},
				{
					"LaceCollapse",
					new NonSceneAssetInfo<RandomAudioClipTable>("sfxdynamic_assets_laceboss", "Assets/Audio/Voices/Lace_Silksong/Lace_after_battle_collapse.asset")
				},
				{
					"HornetSpeak",
					new NonSceneAssetInfo<RandomAudioClipTable>("herodynamic_assets_all", "Assets/Audio/Voices/Hornet_Silksong/Hornet Voice Action Grunt.asset")
				}
			});
		}

		[IteratorStateMachine(typeof(<CacheObjects>d__5))]
		internal IEnumerator CacheObjects()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <CacheObjects>d__5(0)
			{
				<>4__this = this
			};
		}

		internal void ClearCache()
		{
			sceneCache.Unload();
			audioClipCache.Unload();
			prefabCache.Unload();
		}
	}
	internal class PrepatcherUtils
	{
		internal static bool SilkenSisterMonitor(PlayerData pd, string fieldName, bool current)
		{
			if (fieldName == "defeatedPhantom" || fieldName == "blackThreadWorld")
			{
				return false;
			}
			return current;
		}
	}
	internal class SilkenSistersConfig
	{
		internal ConfigEntry<KeyCode> modifierKey;

		internal ConfigEntry<KeyCode> actionKey;

		internal ConfigEntry<float> syncWaitTime;

		internal ConfigEntry<float> syncDelay;

		internal ConfigEntry<float> syncGatherDistance;

		internal ConfigEntry<float> syncTeleDistance;

		internal ConfigEntry<float> syncRangeDistance;

		internal ConfigEntry<int> MaxHP;

		internal ConfigEntry<int> P2HP;

		internal ConfigEntry<int> P3HP;

		internal ConfigEntry<int> ParryCooldown;

		internal ConfigEntry<float> ParryBaitDistance;

		internal ConfigEntry<float> DefenseParryDistance;

		public ConfigEntry<bool> syncedFight;

		internal void BindConfig(ConfigFile Config)
		{
			modifierKey = Config.Bind<KeyCode>("Keybinds", "Modifier", (KeyCode)308, "Modifier");
			syncedFight = Config.Bind<bool>("General", "SyncedFight", false, "Use the Synced patterns for the boss fights. Playtest version");
			syncWaitTime = Config.Bind<float>("Sync fight", "Idle time", 1.5f, "Debug config for defining how long they will wait for each other to finish their actions");
			syncDelay = Config.Bind<float>("Sync fight", "Delay time", 0.5f, "Debug config for defining how the anti-synchronous actions will be delayed");
			syncGatherDistance = Config.Bind<float>("Sync fight", "Gather Distance", 1.75f, "Debug config for defining how close lace and phantom must be for attacking");
			syncTeleDistance = Config.Bind<float>("Sync fight", "Tele Distance", 8f, "Debug Config that defines how far lace and phantom must be for teleportation move.");
			syncRangeDistance = Config.Bind<float>("Sync fight", "Range Distance", 6f, "Debug Config that defines the checking distance between the siblings and hornet.");
			MaxHP = Config.Bind<int>("Sync fight", "Max HP", 1500, "Debug Config that defines max pooled HP.");
			P2HP = Config.Bind<int>("Sync fight", "P2 HP", 1100, "Debug Config that defines pooled hp p2 shift.");
			P3HP = Config.Bind<int>("Sync fight", "P3 HP", 600, "Debug Config that defines pooled hp p3 shift.");
			ParryCooldown = Config.Bind<int>("Sync fight", "Parry CoolDown", 3, "Debug Config that defines the number of attacks between each parry attempt.");
			ParryBaitDistance = Config.Bind<float>("Sync fight", "Parry Bait Distance", 3f, "Debug Config that defines the distance at which they tp for parrybait.");
			DefenseParryDistance = Config.Bind<float>("Sync fight", "Defense Parry Distance", 2f, "Debug Config that defines the distance at which they tp for defend parry.");
		}
	}
}
namespace SilkenSisters.Patches
{
	internal class DebugPatches
	{
		[Conditional("DEBUG")]
		public static void CreateDebugPatch()
		{
		}

		[Conditional("DEBUG")]
		public static void RemoveDebugPatch()
		{
			if (SilkenSisters.instance._utilitypatches != null)
			{
				SilkenSisters.instance._utilitypatches.UnpatchSelf();
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(FsmState), "OnEnter")]
		private static void setStateListener(FsmState __instance)
		{
			if (((Object)__instance.Fsm.GameObject).name == "Lace Boss2 New")
			{
				_ = __instance.Fsm.Name == "Control";
			}
			if (((Object)__instance.Fsm.GameObject).name == "Boss Scene" && __instance.Fsm.Name == "Silken Sisters Sync Control")
			{
				SilkenSisters.Log.LogDebug((object)("[StateListen] " + __instance.Name));
			}
			if (0 == 0 || (!(((Object)__instance.Fsm.GameObject).name == $"{SilkenSisters.instance.deepMemoryInstance}") && !(((Object)__instance.Fsm.GameObject).name == "before") && !(((Object)__instance.Fsm.GameObject).name == "thread_memory")))
			{
				return;
			}
			SilkenSisters.Log.LogDebug((object)(((Object)__instance.Fsm.GameObject).name + ", " + __instance.fsm.name + ", Entering state " + __instance.Name));
			if (__instance.Actions.Length != 0)
			{
				FsmTransition[] transitions = __instance.transitions;
				foreach (FsmTransition val in transitions)
				{
					SilkenSisters.Log.LogDebug((object)("    transitions for state " + __instance.Name + ": " + val.EventName + " to " + val.toState));
				}
				FsmStateAction[] actions = __instance.Actions;
				foreach (FsmStateAction val2 in actions)
				{
					SilkenSisters.Log.LogDebug((object)$"        Action for state {__instance.Name}: {((object)val2).GetType()}");
				}
			}
		}
	}
	internal class EncounterPatches
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(FsmState), "OnEnter")]
		private static void PatchLaceEncounter(FsmState __instance)
		{
			//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)
			if (((Object)__instance.Fsm.GameObject).name == "Lace Encounter Control" && __instance.Name == "Init")
			{
				Scene activeScene = SceneManager.GetActiveScene();
				if (((Scene)(ref activeScene)).name == "Dust_01")
				{
					FsmUtil.DisableAction(__instance.fsm, "Check", 3);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Language), "Get")]
	[HarmonyPatch(new Type[]
	{
		typeof(string),
		typeof(string)
	})]
	public static class Language_Get_Patch
	{
		private static void Prefix(ref string key, ref string sheetTitle)
		{
			if (key.Contains("SILKEN_SISTERS"))
			{
				sheetTitle = "Mods.io.github.al3ks1s.silkensisters";
			}
			if (key.Contains("SILKEN_SISTERS_SUB") && SilkenSisters.instance.configManager.syncedFight.Value && SilkenSisters.isMemory())
			{
				key = "SILKEN_SISTERS_SUB_DEBUG";
			}
		}
	}
	internal class UtilityPatches
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(HeroController), "Die")]
		private static void setDeathListener(HeroController __instance, ref bool nonLethal, ref bool frostDeath)
		{
			SilkenSisters.Log.LogDebug((object)$"[DeathListener] Hornet died / isMemory? Mod:{SilkenSisters.isMemory()} Scene:{GameManager.instance.IsMemoryScene()}");
			if (SilkenSisters.isMemory() && GameManager.instance.IsMemoryScene())
			{
				SilkenSisters.Log.LogDebug((object)"[DeathListener] Hornet died in memory, removing the Prepatcher hook");
				PlayerDataVariableEvents.OnGetBool -= PrepatcherUtils.SilkenSisterMonitor;
				if ((Object)(object)SilkenSisters.hornetConstrain != (Object)null)
				{
					((Behaviour)SilkenSisters.hornetConstrain).enabled = false;
				}
			}
		}
	}
}
namespace SilkenSisters.Behaviors
{
	internal class ChallengeRegion : MonoBehaviour
	{
		private GameObject _challengeRegion;

		private PlayMakerFSM _regionControl;

		private PlayMakerFSM _control;

		private void Awake()
		{
			Setup();
		}

		private async Task Setup()
		{
			SilkenSisters.Log.LogDebug((object)"[ChallengeRegion.Setup] Finished setting up ChallengeRegion");
			getComponents();
			setPositions();
			disableCradleStuff();
			setPhantomTrigger();
			setGarama();
			SilkenSisters.Log.LogDebug((object)"[ChallengeRegion.Setup] Finished setting up ChallengeRegion");
		}

		private void getComponents()
		{
			_challengeRegion = UnityExtensions.FindChild(((Component)this).gameObject, "Challenge Region");
			_regionControl = FsmUtil.GetFsmPreprocessed(_challengeRegion, "Challenge");
			_control = FsmUtil.GetFsmPreprocessed(((Component)this).gameObject, "First Challenge");
		}

		private void setPositions()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: 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)
			((Component)this).gameObject.transform.position = new Vector3(84.45f, 105.8935f, 2.504f);
			_challengeRegion.transform.localPosition = new Vector3(-0.2145f, 1.1139f, 2.4959f);
			SilkenSisters.Log.LogDebug((object)$"[ChallengeRegion.setPositions] Dialog position:{((Component)this).gameObject.transform.position}, RegionPosition:{_challengeRegion.transform.localPosition}");
		}

		private void disableCradleStuff()
		{
			UnityExtensions.FindChild(((Component)this).gameObject, "Challenge Glows/Cradle__0013_loom_strut_based (2)").SetActive(false);
			UnityExtensions.FindChild(((Component)this).gameObject, "Challenge Glows/Cradle__0013_loom_strut_based (3)").SetActive(false);
			FsmUtil.GetTransition(_control, "Idle", "CHALLENGE START").FsmEvent = FsmEvent.GetFsmEvent("QUICK START");
			SilkenSisters.Log.LogDebug((object)("[ChallengeRegion.disableCradleStuff] Cradle specific objects active?: " + string.Format("CradleLoom1:{0}, ", UnityExtensions.FindChild(((Component)this).gameObject, "Challenge Glows/Cradle__0013_loom_strut_based (2)").activeSelf) + string.Format("CradleLoom2:{0}", UnityExtensions.FindChild(((Component)this).gameObject, "Challenge Glows/Cradle__0013_loom_strut_based (3)").activeSelf)));
		}

		private void setPhantomTrigger()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_004d: 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)
			SilkenSisters.Log.LogDebug((object)"[ChallengeRegion.setPhantomTrigger] Setting battle trigger");
			SendEventByName val = new SendEventByName();
			val.sendEvent = FsmString.op_Implicit("ENTER");
			val.delay = FsmFloat.op_Implicit(0f);
			FsmEventTarget val2 = new FsmEventTarget();
			val2.gameObject = SilkenSisters.instance.phantomBossSceneFSMOwner;
			val2.target = (EventTarget)1;
			val.eventTarget = val2;
			FsmUtil.AddAction(_regionControl, "Challenge Complete", (FsmStateAction)(object)val);
			FsmUtil.GetAction<GetXDistance>(_regionControl, "Straight Back?", 1).gameObject.ownerOption = (OwnerDefaultOption)0;
		}

		private void setGarama()
		{
			PlayMakerFSM val = SilkenSisters.hornet.GetComponents<PlayMakerFSM>().First((PlayMakerFSM f) => f.FsmName == "Silk Specials");
			FsmUtil.DisableAction(_regionControl, "Hornet Voice", 0);
			FsmUtil.AddAction(_regionControl, "Hornet Voice", FsmUtil.GetStateAction(val, "Standard", 0));
		}
	}
	internal class DeepMemory : MonoBehaviour
	{
		private PlayMakerFSM _control;

		private GameObject _before;

		private void Awake()
		{
			Setup();
		}

		private async Task Setup()
		{
			try
			{
				SilkenSisters.Log.LogDebug((object)"[DeepMemory.Setup] Started setting deep memory up");
				getComponents();
				setPosition();
				disableCrustKingObjects();
				editFSMTransition();
				editPlayerData();
				bypassToolPickup();
				manageTransitionGates();
				SilkenSisters.Log.LogDebug((object)"[DeepMemory.Setup] Done");
			}
			catch (Exception ex)
			{
				SilkenSisters.Log.LogError((object)$"{ex} {ex.Message}");
			}
		}

		private void getComponents()
		{
			_control = FsmUtil.GetFsmPreprocessed(((Component)this).gameObject, "To Memory");
			_before = UnityExtensions.FindChild(((Component)this).gameObject, "before");
		}

		private void setPosition()
		{
			//IL_001a: 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)
			((Component)this).gameObject.transform.position = new Vector3(59.249f, 56.7457f, -3.1141f);
			UnityExtensions.FindChild(_before, "Deep_Memory_appear/threads").SetActive(false);
			Extensions.SetLocalPosition2D(UnityExtensions.FindChild(_before, "thread_memory").transform, 1.768f, -3.143f);
			SilkenSisters.Log.LogDebug((object)$"[DeepMemory.setPosition] position:{((Component)this).gameObject.transform.position}");
		}

		private void disableCrustKingObjects()
		{
			SilkenSisters.Log.LogDebug((object)"[DeepMemory.disableCrustKingObjects] Finding and deleting coral king sprite");
			Object.Destroy((Object)(object)UnityExtensions.FindChild(_before, "CK_ground_hit0004").gameObject);
		}

		private void editFSMTransition()
		{
			FsmUtil.GetAction<BeginSceneTransition>(_control, "Transition Scene", 4).sceneName = FsmString.op_Implicit("Organ_01");
			FsmUtil.GetAction<BeginSceneTransition>(_control, "Transition Scene", 4).entryGateName = FsmString.op_Implicit("door_wakeInMemory_phantom");
			SilkenSisters.Log.LogDebug((object)("[DeepMemory.editFSMTransition] " + string.Format("Scene:{0}, ", FsmUtil.GetAction<BeginSceneTransition>(_control, "Transition Scene", 4).sceneName) + string.Format("Gate:{0}", FsmUtil.GetAction<BeginSceneTransition>(_control, "Transition Scene", 4).entryGateName)));
		}

		private void editPlayerData()
		{
			FsmUtil.InsertMethod(_control, "Transition Scene", (Action)HookPlayerData, 0, false);
		}

		private void bypassToolPickup()
		{
			FsmUtil.GetTransition(FsmUtil.GetFsmPreprocessed(_before, "activate memory on tool pickup"), "State 1", "PICKED UP").fsmEvent = FsmEvent.GetFsmEvent("FINISHED");
		}

		private void manageTransitionGates()
		{
			FsmUtil.AddMethod(_control, "Transition Scene", (Action)disableRespawn, false);
			FsmUtil.InsertMethod(_control, "Transition Scene", (Action)enableDoor, 0, false);
		}

		private void enableDoor()
		{
			SilkenSisters.instance.wakeupPointInstance.SetActive(true);
			SilkenSisters.Log.LogDebug((object)$"[DeepMemory.enableDoor] Door active?:{SilkenSisters.instance.wakeupPointInstance.activeSelf}");
		}

		private void disableRespawn()
		{
			SilkenSisters.instance.respawnPointInstance.SetActive(false);
			SilkenSisters.instance.respawnPointInstance.GetComponent<PlayMakerFSM>().fsm.SetState("Pause");
			SilkenSisters.Log.LogDebug((object)$"[DeepMemory.disableRespawn] Respawn active?:{SilkenSisters.instance.respawnPointInstance.activeSelf}, Current state:{SilkenSisters.instance.respawnPointInstance.GetComponent<PlayMakerFSM>().ActiveStateName}");
		}

		private void HookPlayerData()
		{
			PlayerDataVariableEvents.OnGetBool += PrepatcherUtils.SilkenSisterMonitor;
		}
	}
	internal class WakeUpMemory : MonoBehaviour
	{
		private GameObject _wakeTransitionGate;

		private PlayMakerFSM _control;

		private void Awake()
		{
			Setup();
		}

		private async Task Setup()
		{
			try
			{
				SilkenSisters.Log.LogDebug((object)"[WakeUpMemory.Setup] Started setting wakeup transition up");
				getComponents();
				setName();
				setPosition();
				editFSM();
				SilkenSisters.Log.LogDebug((object)"[WakeUpMemory.Setup] Finished");
			}
			catch (Exception ex)
			{
				SilkenSisters.Log.LogError((object)$"{ex} {ex.Message}");
			}
		}

		private void getComponents()
		{
			_wakeTransitionGate = UnityExtensions.FindChild(((Component)this).gameObject, "door_wakeInMemory");
			_control = FsmUtil.GetFsmPreprocessed(_wakeTransitionGate, "Wake Up");
		}

		private void setName()
		{
			((Object)_wakeTransitionGate).name = "door_wakeInMemory_phantom";
			SilkenSisters.Log.LogDebug((object)("[WakeUpMemory.setName] gateName:" + ((Object)_wakeTransitionGate).name));
		}

		private void setPosition()
		{
			//IL_001a: 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)
			((Component)this).gameObject.transform.position = new Vector3(115.4518f, 104.5621f, 0f);
			SilkenSisters.Log.LogDebug((object)$"[WakeUpMemory.setPosition] gatePosition:{((Component)this).gameObject.transform.position}");
		}

		private void editFSM()
		{
			SilkenSisters.Log.LogDebug((object)"[WakeUpMemory.editFSM] Editing the door FSM");
			FsmUtil.AddMethod(_control, "Take Control", (Action)enableRespawn, false);
			FsmUtil.AddMethod(_control, "Take Control", (Action)enableIsMemory, false);
			FsmUtil.AddMethod(_control, "Take Control", (Action)recordHeroState, false);
			FsmUtil.AddMethod(_control, "Take Control", (Action)SilkenSisters.instance.setupMemoryFight, false);
			FsmUtil.AddMethod(_control, "End", (Action)disableSelf, false);
			FsmUtil.AddMethod(_control, "End", (Action)closeOffOrgan, false);
			FsmUtil.GetAction<ConvertBoolToFloat>(_control, "Fade Up", 1).falseValue = FsmFloat.op_Implicit(3f);
			FsmUtil.GetAction<ConvertBoolToFloat>(_control, "Fade Up", 1).trueValue = FsmFloat.op_Implicit(3f);
		}

		private void enableIsMemory()
		{
			GameManager._instance.ForceCurrentSceneIsMemory(true);
			SilkenSisters.Log.LogDebug((object)$"[WakeUpMemory.enableIsMemory] Is Memory? {GameManager._instance.IsMemoryScene()} {GameManager._instance.forceCurrentSceneMemory}");
		}

		private void enableRespawn()
		{
			SilkenSisters.instance.respawnPointInstance.SetActive(true);
			SilkenSisters.Log.LogDebug((object)$"[WakeUpMemory.enableRespawn] respawnObject active:{SilkenSisters.instance.respawnPointInstance.activeSelf}");
		}

		private void disableSelf()
		{
			((Component)this).gameObject.SetActive(false);
		}

		private void closeOffOrgan()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = UnityExtensions.FindGameObject(SceneManager.GetActiveScene(), "Boss Scene/Gates/Battle Gate (1)");
			Extensions.SetPosition3D(Object.Instantiate<GameObject>(obj).transform, 45.4916f, 71.6012f, 0.003f);
			Extensions.SetPosition3D(Object.Instantiate<GameObject>(obj).transform, 67.0862f, 8.5155f, 0.003f);
		}

		private void recordHeroState()
		{
			//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)
			HeroController.instance.RefillSilkToMaxSilent();
			PlayerData.instance.PreMemoryState = HeroItemsState.Record(HeroController.instance);
			PlayerData.instance.HasStoredMemoryState = true;
			PlayerData.instance.CaptureToolAmountsOverride();
		}
	}
	internal class WakeUpRespawn : MonoBehaviour
	{
		private PlayMakerFSM _control;

		private void Awake()
		{
			Setup();
		}

		private async Task Setup()
		{
			try
			{
				SilkenSisters.Log.LogDebug((object)"[WakeUpRespawn.Setup] Started setting WakeUpRespawn up");
				getComponents();
				setName();
				setPosition();
				editFSM();
				SilkenSisters.Log.LogDebug((object)"[WakeUpRespawn.Setup] Finished");
			}
			catch (Exception ex)
			{
				SilkenSisters.Log.LogError((object)$"{ex} {ex.Message}");
			}
		}

		private void getComponents()
		{
			_control = FsmUtil.GetFsmPreprocessed(((Component)this).gameObject, "Wake Up");
		}

		private void setName()
		{
			((Object)((Component)this).gameObject).name = "door_wakeOnGround_phantom";
			SilkenSisters.Log.LogDebug((object)("[WakeUpRespawn.setName] gateName:" + ((Object)((Component)this).gameObject).name));
		}

		private void setPosition()
		{
			//IL_001a: 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)
			((Component)this).gameObject.transform.position = new Vector3(59.249f, 56.7457f, 0f);
			SilkenSisters.Log.LogDebug((object)$"[WakeUpRespawn.setPosition] gatePosition:{((Component)this).gameObject.transform.position}");
		}

		private void editFSM()
		{
			FsmUtil.DisableAction(FsmUtil.GetFsmPreprocessed(((Component)this).gameObject, "Wake Up"), "Save?", 1);
			FsmUtil.AddMethod(_control, "Fade Up", (Action)restoreHeroState, false);
			FsmUtil.AddMethod(_control, "End", (Action)disableDoor, false);
			FsmUtil.AddMethod(_control, "End", (Action)disableSelf, false);
		}

		private void disableDoor()
		{
			SilkenSisters.Log.LogDebug((object)"[WakeUpRespawn.disableDoor] Trying to disable door");
			SilkenSisters.instance.wakeupPointInstance.SetActive(false);
			SilkenSisters.instance.wakeupPointInstance.GetComponent<PlayMakerFSM>().fsm.Reinitialize();
			UnityExtensions.FindChild(SilkenSisters.instance.wakeupPointInstance, "door_wakeInMemory_phantom").GetComponent<PlayMakerFSM>().fsm.SetState("Pause");
			SilkenSisters.Log.LogDebug((object)$"[WakeUpRespawn.disableDoor] Door {((Object)SilkenSisters.instance.wakeupPointInstance).name} enabled?:{SilkenSisters.instance.wakeupPointInstance.activeSelf}");
		}

		private void disableSelf()
		{
			((Component)this).gameObject.SetActive(false);
			SilkenSisters.Log.LogDebug((object)$"[WakeUpRespawn.disableSelf] {((Component)this).gameObject.activeSelf}");
		}

		private void restoreHeroState()
		{
			if (PlayerData.instance.HasStoredMemoryState)
			{
				HeroController.instance.ClearEffectsInstant();
				((HeroItemsState)(ref PlayerData.instance.PreMemoryState)).Apply(HeroController.instance);
				PlayerData.instance.HasStoredMemoryState = false;
				PlayerData.instance.ClearToolAmountsOverride();
			}
		}
	}
	internal class FightSelectionLever : MonoBehaviour
	{
		private GameObject infoPrompt;

		private BasicNPC promptnpc;

		private void Awake()
		{
			Setup();
		}

		private async Task Setup()
		{
			((Component)this).gameObject.transform.position = new Vector3(60.9817f, 51.961f, 1.8055f);
			Extensions.SetRotationZ(((Component)this).gameObject.transform, 320.1306f);
			UnityExtensions.FindChild(((Component)this).gameObject, "Platform").SetActive(false);
			UnityExtensions.FindChild(((Component)this).gameObject, "Enviro Region Simple (2)").SetActive(false);
			UnityExtensions.FindChild(((Component)this).gameObject, "Hero Detector Close").SetActive(false);
			UnityExtensions.FindChild(((Component)this).gameObject, "Hero Detector Scene Enter").SetActive(false);
			UnityExtensions.FindChild(((Component)this).gameObject, "axel").SetActive(false);
			UnityExtensions.FindChild(((Component)this).gameObject, "Levers/Lever Bottom").SetActive(false);
			UnityExtensions.FindChild(((Component)this).gameObject, "Levers/Lever Top").GetComponent<Lever>().OnHit.AddListener(new UnityAction(FlipSync));
			UnityExtensions.FindChild(((Component)this).gameObject, "Levers/Lever Top").GetComponent<Lever>().OnHit.AddListener(new UnityAction(DisablePrompt));
			UnityExtensions.FindChild(((Component)this).gameObject, "Levers/Lever Top").GetComponent<Lever>().OnHitDelayed.AddListener(new UnityAction(SetLeverText));
			addInfo();
		}

		private void addInfo()
		{
			//IL_0070: 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)
			infoPrompt = ManagedAssetExtensions.InstantiateAsset<GameObject>(SilkenSisters.instance.assetManager.sceneCache, "infoPromptCache");
			promptnpc = infoPrompt.GetComponent<BasicNPC>();
			infoPrompt.transform.SetParent(UnityExtensions.FindChild(((Component)this).gameObject, "Levers/Lever Top/Lever").transform, true);
			infoPrompt.transform.position = new Vector3(62.6255f, 53.961f, 1.8055f);
			UnityExtensions.FindChild(infoPrompt, "Prompt Marker").transform.position = new Vector3(62.6255f, 56.4146f, 2.0055f);
			SetLeverText();
		}

		private void SetLeverText()
		{
			promptnpc.talkText[0].Sheet = "Mods.io.github.al3ks1s.silkensisters";
			if (SilkenSisters.instance.configManager.syncedFight.Value)
			{
				promptnpc.talkText[0].Key = "SILKEN_SISTERS_SYNC_FIGHT_ON";
			}
			else
			{
				promptnpc.talkText[0].Key = "SILKEN_SISTERS_SYNC_FIGHT_OFF";
			}
			infoPrompt.SetActive(true);
		}

		private void DisablePrompt()
		{
			infoPrompt.SetActive(false);
		}

		private void FlipSync()
		{
			SilkenSisters.instance.configManager.syncedFight.Value = !SilkenSisters.instance.configManager.syncedFight.Value;
		}
	}
	internal class InfoPrompt : MonoBehaviour
	{
		private BasicNPC _npc;

		private void Awake()
		{
			Setup();
		}

		private async Task Setup()
		{
			try
			{
				SilkenSisters.Log.LogDebug((object)"[ChallengeRegion.Setup] Started setting up info prompt");
				getComponents();
				setPosition();
				setText();
				SilkenSisters.Log.LogDebug((object)"[ChallengeRegion.Setup] Finished setting up info prompt");
			}
			catch (Exception ex)
			{
				SilkenSisters.Log.LogError((object)$"{ex} {ex.Message}");
			}
		}

		private void getComponents()
		{
			_npc = ((Component)this).GetComponent<BasicNPC>();
		}

		private void setPosition()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).gameObject.transform.position = new Vector3(59.8327f, 54.3406f, 0.006f);
		}

		private void setText()
		{
			_npc.talkText[0].Sheet = "Mods.io.github.al3ks1s.silkensisters";
			_npc.talkText[0].Key = "SILKEN_SISTERS_INFOPROMPT";
			SilkenSisters.Log.LogDebug((object)Language.Get("SILKEN_SISTERS_INFOPROMPT", "Mods.io.github.al3ks1s.silkensisters"));
		}
	}
	internal class Lace1 : MonoBehaviour
	{
		private PlayMakerFSM _control;

		private HealthManager _healthManager;

		private void Awake()
		{
			Setup();
		}

		private async Task Setup()
		{
			try
			{
				SilkenSisters.Log.LogDebug((object)"[Lace1.Setup] Started setting up Lace");
				getComponents();
				buffHealth();
				editPositionConstraint();
				rerouteState();
				fixActionsPositions();
				disableTitleCard();
				setLaceFacing();
				DisableMusic();
				PrepareCorpse();
				SilkenSisters.Log.LogDebug((object)"[Lace1.Setup] Finished setting up Lace");
			}
			catch (Exception ex)
			{
				SilkenSisters.Log.LogError((object)$"{ex} {ex.Message}");
			}
		}

		private void getComponents()
		{
			//IL_001a: 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)
			((Component)this).gameObject.transform.position = new Vector3(78.2832f, 104.5677f, 0.004f);
			SilkenSisters.Log.LogDebug((object)$"[Lace1.getComponents] position:{((Component)this).gameObject.transform.position}");
			_control = FsmUtil.GetFsmPreprocessed(((Component)this).gameObject, "Control");
			_healthManager = ((Component)this).gameObject.GetComponent<HealthManager>();
		}

		private void buffHealth()
		{
			((Component)this).gameObject.GetComponent<HealthManager>().initHp = 600;
			((Component)this).gameObject.GetComponent<HealthManager>().hp = 600;
			FsmUtil.GetIntVariable(_control, "Rage HP").value = 300;
		}

		private void editPositionConstraint()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			ConstrainPosition val = (ConstrainPosition)((Component)this).gameObject.GetComponent(typeof(ConstrainPosition));
			val.SetXMin(72.4f);
			val.SetXMax(96.52f);
			val.SetYMin(104f);
			val.constrainX = true;
			val.constrainY = true;
			SilkenSisters.Log.LogDebug((object)("[Lace1.editPositionConstraint] Constraints: " + $"MinX:{val.xMin}" + $"MaxX:{val.xMax}" + $"MinY:{val.yMin}"));
		}

		private void rerouteState()
		{
			FsmUtil.ChangeTransition(_control, "Encountered?", "MEET", "Refight");
			FsmUtil.AddTransition(_control, "Dormant", "BATTLE START REFIGHT", "Encountered?");
			FsmUtil.AddTransition(_control, "Dormant", "BATTLE START FIRST", "Encountered?");
			FsmUtil.ChangeTransition(_control, "Start Battle", "FINISHED", "Idle");
			SilkenSisters.Log.LogDebug((object)("[Lace1.rerouteState] \n              Encountered:Meet -> " + FsmUtil.GetTransition(_control, "Encountered?", "MEET").ToState));
		}

		private void fixActionsPositions()
		{
			SilkenSisters.Log.LogDebug((object)"Fix floor heights");
			FsmUtil.GetAction<FloatInRange>(_control, "Downstab Land", 1).lowerValue = FsmFloat.op_Implicit(73f);
			FsmUtil.GetAction<FloatInRange>(_control, "Downstab Land", 1).upperValue = FsmFloat.op_Implicit(96f);
			SilkenSisters.Log.LogDebug((object)string.Format("[Lace1.fixActionsPositions] Downstab Land Pos: min:{0}, max:{1}", FsmUtil.GetAction<FloatInRange>(_control, "Downstab Land", 1).lowerValue, FsmUtil.GetAction<FloatInRange>(_control, "Downstab Land", 1).upperValue));
			FsmUtil.GetAction<FloatInRange>(_control, "Dstab Constrain?", 1).lowerValue = FsmFloat.op_Implicit(73f);
			FsmUtil.GetAction<FloatInRange>(_control, "Dstab Constrain?", 1).upperValue = FsmFloat.op_Implicit(96f);
			SilkenSisters.Log.LogDebug((object)string.Format("[Lace1.fixActionsPositions] CrossSlash Pos: min:{0}, max:{1}", FsmUtil.GetAction<FloatInRange>(_control, "Dstab Constrain?", 1).lowerValue, FsmUtil.GetAction<FloatInRange>(_control, "Dstab Constrain?", 1).upperValue));
			FsmUtil.FindFloatVariable(_control, "Land Y").Value = 104.5677f;
			FsmUtil.FindFloatVariable(_control, "Centre X").Value = 84f;
			SilkenSisters.Log.LogDebug((object)("[Lace1.fixActionsPositions] Float vars: " + string.Format("Land Y: {0} ", FsmUtil.FindFloatVariable(_control, "Land Y").Value) + string.Format("Centre X: {0}", FsmUtil.FindFloatVariable(_control, "Centre X").Value)));
		}

		private void disableTitleCard()
		{
			SilkenSisters.Log.LogDebug((object)"[Lace1.disableTitleCard] Disabling title card");
			FsmUtil.DisableAction(_control, "Start Battle", 3);
			SilkenSisters.Log.LogDebug((object)("[Lace1.disableTitleCard] " + string.Format("(Start Battle):{0}", FsmUtil.GetStateAction(_control, "Start Battle", 3).active)));
		}

		private void DisableMusic()
		{
			FsmUtil.DisableAction(_control, "Start Battle", 1);
		}

		private void setLaceFacing()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Expected O, but got Unknown
			FaceObjectV2 val = new FaceObjectV2();
			val.spriteFacesRight = FsmBool.op_Implicit(true);
			val.playNewAnimation = false;
			val.newAnimationClip = FsmString.op_Implicit("");
			val.resetFrame = false;
			val.everyFrame = false;
			val.pauseBetweenTurns = 0.5f;
			val.objectA = SilkenSisters.instance.laceBossFSMOwner;
			val.objectB = FsmGameObject.op_Implicit(SilkenSisters.hornet);
			FsmUtil.InsertAction(_control, "Init", (FsmStateAction)(object)val, 4);
			SilkenSisters.Log.LogDebug((object)string.Format("[Lace1.setLaceFacing] Facing Action:{0}", ((object)FsmUtil.GetStateAction(_control, "Init", 4)).GetType()));
			FsmUtil.DisableAction(_control, "Refight", 1);
			Tk2dPlayAnimation val2 = new Tk2dPlayAnimation();
			val2.animLibName = FsmString.op_Implicit("");
			val2.clipName = FsmString.op_Implicit("Idle");
			val2.gameObject = SilkenSisters.instance.laceBossFSMOwner;
			FsmUtil.InsertAction(_control, "Dormant", 1, (FsmStateAction)(object)val2);
			SilkenSisters.Log.LogDebug((object)$"[Lace1.setLaceFacing] fsmowner:{val2.gameObject}");
		}

		private void addDamageDelegate()
		{
			_healthManager.TookDamage += TransferDamage;
		}

		private void TransferDamage()
		{
			SilkenSisters.Log.LogDebug((object)$"Lace: {_healthManager.hp}");
			SilkenSisters.Log.LogDebug((object)$"Lace: {_healthManager.lastHitInstance.DamageDealt}");
		}

		private void PrepareCorpse()
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0096: Expected O, but got Unknown
			//IL_009b: Expected O, but got Unknown
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: 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_00c8: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Expected O, but got Unknown
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: 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_0106: Expected O, but got Unknown
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Expected O, but got Unknown
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Expected O, but got Unknown
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: 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_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Expected O, but got Unknown
			//IL_01ae: 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_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Expected O, but got Unknown
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Expected O, but got Unknown
			//IL_01d7: Expected O, but got Unknown
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Expected O, but got Unknown
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: 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_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Expected O, but got Unknown
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Expected O, but got Unknown
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: 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_027b: Expected O, but got Unknown
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Expected O, but got Unknown
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Expected O, but got Unknown
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Expected O, but got Unknown
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: 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_0307: Expected O, but got Unknown
			//IL_030c: Expected O, but got Unknown
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Expected O, but got Unknown
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0353: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_0369: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Expected O, but got Unknown
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Expected O, but got Unknown
			SilkenSisters.Log.LogDebug((object)"Started setting corpse handler");
			GameObject obj = UnityExtensions.FindChild(((Component)this).gameObject, "Corpse Lace1(Clone)");
			PlayMakerFSM fsmPreprocessed = FsmUtil.GetFsmPreprocessed(obj, "Control");
			obj.GetComponent<ConstrainPosition>().SetXMin(70f);
			FsmUtil.DisableAction(fsmPreprocessed, "Start", 1);
			FsmUtil.DisableAction(fsmPreprocessed, "Start", 2);
			FsmUtil.DisableAction(fsmPreprocessed, "Jump Away", 8);
			FsmUtil.AddState(fsmPreprocessed, "Tele Out");
			FsmUtil.AddAction(fsmPreprocessed, "Tele Out", (FsmStateAction)new SetIsKinematic2d
			{
				isKinematic = FsmBool.op_Implicit(true),
				gameObject = new FsmOwnerDefault
				{
					OwnerOption = (OwnerDefaultOption)0
				}
			});
			FsmUtil.AddAction(fsmPreprocessed, "Tele Out", (FsmStateAction)new Tk2dPlayAnimationWithEvents
			{
				clipName = FsmString.op_Implicit("Tele Out"),
				gameObject = new FsmOwnerDefault
				{
					OwnerOption = (OwnerDefaultOption)0
				},
				animationCompleteEvent = FsmEvent.GetFsmEvent("FINISHED")
			});
			FsmUtil.AddState(fsmPreprocessed, "Tele In");
			FsmUtil.AddAction(fsmPreprocessed, "Tele In", (FsmStateAction)new FaceObjectV2
			{
				objectA = new FsmOwnerDefault
				{
					OwnerOption = (OwnerDefaultOption)0
				},
				objectB = new FsmGameObject
				{
					Value = GameObject.Find("Boss Scene/Gates/Battle Gate")
				},
				newAnimationClip = FsmString.op_Implicit(""),
				playNewAnimation = false,
				spriteFacesRight = FsmBool.op_Implicit(true),
				resetFrame = false,
				everyFrame = false,
				pauseBetweenTurns = 0f
			});
			FsmUtil.AddAction(fsmPreprocessed, "Tele In", (FsmStateAction)new PlayRandomAudioClipTable
			{
				Table = FsmUtil.GetAction<PlayRandomAudioClipTable>(_control, "Lava Tele Out", 0).Table,
				SpawnPosition = new FsmVector3
				{
					Value = new Vector3(0f, 0f, 0f)
				},
				SpawnPoint = new FsmOwnerDefault
				{
					OwnerOption = (OwnerDefaultOption)0
				},
				AudioPlayerPrefab = new FsmObject
				{
					Value = null
				}
			});
			FsmUtil.AddAction(fsmPreprocessed, "Tele In", (FsmStateAction)new SetPosition
			{
				gameObject = new FsmOwnerDefault
				{
					OwnerOption = (OwnerDefaultOption)0
				},
				vector = new FsmVector3
				{
					Value = new Vector3(81.9569f, 106.2943f, 2.7723f)
				},
				x = FsmFloat.op_Implicit(81.9569f),
				y = FsmFloat.op_Implicit(107.0221f),
				z = FsmFloat.op_Implicit(2.7723f)
			});
			FsmUtil.AddAction(fsmPreprocessed, "Tele In", (FsmStateAction)new Tk2dPlayAnimationWithEvents
			{
				clipName = FsmString.op_Implicit("Tele In"),
				gameObject = new FsmOwnerDefault
				{
					OwnerOption = (OwnerDefaultOption)0
				},
				animationCompleteEvent = FsmEvent.GetFsmEvent("FINISHED")
			});
			FsmUtil.AddState(fsmPreprocessed, "Ouchie");
			FsmUtil.AddAction(fsmPreprocessed, "Ouchie", (FsmStateAction)new Tk2dPlayAnimation
			{
				clipName = FsmString.op_Implicit("Death Land Stun"),
				gameObject = new FsmOwnerDefault
				{
					OwnerOption = (OwnerDefaultOption)0
				},
				animLibName = FsmString.op_Implicit("")
			});
			FsmUtil.AddAction(fsmPreprocessed, "Ouchie", (FsmStateAction)new Tk2dPlayFrame
			{
				frame = FsmInt.op_Implicit(5),
				gameObject = new FsmOwnerDefault
				{
					OwnerOption = (OwnerDefaultOption)0
				}
			});
			FsmUtil.AddAction(fsmPreprocessed, "Ouchie", (FsmStateAction)new Wait
			{
				finishEvent = FsmEvent.GetFsmEvent("FINISHED"),
				time = FsmFloat.op_Implicit(1f)
			});
			FsmUtil.AddState(fsmPreprocessed, "Man that hurts");
			FsmUtil.AddAction(fsmPreprocessed, "Man that hurts", (FsmStateAction)new Tk2dPlayAnimation
			{
				clipName = FsmString.op_Implicit("Death 1"),
				gameObject = new FsmOwnerDefault
				{
					OwnerOption = (OwnerDefaultOption)0
				},
				animLibName = FsmString.op_Implicit("")
			});
			FsmUtil.ChangeTransition(fsmPreprocessed, "Land", "FINISHED", "Tele Out");
			FsmUtil.AddTransition(fsmPreprocessed, "Tele Out", "FINISHED", "Tele In");
			FsmUtil.AddTransition(fsmPreprocessed, "Tele In", "FINISHED", "Ouchie");
			FsmUtil.AddTransition(fsmPreprocessed, "Ouchie", "FINISHED", "Man that hurts");
			FsmUtil.AddTransition(fsmPreprocessed, "Man that hurts", "LACE JUMP", "Jump Antic");
			SilkenSisters.Log.LogDebug((object)"Finished setting up corpse handler");
		}

		private void prepareSync()
		{
		}
	}
	internal class Lace1Scene : MonoBehaviour
	{
		private PlayMakerFSM _control;

		private void Awake()
		{
			Setup();
		}

		private async Task Setup()
		{
			SilkenSisters.Log.LogDebug((object)"[Lace1Scene.Setup] Started setting Lace scene up");
			getComponents();
			disableSceneObjects();
			moveSceneBounds();
			fixWallRangeAlert();
			SilkenSisters.Log.LogDebug((object)"[Lace1Scene.Setup] Finished setting Lace scene up");
		}

		private void getComponents()
		{
			_control = FsmUtil.GetFsmPreprocessed(((Component)this).gameObject, "Control");
		}

		private void disableSceneObjects()
		{
			SilkenSisters.Log.LogDebug((object)"[Lace1Scene.disableSceneObjects] Disabling unwanted LaceBossScene items");
			UnityExtensions.FindChild(((Component)this).gameObject, "Slam Particles").SetActive(false);
			UnityExtensions.FindChild(((Component)this).gameObject, "Battle Gates").SetActive(false);
			UnityExtensions.FindChild(((Component)this).gameObject, "Silkflies").SetActive(false);
			UnityExtensions.FindChild(((Component)this).gameObject, "Silkflies w/o Sprint").SetActive(false);
		}

		private void moveSceneBounds()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			SilkenSisters.Log.LogDebug((object)"[Lace1Scene.moveSceneBounds] Moving lace arena objects");
			UnityExtensions.FindChild(((Component)this).gameObject, "Arena Centre").transform.position = new Vector3(84.5f, 104f, 0f);
		}

		private void fixWallRangeAlert()
		{
			//IL_004a: 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_0089: 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_00b7: 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_00db: 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_0109: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = UnityExtensions.FindChild(((Component)((Component)this).gameObject.transform.parent).gameObject, "Wall Range");
			Extensions.SetPosition3D(val.transform, 84.0349f, 103.67f, 0f);
			SilkenSisters.Log.LogDebug((object)$"[Lace1.fixWallRangeAlert] position:{val.transform.position}");
			BoxCollider2D[] components = val.GetComponents<BoxCollider2D>();
			components[0].size = new Vector2(5f, 30f);
			((Collider2D)components[0]).offset = new Vector2(-9f, 0.4726f);
			components[1].size = new Vector2(5f, 35.1782f);
			((Collider2D)components[1]).offset = new Vector2(10f, 7.1234f);
			SilkenSisters.Log.LogDebug((object)$"[Lace1.fixWallRangeAlert] alertLeft: Size:{components[0].size}, Size:{((Collider2D)components[0]).offset}");
			SilkenSisters.Log.LogDebug((object)$"[Lace1.fixWallRangeAlert] alertRight: Size:{components[1].size}, Size:{((Collider2D)components[1]).offset}");
		}
	}
	internal class Lace2 : MonoBehaviour
	{
		private PlayMakerFSM _control;

		private HealthManager _healthManager;

		private void Awake()
		{
			Setup();
		}

		private async Task Setup()
		{
			try
			{
				SilkenSisters.Log.LogDebug((object)"[Lace2.Setup] Started setting up Lace");
				getComponents();
				disableParticleEffects();
				editPositionConstraint();
				rerouteState();
				fixActionsPositions();
				disableTitleCard();
				fixWallRangeAlert();
				disableLaceMusic();
				setLaceFacing();
				addDamageDelegate();
				PrepareCorpse();
				prepareSync();
				SilkenSisters.Log.LogDebug((object)$"Damage scaling: {_healthManager.damageScaling.Level1Mult} {_healthManager.damageScaling.Level2Mult} {_healthManager.damageScaling.Level3Mult} {_healthManager.damageScaling.Level4Mult} {_healthManager.damageScaling.Level5Mult} ");
				SilkenSisters.Log.LogDebug((object)"[Lace2.Setup] Finished setting up Lace");
				((Component)this).gameObject.SetActive(false);
			}
			catch (Exception ex)
			{
				SilkenSisters.Log.LogError((object)$"{ex} {ex.Message}");
			}
		}

		private void getComponents()
		{
			//IL_001a: 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)
			((Component)this).gameObject.transform.position = new Vector3(78.2832f, 104.5677f, 0.004f);
			SilkenSisters.Log.LogDebug((object)$"[Lace2.getComponents] position:{((Component)this).gameObject.transform.position}");
			_control = FsmUtil.GetFsmPreprocessed(((Component)this).gameObject, "Control");
			_healthManager = ((Component)this).gameObject.GetComponent<HealthManager>();
			_healthManager.damageScaling = UnityExtensions.FindChild(SilkenSisters.instance.phantomBossScene, "Phantom").GetComponent<HealthManager>().damageScaling;
		}

		private void disableParticleEffects()
		{
			UnityExtensions.FindChild(((Component)this).gameObject, "Pt DashPetal").SetActive(false);
			UnityExtensions.FindChild(((Component)this).gameObject, "Pt SkidPetal").SetActive(false);
			UnityExtensions.FindChild(((Component)this).gameObject, "Pt RisingPetal").SetActive(false);
			UnityExtensions.FindChild(((Component)this).gameObject, "Pt MovePetal").SetActive(false);
		}

		private void editPositionConstraint()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			ConstrainPosition val = (ConstrainPosition)((Component)this).gameObject.GetComponent(typeof(ConstrainPosition));
			val.SetXMin(72.4f);
			val.SetXMax(96.52f);
			val.SetYMin(104f);
			val.constrainX = true;
			val.constrainY = true;
			SilkenSisters.Log.LogDebug((object)("[Lace2.editPositionConstraint] Constraints: " + $"MinX:{val.xMin}" + $"MaxX:{val.xMax}" + $"MinY:{val.yMin}"));
		}

		private void rerouteState()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			FsmUtil.ChangeTransition(_control, "Init", "REFIGHT", "Start Battle Wait");
			FsmUtil.ChangeTransition(_control, "Start Battle Wait", "BATTLE START REFIGHT", "Refight Engarde");
			FsmUtil.ChangeTransition(_control, "Start Battle Wait", "BATTLE START FIRST", "Refight Engarde");
			new Wait().time = FsmFloat.op_Implicit(2f);
			SilkenSisters.Log.LogDebug((object)("[Lace2.rerouteState] \n              Init:REFIGHT -> " + FsmUtil.GetTransition(_control, "Init", "REFIGHT").ToState + " \n              Start Battle Wait:BATTLE START REFIGHT -> " + FsmUtil.GetTransition(_control, "Start Battle Wait", "BATTLE START REFIGHT").ToState + "\n              Start Battle Wait:BATTLE START FIRST -> " + FsmUtil.GetTransition(_control, "Start Battle Wait", "BATTLE START FIRST").ToState));
		}

		private void fixActionsPositions()
		{
			SilkenSisters.Log.LogDebug((object)"Fix floor heights");
			FsmUtil.GetAction<SetPosition2d>(_control, "ComboSlash 1", 0).y = FsmFloat.op_Implicit(104.5677f);
			FsmUtil.GetAction<SetPosition2d>(_control, "Charge Antic", 2).y = FsmFloat.op_Implicit(104.5677f);
			FsmUtil.GetAction<SetPosition2d>(_control, "Counter Antic", 1).y = FsmFloat.op_Implicit(104.5677f);
			SilkenSisters.Log.LogDebug((object)("[Lace2.fixActionsPositions] Floor heights:\n" + string.Format("              ComboSlash 1: {0}\n", FsmUtil.GetAction<SetPosition2d>(_control, "ComboSlash 1", 0).y) + string.Format("              Charge Antic: {0}\n", FsmUtil.GetAction<SetPosition2d>(_control, "Charge Antic", 2).y) + string.Format("              Counter Antic {0}", FsmUtil.GetAction<SetPosition2d>(_control, "Counter Antic", 1).y)));
			FsmUtil.GetAction<SetPosition>(_control, "Counter TeleIn", 5).y = FsmFloat.op_Implicit(110f);
			SilkenSisters.Log.LogDebug((object)string.Format("[Lace2.fixActionsPositions] TeleHeight: {0}", FsmUtil.GetAction<SetPosition>(_control, "Counter TeleIn", 5).y));
			FsmUtil.GetAction<FloatClamp>(_control, "Counter TeleIn", 4).minValue = FsmFloat.op_Implicit(73f);
			FsmUtil.GetAction<FloatClamp>(_control, "Counter TeleIn", 4).maxValue = FsmFloat.op_Implicit(96f);
			SilkenSisters.Log.LogDebug((object)string.Format("[Lace2.fixActionsPositions] TeleXClamp: min:{0}, max:{1}", FsmUtil.GetAction<FloatClamp>(_control, "Counter TeleIn", 4).minValue, FsmUtil.GetAction<FloatClamp>(_control, "Counter TeleIn", 4).maxValue));
			FsmUtil.FindFloatVariable(_control, "Tele Out Floor").Value = 103f;
			FsmUtil.GetAction<FloatClamp>(_control, "Tele In", 6).minValue = FsmFloat.op_Implicit(73f);
			FsmUtil.GetAction<FloatClamp>(_control, "Tele In", 6).maxValue = FsmFloat.op_Implicit(96f);
			FsmUtil.GetAction<SetPosition2d>(_control, "Tele In", 7).y = FsmFloat.op_Implicit(104.5677f);
			FsmUtil.GetAction<FloatClamp>(_control, "Set CrossSlash Pos", 1).minValue = FsmFloat.op_Implicit(73f);
			FsmUtil.GetAction<FloatClamp>(_control, "Set CrossSlash Pos", 1).maxValue = FsmFloat.op_Implicit(96f);
			SilkenSisters.Log.LogDebug((object)string.Format("[Lace2.fixActionsPositions] CrossSlash Pos: min:{0}, max:{1}", FsmUtil.GetAction<FloatClamp>(_control, "Set CrossSlash Pos", 1).minValue, FsmUtil.GetAction<FloatClamp>(_control, "Set CrossSlash Pos", 1).maxValue));
			FsmUtil.FindFloatVariable(_control, "Land Y").Value = 104.5677f;
			FsmUtil.FindFloatVariable(_control, "Arena Plat Bot Y").Value = 102f;
			FsmUtil.FindFloatVariable(_control, "Centre X").Value = 84f;
			SilkenSisters.Log.LogDebug((object)("[Lace2.fixActionsPositions] Float vars: " + string.Format("Land Y: {0} ", FsmUtil.FindFloatVariable(_control, "Land Y").Value) + string.Format("Arena Plat Bot Y: {0} ", FsmUtil.FindFloatVariable(_control, "Arena Plat Bot Y").Value) + string.Format("Centre X: {0}", FsmUtil.FindFloatVariable(_control, "Centre X").Value)));
			FsmUtil.GetAction<CheckXPosition>(_control, "Force R?", 2).compareTo = FsmFloat.op_Implicit(73f);
			FsmUtil.GetAction<CheckXPosition>(_control, "Force L?", 1).compareTo = FsmFloat.op_Implicit(96f);
			SilkenSisters.Log.LogDebug((object)string.Format("[Lace2.fixActionsPositions] Lace Dstab bounds: Left:{0}, Right:{1}", FsmUtil.GetAction<CheckXPosition>(_control, "Force R?", 2).compareTo, FsmUtil.GetAction<CheckXPosition>(_control, "Force L?", 1).compareTo));
			FsmUtil.GetAction<FloatTestToBool>(_control, "CrossSlash Aim", 10);
			FsmUtil.FindFloatVariable(_control, "Bomb Max X").Value = 96f;
			FsmUtil.FindFloatVariable(_control, "Bomb Min X").Value = 72f;
			FsmUtil.FindFloatVariable(_control, "Bomb Max Y").Value = 115f;
			FsmUtil.FindFloatVariable(_control, "Bomb Min Y").Value = 105f;
		}

		private void disableTitleCard()
		{
			SilkenSisters.Log.LogDebug((object)"[Lace2.disableTitleCard] Disabling title card");
			FsmUtil.DisableAction(_control, "Start Battle Refight", 4);
			FsmUtil.DisableAct