Decompiled source of Judgement v1.5.3

plugins/Judgement/Judgement.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using EntityStates.InfiniteTowerSafeWard;
using EntityStates.Missions.BrotherEncounter;
using HG.Reflection;
using HarmonyLib;
using IL.RoR2;
using IL.RoR2.UI.MainMenu;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.Utils;
using On.EntityStates.InfiniteTowerSafeWard;
using On.EntityStates.Missions.BrotherEncounter;
using On.RoR2;
using On.RoR2.UI;
using R2API;
using R2API.Utils;
using RoR2;
using RoR2.Artifacts;
using RoR2.ExpansionManagement;
using RoR2.UI;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: NetworkCompatibility(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Judgement")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+2bd6ec18cf4cbff9e0cb466f3c0bfa52800af467")]
[assembly: AssemblyProduct("Judgement")]
[assembly: AssemblyTitle("Judgement")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
public class CheckWavePickups : MonoBehaviour
{
	private List<GameObject> potentialList = new List<GameObject>();

	public void AddPickup(GameObject pickup)
	{
		potentialList.Add(pickup);
	}

	public bool CanStartWave()
	{
		bool flag = false;
		Debug.LogWarning((object)$"PotentialList Count Before {potentialList.Count}");
		potentialList.RemoveAll(delegate(GameObject potential)
		{
			Debug.LogWarning((object)$"Potential object {potential}");
			return ((Object)(object)potential == (Object)null) ? true : false;
		});
		Debug.LogWarning((object)$"PotentialList Count After {potentialList.Count}");
		if (potentialList.Count <= 0)
		{
			flag = true;
		}
		Debug.LogWarning((object)$"Can Start Wave? {flag}");
		return flag;
	}
}
namespace Judgement
{
	public class CreateGameMode
	{
		public class JudgementRunButton : MonoBehaviour
		{
			[Serializable]
			[CompilerGenerated]
			private sealed class <>c
			{
				public static readonly <>c <>9 = new <>c();

				public static UnityAction <>9__1_0;

				internal void <Start>b__1_0()
				{
					Util.PlaySound("Play_UI_menuClick", ((Component)RoR2Application.instance).gameObject);
					Console.instance.SubmitCmd((NetworkUser)null, "transition_command \"gamemode xJudgementRun; host 0; \"", false);
				}
			}

			public HGButton hgButton;

			public void Start()
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Expected O, but got Unknown
				//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_0046: Expected O, but got Unknown
				hgButton = ((Component)this).GetComponent<HGButton>();
				((Button)hgButton).onClick = new ButtonClickedEvent();
				ButtonClickedEvent onClick = ((Button)hgButton).onClick;
				object obj = <>c.<>9__1_0;
				if (obj == null)
				{
					UnityAction val = delegate
					{
						Util.PlaySound("Play_UI_menuClick", ((Component)RoR2Application.instance).gameObject);
						Console.instance.SubmitCmd((NetworkUser)null, "transition_command \"gamemode xJudgementRun; host 0; \"", false);
					};
					<>c.<>9__1_0 = val;
					obj = (object)val;
				}
				((UnityEvent)onClick).AddListener((UnityAction)obj);
			}
		}

		public class JudgementRunButtonAdder : MonoBehaviour
		{
			public void Start()
			{
				GameObject obj = Object.Instantiate<GameObject>(((Component)((Component)this).transform.Find("GenericMenuButton (Eclipse)")).gameObject, ((Component)this).transform);
				obj.AddComponent<JudgementRunButton>();
				obj.GetComponent<LanguageTextMeshController>().token = "Judgement";
				obj.GetComponent<HGButton>().hoverToken = "Defeat all that stand before you to reach the final throne.";
			}
		}

		public static GameObject judgementRunPrefab;

		public static GameObject extraGameModeMenu;

		private GameObject simClone = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/GameModes/InfiniteTowerRun/InfiniteTowerRun.prefab").WaitForCompletion();

		public CreateGameMode()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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
			CreateJudgementRun();
			MultiplayerMenuController.BuildGameModeChoices += new Manipulator(AddGameModeToMultiplayer);
			GameModeCatalog.SetGameModes += new hook_SetGameModes(SortGameModes);
			LanguageTextMeshController.Start += new hook_Start(AddGameModeButton);
		}

		private static void AddGameModeToMultiplayer(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0039: 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)
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallvirt(x, (MethodBase)typeof(List<string>).GetMethod("Contains"))
			}))
			{
				val.Emit(OpCodes.Pop);
				val.Emit(OpCodes.Ldc_I4_1);
			}
			else
			{
				Log.Error("Judgement: Failed to apply AddGameModeToMultiplayer IL Hook", "C:\\Users\\Nux\\Desktop\\RoR2Modding\\Dev\\Judgement\\Judgement\\CreateGameMode.cs", "AddGameModeToMultiplayer", 41);
			}
		}

		private void SortGameModes(orig_SetGameModes orig, Run[] newGameModePrefabComponents)
		{
			Array.Sort(newGameModePrefabComponents, (Run a, Run b) => string.CompareOrdinal(((Object)a).name, ((Object)b).name));
			orig.Invoke(newGameModePrefabComponents);
		}

		private void AddGameModeButton(orig_Start orig, LanguageTextMeshController self)
		{
			orig.Invoke(self);
			if (self.token == "TITLE_ECLIPSE" && Object.op_Implicit((Object)(object)((Component)self).GetComponent<HGButton>()))
			{
				((Component)((Component)self).transform.parent).gameObject.AddComponent<JudgementRunButtonAdder>();
			}
		}

		private void CreateJudgementRun()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: 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_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: 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_012b: Unknown result type (might be due to invalid IL or missing references)
			judgementRunPrefab = PrefabAPI.InstantiateClone(new GameObject("xJudgementRun"), "xJudgementRun");
			judgementRunPrefab.AddComponent<NetworkIdentity>();
			PrefabAPI.RegisterNetworkPrefab(judgementRunPrefab);
			InfiniteTowerRun component = simClone.GetComponent<InfiniteTowerRun>();
			JudgementRun judgementRun = judgementRunPrefab.AddComponent<JudgementRun>();
			((Run)judgementRun).nameToken = "Judgement";
			((Run)judgementRun).userPickable = true;
			((Run)judgementRun).startingSceneGroup = ((Run)component).startingSceneGroup;
			((Run)judgementRun).gameOverPrefab = ((Run)component).gameOverPrefab;
			((Run)judgementRun).lobbyBackgroundPrefab = ((Run)component).lobbyBackgroundPrefab;
			((Run)judgementRun).uiPrefab = ((Run)component).uiPrefab;
			((InfiniteTowerRun)judgementRun).defaultWavePrefab = component.defaultWavePrefab;
			List<WeightedWave> list = new List<WeightedWave>();
			List<WeightedWave> list2 = new List<WeightedWave>();
			InfiniteTowerWaveCategory[] waveCategories = component.waveCategories;
			foreach (InfiniteTowerWaveCategory val in waveCategories)
			{
				WeightedWave[] wavePrefabs;
				if (((Object)val).name == "BossWaveCategory")
				{
					wavePrefabs = val.wavePrefabs;
					foreach (WeightedWave val2 in wavePrefabs)
					{
						if (!((Object)val2.wavePrefab).name.Contains("Brother") && !((Object)val2.wavePrefab).name.Contains("Lunar") && !((Object)val2.wavePrefab).name.Contains("Void"))
						{
							list2.Add(val2);
						}
					}
					continue;
				}
				wavePrefabs = val.wavePrefabs;
				foreach (WeightedWave val3 in wavePrefabs)
				{
					if (!((Object)val3.wavePrefab).name.Contains("Command"))
					{
						list.Add(val3);
					}
				}
			}
			InfiniteTowerWaveCategory val4 = ScriptableObject.CreateInstance<InfiniteTowerWaveCategory>();
			((Object)val4).name = "CommonWaveCategoryNux";
			val4.wavePrefabs = list.ToArray();
			val4.availabilityPeriod = 1;
			val4.minWaveIndex = 0;
			InfiniteTowerWaveCategory val5 = ScriptableObject.CreateInstance<InfiniteTowerWaveCategory>();
			((Object)val5).name = "BossWaveCategoryNux";
			val5.wavePrefabs = list2.ToArray();
			val5.availabilityPeriod = 2;
			val5.minWaveIndex = 0;
			InfiniteTowerWaveCategory[] waveCategories2 = (InfiniteTowerWaveCategory[])(object)new InfiniteTowerWaveCategory[2] { val5, val4 };
			((InfiniteTowerRun)judgementRun).waveCategories = waveCategories2;
			((InfiniteTowerRun)judgementRun).defaultWaveEnemyIndicatorPrefab = component.defaultWaveEnemyIndicatorPrefab;
			((InfiniteTowerRun)judgementRun).enemyItemPattern = component.enemyItemPattern;
			((InfiniteTowerRun)judgementRun).enemyItemPeriod = 100;
			((InfiniteTowerRun)judgementRun).enemyInventory = judgementRunPrefab.AddComponent<Inventory>();
			((InfiniteTowerRun)judgementRun).stageTransitionPeriod = 2;
			((InfiniteTowerRun)judgementRun).stageTransitionPortalCard = component.stageTransitionPortalCard;
			((InfiniteTowerRun)judgementRun).stageTransitionPortalMaxDistance = component.stageTransitionPortalMaxDistance;
			((InfiniteTowerRun)judgementRun).stageTransitionChatToken = component.stageTransitionChatToken;
			((InfiniteTowerRun)judgementRun).fogDamagePrefab = component.fogDamagePrefab;
			((InfiniteTowerRun)judgementRun).spawnMaxRadius = component.spawnMaxRadius;
			((InfiniteTowerRun)judgementRun).initialSafeWardCard = component.initialSafeWardCard;
			((InfiniteTowerRun)judgementRun).safeWardCard = component.safeWardCard;
			((InfiniteTowerRun)judgementRun).playerRespawnEffectPrefab = component.playerRespawnEffectPrefab;
			((InfiniteTowerRun)judgementRun).interactableCredits = 0;
			((InfiniteTowerRun)judgementRun).blacklistedTags = component.blacklistedTags;
			((InfiniteTowerRun)judgementRun).blacklistedItems = component.blacklistedItems;
			judgementRunPrefab.AddComponent<TeamManager>();
			judgementRunPrefab.AddComponent<NetworkRuleBook>();
			judgementRunPrefab.AddComponent<TeamFilter>();
			judgementRunPrefab.AddComponent<EnemyInfoPanelInventoryProvider>();
			judgementRunPrefab.AddComponent<DirectorCore>();
			judgementRunPrefab.AddComponent<ExpansionRequirementComponent>();
			judgementRunPrefab.AddComponent<RunCameraManager>();
			ContentAddition.AddGameMode(judgementRunPrefab);
		}
	}
	public class EntityStateHooks
	{
		public EntityStateHooks()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			AwaitingActivation.OnEnter += new hook_OnEnter(ChangeBaseWardRadius);
			Active.OnEnter += new hook_OnEnter(ChangeActiveWardRadius);
		}

		private void ChangeBaseWardRadius(orig_OnEnter orig, AwaitingActivation self)
		{
			if (Object.op_Implicit((Object)(object)Run.instance) && ((Object)Run.instance).name.Contains("Judgement") && self.radius != 30f)
			{
				self.radius = 30f;
			}
			orig.Invoke(self);
		}

		private void ChangeActiveWardRadius(orig_OnEnter orig, Active self)
		{
			if (Object.op_Implicit((Object)(object)Run.instance) && ((Object)Run.instance).name.Contains("Judgement"))
			{
				self.radius = 75f;
			}
			orig.Invoke(self);
		}
	}
	public class RunHooks
	{
		private BasicPickupDropTable dtEquip = Addressables.LoadAssetAsync<BasicPickupDropTable>((object)"RoR2/Base/Common/dtEquipment.asset").WaitForCompletion();

		private BasicPickupDropTable dtWhite = Addressables.LoadAssetAsync<BasicPickupDropTable>((object)"RoR2/Base/Common/dtTier1Item.asset").WaitForCompletion();

		private BasicPickupDropTable dtGreen = Addressables.LoadAssetAsync<BasicPickupDropTable>((object)"RoR2/Base/Common/dtTier2Item.asset").WaitForCompletion();

		private BasicPickupDropTable dtRed = Addressables.LoadAssetAsync<BasicPickupDropTable>((object)"RoR2/Base/Common/dtTier3Item.asset").WaitForCompletion();

		private BasicPickupDropTable dtYellow = Addressables.LoadAssetAsync<BasicPickupDropTable>((object)"RoR2/Base/DuplicatorWild/dtDuplicatorWild.asset").WaitForCompletion();

		private GameObject potentialPickup = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/OptionPickup/OptionPickup.prefab").WaitForCompletion();

		private SceneDef voidPlains = Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC1/itgolemplains/itgolemplains.asset").WaitForCompletion();

		private SceneDef voidAqueduct = Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC1/itgoolake/itgoolake.asset").WaitForCompletion();

		private SceneDef voidAphelian = Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC1/itancientloft/itancientloft.asset").WaitForCompletion();

		private SceneDef voidRPD = Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC1/itfrozenwall/itfrozenwall.asset").WaitForCompletion();

		private SceneDef voidAbyssal = Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC1/itdampcave/itdampcave.asset").WaitForCompletion();

		private SceneDef voidMeadow = Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC1/itskymeadow/itskymeadow.asset").WaitForCompletion();

		private GameEndingDef judgementRunEnding = Addressables.LoadAssetAsync<GameEndingDef>((object)"RoR2/Base/WeeklyRun/PrismaticTrialEnding.asset").WaitForCompletion();

		private GameObject tpOutController = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Common/TeleportOutController.prefab").WaitForCompletion();

		public RunHooks()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Expected O, but got Unknown
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Expected O, but got Unknown
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Expected O, but got Unknown
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Expected O, but got Unknown
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Expected O, but got Unknown
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Expected O, but got Unknown
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Expected O, but got Unknown
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Expected O, but got Unknown
			SceneDirector.PopulateScene += new Manipulator(RemoveExtraLoot);
			PurchaseInteraction.OnInteractionBegin += new hook_OnInteractionBegin(PreventPrinterCheese);
			Run.PickNextStageScene += new hook_PickNextStageScene(SetFirstStage);
			CharacterMaster.OnBodyStart += new hook_OnBodyStart(CreateDropletsOnStart);
			MusicController.PickCurrentTrack += new hook_PickCurrentTrack(SetJudgementMusic);
			BossDeath.OnEnter += new hook_OnEnter(EndRun);
			CharacterBody.Start += new hook_Start(ManageSurvivorStats);
			SceneExitController.Begin += new hook_Begin(ManageStageSelection);
		}

		private void TrackPotentials(orig_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 orig, CreatePickupInfo pickupInfo, Vector3 position, Vector3 velocity)
		{
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: 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_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)Run.instance) && ((Object)Run.instance).name.Contains("Judgement"))
			{
				JudgementRun component = ((Component)Run.instance).gameObject.GetComponent<JudgementRun>();
				if (Object.op_Implicit((Object)(object)((InfiniteTowerRun)component).safeWardController))
				{
					CheckWavePickups component2 = ((Component)((InfiniteTowerRun)component).safeWardController).gameObject.GetComponent<CheckWavePickups>();
					Debug.LogWarning((object)$"Pickup Checker? {component2}");
					if (Object.op_Implicit((Object)(object)component2))
					{
						if (CommandArtifactManager.IsCommandArtifactEnabled)
						{
							ref PickupArtifactFlag artifactFlag = ref pickupInfo.artifactFlag;
							artifactFlag = (PickupArtifactFlag)((uint)artifactFlag | 1u);
						}
						GameObject val = Object.Instantiate<GameObject>(PickupDropletController.pickupDropletPrefab, position, Quaternion.identity);
						PickupDropletController component3 = val.GetComponent<PickupDropletController>();
						if (Object.op_Implicit((Object)(object)component3))
						{
							component3.createPickupInfo = pickupInfo;
							component3.NetworkpickupIndex = ((CreatePickupInfo)(ref pickupInfo)).pickupIndex;
						}
						Rigidbody component4 = val.GetComponent<Rigidbody>();
						component4.velocity = velocity;
						component4.AddTorque(Random.Range(150f, 120f) * Random.onUnitSphere);
						component2.AddPickup(val);
						Debug.LogWarning((object)"Added Pickup");
						NetworkServer.Spawn(val);
					}
					else
					{
						orig.Invoke(pickupInfo, position, velocity);
					}
				}
				else
				{
					orig.Invoke(pickupInfo, position, velocity);
				}
			}
			else
			{
				orig.Invoke(pickupInfo, position, velocity);
			}
		}

		private void PreventPrinterCheese(orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Invalid comparison between Unknown and I4
			JudgementRun component = ((Component)Run.instance).gameObject.GetComponent<JudgementRun>();
			if (Object.op_Implicit((Object)(object)component))
			{
				if (((Object)self).name == "VoidChest(Clone)")
				{
					CharacterBody component2 = ((Component)activator).GetComponent<CharacterBody>();
					if (component.persistentCurse.TryGetValue(((NetworkBehaviour)component2.master).netId, out var _))
					{
						component.persistentCurse[((NetworkBehaviour)component2.master).netId] += 20;
					}
					else
					{
						component.persistentCurse.Add(((NetworkBehaviour)component2.master).netId, 20);
					}
					if ((int)Run.instance.selectedDifficulty < 10)
					{
						for (int i = 0; i < 20; i++)
						{
							component2.AddBuff(Buffs.PermanentCurse);
						}
					}
					orig.Invoke(self, activator);
				}
				else if (((Object)self).name == "DuplicatorLarge(Clone)")
				{
					if (((Component)activator).GetComponent<CharacterBody>().inventory.GetItemCount(Items.RegeneratingScrap) != 0)
					{
						orig.Invoke(self, activator);
					}
				}
				else
				{
					orig.Invoke(self, activator);
				}
			}
			else
			{
				orig.Invoke(self, activator);
			}
		}

		private void SetFirstStage(orig_PickNextStageScene orig, Run self, WeightedSelection<SceneDef> choices)
		{
			if (Run.instance.stageClearCount == 0 && ((Object)self).name.Contains("Judgement"))
			{
				if (((InfiniteTowerRun)((Component)Run.instance).gameObject.GetComponent<JudgementRun>()).waveIndex == 0)
				{
					SceneDef nextStageScene = SceneCatalog.FindSceneDef("itgolemplains");
					self.nextStageScene = nextStageScene;
				}
			}
			else
			{
				orig.Invoke(self, choices);
			}
		}

		public void SavePersistentHP()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			JudgementRun component = ((Component)Run.instance).gameObject.GetComponent<JudgementRun>();
			foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
			{
				if (component.persistentHP.TryGetValue(((NetworkBehaviour)instance.master).netId, out var _))
				{
					component.persistentHP[((NetworkBehaviour)instance.master).netId] = instance.master.GetBody().healthComponent.health;
				}
				else
				{
					component.persistentHP.Add(((NetworkBehaviour)instance.master).netId, instance.master.GetBody().healthComponent.health);
				}
			}
		}

		public void LoadPersistentHP(CharacterBody body)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			JudgementRun component = ((Component)Run.instance).gameObject.GetComponent<JudgementRun>();
			if (Object.op_Implicit((Object)(object)body.master) && Object.op_Implicit((Object)(object)body.healthComponent) && component.persistentHP.TryGetValue(((NetworkBehaviour)body.master).netId, out var value))
			{
				body.healthComponent.health = value;
			}
		}

		public void LoadPersistentCurse(CharacterBody body)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			JudgementRun component = ((Component)Run.instance).gameObject.GetComponent<JudgementRun>();
			if (Object.op_Implicit((Object)(object)body.master) && component.persistentCurse.TryGetValue(((NetworkBehaviour)body.master).netId, out var value))
			{
				for (int i = 0; i < value; i++)
				{
					body.AddBuff(Buffs.PermanentCurse);
				}
			}
		}

		private void RemoveExtraLoot(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "TreasureCache")
			}))
			{
				val.Index += 2;
				val.EmitDelegate<Func<int, int>>((Func<int, int>)((int count) => ItemFunction(count)));
			}
			else
			{
				Log.Error("Judgement: TreasureCache IL hook failed", "C:\\Users\\Nux\\Desktop\\RoR2Modding\\Dev\\Judgement\\Judgement\\Hooks\\RunHooks.cs", "RemoveExtraLoot", 194);
			}
			val.Index = 0;
			if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "TreasureCacheVoid")
			}))
			{
				val.Index += 2;
				val.EmitDelegate<Func<int, int>>((Func<int, int>)((int count) => ItemFunction(count)));
			}
			else
			{
				Log.Error("Judgement: TreasureCacheVoid IL hook failed", "C:\\Users\\Nux\\Desktop\\RoR2Modding\\Dev\\Judgement\\Judgement\\Hooks\\RunHooks.cs", "RemoveExtraLoot", 204);
			}
			val.Index = 0;
			if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "FreeChest")
			}))
			{
				val.Index += 2;
				val.EmitDelegate<Func<int, int>>((Func<int, int>)((int count) => ItemFunction(count)));
			}
			else
			{
				Log.Error("Judgement: FreeChest IL hook failed", "C:\\Users\\Nux\\Desktop\\RoR2Modding\\Dev\\Judgement\\Judgement\\Hooks\\RunHooks.cs", "RemoveExtraLoot", 214);
			}
			static int ItemFunction(int itemCount)
			{
				if (Object.op_Implicit((Object)(object)Run.instance) && ((Object)Run.instance).name.Contains("Judgement"))
				{
					return 0;
				}
				return itemCount;
			}
		}

		private void CreateDropletsOnStart(orig_OnBodyStart orig, CharacterMaster self, CharacterBody body)
		{
			//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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Invalid comparison between Unknown and I4
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Invalid comparison between Unknown and I4
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: 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_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: 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_0249: 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_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_030a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody body2 = body;
			orig.Invoke(self, body2);
			PlayerCharacterMasterController component = ((Component)self).GetComponent<PlayerCharacterMasterController>();
			if (!Object.op_Implicit((Object)(object)Run.instance) || !((Object)Run.instance).name.Contains("Judgement"))
			{
				return;
			}
			Scene activeScene = SceneManager.GetActiveScene();
			string name = ((Scene)(ref activeScene)).name;
			JudgementRun component2 = ((Component)Run.instance).gameObject.GetComponent<JudgementRun>();
			if ((int)Run.instance.selectedDifficulty > 3 && Object.op_Implicit((Object)(object)body2.teamComponent) && (int)body2.teamComponent.teamIndex == 1 && (!body2.HasBuff(Buffs.Immune) || ((InfiniteTowerRun)component2).waveIndex == 0))
			{
				HealthComponent healthComponent = body2.healthComponent;
				if (Object.op_Implicit((Object)(object)healthComponent))
				{
					healthComponent.Networkhealth = healthComponent.fullHealth;
				}
			}
			if (!Object.op_Implicit((Object)(object)component))
			{
				return;
			}
			if (name == "moon2" && !body2.HasBuff(Buffs.Immune))
			{
				Vector3 val = new Vector3(127f, 500f, 101f);
				float num = Random.Range(0f, 360f);
				float num2 = 5f * Mathf.Sqrt(Random.Range(0f, 1f));
				Vector3 val2 = val + new Vector3(num2 * Mathf.Cos(num * (MathF.PI / 180f)), 0f, num2 * Mathf.Sin(num * (MathF.PI / 180f)));
				TeleportHelper.TeleportBody(body2, val2, false);
			}
			Vector3 velocity;
			Quaternion quaternion;
			if (NetworkServer.active && name != "moon2" && !body2.HasBuff(Buffs.Immune))
			{
				double num3 = 72.0;
				velocity = Vector3.up * 10f + Vector3.forward * 2f;
				Vector3 up = Vector3.up;
				quaternion = Quaternion.AngleAxis((float)num3, up);
				CreateDrop(PickupCatalog.FindPickupIndex((ItemTier)0), dtWhite, Run.instance.runRNG);
				CreateDrop(PickupCatalog.FindPickupIndex((ItemTier)0), dtWhite, Run.instance.runRNG);
				CreateDrop(PickupCatalog.FindPickupIndex((ItemTier)0), dtWhite, Run.instance.runRNG);
				switch (((InfiniteTowerRun)component2).waveIndex)
				{
				case 0:
					CreateDrop(PickupCatalog.FindPickupIndex((ItemTier)1), dtGreen, Run.instance.runRNG);
					CreateDrop(PickupCatalog.FindPickupIndex(EquipmentCatalog.FindEquipmentIndex("LifestealOnHit")), dtEquip, Run.instance.runRNG);
					break;
				case 4:
					CreateDrop(PickupCatalog.FindPickupIndex((ItemTier)2), dtRed, Run.instance.runRNG);
					CreateDrop(PickupCatalog.FindPickupIndex(EquipmentCatalog.FindEquipmentIndex("LifestealOnHit")), dtEquip, Run.instance.runRNG);
					break;
				case 6:
					CreateDrop(PickupCatalog.FindPickupIndex((ItemTier)1), dtGreen, Run.instance.runRNG);
					CreateDrop(PickupCatalog.FindPickupIndex((ItemTier)4), dtYellow, Run.instance.runRNG);
					break;
				case 8:
					CreateDrop(PickupCatalog.FindPickupIndex((ItemTier)2), dtRed, Run.instance.runRNG);
					CreateDrop(PickupCatalog.FindPickupIndex((ItemTier)1), dtGreen, Run.instance.runRNG);
					break;
				default:
					CreateDrop(PickupCatalog.FindPickupIndex((ItemTier)1), dtGreen, Run.instance.runRNG);
					CreateDrop(PickupCatalog.FindPickupIndex((ItemTier)1), dtGreen, Run.instance.runRNG);
					break;
				}
			}
			void CreateDrop(PickupIndex pickupIndex, BasicPickupDropTable dropTable, Xoroshiro128Plus rng)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_005c: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_0076: Unknown result type (might be due to invalid IL or missing references)
				//IL_007b: Unknown result type (might be due to invalid IL or missing references)
				CreatePickupInfo val3 = default(CreatePickupInfo);
				((CreatePickupInfo)(ref val3)).pickupIndex = pickupIndex;
				val3.position = body2.corePosition + Vector3.up * 1.5f;
				val3.pickerOptions = PickupPickerController.GenerateOptionsFromDropTable(3, (PickupDropTable)(object)dropTable, rng);
				val3.prefabOverride = potentialPickup;
				CreatePickupInfo val4 = val3;
				PickupDropletController.CreatePickupDroplet(val4, val4.position, velocity);
				velocity = quaternion * velocity;
			}
		}

		private static void SetJudgementMusic(orig_PickCurrentTrack orig, MusicController self, ref MusicTrackDef newTrack)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, ref newTrack);
			if (Object.op_Implicit((Object)(object)Run.instance) && ((Object)Run.instance).name.Contains("Judgement"))
			{
				Scene activeScene = SceneManager.GetActiveScene();
				if (((Scene)(ref activeScene)).name != "moon2")
				{
					newTrack = MusicTrackCatalog.FindMusicTrackDef("muSong23");
				}
			}
		}

		private void ManageStageSelection(orig_Begin orig, SceneExitController self)
		{
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)Run.instance) && ((Object)Run.instance).name.Contains("Judgement"))
			{
				JudgementRun component = ((Component)Run.instance).gameObject.GetComponent<JudgementRun>();
				if (NetworkServer.active)
				{
					SavePersistentHP();
				}
				if (((InfiniteTowerRun)component).waveIndex == 0)
				{
					Run.instance.nextStageScene = voidPlains;
				}
				if (((InfiniteTowerRun)component).waveIndex == 2)
				{
					int[] array = Array.Empty<int>();
					WeightedSelection<SceneDef> obj = new WeightedSelection<SceneDef>(8);
					obj.AddChoice(voidAqueduct, 1f);
					obj.AddChoice(voidAphelian, 1f);
					int num = obj.EvaluateToChoiceIndex(Run.instance.runRNG.nextNormalizedFloat, array);
					ChoiceInfo<SceneDef> choice = obj.GetChoice(num);
					Run.instance.nextStageScene = choice.value;
				}
				if (((InfiniteTowerRun)component).waveIndex == 4)
				{
					Run.instance.nextStageScene = voidRPD;
				}
				if (((InfiniteTowerRun)component).waveIndex == 6)
				{
					Run.instance.nextStageScene = voidAbyssal;
				}
				if (((InfiniteTowerRun)component).waveIndex == 8)
				{
					Run.instance.nextStageScene = voidMeadow;
				}
				if (((InfiniteTowerRun)component).waveIndex == 10)
				{
					SceneDef nextStageScene = SceneCatalog.FindSceneDef("moon2");
					Run.instance.nextStageScene = nextStageScene;
				}
				ReadOnlyCollection<CharacterMaster> readOnlyInstancesList = CharacterMaster.readOnlyInstancesList;
				for (int i = 0; i < readOnlyInstancesList.Count; i++)
				{
					CharacterMaster component2 = ((Component)readOnlyInstancesList[i]).GetComponent<CharacterMaster>();
					if (Object.op_Implicit((Object)(object)((Component)component2).GetComponent<SetDontDestroyOnLoad>()))
					{
						GameObject bodyObject = component2.GetBodyObject();
						if (Object.op_Implicit((Object)(object)bodyObject))
						{
							GameObject obj2 = Object.Instantiate<GameObject>(tpOutController, bodyObject.transform.position, Quaternion.identity);
							obj2.GetComponent<TeleportOutController>().Networktarget = bodyObject;
							NetworkServer.Spawn(obj2);
						}
					}
				}
				self.SetState((ExitState)3);
			}
			else
			{
				orig.Invoke(self);
			}
		}

		private void ManageSurvivorStats(orig_Start orig, CharacterBody self)
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Invalid comparison between Unknown and I4
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			if (!Object.op_Implicit((Object)(object)Run.instance) || !((Object)Run.instance).name.Contains("Judgement") || !self.isPlayerControlled || self.HasBuff(Buffs.Immune))
			{
				return;
			}
			JudgementRun component = ((Component)Run.instance).gameObject.GetComponent<JudgementRun>();
			if (NetworkServer.active)
			{
				LoadPersistentHP(self);
				LoadPersistentCurse(self);
			}
			if ((int)Run.instance.selectedDifficulty >= 3 && ((InfiniteTowerRun)component).waveIndex == 0)
			{
				self.healthComponent.health = self.healthComponent.fullHealth;
			}
			self.baseRegen = 0f;
			self.levelRegen = 0f;
			Scene activeScene = SceneManager.GetActiveScene();
			if (((Scene)(ref activeScene)).name == "moon2" && self.isPlayerControlled)
			{
				GameObject val = GameObject.Find("HOLDER: Final Arena");
				if (Object.op_Implicit((Object)(object)val) && !((Component)val.transform.GetChild(3)).gameObject.activeSelf)
				{
					Log.Info("Judgement: Mithrix mod found, increasing player base speed by 20%", "C:\\Users\\Nux\\Desktop\\RoR2Modding\\Dev\\Judgement\\Judgement\\Hooks\\RunHooks.cs", "ManageSurvivorStats", 395);
					self.baseMoveSpeed *= 1.2f;
				}
			}
		}

		private void EndRun(orig_OnEnter orig, BossDeath self)
		{
			orig.Invoke(self);
			if (Object.op_Implicit((Object)(object)Run.instance) && ((Object)Run.instance).name.Contains("Judgement"))
			{
				Run.instance.BeginGameOver(judgementRunEnding);
			}
		}
	}
	public class SimulacrumHooks
	{
		private SpawnCard lockBox = Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/Junk/TreasureCache/iscLockbox.asset").WaitForCompletion();

		private SpawnCard lockBoxVoid = Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/DLC1/TreasureCacheVoid/iscLockboxVoid.asset").WaitForCompletion();

		private SpawnCard freeChest = Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/DLC1/FreeChest/iscFreeChest.asset").WaitForCompletion();

		private SpawnCard greenPrinter = Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/Base/DuplicatorLarge/iscDuplicatorLarge.asset").WaitForCompletion();

		private SpawnCard voidChest = Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/DLC1/VoidChest/iscVoidChest.asset").WaitForCompletion();

		public SimulacrumHooks()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Expected O, but got Unknown
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Expected O, but got Unknown
			InfiniteTowerRun.SpawnSafeWard += new hook_SpawnSafeWard(SetupInteractables);
			InfiniteTowerRun.MoveSafeWard += new hook_MoveSafeWard(PreventCrabMovement);
			InfiniteTowerRun.RecalculateDifficultyCoefficentInternal += new hook_RecalculateDifficultyCoefficentInternal(IncreaseScaling);
			InfiniteTowerWaveController.DropRewards += new hook_DropRewards(PreventCrabDrops);
			InfiniteTowerWaveController.OnEnable += new hook_OnEnable(ManageWaveCredits);
			InfiniteTowerBossWaveController.PreStartClient += new hook_PreStartClient(GuaranteeBoss);
		}

		private void ManageWaveCredits(orig_OnEnable orig, InfiniteTowerWaveController self)
		{
			if (Object.op_Implicit((Object)(object)Run.instance) && ((Object)Run.instance).name.Contains("Judgement"))
			{
				if (self is InfiniteTowerBossWaveController)
				{
					self.baseCredits = 400f;
				}
				else
				{
					self.baseCredits = 140f;
				}
			}
			orig.Invoke(self);
		}

		private void PreventCrabMovement(orig_MoveSafeWard orig, InfiniteTowerRun self)
		{
			if (!Object.op_Implicit((Object)(object)Run.instance) || !((Object)Run.instance).name.Contains("Judgement"))
			{
				orig.Invoke(self);
			}
		}

		private void PreventCrabDrops(orig_DropRewards orig, InfiniteTowerWaveController self)
		{
			if (!Object.op_Implicit((Object)(object)Run.instance) || !((Object)Run.instance).name.Contains("Judgement"))
			{
				orig.Invoke(self);
			}
		}

		private void GuaranteeBoss(orig_PreStartClient orig, InfiniteTowerBossWaveController self)
		{
			if (Object.op_Implicit((Object)(object)Run.instance) && ((Object)Run.instance).name.Contains("Judgement"))
			{
				self.guaranteeInitialChampion = true;
			}
			orig.Invoke(self);
		}

		private void IncreaseScaling(orig_RecalculateDifficultyCoefficentInternal orig, InfiniteTowerRun self)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)Run.instance) && ((Object)Run.instance).name.Contains("Judgement"))
			{
				DifficultyDef difficultyDef = DifficultyCatalog.GetDifficultyDef(((Run)self).selectedDifficulty);
				float num = 1.5f * ((float)self.waveIndex * 0.9f);
				float num2 = 0.0506f * (difficultyDef.scalingValue * 2f);
				float num3 = Mathf.Pow(1.02f, (float)self.waveIndex);
				((Run)self).difficultyCoefficient = (float)(1.0 + (double)num2 * (double)num) * num3;
				((Run)self).compensatedDifficultyCoefficient = ((Run)self).difficultyCoefficient;
				((Run)self).ambientLevel = Mathf.Min((float)(((double)((Run)self).difficultyCoefficient - 1.0) / 0.33000001311302185 + 1.0), 9999f);
				int ambientLevelFloor = ((Run)self).ambientLevelFloor;
				((Run)self).ambientLevelFloor = Mathf.FloorToInt(((Run)self).ambientLevel);
				if (ambientLevelFloor != ((Run)self).ambientLevelFloor && ambientLevelFloor != 0 && ((Run)self).ambientLevelFloor > ambientLevelFloor)
				{
					((Run)self).OnAmbientLevelUp();
				}
			}
			else
			{
				orig.Invoke(self);
			}
		}

		private void SetupInteractables(orig_SpawnSafeWard orig, InfiniteTowerRun self, InteractableSpawnCard spawnCard, DirectorPlacementRule placementRule)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: 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_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)Run.instance) && ((Object)Run.instance).name.Contains("Judgement"))
			{
				JudgementRun component = ((Component)Run.instance).gameObject.GetComponent<JudgementRun>();
				Scene activeScene = SceneManager.GetActiveScene();
				if (((Scene)(ref activeScene)).name == "moon2")
				{
					GameObject val = GameObject.Find("Director");
					if (Object.op_Implicit((Object)(object)val) && NetworkServer.active)
					{
						Object.Destroy((Object)(object)((Component)self.fogDamageController).gameObject);
						CombatDirector[] components = val.GetComponents<CombatDirector>();
						for (int i = 0; i < components.Length; i++)
						{
							Object.Destroy((Object)(object)components[i]);
						}
					}
					return;
				}
				GameObject val2 = DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest((SpawnCard)(object)spawnCard, placementRule, self.safeWardRng));
				if (!Object.op_Implicit((Object)(object)val2))
				{
					return;
				}
				NetworkServer.Spawn(val2);
				self.safeWardController = val2.GetComponent<InfiniteTowerSafeWardController>();
				if (Object.op_Implicit((Object)(object)self.safeWardController))
				{
					self.safeWardController.onActivated += self.OnSafeWardActivated;
				}
				HoldoutZoneController component2 = val2.GetComponent<HoldoutZoneController>();
				if (Object.op_Implicit((Object)(object)component2))
				{
					component2.calcAccumulatedCharge += new CalcAccumulatedChargeDelegate(self.CalcHoldoutZoneCharge);
				}
				if (!Object.op_Implicit((Object)(object)self.fogDamageController))
				{
					return;
				}
				self.fogDamageController.AddSafeZone(self.safeWardController.safeZone);
				if (!NetworkServer.active)
				{
					return;
				}
				Vector3 position = ((Component)self.safeWardController).transform.position;
				if (((InfiniteTowerRun)component).waveIndex == 4 || ((InfiniteTowerRun)component).waveIndex == 8)
				{
					for (int j = 0; j < Run.instance.participatingPlayerCount; j++)
					{
						SpawnInteractable(voidChest, position, isFree: false);
					}
				}
				foreach (CharacterMaster readOnlyInstances in CharacterMaster.readOnlyInstancesList)
				{
					if (readOnlyInstances.inventory.GetItemCount(Items.RegeneratingScrap) > 0)
					{
						SpawnInteractable(greenPrinter, position, isFree: false);
						break;
					}
				}
				for (int k = 0; k < CharacterMaster.readOnlyInstancesList.Count; k++)
				{
					if (CharacterMaster.readOnlyInstancesList[k].inventory.GetItemCount(Items.TreasureCache) > 0)
					{
						SpawnInteractable(lockBox, position, isFree: false);
					}
				}
				for (int l = 0; l < CharacterMaster.readOnlyInstancesList.Count; l++)
				{
					if (CharacterMaster.readOnlyInstancesList[l].inventory.GetItemCount(Items.TreasureCacheVoid) > 0)
					{
						SpawnInteractable(lockBoxVoid, position, isFree: false);
					}
				}
				for (int m = 0; m < CharacterMaster.readOnlyInstancesList.Count; m++)
				{
					if (CharacterMaster.readOnlyInstancesList[m].inventory.GetItemCount(Items.FreeChest) > 0)
					{
						SpawnInteractable(freeChest, position, isFree: false);
					}
				}
			}
			else
			{
				orig.Invoke(self, spawnCard, placementRule);
			}
		}

		private void SpawnInteractable(SpawnCard spawnCard, Vector3 position, bool isFree = true)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: 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_0041: Expected O, but got Unknown
			DirectorCore instance = DirectorCore.instance;
			DirectorPlacementRule val = new DirectorPlacementRule();
			val.placementMode = (PlacementMode)1;
			val.position = position;
			val.minDistance = 2f;
			val.maxDistance = 20f;
			DirectorSpawnRequest val2 = new DirectorSpawnRequest(spawnCard, val, Run.instance.runRNG);
			GameObject val3 = instance.TrySpawnObject(val2);
			if (!Object.op_Implicit((Object)(object)val3))
			{
				Log.Error("Judgement: Failed to spawn pre-wave interactable " + ((Object)spawnCard).name + ".", "C:\\Users\\Nux\\Desktop\\RoR2Modding\\Dev\\Judgement\\Judgement\\Hooks\\SimulacrumHooks.cs", "SpawnInteractable", 183);
			}
			if (isFree)
			{
				SetPurchaseCostFree(val3);
			}
		}

		private void SetPurchaseCostFree(GameObject chest)
		{
			PurchaseInteraction component = chest.GetComponent<PurchaseInteraction>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.cost = 0;
				component.Networkcost = 0;
			}
			else
			{
				Log.Error("Judgement: Failed to set " + ((Object)chest).name + " cost to free.", "C:\\Users\\Nux\\Desktop\\RoR2Modding\\Dev\\Judgement\\Judgement\\Hooks\\SimulacrumHooks.cs", "SetPurchaseCostFree", 199);
			}
		}
	}
	public class JudgementRun : InfiniteTowerRun
	{
		public Vector3 safeWardPos = Vector3.zero;

		[SyncVar]
		public Dictionary<NetworkInstanceId, float> persistentHP = new Dictionary<NetworkInstanceId, float>();

		[SyncVar]
		public Dictionary<NetworkInstanceId, int> persistentCurse = new Dictionary<NetworkInstanceId, int>();
	}
	internal static class Log
	{
		internal static ManualLogSource _logSource;

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

		private static string getLogPrefix(string callerPath, string callerMemberName, int callerLineNumber)
		{
			int num = callerPath.LastIndexOf("Judgement");
			if (num >= 0)
			{
				callerPath = callerPath.Substring(num + "Judgement".Length + 1);
			}
			return $"{callerPath}:{callerLineNumber} ({callerMemberName}) ";
		}

		internal static void Error(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogError((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

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

		internal static void Fatal(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogFatal((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

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

		internal static void Info(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogInfo((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

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

		internal static void Message(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogMessage((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

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

		internal static void Warning(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogWarning((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Warning_NoCallerPrefix(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInPlugin("Nuxlar.Judgement", "Judgement", "1.5.3")]
	public class Main : BaseUnityPlugin
	{
		public const string PluginGUID = "Nuxlar.Judgement";

		public const string PluginAuthor = "Nuxlar";

		public const string PluginName = "Judgement";

		public const string PluginVersion = "1.5.3";

		internal static Main Instance { get; private set; }

		public static string PluginDirectory { get; private set; }

		public void Awake()
		{
			Instance = this;
			Stopwatch stopwatch = Stopwatch.StartNew();
			Log.Init(((BaseUnityPlugin)this).Logger);
			new CreateGameMode();
			new RunHooks();
			new SimulacrumHooks();
			new EntityStateHooks();
			stopwatch.Stop();
			Log.Info_NoCallerPrefix($"Judgement: Initialized in {stopwatch.Elapsed.TotalSeconds:F2} seconds");
		}
	}
	internal static class OptionPickupFix
	{
		[SystemInitializer(new Type[] { })]
		private static void Init()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			PickupDisplay.RebuildModel += new Manipulator(PickupDisplay_RebuildModel);
		}

		private static void PickupDisplay_RebuildModel(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			if (!val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo<PickupDisplay>((Expression<Action<PickupDisplay>>)((PickupDisplay _) => _.DestroyModel())))
			}))
			{
				Log.Error("Failed to find patch location", "C:\\Users\\Nux\\Desktop\\RoR2Modding\\Dev\\Judgement\\Judgement\\Patches\\OptionPickupFix.cs", "PickupDisplay_RebuildModel", 27);
				return;
			}
			val.Emit(OpCodes.Ldarg_0);
			val.Emit(OpCodes.Ldfld, AccessTools.DeclaredField(typeof(PickupDisplay), "dontInstantiatePickupModel"));
			val.EmitSkipMethodCall(OpCodes.Brtrue);
		}

		public static void EmitSkipMethodCall(this ILCursor c, OpCode branchOpCode, MethodDefinition method = null)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			c.EmitSkipMethodCall(branchOpCode, null, method);
		}

		public static void EmitSkipMethodCall(this ILCursor c, OpCode branchOpCode, Action<ILCursor> emitSkippedReturnValue, MethodDefinition method = null)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Invalid comparison between Unknown and I4
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: 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_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			if (c == null)
			{
				throw new ArgumentNullException("c");
			}
			if ((int)((OpCode)(ref branchOpCode)).FlowControl != 0 && (int)((OpCode)(ref branchOpCode)).FlowControl != 3)
			{
				throw new ArgumentException($"Invalid branch OpCode: {branchOpCode}");
			}
			if (method == null)
			{
				MethodReference val = default(MethodReference);
				if (!ILPatternMatchingExt.MatchCallOrCallvirt(c.Next, ref val))
				{
					Log.Error($"Failed to find method call to skip: {((MemberReference)c.Context.Method).FullName} at instruction {c.Next} ({c.Index})", "C:\\Users\\Nux\\Desktop\\RoR2Modding\\Dev\\Judgement\\Judgement\\Patches\\OptionPickupFix.cs", "EmitSkipMethodCall", 53);
					return;
				}
				method = Extensions.SafeResolve(val);
				if (method == null)
				{
					Log.Error($"Failed to resolve method '{((MemberReference)val).FullName}': {((MemberReference)c.Context.Method).FullName} at instruction {c.Next} ({c.Index})", "C:\\Users\\Nux\\Desktop\\RoR2Modding\\Dev\\Judgement\\Judgement\\Patches\\OptionPickupFix.cs", "EmitSkipMethodCall", 61);
					return;
				}
			}
			int num = ((MethodReference)method).Parameters.Count + ((!method.IsStatic) ? 1 : 0);
			bool flag = Extensions.Is((MemberReference)(object)((MethodReference)method).ReturnType, (MemberInfo)typeof(void));
			ILLabel val2 = c.DefineLabel();
			c.Emit(branchOpCode, (object)val2);
			int index = c.Index;
			c.Index = index + 1;
			if (num > 0 || !flag)
			{
				ILLabel val3 = c.DefineLabel();
				c.Emit(OpCodes.Br, (object)val3);
				c.MarkLabel(val2);
				for (int i = 0; i < num; i++)
				{
					c.Emit(OpCodes.Pop);
				}
				if (emitSkippedReturnValue != null)
				{
					emitSkippedReturnValue(c);
				}
				else if (!flag)
				{
					Log.Warning($"Skipped method ({((MemberReference)method).FullName}) is not void, emitting default value: {((MemberReference)c.Context.Method).FullName} at instruction {c.Next} ({c.Index})", "C:\\Users\\Nux\\Desktop\\RoR2Modding\\Dev\\Judgement\\Judgement\\Patches\\OptionPickupFix.cs", "EmitSkipMethodCall", 93);
					if (((MethodReference)method).ReturnType.IsValueType)
					{
						VariableDefinition val4 = c.Context.AddVariable(((MethodReference)method).ReturnType);
						c.Emit(OpCodes.Ldloca, val4);
						c.Emit(OpCodes.Initobj, ((MethodReference)method).ReturnType);
						c.Emit(OpCodes.Ldloc, val4);
					}
					else
					{
						c.Emit(OpCodes.Ldnull);
					}
				}
				c.MarkLabel(val3);
			}
			else
			{
				c.MarkLabel(val2);
			}
		}

		public static VariableDefinition AddVariable(this ILContext context, TypeReference variableType)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			VariableDefinition val = new VariableDefinition(variableType);
			context.Method.Body.Variables.Add(val);
			return val;
		}
	}
}