diff --git a/1.4/Assemblies/RJW_Menstruation.dll b/1.4/Assemblies/RJW_Menstruation.dll index 7842531..bd3e682 100644 Binary files a/1.4/Assemblies/RJW_Menstruation.dll and b/1.4/Assemblies/RJW_Menstruation.dll differ diff --git a/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_PregeneratedBabies.cs b/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_PregeneratedBabies.cs index 53171f8..5f94980 100644 --- a/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_PregeneratedBabies.cs +++ b/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_PregeneratedBabies.cs @@ -81,8 +81,6 @@ namespace RJW_Menstruation allowDowned: true, fixedLastName: (string)RandomLastName.Invoke(null, new object[] { mother, mother, xxx.is_human(father) ? father : null }), forceNoIdeo: true, - // Kill on bad positivity in the post-birth - // forceDead: positivityIndex == -1 forcedEndogenes: PregnancyUtility.GetInheritedGenes(father, mother), forcedXenotype: XenotypeDefOf.Baseliner, developmentalStages: DevelopmentalStage.Newborn @@ -135,6 +133,13 @@ namespace RJW_Menstruation } } babies.Add(baby); + // These get cleared out later, but setting the relations now will help keep track of things. + baby.SetMother(mother); + if (mother != father) + { + if (father.gender != Gender.Female) baby.SetFather(father); + else baby.relations.AddDirectRelation(PawnRelationDefOf.Parent, father); + } } } } @@ -195,10 +200,14 @@ namespace RJW_Menstruation OutcomeChance thisOutcome = outcome; Precept_Ritual precept_Ritual = (Precept_Ritual)comp.Pawn.Ideo.GetPrecept(PreceptDefOf.ChildBirth); float birthQuality = PregnancyUtility.GetBirthQualityFor(mother); - do { - PregnancyUtility.ApplyBirthOutcome(thisOutcome, quality, ritual, genes, geneticMother, birtherThing, father, doctor, lordJobRitual, assignments); + Pawn baby = comp.babies[0]; + Pawn thisFather = baby.GetFather(); + if (thisFather == null) thisFather = father; + baby.relations.ClearAllRelations(); // To keep ApplyBirthOutcome from erroring when it tries to set up relations + + PregnancyUtility.ApplyBirthOutcome(thisOutcome, quality, ritual, genes, geneticMother, birtherThing, thisFather, doctor, lordJobRitual, assignments); // No more babies if mom dies halfway through. Unrealistic maybe, but saves a lot of headache in ApplyBirthOutcome if (mother.health.Dead) break; thisOutcome = ((RitualOutcomeEffectWorker_ChildBirth)precept_Ritual.outcomeEffect).GetOutcome(birthQuality, null); @@ -226,7 +235,6 @@ namespace RJW_Menstruation } } - // Much the same as the other one [HarmonyPatch(typeof(RitualOutcomeEffectWorker_ChildBirth), nameof (RitualOutcomeEffectWorker_ChildBirth.Apply))] public static class Ritual_ChildBirth_Apply_Patch { @@ -237,16 +245,24 @@ namespace RJW_Menstruation HediffComp_PregeneratedBabies comp = mother.health.hediffSet.GetFirstHediff().TryGetComp(); if (comp?.HasBaby ?? false) { + // Much the same as the other one + // Don't reroll the outcome every time, I think // This is all one ritual, so every baby has the same ritual outcome // I don't think this will add the ritual memory every time? // Though even if it does, that's probably okay. More babies more memories after all do { - PregnancyUtility.ApplyBirthOutcome(outcome, quality, ritual, genes, geneticMother, birtherThing, father, doctor, lordJobRitual, assignments); + Pawn baby = comp.babies[0]; + Pawn thisFather = baby.GetFather(); + if (thisFather == null) thisFather = father; + baby.relations.ClearAllRelations(); + + PregnancyUtility.ApplyBirthOutcome(outcome, quality, ritual, genes, geneticMother, birtherThing, thisFather, doctor, lordJobRitual, assignments); if (mother.health.Dead) break; } while (comp.HasBaby); + // The ritual version doesn't use the return value, either return null; } }