Decompiled source of Microsoft SAM Inner Monologue v1.0.2

plugins/MicrosoftSAMInnerMonologue/InnerMonologue.dll

Decompiled 3 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using HarmonyLib;
using ProjectProphet.Patching;
using ProjectProphet.StageAddons;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ProjectProphet")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ProjectProphet")]
[assembly: AssemblyCopyright("Copyright ©  2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("dfa813c9-c407-48f5-b20f-615a3c8fdbe3")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ProjectProphet
{
	public static class Utils
	{
		public static bool notifLaunched;

		public const string bundleProjectPath = "Assets\\Maranara\\Projects\\InnerMonologue";

		private static string _packedPath;

		public static Dictionary<string, Shader> shaders;

		public static StyleHUD shud => MonoSingleton<StyleHUD>.Instance;

		public static GunControl gc => MonoSingleton<GunControl>.Instance;

		public static WeaponCharges wc => MonoSingleton<WeaponCharges>.Instance;

		public static TimeController timeController => MonoSingleton<TimeController>.Instance;

		public static string PackedPath
		{
			get
			{
				if (string.IsNullOrEmpty(_packedPath))
				{
					_packedPath = Path.Combine(ModPath() ?? "", "bundles");
				}
				return _packedPath;
			}
		}

		public static AssetBundle curStageBundle { get; private set; }

		private static string ModPath()
		{
			return Assembly.GetExecutingAssembly().Location.Substring(0, Assembly.GetExecutingAssembly().Location.LastIndexOf("\\"));
		}

		public static void InitShaders()
		{
			Shader value = Shader.Find("psx/vertexlit/vertexlit");
			shaders = new Dictionary<string, Shader>();
			shaders.Add("psx/vertexlit/vertexlit", value);
			shaders.Add("Standard", value);
			shaders.Add("psx/unlit/transparent/nocull-fresnel", Shader.Find("psx/unlit/transparent/nocull-fresnel"));
			shaders.Add("psx/unlit/ambient", Shader.Find("psx/unlit/ambient"));
			shaders.Add("psx/unlit/transparent/unlit-scrolling", Shader.Find("psx/unlit/transparent/unlit-scrolling"));
		}

		public static void FixShaders(this GameObject go)
		{
			Renderer[] componentsInChildren = (Renderer[])(object)go.GetComponentsInChildren<SkinnedMeshRenderer>();
			Renderer[] array = componentsInChildren;
			componentsInChildren = (Renderer[])(object)go.GetComponentsInChildren<MeshRenderer>();
			Renderer[] array2 = componentsInChildren;
			Renderer[] array3 = array;
			foreach (Renderer rend in array3)
			{
				FixRenderer(rend);
			}
			Renderer[] array4 = array2;
			foreach (Renderer rend2 in array4)
			{
				FixRenderer(rend2);
			}
		}

		private static void FixRenderer(Renderer rend)
		{
			Material[] sharedMaterials = rend.sharedMaterials;
			foreach (Material val in sharedMaterials)
			{
				if (!((Object)(object)val == (Object)null) && shaders.ContainsKey(((Object)val.shader).name))
				{
					val.shader = shaders[((Object)val.shader).name];
				}
			}
		}

		public static T FindScriptInScene<T>()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			GameObject[] rootGameObjects = ((Scene)(ref activeScene)).GetRootGameObjects();
			GameObject[] array = rootGameObjects;
			foreach (GameObject val in array)
			{
				T componentInChildren = val.GetComponentInChildren<T>(true);
				if (componentInChildren != null)
				{
					return componentInChildren;
				}
			}
			return default(T);
		}

		public static T[] FindScriptsInScene<T>()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			GameObject[] rootGameObjects = ((Scene)(ref activeScene)).GetRootGameObjects();
			List<T> list = new List<T>();
			GameObject[] array = rootGameObjects;
			foreach (GameObject val in array)
			{
				T[] componentsInChildren = val.GetComponentsInChildren<T>(true);
				list.AddRange(componentsInChildren);
			}
			return list.ToArray();
		}

		public static Vector3 ClampMagnitude(this Vector3 v, float max, float min)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			double num = ((Vector3)(ref v)).sqrMagnitude;
			if (num > (double)max * (double)max)
			{
				return ((Vector3)(ref v)).normalized * max;
			}
			if (num < (double)min * (double)min)
			{
				return ((Vector3)(ref v)).normalized * min;
			}
			return v;
		}

		public static ObjectActivator LineOnActivate(GameObject target, GameObject lineObj)
		{
			return LineOnActivate(target, lineObj, 0.1f);
		}

		public static ObjectActivator LineOnActivate(GameObject target, GameObject lineObj, float delay)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			lineObj.SetActive(false);
			lineObj.GetComponent<AudioSource>().playOnAwake = true;
			GameObject val = new GameObject("Line OBAC");
			val.transform.parent = target.transform;
			val.transform.localPosition = Vector3.zero;
			ObjectActivator val2 = val.AddComponent<ObjectActivator>();
			val2.delay = delay;
			val2.events = new UltrakillEvent();
			val2.events.toActivateObjects = (GameObject[])(object)new GameObject[1];
			val2.events.toActivateObjects[0] = lineObj.gameObject;
			return val2;
		}

		public static UnityAction LineEvent(GameObject lineObj)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			lineObj.SetActive(false);
			lineObj.GetComponent<AudioSource>().playOnAwake = true;
			return (UnityAction)delegate
			{
				lineObj.SetActive(true);
			};
		}

		public static void DeathLine(EnemyIdentifier id, GameObject line, float delay)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			line.SetActive(false);
			line.GetComponent<AudioSource>().playOnAwake = true;
			GameObject val = new GameObject("Line OBAC");
			val.SetActive(false);
			ObjectActivator val2 = val.AddComponent<ObjectActivator>();
			val2.delay = delay;
			val2.events = new UltrakillEvent();
			val2.events.toActivateObjects = (GameObject[])(object)new GameObject[1];
			val2.events.toActivateObjects[0] = line.gameObject;
			List<GameObject> list = new List<GameObject>();
			if (id.activateOnDeath != null)
			{
				list.AddRange(id.activateOnDeath);
			}
			list.Add(val);
			id.activateOnDeath = list.ToArray();
		}

		public static void HurtButDontKill(int damage)
		{
			NewMovement instance = MonoSingleton<NewMovement>.Instance;
			int num = 0;
			if (instance.hp != 1)
			{
				num = ((instance.hp > damage) ? damage : (instance.hp - 1));
				instance.GetHurt(num, false, 1f, false, false);
			}
		}

		public static GameObject LoadAndInstantiateStage(string levelName)
		{
			string text = PackedPath + "\\" + levelName + ".lvl";
			if ((Object)(object)curStageBundle == (Object)null)
			{
				curStageBundle = AssetBundle.LoadFromFile(text);
			}
			else
			{
				Debug.Log((object)((Object)curStageBundle).name);
				if (((Object)curStageBundle).name != levelName + ".lvl")
				{
					if ((Object)(object)curStageBundle != (Object)null)
					{
						curStageBundle.Unload(true);
					}
					curStageBundle = AssetBundle.LoadFromFile(text);
					((Object)curStageBundle).name = levelName;
					Debug.Log((object)"Loading stage bundle...");
				}
				else
				{
					Debug.Log((object)"Stage bundle already loaded");
				}
			}
			if (curStageBundle.isStreamedSceneAssetBundle)
			{
				return null;
			}
			GameObject val = curStageBundle.LoadAsset<GameObject>("Assets\\Maranara\\Projects\\InnerMonologue/LevelAddons/" + levelName + ".prefab");
			return Object.Instantiate<GameObject>(val);
		}
	}
	[BepInPlugin("maranara_inner_monologue", "Inner Monologue", "1.0.0")]
	public class InternalMonologue : BaseUnityPlugin
	{
		public static Harmony harmony;

		private static float styleTimer;

		private static GabrielVoice curDeathVoice;

		private static GabrielVoice curStyleVoice;

		private static GameObject deathVoicePrefab;

		private static GameObject ultrakillVoicePrefab;

		public static Dictionary<int, StageAddon> sceneToBundle;

		public static Dictionary<string, StageAddon> specialToBundle;

		private void Start()
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
			{
				if (pluginInfo.Key == "maranara_project_prophet")
				{
					Debug.LogError((object)"[INNER MONOLOGUE MOD BLOCKED] Cannot load Inner Monologue as it will break MASQUERADE DIVINITY.");
					Object.Destroy((Object)(object)this);
					return;
				}
			}
			Utils.InitShaders();
			harmony = new Harmony("maranara_inner_monologue");
			harmony.PatchAll(typeof(InternalMonologue));
			InitStageAddons();
			string text = Utils.PackedPath + "\\death.bd";
			AssetBundle val = AssetBundle.LoadFromFile(text);
			((Object)val).hideFlags = (HideFlags)32;
			deathVoicePrefab = val.LoadAsset<GameObject>("Assets\\Maranara\\Projects\\InnerMonologue/LevelAddons/Death.prefab");
			ultrakillVoicePrefab = val.LoadAsset<GameObject>("Assets\\Maranara\\Projects\\InnerMonologue/LevelAddons/Ultrakill.prefab");
		}

		[HarmonyPatch(typeof(NewMovement), "Start")]
		[HarmonyPostfix]
		public static void NewMovStart(NewMovement __instance)
		{
			GameObject val = Object.Instantiate<GameObject>(deathVoicePrefab);
			curDeathVoice = val.GetComponent<GabrielVoice>();
			GameObject val2 = Object.Instantiate<GameObject>(ultrakillVoicePrefab);
			curStyleVoice = val2.GetComponent<GabrielVoice>();
		}

		[HarmonyPatch(typeof(Punch), "ForceHold")]
		[HarmonyPostfix]
		public static void PunchHold(Punch __instance, ItemIdentifier itid)
		{
			Wrath.PickUpFlorpCheck(itid);
		}

		[HarmonyPatch(typeof(Punch), "PlaceHeldObject")]
		[HarmonyPostfix]
		public static void PlaceFlorpCheck(Punch __instance)
		{
			Wrath.PlaceFlorpCheck();
		}

		[HarmonyPatch(typeof(NewMovement), "GetHurt")]
		[HarmonyPostfix]
		public static void GetHurt(NewMovement __instance)
		{
			if (__instance.dead)
			{
				curDeathVoice.Taunt();
			}
		}

		[HarmonyPatch(typeof(NewMovement), "Update")]
		[HarmonyPostfix]
		public static void RankUpdate(NewMovement __instance)
		{
			if (styleTimer > 0f)
			{
				styleTimer -= Time.deltaTime;
			}
		}

		[HarmonyPatch(typeof(StyleHUD), "AscendRank")]
		[HarmonyPostfix]
		public static void RankUp(StyleHUD __instance)
		{
			if (((Object)__instance.currentRank.sprite).name == "RankU" && styleTimer <= 0f)
			{
				styleTimer = 15f;
				curStyleVoice.Taunt();
			}
		}

		[HarmonyPatch(typeof(SceneHelper), "OnSceneLoaded")]
		[HarmonyPostfix]
		private static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			string currentScene = SceneHelper.CurrentScene;
			if (string.IsNullOrEmpty(currentScene))
			{
				return;
			}
			currentScene = currentScene.Substring(currentScene.Length - 3);
			currentScene = currentScene.Remove(1, 1);
			StageAddon value2;
			if (int.TryParse(currentScene, out var result))
			{
				string path = Utils.PackedPath + "\\" + currentScene + ".lvl";
				if (sceneToBundle.TryGetValue(result, out var value))
				{
					value.RunAddon();
				}
				else if (File.Exists(path))
				{
					Utils.LoadAndInstantiateStage(currentScene);
				}
			}
			else if (specialToBundle.TryGetValue(currentScene, out value2))
			{
				value2.RunAddon();
			}
		}

		private void InitStageAddons()
		{
			sceneToBundle = new Dictionary<int, StageAddon>();
			specialToBundle = new Dictionary<string, StageAddon>();
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			Type[] types = executingAssembly.GetTypes();
			foreach (Type type in types)
			{
				if (type.Namespace != "ProjectProphet.StageAddons")
				{
					continue;
				}
				MethodInfo[] methods = type.GetMethods();
				MethodInfo[] array = methods;
				foreach (MethodInfo methodInfo in array)
				{
					StageAddon customAttribute = methodInfo.GetCustomAttribute<StageAddon>();
					if (customAttribute != null)
					{
						customAttribute.SetMethodInfo(methodInfo);
						if (customAttribute.stage != 0)
						{
							sceneToBundle.Add(customAttribute.stage, customAttribute);
						}
						else
						{
							specialToBundle.Add(customAttribute.specialStageName, customAttribute);
						}
					}
				}
			}
		}
	}
}
namespace ProjectProphet.StageAddons
{
	public static class Gluttony
	{
		[StageAddon(32)]
		public static void Gabriel()
		{
			GameObject val = Utils.LoadAndInstantiateStage("32");
			GameObject gameObject = ((Component)val.transform.GetChild(1)).gameObject;
			ScaleTransform val2 = Utils.FindScriptInScene<ScaleTransform>();
			Utils.LineOnActivate(((Component)((Component)val2).transform.GetChild(3)).gameObject, gameObject, 0.3f);
			CutsceneSkip val3 = Utils.FindScriptInScene<CutsceneSkip>();
			List<GameObject> list = new List<GameObject>();
			list.AddRange(val3.onSkip.toActivateObjects);
			list.Add(gameObject);
			val3.onSkip.toActivateObjects = list.ToArray();
		}

