Compare commits

...

3 commits

5 changed files with 27 additions and 9 deletions

Binary file not shown.

View file

@ -21,7 +21,22 @@ namespace RJW_Menstruation
public bool HasBaby
{
get => !babies.NullOrEmpty();
get => !babies.NullOrEmpty();
}
public int BabyCount
{
get
{
if (babies == null) return 0;
else return babies.Count;
}
}
public Pawn PeekBaby()
{
if (babies.NullOrEmpty()) return null;
else return babies.First();
}
public Pawn PopBaby()
@ -157,7 +172,7 @@ namespace RJW_Menstruation
// Easier to work out twins that way
// From e.g. a vat
if (!(birtherThing is Pawn mother) || !xxx.is_human(mother))
if (!(birtherThing is Pawn mother) || !xxx.is_human(mother) || !mother.ShouldCycle())
return PawnGenerator.GeneratePawn(request);
// No babies found. Could be an unmodified pregnancy
@ -200,7 +215,7 @@ namespace RJW_Menstruation
{
private static Thing ApplyBirthLoop(RitualOutcomePossibility outcome, float quality, Precept_Ritual ritual, List<GeneDef> genes, Pawn geneticMother, Thing birtherThing, Pawn father, Pawn doctor, LordJob_Ritual lordJobRitual, RitualRoleAssignments assignments, bool preventLetter)
{
if (birtherThing is Pawn mother)
if (birtherThing is Pawn mother && mother.ShouldCycle())
{
HediffComp_PregeneratedBabies comp = mother.health.hediffSet.GetFirstHediff<Hediff_LaborPushing>().TryGetComp<HediffComp_PregeneratedBabies>();
if (comp?.HasBaby ?? false)
@ -210,7 +225,7 @@ namespace RJW_Menstruation
float birthQuality = PregnancyUtility.GetBirthQualityFor(mother);
do
{
Pawn baby = comp.babies[0];
Pawn baby = comp.PeekBaby();
Pawn thisFather = baby.GetFather() ?? father;
baby.relations.ClearAllRelations(); // To keep ApplyBirthOutcome from erroring when it tries to set up relations
@ -256,7 +271,7 @@ namespace RJW_Menstruation
{
private static Thing ApplyBirthLoop(RitualOutcomePossibility outcome, float quality, Precept_Ritual ritual, List<GeneDef> genes, Pawn geneticMother, Thing birtherThing, Pawn father, Pawn doctor, LordJob_Ritual lordJobRitual, RitualRoleAssignments assignments)
{
if (birtherThing is Pawn mother)
if (birtherThing is Pawn mother && mother.ShouldCycle())
{
HediffComp_PregeneratedBabies comp = mother.health.hediffSet.GetFirstHediff<Hediff_LaborPushing>().TryGetComp<HediffComp_PregeneratedBabies>();
if (comp?.HasBaby ?? false)
@ -269,7 +284,7 @@ namespace RJW_Menstruation
// Though even if it does, that's probably okay. More babies more memories after all
do
{
Pawn baby = comp.babies[0];
Pawn baby = comp.PeekBaby();
Pawn thisFather = baby.GetFather() ?? father;
baby.relations.ClearAllRelations();

View file

@ -118,8 +118,8 @@ namespace RJW_Menstruation
}
else if (babiescomp?.HasBaby ?? false)
{
babydef = babiescomp.babies.First().def;
babycount = babiescomp.babies.Count;
babydef = babiescomp.PeekBaby().def;
babycount = babiescomp.BabyCount;
}
else
{

View file

@ -68,6 +68,9 @@ namespace RJW_Menstruation
PawnKindDef motherKindDef = Utility.GetRacesPawnKind(mother);
PawnKindDef fatherKindDef = Utility.GetRacesPawnKind(father);
if (motherKindDef is CreepJoinerFormKindDef) motherKindDef = PawnKindDefOf.Colonist;
if (fatherKindDef is CreepJoinerFormKindDef) fatherKindDef = PawnKindDefOf.Colonist;
PawnKindDef spawn_kind_def = motherKindDef;
int flag = 0;

View file

@ -178,7 +178,7 @@ namespace RJW_Menstruation
}
}
HediffComp_PregeneratedBabies babiescomp = comp.Pregnancy.TryGetComp<HediffComp_PregeneratedBabies>();
return babiescomp?.babies?.FirstOrDefault();
return babiescomp?.PeekBaby();
}
public static void DrawBreastIcon(this Pawn pawn, Rect rect)