New settings handling

This commit is contained in:
amevarashi 2023-03-24 20:22:54 +05:00
parent fed4b54915
commit 8d49addd63
24 changed files with 309 additions and 233 deletions

View file

@ -0,0 +1,37 @@
/*using HarmonyLib;
using System.Xml;
using Verse;
namespace RJWSexperience.Patches
{
public static class ConditionalDefLoad
{
public static void DoPatch()
{
Harmony harmony = new Harmony("RJW_SexperienceXmlLoad");
harmony.Patch(AccessTools.Method(typeof(DirectXmlLoader), nameof(DirectXmlLoader.DefFromNode)), new HarmonyMethod(typeof(ConditionalDefLoad), nameof(ConditionalDefLoad.Prefix)));
}
public static bool Prefix(XmlNode node, LoadableXmlAsset loadingAsset, ref Def __result)
{
if (node.NodeType != XmlNodeType.Element)
{
return true;
}
var settingName = node.Attributes?["RsLoadFlag"]?.Value;
if (settingName.NullOrEmpty())
{
return true;
}
if (SexperienceMod.Settings.GetValue<bool>(settingName))
{
__result = null;
return false;
}
return true;
}
}
}*/