diff --git a/1.4/Assemblies/RJW_Menstruation.dll b/1.4/Assemblies/RJW_Menstruation.dll index de4e12b..2d0b679 100644 Binary files a/1.4/Assemblies/RJW_Menstruation.dll and b/1.4/Assemblies/RJW_Menstruation.dll differ diff --git a/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Menstruation.cs b/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Menstruation.cs index f4fd872..e5cfef8 100644 --- a/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Menstruation.cs +++ b/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Menstruation.cs @@ -198,20 +198,9 @@ namespace RJW_Menstruation get { if (opcache > 0) return opcache; - float avglittersize; - try - { - avglittersize = Mathf.Max(Rand.ByCurveAverage(Pawn.RaceProps.litterSizeCurve), 1.0f); - } - catch - { - // Any exceptions in that will have been reported elsewhere in the code by now - avglittersize = 1.0f; - }; - avglittersize *= ovulationFactor; const float yearsBeforeMenopause = 6.0f; opcache = (int)(RaceCyclesPerYear() * - avglittersize * + AverageLitterSize() * yearsBeforeMenopause * (Pawn.RaceProps.lifeExpectancy / ThingDefOf.Human.race.lifeExpectancy)); if (opcache == 0) opcache = 1; @@ -689,6 +678,7 @@ namespace RJW_Menstruation estrusLevel = Props.concealedEstrus ? EstrusLevel.Concealed : EstrusLevel.Visible; ovulationFactor = 1f; noBleeding = false; + opcache = -1; if (Pawn.genes == null || !ModsConfig.BiotechActive) return; @@ -1220,6 +1210,21 @@ namespace RJW_Menstruation { } + protected float AverageLitterSize() + { + float avglittersize; + try + { + avglittersize = Mathf.Max(Rand.ByCurveAverage(Pawn.RaceProps.litterSizeCurve), 1.0f); + } + catch (NullReferenceException) + { + avglittersize = 1.0f; + } + avglittersize *= ovulationFactor; + return avglittersize; + } + protected virtual float RaceCyclesPerYear() { int breedingSeasons = 0; @@ -1242,16 +1247,7 @@ namespace RJW_Menstruation public int GetOvaryPowerByAge() { - float avglittersize; - try - { - avglittersize = Mathf.Max(Rand.ByCurveAverage(Pawn.RaceProps.litterSizeCurve), 1.0f); - } - catch (NullReferenceException) - { - avglittersize = 1.0f; - } - avglittersize *= ovulationFactor; + float avglittersize = AverageLitterSize(); float fertStartAge = Pawn.RaceProps.lifeStageAges?.Find(stage => stage.def.reproductive)?.minAge ?? 0.0f; float fertEndAge = Pawn.RaceProps.lifeExpectancy * (Pawn.IsAnimal() ? RJWPregnancySettings.fertility_endage_female_animal : RJWPregnancySettings.fertility_endage_female_humanlike); @@ -1972,7 +1968,7 @@ namespace RJW_Menstruation public int EggsRestoredPerBiosculptor(float yearsWorth) { - return Math.Max(1, (int)((float)RaceCyclesPerYear() * yearsWorth)); + return Math.Max(1, (int)(RaceCyclesPerYear() * yearsWorth * AverageLitterSize())); } public void RestoreEggs(float yearsWorth) diff --git a/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/MenstruationUtility.cs b/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/MenstruationUtility.cs index 8221acd..75c796f 100644 --- a/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/MenstruationUtility.cs +++ b/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/MenstruationUtility.cs @@ -396,12 +396,10 @@ namespace RJW_Menstruation public static bool ShouldCycle(this Pawn pawn) { if (!Configurations.EnableAnimalCycle && pawn.IsAnimal()) return false; + if (pawn.GetComp() != null) return false; if (pawn.RaceHasOviPregnancy()) return false; - if (ModsConfig.BiotechActive && pawn.genes != null) - { - foreach (Gene gene in pawn.genes.GenesListForReading) - if (VariousDefOf.EggLayerGenes.Contains(gene.def)) return false; - } + if (ModsConfig.BiotechActive && pawn.genes != null && + pawn.genes.GenesListForReading.Select(gene => gene.def).Intersect(VariousDefOf.EggLayerGenes).Any()) return false; return true; } 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 index aaf24de..eb8777a 100644 --- a/1.4/source/RJW_Menstruation/RJW_Menstruation/Patch/Biotech_Patch.cs +++ b/1.4/source/RJW_Menstruation/RJW_Menstruation/Patch/Biotech_Patch.cs @@ -192,23 +192,6 @@ namespace RJW_Menstruation } } - [HarmonyPatch(typeof(Pawn_GeneTracker), "AddGene", new Type[] { typeof(Gene), typeof(bool) })] - public class AddGene_Patch - { - public static bool Prefix(ref Gene __result, Gene gene, Pawn ___pawn) - { - if (!VariousDefOf.WombGenes.Contains(gene.def)) return true; - bool keepGene; - if (PawnGenerator.IsBeingGenerated(___pawn)) - // During pawn generation, the vagina hediff doesn't exist yet, so use gender to decide instead - // Not the most accurate, but close enough - keepGene = ___pawn.gender == Gender.Female; - else keepGene = ___pawn.GetMenstruationComps().Any(); - if (!keepGene) __result = null; - return keepGene; - } - } - [HarmonyPatch(typeof(Pawn_GeneTracker), "Notify_GenesChanged")] public class Notify_GenesChanged_Patch { diff --git a/1.4/source/RJW_Menstruation/RJW_Menstruation/Things.cs b/1.4/source/RJW_Menstruation/RJW_Menstruation/Things.cs index 6417fb4..cfee336 100644 --- a/1.4/source/RJW_Menstruation/RJW_Menstruation/Things.cs +++ b/1.4/source/RJW_Menstruation/RJW_Menstruation/Things.cs @@ -219,7 +219,7 @@ namespace RJW_Menstruation public void CheckDirty() { - if (absorbedfluids > this.GetStatValue(VariousDefOf.MaxAbsorbable) && (Wearer?.apparel?.IsLocked(this) ?? false)) + if (absorbedfluids > this.GetStatValue(VariousDefOf.MaxAbsorbable) && !(Wearer?.apparel?.IsLocked(this) ?? false)) { def = DirtyDef; dirty = true; diff --git a/1.4/source/RJW_Menstruation/RJW_Menstruation/VariousDefOf.cs b/1.4/source/RJW_Menstruation/RJW_Menstruation/VariousDefOf.cs index 920bd78..e3f8f66 100644 --- a/1.4/source/RJW_Menstruation/RJW_Menstruation/VariousDefOf.cs +++ b/1.4/source/RJW_Menstruation/RJW_Menstruation/VariousDefOf.cs @@ -54,16 +54,6 @@ namespace RJW_Menstruation public static readonly GeneDef QuadOvulation = DefDatabase.GetNamed("Menstruation_QuadOvulation"); public static readonly GeneDef NoBleeding = DefDatabase.GetNamed("Menstruation_NoBleeding"); - public static readonly HashSet WombGenes = new HashSet() { - ShortEggLifetime, - DoubleEggLifetime, - QuadEggLifetime, - NeverEstrus, - FullEstrus, - DoubleOvulation, - QuadOvulation, - NoBleeding }; - private static List allraces = null; private static List allkinds = null; private static HashSet allvaginas = null; diff --git a/About/Manifest.xml b/About/Manifest.xml index eb861f5..6b4c770 100644 --- a/About/Manifest.xml +++ b/About/Manifest.xml @@ -1,7 +1,7 @@ RJW Menstruation - 1.0.9.2 + 1.0.9.3 diff --git a/changelogs.txt b/changelogs.txt index 2000239..e6f1bf5 100644 --- a/changelogs.txt +++ b/changelogs.txt @@ -1,3 +1,9 @@ +Version 1.0.9.3 + - The biosculptor egg restoration cycle will now give more eggs to races that ovulate more than one egg at a time. + - All pawns can now use all menstruation genes, regardless of gender or having a womb. + - Egglaying animals no longer have a menstrual cycle. + - Fix bug preventing absorbers from becoming dirty. + Version 1.0.9.2 - Updated Traditional Chinese translation by Hydrogen. - Fixed the no bleeding gene having positive metabolic efficiency instead of negative.