Decompiled source of ExpansionManager v1.2.2

plugins/ExpansionManager.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates.HallowedCauldron;
using EntityStates.TeleporterCatastrophe.DLC4.Teleporter;
using ExpansionManager.Util;
using HG;
using HG.Reflection;
using IL.RoR2;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.EntityStates.HallowedCauldron;
using On.EntityStates.TeleporterCatastrophe.DLC4.Teleporter;
using On.RoR2;
using On.RoR2.UI;
using RoR2;
using RoR2.ContentManagement;
using RoR2.ExpansionManagement;
using RoR2.UI;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;
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: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.2.0")]
[module: RefSafetyRules(11)]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ExpansionManager
{
	public static class ExpansionManagerAssets
	{
		public static string assetsPath;

		private static AssetBundleCreateRequest assetBundleCreateRequest;

		private static AssetBundle assetBundle;

		public static AssetBundle Bundle
		{
			get
			{
				if (!Object.op_Implicit((Object)(object)assetBundle))
				{
					AssetBundleCreateRequest obj = assetBundleCreateRequest;
					assetBundle = ((obj != null) ? obj.assetBundle : null);
				}
				return assetBundle;
			}
		}

		public static void ModInit()
		{
			assetBundleCreateRequest = AssetBundle.LoadFromFileAsync(assetsPath);
		}
	}
	[BepInPlugin("groovesalad.ExpansionManager", "ExpansionManager", "1.2.2")]
	public class ExpansionManagerPlugin : BaseUnityPlugin
	{
		public const string GUID = "groovesalad.ExpansionManager";

		public const string NAME = "ExpansionManager";

		public const string VERSION = "1.2.2";

		public static ManualLogSource Logger { get; private set; }

		protected void Awake()
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			ExpansionManagerAssets.assetsPath = Path.Combine(directoryName, "AssetBundles", "expansionmanagerassets.bundle");
			ExpansionManagerAssets.ModInit();
			Language.collectLanguageRootFolders += delegate(List<string> list)
			{
				list.Add(Path.Combine(directoryName, "Language"));
			};
			RuleDef.FromExpansion += new hook_FromExpansion(ConfigureHiddenExpansions);
			ExpansionRulesCatalog.ModInit();
			ExpansionManagerUI.ModInit();
		}

		private RuleDef ConfigureHiddenExpansions(orig_FromExpansion orig, ExpansionDef expansion)
		{
			RuleDef val = orig.Invoke(expansion);
			IEnumerable<char> values = Language.GetString(expansion.nameToken).Where(delegate(char letter)
			{
				bool flag;
				switch (letter)
				{
				case '\t':
				case '\n':
				case '"':
				case '\'':
				case '=':
				case '[':
				case '\\':
				case ']':
					flag = true;
					break;
				default:
					flag = false;
					break;
				}
				return !flag;
			});
			val.hideLobbyDisplay = ((BaseUnityPlugin)this).Config.Bind<bool>("Hide Expansion", string.Join("", values), val.hideLobbyDisplay, (ConfigDescription)null).Value;
			return val;
		}
	}
	public static class ExpansionManagerUI
	{
		public class FadedOutMeshEffect : BaseMeshEffect
		{
			public Color color = new Color(1f, 1f, 1f, 0f);

			public override void ModifyMesh(VertexHelper vh)
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_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)
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				if (!((UIBehaviour)this).IsActive())
				{
					return;
				}
				UIVertex val = default(UIVertex);
				for (int i = 0; i < vh.currentVertCount; i++)
				{
					vh.PopulateUIVertex(ref val, i);
					if (val.position.y > 0f && val.position.x > 0f)
					{
						val.color = Color32.op_Implicit(color);
						vh.SetUIVertex(val, i);
					}
				}
			}
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static hook_SetChoice <0>__RuleChoiceController_SetChoice;

			public static hook_UpdateChoiceDisplay <1>__RuleChoiceController_UpdateChoiceDisplay;

			public static hook_SetData <2>__RuleCategoryController_SetData;
		}

		private const string EXPANSIONS_DISPLAY_TOKEN = "RULE_HEADER_EXPANSIONS";

		public static Sprite texUIHeaderSharp;

		public static void ModInit()
		{
			//IL_0010: 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: Expected O, but got Unknown
			//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_003b: Expected O, but got Unknown
			//IL_0050: 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_005b: Expected O, but got Unknown
			object obj = <>O.<0>__RuleChoiceController_SetChoice;
			if (obj == null)
			{
				hook_SetChoice val = RuleChoiceController_SetChoice;
				<>O.<0>__RuleChoiceController_SetChoice = val;
				obj = (object)val;
			}
			RuleChoiceController.SetChoice += (hook_SetChoice)obj;
			object obj2 = <>O.<1>__RuleChoiceController_UpdateChoiceDisplay;
			if (obj2 == null)
			{
				hook_UpdateChoiceDisplay val2 = RuleChoiceController_UpdateChoiceDisplay;
				<>O.<1>__RuleChoiceController_UpdateChoiceDisplay = val2;
				obj2 = (object)val2;
			}
			RuleChoiceController.UpdateChoiceDisplay += (hook_UpdateChoiceDisplay)obj2;
			object obj3 = <>O.<2>__RuleCategoryController_SetData;
			if (obj3 == null)
			{
				hook_SetData val3 = RuleCategoryController_SetData;
				<>O.<2>__RuleCategoryController_SetData = val3;
				obj3 = (object)val3;
			}
			RuleCategoryController.SetData += (hook_SetData)obj3;
		}

		[SystemInitializer(new Type[] { })]
		private static IEnumerator Init()
		{
			AssetBundleRequest load_texUIHeaderSharp = ExpansionManagerAssets.Bundle.LoadAssetAsync<Sprite>("texUIHeaderSharp");
			while (!((AsyncOperation)load_texUIHeaderSharp).isDone)
			{
				yield return null;
			}
			texUIHeaderSharp = (Sprite)load_texUIHeaderSharp.asset;
		}

		private static void RuleChoiceController_SetChoice(orig_SetChoice orig, RuleChoiceController self, RuleChoiceDef newChoiceDef)
		{
			if (self.choiceDef?.extraData is ExpansionDef && !(newChoiceDef?.extraData is ExpansionDef))
			{
				self.tooltipProvider.overrideBodyText = null;
				Transform val = ((Component)self).transform.Find("NotificationIcon");
				if (Object.op_Implicit((Object)(object)val))
				{
					((Component)val).gameObject.SetActive(false);
				}
				if (Object.op_Implicit((Object)(object)self.image))
				{
					FadedOutMeshEffect component = ((Component)self.image).gameObject.GetComponent<FadedOutMeshEffect>();
					if (Object.op_Implicit((Object)(object)component))
					{
						((Behaviour)component).enabled = false;
					}
				}
			}
			orig.Invoke(self, newChoiceDef);
		}

		private static void RuleChoiceController_UpdateChoiceDisplay(orig_UpdateChoiceDisplay orig, RuleChoiceController self, RuleChoiceDef displayChoiceDef)
		{
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0405: Unknown result type (might be due to invalid IL or missing references)
			//IL_040a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0426: Unknown result type (might be due to invalid IL or missing references)
			//IL_043f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0487: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_062f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0634: Unknown result type (might be due to invalid IL or missing references)
			//IL_0649: Unknown result type (might be due to invalid IL or missing references)
			//IL_064e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0672: Unknown result type (might be due to invalid IL or missing references)
			//IL_0677: Unknown result type (might be due to invalid IL or missing references)
			//IL_0693: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a7: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, displayChoiceDef);
			if (displayChoiceDef.extraData is ExpansionRulesCatalog.ExpansionContentRule { expansionDef: var expansionDef } expansionContentRule)
			{
				if (Object.op_Implicit((Object)(object)self.image))
				{
					Transform val = ((Component)self.image).transform.parent.Find("SubIcon");
					AsyncImage val2 = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<AsyncImage>() : null);
					if (!Object.op_Implicit((Object)(object)val2))
					{
						val2 = new GameObject("SubIcon", new Type[3]
						{
							typeof(RectTransform),
							typeof(CanvasRenderer),
							typeof(AsyncImage)
						}).GetComponent<AsyncImage>();
						((Component)val2).transform.SetParent(((Component)self.image).transform.parent, false);
						Transform val3 = ((Component)val2).transform.parent.Find("HoverOutline");
						if (Object.op_Implicit((Object)(object)val3))
						{
							((Component)val2).transform.SetSiblingIndex(((Component)val3).transform.GetSiblingIndex());
						}
						((Component)val2).gameObject.layer = LayerIndex.ui.intVal;
						RectTransform component = ((Component)val2).GetComponent<RectTransform>();
						component.sizeDelta = new Vector2(32f, 32f);
						((Transform)component).localPosition = new Vector3(-20f, 20f);
					}
					AssetReferenceT<Sprite> val4 = expansionDef.disabledIconSpriteReference;
					Sprite val5 = expansionDef.disabledIconSprite;
					if (expansionContentRule.enabled)
					{
						val5 = expansionDef.iconSprite;
						val4 = expansionDef.iconSpriteReference;
					}
					((AsyncViewable<Sprite, Image>)(object)val2).SetAssetOrDirectReference(val4, val5);
				}
				{
					foreach (RuleChoiceController instances in RuleChoiceController.instancesList)
					{
						if (instances.choiceDef != null && (Object)/*isinst with value type is only supported in some contexts*/ == (Object)(object)expansionDef)
						{
							instances.UpdateChoiceDisplay(instances.choiceDef);
						}
					}
					return;
				}
			}
			object extraData = displayChoiceDef.extraData;
			ExpansionDef val6 = (ExpansionDef)((extraData is ExpansionDef) ? extraData : null);
			if (val6 == null || !ExpansionRulesCatalog.expansionByRuleCategory.TryGetValue(val6.expansionIndex, out var value))
			{
				return;
			}
			if (Object.op_Implicit((Object)(object)PreGameController.instance) && Object.op_Implicit((Object)(object)self.tooltipProvider) && value.children.Count > 0)
			{
				self.tooltipProvider.overrideBodyText = null;
				string bodyText = self.tooltipProvider.bodyText;
				bodyText += "\n";
				foreach (RuleDef item in value.children.OrderByDescending((RuleDef x) => PreGameController.instance.readOnlyRuleBook.GetRuleChoiceIndex(x) == x.defaultChoiceIndex))
				{
					RuleChoiceDef ruleChoice = PreGameController.instance.readOnlyRuleBook.GetRuleChoice(item);
					if (ruleChoice != null)
					{
						bodyText += Language.GetStringFormatted("EXPANSION_CONTENT_" + ruleChoice.localName.ToUpperInvariant(), new object[1] { ruleChoice.getTooltipName(ruleChoice) });
					}
				}
				self.tooltipProvider.overrideBodyText = bodyText;
			}
			if (!Object.op_Implicit((Object)(object)((Component)self).GetComponentInParent<RuleCategoryController>()))
			{
				return;
			}
			Transform val7 = ((Component)self).transform.Find("BaseOutline");
			Image val8 = (Object.op_Implicit((Object)(object)val7) ? ((Component)val7).GetComponent<Image>() : null);
			Transform val9 = ((Component)self).transform.Find("HoverOutline");
			Image val10 = (Object.op_Implicit((Object)(object)val9) ? ((Component)val9).GetComponent<Image>() : null);
			if (!Object.op_Implicit((Object)(object)val8))
			{
				val8 = new GameObject("BaseOutline", new Type[3]
				{
					typeof(RectTransform),
					typeof(CanvasRenderer),
					typeof(Image)
				}).GetComponent<Image>();
				((Component)val8).transform.SetParent(((Component)self).transform, false);
				((Component)val8).gameObject.layer = LayerIndex.ui.intVal;
				val8.sprite = texUIHeaderSharp;
				((Graphic)val8).color = Color32.op_Implicit(new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)30));
				RectTransform component2 = ((Component)val8).GetComponent<RectTransform>();
				component2.sizeDelta = new Vector2(48f, 8f);
				((Transform)component2).localPosition = new Vector3(0f, -30f, 0f);
			}
			if (!Object.op_Implicit((Object)(object)val10))
			{
				val10 = new GameObject("HoverOutline", new Type[3]
				{
					typeof(RectTransform),
					typeof(CanvasRenderer),
					typeof(Image)
				}).GetComponent<Image>();
				((Component)val10).transform.SetParent(((Component)self).transform, false);
				((Component)val10).gameObject.layer = LayerIndex.ui.intVal;
				val10.sprite = texUIHeaderSharp;
				((Graphic)val10).color = Color.white;
				RectTransform component3 = ((Component)val10).GetComponent<RectTransform>();
				component3.sizeDelta = new Vector2(48f, 8f);
				((Transform)component3).localPosition = new Vector3(0f, -32f, 0f);
			}
			if (Object.op_Implicit((Object)(object)self.hgButton))
			{
				self.hgButton.showImageOnHover = true;
				self.hgButton.imageOnInteractable = val8;
				self.hgButton.imageOnHover = val10;
			}
			Transform val11 = ((Component)self).transform.Find("NotificationIcon");
			Image val12 = (Object.op_Implicit((Object)(object)val11) ? ((Component)val11).GetComponent<Image>() : null);
			bool flag = false;
			if (Object.op_Implicit((Object)(object)PreGameController.instance) && value.children.Count > 0)
			{
				flag = value.children.Any((RuleDef x) => PreGameController.instance.readOnlyRuleBook.GetRuleChoiceIndex(x) != x.defaultChoiceIndex);
			}
			if (flag && !Object.op_Implicit((Object)(object)val12))
			{
				val12 = new GameObject("NotificationIcon", new Type[3]
				{
					typeof(RectTransform),
					typeof(CanvasRenderer),
					typeof(Image)
				}).GetComponent<Image>();
				((Component)val12).transform.SetParent(((Component)self).transform, false);
				((Component)val12).gameObject.layer = LayerIndex.ui.intVal;
				val12.sprite = Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/UI/texPlayerVoteStatus.png").WaitForCompletion();
				((Graphic)val12).material = Addressables.LoadAssetAsync<Material>((object)"RoR2/Base/UI/matUIOverbrighten2x.mat").WaitForCompletion();
				((Graphic)val12).color = Color32.op_Implicit(new Color32((byte)235, (byte)235, (byte)235, (byte)200));
				RectTransform component4 = ((Component)val12).GetComponent<RectTransform>();
				component4.sizeDelta = new Vector2(20f, 30f);
				((Transform)component4).localPosition = new Vector3(16f, 16f);
			}
			if (Object.op_Implicit((Object)(object)val12))
			{
				((Component)val12).gameObject.SetActive(flag);
			}
			if (Object.op_Implicit((Object)(object)self.image))
			{
				FadedOutMeshEffect fadedOutMeshEffect = ((Component)self.image).gameObject.GetComponent<FadedOutMeshEffect>();
				if (flag && !Object.op_Implicit((Object)(object)fadedOutMeshEffect))
				{
					fadedOutMeshEffect = ((Component)self.image).gameObject.AddComponent<FadedOutMeshEffect>();
				}
				if (Object.op_Implicit((Object)(object)fadedOutMeshEffect))
				{
					((Behaviour)fadedOutMeshEffect).enabled = flag;
				}
			}
		}

		private static void RuleCategoryController_SetData(orig_SetData orig, RuleCategoryController self, RuleCategoryDef categoryDef, RuleChoiceMask availability, RuleBook ruleBook)
		{
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Expected O, but got Unknown
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Expected O, but got Unknown
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Expected O, but got Unknown
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Expected O, but got Unknown
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, categoryDef, availability, ruleBook);
			if (ExpansionRulesCatalog.ruleCategoryByExpansion.TryGetValue(categoryDef, out var expansionDef))
			{
				if (Object.op_Implicit((Object)(object)self.popoutPanelInstance))
				{
					self.popoutPanelInstance.popoutPanelDescriptionText.formatArgs = new object[1] { Language.GetString(expansionDef.nameToken) };
				}
				if (self.rulesToDisplay != null && self.popoutButtonIconAllocator?.elements != null)
				{
					for (int i = 0; i < self.rulesToDisplay.Count; i++)
					{
						self.popoutButtonIconAllocator.elements[i].UpdateFromVotes();
					}
				}
				RuleBookViewer componentInParent = ((Component)self).GetComponentInParent<RuleBookViewer>();
				if (Object.op_Implicit((Object)(object)componentInParent) && componentInParent.categoryElementAllocator != null)
				{
					RuleCategoryController val = componentInParent.categoryElementAllocator?.elements?.FirstOrDefault((Func<RuleCategoryController, bool>)((RuleCategoryController x) => x.currentCategory != null && x.currentCategory.displayToken == "RULE_HEADER_EXPANSIONS"));
					if (Object.op_Implicit((Object)(object)val) && val.rulesToDisplay != null)
					{
						int num = val.rulesToDisplay.FindIndex(delegate(RuleDef x)
						{
							object extraData = x.choices[x.defaultChoiceIndex].extraData;
							return (Object)((extraData is ExpansionDef) ? extraData : null) == (Object)(object)expansionDef;
						});
						if (num >= 0)
						{
							RuleChoiceController val2 = val.voteResultIconAllocator?.elements?[num];
							HGButton val3 = default(HGButton);
							if (Object.op_Implicit((Object)(object)val2) && ((Component)val2).TryGetComponent<HGButton>(ref val3))
							{
								((UnityEvent)((Button)val3).onClick).RemoveListener(new UnityAction(self.TogglePopoutPanel));
								((UnityEvent)((Button)val3).onClick).AddListener(new UnityAction(self.TogglePopoutPanel));
								((MPButton)val3).allowAllEventSystems = true;
								((MPButton)val3).submitOnPointerUp = true;
								((MPButton)val3).selectOnPointerEnter = true;
								((MPButton)val3).disablePointerClick = false;
								((MPButton)val3).disableGamepadClick = false;
								((MPButton)val3).defaultFallbackButton = true;
								HGButton obj = val3;
								Navigation navigation = default(Navigation);
								((Navigation)(ref navigation)).mode = (Mode)3;
								((Selectable)obj).navigation = navigation;
							}
						}
					}
				}
				GameObject val4 = new GameObject();
				val4.transform.SetParent(((Component)self).transform.parent, false);
				((Component)self).transform.SetParent(val4.transform);
				val4.SetActive(false);
			}
			else if (categoryDef.displayToken == "RULE_HEADER_EXPANSIONS")
			{
				GridLayoutGroup val5 = (Object.op_Implicit((Object)(object)self.voteResultGridContainer) ? ((Component)self.voteResultGridContainer).GetComponent<GridLayoutGroup>() : null);
				if (Object.op_Implicit((Object)(object)val5))
				{
					((LayoutGroup)val5).padding = new RectOffset(6, 6, 12, 12);
					val5.spacing = Vector2.zero;
				}
			}
		}
	}
	public static class ExpansionRulesCatalog
	{
		public struct ExpansionContentRule
		{
			public bool enabled;

			public ExpansionDef expansionDef;
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static Manipulator <0>__RuleCatalog_Init;

			public static Action <1>__AddExpansionRules;

			public static Func<bool> <2>__HiddenTestFalse;

			public static Func<RuleChoiceDef, string> <3>__GetOffTooltipNameFromToken;
		}

		public static readonly Dictionary<ExpansionIndex, RuleCategoryDef> expansionByRuleCategory = new Dictionary<ExpansionIndex, RuleCategoryDef>();

		public static readonly Dictionary<RuleCategoryDef, ExpansionDef> ruleCategoryByExpansion = new Dictionary<RuleCategoryDef, ExpansionDef>();

		public static readonly Dictionary<ExpansionIndex, RuleChoiceDef> disableExpansionItemsChoices = new Dictionary<ExpansionIndex, RuleChoiceDef>();

		public static readonly Dictionary<ExpansionIndex, RuleChoiceDef> disableExpansionElitesChoices = new Dictionary<ExpansionIndex, RuleChoiceDef>();

		public static readonly Dictionary<ExpansionIndex, RuleChoiceDef> disableExpansionStagesChoices = new Dictionary<ExpansionIndex, RuleChoiceDef>();

		public static readonly Dictionary<ExpansionIndex, RuleChoiceDef> disableExpansionMonstersChoices = new Dictionary<ExpansionIndex, RuleChoiceDef>();

		public static readonly Dictionary<ExpansionIndex, RuleChoiceDef> disableExpansionInteractablesChoices = new Dictionary<ExpansionIndex, RuleChoiceDef>();

		public static event Action<ExpansionDef, RuleCategoryDef> GenerateRulesForExpansion;

		public static void ModInit()
		{
			//IL_0010: 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: Expected O, but got Unknown
			object obj = <>O.<0>__RuleCatalog_Init;
			if (obj == null)
			{
				Manipulator val = RuleCatalog_Init;
				<>O.<0>__RuleCatalog_Init = val;
				obj = (object)val;
			}
			RuleCatalog.Init += (Manipulator)obj;
		}

		private static void RuleCatalog_Init(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<RuleDef>(x, "FromExpansion")
			}) && val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, typeof(RuleCatalog), "AddCategory")
			}))
			{
				val.EmitDelegate<Action>((Action)AddExpansionRules);
			}
			else
			{
				ExpansionManagerPlugin.Logger.LogError((object)"ExpansionRulesCatalog: RuleCatalog_Init IL match failed");
			}
		}

		private static void AddExpansionRules()
		{
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			Sprite enabledIcon = ExpansionManagerAssets.Bundle.LoadAsset<Sprite>("texRuleExpansionStagesOn");
			Sprite disabledIcon = ExpansionManagerAssets.Bundle.LoadAsset<Sprite>("texRuleExpansionStagesOff");
			Sprite enabledIcon2 = ExpansionManagerAssets.Bundle.LoadAsset<Sprite>("texRuleExpansionInteractablesOn");
			Sprite disabledIcon2 = ExpansionManagerAssets.Bundle.LoadAsset<Sprite>("texRuleExpansionInteractablesOff");
			Sprite enabledIcon3 = ExpansionManagerAssets.Bundle.LoadAsset<Sprite>("texRuleExpansionElitesOn");
			Sprite disabledIcon3 = ExpansionManagerAssets.Bundle.LoadAsset<Sprite>("texRuleExpansionElitesOff");
			Sprite enabledIcon4 = ExpansionManagerAssets.Bundle.LoadAsset<Sprite>("texRuleExpansionMonstersOn");
			Sprite disabledIcon4 = ExpansionManagerAssets.Bundle.LoadAsset<Sprite>("texRuleExpansionMonstersOff");
			Sprite enabledIcon5 = ExpansionManagerAssets.Bundle.LoadAsset<Sprite>("texRuleExpansionItemsOn");
			Sprite disabledIcon5 = ExpansionManagerAssets.Bundle.LoadAsset<Sprite>("texRuleExpansionItemsOff");
			Enumerator<ExpansionDef> enumerator = ExpansionCatalog.expansionDefs.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					ExpansionDef expansionDef = enumerator.Current;
					RuleCategoryDef val = RuleCatalog.AddCategory(expansionDef.nameToken, expansionDef.descriptionToken, Color32.op_Implicit(new Color32((byte)219, (byte)114, (byte)114, byte.MaxValue)), (string)null, "RULE_HEADER_EXPANSIONS_EDIT", (Func<bool>)RuleCatalog.HiddenTestFalse, (RuleCategoryType)1, (GridFormattingOverride)null);
					expansionByRuleCategory[expansionDef.expansionIndex] = val;
					ruleCategoryByExpansion[val] = expansionDef;
					if (Array.Exists(ContentManager.sceneDefs, StageMatchesExpansion))
					{
						RuleCatalog.AddRule(GenerateContentRule(expansionDef, "Stages", enabledIcon, disabledIcon, disableExpansionStagesChoices));
					}
					if (Array.Exists(ContentManager.networkedObjectPrefabs, InteractableMatchesExpansion))
					{
						RuleCatalog.AddRule(GenerateContentRule(expansionDef, "Interactables", enabledIcon2, disabledIcon2, disableExpansionInteractablesChoices));
					}
					if (Array.Exists(ContentManager.eliteDefs, EliteMatchesExpansion))
					{
						RuleCatalog.AddRule(GenerateContentRule(expansionDef, "Elites", enabledIcon3, disabledIcon3, disableExpansionElitesChoices));
					}
					if (Array.Exists(ContentManager.masterPrefabs, MonsterMatchesExpansion))
					{
						RuleCatalog.AddRule(GenerateContentRule(expansionDef, "Monsters", enabledIcon4, disabledIcon4, disableExpansionMonstersChoices));
					}
					if (Array.Exists(ContentManager.itemDefs, ItemMatchesExpansion) || Array.Exists(ContentManager.equipmentDefs, EquipmentMatchesExpansion))
					{
						RuleCatalog.AddRule(GenerateContentRule(expansionDef, "Items", enabledIcon5, disabledIcon5, disableExpansionItemsChoices));
					}
					if (ExpansionRulesCatalog.GenerateRulesForExpansion != null)
					{
						ExpansionRulesCatalog.GenerateRulesForExpansion(expansionDef, val);
						ExpansionRulesCatalog.GenerateRulesForExpansion = null;
					}
					bool EliteMatchesExpansion(EliteDef eliteDef)
					{
						if (Object.op_Implicit((Object)(object)eliteDef.eliteEquipmentDef))
						{
							return (Object)(object)eliteDef.eliteEquipmentDef.requiredExpansion == (Object)(object)expansionDef;
						}
						return false;
					}
					bool EquipmentMatchesExpansion(EquipmentDef equipmentDef)
					{
						if ((Object)(object)equipmentDef.requiredExpansion == (Object)(object)expansionDef)
						{
							return !equipmentDef.IsElite();
						}
						return false;
					}
					bool InteractableMatchesExpansion(GameObject networkedObjectPrefab)
					{
						ExpansionRequirementComponent val2 = default(ExpansionRequirementComponent);
						if (networkedObjectPrefab.TryGetComponent<ExpansionRequirementComponent>(ref val2))
						{
							return (Object)(object)val2.requiredExpansion == (Object)(object)expansionDef;
						}
						return false;
					}
					bool ItemMatchesExpansion(ItemDef itemDef)
					{
						return (Object)(object)itemDef.requiredExpansion == (Object)(object)expansionDef;
					}
					bool MonsterMatchesExpansion(GameObject masterPrefab)
					{
						ExpansionRequirementComponent val2 = default(ExpansionRequirementComponent);
						if (masterPrefab.TryGetComponent<ExpansionRequirementComponent>(ref val2))
						{
							if ((Object)(object)val2.requiredExpansion == (Object)(object)expansionDef)
							{
								return !val2.requireEntitlementIfPlayerControlled;
							}
							return false;
						}
						CharacterMaster val3 = default(CharacterMaster);
						if (masterPrefab.TryGetComponent<CharacterMaster>(ref val3) && Object.op_Implicit((Object)(object)val3.bodyPrefab) && val3.bodyPrefab.TryGetComponent<ExpansionRequirementComponent>(ref val2))
						{
							if ((Object)(object)val2.requiredExpansion == (Object)(object)expansionDef)
							{
								return !val2.requireEntitlementIfPlayerControlled;
							}
							return false;
						}
						return false;
					}
					bool StageMatchesExpansion(SceneDef sceneDef)
					{
						//IL_0016: Unknown result type (might be due to invalid IL or missing references)
						//IL_001b: Unknown result type (might be due to invalid IL or missing references)
						//IL_001c: 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_0020: Invalid comparison between Unknown and I4
						//IL_0022: 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_0026: Invalid comparison between Unknown and I4
						bool flag = (Object)(object)sceneDef.requiredExpansion == (Object)(object)expansionDef;
						if (flag)
						{
							SceneType sceneType = sceneDef.sceneType;
							bool flag2 = ((sceneType - 1 <= 1 || sceneType - 4 <= 1) ? true : false);
							flag = flag2;
						}
						return flag;
					}
				}
			}
			finally
			{
				((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
			}
		}

		public static RuleDef GenerateContentRule(ExpansionDef expansionDef, string contentName, Sprite enabledIcon, Sprite disabledIcon, Dictionary<ExpansionIndex, RuleChoiceDef> disableExpansionContentChoices = null)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Expected O, but got Unknown
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			RuleDef val = new RuleDef("Expansions." + ((Object)expansionDef).name + "." + contentName, expansionDef.nameToken)
			{
				forceLobbyDisplay = true
			};
			string text = "EXPANSION_" + contentName.ToUpperInvariant();
			string text2 = text + "_DESC";
			RuleChoiceDef obj = val.AddChoice("On", (object)new ExpansionContentRule
			{
				enabled = true,
				expansionDef = expansionDef
			}, false);
			obj.sprite = enabledIcon;
			obj.tooltipNameToken = text;
			obj.tooltipNameColor = Color32.op_Implicit(new Color32((byte)219, (byte)114, (byte)114, byte.MaxValue));
			obj.tooltipBodyToken = text2;
			obj.requiredEntitlementDef = expansionDef.requiredEntitlement;
			obj.requiredExpansionDef = expansionDef;
			val.MakeNewestChoiceDefault();
			RuleChoiceDef val2 = val.AddChoice("Off", (object)new ExpansionContentRule
			{
				enabled = false,
				expansionDef = expansionDef
			}, false);
			val2.sprite = disabledIcon;
			val2.tooltipNameToken = text;
			val2.tooltipNameColor = Color32.op_Implicit(ColorCatalog.GetColor((ColorIndex)10));
			val2.getTooltipName = RuleChoiceDef.GetOffTooltipNameFromToken;
			val2.tooltipBodyToken = text2 + "_OFF";
			if (disableExpansionContentChoices != null)
			{
				disableExpansionContentChoices[expansionDef.expansionIndex] = val2;
			}
			return val;
		}

		public static bool IsExpansionContentDisabled(RuleBook ruleBook, ExpansionDef expansionDef, Dictionary<ExpansionIndex, RuleChoiceDef> disableExpansionContentChoices)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)expansionDef) && disableExpansionContentChoices.TryGetValue(expansionDef.expansionIndex, out var value))
			{
				return ruleBook.IsChoiceActive(value);
			}
			return false;
		}

		public static bool AreExpansionItemsDisabled(this Run run, ExpansionDef expansionDef)
		{
			return IsExpansionContentDisabled(run.ruleBook, expansionDef, disableExpansionItemsChoices);
		}

		public static bool AreExpansionElitesDisabled(this Run run, ExpansionDef expansionDef)
		{
			return IsExpansionContentDisabled(run.ruleBook, expansionDef, disableExpansionElitesChoices);
		}

		public static bool AreExpansionStagesDisabled(this Run run, ExpansionDef expansionDef)
		{
			return IsExpansionContentDisabled(run.ruleBook, expansionDef, disableExpansionStagesChoices);
		}

		public static bool AreExpansionMonstersDisabled(this Run run, ExpansionDef expansionDef)
		{
			return IsExpansionContentDisabled(run.ruleBook, expansionDef, disableExpansionMonstersChoices);
		}

		public static bool AreExpansionInteractablesDisabled(this Run run, ExpansionDef expansionDef)
		{
			return IsExpansionContentDisabled(run.ruleBook, expansionDef, disableExpansionInteractablesChoices);
		}
	}
}
namespace ExpansionManager.Util
{
	public static class EquipmentUtil
	{
		public static bool IsElite(this EquipmentDef equipmentDef)
		{
			if (Object.op_Implicit((Object)(object)equipmentDef.passiveBuffDef))
			{
				return equipmentDef.passiveBuffDef.isElite;
			}
			return false;
		}
	}
	public static class PickupUtil
	{
		public static ExpansionDef GetRequiredExpansion(this PickupDef pickupDef)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Invalid comparison between Unknown and I4
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Invalid comparison between Unknown and I4
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			ExpansionDef result = null;
			if ((int)pickupDef.itemIndex != -1)
			{
				ItemDef itemDef = ItemCatalog.GetItemDef(pickupDef.itemIndex);
				if (Object.op_Implicit((Object)(object)itemDef))
				{
					result = itemDef.requiredExpansion;
				}
			}
			else if ((int)pickupDef.equipmentIndex != -1)
			{
				EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(pickupDef.equipmentIndex);
				if (Object.op_Implicit((Object)(object)equipmentDef))
				{
					result = equipmentDef.requiredExpansion;
				}
			}
			else if ((int)pickupDef.artifactIndex != -1)
			{
				ArtifactDef artifactDef = ArtifactCatalog.GetArtifactDef(pickupDef.artifactIndex);
				if (Object.op_Implicit((Object)(object)artifactDef))
				{
					result = artifactDef.requiredExpansion;
				}
			}
			return result;
		}
	}
}
namespace ExpansionManager.Fixes
{
	public static class AlternatePathEncounter
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_OverrideCurrentMonsterCard <0>__CombatDirector_OverrideCurrentMonsterCard;

