Better anti-prune algo. Also won't prune pawns with sperm/egg in a player faction/prisoner womb

This commit is contained in:
lutepickle 2022-06-03 12:02:44 -07:00
parent b814412eb0
commit 961e7f7b73
4 changed files with 26 additions and 28 deletions

Binary file not shown.

View file

@ -178,15 +178,6 @@ 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
@ -428,14 +419,14 @@ namespace RJW_Menstruation
return -1;
}
}
public bool IsFertilizedBy(Pawn pawn)
public IEnumerable<Pawn> GetCummersAndFertilizers()
{
if (eggs.NullOrEmpty()) return false;
foreach (Egg egg in eggs)
{
if (egg.fertilizer == pawn) return true;
}
return false;
if (!cums.NullOrEmpty())
foreach (Cum cum in cums)
yield return cum.pawn;
if (!eggs.NullOrEmpty())
foreach (Egg egg in eggs)
yield return egg.fertilizer;
}
public bool IsEggExist
{

View file

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using HarmonyLib;
using Verse;
using RimWorld;
@ -9,23 +10,28 @@ namespace RJW_Menstruation.Patch
[HarmonyPatch(typeof(WorldPawnGC), "GetCriticalPawnReason")]
public static class GetCriticalPawnReason_Patch
{
readonly public static HashSet<Pawn> cummedPawns = new HashSet<Pawn>();
public static void Postfix(ref string __result, Pawn pawn)
{
if (!__result.NullOrEmpty()) return;
foreach(Pawn wombHaver in PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_OfPlayerFaction)
if (cummedPawns.Contains(pawn))
__result = "Has cum or fertilized egg in a womb";
}
}
[HarmonyPatch(typeof(WorldPawnGC), "AccumulatePawnGCData")]
public static class PawnGCPass_Patch
{
public static void Prefix()
{
GetCriticalPawnReason_Patch.cummedPawns.Clear();
// foreach(Pawn p in PawnsFinder.All_AliveOrDead)
foreach(Pawn p in PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_OfPlayerFaction.Union(PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_PrisonersOfColony))
{
HediffComp_Menstruation comp = wombHaver.GetMenstruationComp();
HediffComp_Menstruation comp = p.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;
}
GetCriticalPawnReason_Patch.cummedPawns.UnionWith(comp.GetCummersAndFertilizers());
}
}
}

View file

@ -4,6 +4,7 @@ Version 1.0.6.5
- Add a brief description when mousing over the current phase in the womb dialog.
- Add an ovary image to the womb status dialog (but not the little icon) when ovulation is imminent or occuring.
- Redone algorithm for paternity selecton upon an egg being fertilized, to make for a fairer contest when there is lots of sperm from multiple people.
- NPC pawns with cum inside a pawn of your faction (or a prisoner you're holding) won't be removed by the GC at least until that cum is gone.
Version 1.0.6.4
- Fix a bug with pawns not being generated.