		[StageAddon(62)]
		public static void Gabriel2()
		{
			GameObject val = Utils.LoadAndInstantiateStage("62");
			GameObject gameObject = ((Component)val.transform.GetChild(1)).gameObject;
			ScaleTransform val2 = Utils.FindScriptInScene<ScaleTransform>();
			GameObject gameObject2 = ((Component)((Component)val2).transform.parent.GetChild(1).GetChild(0)).gameObject;
			Utils.LineOnActivate(gameObject2, gameObject, 7f);
		}
	}
	public static class Special
	{
		[StageAddon("0S")]
		public static void SomethingWicked()
		{
			GameObject val = Utils.LoadAndInstantiateStage("0S");
			GameObject gameObject = ((Component)GameObject.Find("MessageParent").transform.GetChild(0)).gameObject;
			Utils.LineOnActivate(gameObject, ((Component)val.transform.GetChild(0)).gameObject, 4f);
		}

		[StageAddon("1S")]
		public static void Puzzle()
		{
			GameObject val = Utils.LoadAndInstantiateStage("1S");
		}

		[StageAddon("4S")]
		public static void Clash()
		{
			GameObject val = Utils.LoadAndInstantiateStage("4S");
			GameObject gameObject = ((Component)val.transform.GetChild(0)).gameObject;
			gameObject.SetActive(false);
			List<GameObject> list = new List<GameObject>();
			Door val2 = ((Component)GameObject.Find("FirstRoom Secret").transform.Find("Room").Find("FinalDoor")).GetComponent<FinalDoor>().doors[0];
			list.AddRange(val2.activatedRooms);
			list.Add(gameObject);
			val2.activatedRooms = list.ToArray();
		}

