diff --git a/1.5/Languages/English/Keyed/RJW_Menstruation.xml b/1.5/Languages/English/Keyed/RJW_Menstruation.xml index 08b7327..7aa650e 100644 --- a/1.5/Languages/English/Keyed/RJW_Menstruation.xml +++ b/1.5/Languages/English/Keyed/RJW_Menstruation.xml @@ -133,7 +133,7 @@ Use basic RJW pregnancy Use menstruation multiple pregnancy Use Biotech pregnancy - Enable multiple babies/twins in a single Biotech pregnancy. + (EXPERIMENTAL) Enable multiple babies/twins in a single Biotech pregnancy. Enabling this option will allow identical and hetero ovular twins with Biotech. Also allows the hybrid system, but two humanlikes cannot produce an animal. Show womb status when drafted Draw womb icon for drafted pawns diff --git a/1.5/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Menstruation.cs b/1.5/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Menstruation.cs index cdf9afd..ae03413 100644 --- a/1.5/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Menstruation.cs +++ b/1.5/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Menstruation.cs @@ -125,7 +125,7 @@ namespace RJW_Menstruation protected bool estrusflag = false; protected float? ovulationChanceCache = null; // Dirtied every simulation protected float? implantationChanceCache = null; - protected int? opcache = null; + protected int opcache = -1; protected float antisperm = 0.0f; // RJW pregnancy, or Biotech pregnancy/labor/laborpushing protected Hediff pregnancy = null; @@ -197,14 +197,14 @@ namespace RJW_Menstruation { get { - if (opcache.HasValue) return opcache.Value; + if (opcache > 0) return opcache; const float yearsBeforeMenopause = 6.0f; opcache = (int)(RaceCyclesPerYear() * AverageLitterSize() * yearsBeforeMenopause * (Pawn.RaceProps.lifeExpectancy / ThingDefOf.Human.race.lifeExpectancy)); - if (opcache <= 0) opcache = 1; - return opcache.Value; + if (opcache == 0) opcache = 1; + return opcache; } } @@ -655,7 +655,7 @@ namespace RJW_Menstruation estrusLevel = Props.concealedEstrus ? EstrusLevel.Concealed : EstrusLevel.Visible; ovulationFactor = 1f; noBleeding = false; - opcache = null; + opcache = -1; if (Pawn.genes == null || !ModsConfig.BiotechActive) return; foreach (MenstruationModExtension extension in Pawn.genes.GenesListForReading.Where(gene => gene.Active).Select(gene => gene.def.GetModExtension()).Where(ext => ext != null)) @@ -971,7 +971,7 @@ namespace RJW_Menstruation if (Pawn.HasIUD()) antisperm = 0.70f + asafactor; else antisperm = 0.0f + asafactor; - absorber = Pawn.apparel?.WornApparel.OfType().FirstOrDefault(); + absorber = (Absorber)Pawn.apparel?.WornApparel.Find(x => x is Absorber); if (absorber != null) { absorber.WearEffect(TickInterval); @@ -1390,12 +1390,6 @@ namespace RJW_Menstruation deadeggs.Add(egg); continue; } - else if (ModsConfig.BiotechActive && !Find.Storyteller.difficulty.ChildrenAllowed) - { - if (Configurations.Debug) Log.Message($"Could not implant {Pawn}'s egg due to children being disabled"); - deadeggs.Add(egg); - continue; - } else if (Rand.Chance(Configurations.ImplantationChance * ImplantChance * InterspeciesImplantFactor(egg.fertilizer))) { try diff --git a/1.5/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_PregeneratedBabies.cs b/1.5/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_PregeneratedBabies.cs index 505d9be..2f6cea5 100644 --- a/1.5/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_PregeneratedBabies.cs +++ b/1.5/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_PregeneratedBabies.cs @@ -43,14 +43,14 @@ namespace RJW_Menstruation switch (parent) { case Hediff_Pregnant hediff_Pregnant: - Hediff_Labor labor = Pawn.health.hediffSet.hediffs.OfType().MaxByWithFallback(hediff => hediff.loadID); + Hediff_Labor labor = (Hediff_Labor)Pawn.health.hediffSet.hediffs.Where(hediff => hediff is Hediff_Labor).MaxByWithFallback(hediff => hediff.loadID); HediffComp_PregeneratedBabies laborcomp = labor?.TryGetComp(); if (laborcomp == null) return; laborcomp.babies = this.babies; laborcomp.enzygoticSiblings = this.enzygoticSiblings; break; case Hediff_Labor hediff_Labor: - Hediff_LaborPushing pushing = Pawn.health.hediffSet.hediffs.OfType().MaxByWithFallback(hediff => hediff.loadID); + Hediff_LaborPushing pushing = (Hediff_LaborPushing)Pawn.health.hediffSet.hediffs.Where(hediff => hediff is Hediff_LaborPushing).MaxByWithFallback(hediff => hediff.loadID); HediffComp_PregeneratedBabies pushingcomp = pushing?.TryGetComp(); if (pushingcomp == null) return; pushingcomp.babies = this.babies; @@ -103,6 +103,7 @@ namespace RJW_Menstruation { firstbaby = baby; request.FixedGender = baby.gender; + request.ForcedEndogenes = baby.genes?.Endogenes.Select(gene => gene.def).ToList(); } else { diff --git a/1.5/source/RJW_Menstruation/RJW_Menstruation/HediffComps/MenstruationUtility.cs b/1.5/source/RJW_Menstruation/RJW_Menstruation/HediffComps/MenstruationUtility.cs index a8e873f..7a42bae 100644 --- a/1.5/source/RJW_Menstruation/RJW_Menstruation/HediffComps/MenstruationUtility.cs +++ b/1.5/source/RJW_Menstruation/RJW_Menstruation/HediffComps/MenstruationUtility.cs @@ -395,10 +395,23 @@ namespace RJW_Menstruation public static HediffComp_Menstruation.EstrusLevel HighestEstrus(this Pawn pawn) { - return pawn.GetMenstruationComps(). - Select(comp => comp.GetEstrusLevel()). - DefaultIfEmpty(HediffComp_Menstruation.EstrusLevel.None). - Max(); + HediffComp_Menstruation.EstrusLevel res = HediffComp_Menstruation.EstrusLevel.None; + + foreach(HediffComp_Menstruation comp in pawn.GetMenstruationComps()) + { + switch (comp.GetEstrusLevel()) + { + case HediffComp_Menstruation.EstrusLevel.None: + break; + case HediffComp_Menstruation.EstrusLevel.Concealed: + res = HediffComp_Menstruation.EstrusLevel.Concealed; + break; + case HediffComp_Menstruation.EstrusLevel.Visible: + return HediffComp_Menstruation.EstrusLevel.Visible; + } + } + + return res; } public static bool HasIUD(this Pawn pawn) @@ -428,10 +441,21 @@ namespace RJW_Menstruation public static float DamagePants(this Pawn pawn, float fluidAmount) { if (pawn.apparel == null) return 0; - if (!pawn.apparel.WornApparel. - Where(apparel => apparel.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Legs)). - TryMinBy(apparel => apparel.def.apparel.LastLayer.drawOrder, out Apparel pants)) - return 0; + Apparel pants = null; + foreach(Apparel apparel in pawn.apparel.WornApparel.Where(app => app.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Legs))) + { + if (apparel.def.apparel.LastLayer == ApparelLayerDefOf.OnSkin) + { + pants = apparel; + break; + } + else if (pants == null || apparel.def.apparel.LastLayer == ApparelLayerDefOf.Middle) + // Either grab whatever's available or reassign the pants from shell to a middle + pants = apparel; + // Pants are middle and this is a shell + else continue; + } + if (pants == null) return 0; const float HPPerMl = 0.5f; diff --git a/1.5/source/RJW_Menstruation/RJW_Menstruation/Hediff_MultiplePregnancy.cs b/1.5/source/RJW_Menstruation/RJW_Menstruation/Hediff_MultiplePregnancy.cs index 31e2027..f8f4d3e 100644 --- a/1.5/source/RJW_Menstruation/RJW_Menstruation/Hediff_MultiplePregnancy.cs +++ b/1.5/source/RJW_Menstruation/RJW_Menstruation/Hediff_MultiplePregnancy.cs @@ -343,6 +343,7 @@ namespace RJW_Menstruation firstbaby = baby; request.FixedGender = baby.gender; + request.ForcedEndogenes = baby.genes?.Endogenes.Select(gene => gene.def).ToList(); } else { diff --git a/About/ModIcon.png b/About/ModIcon.png deleted file mode 100644 index f12d8f5..0000000 Binary files a/About/ModIcon.png and /dev/null differ