Decompiled source of Ancient Observatory v0.2.1

Ancient_Observatory.dll

Decompiled 4 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EnemiesReturns.Configuration;
using EnemiesReturns.Enemies.Colossus;
using EnemiesReturns.Enemies.Swift;
using FRCSharp;
using FSCStage;
using HG;
using HG.Reflection;
using Promenade.Content;
using R2API;
using RoR2;
using RoR2.ContentManagement;
using RoR2.Navigation;
using Sandswept;
using ShaderSwapper;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace FSCStage
{
	public class IsStarstorm2
	{
		private static bool? _enabled;

		public static bool enabled
		{
			get
			{
				if (!_enabled.HasValue)
				{
					_enabled = Chainloader.PluginInfos.ContainsKey("com.TeamMoonstorm.MSU") && Chainloader.PluginInfos.ContainsKey("com.TeamMoonstorm");
				}
				return _enabled.Value;
			}
		}
	}
	public class IsEnemiesReturns
	{
		private static bool? _enabled;

		public static bool enabled
		{
			get
			{
				if (!_enabled.HasValue)
				{
					_enabled = Chainloader.PluginInfos.ContainsKey("com.Viliger.EnemiesReturns");
				}
				return _enabled.Value;
			}
		}
	}
	public class IsSandswept
	{
		private static bool? _enabled;

		public static bool enabled
		{
			get
			{
				if (!_enabled.HasValue)
				{
					_enabled = Chainloader.PluginInfos.ContainsKey("com.TeamSandswept.Sandswept");
				}
				return _enabled.Value;
			}
		}
	}
	public class IsForgottenRelics
	{
		private static bool? _enabled;

		public static bool enabled
		{
			get
			{
				if (!_enabled.HasValue)
				{
					_enabled = Chainloader.PluginInfos.ContainsKey("PlasmaCore.ForgottenRelics");
				}
				return _enabled.Value;
			}
		}
	}
}
namespace Promenade
{
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	public class EnemiesReturnsCompat
	{
		public static void AddEnemies()
		{
			//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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Expected O, but got Unknown
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Expected O, but got Unknown
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Expected O, but got Unknown
			if (Promenade.toggleColossus.Value && Colossus.Enabled.Value)
			{
				DirectorCard card = new DirectorCard
				{
					spawnCard = (SpawnCard)SpawnCards.cscColossusGrassy,
					spawnDistance = (MonsterSpawnDistance)0,
					selectionWeight = Colossus.SelectionWeight.Value,
					minimumStageCompletions = Colossus.MinimumStageCompletion.Value
				};
				DirectorCardHolder val = new DirectorCardHolder
				{
					Card = card,
					MonsterCategory = (MonsterCategory)4
				};
				if (!Colossus.DefaultStageList.Value.Contains("observatory_wormsworms"))
				{
					Helpers.AddNewMonsterToStage(val, false, (Stage)1, "observatory_wormsworms");
					Log.Info("Colossus added to ancient observatory's spawn pool.");
				}
				if (!Colossus.DefaultStageList.Value.Contains("itobservatory_wormsworms"))
				{
					Helpers.AddNewMonsterToStage(val, false, (Stage)1, "itobservatory_wormsworms");
					Log.Info("Colossus added to ancient observatory's simulacrum spawn pool.");
				}
			}
			if (Promenade.toggleSwift.Value && Swift.Enabled.Value)
			{
				DirectorCard card2 = new DirectorCard
				{
					spawnCard = (SpawnCard)SpawnCards.cscSwiftDefault,
					spawnDistance = (MonsterSpawnDistance)2,
					selectionWeight = Swift.SelectionWeight.Value,
					minimumStageCompletions = Swift.MinimumStageCompletion.Value
				};
				DirectorCardHolder val2 = new DirectorCardHolder
				{
					Card = card2,
					MonsterCategory = (MonsterCategory)2
				};
				if (!Swift.DefaultStageList.Value.Contains("observatory_wormsworms"))
				{
					Helpers.AddNewMonsterToStage(val2, false, (Stage)1, "observatory_wormsworms");
					Log.Info("Swift added to ancient observatory's spawn pool.");
				}
				Swift.DefaultStageList.Value.Contains("itobservatory_wormsworms");
			}
		}
	}
	public class ForgottenRelicsCompat
	{
		public static CharacterSpawnCard CannonballJellyfishCard;

