Decompiled source of SilkenSisters v0.3.0

SilkenSisters.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.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 Silksong.AssetHelper.Core;
using Silksong.AssetHelper.ManagedAssets;
using Silksong.FsmUtil;
using Silksong.UnityHelper.Extensions;
using TeamCherry.Localization;
using UnityEngine;
using UnityEngine.ResourceManagement.ResourceProviders;
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.3.0.0")]
[assembly: AssemblyInformationalVersion("0.3.0+a58c2564fd6ca568acc81aa79ec8845df4cc6e78")]
[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.3.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace Microsoft.CodeAnalysis
{
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace SilkenSisters
{
	public class 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.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("io.github.al3ks1s.silkensisters", "SilkenSisters", "0.3.0")]
	public class SilkenSisters : BaseUnityPlugin
	{
		[CompilerGenerated]
		private sealed class <>c__DisplayClass46_0
		{
			public List<ManagedAsset<GameObject>> _individualAssets;

			internal bool <cacheGameObjects>b__1()
			{
				return _individualAssets.All((ManagedAsset<GameObject> x) => x.Handle.IsDone);
			}
		}

		[CompilerGenerated]
		private sealed class <WaitAndPatch>d__39 : 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__39(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();
			}
		}

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

			private object <>2__current;

			public SilkenSisters <>4__this;

			private Stopwatch <sw>5__2;

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

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

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

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

			private bool MoveNext()
			{
				//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_012a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0134: Expected O, but got Unknown
				int num = <>1__state;
				SilkenSisters silkenSisters = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
				{
					<>1__state = -1;
					<>c__DisplayClass46_0 CS$<>8__locals0 = new <>c__DisplayClass46_0();
					<sw>5__2 = Stopwatch.StartNew();
					CS$<>8__locals0._individualAssets = new List<ManagedAsset<GameObject>> { silkenSisters.laceNPCCache, silkenSisters.lace2BossSceneCache, silkenSisters.lace1BossSceneCache, silkenSisters.challengeDialogCache, silkenSisters.wakeupPointCache, silkenSisters.coralBossSceneCache, silkenSisters.deepMemoryCache, silkenSisters.infoPromptCache, silkenSisters.silkfliesCache };
					if (CS$<>8__locals0._individualAssets.All((ManagedAsset<GameObject> x) => x.HasBeenLoaded))
					{
						break;
					}
					((BaseUnityPlugin)silkenSisters).Logger.LogMessage((object)"[cacheGameObjects] Initializing cache");
					foreach (ManagedAsset<GameObject> individualAsset in CS$<>8__locals0._individualAssets)
					{
						individualAsset.Load();
					}
					<>2__current = (object)new WaitUntil((Func<bool>)(() => CS$<>8__locals0._individualAssets.All((ManagedAsset<GameObject> x) => x.Handle.IsDone)));
					<>1__state = 1;
					return true;
				}
				case 1:
				{
					<>1__state = -1;
					GameObject obj = ManagedAssetExtensions.InstantiateAsset<GameObject>(silkenSisters.coralBossSceneCache);
					PlayMakerFSM fsmPreprocessed = FsmUtil.GetFsmPreprocessed(obj, "Control");
					silkenSisters.ExitMemoryCache = FsmUtil.GetState(fsmPreprocessed, "Exit Memory");
					Object.Destroy((Object)(object)obj);
					<sw>5__2.Stop();
					break;
				}
				}
				Log.LogInfo((object)$"It took {<sw>5__2.ElapsedMilliseconds}ms to load the assets");
				((BaseUnityPlugin)silkenSisters).Logger.LogMessage((object)"[cacheGameObjects] Caching done");
				return false;
			}

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

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

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

			private object <>2__current;

			public SilkenSisters <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_011e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0128: Expected O, but got Unknown
				int num = <>1__state;
				SilkenSisters silkenSisters = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = ((MonoBehaviour)silkenSisters).StartCoroutine(silkenSisters.cacheGameObjects());
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (!isMemory() && canSetupMemoryFight())
					{
						((BaseUnityPlugin)silkenSisters).Logger.LogMessage((object)"[preloadOrgan] Is not memory and all requirements met, setting things up");
						silkenSisters.setupDeepMemoryZone();
					}
					else if (!isMemory() && canSetupNormalFight() && debugBuild)
					{
						((BaseUnityPlugin)silkenSisters).Logger.LogMessage((object)"[preloadOrgan] Setting up normalFight (not available as of yet)");
						silkenSisters.setupNormalFight();
					}
					else
					{
						((BaseUnityPlugin)silkenSisters).Logger.LogInfo((object)$"[preloadOrgan] Scene info: canSetup?:{canSetupMemoryFight()}, isMemory?:{isMemory()}");
						if (!isMemory() && !canSetupMemoryFight() && !canSetupNormalFight())
						{
							((BaseUnityPlugin)silkenSisters).Logger.LogMessage((object)"[preloadOrgan] Displaying the info prompt");
							silkenSisters.infoPromptInstance = ManagedAssetExtensions.InstantiateAsset<GameObject>(silkenSisters.infoPromptCache);
							silkenSisters.infoPromptInstance.AddComponent<InfoPrompt>();
							silkenSisters.infoPromptInstance.SetActive(true);
						}
					}
					<>2__current = (object)new WaitForSeconds(0.2f);
					<>1__state = 2;
					return true;
				case 2:
				{
					<>1__state = -1;
					GameObject val = GameObject.Find("Deep Memory Enter Black(Clone)");
					if ((Object)(object)val != (Object)null)
					{
						((BaseUnityPlugin)silkenSisters).Logger.LogMessage((object)"[preloadOrgan] Deleting leftover memory effect");
						Object.Destroy((Object)(object)val);
					}
					val = GameObject.Find("Deep Memory Pre Enter Effect(Clone)");
					if ((Object)(object)val != (Object)null)
					{
						((BaseUnityPlugin)silkenSisters).Logger.LogMessage((object)"[preloadOrgan] Deleting leftover memory effect");
						Extensions.SetPosition2D(val.transform, -100f, -100f);
					}
					return false;
				}
				}
			}

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

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

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

			private object <>2__current;

			public SilkenSisters <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0056: Unknown result type (might be due to invalid IL or missing references)
				//IL_0090: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				SilkenSisters silkenSisters = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = silkenSisters.wispbundle.Load();
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>2__current = silkenSisters.wisp.Load();
					<>1__state = 2;
					return true;
				case 2:
				{
					<>1__state = -1;
					GameObject obj = ManagedAssetExtensions.InstantiateAsset<GameObject>(silkenSisters.wisp);
					obj.transform.position = hornet.transform.position;
					Object.DontDestroyOnLoad((Object)(object)obj);
					return false;
				}
				}
			}

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

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

		public List<ManagedAsset<GameObject>> _individualAssets = new List<ManagedAsset<GameObject>>();

		public static SilkenSisters plugin;

		public static Scene organScene;

		public ManagedAsset<GameObject> laceNPCCache;

		public ManagedAsset<GameObject> silkfliesCache;

		public ManagedAsset<GameObject> lace2BossSceneCache;

		public ManagedAsset<GameObject> lace1BossSceneCache;

		public ManagedAsset<GameObject> challengeDialogCache;

		public ManagedAsset<GameObject> wakeupPointCache;

		public ManagedAsset<GameObject> coralBossSceneCache;

		public ManagedAsset<GameObject> deepMemoryCache;

		public ManagedAsset<GameObject> wisp;

		public ManagedAsset<IAssetBundleResource> wispbundle;

		public ManagedAsset<GameObject> infoPromptCache;

		public FsmState ExitMemoryCache;

		public GameObject laceNPCInstance;

		public FsmOwnerDefault laceNPCFSMOwner;

		public GameObject silkflies;

		public GameObject laceBossInstance;

		public GameObject laceBossSceneInstance;

		public FsmOwnerDefault laceBossFSMOwner;

		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;

		internal static ManualLogSource Log;

		private ConfigEntry<KeyCode> modifierKey;

		private ConfigEntry<KeyCode> actionKey;

		public static ConfigEntry<bool> syncedFight;

		public static bool debugBuild;

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

		public static string Name => "SilkenSisters";

		public static string Version => "0.3.0";

		private void Awake()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			Log = new ManualLogSource("SilkenSisters");
			Logger.Sources.Add((ILogSource)(object)Log);
			debugBuild = true;
			plugin = this;
			modifierKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keybinds", "Modifier", (KeyCode)308, "Modifier");
			syncedFight = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "SyncedFight", false, "Use the Synced patterns for the boss fights. Unavailable as of yet.");
			((MonoBehaviour)this).StartCoroutine(WaitAndPatch());
			requestAssets();
			SceneManager.sceneLoaded += onSceneLoaded;
			Harmony.CreateAndPatchAll(typeof(SilkenSisters), (string)null);
			((BaseUnityPlugin)this).Logger.LogMessage((object)"Plugin loaded and initialized");
		}

		private void requestAssets()
		{
			laceNPCCache = ManagedAsset<GameObject>.FromSceneAsset("Coral_19", "Encounter Scene Control/Lace Meet/Lace NPC Blasted Bridge");
			lace2BossSceneCache = ManagedAsset<GameObject>.FromSceneAsset("Song_Tower_01", "Boss Scene");
			lace1BossSceneCache = ManagedAsset<GameObject>.FromSceneAsset("Bone_East_12", "Boss Scene");
			silkfliesCache = ManagedAsset<GameObject>.FromSceneAsset("Bone_East_12", "Boss Scene/Silkflies");
			challengeDialogCache = ManagedAsset<GameObject>.FromSceneAsset("Cradle_03", "Boss Scene/Intro Sequence");
			wakeupPointCache = ManagedAsset<GameObject>.FromSceneAsset("Memory_Coral_Tower", "Door Get Up");
			coralBossSceneCache = ManagedAsset<GameObject>.FromSceneAsset("Memory_Coral_Tower", "Boss Scene");
			deepMemoryCache = ManagedAsset<GameObject>.FromSceneAsset("Coral_Tower_01", "Memory Group");
			infoPromptCache = ManagedAsset<GameObject>.FromSceneAsset("Arborium_01", "Inspect Region");
			wisp = ManagedAsset<GameObject>.FromSceneAsset("Wisp_02", "Wisp Bounce Pod");
			wispbundle = new ManagedAsset<IAssetBundleResource>(AddressablesData.ToBundleKey("textures_assets_areabellareawispsprintmaster"));
		}

		[IteratorStateMachine(typeof(<WaitAndPatch>d__39))]
		private IEnumerator WaitAndPatch()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <WaitAndPatch>d__39(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 setStateListener(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 (((Object)__instance.Fsm.GameObject).name == "Lace NPC Blasted Bridge(Clone)" && __instance.Fsm.Name == "Control")
			{
				Log.LogInfo((object)("[StateListen] " + __instance.Name));
			}
			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 canSetupMemoryFight()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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 canSetupNormalFight()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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] = $"DefeatedLace1:{PlayerData._instance.defeatedLace1} ";
			obj[4] = $"DefeatedLace2:{PlayerData._instance.defeatedLaceTower} ";
			obj[5] = $"DefeatedPhantom:{PlayerData._instance.defeatedPhantom} ";
			obj[6] = $"Act3:{PlayerData._instance.blackThreadWorld}";
			log.LogDebug((object)string.Concat(obj));
			activeScene = SceneManager.GetActiveScene();
			if (((Scene)(ref activeScene)).name == "Organ_01" && !PlayerData._instance.defeatedLace1 && !PlayerData._instance.defeatedLaceTower && !PlayerData._instance.defeatedPhantom)
			{
				return !PlayerData._instance.blackThreadWorld;
			}
			return false;
		}

		public static bool isMemory()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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;
		}

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

		private void onSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"[onSceneLoaded] Scene loaded : {((Scene)(ref scene)).name}, active scene : {SceneManager.GetActiveScene()}, Path:{((Scene)(ref scene)).path}");
			_ = 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;
					((MonoBehaviour)this).StartCoroutine(preloadOrgan());
				}
				else
				{
					((BaseUnityPlugin)this).Logger.LogMessage((object)"[onSceneLoaded] Scene is not organ, clearing instances and cache");
					clearInstances();
				}
			}
			if (((Scene)(ref scene)).name == "Quit_To_Menu")
			{
				clearInstances();
				clearCache();
			}
		}

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

		private void clearInstances()
		{
			laceNPCInstance = null;
			laceNPCFSMOwner = null;
			silkflies = null;
			laceBossInstance = null;
			laceBossSceneInstance = null;
			laceBossFSMOwner = null;
			challengeDialogInstance = null;
			deepMemoryInstance = null;
			phantomBossScene = null;
			phantomBossSceneFSMOwner = null;
			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;
			}
			laceNPCCache.Unload();
			silkfliesCache.Unload();
			lace2BossSceneCache.Unload();
			lace1BossSceneCache.Unload();
			challengeDialogCache.Unload();
			wakeupPointCache.Unload();
			deepMemoryCache.Unload();
			ExitMemoryCache = null;
		}

		public void setupNormalFight()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Expected O, but got Unknown
			((BaseUnityPlugin)this).Logger.LogMessage((object)"[setupFight] Trying to register phantom");
			phantomBossScene = UnityExtensions.FindGameObject(SceneManager.GetActiveScene(), "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 = ManagedAssetExtensions.InstantiateAsset<GameObject>(challengeDialogCache);
			challengeDialogInstance.AddComponent<ChallengeRegion>();
			challengeDialogInstance.SetActive(true);
			laceBossSceneInstance = ManagedAssetExtensions.InstantiateAsset<GameObject>(lace1BossSceneCache);
			laceBossSceneInstance.AddComponent<Lace1>();
			laceBossSceneInstance.SetActive(true);
			((BaseUnityPlugin)this).Logger.LogInfo((object)("[setupFight] Trying to find Lace Boss from scene " + ((Object)laceBossSceneInstance.gameObject).name));
			laceBossInstance = UnityExtensions.FindChild(laceBossSceneInstance, "Lace Boss1");
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"[setupFight] Lace object: {laceBossInstance}");
			laceBossInstance.SetActive(false);
			laceBossInstance.AddComponent<Lace1>();
			Component[] components = laceBossInstance.GetComponents(typeof(DeactivateIfPlayerdataTrue));
			for (int i = 0; i < components.Length; i++)
			{
				((Behaviour)(DeactivateIfPlayerdataTrue)components[i]).enabled = false;
			}
			laceBossFSMOwner = new FsmOwnerDefault();
			laceBossFSMOwner.OwnerOption = (OwnerDefaultOption)1;
			laceBossFSMOwner.GameObject = FsmGameObject.op_Implicit(laceBossInstance);
			laceNPCInstance = ManagedAssetExtensions.InstantiateAsset<GameObject>(laceNPCCache);
			laceNPCInstance.AddComponent<LaceNPC>();
			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>();
			UnityExtensions.FindChild(phantomBossScene, "Phantom").AddComponent<PhantomBoss>();
		}

		public void setupMemoryFight()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Expected O, but got Unknown
			((BaseUnityPlugin)this).Logger.LogMessage((object)"[setupFight] Trying to register phantom");
			phantomBossScene = UnityExtensions.FindGameObject(SceneManager.GetActiveScene(), "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 = ManagedAssetExtensions.InstantiateAsset<GameObject>(challengeDialogCache);
			challengeDialogInstance.AddComponent<ChallengeRegion>();
			challengeDialogInstance.SetActive(true);
			laceBossSceneInstance = ManagedAssetExtensions.InstantiateAsset<GameObject>(lace2BossSceneCache);
			laceBossSceneInstance.AddComponent<Lace2Scene>();
			laceBossSceneInstance.SetActive(true);
			((BaseUnityPlugin)this).Logger.LogInfo((object)("[setupFight] Trying to find Lace Boss from scene " + ((Object)laceBossSceneInstance.gameObject).name));
			laceBossInstance = UnityExtensions.FindChild(laceBossSceneInstance, "Lace Boss2 New");
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"[setupFight] Lace object: {laceBossInstance}");
			laceBossInstance.SetActive(false);
			laceBossInstance.AddComponent<Lace2>();
			((Behaviour)(DeactivateIfPlayerdataTrue)laceBossInstance.GetComponent(typeof(DeactivateIfPlayerdataTrue))).enabled = false;
			laceBossFSMOwner = new FsmOwnerDefault();
			laceBossFSMOwner.OwnerOption = (OwnerDefaultOption)1;
			laceBossFSMOwner.GameObject = FsmGameObject.op_Implicit(laceBossInstance);
			laceNPCInstance = ManagedAssetExtensions.InstantiateAsset<GameObject>(laceNPCCache);
			laceNPCInstance.AddComponent<LaceNPC>();
			laceNPCInstance.SetActive(true);
			silkflies = ManagedAssetExtensions.InstantiateAsset<GameObject>(silkfliesCache);
			silkflies.SetActive(false);
			silkflies.AddComponent<SilkFlies>();
			silkflies.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>();
			UnityExtensions.FindChild(phantomBossScene, "Phantom").AddComponent<PhantomBoss>();
		}

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

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

		private void spawnLaceBoss2()
		{
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			laceBossSceneInstance = ManagedAssetExtensions.InstantiateAsset<GameObject>(lace2BossSceneCache);
			laceBossSceneInstance.AddComponent<Lace2Scene>();
			laceBossSceneInstance.SetActive(true);
			((BaseUnityPlugin)this).Logger.LogInfo((object)("[spawnLaceBoss2] Trying to find Lace Boss from scene " + ((Object)laceBossSceneInstance.gameObject).name));
			laceBossInstance = UnityExtensions.FindChild(laceBossSceneInstance, "Lace Boss2 New");
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"[spawnLaceBoss2] Lace object: {laceBossInstance}");
			laceBossInstance.SetActive(false);
			laceBossInstance.AddComponent<Lace2>();
			laceBossFSMOwner = new FsmOwnerDefault();
			laceBossFSMOwner.OwnerOption = (OwnerDefaultOption)1;
			laceBossFSMOwner.GameObject = FsmGameObject.op_Implicit(laceBossInstance);
		}

		private void Update()
		{
			//IL_00be: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0369: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0466: Unknown result type (might be due to invalid IL or missing references)
			//IL_046b: 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.GetKeyDown((KeyCode)111))
			{
				PlayerData.instance.PreMemoryState = HeroItemsState.Record(HeroController.instance);
				PlayerData.instance.HasStoredMemoryState = true;
				PlayerData.instance.CaptureToolAmountsOverride();
			}
			if (Input.GetKeyDown((KeyCode)112))
			{
				HeroController.instance.ClearEffectsInstant();
				((HeroItemsState)(ref PlayerData.instance.PreMemoryState)).Apply(HeroController.instance);
				PlayerData.instance.HasStoredMemoryState = false;
				PlayerData.instance.ClearToolAmountsOverride();
			}
			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))
			{
				laceBossInstance.SetActive(true);
				((PlayMakerFSM)laceBossInstance.GetComponent(typeof(PlayMakerFSM))).SendEvent("BATTLE START FIRST");
			}
			if (Input.GetKey(modifierKey.Value) && Input.GetKeyDown((KeyCode)259))
			{
				laceBossInstance.GetComponent<HealthManager>().hp = 1;
			}
			if (Input.GetKey(modifierKey.Value) && Input.GetKeyDown((KeyCode)257))
			{
				UnityExtensions.FindChild(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))
			{
				UnityExtensions.FindChild(phantomBossScene, "Phantom").SetActive(false);
			}
			if (Input.GetKey(modifierKey.Value) && Input.GetKeyDown((KeyCode)262))
			{
				((PlayMakerFSM)laceBossInstance.GetComponent(typeof(PlayMakerFSM))).SetState("Multihit Slash End");
			}
			if (Input.GetKey(modifierKey.Value) && Input.GetKeyDown((KeyCode)260))
			{
				PlayMakerFSM.BroadcastEvent("PHANTOM_SYNC");
				PlayMakerFSM.BroadcastEvent("LACE_SYNC");
			}
			Scene activeScene;
			if (Input.GetKey(modifierKey.Value) && Input.GetKeyDown((KeyCode)112))
			{
				PlayerData._instance.defeatedPhantom = true;
				PlayerData._instance.defeatedLaceTower = true;
				PlayerData._instance.blackThreadWorld = true;
				PlayerData._instance.hasNeedolinMemoryPowerup = true;
				ManualLogSource log = Log;
				string[] obj = new string[7] { "[CanSetup] Scene:", null, null, null, null, null, null };
				activeScene = SceneManager.GetActiveScene();
				obj[1] = ((Scene)(ref activeScene)).name;
				obj[2] = " ";
				obj[3] = $"DefeatedLace2:{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));
			}
			if (Input.GetKey(modifierKey.Value) && Input.GetKeyDown((KeyCode)108))
			{
				PlayerData._instance.defeatedPhantom = false;
				PlayerData._instance.defeatedLace1 = false;
				PlayerData._instance.defeatedLaceTower = false;
				PlayerData._instance.blackThreadWorld = false;
				PlayerData._instance.hasNeedolinMemoryPowerup = false;
				ManualLogSource log2 = Log;
				string[] obj2 = new string[6] { "[CanSetup] Scene:", null, null, null, null, null };
				activeScene = SceneManager.GetActiveScene();
				obj2[1] = ((Scene)(ref activeScene)).name;
				obj2[2] = " ";
				obj2[3] = $"DefeatedLace2:{PlayerData._instance.defeatedLaceTower} ";
				obj2[4] = $"DefeatedPhantom:{PlayerData._instance.defeatedPhantom} ";
				obj2[5] = $"Act3:{PlayerData._instance.blackThreadWorld}";
				log2.LogWarning((object)string.Concat(obj2));
			}
		}

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

		public void releasewisp()
		{
			wisp.Unload();
		}
	}
	[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.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 = UnityExtensions.FindChild(((Component)this).gameObject, "Challenge Region");
			_regionControl = FsmUtil.GetFsmPreprocessed(_challengeRegion, "Challenge");
			_control = FsmUtil.GetFsmPreprocessed(((Component)this).gameObject, "First Challenge");
		}

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

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

		private void setPhantomTrigger()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			SilkenSisters.Log.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()
		{
			try
			{
				SilkenSisters.Log.LogMessage((object)"[DeepMemory.Setup] Started setting deep memory up");
				getComponents();
				setPosition();
				disableCrustKingObjects();
				editFSMTransition();
				editPlayerData();
				bypassToolPickup();
				manageTransitionGates();
				SilkenSisters.Log.LogMessage((object)"[DeepMemory.Setup] Done");
			}
			catch (Exception ex)
			{
				SilkenSisters.Log.LogError((object)$"{ex} {ex.Message}");
			}
		}

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

		private void setPosition()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).gameObject.transform.position = new Vector3(59.249f, 56.7457f, -3.1141f);
			UnityExtensions.FindChild(_before, "Deep_Memory_appear/threads").SetActive(false);
			Extensions.SetLocalPosition2D(UnityExtensions.FindChild(_before, "thread_memory").transform, 1.768f, -3.143f);
			SilkenSisters.Log.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)UnityExtensions.FindChild(_before, "CK_ground_hit0004").gameObject);
		}

		private void editFSMTransition()
		{
			FsmUtil.GetAction<BeginSceneTransition>(_control, "Transition Scene", 4).sceneName = FsmString.op_Implicit("Organ_01");
			FsmUtil.GetAction<BeginSceneTransition>(_control, "Transition Scene", 4).entryGateName = FsmString.op_Implicit("door_wakeInMemory_phantom");
			SilkenSisters.Log.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()
		{
			try
			{
				SilkenSisters.Log.LogMessage((object)"[WakeUpMemory.Setup] Started setting wakeup transition up");
				getComponents();
				setName();
				setPosition();
				editFSM();
				SilkenSisters.Log.LogMessage((object)"[WakeUpMemory.Setup] Finished");
			}
			catch (Exception ex)
			{
				SilkenSisters.Log.LogError((object)$"{ex} {ex.Message}");
			}
		}

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

		private void setName()
		{
			((Object)_wakeTransitionGate).name = "door_wakeInMemory_phantom";
			SilkenSisters.Log.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(recordHeroState);
			FsmUtil.AddAction(_control, "Take Control", (FsmStateAction)(object)invokeMethod3);
			InvokeMethod invokeMethod4 = new InvokeMethod(SilkenSisters.plugin.setupMemoryFight);
			FsmUtil.AddAction(_control, "Take Control", (FsmStateAction)(object)invokeMethod4);
			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 invokeMethod5 = new InvokeMethod(disableSelf);
			FsmUtil.AddAction(_control, "End", (FsmStateAction)(object)invokeMethod5);
			InvokeMethod invokeMethod6 = new InvokeMethod(closeOffOrgan);
			FsmUtil.AddAction(_control, "End", (FsmStateAction)(object)invokeMethod6);
		}

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

		private void recordHeroState()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			HeroController.instance.RefillSilkToMaxSilent();
			if (!PlayerData.instance.HasStoredMemoryState)
			{
				PlayerData.instance.PreMemoryState = HeroItemsState.Record(HeroController.instance);
				PlayerData.instance.HasStoredMemoryState = true;
				PlayerData.instance.CaptureToolAmountsOverride();
			}
		}
	}
	internal class WakeUpRespawn : MonoBehaviour
	{
		private PlayMakerFSM _control;

		private void Awake()
		{
			Setup();
		}

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

		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);
			InvokeMethod invokeMethod = new InvokeMethod(restoreHeroState);
			FsmUtil.AddAction(fsmPreprocessed, "Fade Up", (FsmStateAction)(object)invokeMethod);
			InvokeMethod invokeMethod2 = new InvokeMethod(disableDoor);
			FsmUtil.AddAction(fsmPreprocessed, "End", (FsmStateAction)(object)invokeMethod2);
			InvokeMethod invokeMethod3 = new InvokeMethod(disableSelf);
			FsmUtil.AddAction(fsmPreprocessed, "End", (FsmStateAction)(object)invokeMethod3);
		}

		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();
			UnityExtensions.FindChild(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 restoreHeroState()
		{
			if (PlayerData.instance.HasStoredMemoryState)
			{
				HeroController.instance.ClearEffectsInstant();
				((HeroItemsState)(ref PlayerData.instance.PreMemoryState)).Apply(HeroController.instance);
				PlayerData.instance.HasStoredMemoryState = false;
				PlayerData.instance.ClearToolAmountsOverride();
			}
		}
	}
	internal class InfoPrompt : MonoBehaviour
	{
		private BasicNPC _npc;

		private void Awake()
		{
			Setup();
		}

		private async Task Setup()
		{
			try
			{
				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");
			}
			catch (Exception ex)
			{
				SilkenSisters.Log.LogError((object)$"{ex} {ex.Message}");
			}
		}

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

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

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

		private void Awake()
		{
			Setup();
		}

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

		private void getComponents()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).gameObject.transform.position = new Vector3(78.2832f, 104.5677f, 0.004f);
			SilkenSisters.Log.LogInfo((object)$"[Lace1.getComponents] position:{((Component)this).gameObject.transform.position}");
			_control = FsmUtil.GetFsmPreprocessed(((Component)this).gameObject, "Control");
		}

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

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

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

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

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

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

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

		private void Awake()
		{
			Setup();
		}

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

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

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

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

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

		private void Awake()
		{
			Setup();
		}

		private async Task Setup()
		{
			try
			{
				SilkenSisters.Log.LogMessage((object)"[Lace2.Setup] Started setting up Lace");
				getComponents();
				disableParticleEffects();
				editPositionConstraint();
				rerouteState();
				fixActionsPositions();
				disableTitleCard();
				fixWallRangeAlert();
				disableLaceMusic();
				setLaceFacing();
				prepareSync();
				SilkenSisters.Log.LogMessage((object)"[Lace2.Setup] Finished setting up Lace");
			}
			catch (Exception ex)
			{
				SilkenSisters.Log.LogError((object)$"{ex} {ex.Message}");
			}
		}

		private void getComponents()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).gameObject.transform.position = new Vector3(78.2832f, 104.5677f, 0.004f);
			SilkenSisters.Log.LogInfo((object)$"[Lace2.getComponents] position:{((Component)this).gameObject.transform.position}");
			_control = FsmUtil.GetFsmPreprocessed(((Component)this).gameObject, "Control");
		}

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

		private void editPositionConstraint()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			ConstrainPosition val = (ConstrainPosition)((Component)this).gameObject.GetComponent(typeof(ConstrainPosition));
			val.SetXMin(72.4f);
			val.SetXMax(96.52f);
			val.SetYMin(104f);
			val.constrainX = true;
			val.constrainY = true;
			SilkenSisters.Log.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 disableLaceMusic()
		{
			FsmUtil.DisableAction(_control, "Start Battle Refight", 1);
			FsmUtil.DisableAction(_control, "Start Battle Refight", 2);
		}

		private void fixWallRangeAlert()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = UnityExtensions.FindChild(((Component)((Component)this).gameObject.transform.parent).gameObject, "Wall Range");
			Extensions.SetPosition3D(val.transform, 84.0349f, 103.67f, 0f);
			SilkenSisters.Log.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));
		}

		private void prepareSync()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			if (SilkenSisters.syncedFight.Value && SilkenSisters.debugBuild)
			{
				SilkenSisters.Log.LogMessage((object)"[Lace.prepareSync] Adding a Sync state");
				FsmUtil.AddState(_control, "SilkenSync");
				if (FsmEvent.GetFsmEvent("LACE_SYNC") == null)
				{
					FsmEvent.AddFsmEvent(new FsmEvent("LACE_SYNC"));
				}
				SilkenSisters.Log.LogMessage((object)"[Lace.prepareSync] Added a sync event");
				FsmUtil.ChangeTransition(_control, "Evade Move", "FINISHED", "Idle");
				FsmUtil.ChangeTransition(_control, "CrossSlash?", "FINISHED", "SilkenSync");
				FsmUtil.AddTransition(_control, "SilkenSync", "LACE_SYNC", "Distance Check");
			}
		}
	}
	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");
			UnityExtensions.FindChild(((Component)this).gameObject, "Flower Effect Hornet").SetActive(false);
			UnityExtensions.FindChild(((Component)this).gameObject, "steam hazard").SetActive(false);
			UnityExtensions.FindChild(((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");
			UnityExtensions.FindChild(((Component)this).gameObject, "Arena L").transform.position = new Vector3(72f, 104f, 0f);
			UnityExtensions.FindChild(((Component)this).gameObject, "Arena R").transform.position = new Vector3(97f, 104f, 0f);
			UnityExtensions.FindChild(((Component)this).gameObject, "Centre").transform.position = new Vector3(84.5f, 104f, 0f);
		}
	}
	internal class LaceCorpse : MonoBehaviour
	{
	}
	internal class Lace3
	{
	}
	internal class LaceNPC : MonoBehaviour
	{
		private PlayMakerFSM _control;

		private Transform _npcTransform;

		private void Awake()
		{
			Setup();
		}

		private async Task Setup()
		{
			try
			{
				SilkenSisters.Log.LogMessage((object)"[LaceNPC.Setup] Spawning lace on the organ bench");
				register();
				getComponents();
				AddVariables();
				disableRangeDetection();
				setPosition();
				editFSMAnimations();
				EditTransitions();
				SetConductAnimation();
				SkipDialogue();
				EditDialog();
				resumePhantom();
				SilkenSisters.Log.LogMessage((object)"[LaceNPC.Setup] Finished setting up LaceNPC");
			}
			catch (Exception ex)
			{
				SilkenSisters.Log.LogError((object)$"{ex} {ex.Message}");
			}
		}

		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()
		{
			UnityExtensions.FindChild(((Component)this).gameObject, "Start Range").SetActive(false);
			SilkenSisters.Log.LogInfo((object)string.Format("[LaceNPC.disableRangeDetection] LaceNPCDetection?:{0}", UnityExtensions.FindChild(((Component)this).gameObject, "Start Range").activeSelf));
		}

		private void setPosition()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			Extensions.SetPosition3D(_npcTransform, 81.9569f, 106.2943f, 2.7723f);
			SilkenSisters.Log.LogInfo((object)$"[LaceNPC.setPosition] position:{_npcTransform.position}");
		}

		private void SetConductAnimation()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Expected O, but got Unknown
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Expected O, but got Unknown
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Expected O, but got Unknown
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Expected O, but got Unknown
			FsmUtil.AddAction(_control, "Init", (FsmStateAction)new RandomBool
			{
				storeResult = FsmUtil.GetBoolVariable(_control, "IsConducting")
			});
			FsmUtil.AddAction(_control, "Init", (FsmStateAction)new BoolTest
			{
				boolVariable = FsmUtil.GetBoolVariable(_control, "IsConducting"),
				isTrue = FsmEvent.GetFsmEvent("CONDUCT")
			});
			FsmUtil.AddAction(_control, "Init", (FsmStateAction)new BoolTest
			{
				boolVariable = FsmUtil.GetBoolVariable(_control, "IsMemory"),
				isFalse = FsmEvent.GetFsmEvent("CONDUCT"),
				isTrue = FsmEvent.GetFsmEvent("FINISHED")
			});
			FsmUtil.AddState(_control, "Conduct");
			FsmUtil.AddTransition(_control, "Init", "CONDUCT", "Conduct");
			FsmUtil.AddTransition(_control, "Conduct", "FINISHED", "Dormant");
			FsmUtil.AddAction(_control, "Conduct", (FsmStateAction)(object)new InvokeMethod(setConductPosition));
			FsmUtil.AddAction(_control, "Conduct", (FsmStateAction)new Tk2dPlayAnimation
			{
				gameObject = SilkenSisters.plugin.laceNPCFSMOwner,
				animLibName = FsmString.op_Implicit(""),
				clipName = FsmString.op_Implicit("Conduct")
			});
			FsmUtil.DisableAction(_control, "Take Control", 1);
			FsmUtil.AddAction(_control, "Take Control", (FsmStateAction)new tk2dPlayAnimationConditional
			{
				Target = SilkenSisters.plugin.laceNPCFSMOwner,
				AnimName = FsmString.op_Implicit("NPC Idle Turn Left"),
				Condition = FsmUtil.GetBoolVariable(_control, "IsConducting")
			});
			FsmUtil.DisableAction(_control, "Sit Up", 1);
			FsmUtil.InsertAction(_control, "Sit Up", (FsmStateAction)new tk2dPlayAnimationConditional
			{
				Target = SilkenSisters.plugin.laceNPCFSMOwner,
				AnimName = FsmString.op_Implicit("TurnToIdle"),
				Condition = FsmUtil.GetBoolVariable(_control, "IsConducting")
			}, 1);
			FsmUtil.AddAction(_control, "Sit Up", (FsmStateAction)new tk2dPlayAnimationConditional
			{
				Target = SilkenSisters.plugin.laceNPCFSMOwner,
				AnimName = FsmString.op_Implicit("SitToIdle"),
				Condition = FsmUtil.GetBoolVariable(_control, "IsNotConducting")
			});
		}

		private void AddVariables()
		{
			FsmUtil.AddBoolVariable(_control, "IsConducting").Value = false;
			FsmUtil.AddBoolVariable(_control, "IsNotConducting").Value = true;
			FsmUtil.AddBoolVariable(_control, "IsMemory").Value = SilkenSisters.isMemory();
		}

		private void EditDialog()
		{
			FsmUtil.DisableAction(_control, "Take Control", 3);
			FsmUtil.DisableAction(_control, "Start Pause", 2);
			FsmUtil.DisableAction(_control, "Sit Up", 5);
			FsmUtil.DisableAction(_control, "Convo 3", 2);
			FsmUtil.DisableAction(_control, "Convo 3", 3);
			FsmUtil.DisableAction(_control, "Convo 3", 4);
			FsmUtil.DisableAction(_control, "Convo 3", 5);
			FsmUtil.DisableAction(_control, "Convo 4", 2);
			((RunDialogueBase)FsmUtil.GetAction<RunDialogue>(_control, "Convo 1", 0)).PreventHeroAnimation = FsmBool.op_Implicit(true);
			FsmUtil.GetAction<RunDialogue>(_control, "Convo 4", 0).Key = FsmString.op_Implicit("LACE_MEET_4");
			FsmUtil.GetAction<EndDialogue>(_control, "End", 3).ReturnControl = FsmBool.op_Implicit(false);
			FsmUtil.DisableAction(_control, "To Idle Anim", 0);
			FsmUtil.DisableAction(_control, "End Dialogue", 1);
		}

		private void EditTransitions()
		{
			FsmUtil.GetTransition(_control, "Take Control", "LAND").fsmEvent = FsmEvent.GetFsmEvent("FINISHED");
			FsmUtil.AddState(_control, "Lace Ready");
			FsmUtil.AddTransition(_control, "Lace Ready", "JUMP", "Jump Antic");
			FsmUtil.ChangeTransition(_control, "End Dialogue", "FINISHED", "Lace Ready");
			FsmUtil.ChangeTransition(_control, "Take Control", "FINISHED", "Convo 1");
		}

		private void editFSMAnimations()
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			SilkenSisters.Log.LogMessage((object)"[LaceNPC.editFSMAnimations] Editing Lace NPC FSM");
			InvokeMethod invokeMethod = new InvokeMethod(makeFliesLeave);
			FsmUtil.AddAction(_control, "Take Control", (FsmStateAction)(object)invokeMethod);
			SetPosition action = FsmUtil.GetAction<SetPosition>(_control, "Sit Up", 3);
			action.vector = FsmVector3.op_Implicit(new Vector3(81.9569f, 106.7942f, 2.7021f));
			action.x = FsmFloat.op_Implicit(81.9569f);
			action.y = FsmFloat.op_Implicit(106.7942f);
			action.z = FsmFloat.op_Implicit(2.7021f);
			InvokeMethod invokeMethod2 = new InvokeMethod(toggleChallenge);
			FsmUtil.AddAction(_control, "Jump Away", (FsmStateAction)(object)invokeMethod2);
			InvokeMethod invokeMethod3 = new InvokeMethod(startConstrainHornet);
			FsmUtil.AddAction(_control, "Jump Away", (FsmStateAction)(object)invokeMethod3);
			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 SkipDialogue()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Expected O, but got Unknown
			FsmUtil.AddTransition(_control, "Take Control", "SKIP", "Sit Up");
			FsmUtil.AddAction(_control, "Take Control", (FsmStateAction)new BoolTestDelay
			{
				boolVariable = FsmUtil.GetBoolVariable(_control, "IsMemory"),
				isTrue = FsmEvent.GetFsmEvent("SKIP"),
				delay = FsmFloat.op_Implicit(0.5f)
			});
			FsmUtil.AddTransition(_control, "Sit Up", "SKIP", "Lace Ready");
			FsmUtil.AddAction(_control, "Sit Up", (FsmStateAction)new BoolTest
			{
				boolVariable = FsmUtil.GetBoolVariable(_control, "IsMemory"),
				isTrue = FsmEvent.GetFsmEvent("SKIP")
			});
		}

		private void resumePhantom()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			FsmOwnerDefault val = new FsmOwnerDefault();
			val.OwnerOption = (OwnerDefaultOption)1;
			val.GameObject = FsmGameObject.op_Implicit(UnityExtensions.FindChild(SilkenSisters.plugin.phantomBossScene, "Organ Phantom"));
			FsmUtil.AddAction(_control, "Lace Ready", (FsmStateAction)new Tk2dResumeAnimation
			{
				gameObject = val
			});
		}

		private void setConductPosition()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			_npcTransform.position = new Vector3(81.9569f, 106.9124f, 2.9723f);
			FsmUtil.GetBoolVariable(_control, "IsConducting").Value = true;
			FsmUtil.GetBoolVariable(_control, "IsNotConducting").Value = false;
		}

		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}");
		}

		private void makeFliesLeave()
		{
			SilkenSisters.plugin.silkflies.GetComponent<SilkFlies>().Leave();
			SilkenSisters.Log.LogInfo((object)$"[LaceNPC.startConstrainHornet] constrainHornet?:{((Behaviour)SilkenSisters.hornetConstrain).enabled}");
		}
	}
	internal class SilkFlies : MonoBehaviour
	{
		private List<GameObject> _flies = new List<GameObject>();

		private List<PlayMakerFSM> _controls;

		private List<Vector3> _positions = new List<Vector3>(5)
		{
			new Vector3(81.5f, 108.8f, 2.7723f),
			new Vector3(76f, 109f, 2.7723f),
			new Vector3(79.5f, 106f, 2.7723f),
			new Vector3(77f, 106f, 2.7723f),
			new Vector3(78.5f, 110f, 2.7723f)
		};

		private void Awake()
		{
			Setup();
		}

		private void Setup()
		{
			GetComponents();
			SpawnNewFlies();
			SpawnNewFlies();
			SetPositions();
			ReduceBuzz();
		}

		private void GetComponents()
		{
			for (int i = 0; i < ((Component)this).gameObject.transform.childCount; i++)
			{
				_flies.Add(((Component)((Component)this).gameObject.transform.GetChild(i)).gameObject);
			}
			_controls = _flies.Select((GameObject f) => FsmUtil.GetFsmPreprocessed(f, "Control")).ToList();
		}

		private void SetPositions()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < _flies.Count; i++)
			{
				_flies[i].transform.position = _positions[i];
				Extensions.SetScaleX(_flies[i].transform, 0.9f);
				Extensions.SetScaleY(_flies[i].transform, 0.9f);
				FsmUtil.GetAction<IdleBuzzV3>(_controls[i], "Idle", 0).manualStartPos.Value = _positions[i];
			}
		}

		private void ReduceBuzz()
		{
			foreach (PlayMakerFSM control in _controls)
			{
				FsmUtil.GetAction<IdleBuzzV3>(control, "Idle", 0).roamingRangeX = FsmFloat.op_Implicit(0.35f);
				FsmUtil.GetAction<IdleBuzzV3>(control, "Idle", 0).roamingRangeY = FsmFloat.op_Implicit(0.25f);
			}
		}

		private void SpawnNewFlies()
		{
			GameObject val = Object.Instantiate<GameObject>(_flies[0]);
			val.transform.parent = ((Component)this).gameObject.transform;
			_flies.Add(val);
			_controls.Add(FsmUtil.GetFsmPreprocessed(val, "Control"));
		}

		public void Leave()
		{
			foreach (PlayMakerFSM control in _controls)
			{
				control.SendEvent("LEAVE");
			}
		}
	}
	internal class PhantomBoss : MonoBehaviour
	{
		private PlayMakerFSM _control;

		private void Awake()
		{
			Setup();
		}

		private async Task Setup()
		{
			try
			{
				SilkenSisters.Log.LogMessage((object)"[PhantomBoss.Setup] Started setting phantom boss up");
				Extensions.SetPositionX(((Component)this).gameObject.transform, 77.1797f);
				getComponents();
				triggerLace();
				listenForLaceDead();
				if (SilkenSisters.isMemory())
				{
					skipCutscene();
					prepareExitMemoryEffect();
				}
				prepareSync();
				InvokeMethod invokeMethod = new In