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

View file

@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using HarmonyLib; using HarmonyLib;
using Verse; using Verse;
using RimWorld; using RimWorld;
@ -9,23 +10,28 @@ namespace RJW_Menstruation.Patch
[HarmonyPatch(typeof(WorldPawnGC), "GetCriticalPawnReason")] [HarmonyPatch(typeof(WorldPawnGC), "GetCriticalPawnReason")]
public static class GetCriticalPawnReason_Patch public static class GetCriticalPawnReason_Patch
{ {
readonly public static HashSet<Pawn> cummedPawns = new HashSet<Pawn>();
public static void Postfix(ref string __result, Pawn pawn) public static void Postfix(ref string __result, Pawn pawn)
{ {
if (!__result.NullOrEmpty()) return; 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
{ {
HediffComp_Menstruation comp = wombHaver.GetMenstruationComp(); 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 = p.GetMenstruationComp();
if (comp is null) continue; if (comp is null) continue;
if (comp.IsFertilizedBy(pawn)) GetCriticalPawnReason_Patch.cummedPawns.UnionWith(comp.GetCummersAndFertilizers());
{
__result = $"Fertilizing {wombHaver}'s egg";
return;
}
if (comp.HasCumInside(pawn))
{
__result = $"Cum inside {wombHaver}'s womb";
return;
}
} }
} }
} }

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 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. - 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. - 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 Version 1.0.6.4
- Fix a bug with pawns not being generated. - Fix a bug with pawns not being generated.