		[StageAddon("P1")]
		public static void PrimeSanctum()
		{
			GameObject val = Utils.LoadAndInstantiateStage("P1");
			MinosPrime val2 = Utils.FindScriptInScene<MinosPrime>();
			CutsceneSkip[] array = Utils.FindScriptsInScene<CutsceneSkip>();
			CutsceneSkip[] array2 = array;
			foreach (CutsceneSkip val3 in array2)
			{
				if (((Object)((Component)val3).gameObject).name == "MinosPrimeIntro")
				{
					List<GameObject> list = new List<GameObject>();
					list.AddRange(val3.onSkip.toActivateObjects);
					list.Add(((Component)val.transform.GetChild(1)).gameObject);
					val3.onSkip.toActivateObjects = list.ToArray();
					Utils.LineOnActivate(((Component)((Component)val3).transform.GetChild(6)).gameObject, ((Component)val.transform.GetChild(1)).gameObject, 24f);
					break;
				}
			}
			List<GameObject> list2 = new List<GameObject>();
			list2.AddRange(val2.onOutroEnd.toActivateObjects);
			list2.Add(((Component)val.transform.GetChild(2)).gameObject);
			val2.onOutroEnd.toActivateObjects = list2.ToArray();
		}
	}
	public static class Wrath
	{
		private static GameObject florpLoop;

