public static void PatchCategory(this HarmonyLib.Harmony harmony, Type type) { ADOLib.Log($"Patching category {type}"); var patchAttr = type.GetCustomAttribute <CategoryAttribute>(); if (!patchAttr.isValid) { ADOLib.Log($"{type} is not valid for this ADOFAI version", LogType.Warning); return; } var patchClass = patchAttr.PatchClass; if (patchClass == null) { ADOLib.Log($"No patch class found in category {type}", LogType.Warning); return; } var patches = patchClass.GetNestedTypes(AccessTools.all).Where(t => t.GetCustomAttribute <SafePatchAttribute>() != null); foreach (var p in patches) { harmony.SafePatch(p); } ADOLib.Log($"Successfully patched category {type}", LogType.Success); }