diff --git a/1.4/Assemblies/RJW_Menstruation.dll b/1.4/Assemblies/RJW_Menstruation.dll index ec97165..4179a95 100644 Binary files a/1.4/Assemblies/RJW_Menstruation.dll and b/1.4/Assemblies/RJW_Menstruation.dll differ diff --git a/1.4/MilkModule/Assemblies/MilkModule.dll b/1.4/MilkModule/Assemblies/MilkModule.dll index aaf7777..7c22131 100644 Binary files a/1.4/MilkModule/Assemblies/MilkModule.dll and b/1.4/MilkModule/Assemblies/MilkModule.dll differ diff --git a/1.4/source/RJW_Menstruation/RJW_Menstruation/Hediff_MultiplePregnancy.cs b/1.4/source/RJW_Menstruation/RJW_Menstruation/Hediff_MultiplePregnancy.cs index 8abaf18..1142ff4 100644 --- a/1.4/source/RJW_Menstruation/RJW_Menstruation/Hediff_MultiplePregnancy.cs +++ b/1.4/source/RJW_Menstruation/RJW_Menstruation/Hediff_MultiplePregnancy.cs @@ -439,6 +439,20 @@ namespace RJW_Menstruation firstbaby = baby; request.FixedGender = baby.gender; request.ForcedEndogenes = baby.genes?.Endogenes.Select(gene => gene.def).ToList(); + if (GeneUtility.SameHeritableXenotype(mother, father) && mother.genes.UniqueXenotype) + { + baby.genes.xenotypeName = mother.genes.xenotypeName; + baby.genes.iconDef = mother.genes.iconDef; + } + if (baby.genes != null) + { + baby.genes.SetXenotypeDirect(BabyXenoTypeDecider(mother, father, out bool hybridBaby)); + if(hybridBaby) + { + baby.genes.hybrid = true; + baby.genes.xenotypeName = "Hybrid".Translate(); + } + } } else { @@ -451,6 +465,14 @@ namespace RJW_Menstruation baby.story.bodyType = firstbaby.story.bodyType; } + if (baby.genes != null) + { + baby.genes.SetXenotypeDirect(firstbaby.genes.Xenotype); + baby.genes.xenotypeName = firstbaby.genes.xenotypeName; + baby.genes.iconDef = firstbaby.genes.iconDef; + baby.genes.hybrid = firstbaby.genes.hybrid; + } + if (baby.IsHAR()) HARCompatibility.CopyHARProperties(baby, firstbaby); //if (Configurations.AnimalGeneticsActivated) @@ -621,6 +643,39 @@ namespace RJW_Menstruation } + public XenotypeDef BabyXenoTypeDecider(Pawn mother, Pawn father, out bool hybrid) + { + hybrid = false; + bool hybridMother = mother?.genes?.hybrid ?? false; + bool hybridFather = father?.genes?.hybrid ?? false; + if (hybridMother && hybridFather) + { + hybrid = true; + return null; + } + XenotypeDef motherInheritableXenotype = mother?.genes?.Xenotype; + XenotypeDef fatherInheritableXenotype = father?.genes?.Xenotype; + if (!motherInheritableXenotype.inheritable) motherInheritableXenotype = null; + if (!fatherInheritableXenotype.inheritable) fatherInheritableXenotype = null; + + // If they're the same (or both null) + if (motherInheritableXenotype == fatherInheritableXenotype) + { + // Both null, but one's a hybrid + if (motherInheritableXenotype == null && (hybridMother || hybridFather)) + hybrid = true; + + return motherInheritableXenotype; + } + + // If one is null and the other isn't + if ((motherInheritableXenotype == null) != (fatherInheritableXenotype == null)) return motherInheritableXenotype ?? fatherInheritableXenotype; + + // So two different inheritable ones + hybrid = true; + return null; + } + public PawnKindDef GetHybrid(Pawn first, Pawn second) { PawnKindDef res = null; diff --git a/1.4/source/RJW_Menstruation/RJW_Menstruation/Patch/Biotech_Patch.cs b/1.4/source/RJW_Menstruation/RJW_Menstruation/Patch/Biotech_Patch.cs new file mode 100644 index 0000000..2257c55 --- /dev/null +++ b/1.4/source/RJW_Menstruation/RJW_Menstruation/Patch/Biotech_Patch.cs @@ -0,0 +1,64 @@ +using HarmonyLib; +using System.Linq; +using RimWorld; +using Verse; + +namespace RJW_Menstruation +{ + [HarmonyPatch(typeof(Hediff_Pregnant), "Miscarry")] + public class Miscarry_Patch + { + public static void Postfix(Hediff_Pregnant __instance) + { + HediffComp_Menstruation comp = __instance.GetMenstruationCompFromPregnancy(); + if (comp == null) return; + comp.Pregnancy = null; + } + } + + [HarmonyPatch(typeof(Hediff_Pregnant), nameof(Hediff_Pregnant.StartLabor))] + public class StartLabor_Patch + { + public static void Postfix(Hediff_Pregnant __instance) + { + HediffComp_Menstruation comp = __instance.GetMenstruationCompFromPregnancy(); + if (comp == null) return; + comp.Pregnancy = __instance.pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.PregnancyLabor); + } + } + + [HarmonyPatch(typeof(Hediff_Labor), nameof(Hediff_Labor.PreRemoved))] + public class Labor_PreRemoved_Patch + { + public static void PostFix(Hediff_Labor __instance) + { + HediffComp_Menstruation comp = __instance.GetMenstruationCompFromPregnancy(); + if (comp == null) return; + comp.Pregnancy = __instance.pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.PregnancyLaborPushing); + } + } + + [HarmonyPatch(typeof(Hediff_LaborPushing), nameof(Hediff_LaborPushing.PreRemoved))] + public class LaborPushing_PreRemoved_Patch + { + public static void PostFix(Hediff_LaborPushing __instance) + { + HediffComp_Menstruation comp = __instance.GetMenstruationCompFromPregnancy(); + if (comp == null) return; + comp.Pregnancy = null; + } + } + + // Prevents a pregnancy from going into labor if another pregnancy already is + [HarmonyPatch(typeof(Hediff_Pregnant), nameof(Hediff_Pregnant.GestationProgress), MethodType.Getter)] + public class Hediff_Pregnant_GestationProgess_Patch + { + public static void PostFix(Hediff_Pregnant __instance, ref float __result) + { + if (__result < 1f) return; + Pawn pawn = __instance.pawn; + if (pawn.health.hediffSet.hediffs.Any(hediff => hediff.def == HediffDefOf.PregnancyLabor || hediff.def == HediffDefOf.PregnancyLaborPushing)) + __result = 0.999f; + } + } +} \ No newline at end of file diff --git a/1.4/source/RJW_Menstruation/RJW_Menstruation/RJW_Menstruation.csproj b/1.4/source/RJW_Menstruation/RJW_Menstruation/RJW_Menstruation.csproj index 35f0a1c..22ab246 100644 --- a/1.4/source/RJW_Menstruation/RJW_Menstruation/RJW_Menstruation.csproj +++ b/1.4/source/RJW_Menstruation/RJW_Menstruation/RJW_Menstruation.csproj @@ -70,6 +70,7 @@ + diff --git a/changelogs.txt b/changelogs.txt index 5734acd..0b61fda 100644 --- a/changelogs.txt +++ b/changelogs.txt @@ -1,5 +1,8 @@ Version 1.0.8.1 - Added the option for humans to start Biotech pregnancies if the DLC is enabled. If set, non-humans will use the old multiple pregnancy instead. + - Babies conceived through the multiple pregnancy option will now properly inherit xenotypes. + - Properly track biotech pregnancy through labor. + - A biotech pregnancy will pause before going into labor if another womb already is in labor. Version 1.0.8.0 - Support for RimWorld 1.4. All future changes to Menstruation will only be for Rimworld 1.4.