Don't prune pawns with sperm or a fertilized egg in a colonist's womb

This commit is contained in:
lutepickle 2022-06-03 11:04:39 -07:00
parent 5e818ab879
commit b814412eb0
4 changed files with 51 additions and 2 deletions

Binary file not shown.

View file

@ -178,6 +178,15 @@ namespace RJW_Menstruation
return res / Props.maxCumCapacity;
}
}
public bool HasCumInside(Pawn pawn)
{
if (cums.NullOrEmpty()) return false;
foreach (Cum cum in cums)
{
if(cum.pawn == pawn) return true;
}
return false;
}
public float CumCapacity
{
get
@ -419,6 +428,15 @@ namespace RJW_Menstruation
return -1;
}
}
public bool IsFertilizedBy(Pawn pawn)
{
if (eggs.NullOrEmpty()) return false;
foreach (Egg egg in eggs)
{
if (egg.fertilizer == pawn) return true;
}
return false;
}
public bool IsEggExist
{
get
@ -1062,8 +1080,6 @@ namespace RJW_Menstruation
}
}
public void SetEstrus(int days)
{
HediffDef estrusdef = Props.concealedEstrus ? VariousDefOf.Hediff_Estrus_Concealed : VariousDefOf.Hediff_Estrus;

View file

@ -0,0 +1,32 @@
using System.Collections.Generic;
using HarmonyLib;
using Verse;
using RimWorld;
using RimWorld.Planet;
namespace RJW_Menstruation.Patch
{
[HarmonyPatch(typeof(WorldPawnGC), "GetCriticalPawnReason")]
public static class GetCriticalPawnReason_Patch
{
public static void Postfix(ref string __result, Pawn pawn)
{
if (!__result.NullOrEmpty()) return;
foreach(Pawn wombHaver in PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_OfPlayerFaction)
{
HediffComp_Menstruation comp = wombHaver.GetMenstruationComp();
if (comp is null) continue;
if (comp.IsFertilizedBy(pawn))
{
__result = $"Fertilizing {wombHaver}'s egg";
return;
}
if (comp.HasCumInside(pawn))
{
__result = $"Cum inside {wombHaver}'s womb";
return;
}
}
}
}
}

View file

@ -66,6 +66,7 @@
<Compile Include="HediffComps\HediffComp_InducedOvulator.cs" />
<Compile Include="HediffComps\MenstruationUtility.cs" />
<Compile Include="IngestionOutcomeDoers.cs" />
<Compile Include="Patch\GC_Patch.cs" />
<Compile Include="Recipe_Surgery.cs" />
<Compile Include="UI\Dialog_HybridCustom.cs" />
<Compile Include="UI\Dialog_WombStatus.cs" />