From bc5b9c00b58acb9851b48589611ca47595e99932 Mon Sep 17 00:00:00 2001 From: amevarashi Date: Sat, 7 May 2022 21:05:27 +0500 Subject: [PATCH] Cleanup after merge --- Languages/English/Keyed/RJW_Sexperience.xml | 2 + .../RJWSexperience/Configurations.cs | 9 ++- .../RJWSexperience/Cum/CumUtility.cs | 58 ++++++++++++++----- .../ExtensionMethods/PawnExtensions.cs | 45 +------------- RJWSexperience/RJWSexperience/Keyed.cs | 2 + .../RJWSexperience/Patches/RJW_Patch.cs | 32 +++++----- 6 files changed, 69 insertions(+), 79 deletions(-) diff --git a/Languages/English/Keyed/RJW_Sexperience.xml b/Languages/English/Keyed/RJW_Sexperience.xml index c836557..5ace93f 100644 --- a/Languages/English/Keyed/RJW_Sexperience.xml +++ b/Languages/English/Keyed/RJW_Sexperience.xml @@ -91,6 +91,8 @@ Set how much lust can change from a single sex act Enable Bastard relation Child is marked as a bastard if they have only one parent or their parents are (or was) married + Sex can fill buckets + If enabled, boobjobs, footjobs and handjobs that happens near cum bucket will fill it Debug Enable debug logs Reset to default diff --git a/RJWSexperience/RJWSexperience/Configurations.cs b/RJWSexperience/RJWSexperience/Configurations.cs index c55dc98..16b45d1 100644 --- a/RJWSexperience/RJWSexperience/Configurations.cs +++ b/RJWSexperience/RJWSexperience/Configurations.cs @@ -22,8 +22,8 @@ namespace RJWSexperience public const bool MinSexableFromLifestageDefault = true; public const float MinSexablePercentDefault = 0.2f; public const float VirginRatioDefault = 0.01f; + public const bool SexCanFillBucketsDefault = false; public const bool selectionLockedDefault = false; - public const bool SexCanFillBucketsDefault = false; // Private attributes private float maxLustDeviation = MaxInitialLustDefault; @@ -39,6 +39,7 @@ namespace RJWSexperience private float minSexablePercent = MinSexablePercentDefault; private float virginRatio = VirginRatioDefault; private float maxSingleLustChange = MaxSingleLustChangeDefault; + private bool sexCanFillBuckets = SexCanFillBucketsDefault; private bool selectionLocked = selectionLockedDefault; private Settings.SettingsTabDebug debug; @@ -56,7 +57,7 @@ namespace RJWSexperience public float MinSexablePercent => minSexablePercent; public float VirginRatio => virginRatio; public float MaxSingleLustChange => maxSingleLustChange; - public bool SexCanFillBuckets => sexCanFillBuckets; + public bool SexCanFillBuckets => sexCanFillBuckets; public Settings.SettingsTabDebug Debug => debug; [System.Diagnostics.CodeAnalysis.SuppressMessage("Minor Code Smell", "S2292:Trivial properties should be auto-implemented", Justification = "Can't scribe property")] public bool SelectionLocked { get => selectionLocked; set => selectionLocked = value; } @@ -147,9 +148,7 @@ namespace RJWSexperience } listmain.CheckboxLabeled(Keyed.Option_EnableBastardRelation_Label, ref enableBastardRelation, Keyed.Option_EnableBastardRelation_Desc); - - - listmain.CheckboxLabeled("SexCanFillBuckets".Translate(), ref sexCanFillBuckets, "SexCanFillBuckets_desc".Translate()); + listmain.CheckboxLabeled(Keyed.Option_SexCanFillBuckets_Label, ref sexCanFillBuckets, Keyed.Option_SexCanFillBuckets_Desc); if (listmain.ButtonText(Keyed.Button_ResetToDefault)) { diff --git a/RJWSexperience/RJWSexperience/Cum/CumUtility.cs b/RJWSexperience/RJWSexperience/Cum/CumUtility.cs index 47b0d60..5df544e 100644 --- a/RJWSexperience/RJWSexperience/Cum/CumUtility.cs +++ b/RJWSexperience/RJWSexperience/Cum/CumUtility.cs @@ -9,22 +9,32 @@ namespace RJWSexperience.Cum { public static class CumUtility { + private static readonly rjw.Modules.Shared.Logs.ILog log = LogManager.GetLogger("CumUtility"); + + public static float GetOnePartCumVolume(Pawn pawn) + { + List hediffs = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn)); + if (hediffs.NullOrEmpty()) + return 0f; + + float result = GetCumVolume(pawn, GetOneBodyPartComp(hediffs)); + log.Message($"GetOnePartCumVolume({pawn.NameShortColored}) = {result}"); + return result; + } + public static float GetCumVolume(Pawn pawn) { List hediffs = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn)); - if (hediffs.NullOrEmpty()) return 0f; - else return GetCumVolume(pawn, hediffs); + if (hediffs.NullOrEmpty()) + return 0f; + float result = GetCumVolume(pawn, GetAllBodyPartComps(hediffs)); + log.Message($"GetCumVolume({pawn.NameShortColored}) = {result}"); + return result; } - public static float GetCumVolume(Pawn pawn, List hediffs) + public static float GetCumVolume(Pawn pawn, List parts) { - CompHediffBodyPart part = hediffs?.FindAll((Hediff hed) => hed.def.defName.ToLower().Contains("penis")).InRandomOrder().FirstOrDefault()?.TryGetComp(); - if (part == null) part = hediffs?.FindAll((Hediff hed) => hed.def.defName.ToLower().Contains("ovipositorf")).InRandomOrder().FirstOrDefault()?.TryGetComp(); - if (part == null) part = hediffs?.FindAll((Hediff hed) => hed.def.defName.ToLower().Contains("ovipositorm")).InRandomOrder().FirstOrDefault()?.TryGetComp(); - if (part == null) part = hediffs?.FindAll((Hediff hed) => hed.def.defName.ToLower().Contains("tentacle")).InRandomOrder().FirstOrDefault()?.TryGetComp(); - if (part == null) return 0f; - - return GetCumVolume(pawn, part); + return parts.Select(part => GetCumVolume(pawn, part)).Aggregate((sum, x) => sum + x); } public static float GetCumVolume(Pawn pawn, CompHediffBodyPart part) @@ -44,13 +54,35 @@ namespace RJWSexperience.Cum return res; } + public static List GetAllBodyPartComps(List hediffs) + { + List bodyPartComps = new List(); + + foreach (Hediff bodyPart in hediffs) + { + CompHediffBodyPart bodyPartComp = bodyPart.TryGetComp(); + if (bodyPartComp != null) + bodyPartComps.Add(bodyPartComp); + } + + return bodyPartComps; + } + + public static CompHediffBodyPart GetOneBodyPartComp(List hediffs) + { + CompHediffBodyPart part = hediffs?.FindAll((Hediff hed) => hed.def.defName.ToLower().Contains("penis")).InRandomOrder().FirstOrDefault()?.TryGetComp(); + if (part == null) part = hediffs?.FindAll((Hediff hed) => hed.def.defName.ToLower().Contains("ovipositorf")).InRandomOrder().FirstOrDefault()?.TryGetComp(); + if (part == null) part = hediffs?.FindAll((Hediff hed) => hed.def.defName.ToLower().Contains("ovipositorm")).InRandomOrder().FirstOrDefault()?.TryGetComp(); + if (part == null) part = hediffs?.FindAll((Hediff hed) => hed.def.defName.ToLower().Contains("tentacle")).InRandomOrder().FirstOrDefault()?.TryGetComp(); + + return part; + } + public static void FeedCum(Pawn pawn, float amount) { const float allOf = 1000f; - var log = LogManager.GetLogger("PawnExtensions"); - log.Message($"AteCum({pawn.NameShortColored}, {amount})"); - + log.Message($"FeedCum({pawn.NameShortColored}, {amount})"); Thing cum = ThingMaker.MakeThing(VariousDefOf.GatheredCum); cum.stackCount = (int)Math.Ceiling(amount); log.Message($"Created a stack of {cum.stackCount} cum"); diff --git a/RJWSexperience/RJWSexperience/ExtensionMethods/PawnExtensions.cs b/RJWSexperience/RJWSexperience/ExtensionMethods/PawnExtensions.cs index faec323..d3a4173 100644 --- a/RJWSexperience/RJWSexperience/ExtensionMethods/PawnExtensions.cs +++ b/RJWSexperience/RJWSexperience/ExtensionMethods/PawnExtensions.cs @@ -45,7 +45,7 @@ namespace RJWSexperience } public static IEnumerable GetAdjacentBuildings(this Pawn pawn) where T : Building - { + { // This Method was introduced to fill multiple CumBuckets around a single pawn. var results = new List(); if (pawn.Spawned) @@ -63,49 +63,6 @@ namespace RJWSexperience return results; } - public static float GetCumVolume(this Pawn pawn) - { - List hediffs = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn)); - if (hediffs.NullOrEmpty()) return 0; - else return pawn.GetCumVolume(hediffs); - } - - public static float GetCumVolume(this Pawn pawn, List hediffs) - { - float cum_value = 0; - // Add Cum for every existing Penis at the pawn - foreach (var penis in hediffs?.FindAll((Hediff hed) => hed.def.defName.ToLower().Contains("penis"))) - { - cum_value += pawn.GetCumVolume(penis.TryGetComp()); - } - // Look for more exotic parts - if any is found, add some more cum for the first special part found - CompHediffBodyPart special_part = null; - if (special_part == null) special_part = hediffs?.FindAll((Hediff hed) => hed.def.defName.ToLower().Contains("ovipositorf")).InRandomOrder().FirstOrDefault()?.TryGetComp(); - if (special_part == null) special_part = hediffs?.FindAll((Hediff hed) => hed.def.defName.ToLower().Contains("ovipositorm")).InRandomOrder().FirstOrDefault()?.TryGetComp(); - if (special_part == null) special_part = hediffs?.FindAll((Hediff hed) => hed.def.defName.ToLower().Contains("tentacle")).InRandomOrder().FirstOrDefault()?.TryGetComp(); - - cum_value += pawn.GetCumVolume(special_part); - - return cum_value; - } - - public static float GetCumVolume(this Pawn pawn, CompHediffBodyPart part) - { - float res; - - try - { - res = part.FluidAmmount * part.FluidModifier * pawn.BodySize / pawn.RaceProps.baseBodySize * Rand.Range(0.8f, 1.2f) * RJWSettings.cum_on_body_amount_adjust * 0.3f; - } - catch (NullReferenceException) - { - res = 0.0f; - } - if (pawn.Has(Quirk.Messy)) res *= Rand.Range(4.0f, 8.0f); - - return res; - } - /// /// If the pawn is virgin, return true. /// diff --git a/RJWSexperience/RJWSexperience/Keyed.cs b/RJWSexperience/RJWSexperience/Keyed.cs index 83b8c32..46c7ba1 100644 --- a/RJWSexperience/RJWSexperience/Keyed.cs +++ b/RJWSexperience/RJWSexperience/Keyed.cs @@ -92,6 +92,8 @@ namespace RJWSexperience public static readonly string Option_MaxSingleLustChange_Desc = "RSOption_MaxSingleLustChange_Desc".Translate(); public static readonly string Option_EnableBastardRelation_Label = "RSOption_EnableBastardRelation_Label".Translate(); public static readonly string Option_EnableBastardRelation_Desc = "RSOption_EnableBastardRelation_Desc".Translate(); + public static readonly string Option_SexCanFillBuckets_Label = "RSOption_SexCanFillBuckets_Label".Translate(); + public static readonly string Option_SexCanFillBuckets_Desc = "RSOption_SexCanFillBuckets_Desc".Translate(); public static readonly string Option_Debug_Label = "RSOption_Debug_Label".Translate(); public static readonly string Option_Debug_Desc = "RSOption_Debug_Desc".Translate(); public static readonly string Button_ResetToDefault = "Button_ResetToDefault".Translate(); diff --git a/RJWSexperience/RJWSexperience/Patches/RJW_Patch.cs b/RJWSexperience/RJWSexperience/Patches/RJW_Patch.cs index e3eeddf..547699a 100644 --- a/RJWSexperience/RJWSexperience/Patches/RJW_Patch.cs +++ b/RJWSexperience/RJWSexperience/Patches/RJW_Patch.cs @@ -62,37 +62,35 @@ namespace RJWSexperience public static void Postfix(SexProps props, ref float satisfaction) { Pawn pawn = props.pawn; - Pawn partner = props.partner; - xxx.rjwSextype sextype = props.sexType; UpdateLust(props, satisfaction); + FillCumBuckets(props); + RJWUtility.UpdateSatisfactionHIstory(pawn, props.partner, props, satisfaction); + pawn.records?.Increment(VariousDefOf.OrgasmCount); + } + + private static void FillCumBuckets(SexProps props) + { + xxx.rjwSextype sextype = props.sexType; - if (props.sexType == xxx.rjwSextype.Masturbation || partner == null) - { - Building_CumBucket cumbucket = pawn.GetAdjacentBuilding(); - cumbucket?.AddCum(CumUtility.GetCumVolume(pawn)); - } bool sexFillsCumbuckets = // Base: Fill Cumbuckets on Masturbation. Having no partner means it must be masturbation too - sextype == xxx.rjwSextype.Masturbation || partner == null + 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) { - IEnumerable buckets = pawn.GetAdjacentBuildings(); + IEnumerable buckets = props.pawn.GetAdjacentBuildings(); - if (buckets != null && buckets.EnumerableCount() > 0) + if (buckets?.EnumerableCount() > 0) { - var initial_Cum = pawn.GetCumVolume(); - foreach (Building_CumBucket b in buckets) + var initialCum = CumUtility.GetCumVolume(props.pawn); + foreach (Building_CumBucket bucket in buckets) { - b.AddCum(initial_Cum / buckets.EnumerableCount()); + bucket.AddCum(initialCum / buckets.EnumerableCount()); } } } - - RJWUtility.UpdateSatisfactionHIstory(pawn, partner, props, satisfaction); - pawn.records?.Increment(VariousDefOf.OrgasmCount); } private static void UpdateLust(SexProps props, float satisfaction) @@ -146,7 +144,7 @@ namespace RJWSexperience if (!PawnsPenisIsInPartnersMouth(props)) return; - CumUtility.FeedCum(props.partner, CumUtility.GetCumVolume(props.pawn)); + CumUtility.FeedCum(props.partner, CumUtility.GetOnePartCumVolume(props.pawn)); } private static bool PawnsPenisIsInPartnersMouth(SexProps props)