Decompiled source of EnvyAndSpite v1.3.2

doomahreal.ultrakill.levelloader/DoomahLevelLoader.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading.Tasks;
using BepInEx;
using DoomahLevelLoader.UnityComponents;
using HarmonyLib;
using Logic;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("DoomahLevelLoader")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DoomahLevelLoader")]
[assembly: AssemblyTitle("DoomahLevelLoader")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public class TriggerZoneBehavior : MonoBehaviour
{
	public float delay = 2f;

	public float activationDelay = 0.1f;

	private bool hasActivated = false;

	private List<Transform> ignoreList = new List<Transform>();

	private void Start()
	{
		Collider component = ((Component)this).GetComponent<Collider>();
		if ((Object)(object)component != (Object)null)
		{
			component.isTrigger = true;
		}
		DelayedInitialization();
	}

	private void DelayedInitialization()
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Expected O, but got Unknown
		foreach (Transform item in ((Component)this).transform)
		{
			Transform val = item;
			((Component)val).gameObject.SetActive(false);
		}
	}

	private IEnumerator ActivateChildrenWithDelay()
	{
		bool allChildrenActivated;
		do
		{
			allChildrenActivated = true;
			foreach (Transform item in ((Component)this).transform)
			{
				Transform child = item;
				if ((Object)(object)child == (Object)null)
				{
					continue;
				}
				if (!ignoreList.Contains(child) && !((Object)child).name.Contains("Gore Zone") && !((Component)child).gameObject.activeSelf)
				{
					allChildrenActivated = false;
					if (((Object)child).name != null && (((Object)child).name != "NoPass(Clone)" || (Object)(object)((Component)child).GetComponent<AddressableReplacer>() == (Object)null))
					{
						yield return (object)new WaitForSeconds(activationDelay);
					}
					((Component)child).gameObject.SetActive(true);
					Debug.Log((object)("Trigger Activated child:  " + ((Object)child).name));
				}
				else
				{
					ignoreList.Add(child);
				}
			}
		}
		while (!allChildrenActivated);
		hasActivated = true;
	}

	private void OnTriggerEnter(Collider other)
	{
		if (((Object)((Component)other).gameObject).name == "Player" && !hasActivated)
		{
			((MonoBehaviour)this).StartCoroutine(ActivateChildrenWithDelay());
		}
	}
}
public class WaveComponent : MonoBehaviour
{
	public float checkInterval = 1f;

	private float timer = 0f;

	private float activationDelay = 0.1f;

	private bool hasActivated = false;

	private List<Transform> activatedChildren = new List<Transform>();

	private List<Transform> ignoreList = new List<Transform>();

	private void Start()
	{
		DisableAllChildren();
	}

	private void DisableAllChildren()
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Expected O, but got Unknown
		foreach (Transform item in ((Component)this).transform)
		{
			Transform val = item;
			((Component)val).gameObject.SetActive(false);
		}
	}

	private void Update()
	{
		timer += Time.deltaTime;
		if (timer >= checkInterval)
		{
			timer = 0f;
			CheckChildren();
		}
	}

	private IEnumerator ActivateChildrenWithDelay(Transform[] childrenToActivate)
	{
		foreach (Transform child in childrenToActivate)
		{
			if (((Object)child).name != "NoPass(Clone)" || (Object)(object)((Component)child).GetComponent<AddressableReplacer>() == (Object)null)
			{
				((Component)child).gameObject.SetActive(true);
				yield return (object)new WaitForSeconds(activationDelay);
			}
			else
			{
				((Component)child).gameObject.SetActive(true);
			}
		}
	}

	private void CheckChildren()
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Expected O, but got Unknown
		GameObject gameObject = ((Component)((Component)this).transform.parent).gameObject;
		List<GameObject> list = new List<GameObject>();
		foreach (Transform item in ((Component)this).transform)
		{
			Transform val = item;
			list.Add(((Component)val).gameObject);
		}
		List<Transform> list2 = new List<Transform>();
		list2.AddRange(gameObject.GetComponentsInChildren<Transform>());
		list2.Remove(((Component)this).transform);
		List<Transform> list3 = new List<Transform>();
		foreach (Transform item2 in list2)
		{
			EnemyIdentifier component = ((Component)item2).GetComponent<EnemyIdentifier>();
			if ((Object)(object)component != (Object)null && !component.dead)
			{
				list3.Add(item2);
			}
			else if ((Object)(object)component != (Object)null && component.dead && list3.Contains(item2))
			{
				list3.Remove(item2);
			}
		}
		Transform[] array = (Transform[])(object)new Transform[list.Count];
		for (int i = 0; i < list.Count; i++)
		{
			array[i] = list[i].transform;
		}
		if (list3.Count == 0 && !hasActivated)
		{
			hasActivated = true;
			((MonoBehaviour)this).StartCoroutine(ActivateChildrenWithDelay(array));
		}
	}
}
public static class ShaderManager
{
	private static Shader unlitShader;