			public static hook_OverrideBossFight <1>__SolusFight_OverrideBossFight;
		}

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

			public static orig_OverrideCurrentMonsterCard <>9__2_0;

			internal void <SolusFight_OverrideBossFight>b__2_0(CombatDirector combatDirector, DirectorCard overrideMonsterCard)
			{
				combatDirector.OverrideNextBossCard(overrideMonsterCard, false);
			}
		}

		[SystemInitializer(new Type[] { })]
		private static void Init()
		{
			//IL_0010: 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: Expected O, but got Unknown
			//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_003b: Expected O, but got Unknown
			object obj = <>O.<0>__CombatDirector_OverrideCurrentMonsterCard;
			if (obj == null)
			{
				hook_OverrideCurrentMonsterCard val = CombatDirector_OverrideCurrentMonsterCard;
				<>O.<0>__CombatDirector_OverrideCurrentMonsterCard = val;
				obj = (object)val;
			}
			CombatDirector.OverrideCurrentMonsterCard += (hook_OverrideCurrentMonsterCard)obj;
			object obj2 = <>O.<1>__SolusFight_OverrideBossFight;
			if (obj2 == null)
			{
				hook_OverrideBossFight val2 = SolusFight_OverrideBossFight;
				<>O.<1>__SolusFight_OverrideBossFight = val2;
				obj2 = (object)val2;
			}
			SolusFight.OverrideBossFight += (hook_OverrideBossFight)obj2;
		}

		private static void CombatDirector_OverrideCurrentMonsterCard(orig_OverrideCurrentMonsterCard orig, CombatDirector self, DirectorCard overrideMonsterCard)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			if (overrideMonsterCard != null && !overrideMonsterCard.IsAvailable() && Object.op_Implicit((Object)(object)overrideMonsterCard.spawnCard) && self.finalMonsterCardsSelection != null)
			{
				WeightedSelection<DirectorCard> val = new WeightedSelection<DirectorCard>(8);
				for (int i = 0; i < self.finalMonsterCardsSelection.Count; i++)
				{
					ChoiceInfo<DirectorCard> choice = self.finalMonsterCardsSelection.GetChoice(i);
					if (choice.value != null && choice.value.IsAvailable() && choice.value.cost <= overrideMonsterCard.cost && choice.value.cost * 5 >= overrideMonsterCard.cost)
					{
						choice.weight *= choice.value.cost;
						val.AddChoice(choice);
					}
				}
				if (val.Count > 0)
				{
					overrideMonsterCard = val.Evaluate(self.rng.nextNormalizedFloat);
				}
			}
			orig.Invoke(self, overrideMonsterCard);
		}

		private static void SolusFight_OverrideBossFight(orig_OverrideBossFight orig, SolusFight self)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			orig.Invoke(self);
			object obj = <>c.<>9__2_0;
			if (obj == null)
			{
				orig_OverrideCurrentMonsterCard val = delegate(CombatDirector combatDirector, DirectorCard overrideMonsterCard)
				{
					combatDirector.OverrideNextBossCard(overrideMonsterCard, false);
				};
				<>c.<>9__2_0 = val;
				obj = (object)val;
			}
			CombatDirector_OverrideCurrentMonsterCard((orig_OverrideCurrentMonsterCard)obj, TeleporterInteraction.instance.companionBoss, self.ForcedBossFight);
		}
	}
	public static class DeadDccsAdditions
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_MergeCategories <0>__DCCSBlender_MergeCategories;

			public static hook_Awake <1>__CombatDirector_Awake;

			public static orig_MergeCategories <2>__none;
		}

		private const string CHAMPIONS = "Champions";

		private const string MINIBOSSES = "Minibosses";

		private const string BASIC_MONSTERS = "Basic Monsters";

		private const string SPECIAL = "Special";

		public static readonly Dictionary<string, Action<DirectorCardCategorySelection>> monsterSelectionAdditions = new Dictionary<string, Action<DirectorCardCategorySelection>>
		{
			{ "dccsAncientLoftMonstersDLC1", AncientLoftMonstersDLC1 },
			{ "dccsSulfurPoolsMonstersDLC1", SulfurPoolsMonstersDLC1 },
			{ "dccsIronalluviumMonsters", IronAlluviumMonsters },
			{ "dccsIronalluvium2MonstersDLC2", Ironalluvium2MonstersDLC2 },
			{ "dccsRepurposedcraterMonstersDLC1", RepurposedCraterMonstersDLC1 },
			{ "dccsConduitcanyonMonsters", ConduitCanyonMonsters },
			{ "dccsBallFamily_ItemThemed", BallFamily_ItemThemed },
			{ "dccsFungalMonsters", FungalMonsters },
			{ "dccsMireMonsters", MireMonsters }
		};

		public static AsyncOperationHandle<SpawnCard> cscBell = Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/Base/Bell/cscBell.asset");

		public static AsyncOperationHandle<SpawnCard> cscLesserWisp = Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/Base/Wisp/cscLesserWisp.asset");

		public static AsyncOperationHandle<SpawnCard> cscMagmaWorm = Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/Base/MagmaWorm/cscMagmaWorm.asset");

		public static AsyncOperationHandle<SpawnCard> cscHermitCrab = Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/Base/HermitCrab/cscHermitCrab.asset");

		public static AsyncOperationHandle<SpawnCard> cscLemurian = Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/Base/Lemurian/cscLemurian.asset");

		public static AsyncOperationHandle<SpawnCard> cscVulture = Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/Base/Vulture/cscVulture.asset");

		public static AsyncOperationHandle<SpawnCard> cscRoboBallMini = Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/Base/RoboBallBoss/cscRoboBallMini.asset");

		public static AsyncOperationHandle<SpawnCard> cscChild = Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/DLC2/Child/cscChild.asset");

		public static AsyncOperationHandle<SpawnCard> cscMinorConstruct = Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/DLC1/MajorAndMinorConstruct/cscMinorConstruct.asset");

		public static AsyncOperationHandle<SpawnCard> cscMiniMushroom = Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/Base/MiniMushroom/cscMiniMushroom.asset");

		public static AsyncOperationHandle<SpawnCard> cscImp = Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/Base/Imp/cscImp.asset");

		public static AsyncOperationHandle<SpawnCard> cscRoboBallBoss = Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/Base/RoboBallBoss/cscRoboBallBoss.asset");

		public static AsyncOperationHandle<SpawnCard> cscBeetleQueen = Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/Base/BeetleQueen/cscBeetleQueen.asset");

		public static AsyncOperationHandle<SpawnCard> cscClayGrenadier = Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/DLC1/ClayGrenadier/cscClayGrenadier.asset");

		public static AsyncOperationHandle<SpawnCard> cscTitanBlackBeach = Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/Base/Titan/cscTitanBlackBeach.asset");

		public static AsyncOperationHandle<SpawnCard> cscVagrant = Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/Base/Vagrant/cscVagrant.asset");

		public static void AncientLoftMonstersDLC1(DirectorCardCategorySelection dccs)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_002e: 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_0043: 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_0056: Expected O, but got Unknown
			dccs.AttemptAddCard("Minibosses", new DirectorCard
			{
				spawnCard = cscBell.WaitForCompletion(),
				selectionWeight = 1
			});
			dccs.AttemptAddCard("Basic Monsters", new DirectorCard
			{
				spawnCard = cscLesserWisp.WaitForCompletion(),
				selectionWeight = 1,
				preventOverhead = true
			});
		}

		public static void SulfurPoolsMonstersDLC1(DirectorCardCategorySelection dccs)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_002e: 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_0043: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: 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_007e: Expected O, but got Unknown
			dccs.AttemptAddCard("Champions", new DirectorCard
			{
				spawnCard = cscMagmaWorm.WaitForCompletion(),
				selectionWeight = 1
			});
			dccs.AttemptAddCard("Basic Monsters", new DirectorCard
			{
				spawnCard = cscHermitCrab.WaitForCompletion(),
				selectionWeight = 1,
				spawnDistance = (MonsterSpawnDistance)2
			});
			dccs.AttemptAddCard("Basic Monsters", new DirectorCard
			{
				spawnCard = cscLemurian.WaitForCompletion(),
				selectionWeight = 1
			});
			dccs.SetCategoryWeight("Basic Monsters", 2);
		}

		public static void IronAlluviumMonsters(DirectorCardCategorySelection dccs)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			dccs.AttemptAddCard("Basic Monsters", new DirectorCard
			{
				spawnCard = cscRoboBallMini.WaitForCompletion(),
				selectionWeight = 1,
				spawnDistance = (MonsterSpawnDistance)2
			});
			dccs.AttemptAddCard("Basic Monsters", new DirectorCard
			{
				spawnCard = cscVulture.WaitForCompletion(),
				selectionWeight = 1
			});
			dccs.SetCategoryWeight("Basic Monsters", 2);
		}

		public static void Ironalluvium2MonstersDLC2(DirectorCardCategorySelection dccs)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			dccs.AttemptAddCard("Basic Monsters", new DirectorCard
			{
				spawnCard = cscChild.WaitForCompletion(),
				selectionWeight = 1
			});
			dccs.SetCategoryWeight("Basic Monsters", 2);
		}

		public static void RepurposedCraterMonstersDLC1(DirectorCardCategorySelection dccs)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			dccs.AttemptAddCard("Basic Monsters", new DirectorCard
			{
				spawnCard = cscMinorConstruct.WaitForCompletion(),
				selectionWeight = 4,
				preventOverhead = true
			});
		}

		public static void ConduitCanyonMonsters(DirectorCardCategorySelection dccs)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			dccs.AttemptAddCard("Basic Monsters", new DirectorCard
			{
				spawnCard = cscMiniMushroom.WaitForCompletion(),
				selectionWeight = 10
			});
			dccs.AttemptAddCard("Basic Monsters", new DirectorCard
			{
				spawnCard = cscImp.WaitForCompletion(),
				selectionWeight = 10
			});
		}

		public static void BallFamily_ItemThemed(DirectorCardCategorySelection dccs)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_002e: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			dccs.AttemptAddCard("Champions", new DirectorCard
			{
				spawnCard = cscRoboBallBoss.WaitForCompletion(),
				selectionWeight = 1
			});
			dccs.AttemptAddCard("Basic Monsters", new DirectorCard
			{
				spawnCard = cscRoboBallMini.WaitForCompletion(),
				selectionWeight = 1
			});
		}

		public static void FungalMonsters(DirectorCardCategorySelection dccs)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_002e: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			dccs.AttemptAddCard("Champions", new DirectorCard
			{
				spawnCard = cscBeetleQueen.WaitForCompletion(),
				selectionWeight = 1
			});
			dccs.AttemptAddCard("Minibosses", new DirectorCard
			{
				spawnCard = cscClayGrenadier.WaitForCompletion(),
				selectionWeight = 1
			});
		}

		public static void MireMonsters(DirectorCardCategorySelection dccs)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_002e: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_0056: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			dccs.AttemptAddCard("Champions", new DirectorCard
			{
				spawnCard = cscTitanBlackBeach.WaitForCompletion(),
				selectionWeight = 1
			});
			dccs.AttemptAddCard("Champions", new DirectorCard
			{
				spawnCard = cscVagrant.WaitForCompletion(),
				selectionWeight = 1
			});
			dccs.AttemptAddCard("Basic Monsters", new DirectorCard
			{
				spawnCard = cscLesserWisp.WaitForCompletion(),
				selectionWeight = 1
			});
		}

		public static bool AttemptAddCard(this DirectorCardCategorySelection dccs, string categoryName, DirectorCard card)
		{
			int num = dccs.FindCategoryIndexByName(categoryName);
			if (ArrayUtils.IsInBounds<Category>(dccs.categories, num))
			{
				dccs.AddCard(num, card);
				return true;
			}
			return false;
		}

		public static void SetCategoryWeight(this DirectorCardCategorySelection dccs, string categoryName, int categoryWeight)
		{
			int num = dccs.FindCategoryIndexByName(categoryName);
			if (ArrayUtils.IsInBounds<Category>(dccs.categories, num))
			{
				dccs.categories[num].selectionWeight = categoryWeight;
			}
		}

		[SystemInitializer(new Type[] { })]
		private static void Init()
		{
			//IL_0010: 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: Expected O, but got Unknown
			//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_003b: Expected O, but got Unknown
			object obj = <>O.<0>__DCCSBlender_MergeCategories;
			if (obj == null)
			{
				hook_MergeCategories val = DCCSBlender_MergeCategories;
				<>O.<0>__DCCSBlender_MergeCategories = val;
				obj = (object)val;
			}
			DCCSBlender.MergeCategories += (hook_MergeCategories)obj;
			object obj2 = <>O.<1>__CombatDirector_Awake;
			if (obj2 == null)
			{
				hook_Awake val2 = CombatDirector_Awake;
				<>O.<1>__CombatDirector_Awake = val2;
				obj2 = (object)val2;
			}
			CombatDirector.Awake += (hook_Awake)obj2;
		}

		private static void DCCSBlender_MergeCategories(orig_MergeCategories orig, ref DirectorCardCategorySelection blendedDCCS, List<ChoiceInfo<DirectorCardCategorySelection>> selectedDCCSList)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(ref blendedDCCS, selectedDCCSList);
			foreach (ChoiceInfo<DirectorCardCategorySelection> selectedDCCS in selectedDCCSList)
			{
				string text = ((Object)selectedDCCS.value).name;
				if (text.EndsWith("(Clone)"))
				{
					text = text.Remove(text.Length - 7);
				}
				if (monsterSelectionAdditions.TryGetValue(text, out var value))
				{
					SceneDef val = (Object.op_Implicit((Object)(object)SceneInfo.instance) ? SceneInfo.instance.sceneDef : null);
					ExpansionDef val2 = (Object.op_Implicit((Object)(object)val) ? val.requiredExpansion : null);
					if (Object.op_Implicit((Object)(object)val2) && Run.instance.AreExpansionMonstersDisabled(val2))
					{
						ExpansionManagerPlugin.Logger.LogInfo((object)("DeadDccsAdditions: " + ((Object)val2).name + " has monsters disabled, Adding monster cards to " + text));
						value(blendedDCCS);
					}
				}
			}
		}

		private static void CombatDirector_Awake(orig_Awake orig, CombatDirector self)
		{
			//IL_0036: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			orig.Invoke(self);
			if (NetworkServer.active && Object.op_Implicit((Object)(object)self.monsterCards))
			{
				DirectorCardCategorySelection blendedDCCS = ScriptableObject.CreateInstance<DirectorCardCategorySelection>();
				blendedDCCS.CopyFrom(self.monsterCards);
				List<ChoiceInfo<DirectorCardCategorySelection>> selectedDCCSList = new List<ChoiceInfo<DirectorCardCategorySelection>>(1)
				{
					new ChoiceInfo<DirectorCardCategorySelection>
					{
						value = self.monsterCards,
						weight = 1f
					}
				};
				object obj = <>O.<2>__none;
				if (obj == null)
				{
					orig_MergeCategories val = none;
					<>O.<2>__none = val;
					obj = (object)val;
				}
				DCCSBlender_MergeCategories((orig_MergeCategories)obj, ref blendedDCCS, selectedDCCSList);
				self.monsterCardsSelection = blendedDCCS.GenerateDirectorCardWeightedSelection();
			}
			static void none(ref DirectorCardCategorySelection reference, List<ChoiceInfo<DirectorCardCategorySelection>> list)
			{
			}
		}
	}
	public static class DropTableFallbacks
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_GeneratePickup <0>__PickupDropTable_GeneratePickup;

			public static hook_GenerateDistinctPickups <1>__PickupDropTable_GenerateDistinctPickups;

			public static hook_GenerateDrop <2>__PickupDropTable_GenerateDrop;

			public static hook_GenerateUniqueDrops <3>__PickupDropTable_GenerateUniqueDrops;

			public static hook_GetDropTable <4>__DrainingItems_GetDropTable;

			public static hook_OnEnter <5>__OverchargingState_OnEnter;
		}

		public static readonly Dictionary<string, string> fallbacksDictionary = new Dictionary<string, string>
		{
			{ "dtVoidChest", "dtChest1" },
			{ "dtShrineHalcyoniteTier1", "dtShrineHalcyoniteTier3" },
			{ "dtShrineHalcyoniteTier2", "dtShrineHalcyoniteTier3" },
			{ "dtCursedItemTable", "dtDuplicatorWild" },
			{ "bdtHallowedCauldron_HighGrade", "dtTier3Item" }
		};

		public static bool DropTableFallback(PickupDropTable dropTable, out PickupDropTable fallbackDropTable)
		{
			if (dropTable.GetPickupCount() == 0 && fallbacksDictionary.TryGetValue(((Object)dropTable).name, out var fallbackName))
			{
				return Object.op_Implicit((Object)(object)(fallbackDropTable = PickupDropTable.instancesList.Find((PickupDropTable x) => ((Object)x).name == fallbackName)));
			}
			fallbackDropTable = null;
			return false;
		}

		[SystemInitializer(new Type[] { })]
		private static void Init()
		{
			//IL_0010: 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: Expected O, but got Unknown
			//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_003b: Expected O, but got Unknown
			//IL_0050: 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_005b: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Expected O, but got Unknown
			object obj = <>O.<0>__PickupDropTable_GeneratePickup;
			if (obj == null)
			{
				hook_GeneratePickup val = PickupDropTable_GeneratePickup;
				<>O.<0>__PickupDropTable_GeneratePickup = val;
				obj = (object)val;
			}
			PickupDropTable.GeneratePickup += (hook_GeneratePickup)obj;
			object obj2 = <>O.<1>__PickupDropTable_GenerateDistinctPickups;
			if (obj2 == null)
			{
				hook_GenerateDistinctPickups val2 = PickupDropTable_GenerateDistinctPickups;
				<>O.<1>__PickupDropTable_GenerateDistinctPickups = val2;
				obj2 = (object)val2;
			}
			PickupDropTable.GenerateDistinctPickups += (hook_GenerateDistinctPickups)obj2;
			object obj3 = <>O.<2>__PickupDropTable_GenerateDrop;
			if (obj3 == null)
			{
				hook_GenerateDrop val3 = PickupDropTable_GenerateDrop;
				<>O.<2>__PickupDropTable_GenerateDrop = val3;
				obj3 = (object)val3;
			}
			PickupDropTable.GenerateDrop += (hook_GenerateDrop)obj3;
			object obj4 = <>O.<3>__PickupDropTable_GenerateUniqueDrops;
			if (obj4 == null)
			{
				hook_GenerateUniqueDrops val4 = PickupDropTable_GenerateUniqueDrops;
				<>O.<3>__PickupDropTable_GenerateUniqueDrops = val4;
				obj4 = (object)val4;
			}
			PickupDropTable.GenerateUniqueDrops += (hook_GenerateUniqueDrops)obj4;
			object obj5 = <>O.<4>__DrainingItems_GetDropTable;
			if (obj5 == null)
			{
				hook_GetDropTable val5 = DrainingItems_GetDropTable;
				<>O.<4>__DrainingItems_GetDropTable = val5;
				obj5 = (object)val5;
			}
			DrainingItems.GetDropTable += (hook_GetDropTable)obj5;
			object obj6 = <>O.<5>__OverchargingState_OnEnter;
			if (obj6 == null)
			{
				hook_OnEnter val6 = OverchargingState_OnEnter;
				<>O.<5>__OverchargingState_OnEnter = val6;
				obj6 = (object)val6;
			}
			OverchargingState.OnEnter += (hook_OnEnter)obj6;
		}

		private static void PickupDropTable_GenerateDistinctPickups(orig_GenerateDistinctPickups orig, PickupDropTable self, List<UniquePickup> dest, int desiredCount, Xoroshiro128Plus rng, bool allowLoop = true)
		{
			if (DropTableFallback(self, out var fallbackDropTable))
			{
				fallbackDropTable.GenerateDistinctPickups(dest, desiredCount, rng, allowLoop);
			}
			else
			{
				orig.Invoke(self, dest, desiredCount, rng, allowLoop);
			}
		}

		private static UniquePickup PickupDropTable_GeneratePickup(orig_GeneratePickup orig, PickupDropTable self, Xoroshiro128Plus rng)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			if (DropTableFallback(self, out var fallbackDropTable))
			{
				return fallbackDropTable.GeneratePickup(rng);
			}
			return orig.Invoke(self, rng);
		}

		private static PickupIndex[] PickupDropTable_GenerateUniqueDrops(orig_GenerateUniqueDrops orig, PickupDropTable self, int maxDrops, Xoroshiro128Plus rng)
		{
			if (DropTableFallback(self, out var fallbackDropTable))
			{
				return fallbackDropTable.GenerateUniqueDrops(maxDrops, rng);
			}
			return orig.Invoke(self, maxDrops, rng);
		}

		private static PickupIndex PickupDropTable_GenerateDrop(orig_GenerateDrop orig, PickupDropTable self, Xoroshiro128Plus rng)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			if (DropTableFallback(self, out var fallbackDropTable))
			{
				return fallbackDropTable.GenerateDrop(rng);
			}
			return orig.Invoke(self, rng);
		}

		private static DropTier DrainingItems_GetDropTable(orig_GetDropTable orig, DrainingItems self, int tier)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			DropTier val = orig.Invoke(self, tier);
			if (Run.instance.AreExpansionItemsDisabled(DLC4Content.DLC4))
			{
				if (fallbacksDictionary.TryGetValue(((Object)val.dropTable).name, out var fallbackName))
				{
					val = new DropTier
					{
						dropTable = PickupDropTable.instancesList.Find((PickupDropTable x) => ((Object)x).name == fallbackName),
						optionsModifier = val.optionsModifier,
						displayColorIndex = val.displayColorIndex
					};
				}
			}
			return val;
		}

		private static void OverchargingState_OnEnter(orig_OnEnter orig, OverchargingState self)
		{
			orig.Invoke(self);
			if (Run.instance.AreExpansionItemsDisabled(DLC4Content.DLC4))
			{
				BossGroup extraBossGroupServer = self.extraBossGroupServer;
				if (Object.op_Implicit((Object)(object)extraBossGroupServer))
				{
					extraBossGroupServer.bossDropChance = 1f;
				}
			}
		}
	}
	public static class MissingExpansionRequirement
	{
		[SystemInitializer(new Type[] { })]
		private static IEnumerator Init()
		{
			AsyncOperationHandle<ExpansionDef> expansion = Addressables.LoadAssetAsync<ExpansionDef>((object)"RoR2/DLC2/Common/DLC2.asset");
			AsyncOperationHandle<GameObject> prefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC2/ShrineColossusAccess.prefab");
			while (!expansion.IsDone)
			{
				yield return null;
			}
			yield return add();
			expansion = Addressables.LoadAssetAsync<ExpansionDef>((object)"RoR2/DLC3/DLC3.asset");
			IEnumerable<AsyncOperationHandle<GameObject>> requests = new string[4] { "RoR2/DLC3/DroneCombinerStation/DroneCombinerStation.prefab", "RoR2/DLC3/DroneScrapper/DroneScrapper.prefab", "RoR2/DLC3/TemporaryItemsDistributor/TemporaryItemsShopTerminal.prefab", "RoR2/DLC3/TripleDroneShop/TripleDroneShop.prefab" }.Select((string key) => Addressables.LoadAssetAsync<GameObject>((object)key));
			while (!expansion.IsDone)
			{
				yield return null;
			}
			foreach (AsyncOperationHandle<GameObject> item in requests)
			{
				prefab = item;
				yield return add();
			}
			expansion = Addressables.LoadAssetAsync<ExpansionDef>((object)"RoR2/DLC4/DLC4.asset");
			while (!expansion.IsDone)
			{
				yield return null;
			}
			prefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC4/HollowChest/HollowChestFree.prefab");
			yield return add();
			prefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC4/ShrineCompulsion/ShrineCompulsion.prefab");
			yield return add();
			IEnumerator add()
			{
				while (!prefab.IsDone)
				{
					yield return null;
				}
				GameObject result = prefab.Result;
				if (Object.op_Implicit((Object)(object)result) && !Object.op_Implicit((Object)(object)result.GetComponent<ExpansionRequirementComponent>()))
				{
					result.AddComponent<ExpansionRequirementComponent>().requiredExpansion = expansion.Result;
				}
			}
		}
	}
	public static class SafeForcedStormItems
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Manipulator <0>__PickupPickerController_GenerateOptionsFromDropTablePlusForcedStorm;
		}

		[SystemInitializer(new Type[] { })]
		private static void Init()
		{
			//IL_0010: 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: Expected O, but got Unknown
			object obj = <>O.<0>__PickupPickerController_GenerateOptionsFromDropTablePlusForcedStorm;
			if (obj == null)
			{
				Manipulator val = PickupPickerController_GenerateOptionsFromDropTablePlusForcedStorm;
				<>O.<0>__PickupPickerController_GenerateOptionsFromDropTablePlusForcedStorm = val;
				obj = (object)val;
			}
			PickupPickerController.GenerateOptionsFromDropTablePlusForcedStorm += (Manipulator)obj;
		}

		private static void PickupPickerController_GenerateOptionsFromDropTablePlusForcedStorm(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			int locStormDropsListIndex = -1;
			int locElementIndex = -1;
			ILLabel breakLabel = null;
			MethodReference val2 = default(MethodReference);
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[6]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 2),
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref locStormDropsListIndex),
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 3),
				(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 1),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<PickupDropTable>(x, "GenerateDistinctPickups")
			}) && val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[4]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, locStormDropsListIndex),
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref locElementIndex),
				(Instruction x) => ILPatternMatchingExt.MatchCallvirt(x, ref val2),
				(Instruction x) => ILPatternMatchingExt.MatchStfld<Option>(x, "pickup")
			}) && val.TryGotoPrev((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchBgt(x, ref breakLabel)
			}))
			{
				val.Emit(OpCodes.Ldloc, locStormDropsListIndex);
				val.Emit(OpCodes.Ldloc, locElementIndex);
				val.EmitDelegate<Func<List<UniquePickup>, int, bool>>((Func<List<UniquePickup>, int, bool>)((List<UniquePickup> stormDropsList, int i) => ListUtils.IsInBounds<UniquePickup>(stormDropsList, i)));
				val.Emit(OpCodes.Brfalse, (object)breakLabel);
			}
			else
			{
				ExpansionManagerPlugin.Logger.LogError((object)"SafeForcedStormItems: PickupPickerController_GenerateOptionsFromDropTablePlusForcedStorm IL match failed");
			}
		}
	}
}
namespace ExpansionManager.ContentBlockers
{
	public static class DirectorBlockers
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Manipulator <0>__DccsPool_AreConditionsMet;

