mirror of
https://gitgud.io/lutepickle/rjw_menstruation.git
synced 2024-08-14 22:46:52 +00:00
Check for null pregnancy before trying to miscarry it on postpostremoved
This commit is contained in:
parent
89248897f0
commit
6344338ee2
2 changed files with 12 additions and 2 deletions
Binary file not shown.
|
@ -624,7 +624,7 @@ namespace RJW_Menstruation
|
|||
Log.Warning($"Attempted to remove menstruation comp from wrong pawn ({Pawn}).");
|
||||
return;
|
||||
}
|
||||
if (!(pregnancy is Hediff_MechanoidPregnancy))
|
||||
if (pregnancy != null && !(pregnancy is Hediff_MechanoidPregnancy))
|
||||
pregnancy.Miscarry();
|
||||
base.CompPostPostRemoved();
|
||||
}
|
||||
|
@ -1176,22 +1176,26 @@ namespace RJW_Menstruation
|
|||
continue;
|
||||
else if (egg.fertilizer == null)
|
||||
{
|
||||
if (Configurations.Debug) Log.Message($"Could not implant {Pawn}'s egg due to null father");
|
||||
deadeggs.Add(egg);
|
||||
continue;
|
||||
}
|
||||
else if (Pawn.health.hediffSet.GetHediffs<Hediff_InsectEgg>().Any() || pregnancy is Hediff_MechanoidPregnancy)
|
||||
{
|
||||
if (Configurations.Debug) Log.Message($"Could not implant {Pawn}'s egg due to insect or mechanoid pregnancy");
|
||||
deadeggs.Add(egg);
|
||||
continue;
|
||||
}
|
||||
else if (Rand.Range(0.0f, 1.0f) <= Configurations.ImplantationChance * ImplantFactor * InterspeciesImplantFactor(egg.fertilizer))
|
||||
{
|
||||
if (Configurations.Debug) Log.Message($"Implanting fertilized egg of {Pawn}, father {egg.fertilizer}");
|
||||
if (pregnancy != null)
|
||||
{
|
||||
if (Configurations.UseMultiplePregnancy && Configurations.EnableHeteroOvularTwins)
|
||||
{
|
||||
if (pregnancy is Hediff_MultiplePregnancy h)
|
||||
{
|
||||
if (Configurations.Debug) Log.Message($"Adding to existing pregnancy");
|
||||
h.AddNewBaby(Pawn, egg.fertilizer);
|
||||
}
|
||||
pregnant = true;
|
||||
|
@ -1207,6 +1211,7 @@ namespace RJW_Menstruation
|
|||
{
|
||||
if (!Configurations.UseMultiplePregnancy)
|
||||
{
|
||||
if (Configurations.Debug) Log.Message($"Creating new base RJW pregnancy");
|
||||
PregnancyHelper.PregnancyDecider(Pawn, egg.fertilizer);
|
||||
// I hate having to do this, but it gets the newest pregnancy
|
||||
pregnancy = Pawn.health.hediffSet.GetHediffs<Hediff_BasePregnancy>().MaxBy(hediff => hediff.loadID);
|
||||
|
@ -1215,6 +1220,7 @@ namespace RJW_Menstruation
|
|||
}
|
||||
else
|
||||
{
|
||||
if (Configurations.Debug) Log.Message($"Creating new pregnancy");
|
||||
pregnancy = Hediff_BasePregnancy.Create<Hediff_MultiplePregnancy>(Pawn, egg.fertilizer);
|
||||
pregnant = true;
|
||||
deadeggs.Add(egg);
|
||||
|
@ -1222,7 +1228,11 @@ namespace RJW_Menstruation
|
|||
}
|
||||
|
||||
}
|
||||
else deadeggs.Add(egg);
|
||||
else
|
||||
{
|
||||
if (Configurations.Debug) Log.Message($"Fertilized egg of {Pawn} failed to implant (father {egg.fertilizer})");
|
||||
deadeggs.Add(egg);
|
||||
}
|
||||
}
|
||||
|
||||
if (pregnant && (!Configurations.UseMultiplePregnancy || !Configurations.EnableHeteroOvularTwins))
|
||||
|
|
Loading…
Reference in a new issue