Decompiled source of Public Gauntlet v2.6.7

RoRGauntlet.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Net;
using System.Net.Http;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates.LunarTeleporter;
using HG;
using HG.Reflection;
using HarmonyLib;
using IL.RoR2;
using KinematicCharacterController;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using On.EntityStates.LunarTeleporter;
using On.RoR2;
using On.RoR2.Artifacts;
using On.RoR2.Items;
using On.RoR2.UI;
using On.RoR2.UI.MainMenu;
using ProperSave;
using ProperSave.Data;
using R2API;
using RoR2;
using RoR2.Artifacts;
using RoR2.Audio;
using RoR2.Items;
using RoR2.Stats;
using RoR2.UI;
using RoR2.UI.MainMenu;
using RoR2.UI.SkinControllers;
using RoRGauntlet;
using RoRGauntlet.Web;
using RoRes;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("RoRGauntlet")]
[assembly: AssemblyConfiguration("Public")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+20368a92c409912d194188baec5ad9fc250ac525")]
[assembly: AssemblyProduct("RoRGauntlet")]
[assembly: AssemblyTitle("RoRGauntlet")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.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;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public static class GameObjectExtensions
{
	public static T GetCopyOf<T>(this Component comp, T other) where T : Component
	{
		Type type = ((object)comp).GetType();
		if (type != ((object)other).GetType())
		{
			return default(T);
		}
		BindingFlags bindingAttr = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
		PropertyInfo[] properties = type.GetProperties(bindingAttr);
		foreach (PropertyInfo propertyInfo in properties)
		{
			if (propertyInfo.CanWrite)
			{
				try
				{
					propertyInfo.SetValue(comp, propertyInfo.GetValue(other, null), null);
				}
				catch
				{
				}
			}
		}
		FieldInfo[] fields = type.GetFields(bindingAttr);
		foreach (FieldInfo fieldInfo in fields)
		{
			fieldInfo.SetValue(comp, fieldInfo.GetValue(other));
		}
		return (T)(object)((comp is T) ? comp : null);
	}

	public static GameObject FindObject(this GameObject parent, string name)
	{
		Transform[] componentsInChildren = parent.GetComponentsInChildren<Transform>(true);
		foreach (Transform val in componentsInChildren)
		{
			if (((Object)val).name == name)
			{
				return ((Component)val).gameObject;
			}
		}
		return null;
	}
}
namespace RoRGauntlet
{
	internal static class Assets
	{
		public static GameObject lazarusResurrectionEffect;

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

		public static void Initialize(string infoLocation)
		{
			try
			{
				PopulateAssets(infoLocation);
			}
			catch (Exception arg)
			{
				Debug.LogWarning((object)$"Failed to populate assets: {arg}");
			}
		}

		private static void PopulateAssets(string infoLocation)
		{
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(infoLocation) ?? string.Empty, "riskofresourcesassets"));
			lazarusResurrectionEffect = val.LoadAsset<GameObject>("LazarusWingsRez");
			if (!ContentAddition.AddEffect(lazarusResurrectionEffect))
			{
				Log.LogError("lazarusResurrectionEffect is not valid.");
				return;
			}
			Material[] array = (from mat in val.LoadAllAssets<Material>()
				where ((Object)mat.shader).name.StartsWith("Stubbed")
				select mat).ToArray();
			foreach (Material val2 in array)
			{
				if (!((Object)val2.shader).name.StartsWith("Stubbed"))
				{
					Log.LogWarning($"The material {val2} is invalid.");
					continue;
				}
				try
				{
					SwapShader(val2);
				}
				catch (Exception arg)
				{
					Log.LogError($"Failed to swap shader of material {val2}: {arg}");
				}
			}
		}

		private static void SwapShader(Material material)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			Shader shader = Addressables.LoadAssetAsync<Shader>((object)(((Object)material.shader).name.Substring("Stubbed".Length) + ".shader")).WaitForCompletion();
			material.shader = shader;
			if (((Object)material.shader).name.Contains("Cloud Remap"))
			{
				Material val = Addressables.LoadAssetAsync<Material>((object)"RoR2/Base/Common/VFX/matLightningLongBlue.mat").WaitForCompletion();
				RuntimeCloudMaterialMapper runtimeCloudMaterialMapper = new RuntimeCloudMaterialMapper(material);
				material.CopyPropertiesFromMaterial(val);
				runtimeCloudMaterialMapper.SetMaterialValues(ref material);
			}
			swappedMaterials.Add(material);
		}
	}
	public class ConcedeService
	{
		private void ShowConcedeNotAllowed(PauseScreenController pauseScreen)
		{
			//IL_0011: 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)
			SimpleDialogBox obj = SimpleDialogBox.Create((MPEventSystem)null);
			obj.headerToken = new TokenParamsPair("No times submitted", Array.Empty<object>());
			string text = "You cannot concede as nobody has submitted a time yet";
			if (pauseScreen == null)
			{
				text += " Use info screen button (usually tab/select) to move cursor.";
			}
			obj.descriptionToken = new TokenParamsPair(text, Array.Empty<object>());
			obj.AddCancelButton("Cancel", Array.Empty<object>());
		}

		private static void ShowConcedeConfirmationDialog(PauseScreenController pauseScreen)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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_0070: Expected O, but got Unknown
			SimpleDialogBox obj = SimpleDialogBox.Create((MPEventSystem)null);
			obj.headerToken = new TokenParamsPair("Are you sure?", Array.Empty<object>());
			string text = "Are you sure you want to concede this run?";
			if (pauseScreen == null)
			{
				text += " Use info screen button (usually tab/select) to move cursor.";
			}
			obj.descriptionToken = new TokenParamsPair(text, Array.Empty<object>());
			obj.AddActionButton((UnityAction)delegate
			{
				ActuallyConcedeGame(pauseScreen);
			}, "Yes", true, Array.Empty<object>());
			obj.AddCancelButton("Cancel", Array.Empty<object>());
		}

		private static void ActuallyConcedeGame(PauseScreenController pauseScreen)
		{
			//IL_0044: 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)
			if (pauseScreen != null)
			{
				Object.Destroy((Object)(object)((Component)pauseScreen).gameObject);
			}
			if (Run.instance != null)
			{
				Main.ConcedeCheck = true;
				GameEndingDef val = ScriptableObject.CreateInstance<GameEndingDef>();
				val.isWin = false;
				val.showCredits = false;
				val.lunarCoinReward = 0u;
				RunReport.Generate(Run.instance, val);
				Run.CCRunEnd(default(ConCommandArgs));
				Main.ConcedeCheck = false;
			}
		}

		public void ConcedeGame(PauseScreenController pauseScreen)
		{
			string lobbyCode = LoadoutHandler.Instance.Race.LobbyCode;
			int currentLoadout = Main.CurrentLoadout.Value;
			((MonoBehaviour)Main.instance).StartCoroutine(RaceV2Api.GetInstance.GetRaceData(lobbyCode, delegate(Race race)
			{
				if (!race.Sanctioned)
				{
					ShowConcedeConfirmationDialog(pauseScreen);
				}
				else
				{
					List<RunSubmission> list = (from s in race.RunSubmissions ?? new List<RunSubmission>()
						where s != null
						where s.LoadoutId == currentLoadout
						select s).ToList();
					if (SimpleDialogBox.instancesList.Count <= 0)
					{
						if (list.Count > 0)
						{
							Log.LogInfo("Found submission(s) from other player(s); concede is allowed");
							ShowConcedeConfirmationDialog(pauseScreen);
						}
						else
						{
							Log.LogInfo("Can't concede when no other players have submitted their run");
							ShowConcedeNotAllowed(pauseScreen);
						}
					}
				}
			}));
		}
	}
	public class ConcedeUI : MonoBehaviour
	{
		private readonly ConcedeService _concedeService = new ConcedeService();

		public void OnEnable()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			PauseScreenController.Awake += new hook_Awake(PauseScreenControllerOnAwake);
		}

		public void OnDisable()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			PauseScreenController.Awake -= new hook_Awake(PauseScreenControllerOnAwake);
		}

		private void PauseScreenControllerOnAwake(orig_Awake orig, PauseScreenController self)
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Expected O, but got Unknown
			orig.Invoke(self);
			ButtonSkinController componentInChildren = ((Component)self).GetComponentInChildren<ButtonSkinController>();
			if (!Object.op_Implicit((Object)(object)componentInChildren))
			{
				Debug.LogWarning((object)"Failed to get button skin controller");
				return;
			}
			GameObject gameObject = ((Component)componentInChildren).gameObject;
			GameObject obj = Object.Instantiate<GameObject>(gameObject, gameObject.transform.parent);
			((Object)obj).name = "Concede Button";
			LanguageTextMeshController val = default(LanguageTextMeshController);
			if (obj.TryGetComponent<LanguageTextMeshController>(ref val))
			{
				val.token = "Concede Run";
			}
			HGButton val2 = default(HGButton);
			if (!obj.TryGetComponent<HGButton>(ref val2))
			{
				Debug.LogWarning((object)"Failed to setup concede button");
				Object.Destroy((Object)(object)gameObject);
				return;
			}
			((Button)val2).onClick = new ButtonClickedEvent();
			((UnityEvent)((Button)val2).onClick).AddListener((UnityAction)delegate
			{
				_concedeService.ConcedeGame(self);
			});
		}
	}
	public class ConfigurablePillars : MonoBehaviour
	{
		public void OnEnable()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			MoonBatteryMissionController.Awake += new hook_Awake(OnMoonBatteryMissionControllerOnAwake);
		}

		public void OnDisable()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			MoonBatteryMissionController.Awake -= new hook_Awake(OnMoonBatteryMissionControllerOnAwake);
		}

		private void OnMoonBatteryMissionControllerOnAwake(orig_Awake orig, MoonBatteryMissionController self)
		{
			orig.Invoke(self);
			self._numRequiredBatteries = Main.PillarNum.Value;
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class DebugCommands
	{
		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void NextLoadout(ConCommandArgs args)
		{
			if (Main.CurrentLoadout.Value < LoadoutHandler.Instance.GetLoadouts().Count - 1)
			{
				ConfigEntry<int> currentLoadout = Main.CurrentLoadout;
				int value = currentLoadout.Value;
				currentLoadout.Value = value + 1;
			}
			Log.LogInfo("Progressed to loadout " + Main.CurrentLoadout.Value);
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void SetLoadout(ConCommandArgs args)
		{
			Main.CurrentLoadout.Value = ((ConCommandArgs)(ref args)).GetArgInt(0);
			Debug.Log((object)$"Loadout number has been set to : {Main.CurrentLoadout.Value}");
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void SetDifficulty(ConCommandArgs args)
		{
			string argString = ((ConCommandArgs)(ref args)).GetArgString(0);
			string[] obj = new string[12]
			{
				"Eclipse8", "Eclipse7", "Eclipse6", "Eclipse5", "Eclipse4", "Eclipse3", "Eclipse2", "Eclipse1", "Hard", "Normal",
				"Easy", "Any"
			};
			bool flag = false;
			string[] array = obj;
			foreach (string text in array)
			{
				if (argString == text)
				{
					flag = true;
				}
			}
			if (!flag)
			{
				Log.LogDebug("Could not find the difficulty \"" + argString + "\"");
				return;
			}
			Main.DifficultySelect.Value = argString;
			Log.LogInfo("Set difficulty config to to " + argString);
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void ListRecycler(ConCommandArgs args)
		{
			Debug.Log((object)SeededRecycler.megaList);
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void ListNameTokens(ConCommandArgs args)
		{
			Debug.Log((object)"Available Survivor Tokens");
			foreach (SurvivorDef allSurvivorDef in SurvivorCatalog.allSurvivorDefs)
			{
				Debug.Log((object)allSurvivorDef.displayNameToken);
			}
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void SubmitRun(ConCommandArgs args)
		{
			SubmitRun componentInChildren = ((Component)Main.instance).GetComponentInChildren<SubmitRun>(true);
			if (componentInChildren.RunSubmission != null)
			{
				RaceV2Api.GetInstance.SubmitRun(componentInChildren.RunSubmission);
			}
			else
			{
				Debug.LogWarning((object)"No run submission found");
			}
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class SetupCommands
	{
		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void SignIn(ConCommandArgs args)
		{
			LogEnv();
			RaceV2Api getInstance = RaceV2Api.GetInstance;
			string text = ((ConCommandArgs)(ref args)).TryGetArgString(0);
			if (string.IsNullOrEmpty(text))
			{
				getInstance.SignInWeb();
			}
			else
			{
				getInstance.SignIn(text);
			}
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void SetEnvironment(ConCommandArgs args)
		{
			LogEnv();
			string text = ((ConCommandArgs)(ref args)).GetArgString(0).ToLower();
			Main.EnvironmentName.Value = text;
			if (!text.Equals("prd") && !text.Equals("dev") && !text.Equals("dbg"))
			{
				Debug.LogError((object)"Invalid environment. Use 'prd' or 'dev'");
			}
			else
			{
				Debug.Log((object)("Environment set to : " + text));
			}
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void SetTeam(ConCommandArgs args)
		{
			LogEnv();
			int argInt = ((ConCommandArgs)(ref args)).GetArgInt(0);
			Log.LogInfo($"Team number has been set to : {argInt}");
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static async void JoinRace(ConCommandArgs args)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			LogEnv();
			RaceV2Api instance = RaceV2Api.GetInstance;
			string lobbyCode = ((ConCommandArgs)(ref args)).TryGetArgString(0);
			int? team = ((ConCommandArgs)(ref args)).TryGetArgInt(1);
			string password = ((ConCommandArgs)(ref args)).TryGetArgString(2);
			bool flag = string.IsNullOrEmpty(Main.UserId.Value) || string.IsNullOrEmpty(Main.instance.authorization);
			if (string.IsNullOrEmpty(lobbyCode))
			{
				if (flag)
				{
					Debug.Log((object)"Can't join active lobby without a user ID; please `sign_in` first");
					return;
				}
				Debug.Log((object)"Joining current race");
				instance.JoinCurrentRace(delegate(Race race)
				{
					LoadoutHandler.Instance.RegisterRace(race);
					Console.instance.SubmitCmd((NetworkUser)null, "transition_command \"gamemode ClassicRun; host 0; \"", false);
				});
				return;
			}
			if (flag)
			{
				Debug.Log((object)"No user session: signing in first");
				await instance.SignInWeb();
			}
			((MonoBehaviour)Main.instance).StartCoroutine(instance.JoinLobby(lobbyCode, password, delegate(Race race)
			{
				LoadoutHandler.Instance.RegisterRace(race);
				Console.instance.SubmitCmd((NetworkUser)null, "transition_command \"gamemode ClassicRun; host 0; \"", false);
			}, team.GetValueOrDefault(0)));
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void AuditRace(ConCommandArgs args)
		{
			RaceV2Api getInstance = RaceV2Api.GetInstance;
			ulong argULong = ((ConCommandArgs)(ref args)).GetArgULong(0);
			getInstance.AuditLobby((long)argULong);
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void SignOut(ConCommandArgs args)
		{
			Main.UserId.Value = "";
		}

		private static void LogEnv()
		{
			string value = Main.EnvironmentName.Value;
			Debug.Log((object)("Current environment : " + value));
		}
	}
	public class ContainInArenaHandler : MonoBehaviour
	{
		public class ContainInArena : MonoBehaviour
		{
			private const float MinHeight = 490f;

			private Vector3 _startPosition;

			private CharacterMotor _characterMotor;

			public void Awake()
			{
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				_characterMotor = ((Component)this).gameObject.GetComponent<CharacterMotor>();
				if (!Object.op_Implicit((Object)(object)_characterMotor))
				{
					Log.LogWarning("No character motor so character won't TP back to arena");
					((Behaviour)this).enabled = false;
					return;
				}
				Scene activeScene = SceneManager.GetActiveScene();
				string name = ((Scene)(ref activeScene)).name;
				_startPosition = ((Component)this).gameObject.transform.position;
				((Behaviour)this).enabled = _startPosition.y > 450f && name == "moon2";
			}

			public void TeleportBack()
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: 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)
				Vector3 position = ((Component)this).gameObject.transform.position;
				((BaseCharacterController)_characterMotor).Motor.SetPosition(new Vector3(position.x, _startPosition.y + 7f, position.z), true);
			}

			public void FixedUpdate()
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				if (((Component)this).gameObject.transform.position.y < 490f)
				{
					Log.LogDebug($"Teleporting character back because {((Component)this).gameObject.transform.position.y} < {490f}");
					TeleportBack();
				}
			}
		}

		private ContainInArena _containInArena;

		private AsyncOperationHandle<GameObject> _handle;

		public void Awake()
		{
			//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)
			_handle = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Brother/BrotherBody.prefab");
			_handle.Completed += OnLoadBrotherBody;
		}

		private void OnDestroy()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			Object.Destroy((Object)(object)_containInArena);
			Addressables.Release<GameObject>(_handle);
		}

		private void OnLoadBrotherBody(AsyncOperationHandle<GameObject> obj)
		{
			CharacterBody val = default(CharacterBody);
			if (!obj.Result.TryGetComponent<CharacterBody>(ref val))
			{
				Log.LogWarning("No Character body");
			}
			else
			{
				_containInArena = ((Component)val).gameObject.AddComponent<ContainInArena>();
			}
		}
	}
	internal class DLC2 : MonoBehaviour
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_RebuildCards <0>__ClassicStageInfo_RebuildCards;
		}

		private static Xoroshiro128Plus stage;

		private static Xoroshiro128Plus item;

		private event Action _onDisable;

		public void OnEnable()
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//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_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Expected O, but got Unknown
			AddSceneToGroup("RoR2/Base/SceneGroups/sgStage2.asset", "RoR2/DLC2/lemuriantemple/lemuriantemple.asset");
			AddSceneToGroup("RoR2/Base/SceneGroups/sgStage3.asset", "RoR2/DLC2/habitat/habitat.asset");
			AddSceneToGroup("RoR2/Base/SceneGroups/loopSgStage3.asset", "RoR2/DLC2/habitatfall/habitatfall.asset");
			ChangeDestination("RoR2/DLC2/PortalColossus.prefab");
			ReplacePortals("RoR2/DLC2/ShrineHalcyonite.prefab", "RoR2/DLC2/iscColossusPortal.asset");
			Run.onRunStartGlobal += MarkFalseSonComplete;
			PurchaseInteraction.OnInteractionBegin += new Manipulator(ReplaceItemGenerator);
			PurchaseInteraction.OnInteractionBegin += new Manipulator(SeedSaleStarRoll);
			Run.GenerateStageRNG += new hook_GenerateStageRNG(OnGenerateStageRng);
			ChestBehavior.BaseItemDrop += new hook_BaseItemDrop(FixEdgeCase);
			HalcyoniteShrineInteractable.DrainConditionMet += new Manipulator(SkipHalcyonRoll);
			PickupPickerController.GenerateOptionsFromDropTablePlusForcedStorm += new Manipulator(GenerateAll);
			HalcyoniteShrineInteractable.Start += new hook_Start(OnHalcyoniteShrineInteractableOnStart);
			object obj = <>O.<0>__ClassicStageInfo_RebuildCards;
			if (obj == null)
			{
				hook_RebuildCards val = ClassicStageInfo_RebuildCards;
				<>O.<0>__ClassicStageInfo_RebuildCards = val;
				obj = (object)val;
			}
			ClassicStageInfo.RebuildCards += (hook_RebuildCards)obj;
		}

		public void OnDisable()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Expected O, but got Unknown
			//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_00d1: Expected O, but got Unknown
			try
			{
				this._onDisable?.Invoke();
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"Failed to revert gauntlet changes for DLC2, things may be broken until restart: {arg}");
			}
			finally
			{
				this._onDisable = null;
			}
			Run.onRunStartGlobal -= MarkFalseSonComplete;
			PurchaseInteraction.OnInteractionBegin -= new Manipulator(ReplaceItemGenerator);
			PurchaseInteraction.OnInteractionBegin -= new Manipulator(SeedSaleStarRoll);
			Run.GenerateStageRNG -= new hook_GenerateStageRNG(OnGenerateStageRng);
			ChestBehavior.BaseItemDrop -= new hook_BaseItemDrop(FixEdgeCase);
			HalcyoniteShrineInteractable.DrainConditionMet -= new Manipulator(SkipHalcyonRoll);
			PickupPickerController.GenerateOptionsFromDropTablePlusForcedStorm -= new Manipulator(GenerateAll);
			HalcyoniteShrineInteractable.Start -= new hook_Start(OnHalcyoniteShrineInteractableOnStart);
			object obj = <>O.<0>__ClassicStageInfo_RebuildCards;
			if (obj == null)
			{
				hook_RebuildCards val = ClassicStageInfo_RebuildCards;
				<>O.<0>__ClassicStageInfo_RebuildCards = val;
				obj = (object)val;
			}
			ClassicStageInfo.RebuildCards -= (hook_RebuildCards)obj;
		}

		private void OnHalcyoniteShrineInteractableOnStart(orig_Start orig, HalcyoniteShrineInteractable self)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			orig.Invoke(self);
			if (NetworkServer.active)
			{
				self.rng = new Xoroshiro128Plus(stage.nextUlong);
			}
		}

		private void OnGenerateStageRng(orig_GenerateStageRNG orig, Run self)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			orig.Invoke(self);
			stage = new Xoroshiro128Plus(self.spawnRng.nextUlong);
			item = new Xoroshiro128Plus(stage.nextUlong);
		}

		private void MarkFalseSonComplete(Run instance)
		{
			instance.SetEventFlag("FalseSonBossComplete");
		}

		private static void ClassicStageInfo_RebuildCards(orig_RebuildCards orig, ClassicStageInfo self, DirectorCardCategorySelection forcedMonsterCategory, DirectorCardCategorySelection forcedInteractableCategory)
		{
			orig.Invoke(self, forcedMonsterCategory, forcedInteractableCategory);
		}

		private void ReplaceItemGenerator(ILContext context)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_0063: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(context);
			VariableDefinition val2 = new VariableDefinition(context.Import(typeof(int)));
			val.GotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction i) => ILPatternMatchingExt.MatchStfld<ChestBehavior>(i, "dropCount")
			});
			context.Method.Body.Variables.Add(val2);
			val.Emit(OpCodes.Stloc, val2);
			val.Emit(OpCodes.Dup);
			val.EmitDelegate<Action<ChestBehavior>>((Action<ChestBehavior>)delegate(ChestBehavior chest)
			{
				chest.rng = item;
			});
			val.Emit(OpCodes.Ldloc, val2);
		}

		private void SeedSaleStarRoll(ILContext context)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(context);
			VariableDefinition val2 = new VariableDefinition(context.Import(typeof(Xoroshiro128Plus)));
			val.GotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction i) => ILPatternMatchingExt.MatchLdfld<PurchaseInteraction>(i, "saleStarCompatible")
			});
			val.Emit(OpCodes.Dup);
			val.EmitDelegate<Func<bool, Xoroshiro128Plus>>((Func<bool, Xoroshiro128Plus>)((bool compatible) => compatible ? new Xoroshiro128Plus(stage.nextUlong) : new Xoroshiro128Plus(0uL)));
			context.Method.Body.Variables.Add(val2);
			val.Emit(OpCodes.Stloc, val2);
			MethodInfo method = SymbolExtensions.GetMethodInfo((Expression<Action>)(() => Util.CheckRoll(0f, (CharacterMaster)null)));
			while (val.TryGotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction i) => ILPatternMatchingExt.MatchCall(i, (MethodBase)method)
			}))
			{
				val.Remove();
				val.Emit(OpCodes.Ldloc, val2);
				val.Emit(OpCodes.Call, (MethodBase)((object)this).GetType().GetMethod("CheckRoll"));
			}
		}

		private void FixEdgeCase(orig_BaseItemDrop orig, ChestBehavior self)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			if (self.rng == item)
			{
				self.rng = new Xoroshiro128Plus(item);
				orig.Invoke(self);
				for (int i = 1; i < self.dropCount; i++)
				{
					item.Next();
				}
			}
			else
			{
				orig.Invoke(self);
			}
		}

		private void SkipHalcyonRoll(ILContext context)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_002c: 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_0044: 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_0089: Expected O, but got Unknown
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(context);
			FieldInfo field = typeof(HalcyoniteShrineInteractable).GetField("rng", BindingFlags.Instance | BindingFlags.NonPublic);
			while (val.TryGotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction i) => ILPatternMatchingExt.MatchStfld(i, field)
			}))
			{
				val.Emit(OpCodes.Pop);
				val.Emit(OpCodes.Ldarg_0);
				val.Emit(OpCodes.Ldfld, field);
				ILCursor obj = val;
				int index = obj.Index + 1;
				obj.Index = index;
			}
			val = new ILCursor(context);
			field = typeof(Run).GetField("treasureRng");
			while (val.TryGotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction i) => ILPatternMatchingExt.MatchLdfld(i, field)
			}))
			{
				ILCursor obj2 = val;
				int index = obj2.Index + 1;
				obj2.Index = index;
				val.Emit(OpCodes.Pop);
				val.EmitDelegate<Func<Xoroshiro128Plus>>((Func<Xoroshiro128Plus>)(() => new Xoroshiro128Plus(0uL)));
			}
		}

		private void GenerateAll(ILContext context)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(context);
			MethodInfo generate = SymbolExtensions.GetMethodInfo<PickupDropTable, PickupIndex[]>((Expression<Func<PickupDropTable, PickupIndex[]>>)((PickupDropTable _) => _.GenerateUniqueDrops(0, (Xoroshiro128Plus)null)));
			VariableDefinition val2 = new VariableDefinition(context.Import(typeof(object)));
			context.Method.Body.Variables.Add(val2);
			while (val.TryGotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction i) => ILPatternMatchingExt.MatchCallvirt(i, (MethodBase)generate)
			}))
			{
				val.Emit(OpCodes.Stloc, val2);
				val.Emit(OpCodes.Ldc_I4_5);
				val.Emit(OpCodes.Call, (MethodBase)SymbolExtensions.GetMethodInfo((Expression<Action>)(() => Math.Max(0, 0))));
				val.Emit(OpCodes.Ldloc, val2);
				int index = val.Index + 1;
				val.Index = index;
			}
		}

		private async void AddSceneToGroup(string collection, string stage)
		{
			AsyncOperationHandle<SceneCollection> group = Addressables.LoadAssetAsync<SceneCollection>((object)collection);
			AsyncOperationHandle<SceneDef> scene = Addressables.LoadAssetAsync<SceneDef>((object)stage);
			await group.Task;
			await scene.Task;
			if (((Behaviour)this).isActiveAndEnabled)
			{
				SceneEntry[] original = group.Result._sceneEntries;
				ref SceneEntry[] sceneEntries = ref group.Result._sceneEntries;
				SceneEntry val = new SceneEntry
				{
					sceneDef = scene.Result
				};
				ArrayUtils.ArrayAppend<SceneEntry>(ref sceneEntries, ref val);
				_onDisable += delegate
				{
					group.Result._sceneEntries = original;
				};
			}
		}

		private async void ChangeDestination(string portal)
		{
			AsyncOperationHandle<GameObject> prefab = Addressables.LoadAssetAsync<GameObject>((object)portal);
			await prefab.Task;
			if (((Behaviour)this).isActiveAndEnabled)
			{
				SceneExitController controller = prefab.Result.GetComponent<SceneExitController>();
				bool useRunNextStageScene = controller.useRunNextStageScene;
				bool isAlternatePath = controller.isAlternatePath;
				controller.useRunNextStageScene = true;
				controller.isAlternatePath = false;
				_onDisable += delegate
				{
					controller.useRunNextStageScene = useRunNextStageScene;
					controller.isAlternatePath = isAlternatePath;
				};
			}
		}

		private async void ReplacePortals(string parent, string replacement)
		{
			AsyncOperationHandle<GameObject> prefab = Addressables.LoadAssetAsync<GameObject>((object)parent);
			AsyncOperationHandle<InteractableSpawnCard> card = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)replacement);
			await prefab.Task;
			await card.Task;
			if (!((Behaviour)this).isActiveAndEnabled)
			{
				return;
			}
			PortalSpawner[] components = prefab.Result.GetComponents<PortalSpawner>();
			foreach (PortalSpawner portal in components)
			{
				string spawnMessageToken = portal.spawnMessageToken;
				portal.spawnMessageToken = "PORTAL_STORM_OPEN";
				string spawnPreviewMessageToken = portal.spawnPreviewMessageToken;
				portal.spawnPreviewMessageToken = "PORTAL_STORM_WILL_OPEN";
				InteractableSpawnCard portalSpawnCard = portal.portalSpawnCard;
				portal.portalSpawnCard = card.Result;
				string previewChildName = portal.previewChildName;
				portal.previewChildName = "StormPortalIndicator";
				string[] invalidStages = portal.invalidStages;
				portal.invalidStages = Array.Empty<string>();
				_onDisable += delegate
				{
					portal.spawnMessageToken = spawnMessageToken;
					portal.spawnPreviewMessageToken = spawnPreviewMessageToken;
					portal.portalSpawnCard = portalSpawnCard;
					portal.previewChildName = previewChildName;
					portal.invalidStages = invalidStages;
				};
			}
		}

		public static bool CheckRoll(float percent, CharacterMaster master, Xoroshiro128Plus generator)
		{
			if (!(percent >= 100f))
			{
				if (percent <= 0f)
				{
					return false;
				}
				return CheckForLuck(percent, master, generator.nextNormalizedFloat * 100f);
			}
			return true;
		}

		public static bool CheckForLuck(float percent, CharacterMaster master, float roll)
		{
			float num = (Object.op_Implicit((Object)(object)master) ? Mathf.Ceil(master.luck) : 0f);
			float num2 = percent / 100f;
			if (!(num > 0f))
			{
				if (num < 0f)
				{
					num2 = Mathf.Pow(num2, 1f - num);
				}
			}
			else
			{
				num2 = 1f - Mathf.Pow(1f - num2, 1f + num);
			}
			if (roll < num2 * 100f)
			{
				if (roll >= percent)
				{
					GameObject bodyObject = master.GetBodyObject();
					CharacterBody val = default(CharacterBody);
					if (Object.op_Implicit((Object)(object)bodyObject) && bodyObject.TryGetComponent<CharacterBody>(ref val))
					{
						val.wasLucky = true;
					}
				}
				return true;
			}
			return false;
		}
	}
	public class GauntletCatalog
	{
		private static readonly Dictionary<string, string> LexicalToDisplayToken = new Dictionary<string, string>
		{
			{ "bandit", "BANDIT2_BODY_NAME" },
			{ "captain", "CAPTAIN_BODY_NAME" },
			{ "commando", "COMMANDO_BODY_NAME" },
			{ "acrid", "CROCO_BODY_NAME" },
			{ "engineer", "ENGI_BODY_NAME" },
			{ "huntress", "HUNTRESS_BODY_NAME" },
			{ "loader", "LOADER_BODY_NAME" },
			{ "artificer", "MAGE_BODY_NAME" },
			{ "mercenary", "MERC_BODY_NAME" },
			{ "mult", "TOOLBOT_BODY_NAME" },
			{ "rex", "TREEBOT_BODY_NAME" },
			{ "railgunner", "RAILGUNNER_BODY_NAME" },
			{ "viend", "VOIDSURVIVOR_BODY_NAME" },
			{ "seeker", "SEEKER_BODY_NAME" },
			{ "chef", "CHEF_BODY_NAME" },
			{ "falseson", "FALSESON_BODY_NAME" }
		};

		public static string GetDisplayTokenFromLexicalName(string name)
		{
			return LexicalToDisplayToken.GetValueOrDefault(name, name);
		}
	}
	internal class IgnoreFallDamage : MonoBehaviour
	{
		private static CharacterBody body;

		protected void Awake()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			AsyncOperationHandle<GameObject> handle = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Brother/BrotherBody.prefab");
			handle.Completed += delegate
			{
				body = handle.Result.GetComponent<CharacterBody>();
				if (((Behaviour)this).isActiveAndEnabled)
				{
					OnEnable();
				}
			};
		}

		protected void OnEnable()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)body))
			{
				CharacterBody obj = body;
				obj.bodyFlags = (BodyFlags)(obj.bodyFlags | 1);
			}
		}

		protected void OnDisable()
		{
			//IL_0012: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)body))
			{
				CharacterBody obj = body;
				obj.bodyFlags = (BodyFlags)(obj.bodyFlags & -2);
			}
		}
	}
	internal class ItemTransformation : MonoBehaviour
	{
		private CachedGenerator<ItemIndex> input;

		private CachedGenerator<ItemIndex> output;

		private static uint lifetime = 5u;

		[ConCommand(commandName = "cache_lifetime", helpText = "used for Benthic Bloom")]
		private static void SetLifetime(ConCommandArgs argument)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			switch (((ConCommandArgs)(ref argument)).Count)
			{
			case 1:
			{
				uint num = (uint)((ConCommandArgs)(ref argument)).GetArgULong(0);
				if (lifetime == num)
				{
					Debug.Log((object)"no change");
					return;
				}
				if (Object.op_Implicit((Object)(object)Run.instance))
				{
					Debug.Log((object)"please start a new run to load changes");
				}
				lifetime = num;
				break;
			}
			default:
				Debug.Log((object)"too many arguments");
				return;
			case 0:
				break;
			}
			Debug.Log((object)(argument.commandName + " set to " + lifetime));
		}

		public void OnEnable()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			Run.onRunStartGlobal += OnRunStartGlobal;
			CharacterMaster.TryCloverVoidUpgrades += new hook_TryCloverVoidUpgrades(TryCloverVoidUpgrades);
		}

		public void OnDisable()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			Run.onRunStartGlobal -= OnRunStartGlobal;
			CharacterMaster.TryCloverVoidUpgrades -= new hook_TryCloverVoidUpgrades(TryCloverVoidUpgrades);
		}

		private void OnRunStartGlobal(Run instance)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected I4, but got Unknown
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected I4, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			IEnumerable<ItemIndex> first = convert(instance.availableTier1DropList);
			IEnumerable<ItemIndex> enumerable = convert(instance.availableTier2DropList);
			IEnumerable<ItemIndex> second = convert(instance.availableTier3DropList);
			IEnumerable<ItemIndex> second2 = new <>z__ReadOnlyArray<ItemIndex>((ItemIndex[])(object)new ItemIndex[2]
			{
				(ItemIndex)(int)Items.ScrapWhite.itemIndex,
				(ItemIndex)(int)Items.ScrapGreen.itemIndex
			});
			Xoroshiro128Plus val = new Xoroshiro128Plus(instance.runRNG.Next());
			input = new CachedGenerator<ItemIndex>(val.Next(), first.Concat(enumerable).Concat(second2), lifetime);
			output = new CachedGenerator<ItemIndex>(val.Next(), enumerable.Concat(second));
			static IEnumerable<ItemIndex> convert(IEnumerable<PickupIndex> pickup)
			{
				foreach (PickupIndex item in pickup)
				{
					yield return PickupCatalog.GetPickupDef(item).itemIndex;
				}
			}
		}

		private void TryCloverVoidUpgrades(orig_TryCloverVoidUpgrades _, CharacterMaster self)
		{
			//IL_008f: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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_010d: 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)
			if (!NetworkServer.active)
			{
				return;
			}
			Inventory inventory = self.inventory;
			int num = inventory.GetItemCount(Items.CloverVoid) * 3;
			if (num <= 0 || !input.Any(valid))
			{
				return;
			}
			do
			{
				input.log("input:");
				if (!input.TryGetNext(valid, out var item))
				{
					break;
				}
				int itemCount = inventory.GetItemCount(item);
				output.log("output:");
				ItemIndex next = output.GetNext((ItemIndex index) => CheckTag(item, index));
				inventory.RemoveItem(item, itemCount);
				inventory.GiveItem(next, itemCount);
				input.log("removed:");
				input.Clear();
				CharacterMasterNotificationQueue.SendTransformNotification(self, item, next, (TransformationType)2);
			}
			while (--num > 0);
			GameObject bodyInstanceObject = self.bodyInstanceObject;
			if (Object.op_Implicit((Object)(object)bodyInstanceObject))
			{
				Util.PlaySound("Play_item_proc_extraLife", bodyInstanceObject);
			}
			bool valid(ItemIndex index)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				return inventory.GetItemCount(index) > 0;
			}
		}

		private static bool CheckTag(ItemIndex i, ItemIndex j)
		{
			//IL_0000: 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_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_0034: 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_0039: Invalid comparison between Unknown and I4
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			ItemDef itemDef = ItemCatalog.GetItemDef(i);
			ItemDef itemDef2 = ItemCatalog.GetItemDef(j);
			if (itemDef2.tier != (ItemTier)(itemDef.tier + 1))
			{
				return false;
			}
			bool result = true;
			ItemTag[] tags = itemDef.tags;
			foreach (ItemTag val in tags)
			{
				if (val - 1 <= 2)
				{
					if (itemDef2.ContainsTag(val))
					{
						return true;
					}
					result = false;
				}
			}
			return result;
		}
	}
	public class CachedGenerator<T>
	{
		private record Entry
		{
			internal T type;

			internal uint age;

			public Entry(T type)
			{
				this.type = type;
				base..ctor();
			}

			[CompilerGenerated]
			protected virtual bool PrintMembers(StringBuilder builder)
			{
				return false;
			}

			[CompilerGenerated]
			public void Deconstruct(out T type)
			{
				type = this.type;
			}
		}

		[CompilerGenerated]
		private uint <lifetime>P;

		private readonly Xoroshiro128Plus generator;

		private readonly T[] item;

		private readonly LinkedList<Entry> cache;

		internal Action<object> log;

		public CachedGenerator(ulong seed, IEnumerable<T> item, uint lifetime = 0u)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			<lifetime>P = lifetime;
			generator = new Xoroshiro128Plus(seed);
			this.item = item.ToArray();
			cache = new LinkedList<Entry>();
			log = delegate
			{
			};
			base..ctor();
		}

		internal T GetNext(Predicate<T> valid)
		{
			for (LinkedListNode<Entry> linkedListNode = cache.First; linkedListNode != null; linkedListNode = linkedListNode.Next)
			{
				T type = linkedListNode.Value.type;
				log(type);
				if (valid(type))
				{
					cache.Remove(linkedListNode);
					return type;
				}
			}
			log("\t ---- ");
			T val;
			while (true)
			{
				val = generator.NextElementUniform<T>(item);
				log(val);
				if (valid(val))
				{
					break;
				}
				cache.AddLast(new Entry(val));
			}
			return val;
		}

		internal bool Any(Predicate<T> valid)
		{
			T[] array = item;
			foreach (T obj in array)
			{
				if (valid(obj))
				{
					return true;
				}
			}
			return false;
		}

		internal bool TryGetNext(Predicate<T> valid, out T value)
		{
			value = default(T);
			if (Any(valid))
			{
				value = GetNext(valid);
				return true;
			}
			log(null);
			return false;
		}

		internal void Clear()
		{
			LinkedListNode<Entry> linkedListNode = cache.First;
			LinkedListNode<Entry> linkedListNode2 = null;
			while (linkedListNode != null)
			{
				if (++linkedListNode.Value.age > <lifetime>P)
				{
					linkedListNode2 = linkedListNode.Next;
					cache.Remove(linkedListNode);
					log(linkedListNode.Value.type);
					linkedListNode = linkedListNode2;
				}
				else
				{
					linkedListNode = linkedListNode.Next;
				}
			}
			if (linkedListNode2 == null)
			{
				log(null);
			}
		}
	}
	public class LazarusResurrection : MonoBehaviour
	{
		public static ItemIndex lunarWingsIndex = (ItemIndex)106;

		public static ItemIndex lazarusWingsIndex;

		public static int deathCount = 0;

		private static float timePenaltySeconds = 300f;

		private static GameObject cachedHippoRezEffect;

		private static string playSoundString = "Play_item_proc_deathMark";

		public void OnEnable()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			cachedHippoRezEffect = LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/HippoRezEffect");
			CharacterMaster.IsDeadAndOutOfLivesServer += new hook_IsDeadAndOutOfLivesServer(OnCharacterMasterOnIsDeadAndOutOfLivesServer);
			CharacterMaster.OnBodyDeath += new hook_OnBodyDeath(OnCharacterMasterOnOnBodyDeath);
			RunTimerUIController.Update += new hook_Update(TimeAdd);
			Run.onPlayerFirstCreatedServer += OnPlayerAdded;
		}

		public void OnDisable()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			CharacterMaster.IsDeadAndOutOfLivesServer -= new hook_IsDeadAndOutOfLivesServer(OnCharacterMasterOnIsDeadAndOutOfLivesServer);
			CharacterMaster.OnBodyDeath -= new hook_OnBodyDeath(OnCharacterMasterOnOnBodyDeath);
			RunTimerUIController.Update -= new hook_Update(TimeAdd);
			Run.onPlayerFirstCreatedServer -= OnPlayerAdded;
		}

		private void OnCharacterMasterOnOnBodyDeath(orig_OnBodyDeath orig, CharacterMaster self, CharacterBody body)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!NetworkServer.active || !body.isPlayerControlled || body.HasBuff(Buffs.ExtraLifeBuff) || self.seekerSelfRevive || self.inventory.currentEquipmentIndex == Equipment.HealAndRevive.equipmentIndex || self.inventory.GetItemCount(Items.ExtraLife) > 0 || self.inventory.GetItemCount(Items.ExtraLifeVoid) > 0)
				{
					return;
				}
				self.destroyOnBodyDeath = false;
			}
			finally
			{
				orig.Invoke(self, body);
			}
			self.preventRespawnUntilNextStageServer = false;
			self.preventGameOver = true;
			((MonoBehaviour)Main.instance).StartCoroutine(delay());
			IEnumerator delay()
			{
				yield return (object)new WaitForSeconds(1.5f);
				lazarusWingsIndex = ItemCatalog.FindItemIndex("LazarusWings");
				self.inventory.GiveItem(lazarusWingsIndex, 1);
				CharacterMasterNotificationQueue.PushItemNotification(self, lazarusWingsIndex);
				Vector3 val = self.deathFootPosition;
				if (self.killedByUnsafeArea)
				{
					val = (Vector3)(((??)TeleportHelper.FindSafeTeleportDestination(self.deathFootPosition, self.bodyPrefab.GetComponent<CharacterBody>(), RoR2Application.rng)) ?? self.deathFootPosition);
				}
				self.Respawn(val, Quaternion.Euler(0f, Random.Range(0f, 360f), 0f), false);
				self.GetBody().AddTimedBuff(Buffs.Immune, 5f);
				GameObject val2 = ((!Main.UseLazarusDeathEffect.Value) ? cachedHippoRezEffect : Assets.lazarusResurrectionEffect);
				if (Object.op_Implicit((Object)(object)self.bodyInstanceObject))
				{
					EntityStateMachine[] components = self.bodyInstanceObject.GetComponents<EntityStateMachine>();
					foreach (EntityStateMachine obj in components)
					{
						obj.initialStateType = obj.mainStateType;
					}
					if (Object.op_Implicit((Object)(object)val2))
					{
						EffectManager.SpawnEffect(val2, new EffectData
						{
							origin = val,
							rotation = self.bodyInstanceObject.transform.rotation
						}, true);
						Util.PlaySound(playSoundString, self.bodyInstanceObject.gameObject);
					}
				}
			}
		}

		private bool OnCharacterMasterOnIsDeadAndOutOfLivesServer(orig_IsDeadAndOutOfLivesServer orig, CharacterMaster self)
		{
			CharacterBody body = self.GetBody();
			if (orig.Invoke(self))
			{
				if (Object.op_Implicit((Object)(object)body))
				{
					return !body.isPlayerControlled;
				}
				return true;
			}
			return false;
		}

		private void OnPlayerAdded(object _, PlayerCharacterMasterController player)
		{
			player.master.inventory.onInventoryChanged += delegate
			{
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				deathCount = 0;
				foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
				{
					deathCount += instance.master.inventory.GetItemCount(lazarusWingsIndex);
				}
			};
		}

		public void TimeAdd(orig_Update orig, RunTimerUIController self)
		{
			orig.Invoke(self);
			TimerText runStopwatchTimerTextController = self.runStopwatchTimerTextController;
			runStopwatchTimerTextController.seconds += (double)GetTotalPenalty();
		}

		public static float GetTotalPenalty()
		{
			return (float)deathCount * timePenaltySeconds;
		}
	}
	public class LazarusWings
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Func<Instruction, bool> <>9__8_1;

			public static Func<Instruction, bool> <>9__8_2;

			public static Manipulator <>9__8_0;

			internal void <Initialize>b__8_0(ILContext context)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Expected O, but got Unknown
				//IL_008e: 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_00a7: 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)
				<>c__DisplayClass8_0 CS$<>8__locals0 = new <>c__DisplayClass8_0();
				ILCursor val = new ILCursor(context);
				CS$<>8__locals0.failed = null;
				if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[3]
				{
					(Instruction i) => ILPatternMatchingExt.MatchLdfld<ItemDisplayRule>(i, "followerPrefabAddress"),
					(Instruction i) => ILPatternMatchingExt.MatchCallOrCallvirt<AssetReference>(i, "RuntimeKeyIsValid"),
					(Instruction i) => ILPatternMatchingExt.MatchBrfalse(i, ref CS$<>8__locals0.failed)
				}))
				{
					int index = val.Index + 1;
					val.Index = index;
					Instruction next = val.Next;
					val.Emit(OpCodes.Dup);
					val.Emit(OpCodes.Brtrue, next);
					val.Emit(OpCodes.Pop);
					val.Emit(OpCodes.Br, (object)CS$<>8__locals0.failed);
				}
			}

			internal bool <Initialize>b__8_1(Instruction i)
			{
				return ILPatternMatchingExt.MatchLdfld<ItemDisplayRule>(i, "followerPrefabAddress");
			}

			internal bool <Initialize>b__8_2(Instruction i)
			{
				return ILPatternMatchingExt.MatchCallOrCallvirt<AssetReference>(i, "RuntimeKeyIsValid");
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass8_0
		{
			public ILLabel failed;

			internal bool <Initialize>b__3(Instruction i)
			{
				return ILPatternMatchingExt.MatchBrfalse(i, ref failed);
			}
		}

		internal static GameObject lunarWingsDisplayPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/LunarWings/DisplayLunarWings.prefab").WaitForCompletion();

		internal static GameObject lunarWingsPickupPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/LunarWings/PickupLunarWings.prefab").WaitForCompletion();

		internal static Sprite lunarWingsIcon = Addressables.LoadAssetAsync<Sprite>((object)"RoR2/DLC1/LunarWings/texLunarWingsIcon.png").WaitForCompletion();

		private static Material wingsMat = Addressables.LoadAssetAsync<Material>((object)"RoR2/Base/PortalShop/matShopPortalEffectEdge.mat").WaitForCompletion();

		private const string LAZARUSWINGS_NAME = "Lazarus Wings";

		private const string LAZARUSWINGS_PICKUP = "Adds a <style=cIsUtility>5 minute</style> time penalty to the run timer <style=cStack>(+5 minutes per stack)</style>";

		private const string LAZARUSWINGS_DESC = "Adds a <style=cIsUtility>5 minute</style> time penalty to the run timer <style=cStack>(+5 minutes per stack)</style>";

		private const string LAZARUSWINGS_LORE = "The resurrection is a never-ending cycle, one of ongoing torment and despair. \nLife and death are intertwined in a continuous loop, like two sides of a single blade. We are all given a chance at life, but at what cost? \nWe are cast away from the living, and into the darkness, our souls forever wandering, searching for an escape from the deathly embrace. \nWe are doomed to eternal suffering, unless we can learn to accept the resurrection, and overcome our fear of the unknown.";

		public static void Initialize()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: 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_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: 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_0182: 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_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: 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_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: 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_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: 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_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: 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_031b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: 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_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0374: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_03af: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f9: 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_0414: Unknown result type (might be due to invalid IL or missing references)
			//IL_0419: Unknown result type (might be due to invalid IL or missing references)
			//IL_042f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0434: Unknown result type (might be due to invalid IL or missing references)
			//IL_0439: Unknown result type (might be due to invalid IL or missing references)
			//IL_043a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0454: Unknown result type (might be due to invalid IL or missing references)
			//IL_0483: Unknown result type (might be due to invalid IL or missing references)
			//IL_0488: Unknown result type (might be due to invalid IL or missing references)
			//IL_049e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a3: 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_04c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04de: Unknown result type (might be due to invalid IL or missing references)
			//IL_050d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0512: Unknown result type (might be due to invalid IL or missing references)
			//IL_0528: Unknown result type (might be due to invalid IL or missing references)
			//IL_052d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0543: Unknown result type (might be due to invalid IL or missing references)
			//IL_0548: Unknown result type (might be due to invalid IL or missing references)
			//IL_054d: Unknown result type (might be due to invalid IL or missing references)
			//IL_054e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0568: Unknown result type (might be due to invalid IL or missing references)
			//IL_0597: Unknown result type (might be due to invalid IL or missing references)
			//IL_059c: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0621: Unknown result type (might be due to invalid IL or missing references)
			//IL_0626: Unknown result type (might be due to invalid IL or missing references)
			//IL_063c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0641: Unknown result type (might be due to invalid IL or missing references)
			//IL_0657: Unknown result type (might be due to invalid IL or missing references)
			//IL_065c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0661: Unknown result type (might be due to invalid IL or missing references)
			//IL_0662: Unknown result type (might be due to invalid IL or missing references)
			//IL_067c: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0706: Unknown result type (might be due to invalid IL or missing references)
			//IL_0735: Unknown result type (might be due to invalid IL or missing references)
			//IL_073a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0750: Unknown result type (might be due to invalid IL or missing references)
			//IL_0755: Unknown result type (might be due to invalid IL or missing references)
			//IL_076b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0770: Unknown result type (might be due to invalid IL or missing references)
			//IL_0775: Unknown result type (might be due to invalid IL or missing references)
			//IL_0776: Unknown result type (might be due to invalid IL or missing references)
			//IL_0782: Unknown result type (might be due to invalid IL or missing references)
			//IL_078c: Expected O, but got Unknown
			//IL_07a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ac: Expected O, but got Unknown
			ItemDef val = new ItemDef
			{
				name = "LazarusWings",
				tier = (ItemTier)5,
				deprecatedTier = (ItemTier)5,
				pickupModelPrefab = lunarWingsPickupPrefab,
				pickupIconSprite = lunarWingsIcon,
				canRemove = false,
				nameToken = "Lazarus Wings",
				pickupToken = "Adds a <style=cIsUtility>5 minute</style> time penalty to the run timer <style=cStack>(+5 minutes per stack)</style>",
				descriptionToken = "Adds a <style=cIsUtility>5 minute</style> time penalty to the run timer <style=cStack>(+5 minutes per stack)</style>",
				loreToken = "The resurrection is a never-ending cycle, one of ongoing torment and despair. \nLife and death are intertwined in a continuous loop, like two sides of a single blade. We are all given a chance at life, but at what cost? \nWe are cast away from the living, and into the darkness, our souls forever wandering, searching for an escape from the deathly embrace. \nWe are doomed to eternal suffering, unless we can learn to accept the resurrection, and overcome our fear of the unknown."
			};
			lunarWingsDisplayPrefab.AddComponent<ItemDisplay>();
			ItemDisplayRuleDict val2 = new ItemDisplayRuleDict(Array.Empty<ItemDisplayRule>());
			val2.Add("mdlCommandoDualies", (ItemDisplayRule[])(object)new ItemDisplayRule[1]
			{
				new ItemDisplayRule
				{
					followerPrefab = lunarWingsDisplayPrefab,
					childName = "Chest",
					localPos = new Vector3(0.00015f, 0.35673f, -0.13908f),
					localAngles = new Vector3(29.83448f, 2.96739f, 1.53991f),
					localScale = new Vector3(0.66405f, 0.66405f, 0.66405f)
				}
			});
			val2.Add("mdlHuntress", (ItemDisplayRule[])(object)new ItemDisplayRule[1]
			{
				new ItemDisplayRule
				{
					followerPrefab = lunarWingsDisplayPrefab,
					childName = "Chest",
					localPos = new Vector3(0.03159f, 0.12506f, -0.11253f),
					localAngles = new Vector3(2.02883f, 320.887f, 2.59241f),
					localScale = new Vector3(0.67117f, 0.67117f, 0.67117f)
				}
			});
			val2.Add("mdlBandit2", (ItemDisplayRule[])(object)new ItemDisplayRule[1]
			{
				new ItemDisplayRule
				{
					followerPrefab = lunarWingsDisplayPrefab,
					childName = "Chest",
					localPos = new Vector3(0.0186f, 0.19022f, -0.17056f),
					localAngles = new Vector3(21.46973f, 4.22358f, 350.7856f),
					localScale = new Vector3(0.63697f, 0.63697f, 0.63697f)
				}
			});
			val2.Add("mdlToolbot", (ItemDisplayRule[])(object)new ItemDisplayRule[1]
			{
				new ItemDisplayRule
				{
					followerPrefab = lunarWingsDisplayPrefab,
					childName = "Chest",
					localPos = new Vector3(0.26714f, 1.0237f, -1.86616f),
					localAngles = new Vector3(19.8663f, 356.4091f, 358.1597f),
					localScale = new Vector3(7.19914f, 7.19914f, 7.19914f)
				}
			});
			val2.Add("mdlEngi", (ItemDisplayRule[])(object)new ItemDisplayRule[1]
			{
				new ItemDisplayRule
				{
					followerPrefab = lunarWingsDisplayPrefab,
					childName = "Chest",
					localPos = new Vector3(-0.00569f, 0.08394f, -0.2341f),
					localAngles = new Vector3(354.0963f, 358.2862f, 358.6038f),
					localScale = new Vector3(0.79185f, 0.79185f, 0.79185f)
				}
			});
			val2.Add("mdlMage", (ItemDisplayRule[])(object)new ItemDisplayRule[1]
			{
				new ItemDisplayRule
				{
					followerPrefab = lunarWingsDisplayPrefab,
					childName = "Chest",
					localPos = new Vector3(-0.00942f, 0.03686f, -0.27844f),
					localAngles = new Vector3(0.14453f, 355.3709f, 1.70079f),
					localScale = new Vector3(0.74458f, 0.74458f, 0.74458f)
				}
			});
			val2.Add("mdlMerc", (ItemDisplayRule[])(object)new ItemDisplayRule[1]
			{
				new ItemDisplayRule
				{
					followerPrefab = lunarWingsDisplayPrefab,
					childName = "Chest",
					localPos = new Vector3(-0.00667f, 0.12215f, -0.21273f),
					localAngles = new Vector3(12.88405f, 355.9306f, 357.45f),
					localScale = new Vector3(0.76865f, 0.76865f, 0.76865f)
				}
			});
			val2.Add("mdlTreebot", (ItemDisplayRule[])(object)new ItemDisplayRule[1]
			{
				new ItemDisplayRule
				{
					followerPrefab = lunarWingsDisplayPrefab,
					childName = "HeadBase",
					localPos = new Vector3(0.02836f, -1.29261f, 0.70876f),
					localAngles = new Vector3(9.15137f, 176.2903f, 182.9521f),
					localScale = new Vector3(1.60994f, 1.60994f, 1.60994f)
				}
			});
			val2.Add("mdlLoader", (ItemDisplayRule[])(object)new ItemDisplayRule[1]
			{
				new ItemDisplayRule
				{
					followerPrefab = lunarWingsDisplayPrefab,
					childName = "Chest",
					localPos = new Vector3(-0.00592f, 0.18198f, -0.26041f),
					localAngles = new Vector3(3.79341f, 3.28101f, 0.27247f),
					localScale = new Vector3(0.85237f, 0.85237f, 0.85237f)
				}
			});
			val2.Add("mdlCroco", (ItemDisplayRule[])(object)new ItemDisplayRule[1]
			{
				new ItemDisplayRule
				{
					followerPrefab = lunarWingsDisplayPrefab,
					childName = "Chest",
					localPos = new Vector3(-0.02597f, 0.34623f, 3.17591f),
					localAngles = new Vector3(335.5031f, 177.2755f, 3.44059f),
					localScale = new Vector3(7.35741f, 7.35741f, 7.35741f)
				}
			});
			val2.Add("mdlCaptain", (ItemDisplayRule[])(object)new ItemDisplayRule[1]
			{
				new ItemDisplayRule
				{
					followerPrefab = lunarWingsDisplayPrefab,
					childName = "Chest",
					localPos = new Vector3(-0.01571f, 0.24481f, -0.16307f),
					localAngles = new Vector3(18.78144f, 7.25192f, 1.65195f),
					localScale = new Vector3(0.89055f, 0.89055f, 0.89055f)
				}
			});
			val2.Add("mdlRailGunner", (ItemDisplayRule[])(object)new ItemDisplayRule[1]
			{
				new ItemDisplayRule
				{
					followerPrefab = lunarWingsDisplayPrefab,
					childName = "Chest",
					localPos = new Vector3(-0.0457f, -0.12092f, -0.27414f),
					localAngles = new Vector3(353.748f, 10.2935f, 349.5002f),
					localScale = new Vector3(0.74962f, 0.74962f, 0.74962f)
				}
			});
			val2.Add("mdlVoidSurvivor", (ItemDisplayRule[])(object)new ItemDisplayRule[1]
			{
				new ItemDisplayRule
				{
					followerPrefab = lunarWingsDisplayPrefab,
					childName = "Chest",
					localPos = new Vector3(0.02643f, 0.0461f, -0.17402f),
					localAngles = new Vector3(353.6433f, 5.13739f, 6.10527f),
					localScale = new Vector3(0.87425f, 0.87425f, 0.87425f)
				}
			});
			ItemAPI.Add(new CustomItem(val, val2));
			object obj = <>c.<>9__8_0;
			if (obj == null)
			{
				Manipulator val3 = delegate(ILContext context)
				{
					//IL_0007: Unknown result type (might be due to invalid IL or missing references)
					//IL_000d: Expected O, but got Unknown
					//IL_008e: 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_00a7: 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)
					ILCursor val4 = new ILCursor(context);
					ILLabel failed = null;
					if (val4.TryGotoNext((MoveType)0, new Func<Instruction, bool>[3]
					{
						(Instruction i) => ILPatternMatchingExt.MatchLdfld<ItemDisplayRule>(i, "followerPrefabAddress"),
						(Instruction i) => ILPatternMatchingExt.MatchCallOrCallvirt<AssetReference>(i, "RuntimeKeyIsValid"),
						(Instruction i) => ILPatternMatchingExt.MatchBrfalse(i, ref failed)
					}))
					{
						int index = val4.Index + 1;
						val4.Index = index;
						Instruction next = val4.Next;
						val4.Emit(OpCodes.Dup);
						val4.Emit(OpCodes.Brtrue, next);
						val4.Emit(OpCodes.Pop);
						val4.Emit(OpCodes.Br, (object)failed);
					}
				};
				<>c.<>9__8_0 = val3;
				obj = (object)val3;
			}
			CharacterModel.InstantiateDisplayRuleGroup += (Manipulator)obj;
		}
	}
	public class LoadoutHandler
	{
		private protected ManualLogSource _log = Logger.CreateLogSource("LoadoutHandler");

		public static LoadoutHandler Instance { get; } = new LoadoutHandler();


		public Race Race { get; private set; }

		public Loadout GetLoadout(int loadoutNumber)
		{
			_log.LogInfo((object)$"GetLoadout({loadoutNumber})");
			Loadout loadout = null;
			if (loadoutNumber <= Race.Loadouts.Count)
			{
				loadout = Race.Loadouts.FirstOrDefault((Loadout l) => l.Id == loadoutNumber);
				_log.LogDebug((object)$"Found Loadout : {loadout}");
			}
			if (loadout == null)
			{
				_log.LogWarning((object)$"`{loadoutNumber}` not found or out of bounds of {Race.Loadouts.Count} loadout(s)");
			}
			return loadout;
		}

		public List<Loadout> GetLoadouts()
		{
			return Race?.Loadouts ?? new List<Loadout>();
		}

		public void RegisterRace(Race race)
		{
			_log.LogDebug((object)("Keeping track of race : " + race.ToJson()));
			Race = race;
		}
	}
	public class LobbyHandler : MonoBehaviour
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_IsUnlockableUnlocked_UnlockableDef <>9__0_0;

			public static hook_CanUnlockableBeGrantedThisRun_UnlockableDef <>9__0_1;

			public static hook_DoesEveryoneHaveThisUnlockableUnlocked_UnlockableDef <>9__0_2;

			public static hook_AnyUserHasUnlockable <>9__0_3;

			public static Func<Instruction, bool> <>9__4_0;

			public static Func<SurvivorDef, string> <>9__4_2;

			public static Func<SurvivorDef, SurvivorDef> <>9__4_3;

			public static Action<List<SurvivorDef>> <>9__4_1;

			internal bool <OnEnable>b__0_0(orig_IsUnlockableUnlocked_UnlockableDef _, Run _, UnlockableDef _)
			{
				return true;
			}

			internal bool <OnEnable>b__0_1(orig_CanUnlockableBeGrantedThisRun_UnlockableDef _, Run _, UnlockableDef _)
			{
				return false;
			}

			internal bool <OnEnable>b__0_2(orig_DoesEveryoneHaveThisUnlockableUnlocked_UnlockableDef _, Run _, UnlockableDef _)
			{
				return true;
			}

			internal bool <OnEnable>b__0_3(orig_AnyUserHasUnlockable _, UnlockableDef _)
			{
				return true;
			}

			internal bool <HookCharacterBuild>b__4_0(Instruction i)
			{
				return ILPatternMatchingExt.MatchCallvirt(i, (MethodBase)(typeof(List<SurvivorDef>).GetProperty("Count")?.GetMethod));
			}

			internal void <HookCharacterBuild>b__4_1(List<SurvivorDef> survivors)
			{
				List<Loadout> loadouts = LoadoutHandler.Instance.GetLoadouts();
				if (loadouts.Count == 0)
				{
					return;
				}
				Dictionary<string, SurvivorDef> dictionary = SurvivorCatalog.allSurvivorDefs.ToDictionary((SurvivorDef s) => s.displayNameToken, (SurvivorDef s) => s);
				survivors.Clear();
				foreach (Loadout item in loadouts)
				{
					string displayTokenFromLexicalName = GauntletCatalog.GetDisplayTokenFromLexicalName(item.Survivor);
					if (dictionary.TryGetValue(displayTokenFromLexicalName, out var value))
					{
						survivors.Add(value);
					}
				}
			}

			internal string <HookCharacterBuild>b__4_2(SurvivorDef s)
			{
				return s.displayNameToken;
			}

			internal SurvivorDef <HookCharacterBuild>b__4_3(SurvivorDef s)
			{
				return s;
			}
		}

		public void OnEnable()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_0049: 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_0054: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Expected O, but got Unknown
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Expected O, but got Unknown
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Expected O, but got Unknown
			//IL_0091: 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_009c: Expected O, but got Unknown
			Run.OverrideRuleChoices += new hook_OverrideRuleChoices(ForceDifficulty);
			object obj = <>c.<>9__0_0;
			if (obj == null)
			{
				hook_IsUnlockableUnlocked_UnlockableDef val = (orig_IsUnlockableUnlocked_UnlockableDef _, Run _, UnlockableDef _) => true;
				<>c.<>9__0_0 = val;
				obj = (object)val;
			}
			Run.IsUnlockableUnlocked_UnlockableDef += (hook_IsUnlockableUnlocked_UnlockableDef)obj;
			object obj2 = <>c.<>9__0_1;
			if (obj2 == null)
			{
				hook_CanUnlockableBeGrantedThisRun_UnlockableDef val2 = (orig_CanUnlockableBeGrantedThisRun_UnlockableDef _, Run _, UnlockableDef _) => false;
				<>c.<>9__0_1 = val2;
				obj2 = (object)val2;
			}
			Run.CanUnlockableBeGrantedThisRun_UnlockableDef += (hook_CanUnlockableBeGrantedThisRun_UnlockableDef)obj2;
			object obj3 = <>c.<>9__0_2;
			if (obj3 == null)
			{
				hook_DoesEveryoneHaveThisUnlockableUnlocked_UnlockableDef val3 = (orig_DoesEveryoneHaveThisUnlockableUnlocked_UnlockableDef _, Run _, UnlockableDef _) => true;
				<>c.<>9__0_2 = val3;
				obj3 = (object)val3;
			}
			Run.DoesEveryoneHaveThisUnlockableUnlocked_UnlockableDef += (hook_DoesEveryoneHaveThisUnlockableUnlocked_UnlockableDef)obj3;
			object obj4 = <>c.<>9__0_3;
			if (obj4 == null)
			{
				hook_AnyUserHasUnlockable val4 = (orig_AnyUserHasUnlockable _, UnlockableDef _) => true;
				<>c.<>9__0_3 = val4;
				obj4 = (object)val4;
			}
			PreGameController.AnyUserHasUnlockable += (hook_AnyUserHasUnlockable)obj4;
			CharacterSelectBarController.OnCreateSurvivorIcon += new hook_OnCreateSurvivorIcon(OnCreateSurvivorIcon);
			LoadoutPanelController.Rebuild += new hook_Rebuild(LoadoutPanelControllerOnRebuild);
			Row.FromSkillSlot += new hook_FromSkillSlot(OnFromSkillSlot);
			CharacterSelectBarController.Build += new Manipulator(HookCharacterBuild);
		}

		private Row OnFromSkillSlot(orig_FromSkillSlot orig, LoadoutPanelController owner, BodyIndex bodyIndex, int skillSlotIndex, GenericSkill skillSlot)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			Row.AddButton += new hook_AddButton(RowOnAddButton);
			Row result = orig.Invoke(owner, bodyIndex, skillSlotIndex, skillSlot);
			Row.AddButton -= new hook_AddButton(RowOnAddButton);
			return result;
			static void RowOnAddButton(orig_AddButton origAddButton, Row self, LoadoutPanelController loadoutPanelController, Sprite icon, string titleToken, string bodyToken, Color tooltipColor, UnityAction callback, string unlockableName, Node viewableNode, bool isWip, int defIndex)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				origAddButton.Invoke(self, loadoutPanelController, icon, titleToken, bodyToken, tooltipColor, callback, unlockableName, viewableNode, true, defIndex);
			}
		}

		private void LoadoutPanelControllerOnRebuild(orig_Rebuild orig, LoadoutPanelController self)
		{
			orig.Invoke(self);
			try
			{
				Loadout loadout = LoadoutHandler.Instance.GetLoadout(Main.CurrentLoadout.Value);
				SelectAbilitiesForLoadout(loadout, self.eventSystemLocator.eventSystem?.localUser);
			}
			catch (Exception arg)
			{
				Debug.LogWarning((object)$"Failed to set loadout: {arg}");
			}
		}

		private void ForceDifficulty(orig_OverrideRuleChoices orig, Run self, RuleChoiceMask mustInclude, RuleChoiceMask mustExclude, ulong runSeed)
		{
			orig.Invoke(self, mustInclude, mustExclude, runSeed);
			if (Main.DifficultySelect.Value != "Any")
			{
				self.ForceChoice(mustInclude, mustExclude, "Difficulty." + Main.DifficultySelect.Value);
			}
		}

		private void HookCharacterBuild(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				ILCursor val = new ILCursor(il);
				if (!val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
				{
					(Instruction i) => ILPatternMatchingExt.MatchCallvirt(i, (MethodBase)(typeof(List<SurvivorDef>).GetProperty("Count")?.GetMethod))
				}))
				{
					return;
				}
				val.Emit(OpCodes.Dup);
				val.EmitDelegate<Action<List<SurvivorDef>>>((Action<List<SurvivorDef>>)delegate(List<SurvivorDef> survivors)
				{
					List<Loadout> loadouts = LoadoutHandler.Instance.GetLoadouts();
					if (loadouts.Count == 0)
					{
						return;
					}
					Dictionary<string, SurvivorDef> dictionary = SurvivorCatalog.allSurvivorDefs.ToDictionary((SurvivorDef s) => s.displayNameToken, (SurvivorDef s) => s);
					survivors.Clear();
					foreach (Loadout item in loadouts)
					{
						string displayTokenFromLexicalName = GauntletCatalog.GetDisplayTokenFromLexicalName(item.Survivor);
						if (dictionary.TryGetValue(displayTokenFromLexicalName, out var value))
						{
							survivors.Add(value);
						}
					}
				});
			}
			catch (Exception ex)
			{
				Debug.Log((object)ex);
			}
		}

		private void OnCreateSurvivorIcon(orig_OnCreateSurvivorIcon orig, CharacterSelectBarController self, int index, SurvivorIconController controller)
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected O, but got Unknown
			orig.Invoke(self, index, controller);
			((UnityEvent<SurvivorPickInfo>)(object)self.onSurvivorPicked).AddListener((UnityAction<SurvivorPickInfo>)OnPick);
			if (controller == null)
			{
				return;
			}
			ButtonClickedEvent onClick = ((Button)controller.hgButton).onClick;
			if (onClick != null)
			{
				((UnityEvent)onClick).AddListener((UnityAction)delegate
				{
					Main.CurrentLoadout.Value = index + 1;
					Loadout loadout = LoadoutHandler.Instance.GetLoadout(Main.CurrentLoadout.Value);
					SelectAbilitiesForLoadout(loadout, self.currentLocalUser);
				});
			}
			void OnPick(SurvivorPickInfo s)
			{
				if (Main.CurrentLoadout.Value == index + 1)
				{
					self.PickIcon(self.survivorIconControllers.elements[index]);
				}
				((UnityEvent<SurvivorPickInfo>)(object)self.onSurvivorPicked).RemoveListener((UnityAction<SurvivorPickInfo>)OnPick);
			}
		}

		private void SelectAbilitiesForLoadout(Loadout loadout, LocalUser currentLocalUser)
		{
			//IL_0032: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			string token = GauntletCatalog.GetDisplayTokenFromLexicalName(loadout.Survivor);
			BodyIndex val = BodyCatalog.FindBodyIndex(SurvivorCatalog.allSurvivorDefs.First((SurvivorDef s) => s.displayNameToken == token).bodyPrefab);
			GenericSkill[] bodyPrefabSkillSlots = BodyCatalog.GetBodyPrefabSkillSlots(val);
			if (bodyPrefabSkillSlots == null)
			{
				Debug.Log((object)"body prefab skill slots are null");
				return;
			}
			int i = 0;
			int num = 0;
			for (; i < bodyPrefabSkillSlots.Length; i++)
			{
				long num2 = ((bodyPrefabSkillSlots[i].skillFamily.variants.Length > 1) ? loadout.Skills[num++] : 0);
				currentLocalUser.userProfile.loadout.bodyLoadoutManager.SetSkillVariant(val, i, (uint)num2);
			}
			currentLocalUser.userProfile.OnLoadoutChanged();
		}

		public void OnDisable()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			Run.OverrideRuleChoices -= new hook_OverrideRuleChoices(ForceDifficulty);
			CharacterSelectBarController.OnCreateSurvivorIcon -= new hook_OnCreateSurvivorIcon(OnCreateSurvivorIcon);
			LoadoutPanelController.Rebuild -= new hook_Rebuild(LoadoutPanelControllerOnRebuild);
			CharacterSelectBarController.Build -= new Manipulator(HookCharacterBuild);
			Row.FromSkillSlot -= new hook_FromSkillSlot(OnFromSkillSlot);
		}
	}
	internal static class Log
	{
		internal static ManualLogSource _logSource = Logger.CreateLogSource("RoRGauntletLog");

		internal static void Init(ManualLogSource logSource)
		{
			Logger.Sources.Remove((ILogSource)(object)_logSource);
			_logSource = logSource;
		}

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

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

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

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

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

		internal static void LogWarning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	internal class Loop : MonoBehaviour
	{
		private ConfigEntry<bool> entry;

		protected void Awake()
		{
			entry = ((BaseUnityPlugin)Main.instance).Config.Bind<bool>("Run", "Loop Protection", true, "Keep the player from accidentally looping. Still allowed via Newt/Reliquary.");
		}

		protected void OnEnable()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			ActiveToIdle.OnEnter += new hook_OnEnter(LockInteraction);
			IdleToActive.OnEnter += new hook_OnEnter(UnlockInteraction);
			TeleporterInteraction.Start += new Manipulator(NoBlueOrb);
		}

		protected void OnDisable()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			ActiveToIdle.OnEnter -= new hook_OnEnter(LockInteraction);
			IdleToActive.OnEnter -= new hook_OnEnter(UnlockInteraction);
			TeleporterInteraction.Start -= new Manipulator(NoBlueOrb);
		}

		private void LockInteraction(orig_OnEnter orig, ActiveToIdle self)
		{
			orig.Invoke(self);
			TeleporterInteraction teleporterInteraction = ((LunarTeleporterBaseState)self).teleporterInteraction;
			teleporterInteraction.locked |= entry.Value;
		}

		private void UnlockInteraction(orig_OnEnter orig, IdleToActive self)
		{
			orig.Invoke(self);
			((LunarTeleporterBaseState)self).teleporterInteraction.locked = false;
		}

		private void NoBlueOrb(ILContext context)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			MethodInfo method = typeof(TeleporterInteraction).GetProperty("shouldAttemptToSpawnShopPortal").SetMethod;
			ILCursor val = new ILCursor(context);
			val.GotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction i) => ILPatternMatchingExt.MatchCallOrCallvirt(i, (MethodBase)method)
			});
			val.Emit(OpCodes.Ldarg_0);
			val.EmitDelegate<Func<bool, TeleporterInteraction, bool>>((Func<bool, TeleporterInteraction, bool>)((bool portal, TeleporterInteraction teleporter) => (!portal || !entry.Value || !((Object)teleporter).name.StartsWith("LunarTeleporter")) && portal));
		}
	}
	public class LunarShopConfiguration : MonoBehaviour
	{
		private bool lunar;

		private bool seer;

		private bool limited;

		public void OnEnable()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			Stage.onServerStageBegin += SetupBazaar;
			Run.RefreshLunarCombinedDropList += new hook_RefreshLunarCombinedDropList(OnRunOnRefreshLunarCombinedDropList);
			SceneExitController.Begin += new hook_Begin(OnSceneExitControllerOnBegin);
		}

		public void OnDisable()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			Stage.onServerStageBegin -= SetupBazaar;
			Run.RefreshLunarCombinedDropList -= new hook_RefreshLunarCombinedDropList(OnRunOnRefreshLunarCombinedDropList);
			SceneExitController.Begin -= new hook_Begin(OnSceneExitControllerOnBegin);
		}

		private void OnRunOnRefreshLunarCombinedDropList(orig_RefreshLunarCombinedDropList orig, Run self)
		{
			orig.Invoke(self);
			if (limited)
			{
				LimitLunarItems(self);
			}
		}

		private void OnSceneExitControllerOnBegin(orig_Begin orig, SceneExitController self)
		{
			if (limited)
			{
				RemoveLunarItems();
			}
			orig.Invoke(self);
		}

		protected void Awake()
		{
			ConfigFile config = ((BaseUnityPlugin)Main.instance).Config;
			lunar = config.Bind<bool>("Bazaar & Lunar Items", "Lunar Shop Terminal", false, "Enable to purchase lunar items at the Bazaar Between Time.").Value;
			seer = config.Bind<bool>("Bazaar & Lunar Items", "Seer Station", false, "Determines if the next stage can be chosen here.").Value;
			limited = config.Bind<bool>("Bazaar & Lunar Items", "Lunar Lockdown", true, "Only valid for use at a Cleansing Pool on the same stage.").Value;
		}

		private void SetupBazaar(Stage stage)
		{
			SceneDef sceneDef = stage.sceneDef;
			if ("bazaar" == ((sceneDef != null) ? sceneDef.baseSceneName : null))
			{
				SetActive("LunarShopTerminal", lunar);
				SetActive("LunarTable", lunar);
				SetActive("LunarRecycler", lunar && !limited);
				SetActive("SeerStation", seer);
			}
		}

		private void LimitLunarItems(Run run)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			PickupIndex item = PickupCatalog.FindPickupIndex(Items.LunarTrinket.itemIndex);
			run.availableLunarEquipmentDropList.Clear();
			run.availableLunarItemDropList.Clear();
			run.availableLunarCombinedDropList.Clear();
			run.availableLunarItemDropList.Add(item);
			run.availableLunarCombinedDropList.Add(item);
		}

		private void RemoveLunarItems()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			ItemIndex itemIndex = Items.LunarTrinket.itemIndex;
			foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
			{
				instance.master.inventory.RemoveItem(itemIndex, int.MaxValue);
			}
		}

		private static void SetActive(string name, bool state)
		{
			GameObject[] array = Object.FindObjectsOfType<GameObject>();
			foreach (GameObject val in array)
			{
				if (((Object)val).name.StartsWith(name))
				{
					val.SetActive(state);
				}
			}
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("RiskOfResources.PublicRoRGauntlet", "PublicRoRGauntlet", "2.6.7")]
	public class Main : BaseUnityPlugin
	{
		public const string PluginGUID = "RiskOfResources.PublicRoRGauntlet";

		public const string PluginAuthor = "RiskOfResources";

		public const string PluginName = "PublicRoRGauntlet";

		public const string PluginVersion = "2.6.7";

		public static bool ConcedeCheck;

		internal string authorization;

		private GameObject _gauntletGameObject;

		public static Main instance;

		public static ConfigEntry<string> UserId { get; set; }

		public static ConfigEntry<string> EnvironmentName { get; set; }

		public static ConfigEntry<int> CurrentLoadout { get; set; }

		public static ConfigEntry<int> PillarNum { get; set; }

		public static ConfigEntry<string> DifficultySelect { get; set; }

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

		public static ConfigEntry<int> GauntletSize { get; set; }

		public void Awake()
		{
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Expected O, but got Unknown
			instance = this;
			Log.Init(((BaseUnityPlugin)this).Logger);
			LazarusWings.Initialize();
			InitConfig();
			Assets.Initialize(((BaseUnityPlugin)this).Info.Location);
			((Component)this).gameObject.AddComponent<MainMenuLobbyUI>();
			((Component)this).gameObject.AddComponent<LazarusResurrection>();
			((Component)this).gameObject.AddComponent<ConfigurablePillars>();
			((Component)this).gameObject.AddComponent<Stopwatch>();
			Type[] array = new Type[14]
			{
				typeof(StagePreviewUI),
				typeof(StageRNG),
				typeof(SeededPrinter),
				typeof(SeededRecycler),
				typeof(SeededChanceDoll),
				typeof(SeededSonorousWhispers),
				typeof(LobbyHandler),
				typeof(SubmitRun),
				typeof(LunarShopConfiguration),
				typeof(ItemTransformation),
				typeof(Loop),
				typeof(DLC2),
				typeof(IgnoreFallDamage),
				typeof(ContainInArenaHandler)
			};
			_gauntletGameObject = new GameObject("Gauntlet", array);
			_gauntletGameObject.transform.SetParent(((Component)this).transform);
		}

		public void InitConfig()
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Expected O, but got Unknown
			UserId = ((BaseUnityPlugin)this).Config.Bind<string>("Player", "User Id", "", "Resolved by the API. Not something you should mess with");
			CurrentLoadout = ((BaseUnityPlugin)this).Config.Bind<int>("Player", "Loadout Number", 1, "Specifies which loadout number will be employed.");
			EnvironmentName = ((BaseUnityPlugin)this).Config.Bind<string>("Run", "Environment", "prd", new ConfigDescription("Sets the environment, use 'prd' unless told otherwise.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[3] { "prd", "dev", "dbg" }), Array.Empty<object>()));
			PillarNum = ((BaseUnityPlugin)this).Config.Bind<int>("Game Rules", "Number of Pillars", 2, "Port of RiskyMod's number of pillars, simply how many pillars you have to charge before the launchpads get enabled -- it is recommended all players have a consistent pillar requirement");
			GauntletSize = (