Decompiled source of SilkenSisters v0.2.2

SilkenSisters.dll

Decompiled 17 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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 SilkenSisters.Behaviors;
using SilkenSisters.SceneManagement;
using Silksong.FsmUtil;
using TeamCherry.Localization;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SilkenSisters")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.2.2.0")]
[assembly: AssemblyInformationalVersion("0.2.2+e5e3df041514f875684747b23d68c2a7b51eacc2")]
[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.2.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace SilkenSisters
{
	public class FSMEditor
	{
		public Dictionary<string, FsmState> states = new Dictionary<string, FsmState>();

		public Dictionary<string, Dictionary<string, FsmTransition>> transitions = new Dictionary<string, Dictionary<string, FsmTransition>>();

		public Dictionary<string, FsmEvent> events = new Dictionary<string, FsmEvent>();

		public static bool fsmEditorLog;

		public void compileFSM(ref PlayMakerFSM fsm)
		{
			FsmEvent[] fsmEvents = fsm.FsmEvents;
			foreach (FsmEvent val in fsmEvents)
			{
				events[val.Name] = val;
			}
			int num = 0;
			FsmState[] fsmStates = fsm.FsmStates;
			foreach (FsmState val2 in fsmStates)
			{
				states[val2.Name] = val2;
				transitions[val2.Name] = new Dictionary<string, FsmTransition>();
				if (fsmEditorLog)
				{
					SilkenSisters.Log.LogInfo((object)$"Index: {num} State: {states[val2.Name].Name}. {val2.Transitions.Length} Transitions");
				}
				FsmTransition[] array = val2.Transitions;
				foreach (FsmTransition val3 in array)
				{
					transitions[val2.Name][val3.EventName] = val3;
					if (fsmEditorLog)
					{
						SilkenSisters.Log.LogInfo((object)("   Transition : " + transitions[val2.Name][val3.EventName].EventName + ", " + transitions[val2.Name][val3.EventName].ToState));
					}
				}
				FsmStateAction[] actions = val2.Actions;
				foreach (FsmStateAction val4 in actions)
				{
					if (fsmEditorLog)
					{
						SilkenSisters.Log.LogInfo((object)$"       Action : {((object)val4).GetType()}");
					}
				}
				if (fsmEditorLog)
				{
					SilkenSisters.Log.LogInfo((object)"");
				}
				num++;
			}
		}
	}
	public class InvokeMethod : FsmStateAction
	{
		private readonly Action _action;

		public InvokeMethod(Action action)
		{
			_action = action;
		}

		public override void OnEnter()
		{
			_action();
			((FsmStateAction)this).Finish();
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("io.github.al3ks1s.silkensisters", "SilkenSisters", "0.2.2")]
	public class SilkenSisters : BaseUnityPlugin
	{
		[CompilerGenerated]
		private sealed class <WaitAndPatch>d__33 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

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

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

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

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

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

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

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

		public static SilkenSisters plugin;

		public static Scene organScene;

		public GameObject laceNPCCache;

		public GameObject lace2BossSceneCache;

		public GameObject lace1BossSceneCache;

		public GameObject challengeDialogCache;

		public GameObject wakeupPointCache;

		public GameObject deepMemoryCache;

		public GameObject infoPromptCache;

		public FsmState ExitMemoryCache;

		public GameObject laceNPCInstance;

		public FsmOwnerDefault laceNPCFSMOwner;

		public GameObject lace2BossInstance;

		public GameObject lace2BossSceneInstance;

		public FsmOwnerDefault laceBossFSMOwner;

		public GameObject lace1BossInstance;

		public GameObject lace1BossSceneInstance;

		public GameObject challengeDialogInstance;

		public GameObject wakeupPointInstance;

		public GameObject respawnPointInstance;

		public GameObject deepMemoryInstance;

		public GameObject infoPromptInstance;

		public GameObject phantomBossScene;

		public FsmOwnerDefault phantomBossSceneFSMOwner;

		private bool cachingSceneObjects;

		public static GameObject hornet;

		public static FsmOwnerDefault hornetFSMOwner;

		public static ConstrainPosition hornetConstrain;

		private string laceBossPrefabName;

		private ConfigEntry<KeyCode> modifierKey;

		private ConfigEntry<KeyCode> actionKey;

		internal static ManualLogSource Log;

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

		public static string Name => "SilkenSisters";

		public static string Version => "0.2.2";

		private void Awake()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Invalid comparison between Unknown and I4
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Invalid comparison between Unknown and I4
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Invalid comparison between Unknown and I4
			Log = new ManualLogSource("SilkenSisters");
			Logger.Sources.Add((ILogSource)(object)Log);
			plugin = this;
			modifierKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keybinds", "Modifier", (KeyCode)308, "Modifier");
			((MonoBehaviour)this).StartCoroutine(WaitAndPatch());
			SceneManager.sceneLoaded += onSceneLoaded;
			string streamingAssetsPath = Application.streamingAssetsPath;
			RuntimePlatform platform = Application.platform;
			string path = (((int)platform == 1) ? "StandaloneOSX" : (((int)platform == 2) ? "StandaloneWindows64" : (((int)platform != 13) ? "" : "StandaloneLinux64")));
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(streamingAssetsPath, "aa", path, "localpoolprefabs_assets_laceboss.bundle"));
			laceBossPrefabName = ((Object)val).GetName();
			val.Unload(true);
			Harmony.CreateAndPatchAll(typeof(SilkenSisters), (string)null);
			((BaseUnityPlugin)this).Logger.LogMessage((object)"Plugin loaded and initialized");
		}

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

		[HarmonyPrefix]
		[HarmonyPatch(typeof(HeroController), "Die")]
		private static void setDeathListener(HeroController __instance, ref bool nonLethal, ref bool frostDeath)
		{
			Log.LogInfo((object)$"[DeathListener] Hornet died nonLethal:{nonLethal} frost:{frostDeath} / isMemory? Mod:{isMemory()} Scene:{GameManager._instance.IsMemoryScene()}");
			if (isMemory() || GameManager._instance.IsMemoryScene())
			{
				PlayerData._instance.defeatedPhantom = true;
				PlayerData._instance.blackThreadWorld = true;
				if ((Object)(object)hornetConstrain != (Object)null)
				{
					((Behaviour)hornetConstrain).enabled = false;
				}
				Log.LogInfo((object)$"[DeathListener] Hornet died in memory, variable reset: defeatedPhantom:{PlayerData._instance.defeatedPhantom}, blackThreadWorld:{PlayerData._instance.blackThreadWorld}");
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(GameManager), "SaveGame", new Type[]
		{
			typeof(int),
			typeof(Action<bool>),
			typeof(bool),
			typeof(AutoSaveName)
		})]
		private static bool setSaveListener(GameManager __instance, ref int saveSlot, ref Action<bool> ogCallback, ref bool withAutoSave, ref AutoSaveName autoSaveName)
		{
			ogCallback?.Invoke(obj: true);
			Log.LogInfo((object)$"[SaveListener] Trying to save game. isMemory? Mod:{isMemory()} Scene:{GameManager._instance.IsMemoryScene()}. Skipping?:{isMemory() || GameManager._instance.IsMemoryScene()}");
			if (!isMemory())
			{
				return !GameManager._instance.IsMemoryScene();
			}
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(FsmState), "OnEnter")]
		private static void setEventListener(FsmState __instance)
		{
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Expected O, but got Unknown
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Expected O, but got Unknown
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Expected O, but got Unknown
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			if (((Object)__instance.Fsm.GameObject).name == "Corpse Lace2(Clone)" && __instance.Name == "Start" && isMemory())
			{
				Log.LogInfo((object)"Started setting corpse handler");
				GameObject gameObject = __instance.Fsm.GameObject;
				GameObject val = GameObject.Find(((Object)__instance.Fsm.GameObject).name + "/NPC");
				Log.LogInfo((object)$"{val}");
				FSMEditor fSMEditor = new FSMEditor();
				PlayMakerFSM fsm = gameObject.GetComponent<PlayMakerFSM>();
				fSMEditor.compileFSM(ref fsm);
				new FSMEditor();
				PlayMakerFSM fsm2 = val.GetComponent<PlayMakerFSM>();
				fSMEditor.compileFSM(ref fsm2);
				Log.LogInfo((object)"Fixing facing");
				PlayMakerFSM fsmPreprocessed = FsmUtil.GetFsmPreprocessed(gameObject, "Control");
				FsmUtil.GetAction<CheckXPosition>(fsmPreprocessed, "Set Facing", 0).compareTo = FsmFloat.op_Implicit(72f);
				FsmUtil.GetAction<CheckXPosition>(fsmPreprocessed, "Set Facing", 1).compareTo = FsmFloat.op_Implicit(96f);
				Log.LogInfo((object)"Disabling interact action");
				FsmUtil.DisableAction(fsmPreprocessed, "NPC Ready", 0);
				SendEventByName val2 = new SendEventByName();
				val2.sendEvent = FsmString.op_Implicit("INTERACT");
				val2.delay = FsmFloat.op_Implicit(0f);
				FsmOwnerDefault val3 = new FsmOwnerDefault();
				val3.gameObject = FsmGameObject.op_Implicit(val);
				val3.ownerOption = (OwnerDefaultOption)1;
				FsmEventTarget val4 = new FsmEventTarget();
				val4.gameObject = val3;
				val4.target = (EventTarget)1;
				val2.eventTarget = val4;
				FsmUtil.AddAction(fsmPreprocessed, "NPC Ready", (FsmStateAction)(object)val2);
				Log.LogInfo((object)"Editing NPC routes to skip dialogue");
				PlayMakerFSM fsmPreprocessed2 = FsmUtil.GetFsmPreprocessed(val, "Control");
				Log.LogInfo((object)"Editing Idle");
				FsmUtil.ChangeTransition(fsmPreprocessed2, "Idle", "INTERACT", "Drop Pause");
				Log.LogInfo((object)"Drop Pause");
				FsmUtil.DisableAction(fsmPreprocessed2, "Drop Pause", 0);
				FsmUtil.ChangeTransition(fsmPreprocessed2, "Drop Down", "FINISHED", "End Pause");
				FsmUtil.ChangeTransition(fsmPreprocessed2, "Drop Down", "IS_HURT", "End Pause");
				Log.LogInfo((object)"End Pause");
				FsmUtil.DisableAction(fsmPreprocessed2, "End Pause", 0);
				FsmUtil.GetAction<Wait>(fsmPreprocessed2, "End Pause", 1).time = FsmFloat.op_Implicit(0.5f);
				Log.LogInfo((object)"Disabling end actions");
				FsmUtil.DisableAction(fsmPreprocessed2, "End", 5);
				FsmUtil.DisableAction(fsmPreprocessed2, "End", 6);
				FsmUtil.DisableAction(fsmPreprocessed2, "End", 7);
				FsmUtil.DisableAction(fsmPreprocessed2, "End", 8);
				FsmUtil.DisableAction(fsmPreprocessed2, "End", 9);
				FsmUtil.DisableAction(fsmPreprocessed2, "End", 10);
				FsmUtil.DisableAction(fsmPreprocessed2, "End", 11);
				FsmUtil.DisableAction(fsmPreprocessed2, "End", 12);
				FsmUtil.DisableAction(fsmPreprocessed2, "End", 13);
				Log.LogInfo((object)"Disabling audio cutting");
				FsmUtil.DisableAction(fsmPreprocessed, "Start", 0);
				FsmUtil.DisableAction(fsmPreprocessed2, "Talk 1 Start", 3);
				FsmUtil.DisableAction(fsmPreprocessed2, "End", 0);
				Log.LogInfo((object)"Finished setting up corpse handler");
			}
			if (0 == 0 || (!(((Object)__instance.Fsm.GameObject).name == $"{plugin.deepMemoryInstance}") && !(((Object)__instance.Fsm.GameObject).name == "before") && !(((Object)__instance.Fsm.GameObject).name == "thread_memory")))
			{
				return;
			}
			Log.LogInfo((object)(((Object)__instance.Fsm.GameObject).name + ", " + __instance.fsm.name + ", Entering state " + __instance.Name));
			if (__instance.Actions.Length != 0)
			{
				FsmTransition[] transitions = __instance.transitions;
				foreach (FsmTransition val5 in transitions)
				{
					Log.LogInfo((object)("    transitions for state " + __instance.Name + ": " + val5.EventName + " to " + val5.toState));
				}
				FsmStateAction[] actions = __instance.Actions;
				foreach (FsmStateAction val6 in actions)
				{
					Log.LogInfo((object)$"        Action for state {__instance.Name}: {((object)val6).GetType()}");
				}
			}
		}

		public static bool canSetup()
		{
			//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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			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:{PlayerData._instance.defeatedLaceTower} ";
			obj[4] = $"DefeatedPhantom:{PlayerData._instance.defeatedPhantom} ";
			obj[5] = $"Act3:{PlayerData._instance.blackThreadWorld} ";
			obj[6] = $"Needolin:{PlayerData._instance.hasNeedolinMemoryPowerup}";
			log.LogDebug((object)string.Concat(obj));
			activeScene = SceneManager.GetActiveScene();
			if (((Scene)(ref activeScene)).name == "Organ_01" && PlayerData._instance.defeatedLaceTower && PlayerData._instance.defeatedPhantom && PlayerData._instance.blackThreadWorld)
			{
				return PlayerData._instance.hasNeedolinMemoryPowerup;
			}
			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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			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:{PlayerData._instance.defeatedPhantom} ";
			obj[4] = $"Act3:{PlayerData._instance.blackThreadWorld} ";
			obj[5] = $"Needolin:{PlayerData._instance.hasNeedolinMemoryPowerup}";
			log.LogDebug((object)string.Concat(obj));
			activeScene = SceneManager.GetActiveScene();
			if (((Scene)(ref activeScene)).name == "Organ_01" && !PlayerData._instance.defeatedPhantom && !PlayerData._instance.blackThreadWorld)
			{
				return PlayerData._instance.hasNeedolinMemoryPowerup;
			}
			return false;
		}

		private async Task cacheGameObjects()
		{
			if ((Object)(object)laceNPCCache == (Object)null || (Object)(object)lace2BossSceneCache == (Object)null || (Object)(object)challengeDialogCache == (Object)null || (Object)(object)wakeupPointCache == (Object)null || (Object)(object)deepMemoryCache == (Object)null)
			{
				cachingSceneObjects = true;
				if ((Object)(object)AssetBundle.GetAllLoadedAssetBundles().FirstOrDefault((Func<AssetBundle, bool>)((AssetBundle b) => ((Object)b).GetName() == laceBossPrefabName)) != (Object)null)
				{
					AssetBundle.GetAllLoadedAssetBundles().FirstOrDefault((Func<AssetBundle, bool>)((AssetBundle b) => ((Object)b).GetName() == laceBossPrefabName)).Unload(true);
				}
				string streamingAssetsPath = Application.streamingAssetsPath;
				RuntimePlatform platform = Application.platform;
				string path = (((int)platform == 1) ? "StandaloneOSX" : (((int)platform == 2) ? "StandaloneWindows64" : (((int)platform != 13) ? "" : "StandaloneLinux64")));
				AssetBundle laceBossPrefab = AssetBundle.LoadFromFile(Path.Combine(streamingAssetsPath, "aa", path, "localpoolprefabs_assets_laceboss.bundle"));
				((BaseUnityPlugin)this).Logger.LogMessage((object)"[cacheGameObjects] Initializing cache");
				laceNPCCache = await SceneObjectManager.loadObjectFromScene("Coral_19", "Encounter Scene Control/Lace Meet/Lace NPC Blasted Bridge");
				laceNPCCache.AddComponent<LaceNPC>();
				lace2BossSceneCache = await SceneObjectManager.loadObjectFromScene("Song_Tower_01", "Boss Scene");
				lace2BossSceneCache.AddComponent<Lace2Scene>();
				GameObject obj = SceneObjectManager.findChildObject(lace2BossSceneCache, "Lace Boss2 New");
				obj.AddComponent<Lace2>();
				((Behaviour)(DeactivateIfPlayerdataTrue)obj.GetComponent(typeof(DeactivateIfPlayerdataTrue))).enabled = false;
				challengeDialogCache = await SceneObjectManager.loadObjectFromScene("Cradle_03", "Boss Scene/Intro Sequence");
				wakeupPointCache = await SceneObjectManager.loadObjectFromScene("Memory_Coral_Tower", "Door Get Up");
				wakeupPointCache.AddComponent<WakeUpMemory>();
				GameObject obj2 = await SceneObjectManager.loadObjectFromScene("Memory_Coral_Tower", "Boss Scene");
				PlayMakerFSM fsmPreprocessed = FsmUtil.GetFsmPreprocessed(obj2, "Control");
				ExitMemoryCache = FsmUtil.GetState(fsmPreprocessed, "Exit Memory");
				Object.Destroy((Object)(object)obj2);
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"[cacheGameObjects] {ExitMemoryCache.name}, {ExitMemoryCache.actions.Length}");
				deepMemoryCache = await SceneObjectManager.loadObjectFromScene("Coral_Tower_01", "Memory Group");
				deepMemoryCache.AddComponent<DeepMemory>();
				deepMemoryCache.GetComponent<TestGameObjectActivator>().playerDataTest.TestGroups[0].Tests[0].FieldName = "defeatedPhantom";
				deepMemoryCache.GetComponent<TestGameObjectActivator>().playerDataTest.TestGroups[0].Tests[0].BoolValue = false;
				infoPromptCache = await SceneObjectManager.loadObjectFromScene("Arborium_01", "Inspect Region");
				infoPromptCache.AddComponent<InfoPrompt>();
				((BaseUnityPlugin)this).Logger.LogMessage((object)"[cacheGameObjects] Caching done");
				cachingSceneObjects = false;
				if ((Object)(object)laceBossPrefab != (Object)null)
				{
					((BaseUnityPlugin)this).Logger.LogMessage((object)"[cacheGameObjects] Unload lace prefab");
					laceBossPrefab.Unload(false);
				}
				if ((Object)(object)laceNPCCache == (Object)null || (Object)(object)lace2BossSceneCache == (Object)null || (Object)(object)challengeDialogCache == (Object)null || (Object)(object)wakeupPointCache == (Object)null || (Object)(object)deepMemoryCache == (Object)null)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)"[cacheGameObjects] One of the item requested could not be found");
				}
			}
			else
			{
				await Task.Delay(300);
			}
		}

		private void onSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_0012: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"[onSceneLoaded] Scene loaded : {((Scene)(ref scene)).name}, active scene : {SceneManager.GetActiveScene()}");
			_ = new string[4] { "Menu_Title", "Pre_Menu_Loader", "Pre_Menu_Intro", "Quit_To_Menu" };
			if (!cachingSceneObjects)
			{
				if (((Scene)(ref scene)).name == "Organ_01")
				{
					((BaseUnityPlugin)this).Logger.LogMessage((object)"[onSceneLoaded] Organ Detected, preloading");
					organScene = scene;
					preloadOrgan();
				}
				else
				{
					((BaseUnityPlugin)this).Logger.LogMessage((object)"[onSceneLoaded] Scene is not organ, clearing instances and cache");
					clearInstances();
					clearCache();
				}
			}
		}

		private async Task preloadOrgan()
		{
			await cacheGameObjects();
			if (!isMemory() && canSetup())
			{
				((BaseUnityPlugin)this).Logger.LogMessage((object)"[preloadOrgan] Is not memory and all requirements met, setting things up");
				setupDeepMemoryZone();
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"[preloadOrgan] Scene info: canSetup?:{canSetup()}, isMemory?:{isMemory()}");
				if (!isMemory() && !canSetup())
				{
					((BaseUnityPlugin)this).Logger.LogMessage((object)"[preloadOrgan] Displaying the info prompt");
					infoPromptInstance = Object.Instantiate<GameObject>(infoPromptCache);
					infoPromptInstance.SetActive(true);
				}
			}
			GameObject val = GameObject.Find("Deep Memory Enter Black(Clone)");
			if ((Object)(object)val != (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogMessage((object)"[preloadOrgan] Deleting leftover memory effect");
				Object.Destroy((Object)(object)val);
			}
		}

		private void clearInstances()
		{
			laceNPCInstance = null;
			laceNPCFSMOwner = null;
			lace2BossInstance = null;
			lace2BossSceneInstance = null;
			laceBossFSMOwner = null;
			lace1BossInstance = null;
			lace1BossSceneInstance = null;
			challengeDialogInstance = null;
			deepMemoryInstance = null;
			phantomBossScene = null;
			phantomBossSceneFSMOwner = 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;
			}
		}

		private void clearCache()
		{
			hornet = null;
			hornetFSMOwner = null;
			if ((Object)(object)hornetConstrain != (Object)null)
			{
				Object.Destroy((Object)(object)hornetConstrain);
				hornetConstrain = null;
			}
			Object.Destroy((Object)(object)laceNPCCache);
			Object.Destroy((Object)(object)lace2BossSceneCache);
			Object.Destroy((Object)(object)lace1BossSceneCache);
			Object.Destroy((Object)(object)challengeDialogCache);
			Object.Destroy((Object)(object)wakeupPointCache);
			Object.Destroy((Object)(object)deepMemoryCache);
			laceNPCCache = null;
			lace2BossSceneCache = null;
			lace1BossSceneCache = null;
			challengeDialogCache = null;
			wakeupPointCache = null;
			deepMemoryCache = null;
			ExitMemoryCache = null;
		}

		public void setupFight()
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Expected O, but got Unknown
			((BaseUnityPlugin)this).Logger.LogMessage((object)"[setupFight] Trying to register phantom");
			phantomBossScene = SceneObjectManager.findObjectInCurrentScene("Boss Scene");
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"[setupFight] {phantomBossScene}");
			((BaseUnityPlugin)this).Logger.LogMessage((object)"[setupFight] Registering FSMOwner");
			phantomBossSceneFSMOwner = new FsmOwnerDefault();
			phantomBossSceneFSMOwner.OwnerOption = (OwnerDefaultOption)1;
			phantomBossSceneFSMOwner.GameObject = FsmGameObject.op_Implicit(phantomBossScene);
			challengeDialogInstance = Object.Instantiate<GameObject>(challengeDialogCache);
			challengeDialogInstance.AddComponent<ChallengeRegion>();
			challengeDialogInstance.SetActive(true);
			lace2BossSceneInstance = Object.Instantiate<GameObject>(lace2BossSceneCache);
			lace2BossSceneInstance.SetActive(true);
			((BaseUnityPlugin)this).Logger.LogInfo((object)("[setupFight] Trying to find Lace Boss from scene " + ((Object)lace2BossSceneInstance.gameObject).name));
			lace2BossInstance = SceneObjectManager.findChildObject(lace2BossSceneInstance, "Lace Boss2 New");
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"[setupFight] Lace object: {lace2BossInstance}");
			lace2BossInstance.SetActive(false);
			laceBossFSMOwner = new FsmOwnerDefault();
			laceBossFSMOwner.OwnerOption = (OwnerDefaultOption)1;
			laceBossFSMOwner.GameObject = FsmGameObject.op_Implicit(lace2BossInstance);
			laceNPCInstance = Object.Instantiate<GameObject>(laceNPCCache);
			laceNPCInstance.SetActive(true);
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"[setupFight] Trying to set up phantom : phantom available? {(Object)(object)phantomBossScene != (Object)null}");
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"[setupFight] {phantomBossScene}");
			phantomBossScene.AddComponent<PhantomScene>();
			SceneObjectManager.findChildObject(phantomBossScene, "Phantom").AddComponent<PhantomBoss>();
		}

		private void setupDeepMemoryZone()
		{
			deepMemoryInstance = Object.Instantiate<GameObject>(deepMemoryCache);
			deepMemoryInstance.SetActive(true);
			if ((Object)(object)wakeupPointInstance == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogMessage((object)"[setupDeepMemoryZone] Setting up memory wake point");
				wakeupPointInstance = Object.Instantiate<GameObject>(wakeupPointCache);
				wakeupPointInstance.SetActive(false);
				Object.DontDestroyOnLoad((Object)(object)wakeupPointInstance);
			}
			if ((Object)(object)respawnPointInstance == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogMessage((object)"[setupDeepMemoryZone] Setting respawn point");
				respawnPointInstance = Object.Instantiate<GameObject>(SceneObjectManager.findChildObject(deepMemoryCache, "door_wakeOnGround"));
				respawnPointInstance.SetActive(false);
				respawnPointInstance.AddComponent<WakeUpRespawn>();
				Object.DontDestroyOnLoad((Object)(object)respawnPointInstance);
			}
		}

		private void toggleLaceFSM()
		{
			if ((Object)(object)lace2BossInstance != (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogMessage((object)"Pausing Lace");
				PlayMakerFSM val = SceneObjectManager.findChildObject(lace2BossInstance, "Lace Boss2 New").GetComponents<PlayMakerFSM>().First((PlayMakerFSM pfsm) => pfsm.FsmName == "Control");
				val.fsm.manualUpdate = !val.fsm.manualUpdate;
			}
		}

		private void spawnLaceBoss2()
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			lace2BossSceneInstance = Object.Instantiate<GameObject>(lace2BossSceneCache);
			lace2BossSceneInstance.SetActive(true);
			((BaseUnityPlugin)this).Logger.LogInfo((object)("[spawnLaceBoss2] Trying to find Lace Boss from scene " + ((Object)lace2BossSceneInstance.gameObject).name));
			lace2BossInstance = SceneObjectManager.findChildObject(lace2BossSceneInstance, "Lace Boss2 New");
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"[spawnLaceBoss2] Lace object: {lace2BossInstance}");
			lace2BossInstance.SetActive(false);
			laceBossFSMOwner = new FsmOwnerDefault();
			laceBossFSMOwner.OwnerOption = (OwnerDefaultOption)1;
			laceBossFSMOwner.GameObject = FsmGameObject.op_Implicit(lace2BossInstance);
		}

		private void Update()
		{
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)hornet == (Object)null)
			{
				hornet = GameObject.Find("Hero_Hornet(Clone)");
				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;
					}
				}
			}
			if (Input.GetKey(modifierKey.Value) && Input.GetKeyDown((KeyCode)111))
			{
				spawnLaceBoss2();
			}
			if (Input.GetKey(modifierKey.Value) && Input.GetKeyDown((KeyCode)104))
			{
				hornet.transform.position = new Vector3(84.45f, 105f, 0.004f);
			}
			if (Input.GetKey(modifierKey.Value) && Input.GetKeyDown((KeyCode)256))
			{
				lace2BossInstance.SetActive(true);
				((PlayMakerFSM)lace2BossInstance.GetComponent(typeof(PlayMakerFSM))).SendEvent("BATTLE START FIRST");
			}
			if (Input.GetKey(modifierKey.Value) && Input.GetKeyDown((KeyCode)259))
			{
				lace2BossInstance.GetComponent<HealthManager>().hp = 1;
			}
			if (Input.GetKey(modifierKey.Value) && Input.GetKeyDown((KeyCode)257))
			{
				SceneObjectManager.findChildObject(phantomBossScene, "Phantom").GetComponent<HealthManager>().hp = 1;
			}
			if (Input.GetKey(modifierKey.Value) && Input.GetKeyDown((KeyCode)258))
			{
				toggleLaceFSM();
			}
			if (Input.GetKey(modifierKey.Value) && Input.GetKeyDown((KeyCode)264))
			{
				SceneObjectManager.findChildObject(phantomBossScene, "Phantom").SetActive(false);
			}
			if (Input.GetKey(modifierKey.Value) && Input.GetKeyDown((KeyCode)262))
			{
				((PlayMakerFSM)lace2BossInstance.GetComponent(typeof(PlayMakerFSM))).SetState("Multihit Slash End");
			}
			if (Input.GetKey(modifierKey.Value) && Input.GetKeyDown((KeyCode)263))
			{
				PlayerData._instance.defeatedPhantom = true;
				PlayerData._instance.defeatedLaceTower = true;
				PlayerData._instance.blackThreadWorld = true;
				PlayerData._instance.HasStoredMemoryState = 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:{PlayerData._instance.defeatedLaceTower} ";
				obj[4] = $"DefeatedPhantom:{PlayerData._instance.defeatedPhantom} ";
				obj[5] = $"Act3:{PlayerData._instance.blackThreadWorld} ";
				obj[6] = $"Needolin:{PlayerData._instance.hasNeedolinMemoryPowerup}";
				log.LogWarning((object)string.Concat(obj));
			}
		}
	}
	[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";
			}
		}
	}
}
namespace SilkenSisters.SceneManagement
{
	internal static class SceneObjectManager
	{
		public static string sceneFolder;

