diff --git a/1.5/Assemblies/RJW_Menstruation.dll b/1.5/Assemblies/RJW_Menstruation.dll index 463815e..517441c 100644 Binary files a/1.5/Assemblies/RJW_Menstruation.dll and b/1.5/Assemblies/RJW_Menstruation.dll differ diff --git a/1.5/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_PregeneratedBabies.cs b/1.5/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_PregeneratedBabies.cs index 505d9be..ef877e1 100644 --- a/1.5/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_PregeneratedBabies.cs +++ b/1.5/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_PregeneratedBabies.cs @@ -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 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().TryGetComp(); 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 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().TryGetComp(); 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(); diff --git a/1.5/source/RJW_Menstruation/RJW_Menstruation/HediffComps/MenstruationUtility.cs b/1.5/source/RJW_Menstruation/RJW_Menstruation/HediffComps/MenstruationUtility.cs index a8e873f..db4bd06 100644 --- a/1.5/source/RJW_Menstruation/RJW_Menstruation/HediffComps/MenstruationUtility.cs +++ b/1.5/source/RJW_Menstruation/RJW_Menstruation/HediffComps/MenstruationUtility.cs @@ -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 { diff --git a/1.5/source/RJW_Menstruation/RJW_Menstruation/PregnancyCommon.cs b/1.5/source/RJW_Menstruation/RJW_Menstruation/PregnancyCommon.cs index c572dfc..6221a81 100644 --- a/1.5/source/RJW_Menstruation/RJW_Menstruation/PregnancyCommon.cs +++ b/1.5/source/RJW_Menstruation/RJW_Menstruation/PregnancyCommon.cs @@ -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; diff --git a/1.5/source/RJW_Menstruation/RJW_Menstruation/Utility.cs b/1.5/source/RJW_Menstruation/RJW_Menstruation/Utility.cs index 0020d86..dfa13d5 100644 --- a/1.5/source/RJW_Menstruation/RJW_Menstruation/Utility.cs +++ b/1.5/source/RJW_Menstruation/RJW_Menstruation/Utility.cs @@ -178,7 +178,7 @@ namespace RJW_Menstruation } } HediffComp_PregeneratedBabies babiescomp = comp.Pregnancy.TryGetComp(); - return babiescomp?.babies?.FirstOrDefault(); + return babiescomp?.PeekBaby(); } public static void DrawBreastIcon(this Pawn pawn, Rect rect)