		public static void AddEnemies()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_003f: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0061: Expected O, but got Unknown
			if (Promenade.toggleBrassMonolith.Value && !VF2ConfigManager.disableBrassMonolith.Value)
			{
				DirectorCardHolder val = new DirectorCardHolder
				{
					Card = new DirectorCard
					{
						spawnCard = (SpawnCard)VF2ContentPackProvider.cscBrassMonolith,
						selectionWeight = 1
					},
					MonsterCategory = (MonsterCategory)4
				};
				Helpers.AddNewMonsterToStage(val, false, (Stage)1, "observatory_wormsworms");
				Helpers.AddNewMonsterToStage(val, false, (Stage)1, "itobservatory_wormsworms");
				Log.Debug("Brass Monolith added to ancient observatory spawn pool.");
			}
		}
	}
	public class SandsweptCompat
	{
		public static CharacterSpawnCard CannonballJellyfishCard;

		public static bool FindEnabledConfig(string configName)
		{
			ConfigEntryBase[] configEntries = Main.config.GetConfigEntries();
			foreach (ConfigEntryBase val in configEntries)
			{
				if (((object)val.Definition).ToString() == configName)
				{
					return (bool)val.BoxedValue;
				}
			}
			return false;
		}

		public static int FindCreditConfig(string configName)
		{
			ConfigEntryBase[] configEntries = Main.config.GetConfigEntries();
			foreach (ConfigEntryBase val in configEntries)
			{
				if (((object)val.Definition).ToString() == configName)
				{
					return (int)val.DefaultValue;
				}
			}
			return 115;
		}

		public static void AddEnemies()
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			//IL_00c9: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Expected O, but got Unknown
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Expected O, but got Unknown
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Expected O, but got Unknown
			//IL_0112: Expected O, but got Unknown
			bool flag = FindEnabledConfig("Enemies :: Cannonball Jellyfish.Enabled");
			if (Promenade.toggleCannonballJellyfish.Value && flag)
			{
				CannonballJellyfishCard = ScriptableObject.CreateInstance<CharacterSpawnCard>();
				((Object)CannonballJellyfishCard).name = "cscAOCannonballJellyfish";
				((SpawnCard)CannonballJellyfishCard).prefab = Main.assets.LoadAsset<GameObject>("CannonJellyMaster.prefab");
				((SpawnCard)CannonballJellyfishCard).sendOverNetwork = true;
				((SpawnCard)CannonballJellyfishCard).hullSize = (HullClassification)0;
				((SpawnCard)CannonballJellyfishCard).nodeGraphType = (GraphType)1;
				((SpawnCard)CannonballJellyfishCard).requiredFlags = (NodeFlags)0;
				((SpawnCard)CannonballJellyfishCard).forbiddenFlags = (NodeFlags)2;
				((SpawnCard)CannonballJellyfishCard).directorCreditCost = FindCreditConfig("Enemies :: Cannonball Jellyfish.Director Credit Cost");
				((SpawnCard)CannonballJellyfishCard).occupyPosition = false;
				CannonballJellyfishCard.loadout = new SerializableLoadout();
				CannonballJellyfishCard.noElites = false;
				CannonballJellyfishCard.forbiddenAsBoss = false;
				DirectorCardHolder val = new DirectorCardHolder
				{
					Card = new DirectorCard
					{
						spawnCard = (SpawnCard)CannonballJellyfishCard,
						selectionWeight = 1
					},
					MonsterCategory = (MonsterCategory)2
				};
				Helpers.AddNewMonsterToStage(val, false, (Stage)1, "observatory_wormsworms");
				Helpers.AddNewMonsterToStage(val, false, (Stage)1, "itobservatory_wormsworms");
				Log.Debug("Cannonball Jellyfish added to ancient observatory spawn pool.");
			}
		}
	}
	[BepInPlugin("wormsworms.Ancient_Observatory", "Ancient_Observatory", "0.2.1")]
	public class Promenade : BaseUnityPlugin
	{
		public const string Author = "wormsworms";

		public const string Name = "Ancient_Observatory";

		public const string Version = "0.2.1";

		public const string GUID = "wormsworms.Ancient_Observatory";

		public static Promenade instance;

		public static ConfigEntry<bool> enableRegular;

		public static ConfigEntry<bool> enableSimulacrum;

		public static ConfigEntry<bool> stage1Simulacrum;

		public static ConfigEntry<bool> toggleSwift;

		public static ConfigEntry<bool> toggleColossus;

		public static ConfigEntry<bool> toggleCannonballJellyfish;

		public static ConfigEntry<bool> toggleBrassMonolith;

		private void Awake()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			instance = this;
			Log.Init(((BaseUnityPlugin)this).Logger);
			ConfigSetup();
			ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(GiveToRoR2OurContentPackProviders);
			Language.collectLanguageRootFolders += CollectLanguageRootFolders;
			RoR2Application.onLoadFinished = (Action)Delegate.Combine(RoR2Application.onLoadFinished, new Action(AddModdedEnemies));
		}

		public static void AddModdedEnemies()
		{
			if (IsEnemiesReturns.enabled)
			{
				EnemiesReturnsCompat.AddEnemies();
			}
			if (IsSandswept.enabled)
			{
				SandsweptCompat.AddEnemies();
			}
			if (IsForgottenRelics.enabled)
			{
				ForgottenRelicsCompat.AddEnemies();
			}
		}

		public void ArtifactTeleporterSetup(Scene newScene, LoadSceneMode loadSceneMode)
		{
			if (!(((Scene)(ref newScene)).name == "observatory_wormsworms"))
			{
				return;
			}
			string[] array = new string[24]
			{
				"MS_FloatingIsland1", "Final Zone/Grass", "ChainlinkSet", "ChainlinkSet (1)", "ChainlinkSet (2)", "ChainlinkSet (3)", "TP Area Holder/MiscProps", "LShapeScaffolding", "StaircaseScaffolding", "Formula/spmSMGrassSmallCluster",
				"Formula/spmSMGrassSmallCluster (1)", "Formula/spmSMGrassSmallCluster (2)", "Formula/spmSMFruitPlant", "PortalDialer/spmSMGrassSmallCluster (3)", "PortalDialer/spmSMGrassSmallCluster (4)", "PortalDialerButton 1", "PortalDialerButton 2", "PortalDialerButton 3", "PortalDialerButton 4", "PortalDialerButton 5",
				"PortalDialerButton 6", "PortalDialerButton 7", "PortalDialerButton 8", "PortalDialerButton 9"
			};
			string[] obj = new string[9] { "Dialer Button 1", "Dialer Button 2", "Dialer Button 3", "Dialer Button 4", "Dialer Button 5", "Dialer Button 6", "Dialer Button 7", "Dialer Button 8", "Dialer Button 9" };
			PortalDialerButtonController[] array2 = (PortalDialerButtonController[])(object)new PortalDialerButtonController[9];
			GameObject obj2 = GameObject.Find("HOLDER: Artifact TP");
			GameObject val = GameObject.Find("PortalDialer");
			GameObject gameObject = ((Component)obj2.transform.GetChild(2)).gameObject;
			Log.Debug(((Object)val).name);
			Log.Debug(((Object)gameObject).name);
			NetworkServer.Spawn(gameObject);
			string[] array3 = obj;
			PortalDialerButtonController val3 = default(PortalDialerButtonController);
			foreach (string text in array3)
			{
				GameObject.Find(text);
				GameObject val2 = GameObject.Find(text + "/PortalDialerButton(Clone)");
				if ((Object)(object)val2 != (Object)null)
				{
					val2.TryGetComponent<PortalDialerButtonController>(ref val3);
					if ((Object)(object)val3 != (Object)null)
					{
						array2.Append(val3);
						Log.Debug("Appended controller to list: " + text);
						Log.Debug(((object)val3).ToString());
					}
					else
					{
						Log.Debug("dialer.GetComponent returned null: " + text);
					}
				}
				else
				{
					Log.Debug("GameObject.Find returned null: " + text);
				}
			}
			for (int j = 0; j > array2.Length; j++)
			{
				val.GetComponent<PortalDialerController>().buttons.SetValue(array2.ElementAt(j), j);
				val.GetComponent<PortalDialerController>().dialingOrder.SetValue(array2.ElementAt(j), j);
			}
			array3 = array;
			foreach (string text2 in array3)
			{
				if ((Object)(object)GameObject.Find(text2) != (Object)null)
				{
					GameObject.Find(text2).SetActive(false);
				}
			}
		}

		private void Destroy()
		{
			Language.collectLanguageRootFolders -= CollectLanguageRootFolders;
		}

		private static void GiveToRoR2OurContentPackProviders(AddContentPackProviderDelegate addContentPackProvider)
		{
			addContentPackProvider.Invoke((IContentPackProvider)(object)new ContentProvider());
		}

		public void CollectLanguageRootFolders(List<string> folders)
		{
			folders.Add(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "Language"));
		}

		private void ConfigSetup()
		{
			enableRegular = ((BaseUnityPlugin)this).Config.Bind<bool>("00 - Stages", "Enable Ancient Observatory", true, "If set to false, Ancient Observatory will never appear in regular runs.");
			enableSimulacrum = ((BaseUnityPlugin)this).Config.Bind<bool>("00 - Stages", "Enable Simulacrum Variant", true, "If set to false, Ancient Observatory will never appear in the Simulacrum.");
			stage1Simulacrum = ((BaseUnityPlugin)this).Config.Bind<bool>("00 - Stages", "Enable Simulacrum Variant on Stage 1", true, "If set to false, Ancient Observatory will only appear after clearing at least one stage in the Simulacrum.");
			toggleSwift = ((BaseUnityPlugin)this).Config.Bind<bool>("01 - Monsters: EnemiesReturns", "Enable Swift", true, "If set to false, Swifts will not appear in Ancient Observatory.");
			toggleColossus = ((BaseUnityPlugin)this).Config.Bind<bool>("01 - Monsters: EnemiesReturns", "Enable Colossus", true, "If set to false, Colossi will not appear in Ancient Observatory.");
			toggleCannonballJellyfish = ((BaseUnityPlugin)this).Config.Bind<bool>("03 - Monsters: Sandswept", "Enable Cannonball Jellyfish", true, "If set to false, Cannonball Jellyfish will not appear in Ancient Observatory.");
			toggleBrassMonolith = ((BaseUnityPlugin)this).Config.Bind<bool>("02 - Monsters: Forgotten Relics", "Enable Brass Monolith", true, "If set to false, Brass Monoliths will not appear in Ancient Observatory.");
		}
	}
}
namespace Promenade.Content
{
	public class ContentProvider : IContentPackProvider
	{
		private readonly ContentPack _contentPack = new ContentPack();

