Decompiled source of SimulacrumBossStageMod v1.2.3

ServerSideTweaks.dll

Decompiled 6 months 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 BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HG.Reflection;
using IL.RoR2;
using IL.RoR2.Artifacts;
using InLobbyConfig;
using InLobbyConfig.Fields;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.RoR2;
using On.RoR2.Items;
using R2API.Utils;
using RoR2;
using ShareSuite;
using UnityEngine;
using UnityEngine.Networking;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ServerSideTweaks
{
	public class BepConfig
	{
		public static ConfigEntry<float> PearlReplacesLunarItemChance;

		public static ConfigEntry<float> IrradiantPearlReplacesLunarItemChance;

		public static ConfigEntry<bool> NoPearlsInBazaar;

		public static ConfigEntry<float> BazaarEliteAspectReplacesEquipmentChance;

		public static ConfigEntry<bool> SimulacrumNonSharedLoot;

		public static ConfigEntry<int> SimulacrumLootMaxItemDebt;

		public static ConfigEntry<float> SimulacrumCommencementArtifactDissonanceChance;

		public static ConfigEntry<float> SimulacrumDirectorEnemyPowerBias;

		public static ConfigEntry<int> SimulacrumMaxSquadSize;

		public static ConfigEntry<float> ClassicDirectorEnemyPowerBias;

		public static ConfigEntry<bool> Enabled { get; set; }

		public static void Init()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Expected O, but got Unknown
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Expected O, but got Unknown
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Expected O, but got Unknown
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Expected O, but got Unknown
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Expected O, but got Unknown
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Expected O, but got Unknown
			ConfigFile config = ((BaseUnityPlugin)ServerSideTweaks.instance).Config;
			Enabled = config.Bind<bool>("Main", "Enabled", true, "Enable Mod");
			PearlReplacesLunarItemChance = config.Bind<float>("Main", "Pearl replaces Lunar Item chance", 0.1f, new ConfigDescription("Adds a chance for lunar items to be replaced by a pearl.", (AcceptableValueBase)null, Array.Empty<object>()));
			IrradiantPearlReplacesLunarItemChance = config.Bind<float>("Main", "Irradiant Pearl replaces Lunar Item chance", 0.02f, new ConfigDescription("Adds a chance for lunar items to be replaced by an irradiant pearl.", (AcceptableValueBase)null, Array.Empty<object>()));
			NoPearlsInBazaar = config.Bind<bool>("Main", "No Pearl replacements in the Bazaar between Times", true, new ConfigDescription("Prevents pearls from appearing in the Bazaar to prevent hoarding.", (AcceptableValueBase)null, Array.Empty<object>()));
			BazaarEliteAspectReplacesEquipmentChance = config.Bind<float>("Main", "Bazaar: Elite Aspect replaces Equipment Chance", 0.2f, new ConfigDescription("Chance that an equipment item is replaced by an elite aspect (only in Bazaar between Times). Only useful in combination with BazaarIsMyHome.", (AcceptableValueBase)null, Array.Empty<object>()));
			SimulacrumNonSharedLoot = config.Bind<bool>("Simulacrum", "Non-shared loot", false, new ConfigDescription("(ShareSuite only) Forces the loot dropped at the end of each wave to be non-shared.", (AcceptableValueBase)null, Array.Empty<object>()));
			SimulacrumLootMaxItemDebt = config.Bind<int>("Simulacrum", "Max loot debt", 2, new ConfigDescription("Prevents greedy players from taking too much of the loot dropped at the end of each wave.", (AcceptableValueBase)null, Array.Empty<object>()));
			SimulacrumCommencementArtifactDissonanceChance = config.Bind<float>("Simulacrum", "Commencement Artifact of Dissonance Chance", 0.5f, new ConfigDescription("The chance for Artifact of Dissonance to be activated each wave when in the commencement stage to increase enemy variety.", (AcceptableValueBase)null, Array.Empty<object>()));
			SimulacrumDirectorEnemyPowerBias = config.Bind<float>("Simulacrum", "Director: Enemy Power Bias", 0.5f, new ConfigDescription("Bias towards many,weak enemies (=0) or few,strong enemies (=1). Value between 0 and 1, 0.5 = vanilla.", (AcceptableValueBase)null, Array.Empty<object>()));
			SimulacrumMaxSquadSize = config.Bind<int>("Simulacrum", "Max squad size", 30, new ConfigDescription("No more than this many enemies shall be spawned at the same time (30 = vanilla).", (AcceptableValueBase)null, Array.Empty<object>()));
			ClassicDirectorEnemyPowerBias = config.Bind<float>("Classic", "Director: Enemy Power Bias", 0.5f, new ConfigDescription("Bias towards many,weak enemies (=0) or few,strong enemies (=1). Value between 0 and 1, 0.5 = vanilla.", (AcceptableValueBase)null, Array.Empty<object>()));
			if (ModCompatibilityInLobbyConfig.enabled)
			{
				ModCompatibilityInLobbyConfig.CreateFromBepInExConfigFile(config, "Server-Side Tweaks");
			}
		}
	}
	public static class ChatHelper
	{
		private const string RedColor = "ff0000";

		private const string GreenColor = "32cd32";

		private const string SilverColor = "c0c0c0";

		public static void PlayerHasTooManyItems(string userName)
		{
			//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_0022: Expected O, but got Unknown
			string baseToken = "<color=#ff0000>" + userName + " is being greedy!</color>";
			Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
			{
				baseToken = baseToken
			});
		}
	}
	public class EnumCollection
	{
		public enum ArtifactEnum
		{
			None,
			Chaos,
			Command,
			Death,
			Dissonance,
			Enigma,
			Evolution,
			Frailty,
			Glass,
			Honor,
			Kin,
			Metamorphosis,
			Sacrifice,
			Soul,
			Spite,
			Swarms,
			Vengeance
		}

		public enum StageEnum
		{
			None,
			TitanicPlains,
			DistantRoost,
			WetlandAspect,
			AbandonedAqueduct,
			RallypointDelta,
			ScorchedAcres,
			AbyssalDepths,
			SirensCall,
			GildedCoast,
			MomentFractured,
			Bazaar,
			VoidFields,
			MomentWhole,
			SkyMeadow,
			BullwarksAmbry,
			Commencement,
			SunderedGrove,
			VoidLocus,
			Planetarium,
			AphelianSanctuary,
			SimulacrumAbandonedAquaduct,
			SimulacrumAbyssalDepths,
			SimulacrumAphelianSanctuary,
			SimulacrumCommencement,
			SimulacrumRallypointDelta,
			SimulacrumSkyMeadow,
			SimulacrumTitanicPlains,
			SiphonedForest,
			SulfurPools
		}

		public static Dictionary<StageEnum, List<string>> SceneNames = new Dictionary<StageEnum, List<string>>
		{
			{
				StageEnum.TitanicPlains,
				new List<string> { "golemplains", "golemplains2" }
			},
			{
				StageEnum.DistantRoost,
				new List<string> { "blackbeach", "blackbeach2" }
			},
			{
				StageEnum.WetlandAspect,
				new List<string> { "foggyswamp" }
			},
			{
				StageEnum.AbandonedAqueduct,
				new List<string> { "goolake" }
			},
			{
				StageEnum.RallypointDelta,
				new List<string> { "frozenwall" }
			},
			{
				StageEnum.ScorchedAcres,
				new List<string> { "wispgraveyard" }
			},
			{
				StageEnum.AbyssalDepths,
				new List<string> { "dampcavesimple" }
			},
			{
				StageEnum.SirensCall,
				new List<string> { "shipgraveyard" }
			},
			{
				StageEnum.GildedCoast,
				new List<string> { "goldshores" }
			},
			{
				StageEnum.MomentFractured,
				new List<string> { "mysteryspace" }
			},
			{
				StageEnum.Bazaar,
				new List<string> { "bazaar" }
			},
			{
				StageEnum.VoidFields,
				new List<string> { "arena" }
			},
			{
				StageEnum.MomentWhole,
				new List<string> { "limbo" }
			},
			{
				StageEnum.SkyMeadow,
				new List<string> { "skymeadow" }
			},
			{
				StageEnum.BullwarksAmbry,
				new List<string> { "artifactworld" }
			},
			{
				StageEnum.Commencement,
				new List<string> { "moon", "moon2" }
			},
			{
				StageEnum.SunderedGrove,
				new List<string> { "rootjungle" }
			},
			{
				StageEnum.VoidLocus,
				new List<string> { "voidstage" }
			},
			{
				StageEnum.Planetarium,
				new List<string> { "voidraid" }
			},
			{
				StageEnum.AphelianSanctuary,
				new List<string> { "ancientloft" }
			},
			{
				StageEnum.SimulacrumAbandonedAquaduct,
				new List<string> { "itgoolake" }
			},
			{
				StageEnum.SimulacrumAbyssalDepths,
				new List<string> { "itdampcave" }
			},
			{
				StageEnum.SimulacrumAphelianSanctuary,
				new List<string> { "itancientloft" }
			},
			{
				StageEnum.SimulacrumCommencement,
				new List<string> { "itmoon" }
			},
			{
				StageEnum.SimulacrumRallypointDelta,
				new List<string> { "itfrozenwall" }
			},
			{
				StageEnum.SimulacrumSkyMeadow,
				new List<string> { "itskymeadow" }
			},
			{
				StageEnum.SimulacrumTitanicPlains,
				new List<string> { "itgolemplains" }
			},
			{
				StageEnum.SiphonedForest,
				new List<string> { "snowyforest" }
			},
			{
				StageEnum.SulfurPools,
				new List<string> { "sulfurpools" }
			}
		};

		public static T DecrementEnumValue<T>(T value) where T : struct, IConvertible
		{
			if (!typeof(T).IsEnum)
			{
				throw new ArgumentException("T must be an enumerated type");
			}
			int length = Enum.GetValues(typeof(T)).Length;
			return (T)(object)(((int)(object)value - 1 + length) % length);
		}

		public static T IncrementEnumValue<T>(T value) where T : struct, IConvertible
		{
			if (!typeof(T).IsEnum)
			{
				throw new ArgumentException("T must be an enumerated type");
			}
			int length = Enum.GetValues(typeof(T)).Length;
			return (T)(object)(((int)(object)value + 1) % length);
		}

		public static bool IsSimulacrumStage(string name)
		{
			if (GetFirstStageName(StageEnum.SimulacrumAbandonedAquaduct) == name)
			{
				return true;
			}
			if (GetFirstStageName(StageEnum.SimulacrumAbyssalDepths) == name)
			{
				return true;
			}
			if (GetFirstStageName(StageEnum.SimulacrumAphelianSanctuary) == name)
			{
				return true;
			}
			if (GetFirstStageName(StageEnum.SimulacrumCommencement) == name)
			{
				return true;
			}
			if (GetFirstStageName(StageEnum.SimulacrumRallypointDelta) == name)
			{
				return true;
			}
			if (GetFirstStageName(StageEnum.SimulacrumSkyMeadow) == name)
			{
				return true;
			}
			if (GetFirstStageName(StageEnum.SimulacrumTitanicPlains) == name)
			{
				return true;
			}
			return false;
		}

		public static bool SceneNameIsStage(string sceneName, StageEnum stageEnum)
		{
			return SceneNames[stageEnum].Contains(sceneName);
		}

		public static string GetFirstStageName(StageEnum stageEnum)
		{
			return SceneNames[stageEnum].First();
		}

		public static ArtifactDef GetArtifactDef(ArtifactEnum artifacts)
		{
			return (ArtifactDef)(artifacts switch
			{
				ArtifactEnum.Chaos => Artifacts.FriendlyFire, 
				ArtifactEnum.Command => Artifacts.Command, 
				ArtifactEnum.Death => Artifacts.TeamDeath, 
				ArtifactEnum.Dissonance => Artifacts.MixEnemy, 
				ArtifactEnum.Enigma => Artifacts.Enigma, 
				ArtifactEnum.Evolution => Artifacts.MonsterTeamGainsItems, 
				ArtifactEnum.Frailty => Artifacts.WeakAssKnees, 
				ArtifactEnum.Glass => Artifacts.Glass, 
				ArtifactEnum.Honor => Artifacts.EliteOnly, 
				ArtifactEnum.Kin => Artifacts.SingleMonsterType, 
				ArtifactEnum.Metamorphosis => Artifacts.RandomSurvivorOnRespawn, 
				ArtifactEnum.Sacrifice => Artifacts.Sacrifice, 
				ArtifactEnum.Soul => Artifacts.WispOnDeath, 
				ArtifactEnum.Spite => Artifacts.Bomb, 
				ArtifactEnum.Swarms => Artifacts.Swarms, 
				ArtifactEnum.Vengeance => Artifacts.ShadowClone, 
				_ => null, 
			});
		}
	}
	internal static class Log
	{
		internal static ManualLogSource _logSource;

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

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

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

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

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

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

		internal static void LogWarning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	public static class ModCompatibilityInLobbyConfig
	{
		private static bool? _enabled;

		public static bool enabled
		{
			get
			{
				if (!_enabled.HasValue)
				{
					_enabled = Chainloader.PluginInfos.ContainsKey("com.KingEnderBrine.InLobbyConfig");
				}
				return _enabled.Value;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void CreateFromBepInExConfigFile(ConfigFile config, string displayName)
		{
			ModConfigCatalog.Add(ConfigFieldUtilities.CreateFromBepInExConfigFile(config, displayName));
		}
	}
	public static class ModCompatibilityShareSuite
	{
		private static bool? _enabled;

		public static bool enabled
		{
			get
			{
				if (!_enabled.HasValue)
				{
					_enabled = Chainloader.PluginInfos.ContainsKey("com.funkfrog_sipondo.sharesuite");
				}
				return _enabled.Value;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void AddPickupEventHandler(Func<GenericPickupController, CharacterBody, bool> f)
		{
			ItemSharingHooks.AdditionalPickupValidityChecks += f;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void RemovePickupEventHandler(Func<GenericPickupController, CharacterBody, bool> f)
		{
			ItemSharingHooks.AdditionalPickupValidityChecks -= f;
		}
	}
	public class NonShareableItem : MonoBehaviour
	{
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Def.ServerSideTweaks", "ServerSideTweaks", "1.1.1")]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class ServerSideTweaks : BaseUnityPlugin
	{
		public static ServerSideTweaks instance;

		public static int totalItemRewardCount = 0;

		public static float directorEnemyPowerBiasOverride = -1f;

		public static GameObject mostRecentlyCreatedPickup = null;

		public static Dictionary<NetworkUserId, float> usersItemCredit = new Dictionary<NetworkUserId, float>();

		public static List<EquipmentIndex> disableEquipments = new List<EquipmentIndex>();

		public static List<PickupIndex> availableEquipmentDropList_Saved = new List<PickupIndex>();

		public static List<PickupIndex> availableLunarItemDropList_Saved = new List<PickupIndex>();

		public static List<PickupIndex> availableLunarEquipmentDropList_Saved = new List<PickupIndex>();

		public static EnumCollection.StageEnum debug_nextStage = EnumCollection.StageEnum.None;

		public const string PluginGUID = "Def.ServerSideTweaks";

		public const string PluginAuthor = "Def";

		public const string PluginName = "ServerSideTweaks";

		public const string PluginVersion = "1.1.1";

		public static PluginInfo PInfo { get; private set; }

		public void Awake()
		{
			PInfo = ((BaseUnityPlugin)this).Info;
			instance = this;
			Log.Init(((BaseUnityPlugin)this).Logger);
			BepConfig.Init();
		}

		private void OnEnable()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Expected O, but got Unknown
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Expected O, but got Unknown
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Expected O, but got Unknown
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Expected O, but got Unknown
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Expected O, but got Unknown
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Expected O, but got Unknown
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Expected O, but got Unknown
			Run.Start += new hook_Start(Run_Start);
			InfiniteTowerRun.OnWaveAllEnemiesDefeatedServer += new hook_OnWaveAllEnemiesDefeatedServer(InfiniteTowerRun_OnWaveAllEnemiesDefeatedServer);
			InfiniteTowerRun.AdvanceWave += new hook_AdvanceWave(InfiniteTowerRun_AdvanceWave);
			CombatDirector.AttemptSpawnOnTarget += new Manipulator(CombatDirector_AttemptSpawnOnTarget);
			Run.FixedUpdate += new hook_FixedUpdate(Run_FixedUpdate);
			InfiniteTowerWaveController.DropRewards += new Manipulator(InfiniteTowerWaveController_DropRewards);
			InfiniteTowerWaveController.DropRewards += new hook_DropRewards(InfiniteTowerWaveController_DropRewards1);
			GenericPickupController.AttemptGrant += new hook_AttemptGrant(GenericPickupController_AttemptGrant);
			GenericPickupController.OnInteractionBegin += new hook_OnInteractionBegin(GenericPickupController_OnInteractionBegin);
			GenericPickupController.CreatePickup += new Manipulator(GenericPickupController_CreatePickup);
			PickupDropletController.OnCollisionEnter += new hook_OnCollisionEnter(PickupDropletController_OnCollisionEnter);
			PickupPickerController.OnInteractionBegin += new hook_OnInteractionBegin(PickupPickerController_OnInteractionBegin);
			PickupPickerController.CreatePickup_PickupIndex += new hook_CreatePickup_PickupIndex(PickupPickerController_CreatePickup_PickupIndex);
			CommandArtifactManager.OnDropletHitGroundServer += new Manipulator(CommandArtifactManager_OnDropletHitGroundServer);
			RandomlyLunarUtils.CheckForLunarReplacement += new hook_CheckForLunarReplacement(RandomlyLunarUtils_CheckForLunarReplacement);
			RandomlyLunarUtils.CheckForLunarReplacementUniqueArray += new hook_CheckForLunarReplacementUniqueArray(RandomlyLunarUtils_CheckForLunarReplacementUniqueArray);
			InfiniteTowerWaveController.Initialize += new hook_Initialize(InfiniteTowerWaveController_Initialize);
			if (ModCompatibilityShareSuite.enabled)
			{
				ModCompatibilityShareSuite.AddPickupEventHandler(NonShareableItemCheck);
			}
		}

		private void OnDisable()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Expected O, but got Unknown
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Expected O, but got Unknown
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Expected O, but got Unknown
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Expected O, but got Unknown
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Expected O, but got Unknown
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Expected O, but got Unknown
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Expected O, but got Unknown
			Run.Start -= new hook_Start(Run_Start);
			InfiniteTowerRun.OnWaveAllEnemiesDefeatedServer -= new hook_OnWaveAllEnemiesDefeatedServer(InfiniteTowerRun_OnWaveAllEnemiesDefeatedServer);
			InfiniteTowerRun.AdvanceWave -= new hook_AdvanceWave(InfiniteTowerRun_AdvanceWave);
			CombatDirector.AttemptSpawnOnTarget -= new Manipulator(CombatDirector_AttemptSpawnOnTarget);
			Run.FixedUpdate -= new hook_FixedUpdate(Run_FixedUpdate);
			InfiniteTowerWaveController.DropRewards -= new Manipulator(InfiniteTowerWaveController_DropRewards);
			InfiniteTowerWaveController.DropRewards -= new hook_DropRewards(InfiniteTowerWaveController_DropRewards1);
			GenericPickupController.AttemptGrant -= new hook_AttemptGrant(GenericPickupController_AttemptGrant);
			GenericPickupController.OnInteractionBegin -= new hook_OnInteractionBegin(GenericPickupController_OnInteractionBegin);
			GenericPickupController.CreatePickup -= new Manipulator(GenericPickupController_CreatePickup);
			PickupDropletController.OnCollisionEnter -= new hook_OnCollisionEnter(PickupDropletController_OnCollisionEnter);
			PickupPickerController.OnInteractionBegin -= new hook_OnInteractionBegin(PickupPickerController_OnInteractionBegin);
			PickupPickerController.CreatePickup_PickupIndex -= new hook_CreatePickup_PickupIndex(PickupPickerController_CreatePickup_PickupIndex);
			CommandArtifactManager.OnDropletHitGroundServer -= new Manipulator(CommandArtifactManager_OnDropletHitGroundServer);
			RandomlyLunarUtils.CheckForLunarReplacement -= new hook_CheckForLunarReplacement(RandomlyLunarUtils_CheckForLunarReplacement);
			RandomlyLunarUtils.CheckForLunarReplacementUniqueArray -= new hook_CheckForLunarReplacementUniqueArray(RandomlyLunarUtils_CheckForLunarReplacementUniqueArray);
			InfiniteTowerWaveController.Initialize -= new hook_Initialize(InfiniteTowerWaveController_Initialize);
			if (ModCompatibilityShareSuite.enabled)
			{
				ModCompatibilityShareSuite.RemovePickupEventHandler(NonShareableItemCheck);
			}
		}

		private void InfiniteTowerWaveController_Initialize(orig_Initialize orig, InfiniteTowerWaveController self, int waveIndex, Inventory enemyInventory, GameObject spawnTarget)
		{
			if (NetworkServer.active && BepConfig.Enabled.Value)
			{
				self.maxSquadSize = BepConfig.SimulacrumMaxSquadSize.Value;
			}
			orig.Invoke(self, waveIndex, enemyInventory, spawnTarget);
		}

		private bool NonShareableItemCheck(GenericPickupController pickup, CharacterBody picker)
		{
			NonShareableItem nonShareableItem = default(NonShareableItem);
			if (BepConfig.SimulacrumNonSharedLoot.Value)
			{
				return !((Component)pickup).TryGetComponent<NonShareableItem>(ref nonShareableItem);
			}
			return true;
		}

		private void Run_Start(orig_Start orig, Run self)
		{
			totalItemRewardCount = 0;
			mostRecentlyCreatedPickup = null;
			usersItemCredit.Clear();
			ResetOverridePowerBias();
			orig.Invoke(self);
		}

		public static void SetOverridePowerBias(float powerBias)
		{
			directorEnemyPowerBiasOverride = powerBias;
		}

		public static float GetCurrentPowerBias()
		{
			if (((object)Run.instance).GetType() == typeof(InfiniteTowerRun) && BepConfig.Enabled.Value)
			{
				return BepConfig.SimulacrumDirectorEnemyPowerBias.Value;
			}
			if (BepConfig.Enabled.Value)
			{
				return BepConfig.ClassicDirectorEnemyPowerBias.Value;
			}
			return 0.5f;
		}

		public static void ResetOverridePowerBias()
		{
			directorEnemyPowerBiasOverride = -1f;
		}

		private void Run_FixedUpdate(orig_FixedUpdate orig, Run self)
		{
			orig.Invoke(self);
			_ = NetworkServer.active;
		}

		private void PickupPickerController_OnInteractionBegin(orig_OnInteractionBegin orig, PickupPickerController self, Interactor activator)
		{
			if (CanInteract(((Component)self).gameObject, activator))
			{
				orig.Invoke(self, activator);
			}
		}

		private void GenericPickupController_OnInteractionBegin(orig_OnInteractionBegin orig, GenericPickupController self, Interactor activator)
		{
			if (CanInteract(((Component)self).gameObject, activator))
			{
				orig.Invoke(self, activator);
			}
		}

		private bool CanInteract(GameObject self, Interactor activator)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			if (!BepConfig.Enabled.Value)
			{
				return true;
			}
			NonShareableItem nonShareableItem = default(NonShareableItem);
			if (self.TryGetComponent<NonShareableItem>(ref nonShareableItem))
			{
				NetworkUser val = Util.LookUpBodyNetworkUser((activator != null) ? ((Component)activator).GetComponent<CharacterBody>() : null);
				if ((Object)(object)val != (Object)null)
				{
					usersItemCredit.TryGetValue(val.id, out var value);
					if (value >= (float)(-BepConfig.SimulacrumLootMaxItemDebt.Value))
					{
						return true;
					}
					ChatHelper.PlayerHasTooManyItems(val.userName);
					return false;
				}
			}
			return true;
		}

		private void GenericPickupController_AttemptGrant(orig_AttemptGrant orig, GenericPickupController self, CharacterBody body)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, body);
			NonShareableItem nonShareableItem = default(NonShareableItem);
			if (NetworkServer.active && BepConfig.Enabled.Value && ((Component)self).TryGetComponent<NonShareableItem>(ref nonShareableItem) && self.consumed)
			{
				NetworkUser val = Util.LookUpBodyNetworkUser(body);
				if (usersItemCredit.ContainsKey(val.id))
				{
					usersItemCredit[val.id] -= 1f;
				}
				else
				{
					usersItemCredit.Add(val.id, -1f);
				}
			}
		}

		private void InfiniteTowerWaveController_DropRewards(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			val.DefineLabel();
			val.GotoNext(new Func<Instruction, bool>[4]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 6),
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 4),
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 2),
				(Instruction x) => ILPatternMatchingExt.MatchCall<PickupDropletController>(x, "CreatePickupDroplet")
			});
			val.Index += 3;
			val.Remove();
			val.EmitDelegate<Action<CreatePickupInfo, Vector3, Vector3>>((Action<CreatePickupInfo, Vector3, Vector3>)delegate(CreatePickupInfo pickupInfo, Vector3 position, Vector3 velocity)
			{
				//IL_0083: 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_0085: 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_0012: 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_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_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_0035: Unknown result type (might be due to invalid IL or missing references)
				if (BepConfig.Enabled.Value)
				{
					GameObject obj = Object.Instantiate<GameObject>(PickupDropletController.pickupDropletPrefab, position, Quaternion.identity);
					PickupDropletController component = obj.GetComponent<PickupDropletController>();
					if (Object.op_Implicit((Object)(object)component))
					{
						component.createPickupInfo = pickupInfo;
						component.NetworkpickupIndex = ((CreatePickupInfo)(ref pickupInfo)).pickupIndex;
					}
					Rigidbody component2 = obj.GetComponent<Rigidbody>();
					component2.velocity = velocity;
					component2.AddTorque(Random.Range(150f, 120f) * Random.onUnitSphere);
					obj.AddComponent<NonShareableItem>();
					NetworkServer.Spawn(obj);
					totalItemRewardCount++;
				}
				else
				{
					PickupDropletController.CreatePickupDroplet(pickupInfo, position, velocity);
				}
			});
		}

		private void InfiniteTowerWaveController_DropRewards1(orig_DropRewards orig, InfiniteTowerWaveController self)
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: 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_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			if (!NetworkServer.active || !BepConfig.Enabled.Value)
			{
				return;
			}
			int num = PlayerCharacterMasterController.instances.Where((PlayerCharacterMasterController pc) => pc.isConnected).Count();
			foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
			{
				if (instance.isConnected)
				{
					float value = 0f;
					usersItemCredit.TryGetValue(instance.networkUser.id, out value);
					if (usersItemCredit.ContainsKey(instance.networkUser.id))
					{
						usersItemCredit[instance.networkUser.id] += (float)totalItemRewardCount / (float)num;
					}
					else
					{
						usersItemCredit.Add(instance.networkUser.id, (float)totalItemRewardCount / (float)num);
					}
					Log.LogDebug(instance.networkUser.userName + " itemCredit: " + usersItemCredit[instance.networkUser.id]);
				}
			}
			totalItemRewardCount = 0;
		}

		private void PickupDropletController_OnCollisionEnter(orig_OnCollisionEnter orig, PickupDropletController self, Collision collision)
		{
			mostRecentlyCreatedPickup = null;
			orig.Invoke(self, collision);
			if (BepConfig.Enabled.Value && (Object)(object)mostRecentlyCreatedPickup != (Object)null && Object.op_Implicit((Object)(object)((Component)self).GetComponent<NonShareableItem>()))
			{
				mostRecentlyCreatedPickup.AddComponent<NonShareableItem>();
			}
		}

		private void PickupPickerController_CreatePickup_PickupIndex(orig_CreatePickup_PickupIndex orig, PickupPickerController self, PickupIndex pickupIndex)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			mostRecentlyCreatedPickup = null;
			orig.Invoke(self, pickupIndex);
			if (BepConfig.Enabled.Value && (Object)(object)mostRecentlyCreatedPickup != (Object)null && Object.op_Implicit((Object)(object)((Component)self).GetComponent<NonShareableItem>()))
			{
				mostRecentlyCreatedPickup.AddComponent<NonShareableItem>();
			}
		}

		private void CommandArtifactManager_OnDropletHitGroundServer(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			val.DefineLabel();
			val.GotoNext(new Func<Instruction, bool>[6]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<CreatePickupInfo>(x, "position"),
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<CreatePickupInfo>(x, "rotation"),
				(Instruction x) => ILPatternMatchingExt.MatchCall<Object>(x, "Instantiate"),
				(Instruction x) => ILPatternMatchingExt.MatchDup(x)
			});
			val.Index += 5;
			val.EmitDelegate<Func<GameObject, GameObject>>((Func<GameObject, GameObject>)delegate(GameObject obj)
			{
				mostRecentlyCreatedPickup = obj;
				return obj;
			});
		}

		private void GenericPickupController_CreatePickup(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			val.DefineLabel();
			val.GotoNext(new Func<Instruction, bool>[6]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<CreatePickupInfo>(x, "position"),
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<CreatePickupInfo>(x, "rotation"),
				(Instruction x) => ILPatternMatchingExt.MatchCall<Object>(x, "Instantiate"),
				(Instruction x) => ILPatternMatchingExt.MatchDup(x)
			});
			val.Index += 5;
			val.EmitDelegate<Func<GameObject, GameObject>>((Func<GameObject, GameObject>)delegate(GameObject obj)
			{
				mostRecentlyCreatedPickup = obj;
				return obj;
			});
		}

		private bool SkipWithPowerBias(float costMultipliedByMaximumNumberToSpawnBeforeSkipping, CombatDirector combatDirector, float powerBias)
		{
			if (costMultipliedByMaximumNumberToSpawnBeforeSkipping / (float)combatDirector.maximumNumberToSpawnBeforeSkipping > (float)combatDirector.mostExpensiveMonsterCostInDeck * (0.5f + powerBias) * (0.5f + powerBias) * (0.5f + powerBias))
			{
				float num = Math.Max(0f, 0.1f - powerBias);
				if (2f * (0.5f - powerBias) - num > RoR2Application.rng.nextNormalizedFloat)
				{
					return true;
				}
			}
			return costMultipliedByMaximumNumberToSpawnBeforeSkipping * (1.5f - powerBias) * (1.5f - powerBias) < combatDirector.monsterCredit;
		}

		private void CombatDirector_AttemptSpawnOnTarget(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ILLabel val2 = val.DefineLabel();
			val.GotoNext(new Func<Instruction, bool>[7]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 1),
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<CombatDirector>(x, "maximumNumberToSpawnBeforeSkipping"),
				(Instruction x) => ILPatternMatchingExt.MatchMul(x),
				(Instruction x) => ILPatternMatchingExt.MatchConvR4(x),
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<CombatDirector>(x, "monsterCredit")
			});
			val.Index += 6;
			val.Remove();
			val.Remove();
			val.EmitDelegate<Func<float, CombatDirector, bool>>((Func<float, CombatDirector, bool>)delegate(float costMultipliedByMaximumNumberToSpawnBeforeSkipping, CombatDirector combatDirector)
			{
				if (directorEnemyPowerBiasOverride >= 0f)
				{
					return SkipWithPowerBias(costMultipliedByMaximumNumberToSpawnBeforeSkipping, combatDirector, directorEnemyPowerBiasOverride);
				}
				if (((object)Run.instance).GetType() == typeof(InfiniteTowerRun) && BepConfig.Enabled.Value)
				{
					return SkipWithPowerBias(costMultipliedByMaximumNumberToSpawnBeforeSkipping, combatDirector, BepConfig.SimulacrumDirectorEnemyPowerBias.Value);
				}
				return BepConfig.Enabled.Value ? SkipWithPowerBias(costMultipliedByMaximumNumberToSpawnBeforeSkipping, combatDirector, BepConfig.ClassicDirectorEnemyPowerBias.Value) : (costMultipliedByMaximumNumberToSpawnBeforeSkipping < combatDirector.monsterCredit);
			});
			val.Emit(OpCodes.Brfalse, (object)val2);
			val.GotoNext(new Func<Instruction, bool>[4]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<CombatDirector>(x, "currentMonsterCard"),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<DirectorCard>(x, "spawnCard"),
				(Instruction x) => ILPatternMatchingExt.MatchStloc(x, 4)
			});
			val.MarkLabel(val2);
		}

		private void InfiniteTowerRun_OnWaveAllEnemiesDefeatedServer(orig_OnWaveAllEnemiesDefeatedServer orig, InfiniteTowerRun self, InfiniteTowerWaveController wc)
		{
			orig.Invoke(self, wc);
			if (BepConfig.Enabled.Value && NetworkServer.active && !(BepConfig.SimulacrumCommencementArtifactDissonanceChance.Value <= 0f) && (EnumCollection.SceneNameIsStage(SceneCatalog.currentSceneDef.cachedName, EnumCollection.StageEnum.SimulacrumCommencement) || EnumCollection.SceneNameIsStage(SceneCatalog.currentSceneDef.cachedName, EnumCollection.StageEnum.Commencement)))
			{
				RunArtifactManager.instance.SetArtifactEnabledServer(EnumCollection.GetArtifactDef(EnumCollection.ArtifactEnum.Dissonance), false);
			}
		}

		private void InfiniteTowerRun_AdvanceWave(orig_AdvanceWave orig, InfiniteTowerRun self)
		{
			orig.Invoke(self);
			if (BepConfig.Enabled.Value && NetworkServer.active && !(BepConfig.SimulacrumCommencementArtifactDissonanceChance.Value <= 0f) && (EnumCollection.SceneNameIsStage(SceneCatalog.currentSceneDef.cachedName, EnumCollection.StageEnum.SimulacrumCommencement) || EnumCollection.SceneNameIsStage(SceneCatalog.currentSceneDef.cachedName, EnumCollection.StageEnum.Commencement)) && BepConfig.SimulacrumCommencementArtifactDissonanceChance.Value > RoR2Application.rng.nextNormalizedFloat)
			{
				RunArtifactManager.instance.SetArtifactEnabledServer(EnumCollection.GetArtifactDef(EnumCollection.ArtifactEnum.Dissonance), true);
			}
		}

		private PickupIndex RandomlyLunarUtils_CheckForLunarReplacement(orig_CheckForLunarReplacement orig, PickupIndex pickupIndex, Xoroshiro128Plus rng)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: 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_0018: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: 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_0064: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			pickupIndex = orig.Invoke(pickupIndex, rng);
			if (!BepConfig.Enabled.Value)
			{
				return pickupIndex;
			}
			PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex);
			if (pickupDef.isLunar && (!BepConfig.NoPearlsInBazaar.Value || !EnumCollection.SceneNameIsStage(SceneCatalog.currentSceneDef.cachedName, EnumCollection.StageEnum.Bazaar)))
			{
				float nextNormalizedFloat = rng.nextNormalizedFloat;
				if (nextNormalizedFloat < BepConfig.IrradiantPearlReplacesLunarItemChance.Value)
				{
					pickupIndex = PickupCatalog.FindPickupIndex(ItemCatalog.FindItemIndex("ShinyPearl"));
				}
				else if (nextNormalizedFloat < BepConfig.IrradiantPearlReplacesLunarItemChance.Value + BepConfig.PearlReplacesLunarItemChance.Value)
				{
					pickupIndex = PickupCatalog.FindPickupIndex(ItemCatalog.FindItemIndex("Pearl"));
				}
				return pickupIndex;
			}
			if (Object.op_Implicit((Object)(object)EquipmentCatalog.GetEquipmentDef(pickupDef.equipmentIndex)) && !pickupDef.isLunar && EnumCollection.SceneNameIsStage(SceneCatalog.currentSceneDef.cachedName, EnumCollection.StageEnum.Bazaar) && rng.nextNormalizedFloat < BepConfig.BazaarEliteAspectReplacesEquipmentChance.Value)
			{
				List<PickupIndex> list = new List<PickupIndex>();
				string[] array = new string[7] { "EliteEarthEquipment", "EliteFireEquipment", "EliteIceEquipment", "ElitePoisonEquipment", "EliteLunarEquipment", "EliteLightningEquipment", "EliteHauntedEquipment" };
				for (int i = 0; i < array.Length; i++)
				{
					EquipmentIndex val = EquipmentCatalog.FindEquipmentIndex(array[i]);
					list.Add(PickupCatalog.FindPickupIndex(val));
				}
				if (list != null && list.Count > 0)
				{
					int index = rng.RangeInt(0, list.Count);
					pickupIndex = list[index];
				}
			}
			return pickupIndex;
		}

		private void RandomlyLunarUtils_CheckForLunarReplacementUniqueArray(orig_CheckForLunarReplacementUniqueArray orig, PickupIndex[] pickupIndices, Xoroshiro128Plus rng)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: 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_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(pickupIndices, rng);
			if (!BepConfig.Enabled.Value)
			{
				return;
			}
			List<PickupIndex> list = new List<PickupIndex>();
			string[] array = new string[7] { "EliteEarthEquipment", "EliteFireEquipment", "EliteIceEquipment", "ElitePoisonEquipment", "EliteLunarEquipment", "EliteLightningEquipment", "EliteHauntedEquipment" };
			for (int i = 0; i < array.Length; i++)
			{
				EquipmentIndex val = EquipmentCatalog.FindEquipmentIndex(array[i]);
				list.Add(PickupCatalog.FindPickupIndex(val));
			}
			bool flag = false;
			for (int j = 0; j < pickupIndices.Length; j++)
			{
				PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndices[j]);
				if (pickupDef.isLunar && (!BepConfig.NoPearlsInBazaar.Value || !EnumCollection.SceneNameIsStage(SceneCatalog.currentSceneDef.cachedName, EnumCollection.StageEnum.Bazaar)))
				{
					float nextNormalizedFloat = rng.nextNormalizedFloat;
					if (nextNormalizedFloat < BepConfig.IrradiantPearlReplacesLunarItemChance.Value)
					{
						pickupIndices[j] = PickupCatalog.FindPickupIndex(ItemCatalog.FindItemIndex("ShinyPearl"));
					}
					else if (nextNormalizedFloat < BepConfig.IrradiantPearlReplacesLunarItemChance.Value + BepConfig.PearlReplacesLunarItemChance.Value)
					{
						pickupIndices[j] = PickupCatalog.FindPickupIndex(ItemCatalog.FindItemIndex("Pearl"));
					}
				}
				if (Object.op_Implicit((Object)(object)EquipmentCatalog.GetEquipmentDef(pickupDef.equipmentIndex)) && !pickupDef.isLunar && list != null && list.Count > 0 && EnumCollection.SceneNameIsStage(SceneCatalog.currentSceneDef.cachedName, EnumCollection.StageEnum.Bazaar) && rng.nextNormalizedFloat < BepConfig.BazaarEliteAspectReplacesEquipmentChance.Value)
				{
					if (!flag)
					{
						Util.ShuffleList<PickupIndex>(list, rng);
						flag = true;
					}
					pickupIndices[j] = list[j % list.Count];
				}
			}
		}
	}
}

SimulacrumBossStageMod.dll

Decompiled 6 months 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 BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HG.Reflection;
using IL.RoR2;
using InLobbyConfig;
using InLobbyConfig.Fields;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.RoR2;
using R2API.Utils;
using RoR2;
using ServerSideTweaks;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ServerSideTweaks
{
	public static class ModCompatibilityServerSideTweaks
	{
		private static bool? _enabled;

		public static bool enabled
		{
			get
			{
				if (!_enabled.HasValue)
				{
					_enabled = Chainloader.PluginInfos.ContainsKey("Def.ServerSideTweaks");
				}
				return _enabled.Value;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void SetOverridePowerBias(float powerBias)
		{
			ServerSideTweaks.SetOverridePowerBias(powerBias);
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static float GetCurrentPowerBias()
		{
			return ServerSideTweaks.GetCurrentPowerBias();
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void ResetOverridePowerBias()
		{
			ServerSideTweaks.ResetOverridePowerBias();
		}
	}
}
namespace SimulacrumBossStageMod
{
	public class BepConfig
	{
		public static ConfigEntry<EnumCollection.ArtifactEnum> Artifact1;

		public static ConfigEntry<int> Artifact1StartWave;

		public static ConfigEntry<int> Artifact1EndWave;

		public static ConfigEntry<EnumCollection.ArtifactEnum> Artifact2;

		public static ConfigEntry<int> Artifact2StartWave;

		public static ConfigEntry<int> Artifact2EndWave;

		public static ConfigEntry<EnumCollection.ArtifactEnum> Artifact3;

		public static ConfigEntry<int> Artifact3StartWave;

		public static ConfigEntry<int> Artifact3EndWave;

		public static ConfigEntry<EnumCollection.ArtifactEnum> Artifact4;

		public static ConfigEntry<int> Artifact4StartWave;

		public static ConfigEntry<int> Artifact4EndWave;

		public static ConfigEntry<float> DifficultyMultiplier1;

		public static ConfigEntry<int> DifficultyMultiplier1StartWave;

		public static ConfigEntry<int> DifficultyMultiplier1EndWave;

		public static ConfigEntry<float> DifficultyMultiplier2;

		public static ConfigEntry<int> DifficultyMultiplier2StartWave;

		public static ConfigEntry<int> DifficultyMultiplier2EndWave;

		public static ConfigEntry<float> DifficultyMultiplier3;

		public static ConfigEntry<int> DifficultyMultiplier3StartWave;

		public static ConfigEntry<int> DifficultyMultiplier3EndWave;

		public static ConfigEntry<float> DifficultyMultiplier4;

		public static ConfigEntry<int> DifficultyMultiplier4StartWave;

		public static ConfigEntry<int> DifficultyMultiplier4EndWave;

		public static ConfigEntry<EnumCollection.StageEnum> BossStage;

		public static ConfigEntry<int> BossStageStartWave;

		public static ConfigEntry<bool> BossStageTier2Elite;

		public static ConfigEntry<EnumCollection.BossEnum> BossStageBoss;

		public static ConfigEntry<EnumCollection.EliteEnum> BossStageBossElite;

		public static ConfigEntry<int> BossStageBossCount;

		public static ConfigEntry<float> BossStageBossRadius;

		public static ConfigEntry<int> BossStageLunarCoinsReward;

		public static ConfigEntry<bool> BossStageCompleteEndRun;

		public static ConfigEntry<bool> Enabled { get; set; }

		public static void Init()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Expected O, but got Unknown
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Expected O, but got Unknown
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Expected O, but got Unknown
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Expected O, but got Unknown
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Expected O, but got Unknown
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Expected O, but got Unknown
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Expected O, but got Unknown
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Expected O, but got Unknown
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Expected O, but got Unknown
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Expected O, but got Unknown
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Expected O, but got Unknown
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Expected O, but got Unknown
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Expected O, but got Unknown
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Expected O, but got Unknown
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Expected O, but got Unknown
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Expected O, but got Unknown
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Expected O, but got Unknown
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Expected O, but got Unknown
			//IL_0371: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Expected O, but got Unknown
			//IL_0398: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a2: Expected O, but got Unknown
			//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c9: Expected O, but got Unknown
			//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Expected O, but got Unknown
			//IL_0410: Unknown result type (might be due to invalid IL or missing references)
			//IL_041a: Expected O, but got Unknown
			//IL_0437: Unknown result type (might be due to invalid IL or missing references)
			//IL_0441: Expected O, but got Unknown
			//IL_0461: Unknown result type (might be due to invalid IL or missing references)
			//IL_046b: Expected O, but got Unknown
			//IL_0488: Unknown result type (might be due to invalid IL or missing references)
			//IL_0492: Expected O, but got Unknown
			//IL_04af: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b9: Expected O, but got Unknown
			//IL_04d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e3: Expected O, but got Unknown
			//IL_0500: Unknown result type (might be due to invalid IL or missing references)
			//IL_050a: Expected O, but got Unknown
			//IL_0527: Unknown result type (might be due to invalid IL or missing references)
			//IL_0531: Expected O, but got Unknown
			ConfigFile config = ((BaseUnityPlugin)SimulacrumBossStageMod.instance).Config;
			Enabled = config.Bind<bool>("Main", "Enabled", true, "Enable Mod");
			BossStage = config.Bind<EnumCollection.StageEnum>("Boss Stage", "Boss Stage", EnumCollection.StageEnum.VoidLocus, new ConfigDescription("To which stage to warp.", (AcceptableValueBase)null, Array.Empty<object>()));
			BossStageStartWave = config.Bind<int>("Boss Stage", "Boss Stage Warp Wave", 40, new ConfigDescription("At which wave to warp to this stage. Must be multiple of 10.", (AcceptableValueBase)null, Array.Empty<object>()));
			BossStageTier2Elite = config.Bind<bool>("Boss Stage", "Malachite Elites", true, new ConfigDescription("Enables Malachite elites once the boss stage has been reached.", (AcceptableValueBase)null, Array.Empty<object>()));
			BossStageBoss = config.Bind<EnumCollection.BossEnum>("Boss Stage", "Boss", EnumCollection.BossEnum.VoidlingPhase3, new ConfigDescription("Which boss to spawn during the final boss stage wave.", (AcceptableValueBase)null, Array.Empty<object>()));
			BossStageBossElite = config.Bind<EnumCollection.EliteEnum>("Boss Stage", "Boss Elite Aspect", EnumCollection.EliteEnum.Mending, new ConfigDescription("Which elite aspect the boss shall have.", (AcceptableValueBase)null, Array.Empty<object>()));
			BossStageBossCount = config.Bind<int>("Boss Stage", "Boss Count", 1, new ConfigDescription("How many bosses to spawn during the final boss stage wave.", (AcceptableValueBase)null, Array.Empty<object>()));
			BossStageBossRadius = config.Bind<float>("Boss Stage", "Boss Battleground Radius", 1.4f, new ConfigDescription("Whether to increase or decrease the normal radius of the battleground for the final boss stage wave (1.0 = vanilla).", (AcceptableValueBase)null, Array.Empty<object>()));
			BossStageLunarCoinsReward = config.Bind<int>("Boss Stage", "Boss Stage Lunar Coins Reward", 100, new ConfigDescription("How many Lunar Coins to drop once the final stage has been completed.", (AcceptableValueBase)null, Array.Empty<object>()));
			BossStageCompleteEndRun = config.Bind<bool>("Boss Stage", "Completing Boss Stage ends Run", true, new ConfigDescription("If the boss stage is completed, the run will end.", (AcceptableValueBase)null, Array.Empty<object>()));
			Artifact1 = config.Bind<EnumCollection.ArtifactEnum>("Artifacts", "Artifact A", EnumCollection.ArtifactEnum.Dissonance, new ConfigDescription("Which artifact to add.", (AcceptableValueBase)null, Array.Empty<object>()));
			Artifact1StartWave = config.Bind<int>("Artifacts", "Artifact A Start Wave", 41, new ConfigDescription("At which wave to add this artifact.", (AcceptableValueBase)null, Array.Empty<object>()));
			Artifact1EndWave = config.Bind<int>("Artifacts", "Artifact A End Wave", 45, new ConfigDescription("After which wave to remove this artifact.", (AcceptableValueBase)null, Array.Empty<object>()));
			Artifact2 = config.Bind<EnumCollection.ArtifactEnum>("Artifacts", "Artifact B", EnumCollection.ArtifactEnum.Honor, new ConfigDescription("Which artifact to add.", (AcceptableValueBase)null, Array.Empty<object>()));
			Artifact2StartWave = config.Bind<int>("Artifacts", "Artifact B Start Wave", 45, new ConfigDescription("At which wave to add this artifact.", (AcceptableValueBase)null, Array.Empty<object>()));
			Artifact2EndWave = config.Bind<int>("Artifacts", "Artifact B End Wave", 45, new ConfigDescription("After which wave to remove this artifact.", (AcceptableValueBase)null, Array.Empty<object>()));
			Artifact3 = config.Bind<EnumCollection.ArtifactEnum>("Artifacts", "Artifact C", EnumCollection.ArtifactEnum.Honor, new ConfigDescription("Which artifact to add.", (AcceptableValueBase)null, Array.Empty<object>()));
			Artifact3StartWave = config.Bind<int>("Artifacts", "Artifact C Start Wave", 50, new ConfigDescription("At which wave to add this artifact.", (AcceptableValueBase)null, Array.Empty<object>()));
			Artifact3EndWave = config.Bind<int>("Artifacts", "Artifact C End Wave", 50, new ConfigDescription("After which wave to remove this artifact.", (AcceptableValueBase)null, Array.Empty<object>()));
			Artifact4 = config.Bind<EnumCollection.ArtifactEnum>("Artifacts", "Artifact D", EnumCollection.ArtifactEnum.None, new ConfigDescription("Which artifact to add.", (AcceptableValueBase)null, Array.Empty<object>()));
			Artifact4StartWave = config.Bind<int>("Artifacts", "Artifact D Start Wave", 50, new ConfigDescription("At which wave to add this artifact.", (AcceptableValueBase)null, Array.Empty<object>()));
			Artifact4EndWave = config.Bind<int>("Artifacts", "Artifact D End Wave", 50, new ConfigDescription("After which wave to remove this artifact.", (AcceptableValueBase)null, Array.Empty<object>()));
			DifficultyMultiplier1 = config.Bind<float>("Difficulty", "DifficultyMultiplier A", 1.25f, new ConfigDescription("Which DifficultyMultiplier to add.", (AcceptableValueBase)null, Array.Empty<object>()));
			DifficultyMultiplier1StartWave = config.Bind<int>("Difficulty", "DifficultyMultiplier A Start Wave", 41, new ConfigDescription("At which wave to add this DifficultyMultiplier.", (AcceptableValueBase)null, Array.Empty<object>()));
			DifficultyMultiplier1EndWave = config.Bind<int>("Difficulty", "DifficultyMultiplier A End Wave", 49, new ConfigDescription("After which wave to remove this DifficultyMultiplier.", (AcceptableValueBase)null, Array.Empty<object>()));
			DifficultyMultiplier2 = config.Bind<float>("Difficulty", "DifficultyMultiplier B", 1.5f, new ConfigDescription("Which DifficultyMultiplier to add.", (AcceptableValueBase)null, Array.Empty<object>()));
			DifficultyMultiplier2StartWave = config.Bind<int>("Difficulty", "DifficultyMultiplier B Start Wave", 50, new ConfigDescription("At which wave to add this DifficultyMultiplier.", (AcceptableValueBase)null, Array.Empty<object>()));
			DifficultyMultiplier2EndWave = config.Bind<int>("Difficulty", "DifficultyMultiplier B End Wave", 50, new ConfigDescription("After which wave to remove this DifficultyMultiplier.", (AcceptableValueBase)null, Array.Empty<object>()));
			DifficultyMultiplier3 = config.Bind<float>("Difficulty", "DifficultyMultiplier C", 1f, new ConfigDescription("Which DifficultyMultiplier to add.", (AcceptableValueBase)null, Array.Empty<object>()));
			DifficultyMultiplier3StartWave = config.Bind<int>("Difficulty", "DifficultyMultiplier C Start Wave", 50, new ConfigDescription("At which wave to add this DifficultyMultiplier.", (AcceptableValueBase)null, Array.Empty<object>()));
			DifficultyMultiplier3EndWave = config.Bind<int>("Difficulty", "DifficultyMultiplier C End Wave", 50, new ConfigDescription("After which wave to remove this DifficultyMultiplier.", (AcceptableValueBase)null, Array.Empty<object>()));
			DifficultyMultiplier4 = config.Bind<float>("Difficulty", "DifficultyMultiplier D", 1f, new ConfigDescription("Which DifficultyMultiplier to add.", (AcceptableValueBase)null, Array.Empty<object>()));
			DifficultyMultiplier4StartWave = config.Bind<int>("Difficulty", "DifficultyMultiplier D Start Wave", 50, new ConfigDescription("At which wave to add this DifficultyMultiplier.", (AcceptableValueBase)null, Array.Empty<object>()));
			DifficultyMultiplier4EndWave = config.Bind<int>("Difficulty", "DifficultyMultiplier D End Wave", 50, new ConfigDescription("After which wave to remove this DifficultyMultiplier.", (AcceptableValueBase)null, Array.Empty<object>()));
			if (ModCompatibilityInLobbyConfig.enabled)
			{
				ModCompatibilityInLobbyConfig.CreateFromBepInExConfigFile(config, "Simulacrum Boss Stage");
			}
		}
	}
	public class EnumCollection
	{
		public enum BossEnum
		{
			None,
			AlloyVulture,
			AlloyWorshipUnit,
			AlphaConstruct,
			Aurelionite,
			Beetle,
			BeetleGuard,
			BeetleQueen,
			BighornBison,
			BlindPest,
			BlindVermin,
			BrassContraption,
			ClayApothecary,
			ClayDunestrider,
			ClayTemplar,
			ElderLemurian,
			Geep,
			Gip,
			Grandparent,
			GreaterWisp,
			Grovetender,
			Gup,
			HermitCrab,
			Imp,
			ImpOverlord,
			Jellyfish,
			Larva,
			Lemurian,
			LesserWisp,
			LunarChimeraExploder,
			LunarChimeraGolem,
			LunarChimeraWisp,
			MagmaWorm,
			MiniMushrum,
			MithrixPhase1,
			MithrixPhase4,
			MithrixSimulacrum,
			OverloadingWorm,
			Parent,
			Scavenger,
			SolusControlUnit,
			SolusProbe,
			StoneGolem,
			StoneTitan,
			TwistedScavenger,
			VoidBarnacle,
			VoidDevastator,
			VoidJailer,
			VoidReaver,
			VoidlingPhase1,
			VoidlingPhase2,
			VoidlingPhase3,
			WanderingVagrant,
			XiConstruct
		}

		public enum EliteEnum
		{
			None,
			Blazing,
			Overloading,
			Glacial,
			Mending,
			Malachite,
			Celestine,
			Perfected,
			Voidtouched
		}

		public enum ArtifactEnum
		{
			None,
			Chaos,
			Command,
			Death,
			Dissonance,
			Enigma,
			Evolution,
			Frailty,
			Glass,
			Honor,
			Kin,
			Metamorphosis,
			Sacrifice,
			Soul,
			Spite,
			Swarms,
			Vengeance
		}

		public enum StageEnum
		{
			None,
			TitanicPlains,
			DistantRoost,
			WetlandAspect,
			AbandonedAqueduct,
			RallypointDelta,
			ScorchedAcres,
			AbyssalDepths,
			SirensCall,
			GildedCoast,
			MomentFractured,
			Bazaar,
			VoidFields,
			MomentWhole,
			SkyMeadow,
			BullwarksAmbry,
			Commencement,
			SunderedGrove,
			VoidLocus,
			Planetarium,
			AphelianSanctuary,
			SimulacrumAbandonedAquaduct,
			SimulacrumAbyssalDepths,
			SimulacrumAphelianSanctuary,
			SimulacrumCommencement,
			SimulacrumRallypointDelta,
			SimulacrumSkyMeadow,
			SimulacrumTitanicPlains,
			SiphonedForest,
			SulfurPools
		}

		public static Dictionary<BossEnum, string> BossNames = new Dictionary<BossEnum, string>
		{
			{
				BossEnum.AlloyVulture,
				"RoR2/Base/Vulture/cscVulture.asset"
			},
			{
				BossEnum.AlloyWorshipUnit,
				"RoR2/Base/RoboBallBoss/cscSuperRoboBallBoss.asset"
			},
			{
				BossEnum.AlphaConstruct,
				"RoR2/DLC1/MajorAndMinorConstruct/cscMinorConstruct.asset"
			},
			{
				BossEnum.Aurelionite,
				"RoR2/Base/Titan/cscTitanGold.asset"
			},
			{
				BossEnum.Beetle,
				"RoR2/Base/Beetle/cscBeetle.asset"
			},
			{
				BossEnum.BeetleGuard,
				"RoR2/Base/Beetle/cscBeetleGuard.asset"
			},
			{
				BossEnum.BeetleQueen,
				"RoR2/Base/Beetle/cscBeetleQueen.asset"
			},
			{
				BossEnum.BighornBison,
				"RoR2/Base/Bison/cscBison.asset"
			},
			{
				BossEnum.BlindPest,
				"RoR2/DLC1/FlyingVermin/cscFlyingVermin.asset"
			},
			{
				BossEnum.BlindVermin,
				"RoR2/DLC1/Vermin/cscVermin.asset"
			},
			{
				BossEnum.BrassContraption,
				"RoR2/Base/Bell/cscBell.asset"
			},
			{
				BossEnum.ClayApothecary,
				"RoR2/DLC1/ClayGrenadier/cscClayGrenadier.asset"
			},
			{
				BossEnum.ClayDunestrider,
				"RoR2/Base/ClayBoss/cscClayBoss.asset"
			},
			{
				BossEnum.ClayTemplar,
				"RoR2/Base/ClayBruiser/cscClayBruiser.asset"
			},
			{
				BossEnum.ElderLemurian,
				"RoR2/Base/LemurianBruiser/cscLemurianBruiser.asset"
			},
			{
				BossEnum.Geep,
				"RoR2/DLC1/Gup/cscGeepBody.asset"
			},
			{
				BossEnum.Gip,
				"RoR2/DLC1/Gup/cscGipBody.asset"
			},
			{
				BossEnum.Grandparent,
				"RoR2/Base/Grandparent/cscGrandparent.asset"
			},
			{
				BossEnum.GreaterWisp,
				"RoR2/Base/GreaterWisp/cscGreaterWisp.asset"
			},
			{
				BossEnum.Grovetender,
				"RoR2/Base/Gravekeeper/cscGravekeeper.asset"
			},
			{
				BossEnum.Gup,
				"RoR2/DLC1/Gup/cscGupBody.asset"
			},
			{
				BossEnum.HermitCrab,
				"RoR2/Base/HermitCrab/cscHermitCrab.asset"
			},
			{
				BossEnum.Imp,
				"RoR2/Base/Imp/cscImp.asset"
			},
			{
				BossEnum.ImpOverlord,
				"RoR2/Base/ImpBoss/cscImpBoss.asset"
			},
			{
				BossEnum.Jellyfish,
				"RoR2/Base/Jellyfish/cscJellyfish.asset"
			},
			{
				BossEnum.Larva,
				"RoR2/DLC1/AcidLarva/cscAcidLarva.asset"
			},
			{
				BossEnum.Lemurian,
				"RoR2/Base/Lemurian/cscLemurian.asset"
			},
			{
				BossEnum.LesserWisp,
				"RoR2/Base/Wisp/cscLesserWisp.asset"
			},
			{
				BossEnum.LunarChimeraExploder,
				"RoR2/Base/LunarExploder/cscLunarExploder.asset"
			},
			{
				BossEnum.LunarChimeraGolem,
				"RoR2/Base/LunarGolem/cscLunarGolem.asset"
			},
			{
				BossEnum.LunarChimeraWisp,
				"RoR2/Base/LunarWisp/cscLunarWisp.asset"
			},
			{
				BossEnum.MagmaWorm,
				"RoR2/Base/MagmaWorm/cscMagmaWorm.asset"
			},
			{
				BossEnum.MiniMushrum,
				"RoR2/Base/MiniMushroom/cscMiniMushroom.asset"
			},
			{
				BossEnum.MithrixPhase1,
				"RoR2/Base/Brother/cscBrother.asset"
			},
			{
				BossEnum.MithrixPhase4,
				"RoR2/Base/Brother/cscBrotherHurt.asset"
			},
			{
				BossEnum.MithrixSimulacrum,
				"RoR2/DLC1/GameModes/InfiniteTowerRun/InfiniteTowerAssets/cscBrotherIT.asset"
			},
			{
				BossEnum.OverloadingWorm,
				"RoR2/Base/ElectricWorm/cscElectricWorm.asset"
			},
			{
				BossEnum.Parent,
				"RoR2/Base/Parent/cscParent.asset"
			},
			{
				BossEnum.Scavenger,
				"RoR2/Base/Scav/cscScav.asset"
			},
			{
				BossEnum.SolusControlUnit,
				"RoR2/Base/RoboBallBoss/cscRoboBallBoss.asset"
			},
			{
				BossEnum.SolusProbe,
				"RoR2/Base/RoboBallBoss/cscRoboBallMini.asset"
			},
			{
				BossEnum.StoneGolem,
				"RoR2/Base/Golem/cscGolem.asset"
			},
			{
				BossEnum.StoneTitan,
				"RoR2/Base/Titan/cscTitanGolemPlains.asset"
			},
			{
				BossEnum.TwistedScavenger,
				"RoR2/Base/Scav/cscScavBoss.asset"
			},
			{
				BossEnum.VoidBarnacle,
				"RoR2/DLC1/VoidBarnacle/cscVoidBarnacle.asset"
			},
			{
				BossEnum.VoidDevastator,
				"RoR2/DLC1/VoidMegaCrab/cscVoidMegaCrab.asset"
			},
			{
				BossEnum.VoidJailer,
				"RoR2/DLC1/VoidJailer/cscVoidJailer.asset"
			},
			{
				BossEnum.VoidReaver,
				"RoR2/Base/Nullifier/cscNullifier.asset"
			},
			{
				BossEnum.VoidlingPhase1,
				"RoR2/DLC1/VoidRaidCrab/cscMiniVoidRaidCrabPhase1.asset"
			},
			{
				BossEnum.VoidlingPhase2,
				"RoR2/DLC1/VoidRaidCrab/cscMiniVoidRaidCrabPhase2.asset"
			},
			{
				BossEnum.VoidlingPhase3,
				"RoR2/DLC1/VoidRaidCrab/cscMiniVoidRaidCrabPhase3.asset"
			},
			{
				BossEnum.WanderingVagrant,
				"RoR2/Base/Vagrant/cscVagrant.asset"
			},
			{
				BossEnum.XiConstruct,
				"RoR2/DLC1/MajorAndMinorConstruct/cscMegaConstruct.asset"
			}
		};

		public static Dictionary<EliteEnum, EliteDef> EliteDefs = new Dictionary<EliteEnum, EliteDef>
		{
			{
				EliteEnum.Blazing,
				((IEnumerable<EliteDef>)EliteCatalog.eliteDefs).FirstOrDefault((Func<EliteDef, bool>)((EliteDef obj) => ((Object)obj).name == "edFire"))
			},
			{
				EliteEnum.Overloading,
				((IEnumerable<EliteDef>)EliteCatalog.eliteDefs).FirstOrDefault((Func<EliteDef, bool>)((EliteDef obj) => ((Object)obj).name == "edLightning"))
			},
			{
				EliteEnum.Glacial,
				((IEnumerable<EliteDef>)EliteCatalog.eliteDefs).FirstOrDefault((Func<EliteDef, bool>)((EliteDef obj) => ((Object)obj).name == "edIce"))
			},
			{
				EliteEnum.Mending,
				((IEnumerable<EliteDef>)EliteCatalog.eliteDefs).FirstOrDefault((Func<EliteDef, bool>)((EliteDef obj) => ((Object)obj).name == "edEarth"))
			},
			{
				EliteEnum.Malachite,
				((IEnumerable<EliteDef>)EliteCatalog.eliteDefs).FirstOrDefault((Func<EliteDef, bool>)((EliteDef obj) => ((Object)obj).name == "edPoison"))
			},
			{
				EliteEnum.Celestine,
				((IEnumerable<EliteDef>)EliteCatalog.eliteDefs).FirstOrDefault((Func<EliteDef, bool>)((EliteDef obj) => ((Object)obj).name == "edHaunted"))
			},
			{
				EliteEnum.Perfected,
				((IEnumerable<EliteDef>)EliteCatalog.eliteDefs).FirstOrDefault((Func<EliteDef, bool>)((EliteDef obj) => ((Object)obj).name == "edLunar"))
			},
			{
				EliteEnum.Voidtouched,
				((IEnumerable<EliteDef>)EliteCatalog.eliteDefs).FirstOrDefault((Func<EliteDef, bool>)((EliteDef obj) => ((Object)obj).name == "edVoid"))
			}
		};

		public static Dictionary<StageEnum, List<string>> SceneNames = new Dictionary<StageEnum, List<string>>
		{
			{
				StageEnum.TitanicPlains,
				new List<string> { "golemplains", "golemplains2", "golemplains trailer" }
			},
			{
				StageEnum.DistantRoost,
				new List<string> { "blackbeach", "blackbeach2", "blackbeachTest" }
			},
			{
				StageEnum.WetlandAspect,
				new List<string> { "foggyswamp" }
			},
			{
				StageEnum.AbandonedAqueduct,
				new List<string> { "goolake" }
			},
			{
				StageEnum.RallypointDelta,
				new List<string> { "frozenwall" }
			},
			{
				StageEnum.ScorchedAcres,
				new List<string> { "wispgraveyard" }
			},
			{
				StageEnum.AbyssalDepths,
				new List<string> { "dampcavesimple" }
			},
			{
				StageEnum.SirensCall,
				new List<string> { "shipgraveyard" }
			},
			{
				StageEnum.GildedCoast,
				new List<string> { "goldshores" }
			},
			{
				StageEnum.MomentFractured,
				new List<string> { "mysteryspace" }
			},
			{
				StageEnum.Bazaar,
				new List<string> { "bazaar" }
			},
			{
				StageEnum.VoidFields,
				new List<string> { "arena" }
			},
			{
				StageEnum.MomentWhole,
				new List<string> { "limbo" }
			},
			{
				StageEnum.SkyMeadow,
				new List<string> { "skymeadow" }
			},
			{
				StageEnum.BullwarksAmbry,
				new List<string> { "artifactworld" }
			},
			{
				StageEnum.Commencement,
				new List<string> { "moon", "moon2" }
			},
			{
				StageEnum.SunderedGrove,
				new List<string> { "rootjungle" }
			},
			{
				StageEnum.VoidLocus,
				new List<string> { "voidstage" }
			},
			{
				StageEnum.Planetarium,
				new List<string> { "voidraid" }
			},
			{
				StageEnum.AphelianSanctuary,
				new List<string> { "ancientloft" }
			},
			{
				StageEnum.SimulacrumAbandonedAquaduct,
				new List<string> { "itgoolake" }
			},
			{
				StageEnum.SimulacrumAbyssalDepths,
				new List<string> { "itdampcave" }
			},
			{
				StageEnum.SimulacrumAphelianSanctuary,
				new List<string> { "itancientloft" }
			},
			{
				StageEnum.SimulacrumCommencement,
				new List<string> { "itmoon" }
			},
			{
				StageEnum.SimulacrumRallypointDelta,
				new List<string> { "itfrozenwall" }
			},
			{
				StageEnum.SimulacrumSkyMeadow,
				new List<string> { "itskymeadow" }
			},
			{
				StageEnum.SimulacrumTitanicPlains,
				new List<string> { "itgolemplains" }
			},
			{
				StageEnum.SiphonedForest,
				new List<string> { "snowyforest" }
			},
			{
				StageEnum.SulfurPools,
				new List<string> { "sulfurpools" }
			}
		};

		public static T DecrementEnumValue<T>(T value) where T : struct, IConvertible
		{
			if (!typeof(T).IsEnum)
			{
				throw new ArgumentException("T must be an enumerated type");
			}
			int length = Enum.GetValues(typeof(T)).Length;
			return (T)(object)(((int)(object)value - 1 + length) % length);
		}

		public static T IncrementEnumValue<T>(T value) where T : struct, IConvertible
		{
			if (!typeof(T).IsEnum)
			{
				throw new ArgumentException("T must be an enumerated type");
			}
			int length = Enum.GetValues(typeof(T)).Length;
			return (T)(object)(((int)(object)value + 1) % length);
		}

		public static bool IsSimulacrumStage(string name)
		{
			if (GetStageName(StageEnum.SimulacrumAbandonedAquaduct) == name)
			{
				return true;
			}
			if (GetStageName(StageEnum.SimulacrumAbyssalDepths) == name)
			{
				return true;
			}
			if (GetStageName(StageEnum.SimulacrumAphelianSanctuary) == name)
			{
				return true;
			}
			if (GetStageName(StageEnum.SimulacrumCommencement) == name)
			{
				return true;
			}
			if (GetStageName(StageEnum.SimulacrumRallypointDelta) == name)
			{
				return true;
			}
			if (GetStageName(StageEnum.SimulacrumSkyMeadow) == name)
			{
				return true;
			}
			if (GetStageName(StageEnum.SimulacrumTitanicPlains) == name)
			{
				return true;
			}
			return false;
		}

		public static string GetStageName(StageEnum stageEnum)
		{
			return SceneNames[stageEnum].First();
		}

		public static ArtifactDef GetArtifactDef(ArtifactEnum artifacts)
		{
			return (ArtifactDef)(artifacts switch
			{
				ArtifactEnum.Chaos => Artifacts.FriendlyFire, 
				ArtifactEnum.Command => Artifacts.Command, 
				ArtifactEnum.Death => Artifacts.TeamDeath, 
				ArtifactEnum.Dissonance => Artifacts.MixEnemy, 
				ArtifactEnum.Enigma => Artifacts.Enigma, 
				ArtifactEnum.Evolution => Artifacts.MonsterTeamGainsItems, 
				ArtifactEnum.Frailty => Artifacts.WeakAssKnees, 
				ArtifactEnum.Glass => Artifacts.Glass, 
				ArtifactEnum.Honor => Artifacts.EliteOnly, 
				ArtifactEnum.Kin => Artifacts.SingleMonsterType, 
				ArtifactEnum.Metamorphosis => Artifacts.RandomSurvivorOnRespawn, 
				ArtifactEnum.Sacrifice => Artifacts.Sacrifice, 
				ArtifactEnum.Soul => Artifacts.WispOnDeath, 
				ArtifactEnum.Spite => Artifacts.Bomb, 
				ArtifactEnum.Swarms => Artifacts.Swarms, 
				ArtifactEnum.Vengeance => Artifacts.ShadowClone, 
				_ => null, 
			});
		}
	}
	internal static class Log
	{
		internal static ManualLogSource _logSource;

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

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

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

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

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

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

		internal static void LogWarning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	public static class ModCompatibilityInLobbyConfig
	{
		private static bool? _enabled;

		public static bool enabled
		{
			get
			{
				if (!_enabled.HasValue)
				{
					_enabled = Chainloader.PluginInfos.ContainsKey("com.KingEnderBrine.InLobbyConfig");
				}
				return _enabled.Value;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void CreateFromBepInExConfigFile(ConfigFile config, string displayName)
		{
			ModConfigCatalog.Add(ConfigFieldUtilities.CreateFromBepInExConfigFile(config, displayName));
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Def.SimulacrumBossStageMod", "SimulacrumBossStageMod", "1.2.3")]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class SimulacrumBossStageMod : BaseUnityPlugin
	{
		public static SimulacrumBossStageMod instance;

		public const string PluginGUID = "Def.SimulacrumBossStageMod";

		public const string PluginAuthor = "Def";

		public const string PluginName = "SimulacrumBossStageMod";

		public const string PluginVersion = "1.2.3";

		public AsyncOperationHandle<SpawnCard> iscVoidPortal;

		public AsyncOperationHandle<SpawnCard> iscVoidOutroPortal;

		public AsyncOperationHandle<CharacterSpawnCard> bossSpawnCard;

		public float nextBonusTime;

		public int bonusCounter;

		public bool bossStageCompleted;

		public bool bossSpawned;

		public SceneDef nextStageBeforeBoss;

		public float zoneRadiusBoss = 1f;

		public static EliteTierDef poisonEliteTier;

		public EnumCollection.BossEnum debug_enemyTypeToSpawn;

		public EnumCollection.EliteEnum debug_eliteTypeToSpawn;

		public static PluginInfo PInfo { get; private set; }

		public void Awake()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			PInfo = ((BaseUnityPlugin)this).Info;
			instance = this;
			Log.Init(((BaseUnityPlugin)this).Logger);
			BepConfig.Init();
			iscVoidPortal = Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/DLC1/PortalVoid/iscVoidPortal.asset");
			iscVoidOutroPortal = Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/DLC1/VoidOutroPortal/iscVoidOutroPortal.asset");
		}

		private void OnEnable()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			InfiniteTowerRun.Start += new hook_Start(InfiniteTowerRun_Start);
			InfiniteTowerRun.OnWaveAllEnemiesDefeatedServer += new hook_OnWaveAllEnemiesDefeatedServer(InfiniteTowerRun_OnWaveAllEnemiesDefeatedServer);
			InfiniteTowerRun.AdvanceWave += new hook_AdvanceWave(InfiniteTowerRun_AdvanceWave);
			InfiniteTowerRun.FixedUpdate += new hook_FixedUpdate(InfiniteTowerRun_FixedUpdate);
			InfiniteTowerRun.RecalculateDifficultyCoefficentInternal += new hook_RecalculateDifficultyCoefficentInternal(InfiniteTowerRun_RecalculateDifficultyCoefficentInternal);
			InfiniteTowerRun.OnWaveAllEnemiesDefeatedServer += new Manipulator(InfiniteTowerRun_OnWaveAllEnemiesDefeatedServer1);
			InfiniteTowerBossWaveController.Initialize += new hook_Initialize(InfiniteTowerBossWaveController_Initialize);
			InfiniteTowerWaveController.Initialize += new hook_Initialize(InfiniteTowerWaveController_Initialize);
			InfiniteTowerWaveController.DropRewards += new hook_DropRewards(InfiniteTowerWaveController_DropRewards);
		}

		private void OnDisable()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			InfiniteTowerRun.Start -= new hook_Start(InfiniteTowerRun_Start);
			InfiniteTowerRun.OnWaveAllEnemiesDefeatedServer -= new hook_OnWaveAllEnemiesDefeatedServer(InfiniteTowerRun_OnWaveAllEnemiesDefeatedServer);
			InfiniteTowerRun.AdvanceWave -= new hook_AdvanceWave(InfiniteTowerRun_AdvanceWave);
			InfiniteTowerRun.FixedUpdate -= new hook_FixedUpdate(InfiniteTowerRun_FixedUpdate);
			InfiniteTowerRun.RecalculateDifficultyCoefficentInternal -= new hook_RecalculateDifficultyCoefficentInternal(InfiniteTowerRun_RecalculateDifficultyCoefficentInternal);
			InfiniteTowerRun.OnWaveAllEnemiesDefeatedServer -= new Manipulator(InfiniteTowerRun_OnWaveAllEnemiesDefeatedServer1);
			InfiniteTowerBossWaveController.Initialize -= new hook_Initialize(InfiniteTowerBossWaveController_Initialize);
			InfiniteTowerWaveController.Initialize -= new hook_Initialize(InfiniteTowerWaveController_Initialize);
			InfiniteTowerWaveController.DropRewards -= new hook_DropRewards(InfiniteTowerWaveController_DropRewards);
		}

		private void InfiniteTowerRun_Start(orig_Start orig, InfiniteTowerRun self)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			bonusCounter = 0;
			nextBonusTime = 0f;
			bossSpawned = false;
			bossStageCompleted = false;
			nextStageBeforeBoss = null;
			zoneRadiusBoss = 1f;
			if (poisonEliteTier == null)
			{
				EliteTierDef val = new EliteTierDef();
				val.costMultiplier = CombatDirector.baseEliteCostMultiplier * 5f;
				val.eliteTypes = (EliteDef[])(object)new EliteDef[1] { Elites.Poison };
				val.isAvailable = (EliteRules rules) => checkEliteAvailable(rules);
				val.canSelectWithoutAvailableEliteDef = false;
				poisonEliteTier = val;
			}
			if (!CombatDirector.eliteTiers.Contains(poisonEliteTier))
			{
				Array.Resize(ref CombatDirector.eliteTiers, CombatDirector.eliteTiers.Length + 1);
				CombatDirector.eliteTiers[CombatDirector.eliteTiers.Length - 1] = poisonEliteTier;
			}
			if (ModCompatibilityServerSideTweaks.enabled)
			{
				ModCompatibilityServerSideTweaks.ResetOverridePowerBias();
			}
			if (BepConfig.Enabled.Value && BepConfig.BossStageBoss.Value != 0)
			{
				bossSpawnCard = Addressables.LoadAssetAsync<CharacterSpawnCard>((object)EnumCollection.BossNames[BepConfig.BossStageBoss.Value]);
			}
		}

		private void InfiniteTowerRun_OnWaveAllEnemiesDefeatedServer1(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			val.GotoNext(new Func<Instruction, bool>[2]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchCall<InfiniteTowerRun>(x, "IsStageTransitionWave")
			});
			val.Index += 1;
			val.Remove();
			val.EmitDelegate<Func<InfiniteTowerRun, bool>>((Func<InfiniteTowerRun, bool>)((InfiniteTowerRun self) => !IsBossStageStarted(self.waveIndex) && self.IsStageTransitionWave()));
			val.GotoNext(new Func<Instruction, bool>[4]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCall<DirectorCore>(x, "get_instance"),
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<InfiniteTowerRun>(x, "stageTransitionPortalCard"),
				(Instruction x) => ILPatternMatchingExt.MatchNewobj<DirectorPlacementRule>(x)
			});
			val.Index += 2;
			val.Remove();
			val.EmitDelegate<Func<InfiniteTowerRun, SpawnCard>>((Func<InfiniteTowerRun, SpawnCard>)delegate(InfiniteTowerRun self)
			{
				if (!BepConfig.Enabled.Value)
				{
					return (SpawnCard)(object)self.stageTransitionPortalCard;
				}
				if (BepConfig.BossStage.Value == EnumCollection.StageEnum.None)
				{
					return (SpawnCard)(object)self.stageTransitionPortalCard;
				}
				if (bossStageCompleted)
				{
					return (SpawnCard)(object)self.stageTransitionPortalCard;
				}
				if (self.waveIndex < BepConfig.BossStageStartWave.Value)
				{
					return (SpawnCard)(object)self.stageTransitionPortalCard;
				}
				self.stageTransitionPortalMaxDistance = 45f;
				return iscVoidPortal.WaitForCompletion();
			});
		}

		private static bool checkEliteAvailable(EliteRules rules)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			if (((object)Run.instance).GetType() == typeof(InfiniteTowerRun))
			{
				if (BepConfig.Enabled.Value && BepConfig.BossStageTier2Elite.Value)
				{
					return ((InfiniteTowerRun)Run.instance).waveIndex > BepConfig.BossStageStartWave.Value;
				}
				return false;
			}
			return false;
		}

		private void InfiniteTowerBossWaveController_Initialize(orig_Initialize orig, InfiniteTowerBossWaveController self, int waveIndex, Inventory enemyInventory, GameObject spawnTarget)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, waveIndex, enemyInventory, spawnTarget);
			if (waveIndex > BepConfig.BossStageStartWave.Value && BepConfig.Enabled.Value && ((InfiniteTowerRun)Run.instance).IsStageTransitionWave())
			{
				if (ModCompatibilityServerSideTweaks.enabled)
				{
					float currentPowerBias = ModCompatibilityServerSideTweaks.GetCurrentPowerBias();
					float num = Math.Max(val2: ((InfiniteTowerRun)Run.instance).IsStageTransitionWave() ? 1f : 0.9f, val1: ModCompatibilityServerSideTweaks.GetCurrentPowerBias());
					ModCompatibilityServerSideTweaks.SetOverridePowerBias((float)((double)(currentPowerBias + num) / 2.0));
				}
			}
			else if (ModCompatibilityServerSideTweaks.enabled)
			{
				ModCompatibilityServerSideTweaks.ResetOverridePowerBias();
			}
		}

		private void InfiniteTowerWaveController_Initialize(orig_Initialize orig, InfiniteTowerWaveController self, int waveIndex, Inventory enemyInventory, GameObject spawnTarget)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkServer.active && BepConfig.Enabled.Value && IsBossStageStarted(waveIndex) && ((InfiniteTowerRun)Run.instance).IsStageTransitionWave() && !bossStageCompleted)
			{
				self.secondsBeforeSuddenDeath = 180f;
			}
			orig.Invoke(self, waveIndex, enemyInventory, spawnTarget);
		}

		private bool IsBossStageStarted(int waveIndex)
		{
			if (waveIndex > BepConfig.BossStageStartWave.Value && !bossStageCompleted)
			{
				return BepConfig.Enabled.Value;
			}
			return false;
		}

		private void InfiniteTowerRun_FixedUpdate(orig_FixedUpdate orig, InfiniteTowerRun self)
		{
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			//IL_037f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0384: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_038b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0390: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Expected O, but got Unknown
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Expected O, but got Unknown
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Expected O, but got Unknown
			orig.Invoke(self);
			if (!NetworkServer.active || !BepConfig.Enabled.Value)
			{
				return;
			}
			if (IsBossStageStarted(self.waveIndex) && self.IsStageTransitionWave() && nextBonusTime == 0f && !bossStageCompleted && BepConfig.BossStageBoss.Value != 0)
			{
				if (self.waveController.GetNormalizedProgress() > 0.5f && !bossSpawned)
				{
					bossSpawned = true;
					EliteDef val = null;
					if (BepConfig.BossStageBossElite.Value != 0)
					{
						val = EnumCollection.EliteDefs[BepConfig.BossStageBossElite.Value];
					}
					for (int i = 0; i < BepConfig.BossStageBossCount.Value; i++)
					{
						self.waveController.combatDirector.Spawn((SpawnCard)(object)bossSpawnCard.WaitForCompletion(), val, self.waveController.spawnTarget.transform, (MonsterSpawnDistance)2, false, 1f, (PlacementMode)1);
					}
				}
				if (!self.waveController.isInSuddenDeath)
				{
					if (self.waveController._zoneRadiusPercentage < BepConfig.BossStageBossRadius.Value)
					{
						zoneRadiusBoss = Math.Min(BepConfig.BossStageBossRadius.Value, zoneRadiusBoss + self.waveController.suddenDeathRadiusConstrictingPerSecond * Time.fixedDeltaTime);
						self.waveController.Network_zoneRadiusPercentage = zoneRadiusBoss;
					}
					else if (self.waveController._zoneRadiusPercentage > BepConfig.BossStageBossRadius.Value)
					{
						zoneRadiusBoss = Math.Max(0f, zoneRadiusBoss - self.waveController.suddenDeathRadiusConstrictingPerSecond * Time.fixedDeltaTime);
						self.waveController.Network_zoneRadiusPercentage = zoneRadiusBoss;
					}
				}
			}
			if (!bossStageCompleted || nextBonusTime == 0f || Run.instance.GetRunStopwatch() < nextBonusTime)
			{
				return;
			}
			zoneRadiusBoss = 1f;
			bossSpawned = false;
			if (bonusCounter >= BepConfig.BossStageLunarCoinsReward.Value)
			{
				nextBonusTime = 0f;
				if (Object.op_Implicit((Object)(object)nextStageBeforeBoss))
				{
					((Run)self).nextStageScene = nextStageBeforeBoss;
				}
				else
				{
					((Run)self).PickNextStageSceneFromCurrentSceneDestinations();
				}
				SpawnCard val2 = (SpawnCard)((!BepConfig.BossStageCompleteEndRun.Value) ? ((object)self.stageTransitionPortalCard) : ((object)iscVoidOutroPortal.WaitForCompletion()));
				DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest(val2, new DirectorPlacementRule
				{
					minDistance = 0f,
					maxDistance = self.stageTransitionPortalMaxDistance,
					placementMode = (PlacementMode)1,
					position = ((Component)self.safeWardController).transform.position,
					spawnOnTarget = ((Component)self.safeWardController).transform
				}, self.safeWardRng));
				Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
				{
					baseToken = self.stageTransitionChatToken
				});
				if (Object.op_Implicit((Object)(object)self.safeWardController))
				{
					self.safeWardController.WaitForPortal();
				}
			}
			else
			{
				int num = (int)Math.Ceiling((float)BepConfig.BossStageLunarCoinsReward.Value / 50f);
				float num2 = 360f / (float)num;
				float num3 = (float)bonusCounter / (float)BepConfig.BossStageLunarCoinsReward.Value;
				Vector3 val3 = Quaternion.AngleAxis(360f * num3 + 20f * (float)bonusCounter, Vector3.up) * (Vector3.up * (20f + 10f * num3 + (float)bonusCounter / 10f) + Vector3.forward * (5f + 5f * num3 + (float)bonusCounter / 50f));
				Quaternion val4 = Quaternion.AngleAxis(num2, Vector3.up);
				Vector3 position = ((Component)self.safeWardController).transform.position;
				((Vector3)(ref position))..ctor(position.x, position.y + 2f, position.z);
				int num4 = 0;
				while (num4 < num)
				{
					PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex("LunarCoin.Coin0"), position, val3);
					num4++;
					bonusCounter++;
					val3 = val4 * val3;
				}
				if (bonusCounter >= BepConfig.BossStageLunarCoinsReward.Value)
				{
					nextBonusTime = Run.instance.GetRunStopwatch() + 25f;
				}
				else
				{
					nextBonusTime = Run.instance.GetRunStopwatch() + 0.5f;
				}
			}
		}

		private void InfiniteTowerRun_OnWaveAllEnemiesDefeatedServer(orig_OnWaveAllEnemiesDefeatedServer orig, InfiniteTowerRun self, InfiniteTowerWaveController wc)
		{
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, wc);
			if (!NetworkServer.active || !BepConfig.Enabled.Value || self.waveIndex < BepConfig.BossStageStartWave.Value)
			{
				return;
			}
			if (ModCompatibilityServerSideTweaks.enabled)
			{
				ModCompatibilityServerSideTweaks.ResetOverridePowerBias();
			}
			if (!self.IsStageTransitionWave())
			{
				return;
			}
			if (BepConfig.BossStage.Value != 0 && SceneCatalog.currentSceneDef.cachedName != EnumCollection.GetStageName(BepConfig.BossStage.Value) && !bossStageCompleted)
			{
				if ((Object)(object)nextStageBeforeBoss == (Object)null)
				{
					nextStageBeforeBoss = ((Run)self).nextStageScene;
				}
				((Run)self).nextStageScene = ((IEnumerable<SceneDef>)(object)SceneCatalog.allStageSceneDefs).Where((SceneDef s) => s.cachedName == EnumCollection.GetStageName(BepConfig.BossStage.Value)).First();
			}
			if (!IsBossStageStarted(self.waveIndex))
			{
				return;
			}
			nextBonusTime = ((Run)self).GetRunStopwatch();
			bossStageCompleted = true;
			if (Object.op_Implicit((Object)(object)self.safeWardController))
			{
				self.safeWardController.WaitForPortal();
			}
			if (!BepConfig.BossStageCompleteEndRun.Value)
			{
				return;
			}
			foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
			{
				CharacterMaster master = instance.master;
				if (instance.isConnected && master.GetBody().baseNameToken == "COMMANDO_BODY_NAME")
				{
					Vector3 position = master.GetBody().transform.position;
					Quaternion rotation = master.GetBody().transform.rotation;
					master.bodyPrefab = BodyCatalog.FindBodyPrefab("VoidSurvivorBody");
					master.Respawn(position, rotation);
					Run.instance.HandlePlayerFirstEntryAnimation(master.GetBody(), position, rotation);
				}
			}
		}

		private void InfiniteTowerWaveController_DropRewards(orig_DropRewards orig, InfiniteTowerWaveController self)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active || !BepConfig.Enabled.Value || !IsBossStageStarted(self.waveIndex) || !((InfiniteTowerRun)Run.instance).IsStageTransitionWave() || bossStageCompleted || !BepConfig.BossStageCompleteEndRun.Value)
			{
				orig.Invoke(self);
			}
		}

		private void InfiniteTowerRun_RecalculateDifficultyCoefficentInternal(orig_RecalculateDifficultyCoefficentInternal orig, InfiniteTowerRun self)
		{
			orig.Invoke(self);
			if (BepConfig.DifficultyMultiplier1StartWave.Value <= self.waveIndex && self.waveIndex <= BepConfig.DifficultyMultiplier1EndWave.Value)
			{
				((Run)self).difficultyCoefficient = ((Run)self).difficultyCoefficient * BepConfig.DifficultyMultiplier1.Value;
			}
			if (BepConfig.DifficultyMultiplier2StartWave.Value <= self.waveIndex && self.waveIndex <= BepConfig.DifficultyMultiplier2EndWave.Value)
			{
				((Run)self).difficultyCoefficient = ((Run)self).difficultyCoefficient * BepConfig.DifficultyMultiplier2.Value;
			}
			if (BepConfig.DifficultyMultiplier3StartWave.Value <= self.waveIndex && self.waveIndex <= BepConfig.DifficultyMultiplier3EndWave.Value)
			{
				((Run)self).difficultyCoefficient = ((Run)self).difficultyCoefficient * BepConfig.DifficultyMultiplier3.Value;
			}
			if (BepConfig.DifficultyMultiplier4StartWave.Value <= self.waveIndex && self.waveIndex <= BepConfig.DifficultyMultiplier4EndWave.Value)
			{
				((Run)self).difficultyCoefficient = ((Run)self).difficultyCoefficient * BepConfig.DifficultyMultiplier4.Value;
			}
			((Run)self).compensatedDifficultyCoefficient = ((Run)self).difficultyCoefficient;
		}

		private void InfiniteTowerRun_AdvanceWave(orig_AdvanceWave orig, InfiniteTowerRun self)
		{
			orig.Invoke(self);
			if (!NetworkServer.active)
			{
				return;
			}
			if (BepConfig.Artifact1.Value != 0)
			{
				if (BepConfig.Artifact1StartWave.Value <= self.waveIndex && self.waveIndex <= BepConfig.Artifact1EndWave.Value)
				{
					RunArtifactManager.instance.SetArtifactEnabledServer(EnumCollection.GetArtifactDef(BepConfig.Artifact1.Value), true);
				}
				else if (self.waveIndex == BepConfig.Artifact1EndWave.Value + 1)
				{
					RunArtifactManager.instance.SetArtifactEnabledServer(EnumCollection.GetArtifactDef(BepConfig.Artifact1.Value), false);
				}
			}
			if (BepConfig.Artifact2.Value != 0)
			{
				if (BepConfig.Artifact2StartWave.Value <= self.waveIndex && self.waveIndex <= BepConfig.Artifact2EndWave.Value)
				{
					RunArtifactManager.instance.SetArtifactEnabledServer(EnumCollection.GetArtifactDef(BepConfig.Artifact2.Value), true);
				}
				else if (self.waveIndex == BepConfig.Artifact2EndWave.Value + 1)
				{
					RunArtifactManager.instance.SetArtifactEnabledServer(EnumCollection.GetArtifactDef(BepConfig.Artifact2.Value), false);
				}
			}
			if (BepConfig.Artifact3.Value != 0)
			{
				if (BepConfig.Artifact3StartWave.Value <= self.waveIndex && self.waveIndex <= BepConfig.Artifact3EndWave.Value)
				{
					RunArtifactManager.instance.SetArtifactEnabledServer(EnumCollection.GetArtifactDef(BepConfig.Artifact3.Value), true);
				}
				else if (self.waveIndex == BepConfig.Artifact3EndWave.Value + 1)
				{
					RunArtifactManager.instance.SetArtifactEnabledServer(EnumCollection.GetArtifactDef(BepConfig.Artifact3.Value), false);
				}
			}
			if (BepConfig.Artifact4.Value != 0)
			{
				if (BepConfig.Artifact4StartWave.Value <= self.waveIndex && self.waveIndex <= BepConfig.Artifact4EndWave.Value)
				{
					RunArtifactManager.instance.SetArtifactEnabledServer(EnumCollection.GetArtifactDef(BepConfig.Artifact4.Value), true);
				}
				else if (self.waveIndex == BepConfig.Artifact4EndWave.Value + 1)
				{
					RunArtifactManager.instance.SetArtifactEnabledServer(EnumCollection.GetArtifactDef(BepConfig.Artifact4.Value), false);
				}
			}
		}
	}
}