		private static ItemIdentifier florpId;

		[StageAddon(52)]
		public static void Ferryman()
		{
			GameObject val = Utils.LoadAndInstantiateStage("52");
			GameObject gameObject = ((Component)val.transform.GetChild(0)).gameObject;
			Ferryman val2 = Utils.FindScriptInScene<Ferryman>();
			Utils.LineOnActivate(((Component)val2).gameObject, gameObject);
			Idol[] array = Utils.FindScriptsInScene<Idol>();
			Idol[] array2 = array;
			foreach (Idol val3 in array2)
			{
				if (((Object)((Component)val3).transform.root).name == "3 - Ferryman's Cabin")
				{
					((Component)val3).GetComponent<EnemyIdentifier>().onDeath.AddListener(Utils.LineEvent(((Component)val.transform.GetChild(1)).gameObject));
					break;
				}
			}
			ItemPlaceZone val4 = null;
			ItemPlaceZone val5 = null;
			ItemPlaceZone[] array3 = Utils.FindScriptsInScene<ItemPlaceZone>();
			ItemPlaceZone[] array4 = array3;
			foreach (ItemPlaceZone val6 in array4)
			{
				if (((Object)((Component)val6).transform.root).name == "JakitoCaged" && ((Object)((Component)val6).transform.parent).name == "Altar")
				{
					val4 = val6;
				}
				else if (((Object)((Component)val6).transform.root).name == "8 - Ship")
				{
					val5 = val6;
				}
			}
			florpLoop = ((Component)val.transform.GetChild(2)).gameObject;
			florpId = ((Component)val5).GetComponentInChildren<ItemIdentifier>();
			List<GameObject> list = new List<GameObject>();
			list.AddRange(val4.activateOnSuccess);
			list.Add(((Component)val.transform.GetChild(3)).gameObject);
			val4.activateOnSuccess = list.ToArray();
			List<GameObject> list2 = new List<GameObject>();
			list2.AddRange(val4.deactivateOnSuccess);
			list2.Add(florpLoop);
			val4.deactivateOnSuccess = list2.ToArray();
			((MonoBehaviour)ThreadingHelper.Instance).StartCoroutine(WaitWaitWait(florpLoop));
		}