		public static string assetDirectory;

		public string identifier => "wormsworms.Ancient_Observatory.ContentProvider";

		public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
		{
			_contentPack.identifier = identifier;
			string assetsFolderFullPath = (assetDirectory = Path.GetDirectoryName(typeof(ContentProvider).Assembly.Location));
			AssetBundle scenesAssetBundle = null;
			yield return LoadAssetBundle(Path.Combine(assetsFolderFullPath, "ObservatoryScene"), args.progressReceiver, delegate(AssetBundle assetBundle)
			{
				scenesAssetBundle = assetBundle;
			});
			AssetBundle assetsAssetBundle = null;
			yield return LoadAssetBundle(Path.Combine(assetsFolderFullPath, "ObservatoryAssets"), args.progressReceiver, delegate(AssetBundle assetBundle)
			{
				assetsAssetBundle = assetBundle;
			});
			yield return PromenadeContent.LoadAssetBundlesAsync(scenesAssetBundle, assetsAssetBundle, args.progressReceiver, _contentPack);
		}

		private IEnumerator LoadAssetBundle(string assetBundleFullPath, IProgress<float> progress, Action<AssetBundle> onAssetBundleLoaded)
		{
			AssetBundleCreateRequest assetBundleCreateRequest = AssetBundle.LoadFromFileAsync(assetBundleFullPath);
			while (!((AsyncOperation)assetBundleCreateRequest).isDone)
			{
				progress.Report(((AsyncOperation)assetBundleCreateRequest).progress);
				yield return null;
			}
			onAssetBundleLoaded(assetBundleCreateRequest.assetBundle);
		}

