From 0154f89438d68d2e71d689ac6294262631e16fc2 Mon Sep 17 00:00:00 2001
From: lutepickle <28810-lutepickle@users.noreply.gitgud.io>
Date: Thu, 10 Nov 2022 21:25:07 -0800
Subject: [PATCH] Don't allow ovum extraction for menopausal pawns
---
.../English/Keyed/RJW_Menstruation.xml | 3 ++-
.../RJW_Menstruation/Patch/Biotech_Patch.cs | 24 +++++++++++++++++++
.../RJW_Menstruation/Translations.cs | 2 ++
3 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/1.4/Languages/English/Keyed/RJW_Menstruation.xml b/1.4/Languages/English/Keyed/RJW_Menstruation.xml
index d8d471e..8ff0f64 100644
--- a/1.4/Languages/English/Keyed/RJW_Menstruation.xml
+++ b/1.4/Languages/English/Keyed/RJW_Menstruation.xml
@@ -132,6 +132,7 @@
Custom Hybrid Editor
Hybrids of {0}
When {0} breed with {1}, {2} will be born at {3} chance.
If both races have hybrid definitions for each other, the father's definition will be used.
-
+ No eggs
+
\ No newline at end of file
diff --git a/1.4/source/RJW_Menstruation/RJW_Menstruation/Patch/Biotech_Patch.cs b/1.4/source/RJW_Menstruation/RJW_Menstruation/Patch/Biotech_Patch.cs
index 2257c55..f0d80a9 100644
--- a/1.4/source/RJW_Menstruation/RJW_Menstruation/Patch/Biotech_Patch.cs
+++ b/1.4/source/RJW_Menstruation/RJW_Menstruation/Patch/Biotech_Patch.cs
@@ -2,6 +2,7 @@
using System.Linq;
using RimWorld;
using Verse;
+using System.Collections.Generic;
namespace RJW_Menstruation
{
@@ -61,4 +62,27 @@ namespace RJW_Menstruation
__result = 0.999f;
}
}
+
+ [HarmonyPatch(typeof(Recipe_ExtractOvum), nameof(Recipe_ExtractOvum.AvailableReport))]
+ public class ExtractOvum_AvailableReport_Patch
+ {
+ public static void PostFix(Thing thing, ref AcceptanceReport __result)
+ {
+ if (!__result.Accepted) return;
+ Pawn pawn = (Pawn)thing;
+ if (pawn.IsRJWPregnant())
+ {
+ __result = "CannotPregnant".Translate();
+ return;
+ }
+ List comps = pawn.GetMenstruationComps().ToList();
+ if (!comps.Any()) return;
+ if (comps.All(comp => comp.ovarypower <= 0))
+ {
+ __result = Translations.CannotNoEggs;
+ return;
+ }
+ return;
+ }
+ }
}
\ No newline at end of file
diff --git a/1.4/source/RJW_Menstruation/RJW_Menstruation/Translations.cs b/1.4/source/RJW_Menstruation/RJW_Menstruation/Translations.cs
index 973a90b..35d95c8 100644
--- a/1.4/source/RJW_Menstruation/RJW_Menstruation/Translations.cs
+++ b/1.4/source/RJW_Menstruation/RJW_Menstruation/Translations.cs
@@ -135,6 +135,8 @@ namespace RJW_Menstruation
public static readonly string Gizmo_GatherCum = "Gizmo_GatherCum".Translate();
public static readonly string FloatMenu_CleanSelf = "FloatMenu_CleanSelf".Translate();
+ public static readonly string CannotNoEggs = "CannotNoEggs".Translate();
+
public static readonly string CustomHybrid_List_Title = "CustomHybrid_List_Title".Translate();
static public string CustomHybrid_Title(string label) { return TranslatorFormattedStringExtensions.Translate("CustomHybrid_Title", label); }
static public string CustomHybrid_Tooltip(string label, string breedee, string baby, string chance) { return TranslatorFormattedStringExtensions.Translate("CustomHybrid_Tooltip", label, breedee, baby, chance); }