		private static IEnumerator WaitWaitWait(GameObject loooop)
		{
			yield return (object)new WaitForEndOfFrame();
			yield return (object)new WaitForEndOfFrame();
			yield return (object)new WaitForEndOfFrame();
			loooop.SetActive(false);
		}

		public static void PickUpFlorpCheck(ItemIdentifier id)
		{
			if (!((Object)(object)florpLoop == (Object)null) && !((Object)(object)florpId == (Object)null) && !((Object)(object)id != (Object)(object)florpId))
			{
				florpLoop.SetActive(florpId.pickedUp);
			}
		}

		public static void PlaceFlorpCheck()
		{
			if (!((Object)(object)florpLoop == (Object)null) && !((Object)(object)florpId == (Object)null))
			{
				florpLoop.SetActive(false);
			}
		}

		[StageAddon(53)]
		public static void RocketLauncherPickup()
		{
			GameObject val = Utils.LoadAndInstantiateStage("53");
			GameObject gameObject = ((Component)val.transform.GetChild(1)).gameObject;
			gameObject.SetActive(false);
			AudioSource component = gameObject.GetComponent<AudioSource>();
			component.playOnAwake = true;
			WeaponPickUp val2 = Utils.FindScriptInScene<WeaponPickUp>();
			val2.activateOnPickup = gameObject;
		}

