Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ContentDisabler v1.4.1
plugins/ContentDisabler/ContentDisabler.dll
Decompiled 5 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using EntityStates; using IL.RoR2; using Mono.Cecil.Cil; using MonoMod.Cil; using On.RoR2; using On.RoR2.Skills; using On.RoR2.UI.LogBook; using RoR2; using RoR2.ContentManagement; using RoR2.ExpansionManagement; using RoR2.Skills; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ContentDisabler")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ContentDisabler")] [assembly: AssemblyTitle("ContentDisabler")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace TPDespair.ContentDisabler; [BepInPlugin("com.TPDespair.ContentDisabler", "ContentDisabler", "1.4.1")] public class ContentDisablerPlugin : BaseUnityPlugin { [CompilerGenerated] private sealed class <BodyCatalogInit>d__55 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public orig_Init orig; private GameObject[] <>s__1; private int <>s__2; private GameObject <gameObject>5__3; private CharacterBody <charBody>5__4; private string <name>5__5; private ConfigEntry<bool> <configEntry>5__6; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <BodyCatalogInit>d__55(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>s__1 = null; <gameObject>5__3 = null; <charBody>5__4 = null; <name>5__5 = null; <configEntry>5__6 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>s__1 = ContentManager.bodyPrefabs; for (<>s__2 = 0; <>s__2 < <>s__1.Length; <>s__2++) { <gameObject>5__3 = <>s__1[<>s__2]; <charBody>5__4 = <gameObject>5__3.GetComponent<CharacterBody>(); if (Object.op_Implicit((Object)(object)<charBody>5__4)) { <name>5__5 = ((Object)<charBody>5__4).name; if (<name>5__5 == "") { <name>5__5 = <charBody>5__4.baseNameToken; } if (<name>5__5 == "") { <name>5__5 = "UnknownBody"; } <configEntry>5__6 = ConfigEntry("Body", <name>5__5, defaultValue: false, "Disable Body : " + <name>5__5); if (<configEntry>5__6.Value) { if (!DisabledBodies.Contains(<name>5__5)) { DisabledBodies.Add(<name>5__5); } LogWarn("Disabled Body : " + <name>5__5); } <name>5__5 = null; <configEntry>5__6 = null; } <charBody>5__4 = null; <gameObject>5__3 = null; } <>s__1 = null; <>2__current = orig.Invoke(); <>1__state = 1; return true; case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public const string ModVer = "1.4.1"; public const string ModName = "ContentDisabler"; public const string ModGuid = "com.TPDespair.ContentDisabler"; public static ConfigFile configFile; public static ManualLogSource logSource; public static ConfigEntry<bool> ConfigItem; public static ConfigEntry<bool> ConfigEquipment; public static ConfigEntry<bool> ConfigArtifact; public static ConfigEntry<bool> ConfigDifficulty; public static ConfigEntry<bool> ConfigSurvivor; public static ConfigEntry<bool> ConfigSkill; public static ConfigEntry<bool> ConfigSkin; public static ConfigEntry<bool> ConfigBody; public static ConfigEntry<bool> ConfigSpawnCard; public static Dictionary<string, int> ConfigKeys = new Dictionary<string, int>(); public static List<ArtifactDef> DisabledArtifacts = new List<ArtifactDef>(); public static List<SurvivorDef> DisabledSurvivors = new List<SurvivorDef>(); public static Dictionary<string, ConfigEntry<bool>> SkillConfigs = new Dictionary<string, ConfigEntry<bool>>(); public static List<string> InvalidSkillStateNames = new List<string>(); public static List<string> DisabledBodies = new List<string>(); public static Dictionary<SpawnCard, string> SpawnCardBodyNames = new Dictionary<SpawnCard, string>(); public static Dictionary<SpawnCard, ConfigEntry<bool>> SpawnCardConfigs = new Dictionary<SpawnCard, ConfigEntry<bool>>(); private static readonly char[] InvalidConfigChars = new char[8] { '=', '\n', '\t', '\\', '"', '\'', '[', ']' }; public static ConfigEntry<bool> SkillFamilySafeguard { get; set; } public static ConfigEntry<bool> ScanConfigSectionsStartup { get; set; } public static ConfigEntry<bool> ScanConfigSectionsFinalize { get; set; } public void Awake() { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Expected O, but got Unknown //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected O, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Expected O, but got Unknown //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Expected O, but got Unknown //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Expected O, but got Unknown //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Expected O, but got Unknown //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Expected O, but got Unknown //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Expected O, but got Unknown //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Expected O, but got Unknown //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Expected O, but got Unknown configFile = ((BaseUnityPlugin)this).Config; logSource = ((BaseUnityPlugin)this).Logger; GlobalConfig(); if (ScanConfigSectionsStartup.Value) { ConfigStartup(); } if (ConfigArtifact.Value || ConfigDifficulty.Value) { RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(ExcludeRuleChoices)); } if (ConfigItem.Value) { ItemCatalog.Init += new hook_Init(ItemCatalogInit); } if (ConfigEquipment.Value) { EquipmentCatalog.Init += new hook_Init(EquipmentCatalogInit); } if (ConfigArtifact.Value) { ArtifactCatalog.Init += new hook_Init(ArtifactCatalogInit); } if (ConfigSurvivor.Value) { SurvivorCatalog.Init += new hook_Init(SurvivorCatalogInit); LogBookController.CanSelectSurvivorBodyEntry += new hook_CanSelectSurvivorBodyEntry(LogBookControllerCanSelectSurvivorBodyEntry); CharacterMaster.PickRandomSurvivorBodyPrefab += new Manipulator(CharacterMasterPickRandomSurvivorBodyPrefabHook); } if (ConfigSkill.Value) { SkillCatalog.Init += new hook_Init(SkillCatalogInit); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(SkillStrip2)); } if (ConfigSkin.Value) { RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(RemoveSkins)); } if (ConfigBody.Value) { BodyCatalog.Init += new hook_Init(BodyCatalogInit); LogBookController.CanSelectMonsterEntry += new hook_CanSelectMonsterEntry(LogBookControllerCanSelectMonsterEntry); } if (ConfigSpawnCard.Value) { ClassicStageInfo.RebuildCards += new hook_RebuildCards(ClassicStageInfoRebuildCards); ClassicStageInfo.RebuildCards += new Manipulator(ClassicStageInfoRebuildCardsHook); SceneDirector.onGenerateInteractableCardSelection += GatherInteractableCards; SceneDirector.GenerateInteractableCardSelection += new hook_GenerateInteractableCardSelection(SceneDirectorGenerateInteractableCardSelection); DirectorCard.IsAvailable += new hook_IsAvailable(DirectorCardIsAvailable); } if (ScanConfigSectionsFinalize.Value) { RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(ConfigFinalize)); } } private static void GlobalConfig() { SkillFamilySafeguard = configFile.Bind<bool>("00-General", "SkillFamilySafeguard", true, "Ensures that each skillFamily has at least one skill. Set to false to remove any SkillFamily that becomes empty."); ScanConfigSectionsStartup = configFile.Bind<bool>("00-General", "ScanConfigSectionsStartup", true, "Check config entries on startup and enable Generate Config if any entry in that section is set to true."); ScanConfigSectionsFinalize = configFile.Bind<bool>("00-General", "ScanConfigSectionsFinalize", true, "Check config entries on finalize and disable Generate Config if no entry in that section is set to true. Does not apply to SpawnCard."); ConfigItem = configFile.Bind<bool>("01-Generate", "ConfigItem", false, "Generate Item configs and apply patches."); ConfigEquipment = configFile.Bind<bool>("01-Generate", "ConfigEquipment", false, "Generate Equipment configs and apply patches."); ConfigArtifact = configFile.Bind<bool>("01-Generate", "ConfigArtifact", false, "Generate Artifact configs and apply patches."); ConfigDifficulty = configFile.Bind<bool>("01-Generate", "ConfigDifficulty", false, "Generate Difficulty configs and apply patches."); ConfigSurvivor = configFile.Bind<bool>("01-Generate", "ConfigSurvivor", false, "Generate Survivor configs and apply patches."); ConfigSkill = configFile.Bind<bool>("01-Generate", "ConfigSkill", false, "Generate Skill configs and apply patches."); ConfigSkin = configFile.Bind<bool>("01-Generate", "ConfigSkin", false, "Generate Skin configs and apply patches."); ConfigBody = configFile.Bind<bool>("01-Generate", "ConfigBody", false, "Generate Body configs and apply patches."); ConfigSpawnCard = configFile.Bind<bool>("01-Generate", "ConfigSpawnCard", false, "Generate SpawnCard configs and apply patches."); } private static void ConfigStartup() { LogWarn("Scanning Config Entries [Startup]"); Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)typeof(ConfigFile).GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(configFile); if (dictionary == null || dictionary.Count == 0) { LogWarn("There Are No Config Entries"); return; } List<string> list = new List<string>(); foreach (KeyValuePair<ConfigDefinition, string> item in dictionary) { string value = item.Value; if (string.IsNullOrEmpty(value) || !(value == "true")) { continue; } ConfigDefinition key = item.Key; if (key != (ConfigDefinition)null) { string section = key.Section; if (!list.Contains(section)) { LogWarn("Config Section: " + section + " Contains Disabled Entry"); list.Add(section); } } } if (list.Count == 0) { LogWarn("Found No Sections To Enable"); return; } if (list.Contains("Item") && !ConfigItem.Value) { LogWarn("Enabling Item Configs And Patches"); ConfigItem.Value = true; } if (list.Contains("Equipment") && !ConfigEquipment.Value) { LogWarn("Enabling Equipment Configs And Patches"); ConfigEquipment.Value = true; } if (list.Contains("Artifact") && !ConfigArtifact.Value) { LogWarn("Enabling Artifact Configs And Patches"); ConfigArtifact.Value = true; } if (list.Contains("Difficulty") && !ConfigDifficulty.Value) { LogWarn("Enabling Difficulty Configs And Patches"); ConfigDifficulty.Value = true; } if (list.Contains("Survivor") && !ConfigSurvivor.Value) { LogWarn("Enabling Survivor Configs And Patches"); ConfigSurvivor.Value = true; } if (list.Contains("Skill") && !ConfigSkill.Value) { LogWarn("Enabling Skill Configs And Patches"); ConfigSkill.Value = true; } if (list.Contains("Skin") && !ConfigSkin.Value) { LogWarn("Enabling Skin Configs And Patches"); ConfigSkin.Value = true; } if (list.Contains("Body") && !ConfigBody.Value) { LogWarn("Enabling Body Configs And Patches"); ConfigBody.Value = true; } if (list.Contains("SpawnCard") && !ConfigSpawnCard.Value) { LogWarn("Enabling SpawnCard Configs And Patches"); ConfigSpawnCard.Value = true; } } private static void ConfigFinalize() { LogWarn("Scanning Config Entries [Finalize]"); Dictionary<ConfigDefinition, ConfigEntryBase> dictionary = (Dictionary<ConfigDefinition, ConfigEntryBase>)typeof(ConfigFile).GetProperty("Entries", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(configFile); if (dictionary == null || dictionary.Count == 0) { LogWarn("There Are No Config Entries"); return; } List<string> list = new List<string> { "Item", "Equipment", "Artifact", "Difficulty", "Survivor", "Skill", "Skin", "Body" }; foreach (KeyValuePair<ConfigDefinition, ConfigEntryBase> item in dictionary) { ConfigEntryBase value = item.Value; if (value == null) { continue; } string serializedValue = value.GetSerializedValue(); if (string.IsNullOrEmpty(serializedValue) || !(serializedValue == "true")) { continue; } ConfigDefinition key = item.Key; if (key != (ConfigDefinition)null) { string section = key.Section; if (list.Contains(section)) { list.Remove(section); } } } if (list.Count == 0) { LogWarn("Found No Sections To Disable"); return; } foreach (string item2 in list) { LogWarn("Config Section: " + item2 + " Is Unused"); } if (list.Contains("Item") && ConfigItem.Value) { LogWarn("Disabling Item Configs And Patches, Wont Apply Until Next Startup."); ConfigItem.Value = false; } if (list.Contains("Equipment") && ConfigEquipment.Value) { LogWarn("Disabling Equipment Configs And Patches, Wont Apply Until Next Startup."); ConfigEquipment.Value = false; } if (list.Contains("Artifact") && ConfigArtifact.Value) { LogWarn("Disabling Artifact Configs And Patches, Wont Apply Until Next Startup."); ConfigArtifact.Value = false; } if (list.Contains("Difficulty") && ConfigDifficulty.Value) { LogWarn("Disabling Difficulty Configs And Patches, Wont Apply Until Next Startup."); ConfigDifficulty.Value = false; } if (list.Contains("Survivor") && ConfigSurvivor.Value) { LogWarn("Disabling Survivor Configs And Patches, Wont Apply Until Next Startup."); ConfigSurvivor.Value = false; } if (list.Contains("Skill") && ConfigSkill.Value) { LogWarn("Disabling Skill Configs And Patches, Wont Apply Until Next Startup."); ConfigSkill.Value = false; } if (list.Contains("Skin") && ConfigSkin.Value) { LogWarn("Disabling Skin Configs And Patches, Wont Apply Until Next Startup."); ConfigSkin.Value = false; } if (list.Contains("Body") && ConfigBody.Value) { LogWarn("Disabling Body Configs And Patches, Wont Apply Until Next Startup."); ConfigBody.Value = false; } } private static void ExcludeRuleChoices() { List<string> list = new List<string>(); foreach (ArtifactDef disabledArtifact in DisabledArtifacts) { string cachedName = disabledArtifact.cachedName; if (cachedName != null && cachedName != "") { list.Add("Artifacts." + cachedName); } cachedName = disabledArtifact.nameToken; if (cachedName != null && cachedName != "") { list.Add(cachedName); } } if (ConfigDifficulty.Value) { RuleDef val = RuleCatalog.FindRuleDef("Difficulty"); if (val != null) { foreach (RuleChoiceDef choice in val.choices) { string text = choice.tooltipNameToken; if (text == null || text == "") { text = "UnknownDifficulty"; } if (text == "UnknownDifficulty") { LogWarn("Tried to create ConfigEntry for [" + text + "] but it does not have a valid name!"); continue; } ConfigEntry<bool> val2 = ConfigEntry("Difficulty", text, defaultValue: false, "Disable Difficulty : " + text); if (val2.Value) { list.Add(text); LogWarn("Disabled Difficulty : " + text); } } } } LogWarn("----- Hiding RuleCatalog Choices -----"); foreach (RuleDef allRuleDef in RuleCatalog.allRuleDefs) { if (allRuleDef.choices == null || allRuleDef.choices.Count <= 0) { continue; } if (list.Contains(allRuleDef.globalName) || list.Contains(allRuleDef.displayToken)) { foreach (RuleChoiceDef choice2 in allRuleDef.choices) { choice2.excludeByDefault = true; } LogWarn("Hiding RuleCatalog Entries For [" + allRuleDef.globalName + " - " + allRuleDef.displayToken + "]"); } if (!(allRuleDef.globalName == "Difficulty")) { continue; } foreach (RuleChoiceDef choice3 in allRuleDef.choices) { if (list.Contains(choice3.tooltipNameToken)) { choice3.excludeByDefault = true; LogWarn("Hiding RuleCatalog Entry For [" + allRuleDef.globalName + " - " + choice3.tooltipNameToken + "]"); } } } LogWarn("----- RuleCatalog Choices Hidden -----"); } private static void ItemCatalogInit(orig_Init orig) { ItemDef[] itemDefs = ContentManager.itemDefs; foreach (ItemDef val in itemDefs) { string text = ((Object)val).name; if (text == "") { text = val.nameToken; } if (text == "") { text = "UnknownItem"; } ConfigEntry<bool> val2 = ConfigEntry("Item", text, defaultValue: false, "Disable Item : " + text); if (val2.Value) { val._itemTierDef = null; AssignDepricatedTier(val, (ItemTier)5); LogWarn("Disabled Item : " + text); } } orig.Invoke(); } private static void AssignDepricatedTier(ItemDef itemDef, ItemTier itemTier) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) itemDef.deprecatedTier = itemTier; } private static void EquipmentCatalogInit(orig_Init orig) { EquipmentDef[] equipmentDefs = ContentManager.equipmentDefs; foreach (EquipmentDef val in equipmentDefs) { string text = ((Object)val).name; if (text == "") { text = val.nameToken; } if (text == "") { text = "UnknownEquipment"; } ConfigEntry<bool> val2 = ConfigEntry("Equipment", text, defaultValue: false, "Disable Equipment : " + text); if (val2.Value) { val.canDrop = false; val.appearsInSinglePlayer = false; val.appearsInMultiPlayer = false; val.canBeRandomlyTriggered = false; val.enigmaCompatible = false; val.dropOnDeathChance = 0f; LogWarn("Disabled Equipment : " + text); } } orig.Invoke(); } private void ArtifactCatalogInit(orig_Init orig) { ArtifactDef[] artifactDefs = ContentManager.artifactDefs; foreach (ArtifactDef val in artifactDefs) { string text = val.cachedName; if (text == "") { text = val.nameToken; } if (text == "") { text = "UnknownArtifact"; } if (text == "UnknownArtifact") { LogWarn("Tried to create ConfigEntry for [" + text + "] but it does not have a valid name!"); continue; } ConfigEntry<bool> val2 = ConfigEntry("Artifact", text, defaultValue: false, "Disable Artifact : " + text); if (val2.Value) { if (!DisabledArtifacts.Contains(val)) { DisabledArtifacts.Add(val); } LogWarn("Disabled Artifact : " + text); } } orig.Invoke(); } private static void SurvivorCatalogInit(orig_Init orig) { SurvivorDef[] survivorDefs = ContentManager.survivorDefs; foreach (SurvivorDef val in survivorDefs) { string text = val.cachedName; if (text == "") { text = val.displayNameToken; } if (text == "") { text = "UnknownSurvivor"; } ConfigEntry<bool> val2 = ConfigEntry("Survivor", text, defaultValue: false, "Disable Survivor : " + text); if (val2.Value) { val.hidden = true; if (!DisabledSurvivors.Contains(val)) { DisabledSurvivors.Add(val); } LogWarn("Disabled Survivor : " + text); } } orig.Invoke(); } private static bool LogBookControllerCanSelectSurvivorBodyEntry(orig_CanSelectSurvivorBodyEntry orig, CharacterBody body, Dictionary<ExpansionDef, bool> expansionAvailability) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)body)) { SurvivorDef survivorDef = SurvivorCatalog.GetSurvivorDef(SurvivorCatalog.GetSurvivorIndexFromBodyIndex(body.bodyIndex)); if (Object.op_Implicit((Object)(object)survivorDef) && DisabledSurvivors.Contains(survivorDef)) { return false; } } return orig.Invoke(body, expansionAvailability); } private static void CharacterMasterPickRandomSurvivorBodyPrefabHook(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchStloc(x, 1) })) { val.Index += 1; val.Emit(OpCodes.Ldloc, 1); val.EmitDelegate<Func<SurvivorDef[], SurvivorDef[]>>((Func<SurvivorDef[], SurvivorDef[]>)delegate(SurvivorDef[] survivorDefs) { List<SurvivorDef> list = survivorDefs.ToList(); foreach (SurvivorDef disabledSurvivor in DisabledSurvivors) { if (list.Contains(disabledSurvivor)) { list.Remove(disabledSurvivor); string text = disabledSurvivor.cachedName; if (text == "") { text = disabledSurvivor.displayNameToken; } LogWarn("Removed Survivor [" + text + "] From Metamorph Choices."); } } return list.ToArray(); }); val.Emit(OpCodes.Stloc, 1); } else { LogWarn("PickRandomSurvivorHook Failed"); } } private static void SkillCatalogInit(orig_Init orig) { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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_014d: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_0103: 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_0143: Unknown result type (might be due to invalid IL or missing references) SkillDef[] skillDefs = ContentManager.skillDefs; foreach (SkillDef skillDef in skillDefs) { string skillName = GetSkillName(skillDef); if (skillName == "" || skillName == "UnknownSkill") { string stateName = GetStateName(skillDef); LogInvalidSkillStateName(stateName); } else { CreateSkillConfig(skillName); } } LogWarn("----- Rebuilding SkillFamilies -----"); List<Variant> list = new List<Variant>(); SkillFamily[] skillFamilies = ContentManager.skillFamilies; foreach (SkillFamily val in skillFamilies) { list.Clear(); uint defaultVariantIndex = val.defaultVariantIndex; uint defaultVariantIndex2 = 0u; for (int k = 0; k < val.variants.Length; k++) { Variant val2 = val.variants[k]; if (!Object.op_Implicit((Object)(object)val2.skillDef)) { LogWarn("SkillFamilyVariant.skillDef is null !!!"); string name = ((Object)val).name; if (name != null) { LogWarn("--SkillFamily Name: " + name); } UnlockableDef unlockableDef = val2.unlockableDef; if ((Object)(object)unlockableDef != (Object)null && unlockableDef.nameToken != null) { LogWarn("--Associated Unlock: " + unlockableDef.nameToken); } list.Add(val2); continue; } string skillName2 = GetSkillName(val2.skillDef); if (!IsSkillDisabled(skillName2)) { if (k == defaultVariantIndex) { defaultVariantIndex2 = (uint)list.Count; } list.Add(val2); } } if (list.Count == 0) { list.Add(val.variants[defaultVariantIndex]); } val.defaultVariantIndex = defaultVariantIndex2; val.variants = list.ToArray(); } LogWarn("----- SkillFamilies Rebuilt -----"); orig.Invoke(); } private static void SkillStrip2() { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: 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) LogWarn("----- SkillStrip2 Start -----"); List<Variant> list = new List<Variant>(); foreach (GameObject allBodyPrefab in BodyCatalog.allBodyPrefabs) { if (!Object.op_Implicit((Object)(object)allBodyPrefab)) { continue; } GenericSkill[] components = allBodyPrefab.GetComponents<GenericSkill>(); GenericSkill[] array = components; foreach (GenericSkill val in array) { SkillFamily skillFamily = val.skillFamily; if (!Object.op_Implicit((Object)(object)skillFamily)) { continue; } list.Clear(); uint defaultVariantIndex = skillFamily.defaultVariantIndex; uint defaultVariantIndex2 = 0u; for (int j = 0; j < skillFamily.variants.Length; j++) { Variant val2 = skillFamily.variants[j]; string skillName = GetSkillName(val2.skillDef); if (skillName == "" || skillName == "UnknownSkill") { string stateName = GetStateName(val2.skillDef); LogInvalidSkillStateName(stateName); } else if (!SkillConfigs.ContainsKey(skillName)) { CreateSkillConfig(skillName); } if (!IsSkillDisabled(skillName)) { if (j == defaultVariantIndex) { defaultVariantIndex2 = (uint)list.Count; } list.Add(val2); } } bool flag = false; if (list.Count == 0) { SkillDef skillDef = skillFamily.variants[defaultVariantIndex].skillDef; string skillName2 = GetSkillName(skillDef); LogWarn("[" + skillName2 + "] was enabled because its skill family has no options and it is the default skill variant."); list.Add(skillFamily.variants[defaultVariantIndex]); if (!SkillFamilySafeguard.Value) { flag = true; } } skillFamily.defaultVariantIndex = defaultVariantIndex2; skillFamily.variants = list.ToArray(); if (!flag) { continue; } SkillLocator component = allBodyPrefab.GetComponent<SkillLocator>(); if (Object.op_Implicit((Object)(object)component)) { string bodyName = GetBodyName(allBodyPrefab); LogWarn("Removing GenericSkill from SkillLocator of [" + bodyName + "]."); if ((Object)(object)component.primary == (Object)(object)val) { component.primary = null; } if ((Object)(object)component.secondary == (Object)(object)val) { component.secondary = null; } if ((Object)(object)component.utility == (Object)(object)val) { component.utility = null; } if ((Object)(object)component.special == (Object)(object)val) { component.special = null; } val.hideInCharacterSelect = true; Object.DestroyImmediate((Object)(object)val); } else { LogWarn("Tried to remove GenericSkill but SkillLocator could not be found!"); } } } LogWarn("----- SkillStrip2 End -----"); } private static string GetSkillName(SkillDef skillDef) { string skillName = skillDef.skillName; string skillNameToken = skillDef.skillNameToken; skillNameToken = skillNameToken.Trim(); skillName = skillName.Trim(); string text = "UnknownSkill"; if (skillNameToken != "" && skillName != "") { text = skillNameToken + " " + skillName; } else if (skillNameToken != "") { text = skillNameToken; } else if (skillName != "") { text = skillName; } return text.Trim(); } private static string GetStateName(SkillDef skillDef) { string text = skillDef.activationStateMachineName; string text2 = ""; if (text == null) { text = ""; } if (((SerializableEntityStateType)(ref skillDef.activationState)).stateType != null) { text2 = ((SerializableEntityStateType)(ref skillDef.activationState)).typeName; } if (text2 == null) { text2 = ""; } if (text2.Contains(",")) { text2 = text2.Substring(0, text2.IndexOf(",")); } text = text.Trim(); text2 = text2.Trim(); string text3 = "UnknownState"; if (text != "" && text2 != "") { text3 = text + " " + text2; } else if (text2 != "") { text3 = text2; } else if (text != "") { text3 = text; } return text3.Trim(); } private static void LogInvalidSkillStateName(string stateName) { stateName = stateName.Trim(); if (!InvalidSkillStateNames.Contains(stateName)) { InvalidSkillStateNames.Add(stateName); LogWarn("Tried to create ConfigEntry for [" + stateName + "] but its SkillDef does not have a valid name!"); } } private static void CreateSkillConfig(string skillName) { if (skillName == "" || skillName == "UnknownSkill" || skillName == "UnknownState") { return; } if (!SkillConfigs.ContainsKey(skillName)) { ConfigEntry<bool> val = ConfigEntry("Skill", skillName, defaultValue: false, "Disable Skill : " + skillName); SkillConfigs.Add(skillName, val); if (val.Value) { LogWarn("Disabled Skill : " + skillName); } } else { LogWarn("Tried to create another ConfigEntry for [" + skillName + "]. Using the one already available."); } } private static bool IsSkillDisabled(string skillName) { if (skillName == "" || skillName == "UnknownSkill") { return false; } if (!SkillConfigs.ContainsKey(skillName)) { return false; } if (SkillConfigs[skillName].Value) { return true; } return false; } private static void RemoveSkins() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) LogWarn("----- Rebuilding SkinDefs -----"); List<SkinDef> list = new List<SkinDef>(); foreach (GameObject allBodyPrefab in BodyCatalog.allBodyPrefabs) { if (!Object.op_Implicit((Object)(object)allBodyPrefab)) { continue; } bool flag = false; BodyIndex val = BodyCatalog.FindBodyIndex(allBodyPrefab); SkinDef[] bodySkinDefs = SkinCatalog.GetBodySkinDefs(val); if (bodySkinDefs == null) { LogWarn("No Skins found for : " + GetBodyName(allBodyPrefab)); } else { if (bodySkinDefs.Length == 0) { continue; } list.Clear(); string bodyName = GetBodyName(allBodyPrefab); SkinDef[] array = bodySkinDefs; foreach (SkinDef val2 in array) { string text = val2.nameToken; if (text == "") { text = "UnknownSkin"; } text = bodyName + " " + text; ConfigEntry<bool> val3 = ConfigEntry("Skin", text, defaultValue: false, "Disable Skin : " + text); if (val3.Value) { flag = true; LogWarn("Disabled Skin : " + text); } else { list.Add(val2); } } if (!flag) { continue; } bodySkinDefs = list.ToArray(); BodyCatalog.skins[val] = bodySkinDefs; SkinCatalog.skinsByBody[val] = bodySkinDefs; ModelLocator component = allBodyPrefab.GetComponent<ModelLocator>(); if (Object.op_Implicit((Object)(object)component)) { ModelSkinController component2 = ((Component)component.modelTransform).gameObject.GetComponent<ModelSkinController>(); if (Object.op_Implicit((Object)(object)component2)) { component2.skins = bodySkinDefs; } } } } LogWarn("----- SkinDefs Rebuilt -----"); } private static string GetBodyName(GameObject bodyPrefab) { CharacterBody component = bodyPrefab.GetComponent<CharacterBody>(); if (Object.op_Implicit((Object)(object)component)) { string text = ((Object)component).name; if (text == "") { text = component.baseNameToken; } if (text != "") { return text; } } return "UnknownBody"; } [IteratorStateMachine(typeof(<BodyCatalogInit>d__55))] private static IEnumerator BodyCatalogInit(orig_Init orig) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <BodyCatalogInit>d__55(0) { orig = orig }; } private static bool LogBookControllerCanSelectMonsterEntry(orig_CanSelectMonsterEntry orig, CharacterBody body, Dictionary<ExpansionDef, bool> expansionAvailability) { if (Object.op_Implicit((Object)(object)body)) { string text = ((Object)body).name; if (text == "") { text = body.baseNameToken; } if (DisabledBodies.Contains(text)) { return false; } } return orig.Invoke(body, expansionAvailability); } private static void ClassicStageInfoRebuildCards(orig_RebuildCards orig, ClassicStageInfo self, DirectorCardCategorySelection fmc, DirectorCardCategorySelection fic) { orig.Invoke(self, fmc, fic); ProccessWeightedSelectionEntries(self.monsterSelection); } private static void ClassicStageInfoRebuildCardsHook(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ILCursor val = new ILCursor(il); if (val.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, typeof(DccsPool), "GenerateWeightedCategorySelection") })) { val.Index += 1; val.EmitDelegate<Func<WeightedSelection<Category>, WeightedSelection<Category>>>((Func<WeightedSelection<Category>, WeightedSelection<Category>>)delegate(WeightedSelection<Category> weiSel) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) for (int num = weiSel.Count - 1; num >= 0; num--) { Category value = weiSel.GetChoice(num).value; if (ShouldRemoveCategory(value)) { weiSel.RemoveChoice(num); LogWarn("Removing Invalid MonsterFamily From Selection."); } } return weiSel; }); } else { LogWarn("RebuildCardsHook Failed"); } } private static bool ShouldRemoveCategory(Category category) { DirectorCardCategorySelection[] allAllowedFamilyCategoryDccs = GetAllAllowedFamilyCategoryDccs(category); if (allAllowedFamilyCategoryDccs != null && allAllowedFamilyCategoryDccs.Length != 0) { DirectorCardCategorySelection[] array = allAllowedFamilyCategoryDccs; foreach (DirectorCardCategorySelection val in array) { if ((Object)(object)val != (Object)null && IsMonsterFamilyValid(val)) { return false; } } return true; } return false; } private static DirectorCardCategorySelection[] GetAllAllowedFamilyCategoryDccs(Category category) { List<DirectorCardCategorySelection> list = new List<DirectorCardCategorySelection>(); PoolEntry[] alwaysIncluded = category.alwaysIncluded; for (int i = 0; i < alwaysIncluded.Length; i++) { if ((Object)(object)alwaysIncluded[i].dccs != (Object)null && (Object)/*isinst with value type is only supported in some contexts*/ != (Object)null) { list.Add(alwaysIncluded[i].dccs); } } bool flag = false; ConditionalPoolEntry[] includedIfConditionsMet = category.includedIfConditionsMet; foreach (ConditionalPoolEntry val in includedIfConditionsMet) { if ((Object)(object)((PoolEntry)val).dccs != (Object)null && (Object)/*isinst with value type is only supported in some contexts*/ != (Object)null && ((PoolEntry)val).dccs.IsAvailable() && DCCSBlender.AreConditionsMet(val)) { flag = true; list.Add(((PoolEntry)val).dccs); } } if (!flag) { alwaysIncluded = category.includedIfNoConditionsMet; for (int k = 0; k < alwaysIncluded.Length; k++) { if ((Object)(object)alwaysIncluded[k].dccs != (Object)null && (Object)/*isinst with value type is only supported in some contexts*/ != (Object)null && alwaysIncluded[k].dccs.IsAvailable()) { list.Add(alwaysIncluded[k].dccs); } } } return list.ToArray(); } private static bool IsMonsterFamilyValid(DirectorCardCategorySelection dccs) { //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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < dccs.categories.Length; i++) { Category val = dccs.categories[i]; for (int num = val.cards.Length - 1; num >= 0; num--) { DirectorCard val2 = val.cards[num]; if (val2 != null) { SpawnCard spawnCard = val2.spawnCard; if (Object.op_Implicit((Object)(object)spawnCard) && Object.op_Implicit((Object)(object)spawnCard.prefab)) { CreateSpawnCardConfig(spawnCard); if (IsCharacterSpawnCard(spawnCard) && !IsSpawnCardDisabled(spawnCard) && !DisabledBodies.Contains(SpawnCardBodyNames[spawnCard])) { return true; } } } } } return false; } private static void GatherInteractableCards(SceneDirector sceneDirector, DirectorCardCategorySelection dccs) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < dccs.categories.Length; i++) { Category val = dccs.categories[i]; for (int num = val.cards.Length - 1; num >= 0; num--) { DirectorCard val2 = val.cards[num]; if (val2 != null) { SpawnCard spawnCard = val2.spawnCard; if (Object.op_Implicit((Object)(object)spawnCard)) { CreateSpawnCardConfig(spawnCard); } } } } } private static WeightedSelection<DirectorCard> SceneDirectorGenerateInteractableCardSelection(orig_GenerateInteractableCardSelection orig, SceneDirector self) { WeightedSelection<DirectorCard> val = orig.Invoke(self); ProccessWeightedSelectionEntries(val); return val; } private static void ProccessWeightedSelectionEntries(WeightedSelection<DirectorCard> selection) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (selection == null) { return; } for (int i = 0; i < selection.Count; i++) { DirectorCard value = selection.GetChoice(i).value; if (value != null) { SpawnCard spawnCard = value.spawnCard; if (Object.op_Implicit((Object)(object)spawnCard)) { CreateSpawnCardConfig(spawnCard); } } } } private static bool DirectorCardIsAvailable(orig_IsAvailable orig, DirectorCard self) { if (Object.op_Implicit((Object)(object)self.spawnCard) && Object.op_Implicit((Object)(object)self.spawnCard.prefab)) { SpawnCard spawnCard = self.spawnCard; CreateSpawnCardConfig(spawnCard); if (IsCharacterSpawnCard(spawnCard) && DisabledBodies.Contains(SpawnCardBodyNames[spawnCard])) { return false; } if (IsSpawnCardDisabled(spawnCard)) { return false; } } return orig.Invoke(self); } private static bool IsCharacterSpawnCard(SpawnCard spawnCard) { if ((Object)(object)spawnCard == (Object)null) { return false; } if (!SpawnCardBodyNames.ContainsKey(spawnCard)) { CharacterMaster component = spawnCard.prefab.GetComponent<CharacterMaster>(); if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.bodyPrefab)) { CharacterBody component2 = component.bodyPrefab.GetComponent<CharacterBody>(); if (Object.op_Implicit((Object)(object)component2)) { string text = ((Object)component2).name; if (text == "") { text = component2.baseNameToken; } SpawnCardBodyNames.Add(spawnCard, text); } } } return SpawnCardBodyNames.ContainsKey(spawnCard); } private static void CreateSpawnCardConfig(SpawnCard spawnCard) { if ((Object)(object)spawnCard == (Object)null) { LogWarn("Tried to create ConfigEntry for null SpawnCard!"); } else { if (SpawnCardConfigs.ContainsKey(spawnCard)) { return; } string text = ((Object)spawnCard).name; if (text == "") { text = "UnknownSpawnCard"; } if (text == "UnknownSpawnCard") { LogWarn("Tried to create ConfigEntry for [" + text + "] but it does not have a valid name!"); GameObject prefab = spawnCard.prefab; if (Object.op_Implicit((Object)(object)prefab)) { text = ((Object)prefab).name; if (text != null && text != "") { LogWarn("--- PrefabName: " + ((Object)prefab).name); } } } else { ConfigEntry<bool> val = ConfigEntry("SpawnCard", text, defaultValue: false, "Disable SpawnCard : " + text); SpawnCardConfigs.Add(spawnCard, val); if (val.Value) { LogWarn("Disabled SpawnCard : " + text); } } } } private static bool IsSpawnCardDisabled(SpawnCard spawnCard) { if ((Object)(object)spawnCard == (Object)null) { return true; } if (!SpawnCardConfigs.ContainsKey(spawnCard)) { return false; } if (SpawnCardConfigs[spawnCard].Value) { return true; } return false; } private static ConfigEntry<bool> ConfigEntry(string section, string key, bool defaultValue, string description) { string configKey = section + "_" + key; key += ValidateConfigKey(configKey); key = SanitizeConfigKey(key); return configFile.Bind<bool>(section, key, defaultValue, description); } private static string ValidateConfigKey(string configKey) { if (!ConfigKeys.ContainsKey(configKey)) { ConfigKeys.Add(configKey, 1); return ""; } LogWarn("ConfigEntry for " + configKey + " already exists!"); int num = ConfigKeys[configKey]; ConfigKeys[configKey]++; return "_" + num; } private static string SanitizeConfigKey(string configKey) { bool flag = false; if (configKey.Any((char c) => InvalidConfigChars.Contains(c))) { LogWarn("ConfigEntry [" + configKey + "] contains invalid characters!"); configKey = RemoveInvalidChars(configKey); flag = true; } string text = configKey.Trim(); if (configKey != text) { LogWarn("ConfigEntry [" + configKey + "] contains trimable whitespace characters!"); configKey = text; flag = true; } if (flag) { LogWarn("ConfigEntry key has been changed to [" + configKey + "]."); } return configKey; } private static string RemoveInvalidChars(string str) { StringBuilder stringBuilder = new StringBuilder(); foreach (char value in str) { if (!InvalidConfigChars.Contains(value)) { stringBuilder.Append(value); } } return stringBuilder.ToString(); } private static void LogWarn(object data) { logSource.LogWarning(data); } }