From 9613dd2aba049143b957bb5257f4f03257524385 Mon Sep 17 00:00:00 2001 From: amevarashi Date: Fri, 15 Jul 2022 22:49:04 +0500 Subject: [PATCH] Move rape effects to the base mod --- .../Ideology/Patches/RJW_Patch_Ideo.cs | 28 ++-------------- .../RJWSexperience/Patches/RJW_Patch.cs | 33 +++++++++++++++++++ 2 files changed, 36 insertions(+), 25 deletions(-) diff --git a/RJWSexperience/IdeologyAddon/Ideology/Patches/RJW_Patch_Ideo.cs b/RJWSexperience/IdeologyAddon/Ideology/Patches/RJW_Patch_Ideo.cs index 2f163d0..b7c48d6 100644 --- a/RJWSexperience/IdeologyAddon/Ideology/Patches/RJW_Patch_Ideo.cs +++ b/RJWSexperience/IdeologyAddon/Ideology/Patches/RJW_Patch_Ideo.cs @@ -51,7 +51,7 @@ namespace RJWSexperience.Ideology.Patches } [HarmonyPatch(typeof(SexUtility), nameof(SexUtility.Aftersex), new Type[] { typeof(SexProps) })] - public static class RJW_Patch_Aftersex + public static class RJW_Patch_SexUtility_Aftersex_RecordHistoryEvents { public static void Postfix(SexProps props) { @@ -61,17 +61,9 @@ namespace RJWSexperience.Ideology.Patches { if (xxx.is_human(props.pawn)) AfterSexHuman(props.pawn, props.partner); - else if (xxx.is_human(props.partner)) + if (xxx.is_human(props.partner)) AfterSexHuman(props.partner, props.pawn); - if (xxx.is_human(props.partner) && props.isRape) - { - if (props.partner.IsPrisoner) - props.partner.guest.will = Math.Max(0, props.partner.guest.will - 0.2f); - if (props.partner.IsSlave) - RapeEffectSlave(props.partner); - } - if (interactionEvents != null) { foreach (HistoryEventDef eventDef in interactionEvents.pawnEvents) @@ -91,26 +83,12 @@ namespace RJWSexperience.Ideology.Patches } } - public static void AfterSexHuman(Pawn human, Pawn partner) + private static void AfterSexHuman(Pawn human, Pawn partner) { RsiHistoryEventDefOf.RSI_NonIncestuosSex.RecordEventWithPartner(human, partner); - RsiHistoryEventDefOf.RSI_NonIncestuosSex.RecordEventWithPartner(partner, human); if (partner.IsAnimal()) - { RsiHistoryEventDefOf.RSI_SexWithAnimal.RecordEventWithPartner(human, partner); - } - } - - public static void RapeEffectSlave(Pawn victim) - { - Need_Suppression suppression = victim.needs.TryGetNeed(); - if (suppression != null) - { - Hediff broken = victim.health.hediffSet.GetFirstHediffOfDef(xxx.feelingBroken); - if (broken != null) suppression.CurLevel += (0.3f * broken.Severity) + 0.05f; - else suppression.CurLevel += 0.05f; - } } } diff --git a/RJWSexperience/RJWSexperience/Patches/RJW_Patch.cs b/RJWSexperience/RJWSexperience/Patches/RJW_Patch.cs index db6e603..0bd4599 100644 --- a/RJWSexperience/RJWSexperience/Patches/RJW_Patch.cs +++ b/RJWSexperience/RJWSexperience/Patches/RJW_Patch.cs @@ -4,6 +4,7 @@ using rjw; using RJWSexperience.Cum; using RJWSexperience.Logs; using RJWSexperience.SexHistory; +using System; using UnityEngine; using Verse; @@ -155,4 +156,36 @@ namespace RJWSexperience return false; } } + + [HarmonyPatch(typeof(SexUtility), nameof(SexUtility.Aftersex), new Type[] { typeof(SexProps) })] + public static class RJW_Patch_SexUtility_Aftersex_RapeEffects + { + public static void Postfix(SexProps props) + { + if (!props.hasPartner() || !props.isRape || !xxx.is_human(props.partner)) + return; + + if (props.partner.IsPrisoner) + RapeEffectPrisoner(props.partner); + + if (props.partner.IsSlave) + RapeEffectSlave(props.partner); + } + + private static void RapeEffectPrisoner(Pawn victim) + { + victim.guest.will = Math.Max(0, victim.guest.will - 0.2f); + } + + private static void RapeEffectSlave(Pawn victim) + { + Need_Suppression suppression = victim.needs.TryGetNeed(); + if (suppression != null) + { + Hediff broken = victim.health.hediffSet.GetFirstHediffOfDef(xxx.feelingBroken); + if (broken != null) suppression.CurLevel += (0.3f * broken.Severity) + 0.05f; + else suppression.CurLevel += 0.05f; + } + } + } }