Repository navigation
Auto Patcher [No Dependency]
InsanityLib will automatically generate methods for doing the patching/unpatching (these are called by AutoSetup and AutoDispose).
For finer control over the patches you can make use of the [HarmonyPatchCategory] attribute (from Harmony itself) to better split the patches and allow them to be conditionally applied.
The convention for category names is as following: type:condition
Currently the following type will trigger an automatic conditional registration:
-
modif theconditionis the modid of a mod that is present it will automatically run those patches
Sometimes you might want to apply patches based on a more complex condition, in this case you can implement the ManualPatches method:
partial void ManualPatches(Harmony harmony, ICoreAPI api)
{
if(AccessTools.Method("DynamicClassesModSystem.DynamicClassesModSystem:LoadOrCreateTraitsConfig") is not null)
{
TryPatchCategory(harmony, "feature:extendedtraits_dynamictraits", Mod.Logger);
}
if(AccessTools.TypeByName("XLib.XLeveling.XLeveling") is not null)
{
TryPatchCategory(harmony, "feature:extendedtraits_xlib", Mod.Logger);
}
}when : is not specified in the category it is assumed that type is mod, this is to avoid breaking existing mods. This might be removed at a later point so it is not recommended to use this approach anymore.
For finer control you can use the [HarmonyPatchCategory] to group patches: if the category name matches a ModID then it will be automatically applied, if not then you can manually decide when to patch this category by implementing the partial ManualPatches method.