	private static Shader vertexLitShader;

	private static Shader transparentShader;

	private static Dictionary<string, Shader> shaderDictionary;

	public static async Task LoadShaders()
	{
		AsyncOperationHandle<Shader> unlitHandle = Addressables.LoadAssetAsync<Shader>((object)"Assets/Shaders/Main/ULTRAKILL-unlit.shader");
		await unlitHandle.Task;
		unlitShader = unlitHandle.Result;
		AsyncOperationHandle<Shader> vertexLitHandle = Addressables.LoadAssetAsync<Shader>((object)"Assets/Shaders/Main/ULTRAKILL-vertexlit.shader");
		await vertexLitHandle.Task;
		vertexLitShader = vertexLitHandle.Result;
		AsyncOperationHandle<Shader> transparentHandle = Addressables.LoadAssetAsync<Shader>((object)"Assets/Shaders/Transparent/ULTRAKILL-vertexlit-transparent-zwrite.shader");
		await transparentHandle.Task;
		transparentShader = transparentHandle.Result;
		shaderDictionary = new Dictionary<string, Shader>
		{
			{ "ULTRAKILL/VERTEXLIT", vertexLitShader },
			{ "Standard", unlitShader },
			{ "ULTRAKILL/UNLIT", unlitShader },
			{ "ULTRAKILL/TRANSPARENT", transparentShader }
		};
	}

	public static void ApplyShaders(GameObject[] allGameObjects)
	{
		foreach (GameObject val in allGameObjects)
		{
			MeshRenderer[] componentsInChildren = val.GetComponentsInChildren<MeshRenderer>(true);
			MeshRenderer[] array = componentsInChildren;
			foreach (MeshRenderer val2 in array)
			{
				if (!(((Object)((Component)val2).gameObject).name == "Quad") && shaderDictionary.ContainsKey(((Object)((Renderer)val2).material.shader).name))
				{
					Shader shader = shaderDictionary[((Object)((Renderer)val2).material.shader).name];
					ApplyShaderToRenderer(val2, shader);
				}
			}
		}
	}

	private static void ApplyShaderToRenderer(MeshRenderer renderer, Shader shader)
	{
		Material[] materials = ((Renderer)renderer).materials;
		Material[] array = materials;
		foreach (Material val in array)
		{
			val.shader = shader;
		}
		((Renderer)renderer).materials = materials;
	}
}
namespace meshwhatever
{
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "DoomahLevelLoader";

		public const string PLUGIN_NAME = "DoomahLevelLoader";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace DoomahLevelLoader
{
	[HarmonyPatch(typeof(SceneHelper), "RestartScene")]
	public static class SceneHelper_RestartScene_Patch
	{
		[HarmonyPrefix]
		public static bool Prefix()
		{
			if (Plugin.IsCustomLevel)
			{
				SceneManager.LoadScene(Loaderscene.LoadedSceneName);
				Plugin.FixVariables();
				return false;
			}
			return true;
		}
	}
	public static class Loader
	{
		public static AssetBundle LoadTerminal()
		{
			try
			{
				Assembly executingAssembly = Assembly.GetExecutingAssembly();
				string name = "meshwhatever.terminal.bundle";
				using Stream stream = executingAssembly.GetManifestResourceStream(name);
				if (stream == null)
				{
					Debug.LogError((object)"Resource 'terminal.bundle' not found in embedded resources.");
					return null;
				}
				byte[] array = new byte[stream.Length];
				stream.Read(array, 0, array.Length);
				return AssetBundle.LoadFromMemory(array);
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("Error loading terminal: " + ex.Message));
				return null;
			}
		}
	}
	public static class Loaderscene
	{
		private static List<AssetBundle> loadedAssetBundles = new List<AssetBundle>();

