From c955221f647241f3b6f01b0637ef1100d6343083 Mon Sep 17 00:00:00 2001 From: lutepickle <28810-lutepickle@users.noreply.gitgud.io> Date: Sat, 26 Nov 2022 15:20:16 -0800 Subject: [PATCH 1/5] Shift the HAR generation to only the first baby of a set. --- .../RJW_Menstruation/Hediff_MultiplePregnancy.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 699cf02..8446edd 100644 --- a/1.4/source/RJW_Menstruation/RJW_Menstruation/Hediff_MultiplePregnancy.cs +++ b/1.4/source/RJW_Menstruation/RJW_Menstruation/Hediff_MultiplePregnancy.cs @@ -426,10 +426,10 @@ namespace RJW_Menstruation } if (division > 1) { - if (baby.IsHAR()) // necessary for HAR to decide on graphical properties pre-birth - baby.Drawer.renderer.graphics.ResolveAllGraphics(); if (i == 0) - { + { + if (baby.IsHAR()) // necessary for HAR to decide on graphical properties pre-birth + baby.Drawer.renderer.graphics.ResolveAllGraphics(); firstbaby = baby; request.FixedGender = baby.gender; request.ForcedEndogenes = baby.genes?.Endogenes.Select(gene => gene.def).ToList(); From 06039238d20214e3cdbbb8395edf392695e4a9d2 Mon Sep 17 00:00:00 2001 From: lutepickle <28810-lutepickle@users.noreply.gitgud.io> Date: Sat, 26 Nov 2022 15:20:52 -0800 Subject: [PATCH 2/5] Additional safety checks for the transpilers --- .../RJW_Menstruation/Hediff_MultiplePregnancy.cs | 2 +- .../RJW_Menstruation/Patch/Biotech_Patch.cs | 2 +- .../RJW_Menstruation/RJW_Menstruation/Patch/RJW_Patch.cs | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) 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 8446edd..0641e24 100644 --- a/1.4/source/RJW_Menstruation/RJW_Menstruation/Hediff_MultiplePregnancy.cs +++ b/1.4/source/RJW_Menstruation/RJW_Menstruation/Hediff_MultiplePregnancy.cs @@ -428,7 +428,7 @@ namespace RJW_Menstruation { if (i == 0) { - if (baby.IsHAR()) // necessary for HAR to decide on graphical properties pre-birth + if (baby.IsHAR()) // Have HAR determine the first baby's properties baby.Drawer.renderer.graphics.ResolveAllGraphics(); firstbaby = baby; request.FixedGender = baby.gender; 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 f9dc764..a6d34e2 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 @@ -141,7 +141,7 @@ namespace RJW_Menstruation // Also called for Recipe_TerminatePregnancy.ApplyOnPawn public static IEnumerable Transpiler(IEnumerable instructions) { - if (GetPregnancyHediff == null) throw new System.InvalidOperationException("GetPregnancyHediff not found"); + if (GetPregnancyHediff == null || GetPregnancyHediff.ReturnType != typeof(Hediff)) throw new System.InvalidOperationException("GetPregnancyHediff not found"); foreach (CodeInstruction instruction in instructions) { if (instruction.Calls(GetPregnancyHediff)) diff --git a/1.4/source/RJW_Menstruation/RJW_Menstruation/Patch/RJW_Patch.cs b/1.4/source/RJW_Menstruation/RJW_Menstruation/Patch/RJW_Patch.cs index cb98f78..63eb888 100644 --- a/1.4/source/RJW_Menstruation/RJW_Menstruation/Patch/RJW_Patch.cs +++ b/1.4/source/RJW_Menstruation/RJW_Menstruation/Patch/RJW_Patch.cs @@ -132,7 +132,7 @@ namespace RJW_Menstruation private static readonly MethodInfo IsPregnant = AccessTools.Method(typeof(PawnExtensions), nameof(PawnExtensions.IsPregnant), new System.Type[] {typeof(Pawn), typeof(bool)}); public static IEnumerable Transpiler(IEnumerable instructions) { - if (IsPregnant == null) throw new System.InvalidOperationException("IsPregnant not found"); + if (IsPregnant == null || IsPregnant.ReturnType != typeof(bool)) throw new System.InvalidOperationException("IsPregnant not found"); foreach(CodeInstruction instruction in instructions) { if (instruction.Calls(IsPregnant)) @@ -239,7 +239,7 @@ namespace RJW_Menstruation private static readonly FieldInfo MinimumFuckabilityToHookup = AccessTools.Field(typeof(RJWHookupSettings), nameof(RJWHookupSettings.MinimumFuckabilityToHookup)); public static IEnumerable Transpiler(IEnumerable instructions) { - if (MinimumFuckabilityToHookup == null) throw new System.InvalidOperationException("MinimumFuckabilityToHookup not found"); + if (MinimumFuckabilityToHookup == null || MinimumFuckabilityToHookup.FieldType != typeof(float)) throw new System.InvalidOperationException("MinimumFuckabilityToHookup not found"); bool first_fuckability = true; foreach (CodeInstruction instruction in instructions) { @@ -275,8 +275,8 @@ namespace RJW_Menstruation private static readonly FieldInfo MinimumRelationshipToHookup = AccessTools.Field(typeof(RJWHookupSettings), nameof(RJWHookupSettings.MinimumRelationshipToHookup)); public static IEnumerable Transpiler(IEnumerable instructions) { - if (MinimumAttractivenessToHookup == null) throw new System.InvalidOperationException("MinimumAttractivenessToHookup not found"); - if (MinimumRelationshipToHookup == null) throw new System.InvalidOperationException("MinimumRelationshipToHookup not found"); + if (MinimumAttractivenessToHookup == null || MinimumAttractivenessToHookup.FieldType != typeof(float)) throw new System.InvalidOperationException("MinimumAttractivenessToHookup not found"); + if (MinimumRelationshipToHookup == null || MinimumRelationshipToHookup.FieldType != typeof(float)) throw new System.InvalidOperationException("MinimumRelationshipToHookup not found"); LocalBuilder pawn_index = null; // Like in the last one, we switch the arguments around for the second load bool first_attractiveness = true; From 60343e8b3fa3279881694c2fd9d44acaa9d5deb9 Mon Sep 17 00:00:00 2001 From: lutepickle <28810-lutepickle@users.noreply.gitgud.io> Date: Sun, 27 Nov 2022 09:33:19 -0800 Subject: [PATCH 3/5] Have the breasts grow and shrink for Biotech pregnancies, too --- .../RJW_Menstruation/HediffComps/HediffComp_Breast.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Breast.cs b/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Breast.cs index 6edeabe..b0d8b79 100644 --- a/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Breast.cs +++ b/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Breast.cs @@ -257,7 +257,7 @@ namespace RJW_Menstruation } } // Scenario B: Pregnant, grow in the second half of first trimester - else if (Pawn.IsRJWPregnant()) + else if (Pawn.IsRJWPregnant() || Pawn.IsBiotechPregnant()) { float pregnancySize = Mathf.InverseLerp(breastGrowthStart, breastGrowthEnd, Pawn.GetFarthestPregnancyProgress()) * MaxBreastIncrement; if (breastSizeIncreased > pregnancySize) @@ -293,7 +293,7 @@ namespace RJW_Menstruation float newNippleProgress; if (ageOfLastBirth + BabyHalfAge * GenDate.TicksPerYear > Pawn.ageTracker.AgeBiologicalTicks) newNippleProgress = 1f; - else if (Pawn.IsRJWPregnant()) + else if (Pawn.IsRJWPregnant() || Pawn.IsBiotechPregnant()) newNippleProgress = nippleTransitions.Evaluate(Pawn.GetFarthestPregnancyProgress()); else newNippleProgress = 0f; From a917a940ee8659a529a6660f2156926d2bc14b5a Mon Sep 17 00:00:00 2001 From: lutepickle <28810-lutepickle@users.noreply.gitgud.io> Date: Tue, 29 Nov 2022 10:11:28 -0800 Subject: [PATCH 4/5] Add a function to damage pants based on fluid leakage. Not yet called by anything --- .../HediffComps/MenstruationUtility.cs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) 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 7d3ffa3..18a9604 100644 --- a/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/MenstruationUtility.cs +++ b/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/MenstruationUtility.cs @@ -362,5 +362,34 @@ namespace RJW_Menstruation if (ModsConfig.BiotechActive && pawn.health.hediffSet.HasHediff(HediffDefOf.ImplantedIUD)) return true; return false; } + + public static float DamagePants(this Pawn pawn, float fluidAmount) + { + if (pawn.apparel == null) 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; + + DamageWorker.DamageResult damage = pants.TakeDamage(new DamageInfo(DamageDefOf.Deterioration, fluidAmount * HPPerMl, spawnFilth: false)); + + if (pants.Destroyed && PawnUtility.ShouldSendNotificationAbout(pawn) && !pawn.Dead) + Messages.Message("MessageWornApparelDeterioratedAway".Translate(GenLabel.ThingLabel(pants.def, pants.Stuff), pawn).CapitalizeFirst(), pawn, MessageTypeDefOf.NegativeEvent); + + return damage.totalDamageDealt; + } } } From 2b38631d077d5e73fcde95a7e8202e5596b92554 Mon Sep 17 00:00:00 2001 From: lutepickle <28810-lutepickle@users.noreply.gitgud.io> Date: Thu, 8 Dec 2022 20:24:55 -0800 Subject: [PATCH 5/5] Change folder name to fix Traditional Chinese translation --- .../{Recipe_Surgery => RecipeDef}/Recipes_Surgery_Breast.xml | 0 changelogs.txt | 1 + 2 files changed, 1 insertion(+) rename 1.4/Languages/ChineseTraditional/DefInjected/{Recipe_Surgery => RecipeDef}/Recipes_Surgery_Breast.xml (100%) diff --git a/1.4/Languages/ChineseTraditional/DefInjected/Recipe_Surgery/Recipes_Surgery_Breast.xml b/1.4/Languages/ChineseTraditional/DefInjected/RecipeDef/Recipes_Surgery_Breast.xml similarity index 100% rename from 1.4/Languages/ChineseTraditional/DefInjected/Recipe_Surgery/Recipes_Surgery_Breast.xml rename to 1.4/Languages/ChineseTraditional/DefInjected/RecipeDef/Recipes_Surgery_Breast.xml diff --git a/changelogs.txt b/changelogs.txt index 6dc78a5..965c2a1 100644 --- a/changelogs.txt +++ b/changelogs.txt @@ -1,5 +1,6 @@ Version 1.0.8.4 - Fix Biotech xenotype inheritance for single-child pregnancies. + - Fix error in Traditional Chinese translation. - Newborns should now be baseliners if there are no xenotypes to inherit. - The Biotech terminate pregnancy recipe can now terminate a menstruation pregnancy, too.