diff --git a/RJWSexperience/RJWSexperience/Cum/CumUtility.cs b/RJWSexperience/RJWSexperience/Cum/CumUtility.cs index 5df544e..5c3e069 100644 --- a/RJWSexperience/RJWSexperience/Cum/CumUtility.cs +++ b/RJWSexperience/RJWSexperience/Cum/CumUtility.cs @@ -1,4 +1,6 @@ using rjw; +using rjw.Modules.Interactions.Enums; +using RJWSexperience.ExtensionMethods; using RJWSexperience.Logs; using System; using System.Collections.Generic; @@ -78,7 +80,47 @@ namespace RJWSexperience.Cum return part; } - public static void FeedCum(Pawn pawn, float amount) + public static void TryFeedCum(SexProps props) + { + if (!Genital_Helper.has_penis_fertile(props.pawn)) + return; + + if (!PawnsPenisIsInPartnersMouth(props)) + return; + + float cumAmount = CumUtility.GetOnePartCumVolume(props.pawn); + + if (cumAmount <= 0) + return; + + FeedCum(props.partner, cumAmount); + } + + private static bool PawnsPenisIsInPartnersMouth(SexProps props) + { + var interaction = rjw.Modules.Interactions.Helpers.InteractionHelper.GetWithExtension(props.dictionaryKey); + + if (props.pawn == props.GetInteractionInitiator()) + { + if (!interaction.DominantHasTag(GenitalTag.CanPenetrate) && !interaction.DominantHasFamily(GenitalFamily.Penis)) + return false; + var requirement = interaction.SelectorExtension.submissiveRequirement; + if (!requirement.mouth && !requirement.beak && !requirement.mouthORbeak) + return false; + } + else + { + if (!interaction.SubmissiveHasTag(GenitalTag.CanPenetrate) && !interaction.SubmissiveHasFamily(GenitalFamily.Penis)) + return false; + var requirement = interaction.SelectorExtension.dominantRequirement; + if (!requirement.mouth && !requirement.beak && !requirement.mouthORbeak) + return false; + } + + return true; + } + + private static void FeedCum(Pawn pawn, float amount) { const float allOf = 1000f; @@ -89,5 +131,30 @@ namespace RJWSexperience.Cum cum.Ingested(pawn, allOf); log.Message($"{pawn.NameShortColored} ingested cum"); } + + public static void FillCumBuckets(SexProps props) + { + xxx.rjwSextype sextype = props.sexType; + + bool sexFillsCumbuckets = + // Base: Fill Cumbuckets on Masturbation. Having no partner means it must be masturbation too + sextype == xxx.rjwSextype.Masturbation || props.partner == null + // Depending on configuration, also fill cumbuckets when certain sextypes are matched + || (SexperienceMod.Settings.SexCanFillBuckets && (sextype == xxx.rjwSextype.Boobjob || sextype == xxx.rjwSextype.Footjob || sextype == xxx.rjwSextype.Handjob)); + + if (!sexFillsCumbuckets) + return; + + IEnumerable buckets = props.pawn.GetAdjacentBuildings(); + + if (buckets?.EnumerableCount() > 0) + { + var initialCum = CumUtility.GetCumVolume(props.pawn); + foreach (Building_CumBucket bucket in buckets) + { + bucket.AddCum(initialCum / buckets.EnumerableCount()); + } + } + } } } diff --git a/RJWSexperience/RJWSexperience/Patches/RJW_Patch.cs b/RJWSexperience/RJWSexperience/Patches/RJW_Patch.cs index 1bf4c72..db6e603 100644 --- a/RJWSexperience/RJWSexperience/Patches/RJW_Patch.cs +++ b/RJWSexperience/RJWSexperience/Patches/RJW_Patch.cs @@ -1,15 +1,11 @@ using HarmonyLib; using RimWorld; using rjw; -using rjw.Modules.Interactions.Enums; using RJWSexperience.Cum; -using RJWSexperience.ExtensionMethods; using RJWSexperience.Logs; using RJWSexperience.SexHistory; -using System.Collections.Generic; using UnityEngine; using Verse; -using Verse.AI; namespace RJWSexperience { @@ -63,36 +59,11 @@ namespace RJWSexperience public static void Postfix(SexProps props, ref float satisfaction) { LustUtility.UpdateLust(props, satisfaction, base_sat_per_fuck); - FillCumBuckets(props); + CumUtility.FillCumBuckets(props); props.pawn.records?.Increment(VariousDefOf.OrgasmCount); if (SexperienceMod.Settings.History.EnableSexHistory && props.partner != null) props.pawn.TryGetComp()?.RecordSatisfaction(props.partner, props, satisfaction); } - - private static void FillCumBuckets(SexProps props) - { - xxx.rjwSextype sextype = props.sexType; - - bool sexFillsCumbuckets = - // Base: Fill Cumbuckets on Masturbation. Having no partner means it must be masturbation too - sextype == xxx.rjwSextype.Masturbation || props.partner == null - // Depending on configuration, also fill cumbuckets when certain sextypes are matched - || (SexperienceMod.Settings.SexCanFillBuckets && (sextype == xxx.rjwSextype.Boobjob || sextype == xxx.rjwSextype.Footjob || sextype == xxx.rjwSextype.Handjob)); - - if (!sexFillsCumbuckets) - return; - - IEnumerable buckets = props.pawn.GetAdjacentBuildings(); - - if (buckets?.EnumerableCount() > 0) - { - var initialCum = CumUtility.GetCumVolume(props.pawn); - foreach (Building_CumBucket bucket in buckets) - { - bucket.AddCum(initialCum / buckets.EnumerableCount()); - } - } - } } [HarmonyPatch(typeof(SexUtility), "TransferNutrition")] @@ -100,47 +71,7 @@ namespace RJWSexperience { public static void Postfix(SexProps props) { - TryFeedCum(props); - } - - private static void TryFeedCum(SexProps props) - { - if (!Genital_Helper.has_penis_fertile(props.pawn)) - return; - - if (!PawnsPenisIsInPartnersMouth(props)) - return; - - float cumAmount = CumUtility.GetOnePartCumVolume(props.pawn); - - if (cumAmount <= 0) - return; - - CumUtility.FeedCum(props.partner, cumAmount); - } - - private static bool PawnsPenisIsInPartnersMouth(SexProps props) - { - var interaction = rjw.Modules.Interactions.Helpers.InteractionHelper.GetWithExtension(props.dictionaryKey); - - if (props.pawn == props.GetInteractionInitiator()) - { - if (!interaction.DominantHasTag(GenitalTag.CanPenetrate) && !interaction.DominantHasFamily(GenitalFamily.Penis)) - return false; - var requirement = interaction.SelectorExtension.submissiveRequirement; - if (!requirement.mouth && !requirement.beak && !requirement.mouthORbeak) - return false; - } - else - { - if (!interaction.SubmissiveHasTag(GenitalTag.CanPenetrate) && !interaction.SubmissiveHasFamily(GenitalFamily.Penis)) - return false; - var requirement = interaction.SelectorExtension.dominantRequirement; - if (!requirement.mouth && !requirement.beak && !requirement.mouthORbeak) - return false; - } - - return true; + CumUtility.TryFeedCum(props); } }