		private static int currentAssetBundleIndex = 0;

		private static List<string> bundleFolderPaths = new List<string>();

		public static string LoadedSceneName { get; private set; }

		public static void Setup()
		{
			string location = Assembly.GetExecutingAssembly().Location;
			string directoryName = Path.GetDirectoryName(location);
			string text = Path.Combine(directoryName, "UnpackedLevels");
			if (!Directory.Exists(text))
			{
				Directory.CreateDirectory(text);
			}
			string[] files = Directory.GetFiles(directoryName, "*.doomah");
			string[] array = files;
			foreach (string text2 in array)
			{
				string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text2);
				string text3 = Path.Combine(text, fileNameWithoutExtension);
				try
				{
					if (!Directory.Exists(text3))
					{
						ZipFile.ExtractToDirectory(text2, text3);
					}
					LoadAssetBundle(text3);
				}
				catch
				{
					string fileName = Path.GetFileName(text2);
					Debug.LogError((object)("Failed to extract " + fileName + " ! , Please Uninstall map or ask creator to update to 1.3.0!"));
				}
			}
		}

		public static void DeleteUnpackedLevelsFolder()
		{
			string location = Assembly.GetExecutingAssembly().Location;
			string directoryName = Path.GetDirectoryName(location);
			string path = Path.Combine(directoryName, "UnpackedLevels");
			if (Directory.Exists(path))
			{
				try
				{
					Directory.Delete(path, recursive: true);
					Debug.Log((object)"UnpackedLevels folder deleted successfully.");
					return;
				}
				catch (Exception ex)
				{
					Debug.LogError((object)("Failed to delete UnpackedLevels folder: " + ex.Message));
					return;
				}
			}
			Debug.Log((object)"UnpackedLevels folder does not exist.");
		}

		private static void LoadAssetBundle(string folderPath)
		{
			string[] files = Directory.GetFiles(folderPath, "*.bundle");
			string[] array = files;
			foreach (string text in array)
			{
				AssetBundle val = AssetBundle.LoadFromFile(text);
				if ((Object)(object)val != (Object)null)
				{
					loadedAssetBundles.Add(val);
					bundleFolderPaths.Add(Path.GetDirectoryName(text));
				}
			}
		}

		public static string GetCurrentBundleFolderPath()
		{
			if (currentAssetBundleIndex >= 0 && currentAssetBundleIndex < bundleFolderPaths.Count)
			{
				return bundleFolderPaths[currentAssetBundleIndex];
			}
			return null;
		}

		public static void SelectAssetBundle(int index)
		{
			if (index >= 0 && index < loadedAssetBundles.Count)
			{
				currentAssetBundleIndex = index;
			}
		}

		public static void ExtractSceneName()
		{
			if (loadedAssetBundles.Count > 0)
			{
				string[] allScenePaths = loadedAssetBundles[currentAssetBundleIndex].GetAllScenePaths();
				if (allScenePaths.Length != 0)
				{
					string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(allScenePaths[0]);
					LoadedSceneName = fileNameWithoutExtension;
				}
			}
		}

		public static void Loadscene()
		{
			if (!string.IsNullOrEmpty(LoadedSceneName))
			{
				SceneManager.LoadSceneAsync(LoadedSceneName).completed += OnSceneLoadComplete;
				SceneHelper.ShowLoadingBlocker();
			}
		}

		private static void OnSceneLoadComplete(AsyncOperation asyncOperation)
		{
			SceneHelper.DismissBlockers();
		}

		public static void MoveToNextAssetBundle()
		{
			currentAssetBundleIndex = (currentAssetBundleIndex + 1) % loadedAssetBundles.Count;
		}