		public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
		{
			ContentPack.Copy(_contentPack, args.output);
			args.ReportProgress(1f);
			yield break;
		}

		public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
		{
			args.ReportProgress(1f);
			yield break;
		}
	}
	public static class PromenadeContent
	{
		internal const string ScenesAssetBundleFileName = "ObservatoryScene";

		internal const string AssetsAssetBundleFileName = "ObservatoryAssets";

		private static AssetBundle _scenesAssetBundle;

		private static AssetBundle _assetsAssetBundle;

		internal static UnlockableDef[] UnlockableDefs;

		internal static SceneDef[] SceneDefs;

		internal static SceneDef PromenadeSceneDef;

		internal static Sprite PromenadeSceneDefPreviewSprite;

		internal static Material PromenadeBazaarSeer;

		internal static SceneDef SimuSceneDef;

		internal static Sprite SimuSceneDefPreviewSprite;

		internal static Material SimuBazaarSeer;

		public static List<Material> SwappedMaterials = new List<Material>();

		internal static IEnumerator LoadAssetBundlesAsync(AssetBundle scenesAssetBundle, AssetBundle assetsAssetBundle, IProgress<float> progress, ContentPack contentPack)
		{
			_scenesAssetBundle = scenesAssetBundle;
			_assetsAssetBundle = assetsAssetBundle;
			IEnumerator upgradeStubbedShaders = ShaderSwapper.UpgradeStubbedShadersAsync(_assetsAssetBundle);
			while (upgradeStubbedShaders.MoveNext())
			{
				yield return upgradeStubbedShaders.Current;
			}
			yield return LoadAllAssetsAsync<UnlockableDef>(assetsAssetBundle, progress, (Action<UnlockableDef[]>)delegate(UnlockableDef[] assets)
			{
				contentPack.unlockableDefs.Add(assets);
			});
			yield return LoadAllAssetsAsync<Sprite>(_assetsAssetBundle, progress, (Action<Sprite[]>)delegate(Sprite[] assets)
			{
				PromenadeSceneDefPreviewSprite = assets.First((Sprite a) => ((Object)a).name == "texAOScenePreview");
				SimuSceneDefPreviewSprite = assets.First((Sprite a) => ((Object)a).name == "texAOScenePreview");
			});
			yield return LoadAllAssetsAsync<SceneDef>(_assetsAssetBundle, progress, (Action<SceneDef[]>)delegate(SceneDef[] assets)
			{
				SceneDefs = assets;
				PromenadeSceneDef = SceneDefs.First((SceneDef sd) => sd.baseSceneNameOverride == "observatory_wormsworms");
				SimuSceneDef = SceneDefs.First((SceneDef sd) => sd.baseSceneNameOverride == "itobservatory_wormsworms");
				Log.Debug(PromenadeSceneDef.nameToken);
				Log.Debug(SimuSceneDef.nameToken);
				contentPack.sceneDefs.Add(assets);
			});
			PromenadeSceneDef.portalMaterial = StageRegistration.MakeBazaarSeerMaterial((Texture2D)PromenadeSceneDef.previewTexture);
			AsyncOperationHandle<MusicTrackDef> mainTrackDefRequest = Addressables.LoadAssetAsync<MusicTrackDef>((object)"RoR2/Base/Common/MusicTrackDefs/muSong14.asset");
			while (!mainTrackDefRequest.IsDone)
			{
				yield return null;
			}
			AsyncOperationHandle<MusicTrackDef> simuTrackDefRequest = Addressables.LoadAssetAsync<MusicTrackDef>((object)"RoR2/Base/Common/MusicTrackDefs/muSong08.asset");
			while (!mainTrackDefRequest.IsDone)
			{
				yield return null;
			}
			AsyncOperationHandle<MusicTrackDef> bossTrackDefRequest = Addressables.LoadAssetAsync<MusicTrackDef>((object)"RoR2/Base/Common/MusicTrackDefs/muSong23.asset");
			while (!bossTrackDefRequest.IsDone)
			{
				yield return null;
			}
			PromenadeSceneDef.mainTrack = mainTrackDefRequest.Result;
			PromenadeSceneDef.bossTrack = bossTrackDefRequest.Result;
			SimuSceneDef.mainTrack = simuTrackDefRequest.Result;
			SimuSceneDef.bossTrack = bossTrackDefRequest.Result;
			if (Promenade.enableRegular.Value)
			{
				StageRegistration.RegisterSceneDefToNormalProgression(PromenadeSceneDef, 1f, true, true);
			}
			if (Promenade.enableSimulacrum.Value && Promenade.stage1Simulacrum.Value)
			{
				Simulacrum.RegisterSceneToSimulacrum(SimuSceneDef);
			}
			else if (Promenade.enableSimulacrum.Value && !Promenade.stage1Simulacrum.Value)
			{
				Simulacrum.RegisterSceneToSimulacrum(SimuSceneDef, canBeStage1: false);
			}
		}

