2022-11-04 02:01:50 +00:00
|
|
|
|
using HarmonyLib;
|
2022-11-04 14:08:59 +00:00
|
|
|
|
using System.Linq;
|
2022-11-04 02:01:50 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-11-04 14:08:59 +00:00
|
|
|
|
|
|
|
|
|
// Prevents a pregnancy from going into labor if another pregnancy already is
|
|
|
|
|
[HarmonyPatch(typeof(Hediff_Pregnant), nameof(Hediff_Pregnant.GestationProgress), MethodType.Getter)]
|
|
|
|
|
public class Hediff_Pregnant_GestationProgess_Patch
|
|
|
|
|
{
|
|
|
|
|
public static void PostFix(Hediff_Pregnant __instance, ref float __result)
|
|
|
|
|
{
|
|
|
|
|
if (__result < 1f) return;
|
|
|
|
|
Pawn pawn = __instance.pawn;
|
|
|
|
|
if (pawn.health.hediffSet.hediffs.Any(hediff => hediff.def == HediffDefOf.PregnancyLabor || hediff.def == HediffDefOf.PregnancyLaborPushing))
|
|
|
|
|
__result = 0.999f;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-11-04 02:01:50 +00:00
|
|
|
|
}
|