Decompiled source of EclipseAllMaps v1.1.1

EclipseAllMaps.dll

Decompiled 6 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates.Missions.Goldshores;
using HG;
using Microsoft.CodeAnalysis;
using On.EntityStates.Missions.Goldshores;
using On.RoR2;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.ConVar;
using RoR2.ExpansionManagement;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;

[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("EclipseAllMaps")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1+866725642bb6c433fa850f2ca45fa6960f78003d")]
[assembly: AssemblyProduct("EclipseAllMaps")]
[assembly: AssemblyTitle("EclipseAllMaps")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 EclipseAllMaps
{
	internal static class AddedMapCredits
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_Start <>9__0_0;

			internal void <Init>b__0_0(orig_Start orig, SceneDirector self)
			{
				if (NetworkServer.active)
				{
					Rebalance();
				}
				orig.Invoke(self);
			}
		}

		internal static void Init()
		{
			//IL_0014: 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_001f: Expected O, but got Unknown
			object obj = <>c.<>9__0_0;
			if (obj == null)
			{
				hook_Start val = delegate(orig_Start orig, SceneDirector self)
				{
					if (NetworkServer.active)
					{
						Rebalance();
					}
					orig.Invoke(self);
				};
				<>c.<>9__0_0 = val;
				obj = (object)val;
			}
			SceneDirector.Start += (hook_Start)obj;
		}

		private static (int interactable, int monster)? MedianCredits(int stage)
		{
			return stage switch
			{
				2 => (280, 100), 
				3 => (280, 100), 
				4 => (400, 230), 
				5 => (545, 230), 
				_ => null, 
			};
		}

		private static void Rebalance()
		{
			AddedMap addedMap = AddedMaps.InPlay();
			ClassicStageInfo val = (Object.op_Implicit((Object)(object)SceneInfo.instance) ? ((Component)SceneInfo.instance).GetComponent<ClassicStageInfo>() : null);
			if (addedMap != null && Object.op_Implicit((Object)(object)val) && ModSettings.BalanceCredits.Value)
			{
				int num = addedMap.StageOf(SceneCatalog.FindSceneDef(addedMap.SceneName));
				(int, int)? tuple = MedianCredits(num);
				if (tuple.HasValue)
				{
					var (num2, num3) = tuple.Value;
					Log.Info($"{SceneCatalog.mostRecentSceneDef.cachedName} as stage {num}: interactable credits {val.sceneDirectorInteractibleCredits} -> {num2}, monster credits {val.sceneDirectorMonsterCredits} -> {num3}.");
					val.sceneDirectorInteractibleCredits = num2;
					val.sceneDirectorMonsterCredits = num3;
				}
			}
		}
	}
	internal static class AddedMapInteractables
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_RebuildCards <>9__3_0;

			public static Func<Category, float> <>9__5_0;

			public static Func<DirectorCard, string> <>9__5_2;

			internal void <Init>b__3_0(orig_RebuildCards orig, ClassicStageInfo self, DirectorCardCategorySelection forcedMonsterCategory, DirectorCardCategorySelection forcedInteractableCategory)
			{
				orig.Invoke(self, forcedMonsterCategory, forcedInteractableCategory);
				if (!Object.op_Implicit((Object)(object)forcedInteractableCategory) && NetworkServer.active && ModSettings.VoidLocusInteractables.Value && !(AddedMaps.InPlay()?.SceneName != "voidstage"))
				{
					DirectorCardCategorySelection val = VoidLocusInteractables(self);
					if (Object.op_Implicit((Object)(object)val))
					{
						self.interactableCategories = val;
					}
				}
			}

			internal float <Describe>b__5_0(Category category)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return category.selectionWeight;
			}

			internal string <Describe>b__5_2(DirectorCard card)
			{
				SpawnCard spawnCard = card.GetSpawnCard();
				if (spawnCard == null)
				{
					return null;
				}
				return ((Object)spawnCard).name.Replace("isc", "");
			}
		}

		private const string VoidLocus = "voidstage";

		private const string SkyMeadowInteractablesAddress = "RoR2/Base/skymeadow/dpSkyMeadowInteractables.asset";

		private const string VoidLocusInteractablesAddress = "RoR2/DLC1/voidstage/dccsVoidStageInteractables.asset";

		internal static void Init()
		{
			//IL_0014: 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_001f: Expected O, but got Unknown
			object obj = <>c.<>9__3_0;
			if (obj == null)
			{
				hook_RebuildCards val = delegate(orig_RebuildCards orig, ClassicStageInfo self, DirectorCardCategorySelection forcedMonsterCategory, DirectorCardCategorySelection forcedInteractableCategory)
				{
					orig.Invoke(self, forcedMonsterCategory, forcedInteractableCategory);
					if (!Object.op_Implicit((Object)(object)forcedInteractableCategory) && NetworkServer.active && ModSettings.VoidLocusInteractables.Value && !(AddedMaps.InPlay()?.SceneName != "voidstage"))
					{
						DirectorCardCategorySelection val2 = VoidLocusInteractables(self);
						if (Object.op_Implicit((Object)(object)val2))
						{
							self.interactableCategories = val2;
						}
					}
				};
				<>c.<>9__3_0 = val;
				obj = (object)val;
			}
			ClassicStageInfo.RebuildCards += (hook_RebuildCards)obj;
		}

		private static DirectorCardCategorySelection VoidLocusInteractables(ClassicStageInfo stageInfo)
		{
			//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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			DccsPool val = Addressables.LoadAssetAsync<DccsPool>((object)"RoR2/Base/skymeadow/dpSkyMeadowInteractables.asset").WaitForCompletion();
			DirectorCardCategorySelection val2 = Addressables.LoadAssetAsync<DirectorCardCategorySelection>((object)"RoR2/DLC1/voidstage/dccsVoidStageInteractables.asset").WaitForCompletion();
			if (!Object.op_Implicit((Object)(object)val) || val.poolCategories.Length == 0 || !Object.op_Implicit((Object)(object)val2))
			{
				Log.Warning("Sky Meadow's or Void Locus's interactable list is missing; Void Locus keeps its own interactables.");
				return null;
			}
			DirectorCardCategorySelection modifiableMonsterCategories = stageInfo.modifiableMonsterCategories;
			object obj;
			if (Object.op_Implicit((Object)(object)modifiableMonsterCategories))
			{
				List<ExpansionDef> expansionsInEffect = modifiableMonsterCategories.expansionsInEffect;
				if (expansionsInEffect != null && expansionsInEffect.Count > 0)
				{
					obj = new List<ExpansionDef>(modifiableMonsterCategories.expansionsInEffect);
					goto IL_0081;
				}
			}
			obj = null;
			goto IL_0081;
			IL_0081:
			List<ExpansionDef> list = (List<ExpansionDef>)obj;
			Xoroshiro128Plus val3 = new Xoroshiro128Plus(stageInfo.seedServer);
			DirectorCardCategorySelection blendedDCCS = DCCSBlender.GetBlendedDCCS(val.poolCategories[0], ref val3, stageInfo, stageInfo.contentInteractableSourceMixLimit, list);
			DirectorCardCategorySelection val4 = DCCSBlender.BlendSpecificDCCS(new List<DirectorCardCategorySelection> { blendedDCCS, val2 });
			Object.Destroy((Object)(object)blendedDCCS);
			Log.Info("Void Locus interactables: " + Describe(val4));
			return val4;
		}

		private static string Describe(DirectorCardCategorySelection interactables)
		{
			float totalWeight = interactables.categories.Sum((Category category) => category.selectionWeight);
			return string.Join("; ", interactables.categories.Select((Category category) => string.Format("{0} {1:P0} ({2})", category.name, category.selectionWeight / totalWeight, string.Join(", ", category.cards.Select(delegate(DirectorCard card)
			{
				SpawnCard spawnCard = card.GetSpawnCard();
				return (spawnCard == null) ? null : ((Object)spawnCard).name.Replace("isc", "");
			})))));
		}
	}
	internal static class AddedMapMonsters
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_RebuildCards <>9__4_0;

			public static Func<Category, bool> <>9__6_0;

			public static Predicate<DirectorCard> <>9__6_1;

			public static Func<DirectorCard, bool> <>9__7_1;

			public static Func<DirectorCard, string> <>9__7_2;

			public static Func<Category, string> <>9__7_0;

			internal void <Init>b__4_0(orig_RebuildCards orig, ClassicStageInfo self, DirectorCardCategorySelection forcedMonsterCategory, DirectorCardCategorySelection forcedInteractableCategory)
			{
				DirectorCardCategorySelection val = ((!Object.op_Implicit((Object)(object)forcedMonsterCategory) && NetworkServer.active && IsFirstLoopVoidLocus()) ? FirstLoopVoidLocusMonsters(self) : null);
				if (!Object.op_Implicit((Object)(object)val))
				{
					orig.Invoke(self, forcedMonsterCategory, forcedInteractableCategory);
					return;
				}
				try
				{
					orig.Invoke(self, val, forcedInteractableCategory);
				}
				finally
				{
					Object.Destroy((Object)(object)val);
				}
			}

			internal bool <FirstLoopVoidLocusMonsters>b__6_0(Category category)
			{
				return category.name == "Standard";
			}

			internal bool <FirstLoopVoidLocusMonsters>b__6_1(DirectorCard card)
			{
				SpawnCard spawnCard = card.GetSpawnCard();
				return ((spawnCard != null) ? ((Object)spawnCard).name : null) != "cscNullifier";
			}

			internal string <Describe>b__7_0(Category category)
			{
				//IL_0000: 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)
				return category.name + ": " + string.Join(", ", from card in category.cards
					where card.IsAvailable()
					select string.Format("{0} x{1}", ((Object)card.GetSpawnCard()).name.Replace("csc", ""), card.selectionWeight));
			}

			internal bool <Describe>b__7_1(DirectorCard card)
			{
				return card.IsAvailable();
			}

			internal string <Describe>b__7_2(DirectorCard card)
			{
				return string.Format("{0} x{1}", ((Object)card.GetSpawnCard()).name.Replace("csc", ""), card.selectionWeight);
			}
		}

		private const string VoidLocus = "voidstage";

		private const int VanillaVoidLocusMinStagesCleared = 6;

		private const string SkyMeadowMonstersAddress = "RoR2/Base/skymeadow/dpSkyMeadowMonsters.asset";

		private static readonly (string category, string address, bool preventOverhead)[] VoidMonsters = new(string, string, bool)[3]
		{
			("Champions", "RoR2/DLC1/VoidMegaCrab/cscVoidMegaCrab.asset", false),
			("Minibosses", "RoR2/Base/Nullifier/cscNullifier.asset", true),
			("Basic Monsters", "RoR2/DLC1/VoidBarnacle/cscVoidBarnacle.asset", true)
		};

		internal static void Init()
		{
			//IL_0014: 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_001f: Expected O, but got Unknown
			object obj = <>c.<>9__4_0;
			if (obj == null)
			{
				hook_RebuildCards val = delegate(orig_RebuildCards orig, ClassicStageInfo self, DirectorCardCategorySelection forcedMonsterCategory, DirectorCardCategorySelection forcedInteractableCategory)
				{
					DirectorCardCategorySelection val2 = ((!Object.op_Implicit((Object)(object)forcedMonsterCategory) && NetworkServer.active && IsFirstLoopVoidLocus()) ? FirstLoopVoidLocusMonsters(self) : null);
					if (!Object.op_Implicit((Object)(object)val2))
					{
						orig.Invoke(self, forcedMonsterCategory, forcedInteractableCategory);
						return;
					}
					try
					{
						orig.Invoke(self, val2, forcedInteractableCategory);
					}
					finally
					{
						Object.Destroy((Object)(object)val2);
					}
				};
				<>c.<>9__4_0 = val;
				obj = (object)val;
			}
			ClassicStageInfo.RebuildCards += (hook_RebuildCards)obj;
		}

		private static bool IsFirstLoopVoidLocus()
		{
			if (AddedMaps.InPlay() != null && SceneCatalog.mostRecentSceneDef.cachedName == "voidstage" && Run.instance.stageClearCount < 6)
			{
				return ModSettings.VoidLocusMonsters.Value;
			}
			return false;
		}

		private static DirectorCardCategorySelection FirstLoopVoidLocusMonsters(ClassicStageInfo stageInfo)
		{
			//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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			//IL_00e2: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Expected O, but got Unknown
			DccsPool val = Addressables.LoadAssetAsync<DccsPool>((object)"RoR2/Base/skymeadow/dpSkyMeadowMonsters.asset").WaitForCompletion();
			Category val2 = (Object.op_Implicit((Object)(object)val) ? ((IEnumerable<Category>)val.poolCategories).FirstOrDefault((Func<Category, bool>)((Category category) => category.name == "Standard")) : null);
			if (val2 == null)
			{
				Log.Warning("RoR2/Base/skymeadow/dpSkyMeadowMonsters.asset has no Standard category; Void Locus keeps its own monsters.");
				return null;
			}
			Xoroshiro128Plus val3 = new Xoroshiro128Plus(stageInfo.seedServer);
			DirectorCardCategorySelection blendedDCCS = DCCSBlender.GetBlendedDCCS(val2, ref val3, stageInfo, stageInfo.contentSourceMixLimit, (List<ExpansionDef>)null);
			blendedDCCS.RemoveCardsThatFailFilter((Predicate<DirectorCard>)delegate(DirectorCard card)
			{
				SpawnCard spawnCard = card.GetSpawnCard();
				return ((spawnCard != null) ? ((Object)spawnCard).name : null) != "cscNullifier";
			});
			(string, string, bool)[] voidMonsters = VoidMonsters;
			for (int num = 0; num < voidMonsters.Length; num++)
			{
				(string, string, bool) tuple = voidMonsters[num];
				string item = tuple.Item1;
				string item2 = tuple.Item2;
				bool item3 = tuple.Item3;
				int num2 = blendedDCCS.FindCategoryIndexByName(item);
				if (num2 >= 0)
				{
					float num3 = blendedDCCS.SumAllWeightsInCategory(blendedDCCS.categories[num2]);
					blendedDCCS.AddCard(num2, new DirectorCard
					{
						spawnCard = Addressables.LoadAssetAsync<SpawnCard>((object)item2).WaitForCompletion(),
						selectionWeight = Mathf.Max(1, Mathf.RoundToInt(num3)),
						preventOverhead = item3
					});
				}
			}
			Log.Info("Void Locus monsters (first loop): " + Describe(blendedDCCS));
			return blendedDCCS;
		}

		private static string Describe(DirectorCardCategorySelection monsters)
		{
			return string.Join("; ", monsters.categories.Select((Category category) => category.name + ": " + string.Join(", ", from card in category.cards
				where card.IsAvailable()
				select string.Format("{0} x{1}", ((Object)card.GetSpawnCard()).name.Replace("csc", ""), card.selectionWeight))));
		}
	}
	internal static class AddedMapProgression
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_Start <>9__5_0;

			public static hook_Start <>9__5_1;

			public static hook_PickNextStageSceneFromCurrentSceneDestinations <>9__5_2;

			public static hook_Start <>9__5_3;

			internal void <Init>b__5_0(orig_Start orig, VoidStageMissionController self)
			{
				if (NetworkServer.active && VoidLocusGetsTeleporter())
				{
					self.batteryCount = 0;
				}
				orig.Invoke(self);
			}

			internal void <Init>b__5_1(orig_Start orig, SceneDirector self)
			{
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				if (NetworkServer.active && VoidLocusGetsTeleporter())
				{
					if (primordialTeleporter == null)
					{
						primordialTeleporter = Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/Base/Teleporters/iscLunarTeleporter.asset").WaitForCompletion();
					}
					self.teleporterSpawnCard = primordialTeleporter;
					Log.Info("Void Locus: no Deep Void Signals; placing a Primordial Teleporter.");
				}
				orig.Invoke(self);
			}

			internal void <Init>b__5_2(orig_PickNextStageSceneFromCurrentSceneDestinations orig, Run self)
			{
				if (!VoidLocusGetsTeleporter())
				{
					orig.Invoke(self);
					return;
				}
				WeightedSelection<SceneDef> val = new WeightedSelection<SceneDef>(8);
				SceneCatalog.FindSceneDef("skymeadow").AddDestinationsToWeightedSelection(val, (Func<SceneDef, bool>)self.CanPickStage);
				self.PickNextStageScene(val);
			}

			internal void <Init>b__5_3(orig_Start orig, TeleporterInteraction self)
			{
				orig.Invoke(self);
				if (NetworkServer.active && ModSettings.ConduitCanyonToStage5.Value && IsChanged("conduitcanyon"))
				{
					self.sceneExitController.useRunNextStageScene = true;
					SceneDef nextStageScene = Run.instance.nextStageScene;
					Log.Info("Conduit Canyon: the teleporter leads to " + ((nextStageScene != null) ? nextStageScene.cachedName : null) + " instead of the Alloyed path.");
				}
			}
		}

		private const string VoidLocus = "voidstage";

		private const string ConduitCanyon = "conduitcanyon";

		private const string VoidLocusLeadsOnLike = "skymeadow";

		private const string PrimordialTeleporterAddress = "RoR2/Base/Teleporters/iscLunarTeleporter.asset";

		private static SpawnCard primordialTeleporter;

		internal static void Init()
		{
			//IL_0014: 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_001f: Expected O, but got Unknown
			//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: Expected O, but got Unknown
			//IL_005c: 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_0067: Expected O, but got Unknown
			//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_008b: Expected O, but got Unknown
			object obj = <>c.<>9__5_0;
			if (obj == null)
			{
				hook_Start val = delegate(orig_Start orig, VoidStageMissionController self)
				{
					if (NetworkServer.active && VoidLocusGetsTeleporter())
					{
						self.batteryCount = 0;
					}
					orig.Invoke(self);
				};
				<>c.<>9__5_0 = val;
				obj = (object)val;
			}
			VoidStageMissionController.Start += (hook_Start)obj;
			object obj2 = <>c.<>9__5_1;
			if (obj2 == null)
			{
				hook_Start val2 = delegate(orig_Start orig, SceneDirector self)
				{
					//IL_001a: Unknown result type (might be due to invalid IL or missing references)
					//IL_001f: Unknown result type (might be due to invalid IL or missing references)
					if (NetworkServer.active && VoidLocusGetsTeleporter())
					{
						if (primordialTeleporter == null)
						{
							primordialTeleporter = Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/Base/Teleporters/iscLunarTeleporter.asset").WaitForCompletion();
						}
						self.teleporterSpawnCard = primordialTeleporter;
						Log.Info("Void Locus: no Deep Void Signals; placing a Primordial Teleporter.");
					}
					orig.Invoke(self);
				};
				<>c.<>9__5_1 = val2;
				obj2 = (object)val2;
			}
			SceneDirector.Start += (hook_Start)obj2;
			object obj3 = <>c.<>9__5_2;
			if (obj3 == null)
			{
				hook_PickNextStageSceneFromCurrentSceneDestinations val3 = delegate(orig_PickNextStageSceneFromCurrentSceneDestinations orig, Run self)
				{
					if (!VoidLocusGetsTeleporter())
					{
						orig.Invoke(self);
					}
					else
					{
						WeightedSelection<SceneDef> val5 = new WeightedSelection<SceneDef>(8);
						SceneCatalog.FindSceneDef("skymeadow").AddDestinationsToWeightedSelection(val5, (Func<SceneDef, bool>)self.CanPickStage);
						self.PickNextStageScene(val5);
					}
				};
				<>c.<>9__5_2 = val3;
				obj3 = (object)val3;
			}
			Run.PickNextStageSceneFromCurrentSceneDestinations += (hook_PickNextStageSceneFromCurrentSceneDestinations)obj3;
			object obj4 = <>c.<>9__5_3;
			if (obj4 == null)
			{
				hook_Start val4 = delegate(orig_Start orig, TeleporterInteraction self)
				{
					orig.Invoke(self);
					if (NetworkServer.active && ModSettings.ConduitCanyonToStage5.Value && IsChanged("conduitcanyon"))
					{
						self.sceneExitController.useRunNextStageScene = true;
						SceneDef nextStageScene = Run.instance.nextStageScene;
						Log.Info("Conduit Canyon: the teleporter leads to " + ((nextStageScene != null) ? nextStageScene.cachedName : null) + " instead of the Alloyed path.");
					}
				};
				<>c.<>9__5_3 = val4;
				obj4 = (object)val4;
			}
			TeleporterInteraction.Start += (hook_Start)obj4;
		}

		private static bool IsChanged(string sceneName)
		{
			if (AddedMaps.InPlay() != null)
			{
				return SceneCatalog.mostRecentSceneDef.cachedName == sceneName;
			}
			return false;
		}

		private static bool VoidLocusGetsTeleporter()
		{
			if (ModSettings.VoidLocusTeleporter.Value)
			{
				return IsChanged("voidstage");
			}
			return false;
		}
	}
	internal static class AddedMaps
	{
		internal static readonly AddedMap[] All = new AddedMap[4]
		{
			new AddedMap("lemuriantemple"),
			new AddedMap("habitat"),
			new AddedMap("conduitcanyon"),
			new AddedMap("voidstage", 5)
		};

		internal static AddedMap Of(SceneDef scene)
		{
			if (!Object.op_Implicit((Object)(object)scene))
			{
				return null;
			}
			AddedMap[] all = All;
			foreach (AddedMap addedMap in all)
			{
				SceneDef val = SceneCatalog.FindSceneDef(addedMap.SceneName);
				if (Object.op_Implicit((Object)(object)val) && ((Object)(object)scene == (Object)(object)val || (Object)(object)scene == (Object)(object)val.loopedSceneDef))
				{
					return addedMap;
				}
			}
			return null;
		}

		internal static AddedMap InPlay()
		{
			AddedMap addedMap = Of(SceneCatalog.mostRecentSceneDef);
			if (addedMap == null || !addedMap.Enabled || !EclipseStagePool.IsActive(Run.instance))
			{
				return null;
			}
			return addedMap;
		}
	}
	internal sealed class AddedMap
	{
		internal readonly string SceneName;

		private readonly int? stage;

		internal bool Enabled => StageMaps.IsEnabled(SceneName);

		internal AddedMap(string sceneName, int? stage = null)
		{
			SceneName = sceneName;
			this.stage = stage;
		}

		internal int StageOf(SceneDef sceneDef)
		{
			return stage ?? sceneDef.stageOrder;
		}
	}
	internal static class AlternatePathPortals
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_Start <>9__11_0;

			public static hook_IsValidStormTier <>9__11_1;

			public static hook_OnWillSpawnUpdated <>9__11_2;

			public static hook_Pet <>9__11_3;

			internal void <Init>b__11_0(orig_Start orig, PortalSpawner self)
			{
				if (NetworkServer.active && Object.op_Implicit((Object)(object)self.portalSpawnCard) && ((Object)self.portalSpawnCard).name == "iscColossusPortal" && ModSettings.NoColossusPortals.Value && IsClosedColossusPortal(self, out var source))
				{
					self.spawnChance = -1f;
					Log.Info(SceneCatalog.mostRecentSceneDef.cachedName + ": no green Colossus portal from the " + source + ".");
				}
				orig.Invoke(self);
			}

			internal bool <Init>b__11_1(orig_IsValidStormTier orig, Exit self)
			{
				if (ModSettings.NoColossusPortals.Value && EclipseStagePool.IsActive(Run.instance))
				{
					Log.Info("Gilded Coast: no green Colossus portal.");
					return false;
				}
				return orig.Invoke(self);
			}

			internal void <Init>b__11_2(orig_OnWillSpawnUpdated orig, PortalSpawner self, bool newValue)
			{
				if (newValue && NetworkServer.active && IsClosedAlloyedPortal(self))
				{
					newValue = false;
					Log.Info(SceneCatalog.mostRecentSceneDef.cachedName + ": no portal down the Alloyed path (" + ((Object)self.PortalSpawnCard).name + ").");
				}
				orig.Invoke(self, newValue);
			}

			internal void <Init>b__11_3(orig_Pet orig, FrogController self, Interactor interactor)
			{
				//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_0041: 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)
				orig.Invoke(self, interactor);
				if (NetworkServer.active && self.petCount == self.maxPets && EclipseStagePool.IsActive(Run.instance))
				{
					Vector3 position = ((Component)self).transform.position;
					if (ModSettings.FrogPortalToPrimeMeridian.Value)
					{
						OpenPrimeMeridianPortal(position);
					}
					if (ModSettings.FrogPortalToNeuralSanctum.Value)
					{
						OpenNeuralSanctumPortal(position);
					}
				}
			}
		}

		private const string PrimeMeridian = "meridian";

		private const string NeuralSanctum = "solusweb";

		private const string ConduitCanyon = "conduitcanyon";

		private const string ColossusPortalCard = "iscColossusPortal";

		private const string ColossusPortalAddress = "RoR2/DLC2/iscColossusPortal.asset";

		private const string SolutionalHauntPortalCard = "iscHardwareProgPortal_Haunt";

		private const string ConduitCanyonPortalCard = "iscHardwareProgPortal";

		private const string NeuralSanctumPortalAddress = "RoR2/DLC3/SolusWebPortal.prefab";

		private const string FalseSonBeatenFlag = "FalseSonBossComplete";

		private const string SolusHeartBeatenFlag = "SolusHeartBeaten";

		private static InteractableSpawnCard neuralSanctumPortalCard;

		internal static void Init()
		{
			//IL_0014: 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_001f: Expected O, but got Unknown
			//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: Expected O, but got Unknown
			//IL_005c: 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_0067: Expected O, but got Unknown
			//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_008b: Expected O, but got Unknown
			object obj = <>c.<>9__11_0;
			if (obj == null)
			{
				hook_Start val = delegate(orig_Start orig, PortalSpawner self)
				{
					if (NetworkServer.active && Object.op_Implicit((Object)(object)self.portalSpawnCard) && ((Object)self.portalSpawnCard).name == "iscColossusPortal" && ModSettings.NoColossusPortals.Value && IsClosedColossusPortal(self, out var source))
					{
						self.spawnChance = -1f;
						Log.Info(SceneCatalog.mostRecentSceneDef.cachedName + ": no green Colossus portal from the " + source + ".");
					}
					orig.Invoke(self);
				};
				<>c.<>9__11_0 = val;
				obj = (object)val;
			}
			PortalSpawner.Start += (hook_Start)obj;
			object obj2 = <>c.<>9__11_1;
			if (obj2 == null)
			{
				hook_IsValidStormTier val2 = delegate(orig_IsValidStormTier orig, Exit self)
				{
					if (ModSettings.NoColossusPortals.Value && EclipseStagePool.IsActive(Run.instance))
					{
						Log.Info("Gilded Coast: no green Colossus portal.");
						return false;
					}
					return orig.Invoke(self);
				};
				<>c.<>9__11_1 = val2;
				obj2 = (object)val2;
			}
			Exit.IsValidStormTier += (hook_IsValidStormTier)obj2;
			object obj3 = <>c.<>9__11_2;
			if (obj3 == null)
			{
				hook_OnWillSpawnUpdated val3 = delegate(orig_OnWillSpawnUpdated orig, PortalSpawner self, bool newValue)
				{
					if (newValue && NetworkServer.active && IsClosedAlloyedPortal(self))
					{
						newValue = false;
						Log.Info(SceneCatalog.mostRecentSceneDef.cachedName + ": no portal down the Alloyed path (" + ((Object)self.PortalSpawnCard).name + ").");
					}
					orig.Invoke(self, newValue);
				};
				<>c.<>9__11_2 = val3;
				obj3 = (object)val3;
			}
			PortalSpawner.OnWillSpawnUpdated += (hook_OnWillSpawnUpdated)obj3;
			object obj4 = <>c.<>9__11_3;
			if (obj4 == null)
			{
				hook_Pet val4 = delegate(orig_Pet orig, FrogController self, Interactor interactor)
				{
					//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_0041: 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)
					orig.Invoke(self, interactor);
					if (NetworkServer.active && self.petCount == self.maxPets && EclipseStagePool.IsActive(Run.instance))
					{
						Vector3 position = ((Component)self).transform.position;
						if (ModSettings.FrogPortalToPrimeMeridian.Value)
						{
							OpenPrimeMeridianPortal(position);
						}
						if (ModSettings.FrogPortalToNeuralSanctum.Value)
						{
							OpenNeuralSanctumPortal(position);
						}
					}
				};
				<>c.<>9__11_3 = val4;
				obj4 = (object)val4;
			}
			FrogController.Pet += (hook_Pet)obj4;
		}

		private static bool IsClosedColossusPortal(PortalSpawner spawner, out string source)
		{
			if (Object.op_Implicit((Object)(object)((Component)spawner).GetComponentInParent<TeleporterInteraction>()))
			{
				source = "teleporter";
				return AddedMaps.InPlay() != null;
			}
			source = (Object.op_Implicit((Object)(object)((Component)spawner).GetComponentInParent<HalcyoniteShrineInteractable>()) ? "Halcyon Shrine" : ((Object)spawner).name);
			return EclipseStagePool.IsActive(Run.instance);
		}

		private static bool IsClosedAlloyedPortal(PortalSpawner spawner)
		{
			if (!ModSettings.NoSolutionalHauntPortals.Value || !Object.op_Implicit((Object)(object)spawner.PortalSpawnCard) || !EclipseStagePool.IsActive(Run.instance))
			{
				return false;
			}
			string name = ((Object)spawner.PortalSpawnCard).name;
			if (!(name == "iscHardwareProgPortal_Haunt"))
			{
				if (name == "iscHardwareProgPortal")
				{
					return !StageMaps.IsEnabled("conduitcanyon");
				}
				return false;
			}
			return true;
		}

		private static void OpenPrimeMeridianPortal(Vector3 position)
		{
			//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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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)
			//IL_0091: Expected O, but got Unknown
			Run instance = Run.instance;
			SceneDef val = SceneCatalog.FindSceneDef("meridian");
			if (!Object.op_Implicit((Object)(object)val) || !instance.CanPickStage(val) || instance.GetEventFlag("FalseSonBossComplete"))
			{
				return;
			}
			GameObject val2 = SpawnPortal(Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/DLC2/iscColossusPortal.asset").WaitForCompletion(), position);
			if (!Object.op_Implicit((Object)(object)val2))
			{
				Log.Warning("Could not place the portal to Prime Meridian.");
				return;
			}
			SceneExitController val3 = default(SceneExitController);
			if (val2.TryGetComponent<SceneExitController>(ref val3))
			{
				val3.isAlternatePath = false;
				val3.useRunNextStageScene = false;
				val3.destinationScene = val;
			}
			Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
			{
				baseToken = "PORTAL_STORM_OPEN"
			});
			Log.Info("Commencement: the frog opened a portal to Prime Meridian.");
		}

		private static void OpenNeuralSanctumPortal(Vector3 position)
		{
			//IL_00a9: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Expected O, but got Unknown
			Run instance = Run.instance;
			SceneDef val = SceneCatalog.FindSceneDef("solusweb");
			if (!Object.op_Implicit((Object)(object)val) || !instance.CanPickStage(val) || instance.GetEventFlag("SolusHeartBeaten"))
			{
				return;
			}
			if (!Object.op_Implicit((Object)(object)neuralSanctumPortalCard))
			{
				InteractableSpawnCard val2 = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)"RoR2/DLC2/iscColossusPortal.asset").WaitForCompletion();
				GameObject val3 = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC3/SolusWebPortal.prefab").WaitForCompletion();
				if (!Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)val3))
				{
					Log.Warning("The portal to Neural Sanctum is missing.");
					return;
				}
				neuralSanctumPortalCard = Object.Instantiate<InteractableSpawnCard>(val2);
				((Object)neuralSanctumPortalCard).name = "iscNeuralSanctumPortal";
				((SpawnCard)neuralSanctumPortalCard).prefab = val3;
			}
			if (!Object.op_Implicit((Object)(object)SpawnPortal((SpawnCard)(object)neuralSanctumPortalCard, position)))
			{
				Log.Warning("Could not place the portal to Neural Sanctum.");
				return;
			}
			Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
			{
				baseToken = "PORTAL_SOLUSSHOP_OPEN"
			});
			Log.Info("Commencement: the frog opened a portal to Neural Sanctum.");
		}

		private static GameObject SpawnPortal(SpawnCard portalCard, Vector3 position)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: 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_0021: 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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)portalCard))
			{
				return null;
			}
			DirectorPlacementRule val = new DirectorPlacementRule
			{
				placementMode = (PlacementMode)1,
				minDistance = 10f,
				maxDistance = 40f,
				position = position
			};
			return DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest(portalCard, val, new Xoroshiro128Plus(Run.instance.stageRng.nextUlong)));
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("chen-ror2.EclipseAllMaps", "EclipseAllMaps", "1.1.1")]
	public class EclipseAllMapsPlugin : BaseUnityPlugin
	{
		public const string PluginAuthor = "chen-ror2";

		public const string PluginName = "EclipseAllMaps";

		public const string PluginGuid = "chen-ror2.EclipseAllMaps";

		public const string PluginVersion = "1.1.1";

		public void Awake()
		{
			Log.Init(((BaseUnityPlugin)this).Logger);
			ModSettings.Bind(((BaseUnityPlugin)this).Config);
			EclipseStagePool.Init();
			AddedMapCredits.Init();
			AddedMapProgression.Init();
			AddedMapMonsters.Init();
			AddedMapInteractables.Init();
			AlternatePathPortals.Init();
			TeleporterBosses.Init();
			HalcyonShrines.Init();
			if (RiskOfOptionsCompat.IsInstalled)
			{
				RiskOfOptionsCompat.AddOptions(ModSettings.Menu);
			}
			Log.Info("EclipseAllMaps 1.1.1 ready.");
		}
	}
	internal static class EclipseStagePool
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Action <0>__LogAddedMaps;

			public static Predicate<SceneDef> <1>__IsEnabled;
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_PickNextStageScene <>9__2_0;

			public static hook_SetUpSeerStations <>9__2_1;

			public static Func<(SceneDef map, float weight), float> <>9__4_0;

			internal void <Init>b__2_0(orig_PickNextStageScene orig, Run self, WeightedSelection<SceneDef> choices)
			{
				if (IsActive(self))
				{
					ApplyMapSettings(self, choices);
				}
				orig.Invoke(self, choices);
			}

			internal void <Init>b__2_1(orig_SetUpSeerStations orig, BazaarController self)
			{
				Run instance = Run.instance;
				if (!ModSettings.AppliesTo(instance))
				{
					orig.Invoke(self);
					return;
				}
				List<Action> list = new List<Action>();
				try
				{
					RefileStageOrders(instance, list);
					if (IsActive(instance))
					{
						FilterLeftOutMapsOutOfBazaar(instance, self, list);
					}
					orig.Invoke(self);
				}
				finally
				{
					for (int num = list.Count - 1; num >= 0; num--)
					{
						list[num]();
					}
				}
			}

			internal float <ApplyMapSettings>b__4_0((SceneDef map, float weight) entry)
			{
				return entry.weight;
			}
		}

		private static float AddedMapWeight => ModSettings.AddedMapChance.Value;

		internal static void Init()
		{
			//IL_0014: 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_001f: Expected O, but got Unknown
			//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: Expected O, but got Unknown
			object obj = <>c.<>9__2_0;
			if (obj == null)
			{
				hook_PickNextStageScene val = delegate(orig_PickNextStageScene orig, Run self, WeightedSelection<SceneDef> choices)
				{
					if (IsActive(self))
					{
						ApplyMapSettings(self, choices);
					}
					orig.Invoke(self, choices);
				};
				<>c.<>9__2_0 = val;
				obj = (object)val;
			}
			Run.PickNextStageScene += (hook_PickNextStageScene)obj;
			object obj2 = <>c.<>9__2_1;
			if (obj2 == null)
			{
				hook_SetUpSeerStations val2 = delegate(orig_SetUpSeerStations orig, BazaarController self)
				{
					Run instance = Run.instance;
					if (!ModSettings.AppliesTo(instance))
					{
						orig.Invoke(self);
						return;
					}
					List<Action> list = new List<Action>();
					try
					{
						RefileStageOrders(instance, list);
						if (IsActive(instance))
						{
							FilterLeftOutMapsOutOfBazaar(instance, self, list);
						}
						orig.Invoke(self);
					}
					finally
					{
						for (int num = list.Count - 1; num >= 0; num--)
						{
							list[num]();
						}
					}
				};
				<>c.<>9__2_1 = val2;
				obj2 = (object)val2;
			}
			BazaarController.SetUpSeerStations += (hook_SetUpSeerStations)obj2;
			((ResourceAvailability)(ref SceneCatalog.availability)).CallWhenAvailable((Action)LogAddedMaps);
		}

		internal static bool IsActive(Run run)
		{
			if (ModSettings.AppliesTo(run))
			{
				return ModSettings.AddAllMaps.Value;
			}
			return false;
		}

		private static void ApplyMapSettings(Run run, WeightedSelection<SceneDef> choices)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			if ((int)run.ruleBook.stageOrder != 0 || choices.Count == 0)
			{
				return;
			}
			if (!Object.op_Implicit((Object)(object)run.nextStageScene))
			{
				Console instance = Console.instance;
				object value;
				if (instance == null)
				{
					value = null;
				}
				else
				{
					BaseConVar obj = instance.FindConVar("run_scene_override");
					value = ((obj != null) ? obj.GetString() : null);
				}
				if (!string.IsNullOrEmpty((string?)value))
				{
					return;
				}
			}
			int stageOrder = choices.GetChoice(0).value.stageOrder;
			List<SceneDef> list = MapsForStage(run, stageOrder);
			Predicate<SceneDef> predicate = PoolFilter(list);
			List<(SceneDef, float)> list2 = new List<(SceneDef, float)>();
			for (int i = 0; i < choices.Count; i++)
			{
				ChoiceInfo<SceneDef> choice = choices.GetChoice(i);
				if (predicate(choice.value))
				{
					list2.Add((choice.value, choice.weight));
				}
			}
			foreach (SceneDef map in list)
			{
				if (!list2.Exists(((SceneDef map, float weight) entry) => (Object)(object)entry.map == (Object)(object)map))
				{
					list2.Add((map, AddedMapWeight));
				}
			}
			if (list2.Sum<(SceneDef, float)>(((SceneDef map, float weight) entry) => entry.weight) <= 0f)
			{
				Log.Warning($"Every map that could roll on stage {stageOrder} is switched off, so it keeps its usual maps.");
				return;
			}
			choices.Clear();
			foreach (var (val, num) in list2)
			{
				choices.AddChoice(val, num);
			}
			Log.Info(string.Format("Stage {0} pool{1}: {2}", stageOrder, (ModSettings.OnlyAddedMaps.Value && list.Count > 0) ? " (only added maps)" : "", Describe(choices)));
		}

		private static Predicate<SceneDef> PoolFilter(List<SceneDef> addedMaps)
		{
			object obj;
			if (!ModSettings.OnlyAddedMaps.Value || addedMaps.Count <= 0)
			{
				obj = <>O.<1>__IsEnabled;
				if (obj == null)
				{
					return <>O.<1>__IsEnabled = StageMaps.IsEnabled;
				}
			}
			else
			{
				obj = new Predicate<SceneDef>(addedMaps.Contains);
			}
			return (Predicate<SceneDef>)obj;
		}

		private static List<SceneDef> MapsForStage(Run run, int stage)
		{
			List<SceneDef> list = new List<SceneDef>();
			AddedMap[] all = AddedMaps.All;
			foreach (AddedMap addedMap in all)
			{
				if (!addedMap.Enabled)
				{
					continue;
				}
				SceneDef val = SceneCatalog.FindSceneDef(addedMap.SceneName);
				if (Object.op_Implicit((Object)(object)val) && addedMap.StageOf(val) == stage)
				{
					val = LoopedVariant(run, val);
					if (run.CanPickStage(val))
					{
						list.Add(val);
					}
				}
			}
			return list;
		}

		private static SceneDef LoopedVariant(Run run, SceneDef sceneDef)
		{
			SceneDef loopedSceneDef = sceneDef.loopedSceneDef;
			if (run.loopClearCount <= 0 || run.stageClearCount <= 5 || !Object.op_Implicit((Object)(object)loopedSceneDef))
			{
				return sceneDef;
			}
			return loopedSceneDef;
		}

		private static void RefileStageOrders(Run run, List<Action> undo)
		{
			AddedMap[] all = AddedMaps.All;
			foreach (AddedMap addedMap in all)
			{
				SceneDef sceneDef = SceneCatalog.FindSceneDef(addedMap.SceneName);
				if (!Object.op_Implicit((Object)(object)sceneDef) || ((!ModSettings.AddAllMaps.Value || !addedMap.Enabled) && (Object)(object)sceneDef != (Object)(object)run.nextStageScene))
				{
					continue;
				}
				int num = addedMap.StageOf(sceneDef);
				int stageOrder = sceneDef.stageOrder;
				if (num != stageOrder)
				{
					sceneDef.stageOrder = num;
					undo.Add(delegate
					{
						sceneDef.stageOrder = stageOrder;
					});
				}
			}
		}

		private static void FilterLeftOutMapsOutOfBazaar(Run run, BazaarController bazaar, List<Action> undo)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)run.nextStageScene))
			{
				return;
			}
			int stageOrder = run.nextStageScene.stageOrder;
			Predicate<SceneDef> canRoll = PoolFilter(MapsForStage(run, stageOrder));
			List<string> list = new List<string>();
			Enumerator<SceneDef> enumerator = SceneCatalog.allSceneDefs.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					SceneDef sceneDef = enumerator.Current;
					if (sceneDef.stageOrder == stageOrder && !sceneDef.filterOutOfBazaar && !canRoll(sceneDef))
					{
						sceneDef.filterOutOfBazaar = true;
						undo.Add(delegate
						{
							sceneDef.filterOutOfBazaar = false;
						});
						list.Add(sceneDef.cachedName);
					}
				}
			}
			finally
			{
				((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
			}
			SeerSceneOverride[] overrides = bazaar.seerSceneOverrides;
			bazaar.seerSceneOverrides = Array.FindAll(overrides, (SeerSceneOverride seerOverride) => canRoll(seerOverride.sceneDef));
			undo.Add(delegate
			{
				bazaar.seerSceneOverrides = overrides;
			});
			if (list.Count > 0)
			{
				Log.Info(string.Format("Bazaar seers for stage {0} leave out: {1}", stageOrder, string.Join(", ", list)));
			}
		}

		private static string Describe(WeightedSelection<SceneDef> choices)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: 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)
			float totalWeight = choices.GetTotalWeight();
			StringBuilder stringBuilder = new StringBuilder();
			for (int i = 0; i < choices.Count; i++)
			{
				ChoiceInfo<SceneDef> choice = choices.GetChoice(i);
				if (i > 0)
				{
					stringBuilder.Append(", ");
				}
				stringBuilder.Append(choice.value.cachedName).Append(' ').Append((choice.weight / totalWeight).ToString("P0"));
			}
			return stringBuilder.ToString();
		}

		private static void LogAddedMaps()
		{
			AddedMap[] all = AddedMaps.All;
			foreach (AddedMap addedMap in all)
			{
				SceneDef val = SceneCatalog.FindSceneDef(addedMap.SceneName);
				if (!Object.op_Implicit((Object)(object)val))
				{
					Log.Warning("This game build has no '" + addedMap.SceneName + "' scene; it will not be added to Eclipse.");
				}
				else
				{
					Log.Info($"{Language.GetString(val.nameToken)} ({val.cachedName}) joins Eclipse stage {addedMap.StageOf(val)}.");
				}
			}
		}
	}
	internal static class HalcyonShrines
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_Awake <>9__7_0;

			public static hook_HalcyoniteShrineActivation <>9__7_1;

			public static Func<Category, bool> <>9__7_3;

			public static Action<SceneDirector, DirectorCardCategorySelection> <>9__7_2;

			internal void <Init>b__7_0(orig_Awake orig, HalcyoniteShrineInteractable self)
			{
				orig.Invoke(self);
				if (NetworkServer.active && IsWeakened())
				{
					self.monsterCredit *= 0.5f;
				}
			}

			internal void <Init>b__7_1(orig_HalcyoniteShrineActivation orig, CombatDirector self, float monsterCredit, DirectorCard chosenDirectorCard, int difficultyLevel, Transform shrineTransform)
			{
				if (IsWeakened())
				{
					int num = Mathf.Min(difficultyLevel, 15) / 2;
					Log.Info($"Halcyon Shrine: Halcyonite gold bonus {difficultyLevel} -> {num}.");
					difficultyLevel = num;
				}
				orig.Invoke(self, monsterCredit, chosenDirectorCard, difficultyLevel, shrineTransform);
			}

			internal void <Init>b__7_2(SceneDirector sceneDirector, DirectorCardCategorySelection interactables)
			{
				if (!ModSettings.HalcyonShrineEveryStage.Value || !EclipseStagePool.IsActive(Run.instance))
				{
					return;
				}
				int num = CurrentStage();
				if (num < 1 || num > 5 || interactables.categories.Any((Category category) => category.cards.Any(IsHalcyonShrine)))
				{
					return;
				}
				bool flag = num == 1;
				DirectorCard val = (flag ? (tier1Shrine ?? (tier1Shrine = NewCard("RoR2/DLC2/iscShrineHalcyoniteTier1.asset", 7))) : (shrine ?? (shrine = NewCard("RoR2/DLC2/iscShrineHalcyonite.asset", 1))));
				if (val.IsAvailable())
				{
					int num2 = interactables.FindCategoryIndexByName("Storm Stuff");
					if (num2 < 0)
					{
						num2 = interactables.AddCategory("Storm Stuff", flag ? 3f : 1.5f);
					}
					interactables.AddCard(num2, val);
					Log.Info(SceneCatalog.mostRecentSceneDef.cachedName + ": a Halcyon Shrine can spawn.");
				}
			}

			internal bool <Init>b__7_3(Category category)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return category.cards.Any(IsHalcyonShrine);
			}
		}

		private const string Tier1ShrineAddress = "RoR2/DLC2/iscShrineHalcyoniteTier1.asset";

		private const string ShrineAddress = "RoR2/DLC2/iscShrineHalcyonite.asset";

		private const string CategoryName = "Storm Stuff";

		private const int Stage4ClearCount = 3;

		private const int MaxGoldLevel = 15;

		private static DirectorCard tier1Shrine;

		private static DirectorCard shrine;

		internal static void Init()
		{
			//IL_0014: 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_001f: Expected O, but got Unknown
			//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: Expected O, but got Unknown
			object obj = <>c.<>9__7_0;
			if (obj == null)
			{
				hook_Awake val = delegate(orig_Awake orig, HalcyoniteShrineInteractable self)
				{
					orig.Invoke(self);
					if (NetworkServer.active && IsWeakened())
					{
						self.monsterCredit *= 0.5f;
					}
				};
				<>c.<>9__7_0 = val;
				obj = (object)val;
			}
			HalcyoniteShrineInteractable.Awake += (hook_Awake)obj;
			object obj2 = <>c.<>9__7_1;
			if (obj2 == null)
			{
				hook_HalcyoniteShrineActivation val2 = delegate(orig_HalcyoniteShrineActivation orig, CombatDirector self, float monsterCredit, DirectorCard chosenDirectorCard, int difficultyLevel, Transform shrineTransform)
				{
					if (IsWeakened())
					{
						int num = Mathf.Min(difficultyLevel, 15) / 2;
						Log.Info($"Halcyon Shrine: Halcyonite gold bonus {difficultyLevel} -> {num}.");
						difficultyLevel = num;
					}
					orig.Invoke(self, monsterCredit, chosenDirectorCard, difficultyLevel, shrineTransform);
				};
				<>c.<>9__7_1 = val2;
				obj2 = (object)val2;
			}
			CombatDirector.HalcyoniteShrineActivation += (hook_HalcyoniteShrineActivation)obj2;
			SceneDirector.onGenerateInteractableCardSelection += delegate(SceneDirector sceneDirector, DirectorCardCategorySelection interactables)
			{
				if (ModSettings.HalcyonShrineEveryStage.Value && EclipseStagePool.IsActive(Run.instance))
				{
					int num = CurrentStage();
					if (num >= 1 && num <= 5 && !interactables.categories.Any((Category category) => category.cards.Any(IsHalcyonShrine)))
					{
						bool flag = num == 1;
						DirectorCard val3 = (flag ? (tier1Shrine ?? (tier1Shrine = NewCard("RoR2/DLC2/iscShrineHalcyoniteTier1.asset", 7))) : (shrine ?? (shrine = NewCard("RoR2/DLC2/iscShrineHalcyonite.asset", 1))));
						if (val3.IsAvailable())
						{
							int num2 = interactables.FindCategoryIndexByName("Storm Stuff");
							if (num2 < 0)
							{
								num2 = interactables.AddCategory("Storm Stuff", flag ? 3f : 1.5f);
							}
							interactables.AddCard(num2, val3);
							Log.Info(SceneCatalog.mostRecentSceneDef.cachedName + ": a Halcyon Shrine can spawn.");
						}
					}
				}
			};
		}

		private static bool IsWeakened()
		{
			if (ModSettings.WeakerHalcyonShrines.Value && EclipseStagePool.IsActive(Run.instance))
			{
				return Run.instance.stageClearCount >= 3;
			}
			return false;
		}

		private static DirectorCard NewCard(string address, int weight)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			return new DirectorCard
			{
				spawnCard = Addressables.LoadAssetAsync<SpawnCard>((object)address).WaitForCompletion(),
				selectionWeight = weight
			};
		}

		private static bool IsHalcyonShrine(DirectorCard card)
		{
			SpawnCard spawnCard = card.GetSpawnCard();
			if (spawnCard != null)
			{
				return ((Object)spawnCard).name.StartsWith("iscShrineHalcyonite");
			}
			return false;
		}

		private static int CurrentStage()
		{
			SceneDef mostRecentSceneDef = SceneCatalog.mostRecentSceneDef;
			AddedMap addedMap = AddedMaps.Of(mostRecentSceneDef);
			if (addedMap != null)
			{
				return addedMap.StageOf(SceneCatalog.FindSceneDef(addedMap.SceneName));
			}
			if (!Object.op_Implicit((Object)(object)mostRecentSceneDef))
			{
				return 0;
			}
			return mostRecentSceneDef.stageOrder;
		}
	}
	internal static class Log
	{
		private static ManualLogSource _source;

		internal static void Init(ManualLogSource source)
		{
			_source = source;
		}

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

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

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

		internal static void Warning(object data)
		{
			_source.LogWarning(data);
		}

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

		internal static void Fatal(object data)
		{
			_source.LogFatal(data);
		}
	}
	internal static class ModSettings
	{
		internal static ConfigEntry<bool> AddAllMaps;

		internal static ConfigEntry<bool> AlsoInNormalRuns;

		internal static ConfigEntry<float> AddedMapChance;

		internal static ConfigEntry<bool> BalanceCredits;

		internal static ConfigEntry<bool> VoidLocusTeleporter;

		internal static ConfigEntry<bool> VoidLocusMonsters;

		internal static ConfigEntry<bool> VoidLocusInteractables;

		internal static ConfigEntry<bool> ConduitCanyonToStage5;

		internal static ConfigEntry<bool> RobotBosses;

		internal static ConfigEntry<bool> NoColossusPortals;

		internal static ConfigEntry<bool> FrogPortalToPrimeMeridian;

		internal static ConfigEntry<bool> HalcyonShrineEveryStage;

		internal static ConfigEntry<bool> WeakerHalcyonShrines;

		internal static ConfigEntry<bool> NoSolutionalHauntPortals;

		internal static ConfigEntry<bool> FrogPortalToNeuralSanctum;

		internal static ConfigEntry<bool> AlloyHunterBoss;

		internal static ConfigEntry<bool> OnlyAddedMaps;

		private static readonly List<(ConfigEntryBase entry, string label)> menu = new List<(ConfigEntryBase, string)>();

		internal static IEnumerable<(ConfigEntryBase entry, string label)> Menu => menu;

		internal static void Bind(ConfigFile config)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			AddAllMaps = Bind(config, "General", "AddAllMapsToEclipse", "Add all maps to Eclipse", defaultValue: true, "The switch for the whole mod: adds Reformed Altar, Treeborn Colony, Conduit Canyon and Void Locus to the normal stage rotation of Eclipse runs, and applies every other setting. Only the host's settings count, and a change applies from the next stage.");
			AlsoInNormalRuns = Bind(config, "General", "AlsoInNormalRuns", "Also in normal runs", defaultValue: false, "Applies the mod to normal runs as well as Eclipse. Void Locus is then changed wherever you reach it, through a void portal too.");
			AddedMapChance = config.Bind<float>("General", "AddedMapChance", 1f, new ConfigDescription("How likely each added map is next to a usual map of its stage: 1 is as likely, 2 twice, 0.5 half. To keep one out, switch it off under its stage.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>()));
			menu.Add(((ConfigEntryBase)(object)AddedMapChance, "Added map chance"));
			BalanceCredits = Bind(config, "General", "BalanceCredits", "Balance chest and monster credits", defaultValue: true, "Gives each added map the median chest and monster credits of its stage (Void Locus's chest credits go from 220 to 545). Off keeps each map's own.");
			StageMaps.Bind(config);
			menu.AddRange(StageMaps.All.Select((StageMap map) => ((ConfigEntryBase)(object)map.Enabled, Label: map.Label)));
			VoidLocusTeleporter = Bind(config, "Void Locus", "PrimordialTeleporter", "Primordial Teleporter", defaultValue: true, "Replaces Void Locus's Deep Void Signals with a Primordial Teleporter to Commencement (Mithrix), as on Sky Meadow. Off keeps the signals, so a run that rolls Void Locus ends with Voidling in the Planetarium.");
			VoidLocusMonsters = Bind(config, "Void Locus", "StageFiveMonsters", "Stage 5 monsters", defaultValue: true, "On the first loop, Void Locus spawns half Sky Meadow's monsters and half its own, without Void Jailers. Off, or after a loop, it spawns only its own void monsters.");
			VoidLocusInteractables = Bind(config, "Void Locus", "StageFiveInteractables", "Stage 5 interactables", defaultValue: true, "Gives Void Locus Sky Meadow's chests, shrines, printers and drones, with its own void interactables about as common as chests. Off keeps only Void Cradles, Void Potentials and Stalks.");
			ConduitCanyonToStage5 = Bind(config, "Conduit Canyon", "TeleporterToStageFive", "Teleporter to stage 5", defaultValue: true, "Conduit Canyon's teleporter leads to stage 5. Off, it leads down the Alloyed path to Solutional Haunt, as in vanilla.");
			RobotBosses = Bind(config, "Conduit Canyon", "RobotBosses", "Robot bosses", defaultValue: true, "Conduit Canyon's teleporter boss is a Solus Control Unit, Alloy Worship Unit, Solus Amalgamator or Alloy Hunter, each as likely, in one fight. The Alloy Worship Unit and the Alloy Hunter come one at a time, as with Alloy Hunter as a normal boss. Off, the boss is its usual Solus Amalgamator, or the Alloy Hunter with that setting on; with both off, vanilla's scripted two-boss fight stays.");
			NoColossusPortals = Bind(config, "Colossus Path", "NoGreenPortals", "No green portals", defaultValue: true, "No green portal down the Colossus path opens: not from Reformed Altar's and Treeborn Colony's teleporters, Halcyon Shrines, Gilded Coast or the Bazaar's geodes, so the run stays on the stage rotation. Off, they open as in vanilla.");
			FrogPortalToPrimeMeridian = Bind(config, "Colossus Path", "FrogPortalToPrimeMeridian", "Frog portal to Prime Meridian", defaultValue: true, "After Mithrix, petting Commencement's frog 10 times also opens a green portal to Prime Meridian (False Son), next to the void one.");
			HalcyonShrineEveryStage = Bind(config, "Colossus Path", "HalcyonShrineEveryStage", "Halcyon Shrine on every stage", defaultValue: true, "Halcyon Shrines can spawn on every stage, as one of its interactables with their usual cost and odds. Vanilla only has them when a stage's Seekers of the Storm content is rolled in, and never on Conduit Canyon or Void Locus. Needs Seekers of the Storm.");
			WeakerHalcyonShrines = Bind(config, "Colossus Path", "WeakerHalcyonShrinesFromStageFour", "Weaker Halcyon Shrines from stage 4", defaultValue: true, "From stage 4 on, a Halcyon Shrine's monster waves get half the credits, and its Halcyonite half the bonus from the gold drained: at most x5.2 health and x2.75 damage instead of x10 and x4.75. Its cost and reward stay vanilla.");
			NoSolutionalHauntPortals = Bind(config, "Alloyed Path", "NoSolutionalHauntPortals", "No Solutional Haunt portals", defaultValue: true, "Solved access codes and Siren's Call open no portal to Solutional Haunt, so the run stays on the stage rotation; the access codes' extra boss and item stay. A stage 3's access codes still open their portal to Conduit Canyon, a stage 4 of the rotation, unless Conduit Canyon is switched off. Off, they open as in vanilla.");
			FrogPortalToNeuralSanctum = Bind(config, "Alloyed Path", "FrogPortalToNeuralSanctum", "Frog portal to Neural Sanctum", defaultValue: true, "After Mithrix, petting Commencement's frog 10 times also opens a portal to Neural Sanctum (Solus Heart), next to the void one. Accepting Solus Heart's offering ends the run with a win. Needs the Alloyed Collective DLC.");
			AlloyHunterBoss = Bind(config, "Bosses", "AlloyHunterFromStageFour", "Alloy Hunter as a normal boss", defaultValue: true, "From stage 4 on the Alloy Hunter can be the teleporter boss on any map, as likely as any one of that map's own bosses, and Conduit Canyon's teleporter event has one boss. It comes one at a time, as vanilla only ever spawns it: one, plus one per Shrine of the Mountain, each with the health of the hunters the boss credits would buy, so the fight has an 800-credit boss's total health in fewer hunters. Off, it only shows up as vanilla's second boss on Conduit Canyon, killing and replacing a Solus Control Unit. Needs the Alloyed Collective DLC.");
			OnlyAddedMaps = Bind(config, "Debug", "OnlyAddedMaps", "Only added maps", defaultValue: false, "Gives every other map a 0% chance on the stages that gained a map, and keeps them off the Bazaar's Lunar Seers, so an Eclipse run with every map switched on always goes stage 1 -> Reformed Altar -> Treeborn Colony -> Conduit Canyon -> Void Locus -> Commencement. For testing the added maps; leave off for normal play.");
		}

		internal static bool AppliesTo(Run run)
		{
			if (!(run is EclipseRun))
			{
				if (AlsoInNormalRuns.Value && Object.op_Implicit((Object)(object)run))
				{
					return ((object)run).GetType() == typeof(Run);
				}
				return false;
			}
			return true;
		}

		private static ConfigEntry<bool> Bind(ConfigFile config, string section, string key, string label, bool defaultValue, string description)
		{
			ConfigEntry<bool> val = config.Bind<bool>(section, key, defaultValue, description);
			menu.Add(((ConfigEntryBase)(object)val, label));
			return val;
		}
	}
	internal static class RiskOfOptionsCompat
	{
		internal const string PluginGuid = "com.rune580.riskofoptions";

		internal static bool IsInstalled => Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		internal static void AddOptions(IEnumerable<(ConfigEntryBase entry, string label)> options)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			//IL_0084: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Expected O, but got Unknown
			ModSettingsManager.SetModDescription("Adds every map to the normal Eclipse stage rotation.", "chen-ror2.EclipseAllMaps", "EclipseAllMaps");
			foreach (var option in options)
			{
				ConfigEntryBase item = option.entry;
				string item2 = option.label;
				ConfigEntryBase val = item;
				BaseOption val5;
				if (!(val is ConfigEntry<bool> val2))
				{
					if (!(val is ConfigEntry<float> val3) || !(((ConfigEntryBase)val3).Description.AcceptableValues is AcceptableValueRange<float> val4))
					{
						continue;
					}
					val5 = (BaseOption)new StepSliderOption(val3, new StepSliderConfig
					{
						name = item2,
						min = val4.MinValue,
						max = val4.MaxValue,
						increment = 0.1f,
						FormatString = "{0:0.0}x"
					});
				}
				else
				{
					val5 = (BaseOption)new CheckBoxOption(val2, new CheckBoxConfig
					{
						name = item2
					});
				}
				ModSettingsManager.AddOption(val5, "chen-ror2.EclipseAllMaps", "EclipseAllMaps");
			}
		}
	}
	internal sealed class SoloBoss
	{
		private static readonly List<SoloBoss> all = new List<SoloBoss>();

		internal readonly string Name;

		private readonly string cardAddress;

		private readonly int? usualCostOverride;

		private CharacterSpawnCard card;

		private DirectorCard directorCard;

		private int usualCost;

		private float healthMultiplier = 1f;

		internal SoloBoss(string name, string cardAddress, int? usualCost = null)
		{
			Name = name;
			this.cardAddress = cardAddress;
			usualCostOverride = usualCost;
			all.Add(this);
		}

		internal static void Init()
		{
			SpawnCard.onSpawnedServerGlobal += delegate(SpawnResult result)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: 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)
				if (!result.success || !Object.op_Implicit((Object)(object)result.spawnedInstance) || result.spawnRequest == null)
				{
					return;
				}
				foreach (SoloBoss item in all)
				{
					if (Object.op_Implicit((Object)(object)item.card) && (Object)(object)result.spawnRequest.spawnCard == (Object)(object)item.card)
					{
						item.BoostHealth(result.spawnedInstance);
						break;
					}
				}
			};
		}

		internal bool OverrideNextBoss(CombatDirector bossDirector, TeleporterInteraction teleporter)
		{
			if (!Load())
			{
				return false;
			}
			float monsterCredit = bossDirector.monsterCredit;
			int num = 1 + teleporter.shrineBonusStacks + teleporter.hexBonusStacks;
			int num2 = Mathf.FloorToInt(monsterCredit / (float)num);
			((SpawnCard)card).directorCreditCost = Mathf.Max(1, Mathf.Min(Mathf.Max(num2, usualCost), Mathf.FloorToInt(monsterCredit)));
			healthMultiplier = Mathf.Max(1f, (float)((SpawnCard)card).directorCreditCost / (float)usualCost);
			bossDirector.OverrideNextBossCard(directorCard, false);
			Log.Info($"Teleporter boss: {Name}, {Mathf.Max(1, Mathf.FloorToInt(monsterCredit / (float)((SpawnCard)card).directorCreditCost))} of them with x{healthMultiplier:0.00} health ({monsterCredit:0} credits, {num} share(s)).");
			return true;
		}

		private bool Load()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)card))
			{
				CharacterSpawnCard val = Addressables.LoadAssetAsync<CharacterSpawnCard>((object)cardAddress).WaitForCompletion();
				if (!Object.op_Implicit((Object)(object)val))
				{
					Log.Warning(cardAddress + " is missing; no " + Name + " as a teleporter boss.");
					return false;
				}
				card = Object.Instantiate<CharacterSpawnCard>(val);
				((Object)card).name = ((Object)val).name;
				usualCost = Mathf.Max(1, usualCostOverride ?? ((SpawnCard)val).directorCreditCost);
				directorCard = new DirectorCard
				{
					spawnCard = (SpawnCard)(object)card,
					selectionWeight = 1
				};
			}
			return directorCard.IsAvailable();
		}

		private void BoostHealth(GameObject masterObject)
		{
			CharacterMaster val = default(CharacterMaster);
			if (!(healthMultiplier <= 1f) && masterObject.TryGetComponent<CharacterMaster>(ref val) && Object.op_Implicit((Object)(object)val.inventory))
			{
				int itemCountPermanent = val.inventory.GetItemCountPermanent(Items.BoostHp);
				val.inventory.GiveItemPermanent(Items.BoostHp, Mathf.RoundToInt((float)(10 + itemCountPermanent) * (healthMultiplier - 1f)));
			}
		}
	}
	internal static class StageMaps
	{
		private const string FirstLoopOnly = " Only rolls on the first loop.";

		private const string AfterLoopingOnly = " Only rolls after looping.";

		private const string SecondLayout = " Its second layout.";

		internal static readonly StageMap[] All = new StageMap[31]
		{
			new StageMap(1, "blackbeach", "Distant Roost"),
			new StageMap(1, "blackbeach2", "Distant Roost", " Its second layout."),
			new StageMap(1, "golemplains", "Titanic Plains"),
			new StageMap(1, "golemplains2", "Titanic Plains", " Its second layout."),
			new StageMap(1, "snowyforest", "Siphoned Forest"),
			new StageMap(1, "lakes", "Verdant Falls", " Only rolls on the first loop."),
			new StageMap(1, "lakesnight", "Viscous Falls", " Only rolls after looping."),
			new StageMap(1, "village", "Shattered Abodes", " Only rolls on the first loop."),
			new StageMap(1, "villagenight", "Disturbed Impact", " Only rolls after looping."),
			new StageMap(2, "goolake", "Abandoned Aqueduct"),
			new StageMap(2, "foggyswamp", "Wetland Aspect"),
			new StageMap(2, "ancientloft", "Aphelian Sanctuary"),
			new StageMap(2, "nest", "Pretender's Precipice"),
			new StageMap(2, "lemuriantemple", "Reformed Altar", " Added by this mod, without its green Colossus portal."),
			new StageMap(3, "frozenwall", "Rallypoint Delta"),
			new StageMap(3, "wispgraveyard", "Scorched Acres"),
			new StageMap(3, "sulfurpools", "Sulfur Pools"),
			new StageMap(3, "ironalluvium", "Iron Alluvium", " Only rolls on the first loop."),
			new StageMap(3, "ironalluvium2", "Iron Auroras", " Only rolls after looping."),
			new StageMap(3, "mire", "Tenebrous Quagmire"),
			new StageMap(3, "fungal", "Damp Caverns"),
			new StageMap(3, "habitat", "Treeborn Colony", " Added by this mod, without its green Colossus portal; Golden Dieback after looping."),
			new StageMap(4, "dampcavesimple", "Abyssal Depths"),
			new StageMap(4, "shipgraveyard", "Siren's Call"),
			new StageMap(4, "rootjungle", "Sundered Grove"),
			new StageMap(4, "repurposedcrater", "Repurposed Crater"),
			new StageMap(4, "sanctum", "Lurid Basilica"),
			new StageMap(4, "conduitcanyon", "Conduit Canyon", " Added by this mod. Its teleporter leads to stage 5 instead of the Alloyed path."),
			new StageMap(5, "skymeadow", "Sky Meadow"),
			new StageMap(5, "helminthroost", "Helminth Hatchery"),
			new StageMap(5, "voidstage", "Void Locus", " Added by this mod. Instead of Deep Void Signals it has a Primordial Teleporter, leading to Commencement (Mithrix) like Sky Meadow.")
		};

		private static readonly Dictionary<string, StageMap> bySceneName = new Dictionary<string, StageMap>();

		internal static void Bind(ConfigFile config)
		{
			StageMap[] all = All;
			foreach (StageMap stageMap in all)
			{
				stageMap.Bind(config);
				bySceneName[stageMap.SceneName] = stageMap;
			}
		}

		internal static bool IsEnabled(SceneDef sceneDef)
		{
			if (Object.op_Implicit((Object)(object)sceneDef))
			{
				return IsEnabled(sceneDef.cachedName);
			}
			return false;
		}

		internal static bool IsEnabled(string sceneName)
		{
			if (bySceneName.TryGetValue(sceneName, out var value))
			{
				return value.Enabled.Value;
			}
			return true;
		}
	}
	internal sealed class StageMap
	{
		internal readonly int Stage;

		internal readonly string SceneName;

		internal readonly string Label;

		private readonly string note;

		internal ConfigEntry<bool> Enabled { get; private set; }

		internal StageMap(int stage, string sceneName, string name, string note = "")
		{
			Stage = stage;
			SceneName = sceneName;
			Label = name + " (" + sceneName + ")";
			this.note = note;
		}

		internal void Bind(ConfigFile config)
		{
			Enabled = config.Bind<bool>($"Stage {Stage}", SceneName, true, Label + ": switch off to keep it out of Eclipse runs." + note);
		}
	}
	internal static class TeleporterBosses
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_Start <>9__8_0;

			public static hook_SetNextSpawnAsBoss <>9__8_1;

			internal void <Init>b__8_0(orig_Start orig, VultureFightOverride self)
			{
				if (NetworkServer.active && OnConduitCanyon() && (ModSettings.AlloyHunterBoss.Value || ModSettings.RobotBosses.Value))
				{
					self.triggerOnStart = false;
					TeleporterInteraction component = ((Component)self).GetComponent<TeleporterInteraction>();
					if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.bossDirector))
					{
						component.bossDirector.monsterCredit = 0f;
					}
					Log.Info("Conduit Canyon: no scripted Solus Control Unit and Alloy Hunter fight.");
				}
				orig.Invoke(self);
			}

			internal void <Init>b__8_1(orig_SetNextSpawnAsBoss orig, CombatDirector self)
			{
				TeleporterInteraction instance = TeleporterInteraction.instance;
				if (NetworkServer.active && Object.op_Implicit((Object)(object)instance) && (Object)(object)self == (Object)(object)instance.bossDirector && !self.HasOverrideBoss() && EclipseStagePool.IsActive(Run.instance) && (!Object.op_Implicit((Object)(object)RunArtifactManager.instance) || !RunArtifactManager.instance.IsArtifactEnabled(Artifacts.SingleMonsterType)))
				{
					PickBoss(self, instance);
				}
				orig.Invoke(self);
			}
		}

		private const string ConduitCanyon = "conduitcanyon";

		private const int Stage4ClearCount = 3;

		private const string SolusControlUnitAddress = "RoR2/Base/RoboBallBoss/cscRoboBallBoss.asset";

		private const string SolusAmalgamatorAddress = "RoR2/DLC3/SolusAmalgamator/cscSolusAmalgamator.asset";

		private static readonly SoloBoss AlloyHunter = new SoloBoss("Alloy Hunter", "RoR2/DLC3/VultureHunter/cscVultureHunter.asset");

		private static readonly SoloBoss AlloyWorshipUnit = new SoloBoss("Alloy Worship Unit", "RoR2/Base/RoboBallBoss/cscSuperRoboBallBoss.asset", 800);

		private static DirectorCard solusControlUnit;

		private static DirectorCard solusAmalgamator;

		internal static void Init()
		{
			//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_0024: Expected O, but got Unknown
			//IL_003d: 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_0048: Expected O, but got Unknown
			SoloBoss.Init();
			object obj = <>c.<>9__8_0;
			if (obj == null)
			{
				hook_Start val = delegate(orig_Start orig, VultureFightOverride self)
				{
					if (NetworkServer.active && OnConduitCanyon() && (ModSettings.AlloyHunterBoss.Value || ModSettings.RobotBosses.Value))
					{
						self.triggerOnStart = false;
						TeleporterInteraction component = ((Component)self).GetComponent<TeleporterInteraction>();
						if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.bossDirector))
						{
							component.bossDirector.monsterCredit = 0f;
						}
						Log.Info("Conduit Canyon: no scripted Solus Control Unit and Alloy Hunter fight.");
					}
					orig.Invoke(self);
				};
				<>c.<>9__8_0 = val;
				obj = (object)val;
			}
			VultureFightOverride.Start += (hook_Start)obj;
			object obj2 = <>c.<>9__8_1;
			if (obj2 == null)
			{
				hook_SetNextSpawnAsBoss val2 = delegate(orig_SetNextSpawnAsBoss orig, CombatDirector self)
				{
					TeleporterInteraction instance = TeleporterInteraction.instance;
					if (NetworkServer.active && Object.op_Implicit((Object)(object)instance) && (Object)(object)self == (Object)(object)instance.bossDirector && !self.HasOverrideBoss() && EclipseStagePool.IsActive(Run.instance) && (!Object.op_Implicit((Object)(object)RunArtifactManager.instance) || !RunArtifactManager.instance.IsArtifactEnabled(Artifacts.SingleMonsterType)))
					{
						PickBoss(self, instance);
					}
					orig.Invoke(self);
				};
				<>c.<>9__8_1 = val2;
				obj2 = (object)val2;
			}
			CombatDirector.SetNextSpawnAsBoss += (hook_SetNextSpawnAsBoss)obj2;
		}

		private static void PickBoss(CombatDirector bossDirector, TeleporterInteraction teleporter)
		{
			if (ModSettings.RobotBosses.Value && OnConduitCanyon())
			{
				PickRobotBoss(bossDirector, teleporter);
			}
			else if (ModSettings.AlloyHunterBoss.Value && Run.instance.stageClearCount >= 3)
			{
				RollAlloyHunter(bossDirector, teleporter);
			}
		}

		private static void PickRobotBoss(CombatDirector bossDirector, TeleporterInteraction teleporter)
		{
			if (solusControlUnit == null)
			{
				solusControlUnit = NewCard("RoR2/Base/RoboBallBoss/cscRoboBallBoss.asset");
			}
			if (solusAmalgamator == null)
			{
				solusAmalgamator = NewCard("RoR2/DLC3/SolusAmalgamator/cscSolusAmalgamator.asset");
			}
			switch (bossDirector.rng.RangeInt(0, 4))
			{
			case 0:
				OverrideWith(bossDirector, solusControlUnit, "Solus Control Unit");
				break;
			case 1:
				AlloyWorshipUnit.OverrideNextBoss(bossDirector, teleporter);
				break;
			case 2:
				OverrideWith(bossDirector, solusAmalgamator, "Solus Amalgamator");
				break;
			default:
				AlloyHunter.OverrideNextBoss(bossDirector, teleporter);
				break;
			}
		}

		private static void RollAlloyHunter(CombatDirector bossDirector, TeleporterInteraction teleporter)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			WeightedSelection<DirectorCard> finalMonsterCardsSelection = bossDirector.finalMonsterCardsSelection;
			int num2 = 0;
			while (finalMonsterCardsSelection != null && num2 < finalMonsterCardsSelection.Count)
			{
				DirectorCard value = finalMonsterCardsSelection.GetChoice(num2).value;
				SpawnCard spawnCard = value.GetSpawnCard();
				bool isChampion = spawnCard.prefab.GetComponent<CharacterMaster>().bodyPrefab.GetComponent<CharacterBody>().isChampion;
				bool flag = ((CharacterSpawnCard)(((spawnCard is CharacterSpawnCard) ? spawnCard : null)?)).forbiddenAsBoss ?? false;
				if (isChampion && !flag && value.IsAvailable())
				{
					num++;
				}
				num2++;
			}
			if (num > 0 && bossDirector.rng.nextNormalizedFloat * (float)(num + 1) < 1f)
			{
				AlloyHunter.OverrideNextBoss(bossDirector, teleporter);
			}
		}

		private static void OverrideWith(CombatDirector bossDirector, DirectorCard card, string name)
		{
			if (card.IsAvailable())
			{
				bossDirector.OverrideNextBossCard(card, false);
				Log.Info("Teleporter boss: " + name + ".");
			}
		}

		private static DirectorCard NewCard(string address)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			return new DirectorCard
			{
				spawnCard = Addressables.LoadAssetAsync<SpawnCard>((object)address).WaitForCompletion(),
				selectionWeight = 1
			};
		}

		private static bool OnConduitCanyon()
		{
			return AddedMaps.InPlay()?.SceneName == "conduitcanyon";
		}
	}
}