Refactor adding eggs to existing pregnancy, fix implanting eggs in a non-biotech pregnancy when set to biotech (e.g. animals)

This commit is contained in:
lutepickle 2023-10-22 16:37:50 -07:00
parent d5043c0b62
commit 1ce69571f0
2 changed files with 31 additions and 31 deletions

Binary file not shown.

View file

@ -1418,37 +1418,7 @@ namespace RJW_Menstruation
try try
{ {
if (Configurations.Debug) Log.Message($"Implanting fertilized egg of {Pawn} into {parent}, father {egg.fertilizer}"); if (Configurations.Debug) Log.Message($"Implanting fertilized egg of {Pawn} into {parent}, father {egg.fertilizer}");
if (pregnancy != null) if (pregnancy == null)
{
if (Configurations.PregnancySource == Configurations.PregnancyType.Biotech && Configurations.EnableBiotechTwins && Configurations.EnableHeteroOvularTwins)
{
if (Configurations.Debug) Log.Message($"Adding to existing Biotech pregnancy {pregnancy}");
HediffComp_PregeneratedBabies comp = pregnancy.TryGetComp<HediffComp_PregeneratedBabies>();
if (comp == null) Log.Warning($"Trying to add Biotech egg to {Pawn}'s pregnancy without a pregenerated baby comp: {pregnancy}");
else
{
comp.AddNewBaby(Pawn, egg.fertilizer);
pregnant = true;
deadeggs.Add(egg);
}
}
else if (Configurations.PregnancySource == Configurations.PregnancyType.MultiplePregnancy && Configurations.EnableHeteroOvularTwins)
{
if (pregnancy is Hediff_MultiplePregnancy h)
{
if (Configurations.Debug) Log.Message($"Adding to existing pregnancy {h}");
h.AddNewBaby(Pawn, egg.fertilizer);
}
pregnant = true;
deadeggs.Add(egg);
}
else
{
pregnant = true;
break;
}
}
else
{ {
Configurations.PregnancyType usePregnancy = xxx.is_human(Pawn) ? Configurations.PregnancySource : Configurations.PregnancyType.MultiplePregnancy; Configurations.PregnancyType usePregnancy = xxx.is_human(Pawn) ? Configurations.PregnancySource : Configurations.PregnancyType.MultiplePregnancy;
switch (usePregnancy) switch (usePregnancy)
@ -1489,6 +1459,36 @@ namespace RJW_Menstruation
rjw_preg.p_end_tick -= egg.ticksSinceFertilization / Configurations.CycleAcceleration; rjw_preg.p_end_tick -= egg.ticksSinceFertilization / Configurations.CycleAcceleration;
} }
} }
else
{
switch (pregnancy)
{
case Hediff_Pregnant vanillaPreg: // Not going to do the labor ones
if (!Configurations.EnableBiotechTwins || !Configurations.EnableHeteroOvularTwins) goto default;
if (Configurations.Debug) Log.Message($"Adding to existing Biotech pregnancy {pregnancy.GetUniqueLoadID()}");
HediffComp_PregeneratedBabies comp = pregnancy.TryGetComp<HediffComp_PregeneratedBabies>();
if (comp == null) Log.Warning($"Trying to add Biotech egg to {Pawn}'s pregnancy without a pregenerated baby comp: {pregnancy.GetUniqueLoadID()}");
else
{
comp.AddNewBaby(Pawn, egg.fertilizer);
pregnant = true;
deadeggs.Add(egg);
}
break;
case Hediff_MultiplePregnancy multiPreg:
if (!Configurations.EnableHeteroOvularTwins) goto default;
if (Configurations.Debug) Log.Message($"Adding to existing pregnancy {multiPreg.GetUniqueLoadID()}");
multiPreg.AddNewBaby(Pawn, egg.fertilizer);
pregnant = true;
deadeggs.Add(egg);
break;
case Hediff_BasePregnancy _:
default:
pregnant = true;
deadeggs.Add(egg);
break;
}
}
} }
catch (Exception ex) catch (Exception ex)
{ {