		internal static void Unload()
		{
			_assetsAssetBundle.Unload(true);
			_scenesAssetBundle.Unload(true);
		}

		private static IEnumerator LoadAllAssetsAsync<T>(AssetBundle assetBundle, IProgress<float> progress, Action<T[]> onAssetsLoaded) where T : Object
		{
			AssetBundleRequest sceneDefsRequest = assetBundle.LoadAllAssetsAsync<T>();
			while (!((AsyncOperation)sceneDefsRequest).isDone)
			{
				progress.Report(((AsyncOperation)sceneDefsRequest).progress);
				yield return null;
			}
			onAssetsLoaded(sceneDefsRequest.allAssets.Cast<T>().ToArray());
		}
	}
	public static class Simulacrum
	{
		public static void RegisterSceneToSimulacrum(SceneDef sceneDef, bool canBeStage1 = true, float weight = 1f)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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_0034: 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_003d: 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_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			SceneCollection val = Addressables.LoadAssetAsync<SceneCollection>((object)"RoR2/DLC1/GameModes/InfiniteTowerRun/SceneGroups/sgInfiniteTowerStageX.asset").WaitForCompletion();
			SceneCollection val2 = Addressables.LoadAssetAsync<SceneCollection>((object)"RoR2/DLC1/GameModes/InfiniteTowerRun/SceneGroups/sgInfiniteTowerStage1.asset").WaitForCompletion();
			List<SceneCollection> list = new List<SceneCollection>();
			Enumerator<SceneEntry> enumerator = val.sceneEntries.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					SceneEntry current = enumerator.Current;
					if (current.sceneDef.hasAnyDestinations)
					{
						list.Add(current.sceneDef.destinationsGroup);
					}
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
			SceneCollection val3 = ScriptableObject.CreateInstance<SceneCollection>();
			val3._sceneEntries = val._sceneEntries;
			sceneDef.destinationsGroup = val3;
			SceneEntry val4 = default(SceneEntry);
			val4.sceneDef = sceneDef;
			val4.weightMinusOne = weight - 1f;
			SceneEntry val5 = val4;
			ArrayUtils.ArrayAppend<SceneEntry>(ref val._sceneEntries, ref val5);
			if (canBeStage1)
			{
				ArrayUtils.ArrayAppend<SceneEntry>(ref val2._sceneEntries, ref val5);
			}
			foreach (SceneCollection item in list)
			{
				ArrayUtils.ArrayAppend<SceneEntry>(ref item._sceneEntries, ref val5);
			}
		}
	}
}