Compare commits
3 Commits
483ab2f7c0
...
ea1c5794f9
Author | SHA1 | Date |
---|---|---|
lutepickle | ea1c5794f9 | |
lutepickle | 8c213c4fe6 | |
lutepickle | 2846117881 |
Binary file not shown.
Binary file not shown.
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -70,6 +70,7 @@
|
|||
<Compile Include="HediffComps\MenstruationUtility.cs" />
|
||||
<Compile Include="Hediff_Estrus.cs" />
|
||||
<Compile Include="IngestionOutcomeDoers.cs" />
|
||||
<Compile Include="Patch\Biotech_Patch.cs" />
|
||||
<Compile Include="Patch\GC_Patch.cs" />
|
||||
<Compile Include="Recipe_Surgery.cs" />
|
||||
<Compile Include="StatParts.cs" />
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue