Decompiled source of SimulacrumAdditions v2.3.5

SimulacrumAdditions.dll

Decompiled a week ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AK.Wwise;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using EntityStates;
using EntityStates.Drone;
using EntityStates.GrandParent;
using EntityStates.InfiniteTowerSafeWard;
using EntityStates.Missions.Moon;
using EntityStates.QuestVolatileBattery;
using EntityStates.VagrantMonster;
using EntityStates.VagrantNovaItem;
using EntityStates.VoidMegaCrab;
using EntityStates.VoidMegaCrab.Weapon;
using IL.RoR2;
using JetBrains.Annotations;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.EntityStates;
using On.EntityStates.Drone;
using On.EntityStates.GrandParent;
using On.EntityStates.InfiniteTowerSafeWard;
using On.EntityStates.Missions.Moon;
using On.EntityStates.QuestVolatileBattery;
using On.EntityStates.VagrantMonster;
using On.EntityStates.VagrantNovaItem;
using On.EntityStates.VoidMegaCrab;
using On.EntityStates.VoidMegaCrab.Weapon;
using On.RoR2;
using On.RoR2.Artifacts;
using On.RoR2.Projectile;
using On.RoR2.UI;
using On.RoR2.UI.LogBook;
using On.RoR2.UI.MainMenu;
using R2API;
using R2API.Utils;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Artifacts;
using RoR2.CharacterAI;
using RoR2.ExpansionManagement;
using RoR2.Navigation;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2.Stats;
using RoR2.UI;
using RoR2.UI.LogBook;
using RoR2.UI.MainMenu;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SimulacrumAdditions")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+343425940de1fc53dc8687736df18b4b5f623990")]
[assembly: AssemblyProduct("SimulacrumAdditions")]
[assembly: AssemblyTitle("SimulacrumAdditions")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: UnverifiableCode]
namespace SimulacrumAdditions
{
	public class AutoConfig
	{
		public static ConfigFile ConfigFileAuto = new ConfigFile(Paths.ConfigPath + "\\Wolfo.Simulacrum_Additions___Autogenerated_Wave_Config.cfg", true);

		public static ConfigEntry<int> cfgSuperBossEveryXWaves;

		public static void InitConfig()
		{
			InfiniteTowerWaveCategory iTBasicWaves = SimuMain.ITBasicWaves;
			string text = "Basic Waves";
			for (int i = 1; i < iTBasicWaves.wavePrefabs.Length; i++)
			{
				ConfigEntry<bool> val = ConfigFileAuto.Bind<bool>(text, ((Object)iTBasicWaves.wavePrefabs[i].wavePrefab).name, true, "Enable this wave? :\n" + Language.GetString(((Component)iTBasicWaves.wavePrefabs[i].wavePrefab.GetComponent<InfiniteTowerWaveController>().overlayEntries[1].prefab.transform.GetChild(0).GetChild(1).GetChild(0)).GetComponent<InfiniteTowerWaveCounter>().token) + "\n" + Language.GetString(((Component)iTBasicWaves.wavePrefabs[i].wavePrefab.GetComponent<InfiniteTowerWaveController>().overlayEntries[1].prefab.transform.GetChild(0).GetChild(1).GetChild(1)).GetComponent<LanguageTextMeshController>().token));
			}
			iTBasicWaves = SimuMain.ITBossWaves;
			text = "Boss Waves";
			for (int j = 1; j < iTBasicWaves.wavePrefabs.Length; j++)
			{
				ConfigEntry<bool> val2 = ConfigFileAuto.Bind<bool>(text, ((Object)iTBasicWaves.wavePrefabs[j].wavePrefab).name, true, "Enable this wave? :\n" + Language.GetString(((Component)iTBasicWaves.wavePrefabs[j].wavePrefab.GetComponent<InfiniteTowerWaveController>().overlayEntries[1].prefab.transform.GetChild(0).GetChild(1).GetChild(0)).GetComponent<InfiniteTowerWaveCounter>().token) + "\n" + Language.GetString(((Component)iTBasicWaves.wavePrefabs[j].wavePrefab.GetComponent<InfiniteTowerWaveController>().overlayEntries[1].prefab.transform.GetChild(0).GetChild(1).GetChild(1)).GetComponent<LanguageTextMeshController>().token));
			}
			iTBasicWaves = SimuMain.ITSuperBossWaves;
			text = "Super Boss Waves";
			for (int k = 0; k < iTBasicWaves.wavePrefabs.Length; k++)
			{
				ConfigEntry<bool> val3 = ConfigFileAuto.Bind<bool>(text, ((Object)iTBasicWaves.wavePrefabs[k].wavePrefab).name, true, "Enable this wave? :\n" + Language.GetString(((Component)iTBasicWaves.wavePrefabs[k].wavePrefab.GetComponent<InfiniteTowerWaveController>().overlayEntries[1].prefab.transform.GetChild(0).GetChild(1).GetChild(0)).GetComponent<InfiniteTowerWaveCounter>().token) + "\n" + Language.GetString(((Component)iTBasicWaves.wavePrefabs[k].wavePrefab.GetComponent<InfiniteTowerWaveController>().overlayEntries[1].prefab.transform.GetChild(0).GetChild(1).GetChild(1)).GetComponent<LanguageTextMeshController>().token));
			}
		}

		public static void ApplyConfig()
		{
			InfiniteTowerWaveCategory iTBasicWaves = SimuMain.ITBasicWaves;
			string text = "Basic Waves";
			for (int i = 1; i < iTBasicWaves.wavePrefabs.Length; i++)
			{
				ConfigEntry<bool> val = null;
				ConfigFileAuto.TryGetEntry<bool>(text, ((Object)iTBasicWaves.wavePrefabs[i].wavePrefab).name, ref val);
				if (val != null && !val.Value)
				{
					iTBasicWaves.wavePrefabs[i].weight = 0f;
				}
			}
			iTBasicWaves = SimuMain.ITBossWaves;
			text = "Boss Waves";
			for (int j = 1; j < iTBasicWaves.wavePrefabs.Length; j++)
			{
				ConfigEntry<bool> val2 = null;
				ConfigFileAuto.TryGetEntry<bool>(text, ((Object)iTBasicWaves.wavePrefabs[j].wavePrefab).name, ref val2);
				if (val2 != null && !val2.Value)
				{
					iTBasicWaves.wavePrefabs[j].weight = 0f;
				}
			}
			iTBasicWaves = SimuMain.ITSuperBossWaves;
			text = "Super Boss Waves";
			for (int k = 0; k < iTBasicWaves.wavePrefabs.Length; k++)
			{
				ConfigEntry<bool> val3 = null;
				ConfigFileAuto.TryGetEntry<bool>(text, ((Object)iTBasicWaves.wavePrefabs[k].wavePrefab).name, ref val3);
				if (val3 != null && !val3.Value)
				{
					iTBasicWaves.wavePrefabs[k].weight = 0f;
				}
			}
		}
	}
	public class WConfig
	{
		public static ConfigFile ConfigFileUNSORTED = new ConfigFile(Paths.ConfigPath + "\\Wolfo.Simulacrum_Additions.cfg", true);

		public static ConfigEntry<bool> cfgFasterWavesLater;

		public static ConfigEntry<bool> cfgCrabSpeedOnLaterWaves;

		public static ConfigEntry<bool> cfgVoidTripleAllTier;

		public static ConfigEntry<bool> cfgVoidTripleContentsInPing;

		public static ConfigEntry<bool> cfgSimuCreditsRebalance;

		public static ConfigEntry<bool> cfgSimuMoreGold;

		public static ConfigEntry<bool> cfgDifferentTeleportEffect;

		public static ConfigEntry<bool> cfgVoidsEverywhere;

		public static ConfigEntry<bool> cfgExtraDifficuly;

		public static ConfigEntry<bool> cfgNewEnemiesVisible;

		public static ConfigEntry<bool> cfgDumpInfo;

		public static ConfigEntry<bool> cfgVoidCoins;

		public static ConfigEntry<bool> cfgEnableArtifactAugments;

		public static ConfigEntry<bool> cfgEnableArtifactStages;

		public static ConfigEntry<bool> cfgMusicSuperBoss;

		public static ConfigEntry<bool> cfgSacrificeBalance;

		public static ConfigEntry<bool> cfgItemsEvery8;

		public static ConfigEntry<bool> cfgItemsFrequently;

		public static ConfigEntry<bool> cfgMakeSpecialWavesMoreCommon;

		public static ConfigEntry<bool> cfgAwaitTravel;

		public static ConfigEntry<bool> cfgWaveOnEndScreen;

		public static ConfigEntry<float> ArtifactOfRealityBonusRadius;

		public static ConfigEntry<float> cfgCrabRadius;

		public static ConfigEntry<float> cfgCrabRadiusPerPlayer;

		public static ConfigEntry<bool> cfgWarbannerOnBoss;

		public static ConfigEntry<int> cfgSimuEndingStartAtXWaves;

		public static ConfigEntry<int> cfgSimuEndingEveryXWaves;

		public static ConfigEntry<int> cfgSuperBossStartAtXWaves;

		public static ConfigEntry<int> cfgSuperBossEveryXWaves;

		public static ConfigEntry<bool> ResetStatsButton;

		public static void RiskConfig()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_0041: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Expected O, but got Unknown
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Expected O, but got Unknown
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Expected O, but got Unknown
			ModSettingsManager.SetModDescription("Simulacrum Gaming");
			Sprite modIcon = Sprite.Create(Assets.Bundle.LoadAsset<Texture2D>("Assets/Simulacrum/Wave/waveGupYellow.png"), WRect.rec64, WRect.half);
			ModSettingsManager.SetModIcon(modIcon);
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ResetStatsButton));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(cfgNewEnemiesVisible, true));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(cfgVoidCoins));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(cfgVoidTripleAllTier, true));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(cfgSacrificeBalance));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(cfgFasterWavesLater));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(cfgExtraDifficuly));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(cfgSimuMoreGold, false));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(cfgSimuCreditsRebalance, true));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(cfgItemsEvery8, true));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(cfgItemsFrequently, true));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(cfgCrabSpeedOnLaterWaves));
		}

		public static void InitConfig()
		{
			ResetStatsButton = ConfigFileUNSORTED.Bind<bool>("Main", "Reset Wave Count Button", false, "Add a button on the Simulacrum select screen to reset a specific characters wave count.");
			cfgMusicSuperBoss = ConfigFileUNSORTED.Bind<bool>("Main", "Music for Super Boss waves", true, "Like Mithrix theme for Mithrix wave.");
			cfgVoidCoins = ConfigFileUNSORTED.Bind<bool>("Main", "Add Void Coins", true, "Add previously unused Void Coins with which you can purchase Void Interactables. You can still purchase them with Blood if you do not have any.");
			cfgVoidTripleAllTier = ConfigFileUNSORTED.Bind<bool>("Main", "Void Potential Chests can drop more tiers", true, "With this they can give items from any tier, normally they use a normal chest pool.");
			cfgVoidTripleContentsInPing = ConfigFileUNSORTED.Bind<bool>("Main", "Void Potential contents in ping message", true, "When pinging a Void Potential the items inside will be in the ping message. Requested for more easily sharing items inside Void Potentials.");
			cfgNewEnemiesVisible = ConfigFileUNSORTED.Bind<bool>("Main", "Logbook Entries for Simu only bosses", false, "Add reskins of enemies added by mod to Logbook.");
			cfgDifferentTeleportEffect = ConfigFileUNSORTED.Bind<bool>("Main", "Simulacrum Teleport Effect", true, "Void themed teleport effect for Simulacrum runs");
			cfgWaveOnEndScreen = ConfigFileUNSORTED.Bind<bool>("Main", "Wave name on end screen", true, "More info");
			cfgCrabSpeedOnLaterWaves = ConfigFileUNSORTED.Bind<bool>("Main : Crab", "Speed up as waves go on", true, "The crab will travel faster the more waves are completed, mostly noticible later waves.");
			cfgAwaitTravel = ConfigFileUNSORTED.Bind<bool>("Main : Crab", "Crab waits before travelling", true, "Like after wave 5, more time to do stuff before leaving or just to leave instantly.");
			cfgCrabRadius = ConfigFileUNSORTED.Bind<float>("Main : Crab", "Crab Radius : Base Radius", 65f, "Vanilla radius is 60.");
			cfgCrabRadiusPerPlayer = ConfigFileUNSORTED.Bind<float>("Main : Crab", "Crab Radius : Per Player", 5f, "Radius increase per player including player 1. Vanilla radius is 0.");
			cfgVoidsEverywhere = ConfigFileUNSORTED.Bind<bool>("Main", "Void Enemies on all stages", true, "After wave 60 void enemies will spawn on all simu stages.");
			cfgEnableArtifactAugments = ConfigFileUNSORTED.Bind<bool>("Main : Artifacts", "Enable Artifact of Augments", true, "An Artifact that allows only special augments.");
			cfgEnableArtifactStages = ConfigFileUNSORTED.Bind<bool>("Main : Artifacts", "Enable Artifact of Reality", true, "An Artifact that makes the game mode use normal stages instead of simu variants");
			ArtifactOfRealityBonusRadius = ConfigFileUNSORTED.Bind<float>("Main : Artifacts", "Artifact of Reality : Larger Radius", 10f, "Bonus radius since default stages are often bigger and have weird cornerns");
			cfgItemsEvery8 = ConfigFileUNSORTED.Bind<bool>("Simulacrum : Balance", "Items every 8 Waves", true, "Give items every 8 waves. Fits better with the run ending at wave 50.");
			cfgItemsFrequently = ConfigFileUNSORTED.Bind<bool>("Simulacrum : Balance", "Items are given more frequently later", true, "Items will be added twice as frequently after the first Red");
			cfgSimuCreditsRebalance = ConfigFileUNSORTED.Bind<bool>("Simulacrum : Balance", "Simulacrum Credits Rebalance", true, "Get more credits early on, Stages have 630 to 400 credits depending on stages completed and get more credits in multiplayer. Vanilla they always have 600 regardless of stage/player count.");
			cfgSimuMoreGold = ConfigFileUNSORTED.Bind<bool>("Simulacrum : Balance", "Simulacrum Gold Balance", true, "Gold is multiplied per player amount. Gain 50% more gold at the start and 25% less gold starting at wave 30. Helps with early looting and makes it so you won't instantly be able to afford every chest later on.");
			cfgExtraDifficuly = ConfigFileUNSORTED.Bind<bool>("Simulacrum : Balance", "More scaling", true, "Scales immediate wave spawns up and elite cost down to overall increase difficulty but also make waves shorter");
			cfgSacrificeBalance = ConfigFileUNSORTED.Bind<bool>("Simulacrum : Balance", "Nerf Sacrifice in Simulacrum", true, "30% less item drops from enemies and 1 less option in potentials");
			cfgFasterWavesLater = ConfigFileUNSORTED.Bind<bool>("Simulacrum : Balance", "Waves get faster later", true, "Less time between waves and waves spawn enemies faster.");
			cfgSimuEndingStartAtXWaves = ConfigFileUNSORTED.Bind<int>("Simulacrum : Ending Portal", "Ending Start Wave", 50, "This is the first wave the ending Portal appears (only use steps of 10)");
			cfgSimuEndingEveryXWaves = ConfigFileUNSORTED.Bind<int>("Simulacrum : Ending Portal", "Ending Portal Every X Waves", 10, "The ending portal will appear every X waves. (only use steps of 10)");
			cfgSuperBossStartAtXWaves = ConfigFileUNSORTED.Bind<int>("Simulacrum : Forced Super Boss", "Forced Special Boss Start Wave", 50, "A forced special boss is meant to be paired with the wave where the ending portal spawns so it's less of just a random end. (only use steps of 10)");
			cfgSuperBossEveryXWaves = ConfigFileUNSORTED.Bind<int>("Simulacrum : Forced Super Boss", "Forced Special Boss Every X Waves", 30, "The forced special boss will appear every X waves. (only use steps of 10)");
			cfgDumpInfo = ConfigFileUNSORTED.Bind<bool>("Testing", "Wave Info Dump", false, "Dump wave info on startup in log");
			RiskConfig();
		}
	}
	public class Const
	{
		public static GameObject BasicWave = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/GameModes/InfiniteTowerRun/InfiniteTowerAssets/InfiniteTowerWaveDefault.prefab").WaitForCompletion();

		public static GameObject BasicWaveUI = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/GameModes/InfiniteTowerRun/InfiniteTowerAssets/InfiniteTowerCurrentWaveUI.prefab").WaitForCompletion();

		public static GameObject BossWave = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/GameModes/InfiniteTowerRun/InfiniteTowerAssets/InfiniteTowerWaveBoss.prefab").WaitForCompletion();

		public static GameObject BossWaveUI = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/GameModes/InfiniteTowerRun/InfiniteTowerAssets/InfiniteTowerCurrentBossWaveUI.prefab").WaitForCompletion();

		public static GameObject ScavWave = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/GameModes/InfiniteTowerRun/InfiniteTowerAssets/InfiniteTowerWaveBossScav.prefab").WaitForCompletion();

		public static GameObject ArtifactWave = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/GameModes/InfiniteTowerRun/InfiniteTowerAssets/InfiniteTowerWaveArtifactBomb.prefab").WaitForCompletion();

		public static GameObject ArtifactWaveUI = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/GameModes/InfiniteTowerRun/InfiniteTowerAssets/InfiniteTowerCurrentArtifactBombWaveUI.prefab").WaitForCompletion();

		public static GameObject LunarWaveUI = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/GameModes/InfiniteTowerRun/InfiniteTowerAssets/InfiniteTowerCurrentBossLunarWaveUI.prefab").WaitForCompletion();

		public static GameObject VoidWaveUI = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/GameModes/InfiniteTowerRun/InfiniteTowerAssets/InfiniteTowerCurrentBossVoidWaveUI.prefab").WaitForCompletion();

		public static void MakeValues()
		{
		}
	}
	internal static class Assets
	{
		public static AssetBundle Bundle;

		public static PluginInfo PluginInfo;

		public static string Folder = "SimulacrumMod";

		internal static string assemblyDir => Path.GetDirectoryName(PluginInfo.Location);

		internal static void Init(PluginInfo info)
		{
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Expected O, but got Unknown
			PluginInfo = info;
			if (!Directory.Exists(GetPathToFile(Folder)))
			{
				Debug.LogWarning((object)(Folder + " | Folder does not exist"));
				Folder = "plugins\\" + Folder;
				if (!Directory.Exists(GetPathToFile(Folder)))
				{
					Debug.LogWarning((object)(Folder + " | Folder does not exist"));
				}
			}
			if (Directory.Exists(GetPathToFile(Folder + "\\Languages")))
			{
				Language.SetFolders += new hook_SetFolders(SetFolders);
			}
			else
			{
				Debug.LogWarning((object)(Folder + "\\Languages | Folder does not exist"));
			}
			if (Directory.Exists(GetPathToFile(Folder + "\\AssetBundles")))
			{
				Bundle = AssetBundle.LoadFromFile(GetPathToFile(Folder + "\\AssetBundles", "simulacrumadditions"));
			}
			else
			{
				Debug.LogWarning((object)(Folder + "\\AssetBundles | Folder does not exist"));
			}
		}

		private static void SetFolders(orig_SetFolders orig, Language self, IEnumerable<string> newFolders)
		{
			IEnumerable<string> second = Directory.EnumerateDirectories(Path.Combine(GetPathToFile(Folder + "\\Languages")), self.name);
			orig.Invoke(self, newFolders.Union(second));
		}

		internal static string GetPathToFile(string folderName)
		{
			return Path.Combine(assemblyDir, folderName);
		}

		internal static string GetPathToFile(string folderName, string fileName)
		{
			return Path.Combine(assemblyDir, folderName, fileName);
		}
	}
	public static class ArrayUtil
	{
		public static T[] Add<T>(this T[] array, params T[] items)
		{
			return (array ?? Enumerable.Empty<T>()).Concat(items).ToArray();
		}

		public static T[] Remove<T>(this T[] array, params T[] items)
		{
			return (array ?? Enumerable.Empty<T>()).Except(items).ToArray();
		}
	}
	public class WRect
	{
		public static readonly Random random = new Random();

		public static Rect recnothing = new Rect(0f, 0f, 0f, 0f);

		public static Rect recwide = new Rect(0f, 0f, 384f, 256f);

		public static Rect rechalftall = new Rect(0f, 0f, 256f, 320f);

		public static Rect rechalfwide = new Rect(0f, 0f, 320f, 256f);

		public static Rect rectall = new Rect(0f, 0f, 256f, 384f);

		public static Rect rec512 = new Rect(0f, 0f, 512f, 512f);

		public static Rect rec320 = new Rect(0f, 0f, 320f, 320f);

		public static Rect rec256 = new Rect(0f, 0f, 256f, 256f);

		public static Rect rec192 = new Rect(0f, 0f, 192f, 192f);

		public static Rect rec128 = new Rect(0f, 0f, 128f, 128f);

		public static Rect rec106 = new Rect(0f, 0f, 106f, 106f);

		public static Rect rec64 = new Rect(0f, 0f, 64f, 64f);

		public static Vector2 half = new Vector2(0.5f, 0.5f);
	}
	public class ArtifactTweaks
	{
		public static SpawnCard iscLemEggIT;

		public static void Main()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Expected O, but got Unknown
			FogDamageController.MyFixedUpdate += new Manipulator(NoFogLemurianDamage);
			DevotionInventoryController.Awake += new hook_Awake(DevotionInventoryController_Awake);
			InfiniteTowerWaveController.OnAllEnemiesDefeatedServer += new hook_OnAllEnemiesDefeatedServer(ActivateNewArtifacts_OnAllEnemiesDefeatedServer);
			SpawnCard val = (SpawnCard)(object)Addressables.LoadAssetAsync<InteractableSpawnCard>((object)"RoR2/CU8/LemurianEgg/iscLemurianEgg.asset").WaitForCompletion();
			iscLemEggIT = Object.Instantiate<SpawnCard>(val);
			((Object)iscLemEggIT).name = "iscLemurianEggIT";
			iscLemEggIT.directorCreditCost = 1;
			SceneDirector.onGenerateInteractableCardSelection += SimulacrumDevotionAddEgg;
			InfiniteTowerWaveController.PlayBeginSound += new hook_PlayBeginSound(LessOptionsDuringSacrifice);
			SacrificeArtifactManager.OnArtifactEnabled += new hook_OnArtifactEnabled(SacrificeArtifactManager_OnArtifactEnabled);
			SacrificeArtifactManager.OnArtifactDisabled += new hook_OnArtifactDisabled(SacrificeArtifactManager_OnArtifactDisabled);
		}

		private static void LessOptionsDuringSacrifice(orig_PlayBeginSound orig, InfiniteTowerWaveController self)
		{
			orig.Invoke(self);
			if (!WConfig.cfgSacrificeBalance.Value)
			{
				return;
			}
			bool flag = RunArtifactManager.instance.IsArtifactEnabled(Artifacts.sacrificeArtifactDef);
			SimulacrumExtrasHelper component = ((Component)self).GetComponent<SimulacrumExtrasHelper>();
			if (flag && self.rewardOptionCount > 1)
			{
				self.rewardOptionCount--;
				if (Object.op_Implicit((Object)(object)component) && component.rewardOptionCount > 1)
				{
					component.rewardOptionCount--;
				}
			}
		}

		private static void DevotionInventoryController_Awake(orig_Awake orig, DevotionInventoryController self)
		{
			orig.Invoke(self);
			if (Object.op_Implicit((Object)(object)Run.instance) && Object.op_Implicit((Object)(object)((Component)Run.instance).GetComponent<InfiniteTowerRun>()))
			{
				self._devotionMinionInventory.GiveItem(Items.BoostHp, 5);
			}
		}

		private static void NoFogLemurianDamage(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[2]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 0.5f),
				(Instruction x) => ILPatternMatchingExt.MatchMul(x)
			}))
			{
				val.Next.Operand = 0f;
				Debug.Log((object)"IL Found : IL.RoR2.FogDamageController.FixedUpdate");
			}
			else
			{
				Debug.LogWarning((object)"IL Failed : IL.RoR2.FogDamageController.FixedUpdate");
			}
		}

		private static void ActivateNewArtifacts_OnAllEnemiesDefeatedServer(orig_OnAllEnemiesDefeatedServer orig, InfiniteTowerWaveController self)
		{
			orig.Invoke(self);
			if (!NetworkServer.active || !Object.op_Implicit((Object)(object)RunArtifactManager.instance) || !self.isBossWave)
			{
				return;
			}
			foreach (DevotionInventoryController instance in DevotionInventoryController.InstanceList)
			{
				instance.UpdateAllMinions(true);
			}
		}

		private static void SimulacrumDevotionAddEgg(SceneDirector scene, DirectorCardCategorySelection dccs)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)Run.instance) && Object.op_Implicit((Object)(object)((Component)Run.instance).GetComponent<InfiniteTowerRun>()) && RunArtifactManager.instance.IsArtifactEnabled(Artifacts.Devotion))
			{
				DirectorCard val = new DirectorCard
				{
					spawnCard = iscLemEggIT,
					selectionWeight = 10,
					preventOverhead = false,
					minimumStageCompletions = 0,
					spawnDistance = (MonsterSpawnDistance)0
				};
				int num = dccs.AddCategory("Egg", 40f);
				dccs.AddCard(num, val);
			}
		}

		private static void SacrificeArtifactManager_OnArtifactEnabled(orig_OnArtifactEnabled orig, RunArtifactManager runArtifactManager, ArtifactDef artifactDef)
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			orig.Invoke(runArtifactManager, artifactDef);
			if (NetworkServer.active && !((Object)(object)artifactDef != (Object)(object)Artifacts.sacrificeArtifactDef) && WConfig.cfgSacrificeBalance.Value && Object.op_Implicit((Object)(object)Run.instance) && Object.op_Implicit((Object)(object)((Component)Run.instance).GetComponent<InfiniteTowerRun>()))
			{
				Debug.Log((object)"Simulacrum : Added Sacrifice");
				Util.GetExpAdjustedDropChancePercent += new hook_GetExpAdjustedDropChancePercent(SimulacrumNerfSacrifice);
			}
		}

		private static float SimulacrumNerfSacrifice(orig_GetExpAdjustedDropChancePercent orig, float baseChancePercent, GameObject characterBodyObject)
		{
			return orig.Invoke(baseChancePercent, characterBodyObject) * 0.7f;
		}

		private static void SacrificeArtifactManager_OnArtifactDisabled(orig_OnArtifactDisabled orig, RunArtifactManager runArtifactManager, ArtifactDef artifactDef)
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			orig.Invoke(runArtifactManager, artifactDef);
			if (NetworkServer.active && !((Object)(object)artifactDef != (Object)(object)Artifacts.sacrificeArtifactDef) && WConfig.cfgSacrificeBalance.Value && Object.op_Implicit((Object)(object)Run.instance) && Object.op_Implicit((Object)(object)((Component)Run.instance).GetComponent<InfiniteTowerRun>()))
			{
				Debug.Log((object)"Simulacrum : Removed Sacrifice");
				Util.GetExpAdjustedDropChancePercent -= new hook_GetExpAdjustedDropChancePercent(SimulacrumNerfSacrifice);
			}
		}
	}
	public class CrabActivateToTravel
	{
		public class CrabTravelOnCommand : MonoBehaviour
		{
			public void Activate()
			{
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Expected O, but got Unknown
				Run instance = Run.instance;
				Xoroshiro128Plus safeWardRng = ((InfiniteTowerRun)((instance is InfiniteTowerRun) ? instance : null)).safeWardRng;
				EntityStateMachine component = ((Component)this).GetComponent<EntityStateMachine>();
				component.SetNextState((EntityState)new Travelling(safeWardRng));
				PurchaseInteraction component2 = ((Component)this).gameObject.GetComponent<PurchaseInteraction>();
				component2.SetAvailable(false);
				component2.contextToken = "INFINITE_TOWER_SAFE_WARD_CONTEXT";
				Object.Destroy((Object)(object)this);
			}
		}

		public static void Make()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			Travelling.OnEnter += new hook_OnEnter(Travelling_OnEnter);
			if (WConfig.cfgAwaitTravel.Value)
			{
				Unburrow.OnEnter += new hook_OnEnter(Unburrow_OnEnter);
				Unburrow.FixedUpdate += new hook_FixedUpdate(Unburrow_FixedUpdate);
			}
		}

		private static void Travelling_OnEnter(orig_OnEnter orig, Travelling self)
		{
			self.animationStateName = "Swim";
			self.animationLayerName = "Base";
			orig.Invoke(self);
		}

		private static void Unburrow_OnEnter(orig_OnEnter orig, Unburrow self)
		{
			//IL_00ac: 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_00c1: Expected O, but got Unknown
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Expected O, but got Unknown
			//IL_0131: Expected O, but got Unknown
			((BaseSafeWardState)self).zone = ((EntityState)self).GetComponent<VerticalTubeZone>();
			float num = VoidSafeWard_Hooks.baseRadius + (float)Run.instance.participatingPlayerCount * VoidSafeWard_Hooks.radiusPerPlayer;
			if (Object.op_Implicit((Object)(object)((BaseSafeWardState)self).zone) && ((BaseSafeWardState)self).zone.radius > num)
			{
				VoidSafeWard_Hooks.RadiusShrinker radiusShrinker = ((EntityState)self).gameObject.AddComponent<VoidSafeWard_Hooks.RadiusShrinker>();
				radiusShrinker.originalRadius = ((BaseSafeWardState)self).zone.radius;
				radiusShrinker.newRadius = num;
				self.radius = ((BaseSafeWardState)self).zone.radius;
			}
			else
			{
				self.radius = num;
			}
			((BaseSafeWardState)self).objectiveToken = "INFINITETOWER_OBJECTIVE_AWAITING_TRAVEL";
			orig.Invoke(self);
			self.duration = 0f;
			Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
			{
				baseToken = "INFINITETOWER_TRAVEL_NOTICE"
			});
			Animator modelAnimator = ((EntityState)self).GetModelAnimator();
			modelAnimator.Play("BurrowedToIdle", 0, -0.2f);
			CrabTravelOnCommand target = ((EntityState)self).gameObject.AddComponent<CrabTravelOnCommand>();
			PurchaseInteraction component = ((EntityState)self).gameObject.GetComponent<PurchaseInteraction>();
			component.SetAvailable(true);
			component.contextToken = "INFINITETOWER_TRAVEL_CONTEXT";
			PersistentCall item = new PersistentCall
			{
				m_Target = (Object)(object)target,
				m_MethodName = "Activate",
				m_Mode = (PersistentListenerMode)1,
				m_Arguments = new ArgumentCache()
			};
			((UnityEventBase)component.onPurchase).m_PersistentCalls.m_Calls.Add(item);
			((UnityEventBase)component.onPurchase).m_CallsDirty = true;
		}

		private static void Unburrow_FixedUpdate(orig_FixedUpdate orig, Unburrow self)
		{
			((EntityState)self).fixedAge = ((EntityState)self).fixedAge + Time.fixedDeltaTime;
			if (((EntityState)self).fixedAge > 5f && ((EntityState)self).fixedAge < 6f)
			{
				Animator modelAnimator = ((EntityState)self).GetModelAnimator();
				modelAnimator.Play("BurrowedToIdle", 0, 12f);
			}
		}
	}
	public class ITRun_Hooks
	{
		public static SceneDef PreviousSceneDef;

		internal static void AddHooks()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			InfiniteTowerRun.PreStartClient += new hook_PreStartClient(ITRun_SetThingsOn_Start);
			InfiniteTowerRun.OnDestroy += new hook_OnDestroy(ITRun_SetThingsOn_End);
			InfiniteTowerRun.OnWaveAllEnemiesDefeatedServer += new hook_OnWaveAllEnemiesDefeatedServer(PreventRepeatingStages);
			InfiniteTowerWaveCategory.SelectWavePrefab += new hook_SelectWavePrefab(ForceSuperBossWave);
			InfiniteTowerRun.AdvanceWave += new hook_AdvanceWave(MakeWavesMoreCommon);
			if (WConfig.cfgItemsFrequently.Value)
			{
				InfiniteTowerRun.AdvanceWave += new hook_AdvanceWave(MoreItems_AdvanceWave);
			}
		}

		private static void MakeWavesMoreCommon(orig_AdvanceWave orig, InfiniteTowerRun self)
		{
			orig.Invoke(self);
			if ((self.waveIndex == 50 || self.waveIndex == 31) && SimuMain.ITBossWaves.wavePrefabs[0].weight > 1f)
			{
				float num = 1f;
				num = ((self.waveIndex != 31) ? SimuMain.DefaultWeightMultiplier2 : SimuMain.DefaultWeightMultiplier1);
				SimuMain.ITBasicWaves.wavePrefabs[0].weight = SimuMain.BasicWaveWeight * num;
				SimuMain.ITBasicWaves.GenerateWeightedSelection();
				SimuMain.ITBossWaves.wavePrefabs[0].weight = SimuMain.BasicBossWaveWight * num;
				SimuMain.ITBossWaves.GenerateWeightedSelection();
			}
		}

		private static void MoreItems_AdvanceWave(orig_AdvanceWave orig, InfiniteTowerRun self)
		{
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: 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_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: 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)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Expected O, but got Unknown
			if (self.enemyItemPatternIndex >= 5 && self.enemyItemPeriod > 5)
			{
				self.enemyItemPeriod /= 2;
			}
			orig.Invoke(self);
			if (!WConfig.cfgDumpInfo.Value || !NetworkServer.active || self.waveIndex <= self.enemyItemPeriod)
			{
				return;
			}
			int num = self.waveIndex;
			int num2 = 0;
			int num3 = 8;
			while (num >= num3)
			{
				num -= num3;
				num2++;
				if (num2 % 5 == 0 && num3 > 2)
				{
					num3 /= 2;
				}
			}
			Debug.Log((object)("WaveIndex:" + self.waveIndex + " ExpectedItemCount " + num2));
			while (self.enemyItemPatternIndex < num2)
			{
				EnemyItemEntry[] enemyItemPattern = self.enemyItemPattern;
				int enemyItemPatternIndex = self.enemyItemPatternIndex;
				self.enemyItemPatternIndex = enemyItemPatternIndex + 1;
				EnemyItemEntry val = enemyItemPattern[enemyItemPatternIndex % self.enemyItemPattern.Length];
				if (!Object.op_Implicit((Object)(object)val.dropTable))
				{
					break;
				}
				PickupIndex val2 = val.dropTable.GenerateDrop(self.enemyItemRng);
				if (val2 != PickupIndex.none)
				{
					PickupDef pickupDef = PickupCatalog.GetPickupDef(val2);
					if (pickupDef != null)
					{
						self.enemyInventory.GiveItem(pickupDef.itemIndex, val.stacks);
						Chat.SendBroadcastChat((ChatMessageBase)new PlayerPickupChatMessage
						{
							baseToken = "INFINITETOWER_ADD_ITEM",
							pickupToken = pickupDef.nameToken,
							pickupColor = Color32.op_Implicit(pickupDef.baseColor)
						});
					}
				}
			}
		}

		public static GameObject ForceSuperBossWave(orig_SelectWavePrefab orig, InfiniteTowerWaveCategory self, InfiniteTowerRun run, Xoroshiro128Plus rng)
		{
			if (run.waveIndex >= SimuMain.SimuForcedBossStartAtXWaves && run.waveIndex % SimuMain.SimuForcedBossEveryXWaves == SimuMain.SimuForcedBossWaveRest)
			{
				GameObject val = orig.Invoke(SimuMain.ITSuperBossWaves, run, rng);
				Debug.Log((object)"Forcing SuperBoss");
				Debug.Log((object)(run.waveIndex + " Forced SuperBoss  " + (object)val));
				return val;
			}
			GameObject val2 = orig.Invoke(self, run, rng);
			Debug.Log((object)(run.waveIndex + " SelectWavePrefab  " + (object)val2));
			return val2;
		}

		public static void PreventRepeatingStages(orig_OnWaveAllEnemiesDefeatedServer orig, InfiniteTowerRun self, InfiniteTowerWaveController wc)
		{
			orig.Invoke(self, wc);
			if (!self.IsStageTransitionWave())
			{
				return;
			}
			if ((Object)(object)PreviousSceneDef != (Object)null && (Object)(object)PreviousSceneDef == (Object)(object)((Run)self).nextStageScene)
			{
				int num = 0;
				do
				{
					num++;
					((Run)self).PickNextStageSceneFromCurrentSceneDestinations();
				}
				while ((Object)(object)((Run)self).nextStageScene == (Object)(object)PreviousSceneDef && num < 10);
			}
			PreviousSceneDef = Stage.instance.sceneDef;
		}

		private static void ITRun_SetThingsOn_Start(orig_PreStartClient orig, InfiniteTowerRun self)
		{
			orig.Invoke(self);
			SimuMain.ITBossWaves.availabilityPeriod = 5;
			SimuMain.ITBossWaves.minWaveIndex = 0;
			if (SimuMain.ITBossWaves.wavePrefabs[0].weight < 1f)
			{
				SimuMain.ITBasicWaves.wavePrefabs[0].weight = SimuMain.BasicWaveWeight;
				SimuMain.ITBasicWaves.GenerateWeightedSelection();
				SimuMain.ITBossWaves.wavePrefabs[0].weight = SimuMain.BasicBossWaveWight;
				SimuMain.ITBasicWaves.GenerateWeightedSelection();
			}
			SimulacrumDCCS.MakeITSand(makeITSand: true);
			if (WConfig.cfgVoidCoins.Value)
			{
				VoidCoin.VoidCoinRunStart();
			}
			GameObject val = LegacyResourcesAPI.Load<GameObject>("Prefabs/CharacterMasters/EquipmentDroneMaster");
			((Behaviour)val.GetComponent<StartEvent>()).enabled = false;
			val.AddComponent<EquipmentDroneInSimulacrum>();
			Object.Destroy((Object)(object)val.GetComponent<SetDontDestroyOnLoad>());
			((Component)self).gameObject.AddComponent<Hooks_Other.LastWaveHolder>();
		}

		private static void ITRun_SetThingsOn_End(orig_OnDestroy orig, InfiniteTowerRun self)
		{
			orig.Invoke(self);
			GameObject val = LegacyResourcesAPI.Load<GameObject>("Prefabs/CharacterMasters/EquipmentDroneMaster");
			((Behaviour)val.GetComponent<StartEvent>()).enabled = true;
			val.AddComponent<SetDontDestroyOnLoad>();
			Object.Destroy((Object)(object)val.GetComponent<EquipmentDroneInSimulacrum>());
			SimulacrumDCCS.MakeITSand(makeITSand: false);
			if (WConfig.cfgVoidCoins.Value)
			{
				VoidCoin.VoidCoinRunEnd();
			}
		}
	}
	public class Hooks_Other
	{
		public class ResetWavesCounter : MonoBehaviour
		{
			public void Reset()
			{
				//IL_0075: Unknown result type (might be due to invalid IL or missing references)
				//IL_007a: Unknown result type (might be due to invalid IL or missing references)
				Debug.LogWarning((object)"Attempting to reset Simulacrum Wave High-scores");
				MPEventSystem val = MPEventSystem.instancesList[0];
				UserProfile val2;
				if ((Object)(object)val == (Object)null)
				{
					val2 = null;
				}
				else
				{
					LocalUser localUser = val.localUser;
					val2 = ((localUser != null) ? localUser.userProfile : null);
				}
				UserProfile val3 = val2;
				if (val3 != null)
				{
					StatSheet statSheet = val3.statSheet;
					SurvivorDef survivorPreference = val3.GetSurvivorPreference();
					if (Object.op_Implicit((Object)(object)survivorPreference))
					{
						string bodyName = BodyCatalog.GetBodyName(SurvivorCatalog.GetBodyIndexFromSurvivorIndex(survivorPreference.survivorIndex));
						Debug.LogWarning((object)("Resetting for " + bodyName));
						statSheet.SetStatValueFromString(PerBodyStatDef.highestInfiniteTowerWaveReachedEasy.FindStatDef(bodyName ?? ""), "0");
						statSheet.SetStatValueFromString(PerBodyStatDef.highestInfiniteTowerWaveReachedNormal.FindStatDef(bodyName ?? ""), "0");
						statSheet.SetStatValueFromString(PerBodyStatDef.highestInfiniteTowerWaveReachedHard.FindStatDef(bodyName ?? ""), "0");
					}
				}
			}

			public void ResetAll()
			{
				//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
				Debug.LogWarning((object)"Attempting to reset ALL Simulacrum Wave High-scores");
				MPEventSystem val = MPEventSystem.instancesList[0];
				UserProfile val2;
				if ((Object)(object)val == (Object)null)
				{
					val2 = null;
				}
				else
				{
					LocalUser localUser = val.localUser;
					val2 = ((localUser != null) ? localUser.userProfile : null);
				}
				UserProfile val3 = val2;
				if (val3 == null)
				{
					return;
				}
				StatSheet statSheet = val3.statSheet;
				SurvivorDef[] survivorDefs = SurvivorCatalog.survivorDefs;
				foreach (SurvivorDef val4 in survivorDefs)
				{
					if (Object.op_Implicit((Object)(object)val4.bodyPrefab))
					{
						CharacterBody component = val4.bodyPrefab.GetComponent<CharacterBody>();
						if (Object.op_Implicit((Object)(object)component))
						{
							string bodyName = BodyCatalog.GetBodyName(component.bodyIndex);
							Debug.LogWarning((object)("Resetting for " + bodyName));
							statSheet.SetStatValueFromString(PerBodyStatDef.highestInfiniteTowerWaveReachedEasy.FindStatDef(bodyName ?? ""), "0");
							statSheet.SetStatValueFromString(PerBodyStatDef.highestInfiniteTowerWaveReachedNormal.FindStatDef(bodyName ?? ""), "0");
							statSheet.SetStatValueFromString(PerBodyStatDef.highestInfiniteTowerWaveReachedHard.FindStatDef(bodyName ?? ""), "0");
						}
					}
				}
			}

			public void Set50D()
			{
				Set50(0);
			}

			public void Set50R()
			{
				Set50(1);
			}

			public void Set50M()
			{
				Set50(2);
			}

			public void Set50(int difficulty)
			{
				//IL_0075: Unknown result type (might be due to invalid IL or missing references)
				//IL_007a: Unknown result type (might be due to invalid IL or missing references)
				Debug.LogWarning((object)"Attempting to set 50 Simulacrum Wave High-scores");
				MPEventSystem val = MPEventSystem.instancesList[0];
				UserProfile val2;
				if ((Object)(object)val == (Object)null)
				{
					val2 = null;
				}
				else
				{
					LocalUser localUser = val.localUser;
					val2 = ((localUser != null) ? localUser.userProfile : null);
				}
				UserProfile val3 = val2;
				if (val3 == null)
				{
					return;
				}
				StatSheet statSheet = val3.statSheet;
				SurvivorDef survivorPreference = val3.GetSurvivorPreference();
				if (Object.op_Implicit((Object)(object)survivorPreference))
				{
					string bodyName = BodyCatalog.GetBodyName(SurvivorCatalog.GetBodyIndexFromSurvivorIndex(survivorPreference.survivorIndex));
					Debug.LogWarning((object)("Setting 50 for " + bodyName));
					switch (difficulty)
					{
					case 0:
						statSheet.SetStatValueFromString(PerBodyStatDef.highestInfiniteTowerWaveReachedEasy.FindStatDef(bodyName ?? ""), "50");
						break;
					case 1:
						statSheet.SetStatValueFromString(PerBodyStatDef.highestInfiniteTowerWaveReachedNormal.FindStatDef(bodyName ?? ""), "50");
						break;
					case 2:
						statSheet.SetStatValueFromString(PerBodyStatDef.highestInfiniteTowerWaveReachedHard.FindStatDef(bodyName ?? ""), "50");
						break;
					}
				}
			}
		}

		public class LastWaveHolder : MonoBehaviour
		{
			public GameObject UIThing;

			public GameObject LatestWave;
		}

		internal static void AddHooks()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			PickupCatalog.FindPickupIndex_ItemTier += new hook_FindPickupIndex_ItemTier(PickupCatalog_FindPickupIndex_ItemTier);
			ScavengerItemGranter.Start += new hook_Start(SimuGiveScavVoidItems);
			EventFunctions.BeginEnding += new hook_BeginEnding(SimulacrumEndingBeginEnding);
			if (WConfig.cfgWaveOnEndScreen.Value)
			{
				GameEndReportPanelController.SetDisplayData += new hook_SetDisplayData(GameEndReportPanelController_SetDisplayData);
			}
			InfiniteTowerMenuController.OnEventSystemDiscovered += new hook_OnEventSystemDiscovered(InfiniteTowerMenuController_OnEventSystemDiscovered);
		}

		private static void InfiniteTowerMenuController_OnEventSystemDiscovered(orig_OnEventSystemDiscovered orig, InfiniteTowerMenuController self, MPEventSystem eventSystem)
		{
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: 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_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Expected O, but got Unknown
			//IL_02a6: Expected O, but got Unknown
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Expected O, but got Unknown
			//IL_02d6: Expected O, but got Unknown
			//IL_02e1: Expected O, but got Unknown
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Expected O, but got Unknown
			//IL_035c: Expected O, but got Unknown
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: 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_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0387: Expected O, but got Unknown
			//IL_038c: Expected O, but got Unknown
			//IL_0397: Expected O, but got Unknown
			//IL_03da: Unknown result type (might be due to invalid IL or missing references)
			//IL_03df: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0400: Unknown result type (might be due to invalid IL or missing references)
			//IL_0405: Unknown result type (might be due to invalid IL or missing references)
			//IL_0406: Unknown result type (might be due to invalid IL or missing references)
			//IL_0410: Expected O, but got Unknown
			//IL_0415: Expected O, but got Unknown
			//IL_0417: Unknown result type (might be due to invalid IL or missing references)
			//IL_041c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0423: Unknown result type (might be due to invalid IL or missing references)
			//IL_042e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0430: Unknown result type (might be due to invalid IL or missing references)
			//IL_0435: Unknown result type (might be due to invalid IL or missing references)
			//IL_0436: Unknown result type (might be due to invalid IL or missing references)
			//IL_0440: Expected O, but got Unknown
			//IL_0445: Expected O, but got Unknown
			//IL_0450: Expected O, but got Unknown
			//IL_0493: Unknown result type (might be due to invalid IL or missing references)
			//IL_0498: Unknown result type (might be due to invalid IL or missing references)
			//IL_049f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04be: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c9: Expected O, but got Unknown
			//IL_04ce: Expected O, but got Unknown
			//IL_04d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f9: Expected O, but got Unknown
			//IL_04fe: Expected O, but got Unknown
			//IL_0509: Expected O, but got Unknown
			//IL_054c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0551: Unknown result type (might be due to invalid IL or missing references)
			//IL_0558: Unknown result type (might be due to invalid IL or missing references)
			//IL_055d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0565: Unknown result type (might be due to invalid IL or missing references)
			//IL_0570: Unknown result type (might be due to invalid IL or missing references)
			//IL_0572: Unknown result type (might be due to invalid IL or missing references)
			//IL_0577: Unknown result type (might be due to invalid IL or missing references)
			//IL_0578: Unknown result type (might be due to invalid IL or missing references)
			//IL_0582: Expected O, but got Unknown
			//IL_0587: Expected O, but got Unknown
			//IL_0589: Unknown result type (might be due to invalid IL or missing references)
			//IL_058e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0595: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b2: Expected O, but got Unknown
			//IL_05b7: Expected O, but got Unknown
			//IL_05c2: Expected O, but got Unknown
			orig.Invoke(self, eventSystem);
			if (WConfig.ResetStatsButton.Value)
			{
				Transform child = ((Component)self).transform.GetChild(0).GetChild(1).GetChild(0);
				Transform val = child.Find("Reset");
				Transform val2 = child.Find("ResetAll");
				Transform val3 = child.Find("Set50D");
				Transform val4 = child.Find("Set50R");
				Transform val5 = child.Find("Set50M");
				if (child.childCount == 2)
				{
					GameObject gameObject = ((Component)child.GetChild(1)).gameObject;
					GameObject val6 = Object.Instantiate<GameObject>(gameObject, child);
					((Object)val6).name = "ResetAll";
					((Graphic)val6.GetComponent<Image>()).color = Color.red;
					((Component)val6.transform.GetChild(1)).GetComponent<LanguageTextMeshController>().token = "Reset all Survivors";
					val2 = val6.transform;
					val6 = Object.Instantiate<GameObject>(gameObject, child);
					((Object)val6).name = "Reset";
					((Graphic)val6.GetComponent<Image>()).color = Color.red;
					((Component)val6.transform.GetChild(1)).GetComponent<LanguageTextMeshController>().token = "Reset selected Survivor";
					val = val6.transform;
					val6 = Object.Instantiate<GameObject>(gameObject, child);
					((Object)val6).name = "Set50D";
					((Graphic)val6.GetComponent<Image>()).color = Color.magenta;
					((Component)val6.transform.GetChild(1)).GetComponent<LanguageTextMeshController>().token = "Set to 50 for selected Driz";
					val3 = val6.transform;
					val6 = Object.Instantiate<GameObject>(gameObject, child);
					((Object)val6).name = "Set50R";
					((Graphic)val6.GetComponent<Image>()).color = Color.magenta;
					((Component)val6.transform.GetChild(1)).GetComponent<LanguageTextMeshController>().token = "Set to 50 for selected Rain";
					val4 = val6.transform;
					val6 = Object.Instantiate<GameObject>(gameObject, child);
					((Object)val6).name = "Set50M";
					((Graphic)val6.GetComponent<Image>()).color = Color.magenta;
					((Component)val6.transform.GetChild(1)).GetComponent<LanguageTextMeshController>().token = "Set to 50 for selected Mons";
					val5 = val6.transform;
					child.GetChild(1).SetAsLastSibling();
				}
				if (Object.op_Implicit((Object)(object)val))
				{
					((Component)val.GetChild(2)).gameObject.SetActive(false);
					HGButton component = ((Component)val).GetComponent<HGButton>();
					ResetWavesCounter target = ((Component)self).gameObject.AddComponent<ResetWavesCounter>();
					((UnityEventBase)((Button)component).onClick).m_PersistentCalls = new PersistentCallGroup
					{
						m_Calls = new List<PersistentCall>
						{
							new PersistentCall
							{
								m_Target = (Object)(object)target,
								m_MethodName = "Reset",
								m_Mode = (PersistentListenerMode)1,
								m_Arguments = new ArgumentCache()
							},
							new PersistentCall
							{
								m_Target = (Object)(object)self,
								m_MethodName = "UpdateDisplayedSurvivor",
								m_Mode = (PersistentListenerMode)1,
								m_Arguments = new ArgumentCache()
							}
						}
					};
				}
				if (Object.op_Implicit((Object)(object)val2))
				{
					((Component)val2.GetChild(2)).gameObject.SetActive(false);
					HGButton component2 = ((Component)val2).GetComponent<HGButton>();
					ResetWavesCounter target2 = ((Component)self).gameObject.AddComponent<ResetWavesCounter>();
					((UnityEventBase)((Button)component2).onClick).m_PersistentCalls = new PersistentCallGroup
					{
						m_Calls = new List<PersistentCall>
						{
							new PersistentCall
							{
								m_Target = (Object)(object)target2,
								m_MethodName = "ResetAll",
								m_Mode = (PersistentListenerMode)1,
								m_Arguments = new ArgumentCache()
							},
							new PersistentCall
							{
								m_Target = (Object)(object)self,
								m_MethodName = "UpdateDisplayedSurvivor",
								m_Mode = (PersistentListenerMode)1,
								m_Arguments = new ArgumentCache()
							}
						}
					};
				}
				if (Object.op_Implicit((Object)(object)val3))
				{
					((Component)val3.GetChild(2)).gameObject.SetActive(false);
					HGButton component3 = ((Component)val3).GetComponent<HGButton>();
					ResetWavesCounter target3 = ((Component)self).gameObject.AddComponent<ResetWavesCounter>();
					((UnityEventBase)((Button)component3).onClick).m_PersistentCalls = new PersistentCallGroup
					{
						m_Calls = new List<PersistentCall>
						{
							new PersistentCall
							{
								m_Target = (Object)(object)target3,
								m_MethodName = "Set50D",
								m_Mode = (PersistentListenerMode)1,
								m_Arguments = new ArgumentCache()
							},
							new PersistentCall
							{
								m_Target = (Object)(object)self,
								m_MethodName = "UpdateDisplayedSurvivor",
								m_Mode = (PersistentListenerMode)1,
								m_Arguments = new ArgumentCache()
							}
						}
					};
				}
				if (Object.op_Implicit((Object)(object)val4))
				{
					((Component)val4.GetChild(2)).gameObject.SetActive(false);
					HGButton component4 = ((Component)val4).GetComponent<HGButton>();
					ResetWavesCounter target4 = ((Component)self).gameObject.AddComponent<ResetWavesCounter>();
					((UnityEventBase)((Button)component4).onClick).m_PersistentCalls = new PersistentCallGroup
					{
						m_Calls = new List<PersistentCall>
						{
							new PersistentCall
							{
								m_Target = (Object)(object)target4,
								m_MethodName = "Set50R",
								m_Mode = (PersistentListenerMode)1,
								m_Arguments = new ArgumentCache()
							},
							new PersistentCall
							{
								m_Target = (Object)(object)self,
								m_MethodName = "UpdateDisplayedSurvivor",
								m_Mode = (PersistentListenerMode)1,
								m_Arguments = new ArgumentCache()
							}
						}
					};
				}
				if (Object.op_Implicit((Object)(object)val5))
				{
					((Component)val5.GetChild(2)).gameObject.SetActive(false);
					HGButton component5 = ((Component)val5).GetComponent<HGButton>();
					ResetWavesCounter target5 = ((Component)self).gameObject.AddComponent<ResetWavesCounter>();
					((UnityEventBase)((Button)component5).onClick).m_PersistentCalls = new PersistentCallGroup
					{
						m_Calls = new List<PersistentCall>
						{
							new PersistentCall
							{
								m_Target = (Object)(object)target5,
								m_MethodName = "Set50M",
								m_Mode = (PersistentListenerMode)1,
								m_Arguments = new ArgumentCache()
							},
							new PersistentCall
							{
								m_Target = (Object)(object)self,
								m_MethodName = "UpdateDisplayedSurvivor",
								m_Mode = (PersistentListenerMode)1,
								m_Arguments = new ArgumentCache()
							}
						}
					};
				}
			}
		}

		private static void GameEndReportPanelController_SetDisplayData(orig_SetDisplayData orig, GameEndReportPanelController self, DisplayData newDisplayData)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, newDisplayData);
			if (!Object.op_Implicit((Object)(object)Run.instance) || !Object.op_Implicit((Object)(object)((Component)Run.instance).GetComponent<InfiniteTowerRun>()))
			{
				return;
			}
			LastWaveHolder component = ((Component)Run.instance).GetComponent<LastWaveHolder>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return;
			}
			GameObject val = component.LatestWave;
			if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)((Component)Run.instance).GetComponent<InfiniteTowerRun>().waveInstance))
			{
				val = ((Component)Run.instance).GetComponent<InfiniteTowerRun>().waveInstance.GetComponent<InfiniteTowerWaveController>().overlayEntries[1].prefab;
			}
			if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)self.selectedDifficultyLabel) || Object.op_Implicit((Object)(object)component.UIThing))
			{
				return;
			}
			GameObject val2 = Object.Instantiate<GameObject>(((Component)((Component)self.selectedDifficultyLabel).transform.parent).gameObject, ((Component)self.selectedDifficultyLabel).transform.parent.parent);
			val2.transform.SetSiblingIndex(1);
			component.UIThing = val2;
			((Component)val2.transform.GetChild(0)).GetComponent<LanguageTextMeshController>().token = "Last Wave:";
			string token = ((Component)val.transform.GetChild(0).GetChild(1).GetChild(0)).GetComponent<InfiniteTowerWaveCounter>().token;
			token = Language.GetString(token);
			string format = token;
			Run instance = Run.instance;
			token = string.Format(format, ((InfiniteTowerRun)((instance is InfiniteTowerRun) ? instance : null)).waveIndex);
			((Component)val2.transform.GetChild(2)).GetComponent<LanguageTextMeshController>().token = token;
			Image component2 = ((Component)val2.transform.GetChild(3)).GetComponent<Image>();
			Image component3 = ((Component)val.transform.GetChild(0).GetChild(0).GetChild(0)).GetComponent<Image>();
			component2.sprite = component3.sprite;
			((Graphic)component2).color = ((Graphic)component3).color;
			((Graphic)((Component)val2.transform.GetChild(2)).GetComponent<HGTextMeshProUGUI>()).color = ((Graphic)((Component)val.transform.GetChild(0).GetChild(1).GetChild(0)).GetComponent<TextMeshProUGUI>()).color;
			val2.transform.GetChild(2).SetAsLastSibling();
			try
			{
				if (val.transform.GetChild(0).childCount == 4)
				{
					GameObject val3 = Object.Instantiate<GameObject>(((Component)component2).gameObject, val2.transform);
					component3 = ((Component)val.transform.GetChild(0).GetChild(3).GetChild(0)).GetComponent<Image>();
					component2 = val3.GetComponent<Image>();
					component2.sprite = component3.sprite;
					((Graphic)component2).color = ((Graphic)component3).color;
				}
			}
			catch (Exception)
			{
			}
			TooltipProvider val4 = val2.AddComponent<TooltipProvider>();
			val4.titleToken = token;
			val4.titleColor = ((Graphic)((Component)val.transform.GetChild(0).GetChild(2)).GetComponent<Image>()).color;
			val4.bodyToken = ((Component)val.transform.GetChild(0).GetChild(1).GetChild(1)).GetComponent<LanguageTextMeshController>().token;
		}

		public static void SimulacrumEndingBeginEnding(orig_BeginEnding orig, EventFunctions self, GameEndingDef gameEndingDef)
		{
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			if ((Object)(object)gameEndingDef == (Object)(object)GameEndings.VoidEnding && Object.op_Implicit((Object)(object)((Component)Run.instance).GetComponent<InfiniteTowerRun>()))
			{
				orig.Invoke(self, SimuMain.InfiniteTowerEnding);
				foreach (CharacterBody readOnlyInstances in CharacterBody.readOnlyInstancesList)
				{
					if (readOnlyInstances.hasEffectiveAuthority)
					{
					}
					EntityStateMachine val = EntityStateMachine.FindByCustomName(((Component)readOnlyInstances).gameObject, "Body");
					if (Object.op_Implicit((Object)(object)val))
					{
						val.SetInterruptState((EntityState)new Idle(), (InterruptPriority)5);
					}
				}
				Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
				{
					baseToken = "<color=#F4ADFA><sprite name=\"VoidCoin\" tint=1> The Simulation has been suspended. Printing results.. <sprite name=\"VoidCoin\" tint=1></color>"
				});
			}
			else
			{
				orig.Invoke(self, gameEndingDef);
			}
		}

		public static void SimuGiveScavVoidItems(orig_Start orig, ScavengerItemGranter self)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Invalid comparison between Unknown and I4
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Invalid comparison between Unknown and I4
			orig.Invoke(self);
			if (Run.instance is InfiniteTowerRun)
			{
				Inventory component = ((Component)self).GetComponent<Inventory>();
				PickupIndex val = ((PickupDropTable)SimuMain.dtAISafeRandomVoid).GenerateDrop(Run.instance.treasureRng);
				ItemDef itemDef = ItemCatalog.GetItemDef(((PickupIndex)(ref val)).pickupDef.itemIndex);
				if ((int)itemDef.tier == 6)
				{
					component.GiveItem(itemDef, 3);
					Debug.Log((object)("Giving Simu Scav 3x " + (object)itemDef));
				}
				else if ((int)itemDef.tier == 7)
				{
					component.GiveItem(itemDef, 2);
					Debug.Log((object)("Giving Simu Scav 2x " + (object)itemDef));
				}
				else
				{
					component.GiveItem(itemDef, 1);
					Debug.Log((object)("Giving Simu Scav 1x " + (object)itemDef));
				}
			}
		}

		private static PickupIndex PickupCatalog_FindPickupIndex_ItemTier(orig_FindPickupIndex_ItemTier orig, ItemTier tier)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			if (tier == SimuMain.ItemOrangeTierDef.tier && Object.op_Implicit((Object)(object)RunArtifactManager.instance) && RunArtifactManager.instance.IsArtifactEnabled(Artifacts.commandArtifactDef))
			{
				return PickupCatalog.FindPickupIndex(Equipment.Fruit.equipmentIndex);
			}
			return orig.Invoke(tier);
		}

		private static void PickupPickerController_SetOptionsFromPickupForCommandArtifact(orig_SetOptionsFromPickupForCommandArtifact orig, PickupPickerController self, PickupIndex pickupIndex)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, pickupIndex);
		}
	}
	public class VoidSafeWard_Hooks
	{
		public class RadiusShrinker : MonoBehaviour
		{
			public float newRadius;

			public float currentRadius;

			public float originalRadius;

			public float remove = 0.13f;

			public InfiniteTowerSafeWardController crab;

			public void Start()
			{
				currentRadius = originalRadius;
				crab = ((Component)Run.instance).GetComponent<InfiniteTowerRun>().safeWardController;
				if (!Object.op_Implicit((Object)(object)crab))
				{
					Debug.Log((object)"No gameobject");
					Object.Destroy((Object)(object)this);
				}
			}

			public void FixedUpdate()
			{
				//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)crab != (Object)null)
				{
					if (currentRadius > newRadius)
					{
						currentRadius -= remove;
						Reflection.SetFieldValue<float>((object)crab.wardStateMachine.state, "radius", currentRadius);
						crab.holdoutZoneController.baseRadius = currentRadius;
						((BaseSafeWardState)crab.wardStateMachine.state).zone.Networkradius = currentRadius;
					}
					else
					{
						Reflection.SetFieldValue<float>((object)crab.wardStateMachine.state, "radius", newRadius);
						crab.holdoutZoneController.baseRadius = newRadius;
						((BaseSafeWardState)crab.wardStateMachine.state).zone.Networkradius = newRadius;
						Object.Destroy((Object)(object)this);
					}
				}
			}
		}

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

			public static hook_MoveSafeWard <>9__2_0;

			public static hook_OnTimerExpire <>9__2_1;

			public static hook_OnTimerExpire <>9__2_2;

			public static hook_OnEnter <>9__2_3;

			public static hook_OnEnter <>9__2_4;

			public static hook_OnEnter <>9__2_5;

			public static hook_OnEnter <>9__2_6;

			internal void <AddHooks>b__2_0(orig_MoveSafeWard orig, InfiniteTowerRun self)
			{
				if (self.waveIndex % 5 != 0)
				{
					Debug.Log((object)"Preventing early moving of crab");
				}
				else
				{
					orig.Invoke(self);
				}
			}

			internal void <AddHooks>b__2_1(orig_OnTimerExpire orig, InfiniteTowerBossWaveController self)
			{
				if (((InfiniteTowerWaveController)self).waveIndex % 5 != 0)
				{
					if (!NetworkServer.active)
					{
						Debug.LogWarning((object)"[Server] function 'System.Void RoR2.InfiniteTowerWaveController::OnTimerExpire()' called on client");
						return;
					}
					((InfiniteTowerWaveController)self).MarkAsFinished();
					Debug.Log((object)"Preventing early moving of crab");
				}
				else
				{
					orig.Invoke(self);
				}
			}

			internal void <AddHooks>b__2_2(orig_OnTimerExpire orig, InfiniteTowerExplicitSpawnWaveController self)
			{
				if (((InfiniteTowerWaveController)self).waveIndex % 5 != 0)
				{
					if (!NetworkServer.active)
					{
						Debug.LogWarning((object)"[Server] function 'System.Void RoR2.InfiniteTowerWaveController::OnTimerExpire()' called on client");
						return;
					}
					((InfiniteTowerWaveController)self).MarkAsFinished();
					Debug.Log((object)"Preventing early moving of crab");
				}
				else
				{
					orig.Invoke(self);
				}
			}

			internal void <AddHooks>b__2_3(orig_OnEnter orig, Unburrow self)
			{
				orig.Invoke(self);
				if (NetworkServer.active)
				{
					GoldTitanManager.EndChannelingTitansServer((object)((EntityState)self).gameObject);
				}
			}

			internal void <AddHooks>b__2_4(orig_OnEnter orig, AwaitingPortalUse self)
			{
				orig.Invoke(self);
				if (NetworkServer.active)
				{
					GoldTitanManager.EndChannelingTitansServer((object)((EntityState)self).gameObject);
				}
			}

			internal void <AddHooks>b__2_5(orig_OnEnter orig, Burrow self)
			{
				float radius = ((EntityState)self).GetComponent<VerticalTubeZone>().radius;
				self.radius = radius;
				orig.Invoke(self);
			}

			internal void <AddHooks>b__2_6(orig_OnEnter orig, Unburrow self)
			{
				orig.Invoke(self);
				GameObject waveInstance = ((Component)Run.instance).GetComponent<InfiniteTowerRun>().waveInstance;
				if (self.duration > 0f && Object.op_Implicit((Object)(object)waveInstance))
				{
					self.duration = waveInstance.GetComponent<InfiniteTowerWaveController>().secondsAfterWave;
				}
			}
		}

		public static float baseRadius = 65f;

		public static float radiusPerPlayer = 5f;

		internal static void AddHooks()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected O, but got Unknown
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Expected O, but got Unknown
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Expected O, but got Unknown
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Expected O, but got Unknown
			//IL_00d9: 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_00e4: Expected O, but got Unknown
			//IL_0134: 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_013f: Expected O, but got Unknown
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Expected O, but got Unknown
			baseRadius = WConfig.cfgCrabRadius.Value;
			radiusPerPlayer = WConfig.cfgCrabRadiusPerPlayer.Value;
			object obj = <>c.<>9__2_0;
			if (obj == null)
			{
				hook_MoveSafeWard val = delegate(orig_MoveSafeWard orig, InfiniteTowerRun self)
				{
					if (self.waveIndex % 5 != 0)
					{
						Debug.Log((object)"Preventing early moving of crab");
					}
					else
					{
						orig.Invoke(self);
					}
				};
				<>c.<>9__2_0 = val;
				obj = (object)val;
			}
			InfiniteTowerRun.MoveSafeWard += (hook_MoveSafeWard)obj;
			object obj2 = <>c.<>9__2_1;
			if (obj2 == null)
			{
				hook_OnTimerExpire val2 = delegate(orig_OnTimerExpire orig, InfiniteTowerBossWaveController self)
				{
					if (((InfiniteTowerWaveController)self).waveIndex % 5 != 0)
					{
						if (!NetworkServer.active)
						{
							Debug.LogWarning((object)"[Server] function 'System.Void RoR2.InfiniteTowerWaveController::OnTimerExpire()' called on client");
						}
						else
						{
							((InfiniteTowerWaveController)self).MarkAsFinished();
							Debug.Log((object)"Preventing early moving of crab");
						}
					}
					else
					{
						orig.Invoke(self);
					}
				};
				<>c.<>9__2_1 = val2;
				obj2 = (object)val2;
			}
			InfiniteTowerBossWaveController.OnTimerExpire += (hook_OnTimerExpire)obj2;
			object obj3 = <>c.<>9__2_2;
			if (obj3 == null)
			{
				hook_OnTimerExpire val3 = delegate(orig_OnTimerExpire orig, InfiniteTowerExplicitSpawnWaveController self)
				{
					if (((InfiniteTowerWaveController)self).waveIndex % 5 != 0)
					{
						if (!NetworkServer.active)
						{
							Debug.LogWarning((object)"[Server] function 'System.Void RoR2.InfiniteTowerWaveController::OnTimerExpire()' called on client");
						}
						else
						{
							((InfiniteTowerWaveController)self).MarkAsFinished();
							Debug.Log((object)"Preventing early moving of crab");
						}
					}
					else
					{
						orig.Invoke(self);
					}
				};
				<>c.<>9__2_2 = val3;
				obj3 = (object)val3;
			}
			InfiniteTowerExplicitSpawnWaveController.OnTimerExpire += (hook_OnTimerExpire)obj3;
			object obj4 = <>c.<>9__2_3;
			if (obj4 == null)
			{
				hook_OnEnter val4 = delegate(orig_OnEnter orig, Unburrow self)
				{
					orig.Invoke(self);
					if (NetworkServer.active)
					{
						GoldTitanManager.EndChannelingTitansServer((object)((EntityState)self).gameObject);
					}
				};
				<>c.<>9__2_3 = val4;
				obj4 = (object)val4;
			}
			Unburrow.OnEnter += (hook_OnEnter)obj4;
			AwaitingPortalUse.OnEnter += new hook_OnEnter(Radius_AwaitingPortalUse_OnEnter);
			object obj5 = <>c.<>9__2_4;
			if (obj5 == null)
			{
				hook_OnEnter val5 = delegate(orig_OnEnter orig, AwaitingPortalUse self)
				{
					orig.Invoke(self);
					if (NetworkServer.active)
					{
						GoldTitanManager.EndChannelingTitansServer((object)((EntityState)self).gameObject);
					}
				};
				<>c.<>9__2_4 = val5;
				obj5 = (object)val5;
			}
			AwaitingPortalUse.OnEnter += (hook_OnEnter)obj5;
			Active.OnEnter += new hook_OnEnter(Activate_SetCorrectRadius);
			AwaitingActivation.OnEnter += new hook_OnEnter(Waiting_SetRadius);
			Travelling.OnEnter += new hook_OnEnter(Travelling_RadiusAndSpeed);
			object obj6 = <>c.<>9__2_5;
			if (obj6 == null)
			{
				hook_OnEnter val6 = delegate(orig_OnEnter orig, Burrow self)
				{
					float radius = ((EntityState)self).GetComponent<VerticalTubeZone>().radius;
					self.radius = radius;
					orig.Invoke(self);
				};
				<>c.<>9__2_5 = val6;
				obj6 = (object)val6;
			}
			Burrow.OnEnter += (hook_OnEnter)obj6;
			object obj7 = <>c.<>9__2_6;
			if (obj7 == null)
			{
				hook_OnEnter val7 = delegate(orig_OnEnter orig, Unburrow self)
				{
					orig.Invoke(self);
					GameObject waveInstance = ((Component)Run.instance).GetComponent<InfiniteTowerRun>().waveInstance;
					if (self.duration > 0f && Object.op_Implicit((Object)(object)waveInstance))
					{
						self.duration = waveInstance.GetComponent<InfiniteTowerWaveController>().secondsAfterWave;
					}
				};
				<>c.<>9__2_6 = val7;
				obj7 = (object)val7;
			}
			Unburrow.OnEnter += (hook_OnEnter)obj7;
		}

		private static void Radius_AwaitingPortalUse_OnEnter(orig_OnEnter orig, AwaitingPortalUse self)
		{
			((BaseSafeWardState)self).zone = ((EntityState)self).GetComponent<VerticalTubeZone>();
			float num = baseRadius + (float)Run.instance.participatingPlayerCount * radiusPerPlayer;
			if (Object.op_Implicit((Object)(object)((BaseSafeWardState)self).zone) && ((BaseSafeWardState)self).zone.radius > num)
			{
				RadiusShrinker radiusShrinker = ((EntityState)self).gameObject.AddComponent<RadiusShrinker>();
				radiusShrinker.originalRadius = ((BaseSafeWardState)self).zone.radius;
				radiusShrinker.newRadius = num;
				self.radius = ((BaseSafeWardState)self).zone.radius;
			}
			else
			{
				self.radius = num;
			}
			orig.Invoke(self);
		}

		public static void Waiting_SetRadius(orig_OnEnter orig, AwaitingActivation self)
		{
			InfiniteTowerRun component = ((Component)Run.instance).GetComponent<InfiniteTowerRun>();
			if (Object.op_Implicit((Object)(object)component.waveInstance))
			{
				float radius = baseRadius + (float)Run.instance.participatingPlayerCount * radiusPerPlayer;
				self.radius = radius;
			}
			else
			{
				self.radius = baseRadius / 2f;
			}
			orig.Invoke(self);
			if (!Object.op_Implicit((Object)(object)component.safeWardController))
			{
				component.safeWardController = ((EntityState)self).gameObject.GetComponent<InfiniteTowerSafeWardController>();
			}
		}

		public static void Travelling_RadiusAndSpeed(orig_OnEnter orig, Travelling self)
		{
			((BaseSafeWardState)self).zone = ((EntityState)self).GetComponent<VerticalTubeZone>();
			self.radius = ((BaseSafeWardState)self).zone.radius;
			orig.Invoke(self);
			float num = baseRadius / 2f;
			float num2 = 1f;
			float num3 = ((Component)Run.instance).GetComponent<InfiniteTowerRun>().Network_waveIndex;
			if (WConfig.cfgCrabSpeedOnLaterWaves.Value)
			{
				num2 = 1f + (num3 - 10f) / 50f + 0.1f;
				if (num3 > 30f)
				{
					num2 += (num3 - 25f) / 50f;
					if (num2 > 3f)
					{
						num2 = 3f;
					}
				}
				num = Mathf.Min(num * (0.5f + 0.5f * num2), baseRadius);
				self.travelSpeed *= num2;
				self.pathMaxSpeed *= num2;
			}
			if (Object.op_Implicit((Object)(object)RunArtifactManager.instance) && RunArtifactManager.instance.IsArtifactEnabled(ArtifactReal.ArtifactUseNormalStages))
			{
				num = baseRadius;
			}
			else if (Object.op_Implicit((Object)(object)((BaseSafeWardState)self).zone) && ((BaseSafeWardState)self).zone.radius > num)
			{
				RadiusShrinker radiusShrinker = ((EntityState)self).gameObject.AddComponent<RadiusShrinker>();
				radiusShrinker.originalRadius = ((BaseSafeWardState)self).zone.radius;
				radiusShrinker.remove *= 2f;
				radiusShrinker.newRadius = num;
			}
			Debug.Log((object)("Wave:" + num3 + " speedMult:" + num2 + " TravellingSpeed:" + self.travelSpeed + " Radius:" + num));
		}

		private static void Activate_SetCorrectRadius(orig_OnEnter orig, Active self)
		{
			orig.Invoke(self);
			if (Object.op_Implicit((Object)(object)Run.instance) && Run.instance is InfiniteTowerRun && Object.op_Implicit((Object)(object)((InfiniteTowerRun)/*isinst with value type is only supported in some contexts*/).waveInstance))
			{
				Run instance = Run.instance;
				SimulacrumExtrasHelper component = ((InfiniteTowerRun)((instance is InfiniteTowerRun) ? instance : null)).waveInstance.GetComponent<SimulacrumExtrasHelper>();
				if (Object.op_Implicit((Object)(object)component) && component.newRadius > 0f)
				{
					float num = baseRadius + (component.newRadius - 60f) + (float)Run.instance.participatingPlayerCount * radiusPerPlayer;
					Reflection.SetFieldValue<float>((object)((BaseSafeWardState)self).safeWardController.wardStateMachine.state, "radius", component.newRadius);
					((BaseSafeWardState)self).safeWardController.holdoutZoneController.baseRadius = component.newRadius;
				}
				else
				{
					float num2 = baseRadius + (float)Run.instance.participatingPlayerCount * radiusPerPlayer;
					Reflection.SetFieldValue<float>((object)((BaseSafeWardState)self).safeWardController.wardStateMachine.state, "radius", num2);
					((BaseSafeWardState)self).safeWardController.holdoutZoneController.baseRadius = num2;
				}
			}
		}
	}
	public class Wave_Hooks
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_DropRewards <>9__0_0;

			internal void <AddHooks>b__0_0(orig_DropRewards orig, InfiniteTowerWaveController self)
			{
				orig.Invoke(self);
				SimulacrumExtrasHelper component = ((Component)self).GetComponent<SimulacrumExtrasHelper>();
				if (Object.op_Implicit((Object)(object)component) && (Object)(object)component.rewardDropTable != (Object)null)
				{
					component.DropRewards();
				}
			}
		}

		internal static void AddHooks()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			InfiniteTowerRun.InitializeWaveController += new hook_InitializeWaveController(InfiniteTowerRun_BeginNextWave);
			InfiniteTowerExplicitSpawnWaveController.Initialize += new hook_Initialize(GiveStatBoosts_ExplicitSpawnWaveController_Initialize);
			InfiniteTowerWaveController.OnCombatSquadMemberDiscovered += new hook_OnCombatSquadMemberDiscovered(InfiniteTowerWaveController_OnCombatSquadMemberDiscovered);
			InfiniteTowerWaveController.StartTimer += new hook_StartTimer(KillAllGhosts_StartTimer);
			InfiniteTowerWaveController.OnAllEnemiesDefeatedServer += new hook_OnAllEnemiesDefeatedServer(InfiniteTowerWaveController_OnAllEnemiesDefeatedServer);
			InfiniteTowerRun.CleanUpCurrentWave += new hook_CleanUpCurrentWave(InfiniteTowerRun_CleanUpCurrentWave);
			SimulacrumExtrasHelper.shareSuitInstalled = Chainloader.PluginInfos.ContainsKey("com.funkfrog_sipondo.sharesuite");
			object obj = <>c.<>9__0_0;
			if (obj == null)
			{
				hook_DropRewards val = delegate(orig_DropRewards orig, InfiniteTowerWaveController self)
				{
					orig.Invoke(self);
					SimulacrumExtrasHelper component = ((Component)self).GetComponent<SimulacrumExtrasHelper>();
					if (Object.op_Implicit((Object)(object)component) && (Object)(object)component.rewardDropTable != (Object)null)
					{
						component.DropRewards();
					}
				};
				<>c.<>9__0_0 = val;
				obj = (object)val;
			}
			InfiniteTowerWaveController.DropRewards += (hook_DropRewards)obj;
		}

		private static void KillAllGhosts_StartTimer(orig_StartTimer orig, InfiniteTowerWaveController self)
		{
			orig.Invoke(self);
			if (WConfig.cfgFasterWavesLater.Value && self.waveIndex % 5 != 0)
			{
				int num = Mathf.Min(5, Run.instance.participatingPlayerCount);
				self.Network_timerStart += (float)(self.waveIndex / 10 * num) * 0.2f;
				Debug.Log((object)("secondsAfterWave: " + self.Network_timerStart));
			}
			MusicTrackOverride component = ((Component)self).gameObject.GetComponent<MusicTrackOverride>();
			if (Object.op_Implicit((Object)(object)component))
			{
				((Behaviour)component).enabled = false;
			}
			if (!NetworkServer.active)
			{
				return;
			}
			for (int i = 0; i < CharacterMaster.instancesList.Count; i++)
			{
				CharacterMaster val = CharacterMaster.instancesList[i];
				if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val.inventory))
				{
					continue;
				}
				int itemCount = val.inventory.GetItemCount(ItemHelpers.ITKillOnCompletion);
				if (itemCount > 0)
				{
					val.inventory.GiveItem(Items.HealthDecay, 1);
				}
				if (itemCount <= 6)
				{
					continue;
				}
				try
				{
					val.TrueKill();
				}
				catch (Exception ex)
				{
					Debug.Log((object)ex);
					if (val.inventory.GetItemCount(Items.ExtraLife) > 0)
					{
						val.inventory.ResetItem(Items.ExtraLife);
					}
					if (val.inventory.GetItemCount(Items.ExtraLifeVoid) > 0)
					{
						val.inventory.ResetItem(Items.ExtraLifeVoid);
					}
					((MonoBehaviour)val).CancelInvoke("RespawnExtraLife");
					((MonoBehaviour)val).CancelInvoke("PlayExtraLifeSFX");
					((MonoBehaviour)val).CancelInvoke("RespawnExtraLifeVoid");
					((MonoBehaviour)val).CancelInvoke("PlayExtraLifeVoidSFX");
					((MonoBehaviour)val).CancelInvoke("RespawnExtraLifeShrine");
				}
				Object.Destroy((Object)(object)((Component)val).gameObject, 2f);
			}
		}

		public static void InfiniteTowerWaveController_OnAllEnemiesDefeatedServer(orig_OnAllEnemiesDefeatedServer orig, InfiniteTowerWaveController self)
		{
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Expected O, but got Unknown
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Expected O, but got Unknown
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Expected O, but got Unknown
			orig.Invoke(self);
			CombatDirector[] components = ((Component)self).gameObject.GetComponents<CombatDirector>();
			if (components.Length > 1)
			{
				((Behaviour)((Component)self).gameObject.GetComponents<CombatDirector>()[0]).enabled = false;
				((Behaviour)((Component)self).gameObject.GetComponents<CombatDirector>()[1]).enabled = false;
			}
			SimulacrumInteractablesWaveHelper component = ((Component)self).gameObject.GetComponent<SimulacrumInteractablesWaveHelper>();
			if (Object.op_Implicit((Object)(object)component))
			{
				((Behaviour)component).enabled = false;
			}
			InfiniteTowerRun component2 = ((Component)Run.instance).GetComponent<InfiniteTowerRun>();
			if (component2.waveIndex >= SimuMain.SimuEndingStartAtXWaves && component2.waveIndex % SimuMain.SimuEndingEveryXWaves == SimuMain.SimuEndingWaveRest)
			{
				GameObject val = DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest((SpawnCard)(object)SimuMain.iscSimuExitPortal, new DirectorPlacementRule
				{
					minDistance = 30f,
					maxDistance = 35f,
					placementMode = (PlacementMode)1,
					position = ((Component)component2.safeWardController).transform.position,
					spawnOnTarget = ((Component)component2.safeWardController).transform
				}, component2.safeWardRng));
			}
			if (((Object)self).name.EndsWith("EquipmentDrone(Clone)"))
			{
				MeteorStormController[] array = Object.FindObjectsOfType(typeof(MeteorStormController)) as MeteorStormController[];
				if (array.Length != 0)
				{
					for (int i = 0; i < array.Length; i++)
					{
						Object.Destroy((Object)(object)((Component)array[i]).gameObject);
					}
				}
				BuffWard[] array2 = Object.FindObjectsOfType(typeof(BuffWard)) as BuffWard[];
				if (array2.Length != 0)
				{
					GameObject val2 = LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/BrittleDeath");
					for (int j = 0; j < array2.Length; j++)
					{
						if (Object.op_Implicit((Object)(object)(array2[j].buffDef = Buffs.Cripple)))
						{
							Object.Destroy((Object)(object)((Component)array2[j]).gameObject);
							EffectManager.SpawnEffect(val2, new EffectData
							{
								origin = ((Component)array2[j]).transform.position,
								rotation = ((Component)array2[j]).transform.rotation
							}, true);
						}
					}
				}
			}
			else if (((Object)self).name.EndsWith("Enigma(Clone)"))
			{
				((Component)self).GetComponent<ArtifactEnabler>().OnDisable();
			}
			else if (Object.op_Implicit((Object)(object)((Component)self).GetComponent<SimulacrumLightningStormWave>()))
			{
				((Component)self).GetComponent<SimulacrumLightningStormWave>().DisableStorm();
			}
			if (Object.op_Implicit((Object)(object)Run.instance))
			{
				((Component)Run.instance).GetComponent<EnemyInfoPanelInventoryProvider>().MarkAsDirty();
			}
			Debug.Log((object)("OnAllEnemiesDefeatedServer  " + (object)self));
		}

		private static void GiveStatBoosts_ExplicitSpawnWaveController_Initialize(orig_Initialize orig, InfiniteTowerExplicitSpawnWaveController self, int waveIndex, Inventory enemyInventory, GameObject spawnTargetObject)
		{
			//IL_0711: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0673: Unknown result type (might be due to invalid IL or missing references)
			//IL_06dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0545: Unknown result type (might be due to invalid IL or missing references)
			//IL_0560: Unknown result type (might be due to invalid IL or missing references)
			//IL_0562: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0617: Unknown result type (might be due to invalid IL or missing references)
			//IL_0631: Unknown result type (might be due to invalid IL or missing references)
			//IL_0633: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkServer.active)
			{
				if (((InfiniteTowerWaveController)self).linearCreditsPerWave * (float)waveIndex > 400f)
				{
					((InfiniteTowerWaveController)self).linearCreditsPerWave = ((InfiniteTowerWaveController)self).linearCreditsPerWave * (float)waveIndex / 400f;
				}
				float num = 0.5f;
				float num2 = 0.5f;
				bool flag = false;
				if (waveIndex >= SimuMain.SimuForcedBossStartAtXWaves && waveIndex % SimuMain.SimuForcedBossEveryXWaves == SimuMain.SimuForcedBossWaveRest)
				{
					flag = true;
					num = 1f;
				}
				if (Object.op_Implicit((Object)(object)((Component)self).GetComponent<CardRandomizer>()))
				{
					((Component)self).GetComponent<CardRandomizer>().DoTheThing(self);
				}
				int num3 = 0;
				bool flag2 = false;
				switch (((Object)self).name)
				{
				case "InfiniteTowerWaveBossVoidElites(Clone)":
					num = 3f;
					break;
				case "InfiniteTowerWaveBossCharacters(Clone)":
					num = 1.2f;
					flag2 = true;
					if (waveIndex > 29)
					{
						self.spawnList[0].spawnCard.itemsToGrant[0].count = 1;
					}
					else
					{
						self.spawnList[0].spawnCard.itemsToGrant[0].count = 0;
					}
					break;
				case "InfiniteTowerWaveSS2RainbowElites(Clone)":
				{
					num = -1f;
					DirectorCard val = ((Component)self).GetComponent<CombatDirector>().SelectMonsterCardForCombatShrine((float)(waveIndex * 2 + 20));
					if (val == null)
					{
						Debug.LogWarning((object)"Could not find Emyprean candidate normally");
						val = ClassicStageInfo.instance.monsterCategories.categories[2].cards[0];
					}
					((SpawnCard)self.spawnList[0].spawnCard).prefab = val.spawnCard.prefab;
					((SpawnCard)self.spawnList[0].spawnCard).nodeGraphType = val.spawnCard.nodeGraphType;
					break;
				}
				}
				SimuExplicitStats component = ((Component)self).GetComponent<SimuExplicitStats>();
				if (Object.op_Implicit((Object)(object)component))
				{
					if (component.halfOnNonFinal && !flag)
					{
						num = component.hpBonusMulti / 2f;
						num2 = component.damageBonusMulti / 2f;
					}
					else
					{
						num2 = component.damageBonusMulti;
						num = component.hpBonusMulti;
					}
					if (component.spawnAsVoidTeam)
					{
						((InfiniteTowerWaveController)self).combatDirector.teamIndex = (TeamIndex)4;
					}
					if (component.ExtraSpawnAfterWave > 0 && waveIndex > component.ExtraSpawnAfterWave)
					{
						self.spawnList[0].count++;
					}
				}
				if (num > 0f)
				{
					float num4 = 1f;
					float num5 = 1f;
					num4 += Run.instance.difficultyCoefficient / 2.5f * Math.Max(1f, (float)(waveIndex / 10) * 0.225f + 0.225f);
					num5 += Run.instance.difficultyCoefficient / 30f * Math.Max(1f, (float)(waveIndex / 10) * 0.04f);
					num4 *= num;
					num5 *= num2;
					if (flag)
					{
						num4 /= 1f + (float)(Run.instance.participatingPlayerCount - 1) * 0.2f;
						int participatingPlayerCount = Run.instance.participatingPlayerCount;
						num4 *= Mathf.Pow((float)participatingPlayerCount, 0.4f);
					}
					int num6 = Mathf.RoundToInt((num4 - 1f) * 10f);
					int num7 = Mathf.RoundToInt((num5 - 1f) * 10f);
					if (num6 > 100000)
					{
						num6 = 100000;
					}
					Debug.LogFormat(((Object)self).name + " Special Scaling: currentBoostHpCoefficient={0}, currentBoostDamageCoefficient={1}", new object[2] { num6, num7 });
					for (int i = 0; i < self.spawnList.Length; i++)
					{
						bool flag3 = true;
						bool flag4 = true;
						bool flag5 = true;
						for (int j = 0; j < self.spawnList[i].spawnCard.itemsToGrant.Length; j++)
						{
							if ((Object)(object)self.spawnList[i].spawnCard.itemsToGrant[j].itemDef == (Object)(object)Items.BoostHp)
							{
								flag3 = false;
								self.spawnList[i].spawnCard.itemsToGrant[j].count = num6;
							}
							else if ((Object)(object)self.spawnList[i].spawnCard.itemsToGrant[j].itemDef == (Object)(object)Items.BoostDamage)
							{
								flag4 = false;
								self.spawnList[i].spawnCard.itemsToGrant[j].count = num7;
							}
							else if ((Object)(object)self.spawnList[i].spawnCard.itemsToGrant[j].itemDef == (Object)(object)Items.TeleportWhenOob)
							{
								flag5 = false;
							}
						}
						if (flag3)
						{
							self.spawnList[i].spawnCard.itemsToGrant = self.spawnList[i].spawnCard.itemsToGrant.Add(new ItemCountPair
							{
								itemDef = Items.BoostHp,
								count = num6
							});
						}
						if (flag4)
						{
							self.spawnList[i].spawnCard.itemsToGrant = self.spawnList[i].spawnCard.itemsToGrant.Add(new ItemCountPair
							{
								itemDef = Items.BoostDamage,
								count = num7
							});
						}
						if (flag5)
						{
							self.spawnList[i].spawnCard.itemsToGrant = self.spawnList[i].spawnCard.itemsToGrant.Add(new ItemCountPair
							{
								itemDef = Items.TeleportWhenOob,
								count = 1
							});
						}
					}
				}
				if (flag2)
				{
					((InfiniteTowerWaveController)self).combatDirector.teamIndex = (TeamIndex)4;
					((InfiniteTowerWaveController)self).enemyInventory = en