		[StageAddon(54)]
		public static void Leviathan()
		{
			GameObject val = Utils.LoadAndInstantiateStage("54");
			GameObject gameObject = ((Component)val.transform.GetChild(0)).gameObject;
			LeviathanController val2 = Utils.FindScriptInScene<LeviathanController>();
			Utils.LineOnActivate(((Component)val2).gameObject, gameObject, 1f);
			EnemyIdentifier component = ((Component)val2).GetComponent<EnemyIdentifier>();
			Utils.DeathLine(component, ((Component)val.transform.GetChild(1)).gameObject, 0.7f);
		}
	}
	public static class Greed
	{
		[StageAddon(42)]
		public static void Sisyphus()
		{
			GameObject val = Utils.LoadAndInstantiateStage("42");
			GameObject gameObject = ((Component)val.transform.GetChild(1)).gameObject;
			Sisyphus val2 = Utils.FindScriptInScene<Sisyphus>();
			Utils.LineOnActivate(((Component)val2).gameObject, gameObject);
			((Component)val2).GetComponent<Machine>().onDeath.AddListener(Utils.LineEvent(((Component)val.transform.GetChild(2)).gameObject));
		}

		[StageAddon(43)]
		public static void TorchOn()
		{
			GameObject val = Utils.LoadAndInstantiateStage("43");
			GameObject gameObject = ((Component)val.transform.GetChild(1)).gameObject;
			gameObject.SetActive(false);
			gameObject.GetComponent<AudioSource>().playOnAwake = true;
			ItemPlaceZone[] array = Utils.FindScriptsInScene<ItemPlaceZone>();
			ItemPlaceZone[] array2 = array;
			foreach (ItemPlaceZone val2 in array2)
			{
				if (((Object)((Component)val2).transform.root).name == "7 - Generator Room")
				{
					List<GameObject> list = new List<GameObject>();
					list.AddRange(val2.activateOnSuccess);
					list.Add(gameObject);
					val2.activateOnSuccess = list.ToArray();
				}
			}
			Mandalore val3 = Utils.FindScriptInScene<Mandalore>();
			Utils.DeathLine(((Component)val3).GetComponent<EnemyIdentifier>(), ((Component)val.transform.GetChild(2)).gameObject, 3f);
		}

		[StageAddon(44)]
		public static void V22()
		{
			GameObject val = Utils.LoadAndInstantiateStage("44");
			GameObject gameObject = ((Component)val.transform.GetChild(2)).gameObject;
			HudMessage[] array = Utils.FindScriptsInScene<HudMessage>();
			HudMessage[] array2 = array;
			foreach (HudMessage val2 in array2)
			{
				if (((Object)((Component)val2).gameObject).name == "Message" && val2.timed)
				{
					Utils.LineOnActivate(((Component)val2).gameObject, gameObject);
					break;
				}
			}
		}
	}
	public static class Lust
	{
		[StageAddon(23)]
		public static void Mindflayer()
		{
			GameObject val = Utils.LoadAndInstantiateStage("23");
			GameObject gameObject = ((Component)val.transform.GetChild(0)).gameObject;
			Mindflayer val2 = Utils.FindScriptInScene<Mindflayer>();
			Utils.LineOnActivate(((Component)val2).gameObject, gameObject, 1f);
		}

		[StageAddon(24)]
		public static void MinosCorpse()
		{
			GameObject val = Utils.LoadAndInstantiateStage("24");
			GameObject gameObject = ((Component)val.transform.GetChild(0)).gameObject;
			MinosBoss val2 = Utils.FindScriptInScene<MinosBoss>();
			Utils.LineOnActivate(((Component)val2).gameObject, gameObject, 1f);
			FinalRoom val3 = Utils.FindScriptInScene<FinalRoom>();
			Utils.LineOnActivate(((Component)val3).gameObject, ((Component)val.transform.GetChild(1)).gameObject, 0f);
		}
	}
	public static class Limbo
	{
		[StageAddon(12)]
		public static void BurningWorld()
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			GameObject val = Utils.LoadAndInstantiateStage("12");
			GameObject line = ((Component)val.transform.GetChild(0)).gameObject;
			line.SetActive(false);
			((Component)GameObject.Find("FirstRoom").transform.Find("Room").Find("FinalDoor")).GetComponent<FinalDoor>().doors[0].onFullyOpened.AddListener((UnityAction)delegate
			{
				FinalizeScene(line);
			});
			CancerousRodent[] array = Utils.FindScriptsInScene<CancerousRodent>();
			CancerousRodent[] array2 = array;
			foreach (CancerousRodent val2 in array2)
			{
				if (val2.harmless)
				{
					Utils.DeathLine(((Component)val2).GetComponent<EnemyIdentifier>(), ((Component)val.transform.GetChild(1)).gameObject, 0.5f);
					break;
				}
			}
		}

