From 9e0a461db3f6180a489c71a6d804cb0054a257b8 Mon Sep 17 00:00:00 2001 From: amevarashi Date: Fri, 24 Mar 2023 20:56:21 +0500 Subject: [PATCH] Use Prepare instead DoConditionalPatch --- Source/RJWSexperience/Harmony.cs | 1 - Source/RJWSexperience/Patches/GetGizmos.cs | 15 ++------------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/Source/RJWSexperience/Harmony.cs b/Source/RJWSexperience/Harmony.cs index 8fb813b..d3a74d6 100644 --- a/Source/RJWSexperience/Harmony.cs +++ b/Source/RJWSexperience/Harmony.cs @@ -16,7 +16,6 @@ namespace RJWSexperience { var har = new Harmony("RJW_Sexperience"); har.PatchAll(Assembly.GetExecutingAssembly()); - Pawn_GetGizmos.DoConditionalPatch(har); InjectIntoRjwInteractionServices(); } diff --git a/Source/RJWSexperience/Patches/GetGizmos.cs b/Source/RJWSexperience/Patches/GetGizmos.cs index aec7f2e..5541616 100644 --- a/Source/RJWSexperience/Patches/GetGizmos.cs +++ b/Source/RJWSexperience/Patches/GetGizmos.cs @@ -1,27 +1,16 @@ using HarmonyLib; -using RJWSexperience.Logs; using RJWSexperience.SexHistory; using System.Collections.Generic; -using System.Reflection; using Verse; namespace RJWSexperience { + [HarmonyPatch(typeof(Pawn), nameof(Pawn.GetGizmos))] public static class Pawn_GetGizmos { private static Configurations Settings => SexperienceMod.Settings; - public static void DoConditionalPatch(Harmony harmony) - { - if (!Settings.EnableSexHistory) - return; - - MethodInfo original = typeof(Pawn).GetMethod(nameof(Pawn.GetGizmos)); - MethodInfo postfix = typeof(Pawn_GetGizmos).GetMethod(nameof(Pawn_GetGizmos.Postfix)); - harmony.Patch(original, postfix: new HarmonyMethod(postfix)); - - LogManager.GetLogger(nameof(Pawn_GetGizmos)).Message("Applied conditional patch to Pawn.GetGizmos()"); - } + public static bool Prepare() => Settings.EnableSexHistory; public static void Postfix(ref IEnumerable __result, Pawn __instance) {