			public static Manipulator <1>__DCCSBlender_AreConditionsMet;

			public static Manipulator <2>__DirectorCard_IsAvailable;
		}

		[SystemInitializer(new Type[] { })]
		private static void Init()
		{
			//IL_0010: 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: Expected O, but got Unknown
			//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_003b: Expected O, but got Unknown
			//IL_0050: 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_005b: Expected O, but got Unknown
			object obj = <>O.<0>__DccsPool_AreConditionsMet;
			if (obj == null)
			{
				Manipulator val = DccsPool_AreConditionsMet;
				<>O.<0>__DccsPool_AreConditionsMet = val;
				obj = (object)val;
			}
			DccsPool.AreConditionsMet += (Manipulator)obj;
			object obj2 = <>O.<1>__DCCSBlender_AreConditionsMet;
			if (obj2 == null)
			{
				Manipulator val2 = DCCSBlender_AreConditionsMet;
				<>O.<1>__DCCSBlender_AreConditionsMet = val2;
				obj2 = (object)val2;
			}
			DCCSBlender.AreConditionsMet += (Manipulator)obj2;
			object obj3 = <>O.<2>__DirectorCard_IsAvailable;
			if (obj3 == null)
			{
				Manipulator val3 = DirectorCard_IsAvailable;
				<>O.<2>__DirectorCard_IsAvailable = val3;
				obj3 = (object)val3;
			}
			DirectorCard.IsAvailable += (Manipulator)obj3;
		}

		private static void DccsPool_AreConditionsMet(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			int locExpansionIndex = -1;
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref locExpansionIndex),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Run>(x, "IsExpansionEnabled")
			}))
			{
				val.Emit(OpCodes.Ldarg_0);
				val.Emit(OpCodes.Ldloc, locExpansionIndex);
				val.EmitDelegate<Func<bool, DccsPool, ExpansionDef, bool>>((Func<bool, DccsPool, ExpansionDef, bool>)delegate(bool result, DccsPool dccsPool, ExpansionDef requiredExpansion)
				{
					if (result && Object.op_Implicit((Object)(object)ClassicStageInfo.instance))
					{
						if ((Object)(object)dccsPool == (Object)(object)ClassicStageInfo.instance.monsterDccsPool)
						{
							return !Run.instance.AreExpansionMonstersDisabled(requiredExpansion);
						}
						if ((Object)(object)dccsPool == (Object)(object)ClassicStageInfo.instance.interactableDccsPool)
						{
							return !Run.instance.AreExpansionInteractablesDisabled(requiredExpansion);
						}
					}
					return result;
				});
			}
			else
			{
				ExpansionManagerPlugin.Logger.LogError((object)"DirectorBlockers: DccsPool_AreConditionsMet IL match failed");
			}
		}

		private static void DCCSBlender_AreConditionsMet(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			int locExpansionIndex = -1;
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref locExpansionIndex),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Run>(x, "IsExpansionEnabled")
			}))
			{
				val.Emit(OpCodes.Ldarg_0);
				val.Emit(OpCodes.Ldloc, locExpansionIndex);
				val.EmitDelegate<Func<bool, PoolEntry, ExpansionDef, bool>>((Func<bool, PoolEntry, ExpansionDef, bool>)delegate(bool result, PoolEntry poolEntry, ExpansionDef requiredExpansion)
				{
					//IL_0015: Unknown result type (might be due to invalid IL or missing references)
					if (result)
					{
						Category[] categories = poolEntry.dccs.categories;
						for (int i = 0; i < categories.Length; i++)
						{
							DirectorCard[] cards = categories[i].cards;
							for (int j = 0; j < cards.Length; j++)
							{
								SpawnCard spawnCard = cards[j].spawnCard;
								if (spawnCard is CharacterSpawnCard)
								{
									return !Run.instance.AreExpansionMonstersDisabled(requiredExpansion);
								}
								if (spawnCard is InteractableSpawnCard)
								{
									return !Run.instance.AreExpansionInteractablesDisabled(requiredExpansion);
								}
							}
						}
					}
					return result;
				});
			}
			else
			{
				ExpansionManagerPlugin.Logger.LogError((object)"DirectorBlockers: DCCSBlender_AreConditionsMet IL match failed");
			}
		}

		private static void DirectorCard_IsAvailable(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_0077: 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)
			ILCursor val = new ILCursor(il);
			int locExpansionRequirementIndex = -1;
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[3]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref locExpansionRequirementIndex),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<ExpansionRequirementComponent>(x, "requiredExpansion"),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Run>(x, "IsExpansionEnabledOrWaived")
			}))
			{
				val.Emit(OpCodes.Ldarg_0);
				val.Emit(OpCodes.Ldloc, locExpansionRequirementIndex);
				val.EmitDelegate<Func<bool, DirectorCard, ExpansionRequirementComponent, bool>>((Func<bool, DirectorCard, ExpansionRequirementComponent, bool>)delegate(bool result, DirectorCard directorCard, ExpansionRequirementComponent expansionRequirement)
				{
					bool flag = result;
					if (flag)
					{
						SpawnCard spawnCard = directorCard.spawnCard;
						bool flag2 = ((spawnCard is CharacterSpawnCard) ? (!Run.instance.AreExpansionMonstersDisabled(expansionRequirement.requiredExpansion)) : (!(spawnCard is InteractableSpawnCard) || !Run.instance.AreExpansionInteractablesDisabled(expansionRequirement.requiredExpansion)));
						flag = flag2;
					}
					return flag;
				});
			}
			else
			{
				ExpansionManagerPlugin.Logger.LogError((object)"DirectorBlockers: DirectorCard_IsAvailable IL match failed");
			}
		}
	}
	public static class EliteBlockers
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_IsAvailable <0>__EliteDef_IsAvailable;

			public static hook_OnEnter <1>__OverchargingState_OnEnter;

			public static hook_BeginCatastrophesServer <2>__DLC4LesserCatastropheController_BeginCatastrophesServer;
		}

		[SystemInitializer(new Type[] { })]
		private static void Init()
		{
			//IL_0010: 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: Expected O, but got Unknown
			//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_003b: Expected O, but got Unknown
			//IL_0050: 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_005b: Expected O, but got Unknown
			object obj = <>O.<0>__EliteDef_IsAvailable;
			if (obj == null)
			{
				hook_IsAvailable val = EliteDef_IsAvailable;
				<>O.<0>__EliteDef_IsAvailable = val;
				obj = (object)val;
			}
			EliteDef.IsAvailable += (hook_IsAvailable)obj;
			object obj2 = <>O.<1>__OverchargingState_OnEnter;
			if (obj2 == null)
			{
				hook_OnEnter val2 = OverchargingState_OnEnter;
				<>O.<1>__OverchargingState_OnEnter = val2;
				obj2 = (object)val2;
			}
			OverchargingState.OnEnter += (hook_OnEnter)obj2;
			object obj3 = <>O.<2>__DLC4LesserCatastropheController_BeginCatastrophesServer;
			if (obj3 == null)
			{
				hook_BeginCatastrophesServer val3 = DLC4LesserCatastropheController_BeginCatastrophesServer;
				<>O.<2>__DLC4LesserCatastropheController_BeginCatastrophesServer = val3;
				obj3 = (object)val3;
			}
			DLC4LesserCatastropheController.BeginCatastrophesServer += (hook_BeginCatastrophesServer)obj3;
		}

		private static bool EliteDef_IsAvailable(orig_IsAvailable orig, EliteDef self)
		{
			if (orig.Invoke(self))
			{
				if (Object.op_Implicit((Object)(object)self.eliteEquipmentDef) && Object.op_Implicit((Object)(object)self.eliteEquipmentDef.requiredExpansion) && Object.op_Implicit((Object)(object)Run.instance))
				{
					return !Run.instance.AreExpansionElitesDisabled(self.eliteEquipmentDef.requiredExpansion);
				}
				return true;
			}
			return false;
		}

		private static void OverchargingState_OnEnter(orig_OnEnter orig, OverchargingState self)
		{
			orig.Invoke(self);
			CombatDirector extraBossDirectorServer = self.extraBossDirectorServer;
			if (!Object.op_Implicit((Object)(object)extraBossDirectorServer))
			{
				return;
			}
			((UnityEvent<GameObject>)(object)extraBossDirectorServer.onSpawnedServer).AddListener((UnityAction<GameObject>)delegate(GameObject obj)
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				Inventory val = default(Inventory);
				if (obj.TryGetComponent<Inventory>(ref val))
				{
					EquipmentDef equipmentDef = val.GetActiveEquipment().equipmentDef;
					if (Run.instance.AreExpansionElitesDisabled(equipmentDef.requiredExpansion))
					{
						equipmentDef = (((double)Random.value < 0.5) ? Equipment.AffixPoison : Equipment.AffixHaunted);
						Inventory obj2 = val;
						EquipmentIndex equipmentIndex = equipmentDef.equipmentIndex;
						EquipmentLocation activeEquipmentLocation = val.activeEquipmentLocation;
						obj2.SetEquipmentIndex(equipmentIndex, ref activeEquipmentLocation);
					}
				}
			});
		}

		private static void DLC4LesserCatastropheController_BeginCatastrophesServer(orig_BeginCatastrophesServer orig, DLC4LesserCatastropheController self)
		{
			if (Run.instance.AreExpansionElitesDisabled(DLC4Content.DLC4) || Run.instance.AreExpansionMonstersDisabled(DLC4Content.DLC4))
			{
				self.CatastrophesToSpawn = 0;
			}
			orig.Invoke(self);
		}
	}
	public static class InteractableBlockers
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Action<Stage> <0>__Stage_onServerStageBegin;

			public static hook_OnEnable <1>__DLC4ProgressionController_OnEnable;
		}

		[SystemInitializer(new Type[] { })]
		private static void Init()
		{
			//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_003b: Expected O, but got Unknown
			Stage.onServerStageBegin += Stage_onServerStageBegin;
			object obj = <>O.<1>__DLC4ProgressionController_OnEnable;
			if (obj == null)
			{
				hook_OnEnable val = DLC4ProgressionController_OnEnable;
				<>O.<1>__DLC4ProgressionController_OnEnable = val;
				obj = (object)val;
			}
			DLC4ProgressionController.OnEnable += (hook_OnEnable)obj;
		}

		private static void Stage_onServerStageBegin(Stage instance)
		{
			SceneDef sceneDef = instance.sceneDef;
			if (Object.op_Implicit((Object)(object)sceneDef) && Run.instance.AreExpansionInteractablesDisabled(DLC3Content.DLC3) && sceneDef.cachedName == "computationalexchange")
			{
				GameObject val = GameObject.Find("/HOLDER: Interactables/GROUP: Drone Zone/DroneCombinerStation");
				if (Object.op_Implicit((Object)(object)val))
				{
					val.SetActive(false);
				}
			}
		}

		private static void DLC4ProgressionController_OnEnable(orig_OnEnable orig, DLC4ProgressionController self)
		{
			orig.Invoke(self);
			if (Run.instance.AreExpansionInteractablesDisabled(DLC4Content.DLC4))
			{
				SceneDirector.onPrePopulateSceneServer -= self.OnPrePopulateSceneServer;
				TeleporterInteraction.onTeleporterChargedGlobal -= self.HandleTeleporterCompleted;
			}
		}
	}
	public static class ItemBlockers
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Action<CharacterBody> <0>__CharacterBody_onBodyAwakeGlobal;

			public static hook_GenerateWeightedSelection <1>__ExplicitPickupDropTable_GenerateWeightedSelection;

			public static Manipulator <2>__PreGameController_RecalculateModifierAvailability;

			public static hook_FilterByEntitlement <3>__CraftableCatalog_FilterByEntitlement;
		}

		[SystemInitializer(new Type[] { })]
		private static void Init()
		{
			//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_003b: Expected O, but got Unknown
			//IL_0050: 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_005b: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			CharacterBody.onBodyAwakeGlobal += CharacterBody_onBodyAwakeGlobal;
			object obj = <>O.<1>__ExplicitPickupDropTable_GenerateWeightedSelection;
			if (obj == null)
			{
				hook_GenerateWeightedSelection val = ExplicitPickupDropTable_GenerateWeightedSelection;
				<>O.<1>__ExplicitPickupDropTable_GenerateWeightedSelection = val;
				obj = (object)val;
			}
			ExplicitPickupDropTable.GenerateWeightedSelection += (hook_GenerateWeightedSelection)obj;
			object obj2 = <>O.<2>__PreGameController_RecalculateModifierAvailability;
			if (obj2 == null)
			{
				Manipulator val2 = PreGameController_RecalculateModifierAvailability;
				<>O.<2>__PreGameController_RecalculateModifierAvailability = val2;
				obj2 = (object)val2;
			}
			PreGameController.RecalculateModifierAvailability += (Manipulator)obj2;
			object obj3 = <>O.<3>__CraftableCatalog_FilterByEntitlement;
			if (obj3 == null)
			{
				hook_FilterByEntitlement val3 = CraftableCatalog_FilterByEntitlement;
				<>O.<3>__CraftableCatalog_FilterByEntitlement = val3;
				obj3 = (object)val3;
			}
			CraftableCatalog.FilterByEntitlement += (hook_FilterByEntitlement)obj3;
		}

		private static void CharacterBody_onBodyAwakeGlobal(CharacterBody body)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			DeathRewards val = default(DeathRewards);
			if (!((Component)body).TryGetComponent<DeathRewards>(ref val))
			{
				return;
			}
			if (Object.op_Implicit((Object)(object)val.bossDropTable) && val.bossDropTable.GetPickupCount() == 0)
			{
				val.bossDropTable = null;
			}
			PickupDef pickupDef = PickupCatalog.GetPickupDef((PickupIndex)val.bossPickup);
			if (pickupDef != null)
			{
				ExpansionDef requiredExpansion = pickupDef.GetRequiredExpansion();
				if (Object.op_Implicit((Object)(object)requiredExpansion) && Run.instance.AreExpansionItemsDisabled(requiredExpansion))
				{
					val.bossPickup = default(SerializablePickupIndex);
				}
			}
		}

		private static void ExplicitPickupDropTable_GenerateWeightedSelection(orig_GenerateWeightedSelection orig, ExplicitPickupDropTable self)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			if (!Object.op_Implicit((Object)(object)Run.instance))
			{
				return;
			}
			int num = self.weightedSelection.Count;
			while (--num >= 0)
			{
				if (!IsValid(self.weightedSelection.GetChoice(num).value.pickupIndex))
				{
					self.weightedSelection.RemoveChoice(num);
				}
			}
		}

		private static void PreGameController_RecalculateModifierAvailability(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			int locChoiceDefIndex = -1;
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[4]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref locChoiceDefIndex),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<RuleChoiceDef>(x, "requiredExpansionDef"),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<ExpansionDef>(x, "enabledChoice"),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<RuleBook>(x, "IsChoiceActive")
			}))
			{
				val.Emit(OpCodes.Ldarg_0);
				val.Emit(OpCodes.Ldloc, locChoiceDefIndex);
				val.EmitDelegate<Func<bool, PreGameController, RuleChoiceDef, bool>>((Func<bool, PreGameController, RuleChoiceDef, bool>)delegate(bool isChoiceActive, PreGameController controller, RuleChoiceDef choice)
				{
					//IL_0010: Unknown result type (might be due to invalid IL or missing references)
					//IL_0016: Unknown result type (might be due to invalid IL or missing references)
					ExpansionDef requiredExpansionDef = choice.requiredExpansionDef;
					if (Object.op_Implicit((Object)(object)requiredExpansionDef))
					{
						requiredExpansionDef = GetRequiredExpansion(choice.itemIndex, choice.equipmentIndex);
						if (ExpansionRulesCatalog.IsExpansionContentDisabled(controller.readOnlyRuleBook, requiredExpansionDef, ExpansionRulesCatalog.disableExpansionItemsChoices))
						{
							return false;
						}
					}
					return isChoiceActive;
				});
			}
			else
			{
				ExpansionManagerPlugin.Logger.LogError((object)"ItemBlockers: PreGameController_RecalculateModifierAvailability IL match failed");
			}
		}

		private static void CraftableCatalog_FilterByEntitlement(orig_FilterByEntitlement orig, ref RecipeEntry[] source)
		{
			orig.Invoke(ref source);
			source = source.Where((RecipeEntry entry) => IsValid(entry.result)).ToArray();
		}

		public static bool IsValid(PickupIndex pickupIndex)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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_001e: Unknown result type (might be due to invalid IL or missing references)
			if (pickupIndex != PickupIndex.none)
			{
				PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex);
				if (pickupDef != null)
				{
					ExpansionDef requiredExpansion = GetRequiredExpansion(pickupDef.itemIndex, pickupDef.equipmentIndex);
					if (Run.instance.AreExpansionItemsDisabled(requiredExpansion))
					{
						return false;
					}
				}
			}
			return true;
		}

		public static ExpansionDef GetRequiredExpansion(ItemIndex itemIndex, EquipmentIndex equipmentIndex)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Invalid comparison between Unknown and I4
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Invalid comparison between Unknown and I4
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_001f: Invalid comparison between Unknown and I4
			//IL_0021: 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_0026: Invalid comparison between Unknown and I4
			ExpansionDef result = null;
			if ((int)itemIndex != -1)
			{
				ItemDef itemDef = ItemCatalog.GetItemDef(itemIndex);
				if (Object.op_Implicit((Object)(object)itemDef))
				{
					ItemTier tier = itemDef.tier;
					if ((int)tier == 10 || (tier - 12 > 1 && !itemDef.ContainsTag((ItemTag)9)))
					{
						result = itemDef.requiredExpansion;
					}
				}
			}
			else if ((int)equipmentIndex != -1)
			{
				EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(equipmentIndex);
				if (Object.op_Implicit((Object)(object)equipmentDef) && equipmentDef.canDrop)
				{
					result = equipmentDef.requiredExpansion;
				}
			}
			return result;
		}
	}
	public static class StageBlockers
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_IsValidStage <0>__PortalSpawner_IsValidStage;

			public static Manipulator <1>__BazaarController_SetUpSeerStations;

			public static hook_CanPickStage <2>__Run_CanPickStage;
		}

		[SystemInitializer(new Type[] { })]
		private static void Init()
		{
			//IL_0010: 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: Expected O, but got Unknown
			//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_003b: Expected O, but got Unknown
			//IL_0050: 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_005b: Expected O, but got Unknown
			object obj = <>O.<0>__PortalSpawner_IsValidStage;
			if (obj == null)
			{
				hook_IsValidStage val = PortalSpawner_IsValidStage;
				<>O.<0>__PortalSpawner_IsValidStage = val;
				obj = (object)val;
			}
			PortalSpawner.IsValidStage += (hook_IsValidStage)obj;
			object obj2 = <>O.<1>__BazaarController_SetUpSeerStations;
			if (obj2 == null)
			{
				Manipulator val2 = BazaarController_SetUpSeerStations;
				<>O.<1>__BazaarController_SetUpSeerStations = val2;
				obj2 = (object)val2;
			}
			BazaarController.SetUpSeerStations += (Manipulator)obj2;
			object obj3 = <>O.<2>__Run_CanPickStage;
			if (obj3 == null)
			{
				hook_CanPickStage val3 = Run_CanPickStage;
				<>O.<2>__Run_CanPickStage = val3;
				obj3 = (object)val3;
			}
			Run.CanPickStage += (hook_CanPickStage)obj3;
		}

		private static bool PortalSpawner_IsValidStage(orig_IsValidStage orig, PortalSpawner self)
		{
			if (orig.Invoke(self))
			{
				if (Object.op_Implicit((Object)(object)self.requiredExpansion))
				{
					return !Run.instance.AreExpansionStagesDisabled(self.requiredExpansion);
				}
				return true;
			}
			return false;
		}

		private static void BazaarController_SetUpSeerStations(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			int locSceneDefIndex = -1;
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[3]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref locSceneDefIndex),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<SceneDef>(x, "requiredExpansion"),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Run>(x, "IsExpansionEnabled")
			}))
			{
				val.Emit(OpCodes.Ldloc, locSceneDefIndex);
				val.EmitDelegate<Func<bool, SceneDef, bool>>((Func<bool, SceneDef, bool>)((bool result, SceneDef sceneDef) => result && !Run.instance.AreExpansionStagesDisabled(sceneDef.requiredExpansion)));
			}
			else
			{
				ExpansionManagerPlugin.Logger.LogError((object)"StageBlockers: BazaarController_SetUpSeerStations IL match failed");
			}
		}

		private static bool Run_CanPickStage(orig_CanPickStage orig, Run self, SceneDef sceneDef)
		{
			if (orig.Invoke(self, sceneDef))
			{
				if (Object.op_Implicit((Object)(object)sceneDef.requiredExpansion))
				{
					return !self.AreExpansionStagesDisabled(sceneDef.requiredExpansion);
				}
				return true;
			}
			return false;
		}
	}
}