		private static void FinalizeScene(GameObject toActivate)
		{
			Transform transform = GameObject.Find("1 - First Room").transform;
			GameObject gameObject = ((Component)transform.GetChild(0).GetChild(2)).gameObject;
			Utils.LineOnActivate(gameObject, toActivate, 0.5f);
		}

		[StageAddon(13)]
		public static void Sister()
		{
			GameObject val = Utils.LoadAndInstantiateStage("13");
			GameObject gameObject = ((Component)val.transform.GetChild(0)).gameObject;
			Mass val2 = Utils.FindScriptInScene<Mass>();
			Utils.LineOnActivate(((Component)val2).gameObject, gameObject, 0.3f);
		}

		[StageAddon(14)]
		public static void Mirror()
		{
			GameObject val = Utils.LoadAndInstantiateStage("14");
			GameObject gameObject = ((Component)val.transform.GetChild(0)).gameObject;
			V2 val2 = Utils.FindScriptInScene<V2>();
			Utils.LineOnActivate(((Component)val2).gameObject, gameObject, 0.6f);
			WeaponPickUp val3 = Utils.FindScriptInScene<WeaponPickUp>();
			Utils.LineOnActivate(val3.activateOnPickup, ((Component)val.transform.GetChild(1)).gameObject);
		}
	}
	public static class Prelude
	{
		[StageAddon(3)]
		public static void ShotgunPickup()
		{
			GameObject val = Utils.LoadAndInstantiateStage("03");
			GameObject gameObject = ((Component)val.transform.GetChild(1)).gameObject;
			gameObject.SetActive(false);
			AudioSource component = gameObject.GetComponent<AudioSource>();
			component.playOnAwake = true;
			WeaponPickUp val2 = Utils.FindScriptInScene<WeaponPickUp>();
			val2.activateOnPickup = gameObject;
		}

		[StageAddon(5)]
		public static void Cerberus()
		{
			GameObject val = Utils.LoadAndInstantiateStage("05");
			StatueFake[] array = Utils.FindScriptsInScene<StatueFake>();
			StatueFake cerb = null;
			StatueFake cerb2 = null;
			StatueFake[] array2 = array;
			foreach (StatueFake val2 in array2)
			{
				if (val2.quickSpawn)
				{
					cerb2 = val2;
				}
				else
				{
					cerb = val2;
				}
			}
			SubscribeCerb(cerb, val.transform.GetChild(0));
			SubscribeCerb(cerb2, val.transform.GetChild(1));
		}

		private static void SubscribeCerb(StatueFake cerb, Transform line)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			((Component)line).gameObject.SetActive(false);
			((Component)line).GetComponent<AudioSource>().playOnAwake = true;
			ObjectActivator val = cerb.toActivate[1].AddComponent<ObjectActivator>();
			val.events = new UltrakillEvent();
			val.events.toActivateObjects = (GameObject[])(object)new GameObject[1];
			val.events.toActivateObjects[0] = ((Component)line).gameObject;
		}
	}
}
namespace ProjectProphet.Patching
{
	[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
	public class StageAddon : Attribute
	{
		public int stage;

		public string specialStageName;

		private MethodInfo method;

		public StageAddon(int stage)
		{
			this.stage = stage;
		}

		public StageAddon(string stage)
		{
			specialStageName = stage;
		}

		public void SetMethodInfo(MethodInfo info)
		{
			method = info;
		}

		public void RunAddon()
		{
			method.Invoke(null, null);
		}
	}
}