		public static void MoveToPreviousAssetBundle()
		{
			currentAssetBundleIndex = (currentAssetBundleIndex - 1 + loadedAssetBundles.Count) % loadedAssetBundles.Count;
		}
	}
	[BepInPlugin("doomahreal.ultrakill.levelloader", "DoomahLevelLoader", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private AssetBundle terminal;

		private bool terminalInstantiated = false;

		private Shader loadedShader;

		public static bool IsCustomLevel;

		private static Plugin _instance;

		public static Plugin Instance => _instance;

		private async Task Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"doomahreal.ultrakill.levelloader is loaded!");
			Loaderscene.Setup();
			terminal = Loader.LoadTerminal();
			_instance = this;
			Harmony val = new Harmony("doomahreal.ultrakill.levelloader");
			val.PatchAll();
			Loaderscene.ExtractSceneName();
			SceneManager.sceneLoaded += OnSceneLoaded;
			SceneManager.sceneUnloaded += OnSceneUnloaded;
			await ShaderManager.LoadShaders();
		}

		private void OnDestroy()
		{
			SceneManager.sceneLoaded -= OnSceneLoaded;
			SceneManager.sceneUnloaded -= OnSceneUnloaded;
			Loaderscene.DeleteUnpackedLevelsFolder();
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_003e: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			if (SceneHelper.CurrentScene == "uk_construct")
			{
				terminalInstantiated = false;
				Debug.Log((object)"Is scene alright parthner");
			}
			if (((Scene)(ref scene)).name == Loaderscene.LoadedSceneName)
			{
				Scene activeScene = SceneManager.GetActiveScene();
				SceneHelper.CurrentScene = ((Scene)(ref activeScene)).name;
				Camera main = Camera.main;
				IsCustomLevel = true;
				if ((Object)(object)main != (Object)null)
				{
					main.clearFlags = (CameraClearFlags)1;
				}
				else
				{
					Debug.LogWarning((object)"Main camera not found in the scene.");
				}
				activeScene = SceneManager.GetActiveScene();
				ShaderManager.ApplyShaders(((Scene)(ref activeScene)).GetRootGameObjects());
			}
			else
			{
				IsCustomLevel = false;
			}
		}

		private void OnSceneUnloaded(Scene scene)
		{
			if (SceneHelper.CurrentScene == "uk_construct")
			{
				terminalInstantiated = false;
			}
		}

		public static void FixVariables()
		{
			MonoSingleton<MapVarManager>.Instance.ReloadMapVars();
		}

		private void Update()
		{
			if (SceneHelper.CurrentScene == "uk_construct" && (Object)(object)terminal != (Object)null && !terminalInstantiated)
			{
				InstantiateTerminal();
				terminalInstantiated = true;
			}
		}

		private void InstantiateTerminal()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Invalid comparison between Unknown and I4
			//IL_006c: 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)
			AsyncOperationHandle<Shader> val = Addressables.LoadAssetAsync<Shader>((object)"Assets/Shaders/Main/ULTRAKILL-vertexlit.shader");
			val.WaitForCompletion();
			if ((int)val.Status != 1)
			{
				return;
			}
			loadedShader = val.Result;
			GameObject val2 = terminal.LoadAsset<GameObject>("assets/custom/levelloadterminal.prefab");
			if ((Object)(object)val2 == (Object)null)
			{
				return;
			}
			GameObject val3 = Object.Instantiate<GameObject>(val2, new Vector3(-36f, -10f, 335f), Quaternion.Euler(0f, 0f, 180f));
			Transform val4 = val3.transform.Find("Cube");
			if ((Object)(object)val4 == (Object)null)
			{
				return;
			}
			GameObject[] targets = (GameObject[])(object)new GameObject[1] { ((Component)val4).gameObject };
			Renderer component = ((Component)val4).GetComponent<Renderer>();
			if (!((Object)(object)component == (Object)null))
			{
				Material[] materials = component.materials;
				Material[] array = materials;
				foreach (Material val5 in array)
				{
					val5.shader = loadedShader;
				}
				component.materials = materials;
				OutdoorsChecker val6 = val3.AddComponent<OutdoorsChecker>();
				if ((Object)(object)val6 != (Object)null)
				{
					val6.targets = targets;
					val6.nonSolid = false;
				}
			}
		}
	}
	public class EnvyandSpiteterimal : MonoBehaviour
	{
		private static EnvyandSpiteterimal instance;

		public Text levelname;

		public Text loadbutton;

		public Button load;

		public Button gofowardinlist;

		public Button gobackinlist;

		public Image Levelpicture;

		public Text FrownyFace;

		public Button Discord;

		public static EnvyandSpiteterimal Instance
		{
			get
			{
				if ((Object)(object)instance == (Object)null)
				{
					instance = Object.FindObjectOfType<EnvyandSpiteterimal>();
					if ((Object)(object)instance == (Object)null)
					{
						Debug.LogError((object)"EnvyandSpiteterimal instance not found in the scene.");
					}
				}
				return instance;
			}
		}

		private void Start()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//IL_005e: 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_0093: Expected O, but got Unknown
			((UnityEvent)load.onClick).AddListener(new UnityAction(OnLoadButtonClick));
			((UnityEvent)gofowardinlist.onClick).AddListener(new UnityAction(OnGoForwardButtonClick));
			((UnityEvent)gobackinlist.onClick).AddListener(new UnityAction(OnGoBackButtonClick));
			((Graphic)Levelpicture).color = Color.white;
			UpdateLevelName();
			UpdateLevelPicture();
			((UnityEvent)Discord.onClick).AddListener(new UnityAction(OnDiscordButtonClick));
		}

		private void UpdateLevelPicture()
		{
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			string currentBundleFolderPath = Loaderscene.GetCurrentBundleFolderPath();
			if (!string.IsNullOrEmpty(currentBundleFolderPath))
			{
				string[] files = Directory.GetFiles(currentBundleFolderPath, "*.png");
				if (files.Length != 0)
				{
					string path = files[0];
					Texture2D val = LoadTextureFromFile(path);
					if ((Object)(object)val != (Object)null)
					{
						((Texture)val).filterMode = (FilterMode)0;
						Levelpicture.sprite = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), Vector2.zero);
						((Component)FrownyFace).gameObject.SetActive(false);
						((Graphic)Levelpicture).color = Color.white;
					}
				}
				else
				{
					((Component)FrownyFace).gameObject.SetActive(true);
					((Graphic)Levelpicture).color = new Color(1f, 1f, 1f, 0f);
				}
			}
			else
			{
				Debug.LogError((object)"Bundle folder path is null or empty.");
			}
		}

		private Texture2D LoadTextureFromFile(string path)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			byte[] array = File.ReadAllBytes(path);
			Texture2D val = new Texture2D(2, 2);
			ImageConversion.LoadImage(val, array);
			return val;
		}

		private void OnLoadButtonClick()
		{
			Loaderscene.Loadscene();
		}

		private void OnGoForwardButtonClick()
		{
			Loaderscene.MoveToNextAssetBundle();
			Loaderscene.ExtractSceneName();
			UpdateLevelName();
			UpdateLevelPicture();
		}

		private void OnGoBackButtonClick()
		{
			Loaderscene.MoveToPreviousAssetBundle();
			Loaderscene.ExtractSceneName();
			UpdateLevelName();
			UpdateLevelPicture();
		}

		private void OnDiscordButtonClick()
		{
			Application.OpenURL("https://discord.gg/RY8J67neJ9");
		}

		public void UpdateLevelName()
		{
			levelname.text = Loaderscene.LoadedSceneName;
		}
	}
}
namespace DoomahLevelLoader.UnityComponents
{
	public class AddressableReplacer : MonoBehaviour
	{
		public string targetAddress;

