Replaced manual sexperience patch with the Prepare method

This commit is contained in:
amevarashi 2023-04-23 15:38:38 +05:00
parent 7e30ebe68e
commit be1e5c5d5d
2 changed files with 9 additions and 16 deletions

View File

@ -1,25 +1,14 @@
using HarmonyLib; using System.Reflection;
using RJWSexperience.Ideology.Patches;
using System.Reflection;
using Verse; using Verse;
namespace RJWSexperience.Ideology namespace RJWSexperience.Ideology
{ {
[StaticConstructorOnStartup] [StaticConstructorOnStartup]
internal static class First internal static class Harmony
{ {
static First() static Harmony()
{ {
var harmony = new Harmony("RJW_Sexperience.Ideology"); new HarmonyLib.Harmony("RJW_Sexperience.Ideology").PatchAll(Assembly.GetExecutingAssembly());
harmony.PatchAll(Assembly.GetExecutingAssembly());
if (ModLister.HasActiveModWithName("RJW Sexperience"))
{
harmony.Patch(AccessTools.Method("RJWSexperience.RJWUtility:ThrowVirginHistoryEvent"),
prefix: null,
postfix: new HarmonyMethod(typeof(Sexperience_Patch_ThrowVirginHistoryEvent), nameof(Sexperience_Patch_ThrowVirginHistoryEvent.Postfix))
);
}
} }
} }
} }

View File

@ -1,11 +1,15 @@
using rjw; using HarmonyLib;
using rjw;
using RJWSexperience.Ideology.HistoryEvents; using RJWSexperience.Ideology.HistoryEvents;
using Verse; using Verse;
namespace RJWSexperience.Ideology.Patches namespace RJWSexperience.Ideology.Patches
{ {
[HarmonyPatch("RJWSexperience.RJWUtility", "ThrowVirginHistoryEvent")]
public static class Sexperience_Patch_ThrowVirginHistoryEvent public static class Sexperience_Patch_ThrowVirginHistoryEvent
{ {
public static bool Prepare() => ModsConfig.IsActive("rjw.sexperience");
public static void Postfix(Pawn exVirgin, Pawn partner, SexProps props, int degree) public static void Postfix(Pawn exVirgin, Pawn partner, SexProps props, int degree)
{ {
const int femaleAfterSurgery = 1; const int femaleAfterSurgery = 1;