Have the babies track their fathers during pregnancy

This commit is contained in:
lutepickle 2023-01-09 08:50:37 -08:00
parent 638b9f4611
commit d34c96315a
2 changed files with 22 additions and 6 deletions

Binary file not shown.

View File

@ -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<Hediff_LaborPushing>().TryGetComp<HediffComp_PregeneratedBabies>();
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;
}
}