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 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() public Pawn PopBaby()
@ -157,7 +172,7 @@ namespace RJW_Menstruation
// Easier to work out twins that way // Easier to work out twins that way
// From e.g. a vat // 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); return PawnGenerator.GeneratePawn(request);
// No babies found. Could be an unmodified pregnancy // 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) 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>(); HediffComp_PregeneratedBabies comp = mother.health.hediffSet.GetFirstHediff<Hediff_LaborPushing>().TryGetComp<HediffComp_PregeneratedBabies>();
if (comp?.HasBaby ?? false) if (comp?.HasBaby ?? false)
@ -210,7 +225,7 @@ namespace RJW_Menstruation
float birthQuality = PregnancyUtility.GetBirthQualityFor(mother); float birthQuality = PregnancyUtility.GetBirthQualityFor(mother);
do do
{ {
Pawn baby = comp.babies[0]; Pawn baby = comp.PeekBaby();
Pawn thisFather = baby.GetFather() ?? father; Pawn thisFather = baby.GetFather() ?? father;
baby.relations.ClearAllRelations(); // To keep ApplyBirthOutcome from erroring when it tries to set up relations 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) 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>(); HediffComp_PregeneratedBabies comp = mother.health.hediffSet.GetFirstHediff<Hediff_LaborPushing>().TryGetComp<HediffComp_PregeneratedBabies>();
if (comp?.HasBaby ?? false) 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 // Though even if it does, that's probably okay. More babies more memories after all
do do
{ {
Pawn baby = comp.babies[0]; Pawn baby = comp.PeekBaby();
Pawn thisFather = baby.GetFather() ?? father; Pawn thisFather = baby.GetFather() ?? father;
baby.relations.ClearAllRelations(); baby.relations.ClearAllRelations();

View file

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

View file

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

View file

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