Use Prepare instead DoConditionalPatch

This commit is contained in:
amevarashi 2023-03-24 20:56:21 +05:00
parent 8d49addd63
commit 9e0a461db3
2 changed files with 2 additions and 14 deletions

View File

@ -16,7 +16,6 @@ namespace RJWSexperience
{
var har = new Harmony("RJW_Sexperience");
har.PatchAll(Assembly.GetExecutingAssembly());
Pawn_GetGizmos.DoConditionalPatch(har);
InjectIntoRjwInteractionServices();
}

View File

@ -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<DebugLogProvider>(nameof(Pawn_GetGizmos)).Message("Applied conditional patch to Pawn.GetGizmos()");
}
public static bool Prepare() => Settings.EnableSexHistory;
public static void Postfix(ref IEnumerable<Gizmo> __result, Pawn __instance)
{