Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of ExpansionManager v1.0.1
plugins/ExpansionManager.dll
Decompiled a year agousing 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.Logging; using ExpansionManager.Util; using HG; using HG.Reflection; using IL.RoR2; using Microsoft.CodeAnalysis; using Mono.Cecil.Cil; using MonoMod.Cil; 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.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: AssemblyCompany("ExpansionManager")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+5b9d03d4278fae3603a29bbe1ecf2453ae6af4d5")] [assembly: AssemblyProduct("ExpansionManager")] [assembly: AssemblyTitle("ExpansionManager")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace 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.0.1")] public class ExpansionManagerPlugin : BaseUnityPlugin { public const string GUID = "groovesalad.ExpansionManager"; public const string NAME = "ExpansionManager"; public const string VERSION = "1.0.1"; public static ManualLogSource Logger { get; private set; } protected void Awake() { 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")); }; ExpansionRulesCatalog.ModInit(); ExpansionManagerUI.ModInit(); } } 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_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Unknown result type (might be due to invalid IL or missing references) //IL_0470: Unknown result type (might be due to invalid IL or missing references) //IL_04b3: Unknown result type (might be due to invalid IL or missing references) //IL_04cf: Unknown result type (might be due to invalid IL or missing references) //IL_04e8: Unknown result type (might be due to invalid IL or missing references) //IL_05dc: Unknown result type (might be due to invalid IL or missing references) //IL_0618: Unknown result type (might be due to invalid IL or missing references) //IL_061d: Unknown result type (might be due to invalid IL or missing references) //IL_0632: Unknown result type (might be due to invalid IL or missing references) //IL_0637: Unknown result type (might be due to invalid IL or missing references) //IL_065b: Unknown result type (might be due to invalid IL or missing references) //IL_0660: Unknown result type (might be due to invalid IL or missing references) //IL_067c: Unknown result type (might be due to invalid IL or missing references) //IL_0690: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self, displayChoiceDef); if (displayChoiceDef.extraData is ExpansionRulesCatalog.ExpansionContentRule expansionContentRule) { if (Object.op_Implicit((Object)(object)self.image)) { Transform val = ((Component)self.image).transform.parent.Find("SubIcon"); Image val2 = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<Image>() : null); if (!Object.op_Implicit((Object)(object)val2)) { val2 = new GameObject("SubIcon", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }).GetComponent<Image>(); ((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); } val2.sprite = (expansionContentRule.enabled ? expansionContentRule.expansionDef.iconSprite : expansionContentRule.expansionDef.disabledIconSprite); } { foreach (RuleChoiceController instances in RuleChoiceController.instancesList) { if (instances.choiceDef != null && (Object)/*isinst with value type is only supported in some contexts*/ == (Object)(object)expansionContentRule.expansionDef) { instances.UpdateChoiceDisplay(instances.choiceDef); } } return; } } object extraData = displayChoiceDef.extraData; ExpansionDef val4 = (ExpansionDef)((extraData is ExpansionDef) ? extraData : null); if (val4 == null || !ExpansionRulesCatalog.expansionByRuleCategory.TryGetValue(val4.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 val5 = ((Component)self).transform.Find("BaseOutline"); Image val6 = (Object.op_Implicit((Object)(object)val5) ? ((Component)val5).GetComponent<Image>() : null); Transform val7 = ((Component)self).transform.Find("HoverOutline"); Image val8 = (Object.op_Implicit((Object)(object)val7) ? ((Component)val7).GetComponent<Image>() : null); if (!Object.op_Implicit((Object)(object)val6)) { val6 = new GameObject("BaseOutline", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }).GetComponent<Image>(); ((Component)val6).transform.SetParent(((Component)self).transform, false); ((Component)val6).gameObject.layer = LayerIndex.ui.intVal; val6.sprite = texUIHeaderSharp; ((Graphic)val6).color = Color32.op_Implicit(new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)30)); RectTransform component2 = ((Component)val6).GetComponent<RectTransform>(); component2.sizeDelta = new Vector2(48f, 8f); ((Transform)component2).localPosition = new Vector3(0f, -30f, 0f); } if (!Object.op_Implicit((Object)(object)val8)) { val8 = new GameObject("HoverOutline", 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 = Color.white; RectTransform component3 = ((Component)val8).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 = val6; self.hgButton.imageOnHover = val8; } Transform val9 = ((Component)self).transform.Find("NotificationIcon"); Image val10 = (Object.op_Implicit((Object)(object)val9) ? ((Component)val9).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)val10)) { val10 = new GameObject("NotificationIcon", 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 = Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/UI/texPlayerVoteStatus.png").WaitForCompletion(); ((Graphic)val10).material = Addressables.LoadAssetAsync<Material>((object)"RoR2/Base/UI/matUIOverbrighten2x.mat").WaitForCompletion(); ((Graphic)val10).color = Color32.op_Implicit(new Color32((byte)235, (byte)235, (byte)235, (byte)200)); RectTransform component4 = ((Component)val10).GetComponent<RectTransform>(); component4.sizeDelta = new Vector2(20f, 30f); ((Transform)component4).localPosition = new Vector3(16f, 16f); } if (Object.op_Implicit((Object)(object)val10)) { ((Component)val10).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_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Expected O, but got Unknown //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Expected O, but got Unknown //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Expected O, but got Unknown //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) 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) { return; } 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) { return; } 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; } } } else if (categoryDef.displayToken == "RULE_HEADER_EXPANSIONS") { GridLayoutGroup val4 = (Object.op_Implicit((Object)(object)self.voteResultGridContainer) ? ((Component)self.voteResultGridContainer).GetComponent<GridLayoutGroup>() : null); if (Object.op_Implicit((Object)(object)val4)) { ((LayoutGroup)val4).padding = new RectOffset(6, 6, 12, 12); val4.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>__HiddenTestTrue; 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_0135: 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.HiddenTestTrue, (RuleCategoryType)1); 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 val4 = default(ExpansionRequirementComponent); if (networkedObjectPrefab.TryGetComponent<ExpansionRequirementComponent>(ref val4)) { return (Object)(object)val4.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).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 DeadDccsAdditions { [CompilerGenerated] private static class <>O { public static Manipulator <0>__ClassicStageInfo_RebuildCards; } 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 }, { "dccsHelminthRoostMonstersDLC2Only", HelminthRoostMonstersDLC2Only } }; 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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown dccs.AttemptAddCard("Minibosses", new DirectorCard { spawnCard = Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/Base/Bell/cscBell.asset").WaitForCompletion(), selectionWeight = 1 }); dccs.AttemptAddCard("Basic Monsters", new DirectorCard { spawnCard = Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/Base/Wisp/cscLesserWisp.asset").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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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) //IL_008a: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Expected O, but got Unknown dccs.AttemptAddCard("Champions", new DirectorCard { spawnCard = Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/Base/MagmaWorm/cscMagmaWorm.asset").WaitForCompletion(), selectionWeight = 1 }); dccs.AttemptAddCard("Basic Monsters", new DirectorCard { spawnCard = Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/DLC2/Scorchling/cscScorchling.asset").WaitForCompletion(), selectionWeight = 1, spawnDistance = (MonsterSpawnDistance)2 }); dccs.AttemptAddCard("Basic Monsters", new DirectorCard { spawnCard = Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/Base/HermitCrab/cscHermitCrab.asset").WaitForCompletion(), selectionWeight = 1, spawnDistance = (MonsterSpawnDistance)2, preventOverhead = true }); dccs.AttemptAddCard("Basic Monsters", new DirectorCard { spawnCard = Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/Base/Lemurian/cscLemurian.asset").WaitForCompletion(), selectionWeight = 2 }); } public static void HelminthRoostMonstersDLC2Only(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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown dccs.AttemptAddCard("Basic Monsters", new DirectorCard { spawnCard = Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/Base/Imp/cscImp.asset").WaitForCompletion(), selectionWeight = 2 }); } 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; } [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>__ClassicStageInfo_RebuildCards; if (obj == null) { Manipulator val = ClassicStageInfo_RebuildCards; <>O.<0>__ClassicStageInfo_RebuildCards = val; obj = (object)val; } ClassicStageInfo.RebuildCards += (Manipulator)obj; } private static void ClassicStageInfo_RebuildCards(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchStfld<ClassicStageInfo>(x, "modifiableMonsterCategories") })) { val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Action<ClassicStageInfo>>((Action<ClassicStageInfo>)delegate(ClassicStageInfo classicStageInfo) { if (Object.op_Implicit((Object)(object)classicStageInfo.modifiableMonsterCategories)) { string text = ((Object)classicStageInfo.modifiableMonsterCategories).name; if (text.EndsWith("(Clone)")) { text = text.Remove(text.Length - 7); } if (monsterSelectionAdditions.TryGetValue(text, out var value)) { SceneDef val2 = (Object.op_Implicit((Object)(object)SceneInfo.instance) ? SceneInfo.instance.sceneDef : null); ExpansionDef val3 = (Object.op_Implicit((Object)(object)val2) ? val2.requiredExpansion : null); if (Object.op_Implicit((Object)(object)val3) && Run.instance.AreExpansionMonstersDisabled(val3)) { ExpansionManagerPlugin.Logger.LogInfo((object)("DeadDccsAdditions: " + ((Object)val3).name + " has monsters disabled, Adding monster cards to " + text)); value(classicStageInfo.modifiableMonsterCategories); } } } }); } else { ExpansionManagerPlugin.Logger.LogError((object)"DeadDccsAdditions: ClassicStageInfo_RebuildCards IL match failed"); } } } public static class DropTableFallbacks { [CompilerGenerated] private static class <>O { public static hook_GenerateDrop <0>__PickupDropTable_GenerateDrop; public static hook_GenerateUniqueDrops <1>__PickupDropTable_GenerateUniqueDrops; } public static readonly Dictionary<string, string> fallbacksDictionary = new Dictionary<string, string> { { "dtVoidChest", "dtChest1" }, { "dtShrineHalcyoniteTier1", "dtShrineHalcyoniteTier3" }, { "dtShrineHalcyoniteTier2", "dtShrineHalcyoniteTier3" }, { "PrismDroptable", "dtCategoryChest2Damage" }, { string.Empty, "dtChest1" } }; 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 object obj = <>O.<0>__PickupDropTable_GenerateDrop; if (obj == null) { hook_GenerateDrop val = PickupDropTable_GenerateDrop; <>O.<0>__PickupDropTable_GenerateDrop = val; obj = (object)val; } PickupDropTable.GenerateDrop += (hook_GenerateDrop)obj; object obj2 = <>O.<1>__PickupDropTable_GenerateUniqueDrops; if (obj2 == null) { hook_GenerateUniqueDrops val2 = PickupDropTable_GenerateUniqueDrops; <>O.<1>__PickupDropTable_GenerateUniqueDrops = val2; obj2 = (object)val2; } PickupDropTable.GenerateUniqueDrops += (hook_GenerateUniqueDrops)obj2; } 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); } } public static class HalcyoniteOverrideFallback { [CompilerGenerated] private static class <>O { public static hook_OverrideCurrentMonsterCard <0>__CombatDirector_OverrideCurrentMonsterCard; } [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>__CombatDirector_OverrideCurrentMonsterCard; if (obj == null) { hook_OverrideCurrentMonsterCard val = CombatDirector_OverrideCurrentMonsterCard; <>O.<0>__CombatDirector_OverrideCurrentMonsterCard = val; obj = (object)val; } CombatDirector.OverrideCurrentMonsterCard += (hook_OverrideCurrentMonsterCard)obj; } 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); } } 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_0139: Unknown result type (might be due to invalid IL or missing references) //IL_014b: 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) ILCursor val = new ILCursor(il); int locStormDropsArrayIndex = -1; int locElementIndex = -1; ILLabel breakLabel = null; if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[5] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 2), (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 3), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<PickupDropTable>(x, "GenerateUniqueDrops"), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref locStormDropsArrayIndex) }) && val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[3] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, locStormDropsArrayIndex), (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref locElementIndex), (Instruction x) => ILPatternMatchingExt.MatchLdelemAny<PickupIndex>(x) }) && val.TryGotoPrev((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchBgt(x, ref breakLabel) })) { val.Emit(OpCodes.Ldloc, locStormDropsArrayIndex); val.Emit(OpCodes.Ldloc, locElementIndex); val.EmitDelegate<Func<PickupIndex[], int, bool>>((Func<PickupIndex[], int, bool>)((PickupIndex[] stormDropsArray, int i) => ArrayUtils.IsInBounds<PickupIndex>(stormDropsArray, i))); val.Emit(OpCodes.Brfalse, (object)breakLabel); } else { ExpansionManagerPlugin.Logger.LogError((object)"SafeForcedStormItems: PickupPickerController_GenerateOptionsFromDropTablePlusForcedStorm IL match failed"); } } } public static class ShapingShrineExpansionRequirement { [SystemInitializer(new Type[] { })] private static IEnumerator Init() { AsyncOperationHandle<GameObject> load_ShrineColossusAccess = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC2/ShrineColossusAccess.prefab"); AsyncOperationHandle<ExpansionDef> load_DLC2 = Addressables.LoadAssetAsync<ExpansionDef>((object)"RoR2/DLC2/Common/DLC2.asset"); while (!load_ShrineColossusAccess.IsDone) { yield return null; } GameObject result = load_ShrineColossusAccess.Result; if (Object.op_Implicit((Object)(object)result) && !Object.op_Implicit((Object)(object)result.GetComponent<ExpansionRequirementComponent>())) { ExpansionRequirementComponent expansionRequirement = result.AddComponent<ExpansionRequirementComponent>(); while (!load_DLC2.IsDone) { yield return null; } expansionRequirement.requiredExpansion = load_DLC2.Result; } } } } namespace ExpansionManager.ContentBlockers { public static class DirectorBlockers { [CompilerGenerated] private static class <>O { public static Manipulator <0>__DccsPool_AreConditionsMet; public static Manipulator <1>__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 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>__DirectorCard_IsAvailable; if (obj2 == null) { Manipulator val2 = DirectorCard_IsAvailable; <>O.<1>__DirectorCard_IsAvailable = val2; obj2 = (object)val2; } DirectorCard.IsAvailable += (Manipulator)obj2; } 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 (Object.op_Implicit((Object)(object)ClassicStageInfo.instance)) { if ((Object)(object)dccsPool == (Object)(object)ClassicStageInfo.instance.monsterDccsPool) { if (result) { return !Run.instance.AreExpansionMonstersDisabled(requiredExpansion); } return false; } if ((Object)(object)dccsPool == (Object)(object)ClassicStageInfo.instance.interactableDccsPool) { if (result) { return !Run.instance.AreExpansionInteractablesDisabled(requiredExpansion); } return false; } } return result; }); } else { ExpansionManagerPlugin.Logger.LogError((object)"DirectorBlockers: DccsPool_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, "IsExpansionEnabled") })) { 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) { SpawnCard spawnCard = directorCard.spawnCard; if (spawnCard is CharacterSpawnCard) { return result && !Run.instance.AreExpansionMonstersDisabled(expansionRequirement.requiredExpansion); } return (spawnCard is InteractableSpawnCard) ? (result && !Run.instance.AreExpansionInteractablesDisabled(expansionRequirement.requiredExpansion)) : result; }); } 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; } [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>__EliteDef_IsAvailable; if (obj == null) { hook_IsAvailable val = EliteDef_IsAvailable; <>O.<0>__EliteDef_IsAvailable = val; obj = (object)val; } EliteDef.IsAvailable += (hook_IsAvailable)obj; } 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; } } 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; } [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 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; } 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Invalid comparison between Unknown and I4 //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Invalid comparison between Unknown and I4 //IL_0073: 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 && ((int)pickupDef.itemIndex != -1 || (int)pickupDef.equipmentIndex != -1)) { 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Invalid comparison between Unknown and I4 //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Invalid comparison between Unknown and I4 orig.Invoke(self); if (!Object.op_Implicit((Object)(object)Run.instance)) { return; } for (int num = self.weightedSelection.Count; num >= 0; num--) { PickupDef pickupDef = PickupCatalog.GetPickupDef(self.weightedSelection.GetChoice(num).value); if (pickupDef != null && ((int)pickupDef.itemIndex != -1 || (int)pickupDef.equipmentIndex != -1)) { ExpansionDef requiredExpansion = pickupDef.GetRequiredExpansion(); if (Object.op_Implicit((Object)(object)requiredExpansion) && Run.instance.AreExpansionItemsDisabled(requiredExpansion)) { 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 result, PreGameController preGameController, RuleChoiceDef choiceDef) { return (IsValidItem() || IsValidEquipment()) ? (result && !ExpansionRulesCatalog.IsExpansionContentDisabled(preGameController.readOnlyRuleBook, choiceDef.requiredExpansionDef, ExpansionRulesCatalog.disableExpansionItemsChoices)) : result; bool IsValidEquipment() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 //IL_0016: Unknown result type (might be due to invalid IL or missing references) if ((int)choiceDef.equipmentIndex == -1) { return false; } EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(choiceDef.equipmentIndex); if (Object.op_Implicit((Object)(object)equipmentDef)) { return !equipmentDef.IsElite(); } return false; } bool IsValidItem() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 return (int)choiceDef.itemIndex != -1; } }); } else { ExpansionManagerPlugin.Logger.LogError((object)"ItemBlockers: PreGameController_RecalculateModifierAvailability IL match failed"); } } } 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; } } }