using 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;
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 = "")]
[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.3.0")]
public class ContentDisablerPlugin : BaseUnityPlugin
{
public const string ModVer = "1.3.0";
public const string ModName = "ContentDisabler";
public const string ModGuid = "com.TPDespair.ContentDisabler";
public static ConfigFile configFile;
public static ManualLogSource logSource;
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 void Awake()
{
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Expected O, but got Unknown
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Expected O, but got Unknown
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Expected O, but got Unknown
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Expected O, but got Unknown
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Expected O, but got Unknown
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Expected O, but got Unknown
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Expected O, but got Unknown
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Expected O, but got Unknown
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Expected O, but got Unknown
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Expected O, but got Unknown
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Expected O, but got Unknown
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Expected O, but got Unknown
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Expected O, but got Unknown
configFile = ((BaseUnityPlugin)this).Config;
logSource = ((BaseUnityPlugin)this).Logger;
GlobalConfig();
RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(ExcludeRuleChoices));
ItemCatalog.Init += new hook_Init(ItemCatalogInit);
EquipmentCatalog.Init += new hook_Init(EquipmentCatalogInit);
ArtifactCatalog.Init += new hook_Init(ArtifactCatalogInit);
SurvivorCatalog.Init += new hook_Init(SurvivorCatalogInit);
LogBookController.CanSelectSurvivorBodyEntry += new hook_CanSelectSurvivorBodyEntry(LogBookControllerCanSelectSurvivorBodyEntry);
CharacterMaster.PickRandomSurvivorBodyPrefab += new Manipulator(CharacterMasterPickRandomSurvivorBodyPrefabHook);
SkillCatalog.Init += new hook_Init(SkillCatalogInit);
RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(SkillStrip2));
RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(RemoveSkins));
BodyCatalog.Init += new hook_Init(BodyCatalogInit);
LogBookController.CanSelectMonsterEntry += new hook_CanSelectMonsterEntry(LogBookControllerCanSelectMonsterEntry);
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);
}
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.");
}
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);
}
}
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_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: 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];
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_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: 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[] bodySkins = BodyCatalog.GetBodySkins(val);
if (bodySkins.Length == 0)
{
continue;
}
list.Clear();
string bodyName = GetBodyName(allBodyPrefab);
SkinDef[] array = bodySkins;
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;
}
bodySkins = list.ToArray();
BodyCatalog.skins[val] = bodySkins;
SkinCatalog.skinsByBody[val] = bodySkins;
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 = bodySkins;
}
}
}
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";
}
private static IEnumerator BodyCatalogInit(orig_Init orig)
{
GameObject[] bodyPrefabs = ContentManager.bodyPrefabs;
foreach (GameObject gameObject in bodyPrefabs)
{
CharacterBody charBody = gameObject.GetComponent<CharacterBody>();
if (!Object.op_Implicit((Object)(object)charBody))
{
continue;
}
string name = ((Object)charBody).name;
if (name == "")
{
name = charBody.baseNameToken;
}
if (name == "")
{
name = "UnknownBody";
}
ConfigEntry<bool> configEntry = ConfigEntry("Body", name, defaultValue: false, "Disable Body : " + name);
if (configEntry.Value)
{
if (!DisabledBodies.Contains(name))
{
DisabledBodies.Add(name);
}
LogWarn("Disabled Body : " + name);
}
}
yield return orig.Invoke();
}
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_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Expected O, but got Unknown
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
MethodReference wat = null;
if (val.TryGotoNext(new Func<Instruction, bool>[2]
{
(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 10),
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, ref wat)
}) && ((MemberReference)wat).Name.Contains("Count"))
{
val.Index += 1;
val.EmitDelegate<Func<WeightedSelection<MonsterFamily>, WeightedSelection<MonsterFamily>>>((Func<WeightedSelection<MonsterFamily>, WeightedSelection<MonsterFamily>>)delegate(WeightedSelection<MonsterFamily> selection)
{
//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)
//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)
for (int num = selection.Count - 1; num >= 0; num--)
{
MonsterFamily value = selection.GetChoice(num).value;
if (!IsMonsterFamilyValid(value))
{
selection.RemoveChoice(num);
LogWarn("Removing Invalid MonsterFamily From Selection.");
}
}
return selection;
});
val.Emit(OpCodes.Stloc, 10);
val.Emit(OpCodes.Ldloc, 10);
}
else
{
LogWarn("RebuildCardsHook Failed");
}
}
private static bool IsMonsterFamilyValid(MonsterFamily family)
{
//IL_0001: 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_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
DirectorCardCategorySelection monsterFamilyCategories = family.monsterFamilyCategories;
for (int i = 0; i < monsterFamilyCategories.categories.Length; i++)
{
Category val = monsterFamilyCategories.categories[i];
for (int num = val.cards.Length - 1; num >= 0; num--)
{
DirectorCard val2 = val.cards[num];
SpawnCard spawnCard = val2.spawnCard;
if (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];
SpawnCard spawnCard = val2.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)
{
for (int i = 0; i < selection.Count; i++)
{
DirectorCard value = selection.GetChoice(i).value;
SpawnCard spawnCard = value.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 (!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 (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!");
return;
}
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 (!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);
}
}