From 28461178815a41c783ab6e02c3ac9bed71e3fa5e Mon Sep 17 00:00:00 2001
From: lutepickle <28810-lutepickle@users.noreply.gitgud.io>
Date: Thu, 3 Nov 2022 19:01:50 -0700
Subject: [PATCH] Track the changing hediff through pregnancy and labor
---
.../RJW_Menstruation/Patch/Biotech_Patch.cs | 50 +++++++++++++++++++
.../RJW_Menstruation/RJW_Menstruation.csproj | 1 +
changelogs.txt | 1 +
3 files changed, 52 insertions(+)
create mode 100644 1.4/source/RJW_Menstruation/RJW_Menstruation/Patch/Biotech_Patch.cs
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
new file mode 100644
index 0000000..52714ea
--- /dev/null
+++ b/1.4/source/RJW_Menstruation/RJW_Menstruation/Patch/Biotech_Patch.cs
@@ -0,0 +1,50 @@
+using HarmonyLib;
+using RimWorld;
+using Verse;
+
+namespace RJW_Menstruation
+{
+ [HarmonyPatch(typeof(Hediff_Pregnant), "Miscarry")]
+ public class Miscarry_Patch
+ {
+ public static void Postfix(Hediff_Pregnant __instance)
+ {
+ HediffComp_Menstruation comp = __instance.GetMenstruationCompFromPregnancy();
+ if (comp == null) return;
+ comp.Pregnancy = null;
+ }
+ }
+
+ [HarmonyPatch(typeof(Hediff_Pregnant), nameof(Hediff_Pregnant.StartLabor))]
+ public class StartLabor_Patch
+ {
+ public static void Postfix(Hediff_Pregnant __instance)
+ {
+ HediffComp_Menstruation comp = __instance.GetMenstruationCompFromPregnancy();
+ if (comp == null) return;
+ comp.Pregnancy = __instance.pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.PregnancyLabor);
+ }
+ }
+
+ [HarmonyPatch(typeof(Hediff_Labor), nameof(Hediff_Labor.PreRemoved))]
+ public class Labor_PreRemoved_Patch
+ {
+ public static void PostFix(Hediff_Labor __instance)
+ {
+ HediffComp_Menstruation comp = __instance.GetMenstruationCompFromPregnancy();
+ if (comp == null) return;
+ comp.Pregnancy = __instance.pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.PregnancyLaborPushing);
+ }
+ }
+
+ [HarmonyPatch(typeof(Hediff_LaborPushing), nameof(Hediff_LaborPushing.PreRemoved))]
+ public class LaborPushing_PreRemoved_Patch
+ {
+ public static void PostFix(Hediff_LaborPushing __instance)
+ {
+ HediffComp_Menstruation comp = __instance.GetMenstruationCompFromPregnancy();
+ if (comp == null) return;
+ comp.Pregnancy = null;
+ }
+ }
+}
\ No newline at end of file
diff --git a/1.4/source/RJW_Menstruation/RJW_Menstruation/RJW_Menstruation.csproj b/1.4/source/RJW_Menstruation/RJW_Menstruation/RJW_Menstruation.csproj
index 35f0a1c..22ab246 100644
--- a/1.4/source/RJW_Menstruation/RJW_Menstruation/RJW_Menstruation.csproj
+++ b/1.4/source/RJW_Menstruation/RJW_Menstruation/RJW_Menstruation.csproj
@@ -70,6 +70,7 @@
+
diff --git a/changelogs.txt b/changelogs.txt
index 5734acd..63db02c 100644
--- a/changelogs.txt
+++ b/changelogs.txt
@@ -1,5 +1,6 @@
Version 1.0.8.1
- Added the option for humans to start Biotech pregnancies if the DLC is enabled. If set, non-humans will use the old multiple pregnancy instead.
+ - Properly track biotech pregnancy through labor.
Version 1.0.8.0
- Support for RimWorld 1.4. All future changes to Menstruation will only be for Rimworld 1.4.