		public static async Task<GameObject> loadObjectFromScene(string sceneName, string objectToRetrieve)
		{
			ManualLogSource log = SilkenSisters.Log;
			Scene activeScene = SceneManager.GetActiveScene();
			log.LogDebug((object)("[SceneObjectManager.loadObjectFromScene] Current scene " + ((Scene)(ref activeScene)).name));
			SilkenSisters.Log.LogDebug((object)("[SceneObjectManager.loadObjectFromScene] Loading " + sceneName + " scene"));
			AssetBundle bundle = AssetBundle.LoadFromFile(Path.Combine(sceneFolder, (sceneName + ".bundle").ToLower()));
			Awaiter val = AsyncOperationAwaitableExtensions.GetAwaiter(SceneManager.LoadSceneAsync(sceneName, (LoadSceneMode)1));
			Awaiter val2 = default(Awaiter);
			if (!((Awaiter)(ref val)).IsCompleted)
			{
				await val;
				val = val2;
				val2 = default(Awaiter);
			}
			((Awaiter)(ref val)).GetResult();
			Scene sceneByName = SceneManager.GetSceneByName(sceneName);
			SilkenSisters.Log.LogDebug((object)("[SceneObjectManager.loadObjectFromScene] Scene " + ((Scene)(ref sceneByName)).name + " successfully loaded"));
			GameObject val3 = findObjectInScene(sceneByName, objectToRetrieve);
			GameObject go_copy = Object.Instantiate<GameObject>(val3);
			Object.DontDestroyOnLoad((Object)(object)go_copy);
			SilkenSisters.Log.LogDebug((object)("[SceneObjectManager.loadObjectFromScene] Unloading '" + ((Scene)(ref sceneByName)).name + "' scene"));
			val = AsyncOperationAwaitableExtensions.GetAwaiter(SceneManager.UnloadSceneAsync(((Scene)(ref sceneByName)).name));
			if (!((Awaiter)(ref val)).IsCompleted)
			{
				await val;
				val = val2;
				val2 = default(Awaiter);
			}
			((Awaiter)(ref val)).GetResult();
			SilkenSisters.Log.LogDebug((object)("[SceneObjectManager.loadObjectFromScene] Unloading bundle '" + ((Object)bundle).name + "'"));
			val = AsyncOperationAwaitableExtensions.GetAwaiter((AsyncOperation)(object)bundle.UnloadAsync(false));
			if (!((Awaiter)(ref val)).IsCompleted)
			{
				await val;
				val = val2;
			}
			((Awaiter)(ref val)).GetResult();
			go_copy.SetActive(false);
			return go_copy;
		}

