From d5d5dbd77c4250b9a63e05078b5045b0d2ea0c70 Mon Sep 17 00:00:00 2001 From: amevarashi Date: Sun, 20 Mar 2022 14:16:16 +0500 Subject: [PATCH 1/5] Womb cleaning spams job if no bucket on the map --- .../RJW_Menstruation/SexperienceModule/Patch/RJW_Patch.cs | 2 +- 1.3/source/RJW_Menstruation/SexperienceModule/VariousDefOf.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/1.3/source/RJW_Menstruation/SexperienceModule/Patch/RJW_Patch.cs b/1.3/source/RJW_Menstruation/SexperienceModule/Patch/RJW_Patch.cs index f3e8029..4377e5f 100644 --- a/1.3/source/RJW_Menstruation/SexperienceModule/Patch/RJW_Patch.cs +++ b/1.3/source/RJW_Menstruation/SexperienceModule/Patch/RJW_Patch.cs @@ -21,7 +21,7 @@ namespace RJW_Menstruation.Sexperience public static bool HasJobOnThing(Pawn pawn, Thing t, bool forced, ref bool __result) { HediffComp_Menstruation comp = pawn.GetMenstruationComp(); - if (comp != null && comp.DoCleanWomb && comp.TotalCumPercent > 0.001f) + if (comp != null && comp.DoCleanWomb && comp.TotalCumPercent > 0.001f && pawn.Map.listerBuildings.ColonistsHaveBuilding(VariousDefOf.CumBucket)) { __result = true; return false; diff --git a/1.3/source/RJW_Menstruation/SexperienceModule/VariousDefOf.cs b/1.3/source/RJW_Menstruation/SexperienceModule/VariousDefOf.cs index 27cd062..fef502c 100644 --- a/1.3/source/RJW_Menstruation/SexperienceModule/VariousDefOf.cs +++ b/1.3/source/RJW_Menstruation/SexperienceModule/VariousDefOf.cs @@ -12,6 +12,6 @@ namespace RJW_Menstruation.Sexperience public static readonly JobDef VaginaWashingwithBucket = DefDatabase.GetNamed("VaginaWashingwithBucket"); public static readonly ThingDef GatheredCumMixture = DefDatabase.GetNamed("GatheredCumMixture"); - + public static readonly ThingDef CumBucket = DefDatabase.GetNamed("CumBucket"); } } From b7267e614c19825d64ad0b4f774a8aa701465738 Mon Sep 17 00:00:00 2001 From: amevarashi Date: Sun, 20 Mar 2022 14:21:00 +0500 Subject: [PATCH 2/5] Fix futanari impregnation --- .../RJW_Menstruation/Patch/RJW_Patch.cs | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/1.3/source/RJW_Menstruation/RJW_Menstruation/Patch/RJW_Patch.cs b/1.3/source/RJW_Menstruation/RJW_Menstruation/Patch/RJW_Patch.cs index 133673d..dafa7a5 100644 --- a/1.3/source/RJW_Menstruation/RJW_Menstruation/Patch/RJW_Patch.cs +++ b/1.3/source/RJW_Menstruation/RJW_Menstruation/Patch/RJW_Patch.cs @@ -1,5 +1,7 @@ using HarmonyLib; using rjw; +using rjw.Modules.Interactions.Enums; +using rjw.Modules.Interactions.Objects; using Verse; using UnityEngine; @@ -19,6 +21,8 @@ namespace RJW_Menstruation if (partner.IsAnimal() && !Configurations.EnableAnimalCycle) return true; + if (!InteractionCanCausePregnancy(props)) return false; + var pawnparts = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn)); HediffComp_Menstruation comp = partner.GetMenstruationComp(); @@ -39,6 +43,36 @@ namespace RJW_Menstruation } + + /// + /// Checks if pregnancy can happen based on the interaction def + /// This is needed for futanari sex, but should work for everyone + /// + /// + /// Interaction can result in pregnancy + private static bool InteractionCanCausePregnancy(SexProps props) + { + InteractionWithExtension interaction = rjw.Modules.Interactions.Helpers.InteractionHelper.GetWithExtension(props.dictionaryKey); + + if (!interaction.HasInteractionTag(InteractionTag.Fertilization)) + return false; + + bool usesPawnsPenis; + bool usesPartnersVagina; + + if (!props.isReceiver) + { + usesPawnsPenis = interaction.DominantHasTag(GenitalTag.CanPenetrate); + usesPartnersVagina = interaction.SubmissiveHasFamily(GenitalFamily.Vagina); + } + else + { + usesPawnsPenis = interaction.SubmissiveHasTag(GenitalTag.CanPenetrate); + usesPartnersVagina = interaction.DominantHasFamily(GenitalFamily.Vagina); + } + + return usesPawnsPenis && usesPartnersVagina; + } } [HarmonyPatch(typeof(PregnancyHelper), "Doimpregnate")] From 33bbde68cacd815e7b3c4805438cb65050c9e5f8 Mon Sep 17 00:00:00 2001 From: amevarashi Date: Sun, 20 Mar 2022 17:48:27 +0500 Subject: [PATCH 3/5] Disguise progress bar color for the hidden pregnancy --- .../HediffComps/HediffComp_Menstruation.cs | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/1.3/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Menstruation.cs b/1.3/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Menstruation.cs index a9ecec5..f943796 100644 --- a/1.3/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Menstruation.cs +++ b/1.3/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Menstruation.cs @@ -251,11 +251,27 @@ namespace RJW_Menstruation return mixedcolor; } } + + public Stage CurrentVisibleStage + { + get + { + if (curStage == Stage.Pregnant) + { + if (Configurations.InfoDetail == Configurations.DetailLevel.All || (PregnancyHelper.GetPregnancy(parent.pawn)?.Visible ?? false)) + return Stage.Pregnant; + else + return Stage.Luteal; + } + return curStage; + } + } + public string GetCurStageLabel { get { - switch (curStage) + switch (CurrentVisibleStage) { case Stage.Follicular: return Translations.Stage_Follicular; @@ -268,8 +284,7 @@ namespace RJW_Menstruation case Stage.Fertilized: return Translations.Stage_Fertilized; case Stage.Pregnant: - if (Configurations.InfoDetail == Configurations.DetailLevel.All || (PregnancyHelper.GetPregnancy(parent.pawn)?.Visible ?? false)) return Translations.Stage_Pregnant; - else return Translations.Stage_Luteal; + return Translations.Stage_Pregnant; case Stage.Recover: return Translations.Stage_Recover; case Stage.None: @@ -483,7 +498,7 @@ namespace RJW_Menstruation { get { - if (!StageTexture.TryGetValue(curStage, out Texture2D tex)) tex = TextureCache.TzeentchTexture; + if (!StageTexture.TryGetValue(CurrentVisibleStage, out Texture2D tex)) tex = TextureCache.TzeentchTexture; return tex; } } From 55e55fbc35db438151750a7d976a049d5e75a5a9 Mon Sep 17 00:00:00 2001 From: amevarashi Date: Sun, 20 Mar 2022 18:16:08 +0500 Subject: [PATCH 4/5] Hide egg implantation for the hidden pregnancy --- .../RJW_Menstruation/HediffComps/MenstruationUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1.3/source/RJW_Menstruation/RJW_Menstruation/HediffComps/MenstruationUtility.cs b/1.3/source/RJW_Menstruation/RJW_Menstruation/HediffComps/MenstruationUtility.cs index 8e5152c..b01a1b5 100644 --- a/1.3/source/RJW_Menstruation/RJW_Menstruation/HediffComps/MenstruationUtility.cs +++ b/1.3/source/RJW_Menstruation/RJW_Menstruation/HediffComps/MenstruationUtility.cs @@ -157,7 +157,7 @@ namespace RJW_Menstruation } public static Texture2D GetEggIcon(this HediffComp_Menstruation comp) { - if (comp.parent.pawn.IsPregnant()) + if (comp.parent.pawn.IsPregnant(Configurations.InfoDetail != Configurations.DetailLevel.All)) { if (comp.parent.pawn.GetPregnancyProgress() < 0.2f) return ContentFinder.Get("Eggs/Egg_Implanted00", true); else return ContentFinder.Get("Womb/Empty", true); From e67010239b4cb96609b93ab94ae482805140c58e Mon Sep 17 00:00:00 2001 From: amevarashi Date: Wed, 23 Mar 2022 21:27:06 +0500 Subject: [PATCH 5/5] Optimized gizmo injection --- .../RJW_Menstruation/Patch/GetGizmos.cs | 36 ++++++------------- .../SexperienceModule/Patch/GetGizmos.cs | 10 +++--- 2 files changed, 15 insertions(+), 31 deletions(-) diff --git a/1.3/source/RJW_Menstruation/RJW_Menstruation/Patch/GetGizmos.cs b/1.3/source/RJW_Menstruation/RJW_Menstruation/Patch/GetGizmos.cs index 0387438..1ef18f2 100644 --- a/1.3/source/RJW_Menstruation/RJW_Menstruation/Patch/GetGizmos.cs +++ b/1.3/source/RJW_Menstruation/RJW_Menstruation/Patch/GetGizmos.cs @@ -17,43 +17,27 @@ namespace RJW_Menstruation return; } - List gizmoList = __result.ToList(); - - if (__instance.ShouldShowWombGizmo()) { - AddWombGizmos(__instance, ref gizmoList); + __result = AddWombGizmos(__instance, __result); } - - //if (Configurations.EnableWombIcon && __instance.gender == Gender.Female) - //{ - // if (!__instance.IsAnimal()) - // { - // AddWombGizmos(__instance, ref gizmoList); - // } - // else if (Configurations.EnableAnimalCycle) - // { - // AddWombGizmos(__instance, ref gizmoList); - // } - //} - - - - - __result = gizmoList; } - - private static void AddWombGizmos(Pawn __instance, ref List gizmoList) + private static IEnumerable AddWombGizmos(Pawn __instance, IEnumerable gizmos) { + foreach (Gizmo gizmo in gizmos) + yield return gizmo; + HediffComp_Menstruation comp = __instance.GetMenstruationComp(); - if (comp != null) AddMenstruationGizmos(__instance, comp, ref gizmoList); + if (comp == null) yield break; + foreach (Gizmo gizmo in GetMenstruationGizmos(__instance, comp)) + yield return gizmo; } - private static void AddMenstruationGizmos(Pawn pawn, HediffComp_Menstruation comp, ref List gizmolist) + public static List GetMenstruationGizmos(Pawn pawn, HediffComp_Menstruation comp) { - gizmolist.Add(CreateGizmo_WombStatus(pawn, comp)); + return new List() { CreateGizmo_WombStatus(pawn, comp) }; } diff --git a/1.3/source/RJW_Menstruation/SexperienceModule/Patch/GetGizmos.cs b/1.3/source/RJW_Menstruation/SexperienceModule/Patch/GetGizmos.cs index 70640d3..735fb0b 100644 --- a/1.3/source/RJW_Menstruation/SexperienceModule/Patch/GetGizmos.cs +++ b/1.3/source/RJW_Menstruation/SexperienceModule/Patch/GetGizmos.cs @@ -13,15 +13,15 @@ using HarmonyLib; namespace RJW_Menstruation.Sexperience { - [HarmonyPatch(typeof(Pawn_GetGizmos), "AddMenstruationGizmos")] + [HarmonyPatch(typeof(Pawn_GetGizmos), nameof(Pawn_GetGizmos.GetMenstruationGizmos))] public static class GetGizmos_Patch { - public static void Postfix(Pawn pawn, HediffComp_Menstruation comp, ref List gizmolist) + public static void Postfix(Pawn pawn, HediffComp_Menstruation comp, ref List __result) { - gizmolist.Add(CreateGizmo_GatherCum(pawn, comp)); + __result.Add(CreateGizmo_GatherCum(comp)); } - - private static Gizmo CreateGizmo_GatherCum(Pawn pawn, HediffComp_Menstruation comp) + + private static Gizmo CreateGizmo_GatherCum(HediffComp_Menstruation comp) { Texture2D icon = TextureCache.GatherCum_Bucket; string label = Keyed.RS_GatherCum;