		public bool oneTime = true;

		public bool moveToParent = true;

		public bool destroyThis = true;

		public bool IsBoss = false;

		public string BossName;

		public bool IsSanded = false;

		public bool IsPuppet = false;

		public bool IsRadient = false;

		public float RadienceTier;

		public float DamageTier;

		public float SpeedTier;

		public float HealthTier;

		internal EnemyIdentifier eid;

		private bool _activated = false;

		private void OnEnable()
		{
			Activate();
		}

		public void Activate()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			if (oneTime && _activated)
			{
				return;
			}
			_activated = true;
			GameObject val = Addressables.LoadAssetAsync<GameObject>((object)targetAddress).WaitForCompletion();
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogWarning((object)("Tried to load asset at address " + targetAddress + ", but it does not exist"));
				((Behaviour)this).enabled = false;
				return;
			}
			GameObject val2 = Object.Instantiate<GameObject>(val, ((Component)this).transform.position, ((Component)this).transform.rotation, ((Component)this).transform);
			eid = val2.GetComponent<EnemyIdentifier>();
			if ((Object)(object)eid == (Object)null && val2.transform.childCount > 0)
			{
				eid = ((Component)val2.transform.GetChild(0)).GetComponent<EnemyIdentifier>();
			}
			if (moveToParent)
			{
				val2.transform.SetParent(((Component)this).transform.parent, true);
			}
			PostInstantiate(val2);
			if ((Object)(object)eid != (Object)null && IsBoss)
			{
				BossHealthBar val3 = ((Component)eid).gameObject.AddComponent<BossHealthBar>();
				if (!string.IsNullOrEmpty(BossName))
				{
					val3.bossName = BossName;
				}
			}
			if ((Object)(object)eid != (Object)null && IsSanded)
			{
				eid.Sandify(false);
			}
			if ((Object)(object)eid != (Object)null && IsPuppet)
			{
				eid.PuppetSpawn();
				eid.puppet = true;
			}
			if ((Object)(object)eid != (Object)null && IsRadient)
			{
				eid.radianceTier = RadienceTier;
				eid.healthBuffModifier = HealthTier;
				eid.speedBuffModifier = SpeedTier;
				eid.damageBuffModifier = DamageTier;
				eid.BuffAll();
			}
			if (destroyThis)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				((Component)this).gameObject.SetActive(false);
			}
			((Behaviour)this).enabled = false;
		}

		protected virtual void PostInstantiate(GameObject instantiatedObject)
		{
		}
	}
	public class Blocker : AddressableReplacer
	{
		protected override void PostInstantiate(GameObject instantiatedObject)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: 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)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			BoxCollider component = ((Component)this).GetComponent<BoxCollider>();
			if ((Object)(object)component != (Object)null)
			{
				BoxCollider val = instantiatedObject.AddComponent<BoxCollider>();
				val.center = component.center;
				val.size = new Vector3(component.size.z, component.size.y, component.size.x);
				Quaternion rotation = ((Component)this).transform.rotation;
				Quaternion rotation2 = Quaternion.Euler(0f, ((Quaternion)(ref rotation)).eulerAngles.y + 90f, 0f);
				instantiatedObject.transform.rotation = rotation2;
				instantiatedObject.AddComponent<BlockerUpdater>();
				Object.Destroy((Object)(object)component);
			}
			else
			{
				Debug.LogWarning((object)"Original object does not have a BoxCollider component.");
			}
		}
	}
	public class BlockerUpdater : MonoBehaviour
	{
		private float timer = 0f;

		private float checkInterval = 0.2f;

		private void Update()
		{
			timer += Time.deltaTime;
			if (timer >= checkInterval)
			{
				timer = 0f;
				CheckEnemies();
			}
		}

		private void CheckEnemies()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Expected O, but got Unknown
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Expected O, but got Unknown
			bool flag = true;
			Transform parent = ((Component)this).transform.parent;
			if ((Object)(object)parent != (Object)null)
			{
				foreach (Transform item in parent)
				{
					Transform val = item;
					if (!((Object)(object)((Component)val).GetComponent<WaveComponent>() != (Object)null))
					{
						EnemyIdentifier component = ((Component)val).GetComponent<EnemyIdentifier>();
						if ((Object)(object)component != (Object)null && !component.dead)
						{
							flag = false;
							break;
						}
					}
				}
			}
			if (flag && (Object)(object)parent != (Object)null)
			{
				foreach (Transform item2 in parent)
				{
					Transform val2 = item2;
					if ((Object)(object)val2.parent != (Object)null && (Object)(object)((Component)val2.parent).GetComponent<WaveComponent>() != (Object)null)
					{
						continue;
					}
					foreach (Transform item3 in val2)
					{
						Transform val3 = item3;
						EnemyIdentifier component2 = ((Component)val3).GetComponent<EnemyIdentifier>();
						if ((Object)(object)component2 != (Object)null && !component2.dead)
						{
							flag = false;
							break;
						}
					}
					if (!flag)
					{
						break;
					}
				}
			}
			if (flag)
			{
				((Component)this).gameObject.SetActive(false);
			}
		}
	}
	public class CheckpointReplacer : AddressableReplacer
	{
		protected override void PostInstantiate(GameObject instantiatedObject)
		{
			Debug.Log((object)"Replacing checkpoint");
			CheckPoint componentInParent = ((Component)this).GetComponentInParent<CheckPoint>();
			CheckPoint component = instantiatedObject.GetComponent<CheckPoint>();
			foreach (Collider item in from col in instantiatedObject.GetComponentsInChildren<Collider>()
				where col.isTrigger
				select col)
			{
				Object.Destroy((Object)(object)((Component)item).gameObject);
			}
			Transform[] array = (from i in Enumerable.Range(0, instantiatedObject.transform.childCount)
				select instantiatedObject.transform.GetChild(i)).ToArray();
			foreach (Transform val in array)
			{
				Debug.Log((object)((Object)val).name);
				val.SetParent(((Component)this).transform.parent, true);
			}
			componentInParent.graphic = component.graphic;
			componentInParent.activateEffect = component.activateEffect;
		}
	}
	public class FinalDoorFixer : MonoBehaviour
	{
		public bool oneTime = true;

		public bool moveToParent = true;

		public BoxCollider OpenTrigger;

		private FinalDoor FD;

		private GameObject instantiatedObject;

		private bool isOpened = false;

		private bool _activated = false;

		private void OnEnable()
		{
			Activate();
		}

		public void Activate()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			if (oneTime && _activated)
			{
				return;
			}
			_activated = true;
			GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"Assets/Prefabs/Levels/Special Rooms/FinalRoom.prefab").WaitForCompletion();
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogWarning((object)"Tried to load asset, but it does not exist");
				((Behaviour)this).enabled = false;
				return;
			}
			instantiatedObject = Object.Instantiate<GameObject>(val, ((Component)this).transform.position, ((Component)this).transform.rotation, ((Component)this).transform);
			if (moveToParent)
			{
				instantiatedObject.transform.SetParent(((Component)this).transform.parent, true);
			}
			Debug.Log((object)"FinalDoorFixer: Final door game object loaded successfully.");
			Transform obj = instantiatedObject.transform.Find("FinalDoor");
			FinalDoor val2 = ((obj != null) ? ((Component)obj).GetComponent<FinalDoor>() : null);
			if ((Object)(object)val2 != (Object)null)
			{
				FD = val2;
				Debug.Log((object)"FinalDoorFixer: Final door component found successfully.");
			}
			else
			{
				Debug.LogWarning((object)"FinalDoorFixer: Final door component not found.");
			}
			PostInstantiate(instantiatedObject);
		}

		protected virtual void PostInstantiate(GameObject instantiatedObject)
		{
		}

		private void OnTriggerEnter(Collider other)
		{
			if (!isOpened && ((Component)other).CompareTag("Player") && (Object)(object)FD != (Object)null)
			{
				FD.Open();
				isOpened = true;
			}
		}
	}
	public class IdolAssigner : MonoBehaviour
	{
		public AddressableReplacer Target;

		public bool oneTime = true;

		public bool moveToParent = true;

		public bool destroyThis = true;

		private bool _activated = false;

		private void OnEnable()
		{
			Activate();
		}

		public void Activate()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			if (oneTime && _activated)
			{
				return;
			}
			_activated = true;
			GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"Assets/Prefabs/Enemies/Idol.prefab").WaitForCompletion();
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogWarning((object)"Tried to load asset, but it does not exist");
				((Behaviour)this).enabled = false;
				return;
			}
			GameObject val2 = Object.Instantiate<GameObject>(val, ((Component)this).transform.position, ((Component)this).transform.rotation, ((Component)this).transform);
			if (moveToParent)
			{
				val2.transform.SetParent(((Component)this).transform.parent, true);
			}
			Idol component = val2.GetComponent<Idol>();
			if ((Object)(object)component != (Object)null && (Object)(object)Target != (Object)null && (Object)(object)Target.eid != (Object)null)
			{
				component.overrideTarget = Target.eid;
			}
			PostInstantiate(val2);
			if (destroyThis)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				((Component)this).gameObject.SetActive(false);
			}
			((Behaviour)this).enabled = false;
		}

		protected virtual void PostInstantiate(GameObject instantiatedObject)
		{
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}