		public static GameObject findObjectInScene(Scene scene, string objectToRetrieve)
		{
			int objectIndex = 0;
			string[] objectHierarchy = objectToRetrieve.Split("/");
			SilkenSisters.Log.LogDebug((object)("[SceneObjectManager.findObjectInScene] Searching scene " + ((Scene)(ref scene)).name + " for object '" + objectToRetrieve + "'"));
			SilkenSisters.Log.LogDebug((object)$"[SceneObjectManager.findObjectInScene] Scene {((Scene)(ref scene)).name} has {((Scene)(ref scene)).GetRootGameObjects().Length} objects");
			GameObject val = ((Scene)(ref scene)).GetRootGameObjects().First((GameObject obj) => ((Object)obj).name == objectHierarchy[objectIndex]);
			objectIndex++;
			for (; objectIndex < objectHierarchy.Length; objectIndex++)
			{
				SilkenSisters.Log.LogDebug((object)("[SceneObjectManager.findObjectInScene] Current child object searched for: '" + objectHierarchy[objectIndex] + "'"));
				val = ((Component)((Component)val.transform).GetComponentsInChildren<Transform>(true).First((Transform tf) => ((Object)tf).name == objectHierarchy[objectIndex])).gameObject;
			}
			SilkenSisters.Log.LogDebug((object)$"[SceneObjectManager.findObjectInScene] Found object {val}");
			return val;
		}

		public static GameObject findObjectInCurrentScene(string objectToRetrieve)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			return findObjectInScene(SceneManager.GetActiveScene(), objectToRetrieve);
		}

		public static GameObject findChildObject(GameObject obj, string childObj)
		{
			int objectIndex = 0;
			string[] objectHierarchy = childObj.Split("/");
			GameObject val = obj;
			for (; objectIndex < objectHierarchy.Length; objectIndex++)
			{
				SilkenSisters.Log.LogDebug((object)("[SceneObjectManager.findChildObject] Current child object searched for: '" + objectHierarchy[objectIndex] + "'"));
				val = ((Component)((Component)val.transform).GetComponentsInChildren<Transform>(true).First((Transform tf) => ((Object)tf).name == objectHierarchy[objectIndex])).gameObject;
			}
			SilkenSisters.Log.LogDebug((object)$"[SceneObjectManager.findChildObject] Found object {val}");
			return val;
		}

		static SceneObjectManager()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Invalid comparison between Unknown and I4
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Invalid comparison between Unknown and I4
			string streamingAssetsPath = Application.streamingAssetsPath;
			RuntimePlatform platform = Application.platform;
			string path = (((int)platform == 1) ? "StandaloneOSX" : (((int)platform == 2) ? "StandaloneWindows64" : (((int)platform != 13) ? "" : "StandaloneLinux64")));
			sceneFolder = Path.Combine(streamingAssetsPath, "aa", path, "scenes_scenes_scenes");
		}
	}
}
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.LogMessage((object)"[ChallengeRegion.Setup] Finished setting up ChallengeRegion");
			getComponents();
			setPositions();
			disableCradleStuff();
			setPhantomTrigger();
			setGarama();
			SilkenSisters.Log.LogMessage((object)"[ChallengeRegion.Setup] Finished setting up ChallengeRegion");
		}

		private void getComponents()
		{
			_challengeRegion = SceneObjectManager.findChildObject(((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.LogInfo((object)$"[ChallengeRegion.setPositions] Dialog position:{((Component)this).gameObject.transform.position}, RegionPosition:{_challengeRegion.transform.localPosition}");
		}

		private void disableCradleStuff()
		{
			SceneObjectManager.findChildObject(((Component)this).gameObject, "Challenge Glows/Cradle__0013_loom_strut_based (2)").SetActive(false);
			SceneObjectManager.findChildObject(((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.LogInfo((object)("[ChallengeRegion.disableCradleStuff] Cradle specific objects active?: " + string.Format("CradleLoom1:{0}, ", SceneObjectManager.findChildObject(((Component)this).gameObject, "Challenge Glows/Cradle__0013_loom_strut_based (2)").activeSelf) + string.Format("CradleLoom2:{0}", SceneObjectManager.findChildObject(((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.LogMessage((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.plugin.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()
		{
			getComponents();
			setPosition();
			disableCrustKingObjects();
			editFSMTransition();
			editPlayerData();
			bypassToolPickup();
			manageTransitionGates();
			SilkenSisters.Log.LogMessage((object)"[DeepMemory.Setup] Done");
		}

		private void getComponents()
		{
			_control = FsmUtil.GetFsmPreprocessed(((Component)this).gameObject, "To Memory");
			_before = SceneObjectManager.findChildObject(((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);
			SceneObjectManager.findChildObject(_before, "Deep_Memory_appear/threads").SetActive(false);
			Extensions.SetLocalPosition2D(SceneObjectManager.findChildObject(_before, "thread_memory").transform, 1.768f, -3.143f);
			SilkenSisters.Log.LogInfo((object)$"[DeepMemory.setPosition] position:{((Component)this).gameObject.transform.position}");
		}

		private void disableCrustKingObjects()
		{
			SilkenSisters.Log.LogMessage((object)"[DeepMemory.disableCrustKingObjects] Finding and deleting coral king sprite");
			Object.Destroy((Object)(object)SceneObjectManager.findChildObject(_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.LogInfo((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()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			SetPlayerDataBool val = new SetPlayerDataBool();
			val.boolName = FsmString.op_Implicit("defeatedPhantom");
			val.value = FsmBool.op_Implicit(false);
			SetPlayerDataBool val2 = new SetPlayerDataBool();
			val2.boolName = FsmString.op_Implicit("blackThreadWorld");
			val2.value = FsmBool.op_Implicit(false);
			FsmUtil.InsertAction(_control, "Transition Scene", (FsmStateAction)(object)val, 0);
			FsmUtil.InsertAction(_control, "Transition Scene", (FsmStateAction)(object)val2, 0);
		}

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

		private void manageTransitionGates()
		{
			InvokeMethod invokeMethod = new InvokeMethod(disableRespawn);
			FsmUtil.AddAction(_control, "Transition Scene", (FsmStateAction)(object)invokeMethod);
			InvokeMethod invokeMethod2 = new InvokeMethod(enableDoor);
			FsmUtil.InsertAction(_control, "Transition Scene", (FsmStateAction)(object)invokeMethod2, 0);
		}

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

		private void disableRespawn()
		{
			SilkenSisters.plugin.respawnPointInstance.SetActive(false);
			SilkenSisters.plugin.respawnPointInstance.GetComponent<PlayMakerFSM>().fsm.SetState("Pause");
			SilkenSisters.Log.LogInfo((object)$"[DeepMemory.disableRespawn] Respawn active?:{SilkenSisters.plugin.respawnPointInstance.activeSelf}, Current state:{SilkenSisters.plugin.respawnPointInstance.GetComponent<PlayMakerFSM>().ActiveStateName}");
		}
	}
	internal class WakeUpMemory : MonoBehaviour
	{
		private GameObject _wakeTransitionGate;

		private PlayMakerFSM _control;

		private void Awake()
		{
			Setup();
		}

		private async Task Setup()
		{
			getComponents();
			setName();
			setPosition();
			editFSM();
			SilkenSisters.Log.LogMessage((object)"[WakeUpMemory.Setup] Finished");
		}

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

		private void setName()
		{
			((Object)_wakeTransitionGate).name = "door_wakeInMemory_phantom";
			SilkenSisters.Log.LogInfo((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.LogInfo((object)$"[WakeUpMemory.setPosition] gatePosition:{((Component)this).gameObject.transform.position}");
		}

		private void editFSM()
		{
			SilkenSisters.Log.LogInfo((object)"[WakeUpMemory.editFSM] Editing the door FSM");
			InvokeMethod invokeMethod = new InvokeMethod(enableRespawn);
			FsmUtil.AddAction(_control, "Take Control", (FsmStateAction)(object)invokeMethod);
			InvokeMethod invokeMethod2 = new InvokeMethod(enableIsMemory);
			FsmUtil.AddAction(_control, "Take Control", (FsmStateAction)(object)invokeMethod2);
			InvokeMethod invokeMethod3 = new InvokeMethod(SilkenSisters.plugin.setupFight);
			FsmUtil.AddAction(_control, "Take Control", (FsmStateAction)(object)invokeMethod3);
			FsmUtil.GetAction<ConvertBoolToFloat>(_control, "Fade Up", 1).falseValue = FsmFloat.op_Implicit(3f);
			FsmUtil.GetAction<ConvertBoolToFloat>(_control, "Fade Up", 1).trueValue = FsmFloat.op_Implicit(3f);
			InvokeMethod invokeMethod4 = new InvokeMethod(disableSelf);
			FsmUtil.AddAction(_control, "End", (FsmStateAction)(object)invokeMethod4);
			InvokeMethod invokeMethod5 = new InvokeMethod(closeOffOrgan);
			FsmUtil.AddAction(_control, "End", (FsmStateAction)(object)invokeMethod5);
		}

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

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

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

		private void closeOffOrgan()
		{
			GameObject obj = SceneObjectManager.findObjectInCurrentScene("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, 11.5445f, 8.5155f, 0.003f);
		}
	}
	internal class WakeUpRespawn : MonoBehaviour
	{
		private PlayMakerFSM _control;

		private void Awake()
		{
			Setup();
		}

		private async Task Setup()
		{
			getComponents();
			setName();
			setPosition();
			editFSM();
		}

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

		private void setName()
		{
			((Object)((Component)this).gameObject).name = "door_wakeOnGround_phantom";
			SilkenSisters.Log.LogInfo((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.LogInfo((object)$"[WakeUpRespawn.setPosition] gatePosition:{((Component)this).gameObject.transform.position}");
		}

		private void editFSM()
		{
			PlayMakerFSM fsmPreprocessed = FsmUtil.GetFsmPreprocessed(((Component)this).gameObject, "Wake Up");
			FsmUtil.DisableAction(fsmPreprocessed, "Save?", 1);
			new InvokeMethod(replenishTools);
			InvokeMethod invokeMethod = new InvokeMethod(disableDoor);
			FsmUtil.AddAction(fsmPreprocessed, "End", (FsmStateAction)(object)invokeMethod);
			InvokeMethod invokeMethod2 = new InvokeMethod(disableSelf);
			FsmUtil.AddAction(fsmPreprocessed, "End", (FsmStateAction)(object)invokeMethod2);
		}

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

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

		private void replenishTools()
		{
			SilkenSisters.Log.LogInfo((object)"Replenishing tools");
			float num = default(float);
			int num2 = default(int);
			foreach (ToolItem currentEquippedTool in ToolItemManager.GetCurrentEquippedTools())
			{
				if (currentEquippedTool.IsAttackType())
				{
					SilkenSisters.Log.LogWarning((object)(((Object)currentEquippedTool).GetName() ?? ""));
					currentEquippedTool.TryReplenishSingle(true, 0f, ref num, ref num2);
					SilkenSisters.Log.LogWarning((object)$"{num} {num2}");
				}
			}
		}
	}
	internal class InfoPrompt : MonoBehaviour
	{
		private BasicNPC _npc;

		private void Awake()
		{
			Setup();
		}

		private async Task Setup()
		{
			SilkenSisters.Log.LogMessage((object)"[ChallengeRegion.Setup] Started setting up info prompt");
			getComponents();
			setPosition();
			setText();
			SilkenSisters.Log.LogMessage((object)"[ChallengeRegion.Setup] Finished setting up info prompt");
		}

		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.LogMessage((object)Language.Get("SILKEN_SISTERS_INFOPROMPT", "Mods.io.github.al3ks1s.silkensisters"));
		}
	}
	internal class Lace1
	{
	}
	internal class Lace2 : MonoBehaviour
	{
		private PlayMakerFSM _control;

		private void Awake()
		{
			Setup();
		}

		private async Task Setup()
		{
			SilkenSisters.Log.LogMessage((object)"[Lace2.Setup] Started setting up Lace");
			getComponents();
			disableParticleEffects();
			editPositionConstraint();
			rerouteState();
			fixActionsPositions();
			disableTitleCard();
			fixWallRangeAlert();
			setLaceFacing();
			SilkenSisters.Log.LogMessage((object)"[Lace2.Setup] Finished setting up Lace");
		}

		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.LogInfo((object)$"[Lace2.getComponents] position:{((Component)this).gameObject.transform.position}");
			_control = FsmUtil.GetFsmPreprocessed(((Component)this).gameObject, "Control");
		}

		private void disableParticleEffects()
		{
			SceneObjectManager.findChildObject(((Component)this).gameObject, "Pt DashPetal").SetActive(false);
			SceneObjectManager.findChildObject(((Component)this).gameObject, "Pt SkidPetal").SetActive(false);
			SceneObjectManager.findChildObject(((Component)this).gameObject, "Pt RisingPetal").SetActive(false);
			SceneObjectManager.findChildObject(((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.LogInfo((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.LogInfo((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()
		{
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Expected O, but got Unknown
			SilkenSisters.Log.LogMessage((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.LogInfo((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", 4).y = FsmFloat.op_Implicit(110f);
			SilkenSisters.Log.LogInfo((object)string.Format("[Lace2.fixActionsPositions] TeleHeight: {0}", FsmUtil.GetAction<SetPosition>(_control, "Counter TeleIn", 4).y));
			FloatClamp val = new FloatClamp();
			val.floatVariable = FsmUtil.FindFloatVariable(_control, "Tele X");
			val.maxValue = FsmFloat.op_Implicit(96f);
			val.minValue = FsmFloat.op_Implicit(73f);
			FsmUtil.InsertAction(_control, "Counter TeleIn", (FsmStateAction)(object)val, 4);
			SilkenSisters.Log.LogInfo((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.LogInfo((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.LogInfo((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.LogInfo((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.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.LogMessage((object)"[Lace2.disableTitleCard] Disabling title card");
			FsmUtil.DisableAction(_control, "Start Battle Refight", 4);
			FsmUtil.DisableAction(_control, "Start Battle", 4);
			SilkenSisters.Log.LogInfo((object)("[Lace2.disableTitleCard] " + string.Format("(Start Battle Refight):{0}, ", FsmUtil.GetStateAction(_control, "Start Battle Refight", 4).active) + string.Format("(Start Battle):{0}", FsmUtil.GetStateAction(_control, "Start Battle", 4).active)));
		}

		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 = SceneObjectManager.findChildObject(((Component)((Component)this).gameObject.transform.parent).gameObject, "Wall Range");
			Extensions.SetPosition3D(val.transform, 84.0349f, 103.67f, 0f);
			SilkenSisters.Log.LogInfo((object)$"[Lace2.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.LogInfo((object)$"[Lace2.fixWallRangeAlert] alertLeft: Size:{components[0].size}, Size:{((Collider2D)components[0]).offset}");
			SilkenSisters.Log.LogInfo((object)$"[Lace2.fixWallRangeAlert] alertRight: Size:{components[1].size}, Size:{((Collider2D)components[1]).offset}");
		}

		private void setLaceFacing()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: 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.plugin.laceBossFSMOwner;
			val.objectB = FsmGameObject.op_Implicit(SilkenSisters.hornet);
			FsmUtil.InsertAction(_control, "Init", (FsmStateAction)(object)val, 4);
			FsmUtil.DisableAction(_control, "Refight Engarde", 0);
			SilkenSisters.Log.LogInfo((object)string.Format("[Lace2.setLaceFacing] Facing Action:{0}", ((object)FsmUtil.GetStateAction(_control, "Init", 4)).GetType()));
			SilkenSisters.Log.LogInfo((object)string.Format("[Lace2.Refight Engarde] Base facing active?:{0}", FsmUtil.GetStateAction(_control, "Refight Engarde", 0).active));
		}
	}
	internal class Lace2Scene : MonoBehaviour
	{
		private PlayMakerFSM _control;

		private void Awake()
		{
			Setup();
		}

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

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

		private void disableSceneObjects()
		{
			SilkenSisters.Log.LogMessage((object)"[Lace2Scene.disableSceneObjects] Disabling unwanted LaceBossScene items");
			SceneObjectManager.findChildObject(((Component)this).gameObject, "Flower Effect Hornet").SetActive(false);
			SceneObjectManager.findChildObject(((Component)this).gameObject, "steam hazard").SetActive(false);
			SceneObjectManager.findChildObject(((Component)this).gameObject, "Silk Heart Memory Return").SetActive(false);
		}

		private void moveSceneBounds()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			SilkenSisters.Log.LogMessage((object)"[Lace2Scene.moveSceneBounds] Moving lace arena objects");
			SceneObjectManager.findChildObject(((Component)this).gameObject, "Arena L").transform.position = new Vector3(72f, 104f, 0f);
			SceneObjectManager.findChildObject(((Component)this).gameObject, "Arena R").transform.position = new Vector3(97f, 104f, 0f);
			SceneObjectManager.findChildObject(((Component)this).gameObject, "Centre").transform.position = new Vector3(84.5f, 104f, 0f);
		}
	}
	internal class Lace3
	{
	}
	internal class LaceCorpse
	{
	}
	internal class LaceNPC : MonoBehaviour
	{
		private PlayMakerFSM _control;

		private Transform _npcTransform;

		private void Awake()
		{
			Setup();
		}

		private async Task Setup()
		{
			SilkenSisters.Log.LogMessage((object)"[LaceNPC.Setup] Spawning lace on the organ bench");
			register();
			getComponents();
			disableRangeDetection();
			setPosition();
			editFSMAnimations();
			SilkenSisters.Log.LogMessage((object)"[LaceNPC.Setup] Finished setting up LaceNPC");
		}

		private void register()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			SilkenSisters.plugin.laceNPCFSMOwner = new FsmOwnerDefault();
			SilkenSisters.plugin.laceNPCFSMOwner.OwnerOption = (OwnerDefaultOption)1;
			SilkenSisters.plugin.laceNPCFSMOwner.GameObject = FsmGameObject.op_Implicit(((Component)this).gameObject);
		}

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

		private void disableRangeDetection()
		{
			SceneObjectManager.findChildObject(((Component)this).gameObject, "Start Range").SetActive(false);
			SilkenSisters.Log.LogInfo((object)string.Format("[LaceNPC.disableRangeDetection] LaceNPCDetection?:{0}", SceneObjectManager.findChildObject(((Component)this).gameObject, "Start Range").activeSelf));
		}

		private void setPosition()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			Extensions.SetPosition3D(_npcTransform, 81.9569f, 106.1943f, 2.7021f);
			Extensions.SetScaleX(_npcTransform, -0.9f);
			Extensions.SetScaleY(_npcTransform, 0.9f);
			Extensions.SetScaleZ(_npcTransform, 0.9f);
			SilkenSisters.Log.LogInfo((object)$"[LaceNPC.setPosition] position:{_npcTransform.position}");
		}

		private void editFSMAnimations()
		{
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Expected O, but got Unknown
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			SilkenSisters.Log.LogMessage((object)"[LaceNPC.editFSMAnimations] Editing Lace NPC FSM");
			FsmUtil.ChangeTransition(_control, "Take Control", "LAND", "Sit Up");
			FsmUtil.ChangeTransition(_control, "Take Control", "LAND", "Sit Up");
			FsmUtil.GetTransition(_control, "Take Control", "LAND").fsmEvent = FsmEvent.GetFsmEvent("FINISHED");
			FsmUtil.DisableAction(_control, "Take Control", 3);
			FsmUtil.ChangeTransition(_control, "Sit Up", "FINISHED", "Jump Antic");
			Wait val = new Wait();
			val.time = FsmFloat.op_Implicit(2f);
			FsmUtil.DisableAction(_control, "Sit Up", 4);
			FsmUtil.AddAction(_control, "Sit Up", (FsmStateAction)(object)val);
			SetPosition action = FsmUtil.GetAction<SetPosition>(_control, "Sit Up", 3);
			action.vector = FsmVector3.op_Implicit(new Vector3(81.9569f, 106.6942f, 2.7021f));
			action.x = FsmFloat.op_Implicit(81.9569f);
			action.y = FsmFloat.op_Implicit(106.6942f);
			action.z = FsmFloat.op_Implicit(2.7021f);
			InvokeMethod invokeMethod = new InvokeMethod(toggleChallenge);
			FsmUtil.AddAction(_control, "Jump Away", (FsmStateAction)(object)invokeMethod);
			InvokeMethod invokeMethod2 = new InvokeMethod(startConstrainHornet);
			FsmUtil.AddAction(_control, "Jump Away", (FsmStateAction)(object)invokeMethod2);
			FsmUtil.DisableAction(_control, "Jump Antic", 4);
			FsmUtil.DisableAction(_control, "Jump Away", 7);
			FsmUtil.DisableAction(_control, "Look Up End", 0);
			FsmUtil.DisableAction(_control, "End", 1);
			FsmUtil.DisableAction(_control, "End", 4);
			FsmUtil.DisableAction(_control, "End", 5);
		}

		private void toggleChallenge()
		{
			SilkenSisters.plugin.challengeDialogInstance.SetActive(!SilkenSisters.plugin.challengeDialogInstance.activeSelf);
			SilkenSisters.Log.LogInfo((object)$"[LaceNPC.toggleChallenge] challenge?:{SilkenSisters.plugin.challengeDialogInstance.activeSelf}");
		}

		private void startConstrainHornet()
		{
			((Behaviour)SilkenSisters.hornetConstrain).enabled = true;
			SilkenSisters.Log.LogInfo((object)$"[LaceNPC.startConstrainHornet] constrainHornet?:{((Behaviour)SilkenSisters.hornetConstrain).enabled}");
		}
	}
	internal class PhantomBoss : MonoBehaviour
	{
		private PlayMakerFSM _control;

		private void Awake()
		{
			Setup();
		}

		private async Task Setup()
		{
			SilkenSisters.Log.LogMessage((object)"[PhantomBoss.Setup] Started setting phantom boss up");
			Extensions.SetPositionX(((Component)this).gameObject.transform, 77.1797f);
			getComponents();
			triggerLace();
			skipCutscene();
			listenForLaceDead();
			prepareExitMemoryEffect();
			SilkenSisters.Log.LogMessage((object)"[PhantomBoss.Setup] Finished setting phantom boss up");
		}

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

		private void triggerLace()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			SilkenSisters.Log.LogInfo((object)$"[PhantomBoss.skipCutscene] Enable laceBoss {SilkenSisters.plugin.laceBossFSMOwner} {SilkenSisters.plugin.laceBossFSMOwner.gameObject}");
			ActivateGameObject val = new ActivateGameObject();
			val.activate = FsmBool.op_Implicit(true);
			val.gameObject = SilkenSisters.plugin.laceBossFSMOwner;
			val.recursive = FsmBool.op_Implicit(false);
			FsmUtil.AddAction(_control, "Appear", (FsmStateAction)(object)val);
			SilkenSisters.Log.LogMessage((object)"[PhantomBoss.skipCutscene] Trigger lace boss");
			SendEventByName val2 = new SendEventByName();
			val2.sendEvent = FsmString.op_Implicit("BATTLE START FIRST");
			val2.delay = FsmFloat.op_Implicit(0f);
			FsmEventTarget val3 = new FsmEventTarget();
			val3.gameObject = SilkenSisters.plugin.laceBossFSMOwner;
			val3.target = (EventTarget)1;
			val2.eventTarget = val3;
			FsmUtil.AddAction(_control, "To Idle", (FsmStateAction)(object)val2);
		}

		private void skipCutscene()
		{
			SilkenSisters.Log.LogMessage((object)"[PhantomBoss.skipCutscene] Skip cutscene interaction");
			FsmUtil.GetAction<Wait>(_control, "Time Freeze", 4).time = FsmFloat.op_Implicit(0.001f);
			FsmUtil.GetAction<ScaleTime>(_control, "Time Freeze", 5).timeScale = FsmFloat.op_Implicit(1f);
			FsmUtil.DisableAction(_control, "Parry Ready", 0);
			FsmUtil.DisableAction(_control, "Parry Ready", 1);
			FsmUtil.GetAction<Wait>(_control, "Parry Ready", 4).time = FsmFloat.op_Implicit(0.001f);
			FsmUtil.GetAction<Wait>(_control, "Parry Ready", 4).finishEvent = FsmEvent.GetFsmEvent("PARRY");
			FsmUtil.ChangeTransition(_control, "Death Explode", "FINISHED", "End Recover");
			FsmUtil.AddAction(_control, "End Recover", (FsmStateAction)(object)FsmUtil.GetAction<SetPositionToObject2D>(_control, "Get Control", 2));
			FsmUtil.AddAction(_control, "End Recover", (FsmStateAction)(object)FsmUtil.GetAction<SetPositionToObject2D>(_control, "Get Control", 4));
			FsmUtil.DisableAction(_control, "Set Data", 0);
			FsmUtil.DisableAction(_control, "Set Data", 1);
			FsmUtil.DisableAction(_control, "Set Data", 2);
			FsmUtil.DisableAction(_control, "Set Data", 7);
		}

		private void listenForLaceDead()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			FsmGameObject val = FsmUtil.AddGameObjectVariable(_control, "LaceBoss2");
			((NamedVariable)val).SetName("LaceBoss2");
			FindGameObject val2 = new FindGameObject();
			val2.objectName = FsmString.op_Implicit(((Object)SilkenSisters.plugin.lace2BossInstance).name ?? "");
			val2.store = val;
			val2.withTag = FsmString.op_Implicit("Untagged");
			GameObjectIsNull val3 = new GameObjectIsNull();
			val3.gameObject = val;
			val3.isNotNull = FsmEvent.GetFsmEvent("BLOCKED HIT");
			FsmUtil.AddTransition(_control, "Final Parry", "BLOCKED HIT", "Counter Stance");
			FsmUtil.InsertAction(_control, "Final Parry", (FsmStateAction)(object)val3, 0);
			FsmUtil.InsertAction(_control, "Final Parry", (FsmStateAction)(object)val2, 0);
		}

		private void prepareExitMemoryEffect()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Expected O, but got Unknown
			//IL_013d: 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_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Expected O, but got Unknown
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Expected O, but got Unknown
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Expected O, but got Unknown
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Expected O, but got Unknown
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Expected O, but got Unknown
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Expected O, but got Unknown
			//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03da: Expected O, but got Unknown
			//IL_047e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0485: Expected O, but got Unknown
			//IL_0529: Unknown result type (might be due to invalid IL or missing references)
			//IL_052e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0554: Unknown result type (might be due to invalid IL or missing references)
			//IL_055b: Expected O, but got Unknown
			//IL_05bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c4: Expected O, but got Unknown
			//IL_05e0: 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)
			PlayMakerFSM fsmPreprocessed = FsmUtil.GetFsmPreprocessed(SceneObjectManager.findChildObject(SilkenSisters.plugin.deepMemoryCache, "before/thread_memory"), "FSM");
			FsmGameObject storeObject = FsmUtil.AddGameObjectVariable(_control, "Deep Memory Enter");
			FsmUtil.AddState(_control, "Deep Memory Enter");
			SpawnObjectFromGlobalPool val = new SpawnObjectFromGlobalPool();
			val.gameObject = FsmUtil.GetAction<SpawnObjectFromGlobalPool>(fsmPreprocessed, "Deep Memory Enter", 3).gameObject;
			val.spawnPoint = FsmUtil.GetAction<SpawnObjectFromGlobalPool>(fsmPreprocessed, "Deep Memory Enter", 3).spawnPoint;
			val.storeObject = storeObject;
			val.position = new FsmVector3();
			val.rotation = new FsmVector3();
			SetMainCameraFovOffset val2 = new SetMainCameraFovOffset();
			val2.FovOffset = FsmFloat.op_Implicit(-1f);
			val2.TransitionTime = FsmFloat.op_Implicit(4.7f);
			val2.TransitionCurve = FsmUtil.GetAction<SetMainCameraFovOffset>(fsmPreprocessed, "Deep Memory Enter", 4).TransitionCurve;
			Wait val3 = new Wait();
			val3.time = FsmFloat.op_Implicit(4.7f);
			val3.finishEvent = FsmEvent.GetFsmEvent("FINISHED");
			FsmUtil.AddAction(_control, "Deep Memory Enter", (FsmStateAction)(object)val);
			FsmUtil.AddAction(_control, "Deep Memory Enter", (FsmStateAction)(object)val2);
			FsmUtil.AddAction(_control, "Deep Memory Enter", (FsmStateAction)(object)val3);
			FsmUtil.AddState(_control, "Deep Memory Enter Fall");
			new HeroControllerMethods().method = (Method)7;
			new HeroControllerMethods().method = (Method)1;
			TransitionToAudioSnapshot val4 = new TransitionToAudioSnapshot();
			val4.snapshot = FsmUtil.GetAction<TransitionToAudioSnapshot>(fsmPreprocessed, "Deep Memory Enter Fall", 3).snapshot;
			val4.transitionTime = FsmFloat.op_Implicit(2f);
			TransitionToAudioSnapshot val5 = new TransitionToAudioSnapshot();
			val5.snapshot = FsmUtil.GetAction<TransitionToAudioSnapshot>(fsmPreprocessed, "Deep Memory Enter Fall", 4).snapshot;
			val5.transitionTime = FsmFloat.op_Implicit(2f);
			TransitionToAudioSnapshot val6 = new TransitionToAudioSnapshot();
			val6.snapshot = FsmUtil.GetAction<TransitionToAudioSnapshot>(fsmPreprocessed, "Deep Memory Enter Fall", 5).snapshot;
			val6.transitionTime = FsmFloat.op_Implicit(2f);
			SetMainCameraFovOffset val7 = new SetMainCameraFovOffset();
			val7.FovOffset = FsmFloat.op_Implicit(-2f);
			val7.TransitionTime = FsmFloat.op_Implicit(2f);
			val7.TransitionCurve = FsmUtil.GetAction<SetMainCameraFovOffset>(fsmPreprocessed, "Deep Memory Enter Fall", 6).TransitionCurve;
			AudioPlayerOneShotSingle val8 = new AudioPlayerOneShotSingle();
			val8.audioPlayer = FsmUtil.GetAction<AudioPlayerOneShotSingle>(fsmPreprocessed, "Deep Memory Enter Fall", 7).audioPlayer;
			val8.spawnPoint = FsmUtil.GetAction<AudioPlayerOneShotSingle>(fsmPreprocessed, "Deep Memory Enter Fall", 7).spawnPoint;
			val8.audioClip = FsmUtil.GetAction<AudioPlayerOneShotSingle>(fsmPreprocessed, "Deep Memory Enter Fall", 7).audioClip;
			val8.pitchMax = FsmFloat.op_Implicit(1f);
			val8.pitchMin = FsmFloat.op_Implicit(1f);
			val8.volume = FsmFloat.op_Implicit(1f);
			val8.delay = FsmFloat.op_Implicit(0f);
			val8.storePlayer = FsmUtil.GetAction<AudioPlayerOneShotSingle>(fsmPreprocessed, "Deep Memory Enter Fall", 7).storePlayer;
			Tk2dPlayAnimationWithEvents val9 = new Tk2dPlayAnimationWithEvents();
			val9.gameObject = FsmUtil.GetAction<Tk2dPlayAnimationWithEvents>(fsmPreprocessed, "Deep Memory Enter Fall", 8).gameObject;
			val9.clipName = FsmUtil.GetAction<Tk2dPlayAnimationWithEvents>(fsmPreprocessed, "Deep Memory Enter Fall", 8).clipName;
			val9.animationTriggerEvent = FsmUtil.GetAction<Tk2dPlayAnimationWithEvents>(fsmPreprocessed, "Deep Memory Enter Fall", 8).animationTriggerEvent;
			FsmUtil.AddAction(_control, "Deep Memory Enter Fall", (FsmStateAction)(object)FsmUtil.GetAction<HeroControllerMethods>(fsmPreprocessed, "Deep Memory Enter Fall", 1));
			FsmUtil.AddAction(_control, "Deep Memory Enter Fall", (FsmStateAction)(object)FsmUtil.GetAction<HeroControllerMethods>(fsmPreprocessed, "Deep Memory Enter Fall", 2));
			FsmUtil.AddAction(_control, "Deep Memory Enter Fall", (FsmStateAction)(object)val4);
			FsmUtil.AddAction(_control, "Deep Memory Enter Fall", (FsmStateAction)(object)val5);
			FsmUtil.AddAction(_control, "Deep Memory Enter Fall", (FsmStateAction)(object)val6);
			FsmUtil.AddAction(_control, "Deep Memory Enter Fall", (FsmStateAction)(object)val7);
			FsmUtil.AddAction(_control, "Deep Memory Enter Fall", (FsmStateAction)(object)val8);
			FsmUtil.AddAction(_control, "Deep Memory Enter Fall", (FsmStateAction)(object)val9);
			FsmUtil.AddState(_control, "Collapse");
			AudioPlayerOneShotSingle val10 = new AudioPlayerOneShotSingle();
			val10.audioPlayer = FsmUtil.GetAction<AudioPlayerOneShotSingle>(fsmPreprocessed, "Collapse", 2).audioPlayer;
			val10.spawnPoint = FsmUtil.GetAction<AudioPlayerOneShotSingle>(fsmPreprocessed, "Collapse", 2).spawnPoint;
			val10.audioClip = FsmUtil.GetAction<AudioPlayerOneShotSingle>(fsmPreprocessed, "Collapse", 2).audioClip;
			val10.pitchMax = FsmFloat.op_Implicit(1f);
			val10.pitchMin = FsmFloat.op_Implicit(1f);
			val10.volume = FsmFloat.op_Implicit(1f);
			val10.delay = FsmFloat.op_Implicit(0f);
			val10.storePlayer = FsmUtil.GetAction<AudioPlayerOneShotSingle>(fsmPreprocessed, "Collapse", 2).storePlayer;
			AudioPlayerOneShotSingle val11 = new AudioPlayerOneShotSingle();
			val11.audioPlayer = FsmUtil.GetAction<AudioPlayerOneShotSingle>(fsmPreprocessed, "Collapse", 3).audioPlayer;
			val11.spawnPoint = FsmUtil.GetAction<AudioPlayerOneShotSingle>(fsmPreprocessed, "Collapse", 3).spawnPoint;
			val11.audioClip = FsmUtil.GetAction<AudioPlayerOneShotSingle>(fsmPreprocessed, "Collapse", 3).audioClip;
			val11.pitchMax = FsmFloat.op_Implicit(1f);
			val11.pitchMin = FsmFloat.op_Implicit(1f);
			val11.volume = FsmFloat.op_Implicit(1f);
			val11.delay = FsmFloat.op_Implicit(0f);
			val11.storePlayer = FsmUtil.GetAction<AudioPlayerOneShotSingle>(fsmPreprocessed, "Collapse", 3).storePlayer;
			new ListenForAnimationEvent
			{
				Response = FsmEvent.GetFsmEvent("FINISHED"),
				Target = FsmUtil.GetAction<ListenForAnimationEvent>(fsmPreprocessed, "Collapse", 4).Target
			};
			Wait val12 = new Wait();
			val12.time = FsmFloat.op_Implicit(1f);
			val12.finishEvent = FsmEvent.GetFsmEvent("FINISHED");
			FsmUtil.AddAction(_control, "Collapse", (FsmStateAction)(object)val10);
			FsmUtil.AddAction(_control, "Collapse", (FsmStateAction)(object)val11);
			FsmUtil.AddAction(_control, "Collapse", (FsmStateAction)(object)val12);
			FsmState val13 = new FsmState(SilkenSisters.plugin.ExitMemoryCache);
			FsmUtil.GetAction<ScreenFader>(val13, 1).startColour = FsmColor.op_Implicit(new Color(0f, 0f, 0f, 0f));
			FsmUtil.GetAction<ScreenFader>(val13, 1).endColour = FsmColor.op_Implicit(new Color(0f, 0f, 0f, 1f));
			FsmUtil.GetAction<StartPreloadingScene>(val13, 0).SceneName = FsmString.op_Implicit("Organ_01");
			FsmUtil.GetAction<BeginSceneTransition>(val13, 4).sceneName = FsmString.op_Implicit("Organ_01");
			FsmUtil.GetAction<BeginSceneTransition>(val13, 4).entryGateName = FsmString.op_Implicit(((Object)SilkenSisters.plugin.respawnPointInstance).name ?? "");
			SilkenSisters.Log.LogInfo((object)("[PhantomBoss.prepareExitMemoryEffect] Transition Gate to exit memory: " + ((Object)SilkenSisters.plugin.respawnPointInstance).name));
			FsmUtil.GetAction<Wait>(val13, 2).time = FsmFloat.op_Implicit(2f);
			FsmUtil.AddState(_control, val13);
			FsmUtil.AddTransition(_control, "Set Data", "FINISHED", "Deep Memory Enter");
			FsmUtil.AddTransition(_control, "Deep Memory Enter", "FINISHED", "Deep Memory Enter Fall");
			FsmUtil.AddTransition(_control, "Deep Memory Enter Fall", "FINISHED", "Collapse");
			FsmUtil.AddTransition(_control, "Collapse", "FINISHED", "Exit Memory");
			resetPlayerData();
		}

		private void resetPlayerData()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			SetPlayerDataBool val = new SetPlayerDataBool();
			val.boolName = FsmString.op_Implicit("defeatedPhantom");
			val.value = FsmBool.op_Implicit(true);
			SetPlayerDataBool val2 = new SetPlayerDataBool();
			val2.boolName = FsmString.op_Implicit("blackThreadWorld");
			val2.value = FsmBool.op_Implicit(true);
			FsmUtil.InsertAction(_control, "Collapse", (FsmStateAction)(object)val, 0);
			FsmUtil.InsertAction(_control, "Collapse", (FsmStateAction)(object)val2, 0);
			InvokeMethod invokeMethod = new InvokeMethod(endHornetConstrain);
			FsmUtil.AddAction(_control, "Final Parry", (FsmStateAction)(object)invokeMethod);
		}

		private void endHornetConstrain()
		{
			((Behaviour)SilkenSisters.hornetConstrain).enabled = false;
			SilkenSisters.Log.LogInfo((object)$"[PhantomBoss.endHornetConstrain] HornetConstrain?:{((Behaviour)SilkenSisters.hornetConstrain).enabled}");
		}
	}
	internal class PhantomScene : MonoBehaviour
	{
		private PlayMakerFSM _control;

		private void Awake()
		{
			Setup();
		}

		private async Task Setup()
		{
			getComponents();
			disableAreaDetection();
			editFSMEvents();
			editBossTitle();
			setupHornetControl();
		}

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

		private void disableAreaDetection()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			((Behaviour)(PlayMakerUnity2DProxy)((Component)this).GetComponent(typeof(PlayMakerUnity2DProxy))).enabled = false;
			((Behaviour)(BoxCollider2D)((Component)this).GetComponent(typeof(BoxCollider2D))).enabled = false;
		}

		private void editFSMEvents()
		{
			//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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Expected O, but got Unknown
			SilkenSisters.Log.LogMessage((object)"[PhantomBoss.editFSMEvents] Trigger lace jump");
			SendEventByName val = new SendEventByName();
			val.sendEvent = FsmString.op_Implicit("ENTER");
			val.delay = FsmFloat.op_Implicit(0f);
			FsmEventTarget val2 = new FsmEventTarget();
			val2.gameObject = SilkenSisters.plugin.laceNPCFSMOwner;
			val2.target = (EventTarget)1;
			val.eventTarget = val2;
			FsmUtil.AddAction(_control, "Organ Hit", (FsmStateAction)(object)val);
			FaceObjectV2 val3 = new FaceObjectV2();
			val3.objectA = SilkenSisters.hornetFSMOwner;
			val3.objectB = FsmGameObject.op_Implicit(SilkenSisters.plugin.lace2BossInstance);
			val3.spriteFacesRight = FsmBool.op_Implicit(false);
			val3.playNewAnimation = false;
			val3.newAnimationClip = FsmString.op_Implicit("");
			val3.resetFrame = false;
			val3.everyFrame = false;
			val3.pauseBetweenTurns = 0.1f;
			FsmUtil.AddAction(_control, "BG Fog", (FsmStateAction)(object)val3);
			Tk2dPlayAnimation val4 = new Tk2dPlayAnimation();
			val4.gameObject = SilkenSisters.hornetFSMOwner;
			val4.clipName = FsmString.op_Implicit("Challenge Talk Start");
			val4.animLibName = FsmString.op_Implicit("");
			FsmUtil.AddAction(_control, "BG Fog", (FsmStateAction)(object)val4);
		}

		private void setupHornetControl()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_003a: 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_0045: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			SilkenSisters.Log.LogMessage((object)"[PhantomBoss.setupHornetControl] Setting actions to give back hornet control");
			SendMessage val = new SendMessage();
			FunctionCall val2 = new FunctionCall();
			val2.FunctionName = "StartControlToIdle";
			val.functionCall = val2;
			val.gameObject = SilkenSisters.hornetFSMOwner;
			val.options = (SendMessageOptions)1;
			SendMessage val3 = new SendMessage();
			FunctionCall val4 = new FunctionCall();
			val4.FunctionName = "RegainControl";
			val3.functionCall = val4;
			val3.gameObject = SilkenSisters.hornetFSMOwner;
			val3.options = (SendMessageOptions)1;
			SetPlayerDataBool val5 = new SetPlayerDataBool();
			val5.boolName = FsmString.op_Implicit("disablePause");
			val5.value = FsmBool.op_Implicit(false);
			Tk2dPlayAnimation val6 = new Tk2dPlayAnimation();
			val6.gameObject = SilkenSisters.hornetFSMOwner;
			val6.clipName = FsmString.op_Implicit("Challenge Talk End");
			val6.animLibName = FsmString.op_Implicit("");
			FsmUtil.AddAction(_control, "Start Battle", (FsmStateAction)(object)val6);
			FsmUtil.AddAction(_control, "Start Battle", (FsmStateAction)(object)val3);
			FsmUtil.AddAction(_control, "Start Battle", (FsmStateAction)(object)val);
			FsmUtil.AddAction(_control, "Start Battle", (FsmStateAction)(object)val5);
		}

		private void editBossTitle()
		{
			FsmUtil.GetAction<DisplayBossTitle>(_control, "Start Battle", 3).bossTitle = FsmString.op_Implicit("SILKEN_SISTERS");
			SilkenSisters.Log.LogInfo((object)string.Format("[PhantomBoss.editBossTitle] NewTitleBase:{0}", FsmUtil.GetAction<DisplayBossTitle>(_control, "Start Battle", 3).bossTitle));
		}
	}
}