From 81e25a79a9d52ad1c4d9da2820e17eef8b5dbebe Mon Sep 17 00:00:00 2001 From: lutepickle <28810-lutepickle@users.noreply.gitgud.io> Date: Wed, 13 Mar 2024 17:15:13 -0700 Subject: [PATCH] Fixes for 1.5 compatibility --- .../RJW_Menstruation/DebugActions.cs | 3 ++- .../RJW_Menstruation/DrugOutcomeDoers.cs | 18 +++++++++--------- .../HediffComp_PregeneratedBabies.cs | 12 ++++++------ .../RJW_Menstruation/IngestionOutcomeDoers.cs | 4 ++-- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/1.5/source/RJW_Menstruation/RJW_Menstruation/DebugActions.cs b/1.5/source/RJW_Menstruation/RJW_Menstruation/DebugActions.cs index 55f34db..001322d 100644 --- a/1.5/source/RJW_Menstruation/RJW_Menstruation/DebugActions.cs +++ b/1.5/source/RJW_Menstruation/RJW_Menstruation/DebugActions.cs @@ -1,4 +1,5 @@ -using RimWorld; +using LudeonTK; +using RimWorld; using Verse; #pragma warning disable IDE0051 // Remove unused private members diff --git a/1.5/source/RJW_Menstruation/RJW_Menstruation/DrugOutcomeDoers.cs b/1.5/source/RJW_Menstruation/RJW_Menstruation/DrugOutcomeDoers.cs index 5017740..244ee48 100644 --- a/1.5/source/RJW_Menstruation/RJW_Menstruation/DrugOutcomeDoers.cs +++ b/1.5/source/RJW_Menstruation/RJW_Menstruation/DrugOutcomeDoers.cs @@ -6,7 +6,7 @@ namespace RJW_Menstruation { public class FertPillOutcomeDoer : IngestionOutcomeDoer { - protected override void DoIngestionOutcomeSpecial(Pawn pawn, Thing ingested) + protected override void DoIngestionOutcomeSpecial(Pawn pawn, Thing ingested, int ingestedcount) { foreach (HediffComp_Menstruation comp in pawn.GetMenstruationComps()) if (comp.curStage.Equals(HediffComp_Menstruation.Stage.Follicular) @@ -23,7 +23,7 @@ namespace RJW_Menstruation public class InduceOvulationOutcomeDoer : IngestionOutcomeDoer { - protected override void DoIngestionOutcomeSpecial(Pawn pawn, Thing ingested) + protected override void DoIngestionOutcomeSpecial(Pawn pawn, Thing ingested, int ingestedcount) { foreach (HediffComp_Menstruation comp in pawn.GetMenstruationComps()) if (comp.curStage.Equals(HediffComp_Menstruation.Stage.Follicular) @@ -32,7 +32,7 @@ namespace RJW_Menstruation { comp.SetEstrus(); comp.GoNextStage(HediffComp_Menstruation.Stage.Ovulatory); - comp.eggstack += ingested.stackCount - 1; + comp.eggstack += ingestedcount - 1; } } } @@ -42,10 +42,10 @@ namespace RJW_Menstruation public HediffDef hediffDef; public float severity; - protected override void DoIngestionOutcomeSpecial(Pawn pawn, Thing ingested) + protected override void DoIngestionOutcomeSpecial(Pawn pawn, Thing ingested, int ingestedcount) { Hediff hediff = pawn.health.hediffSet.GetFirstHediffOfDef(hediffDef); - if (hediff != null) hediff.Severity += severity; + if (hediff != null) hediff.Severity += severity * ingestedcount; } } @@ -55,7 +55,7 @@ namespace RJW_Menstruation public float effectOffset; - protected override void DoIngestionOutcomeSpecial(Pawn pawn, Thing ingested) + protected override void DoIngestionOutcomeSpecial(Pawn pawn, Thing ingested, int ingestedcount) { foreach (HediffComp_Menstruation comp in pawn.GetMenstruationComps()) if (Configurations.EnableMenopause) comp.RecoverOvary(1 + effectOffset); @@ -64,16 +64,16 @@ namespace RJW_Menstruation public class SuperOvulationOutcomeDoer : IngestionOutcomeDoer { - protected override void DoIngestionOutcomeSpecial(Pawn pawn, Thing ingested) + protected override void DoIngestionOutcomeSpecial(Pawn pawn, Thing ingested, int ingestedcount) { foreach (HediffComp_Menstruation comp in pawn.GetMenstruationComps()) - comp.eggstack += Rand.Range(1, 4); + comp.eggstack += Rand.Range(ingestedcount, 4 * ingestedcount); } } public class ContraceptiveOutcomeDoer : IngestionOutcomeDoer { - protected override void DoIngestionOutcomeSpecial(Pawn pawn, Thing ingested) + protected override void DoIngestionOutcomeSpecial(Pawn pawn, Thing ingested, int ingestedcount) { List memories = pawn.needs?.mood?.thoughts?.memories?.Memories.FindAll( 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 0a919c4..9f383b0 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 @@ -94,7 +94,7 @@ namespace RJW_Menstruation Pawn baby = PawnGenerator.GeneratePawn(request); if (baby == null) break; PregnancyCommon.SetupBabyXenotype(mother, father, baby); // Probably redundant with Biotech post-birth xenotyping - baby.Drawer.renderer.graphics.ResolveAllGraphics(); +// baby.Drawer.renderer.graphics.ResolveAllGraphics(); if (division > 1) { if (i == 0) @@ -194,14 +194,14 @@ namespace RJW_Menstruation [HarmonyPatch(typeof(Hediff_LaborPushing), nameof(Hediff_LaborPushing.PreRemoved))] public static class Hediff_LaborPushing_PreRemoved_Patch { - private static Thing ApplyBirthLoop(OutcomeChance outcome, float quality, Precept_Ritual ritual, List genes, Pawn geneticMother, Thing birtherThing, Pawn father, Pawn doctor, LordJob_Ritual lordJobRitual, RitualRoleAssignments assignments) + private static Thing ApplyBirthLoop(RitualOutcomePossibility outcome, float quality, Precept_Ritual ritual, List genes, Pawn geneticMother, Thing birtherThing, Pawn father, Pawn doctor, LordJob_Ritual lordJobRitual, RitualRoleAssignments assignments) { if (birtherThing is Pawn mother) { HediffComp_PregeneratedBabies comp = mother.health.hediffSet.GetFirstHediff().TryGetComp(); if (comp?.HasBaby ?? false) { - OutcomeChance thisOutcome = outcome; + RitualOutcomePossibility thisOutcome = outcome; Precept_Ritual precept_Ritual = (Precept_Ritual)comp.Pawn.Ideo.GetPrecept(PreceptDefOf.ChildBirth); float birthQuality = PregnancyUtility.GetBirthQualityFor(mother); do @@ -229,7 +229,7 @@ namespace RJW_Menstruation } private static readonly MethodInfo ApplyBirthOutcome = typeof(PregnancyUtility).GetMethod(nameof(PregnancyUtility.ApplyBirthOutcome), - new Type[] {typeof(OutcomeChance), typeof(float), typeof(Precept_Ritual), typeof(List), typeof(Pawn), typeof(Thing), typeof(Pawn), typeof(Pawn), typeof(LordJob_Ritual), typeof(RitualRoleAssignments)}); + new Type[] {typeof(RitualOutcomePossibility), typeof(float), typeof(Precept_Ritual), typeof(List), typeof(Pawn), typeof(Thing), typeof(Pawn), typeof(Pawn), typeof(LordJob_Ritual), typeof(RitualRoleAssignments)}); public static IEnumerable Transpiler(IEnumerable instructions) { if (ApplyBirthOutcome?.ReturnType != typeof(Thing)) throw new InvalidOperationException("ApplyBirthOutcome not found"); @@ -245,7 +245,7 @@ namespace RJW_Menstruation [HarmonyPatch(typeof(RitualOutcomeEffectWorker_ChildBirth), nameof (RitualOutcomeEffectWorker_ChildBirth.Apply))] public static class Ritual_ChildBirth_Apply_Patch { - private static Thing ApplyBirthLoop(OutcomeChance outcome, float quality, Precept_Ritual ritual, List genes, Pawn geneticMother, Thing birtherThing, Pawn father, Pawn doctor, LordJob_Ritual lordJobRitual, RitualRoleAssignments assignments) + private static Thing ApplyBirthLoop(RitualOutcomePossibility outcome, float quality, Precept_Ritual ritual, List genes, Pawn geneticMother, Thing birtherThing, Pawn father, Pawn doctor, LordJob_Ritual lordJobRitual, RitualRoleAssignments assignments) { if (birtherThing is Pawn mother) { @@ -279,7 +279,7 @@ namespace RJW_Menstruation return PregnancyUtility.ApplyBirthOutcome(outcome, quality, ritual, genes, geneticMother, birtherThing, father, doctor, lordJobRitual, assignments); } private static readonly MethodInfo ApplyBirthOutcome = typeof(PregnancyUtility).GetMethod(nameof(PregnancyUtility.ApplyBirthOutcome), - new Type[] { typeof(OutcomeChance), typeof(float), typeof(Precept_Ritual), typeof(List), typeof(Pawn), typeof(Thing), typeof(Pawn), typeof(Pawn), typeof(LordJob_Ritual), typeof(RitualRoleAssignments) }); + new Type[] { typeof(RitualOutcomePossibility), typeof(float), typeof(Precept_Ritual), typeof(List), typeof(Pawn), typeof(Thing), typeof(Pawn), typeof(Pawn), typeof(LordJob_Ritual), typeof(RitualRoleAssignments) }); public static IEnumerable Transpiler(IEnumerable instructions) { if (ApplyBirthOutcome?.ReturnType != typeof(Thing)) throw new InvalidOperationException("ApplyBirthOutcome not found"); diff --git a/1.5/source/RJW_Menstruation/RJW_Menstruation/IngestionOutcomeDoers.cs b/1.5/source/RJW_Menstruation/RJW_Menstruation/IngestionOutcomeDoers.cs index a413f42..08bdccd 100644 --- a/1.5/source/RJW_Menstruation/RJW_Menstruation/IngestionOutcomeDoers.cs +++ b/1.5/source/RJW_Menstruation/RJW_Menstruation/IngestionOutcomeDoers.cs @@ -5,11 +5,11 @@ namespace RJW_Menstruation { public class IngestionOutcomeDoer_GiveHediff_StackCount : IngestionOutcomeDoer_GiveHediff { - protected override void DoIngestionOutcomeSpecial(Pawn pawn, Thing ingested) + protected override void DoIngestionOutcomeSpecial(Pawn pawn, Thing ingested, int ingestedcount) { Hediff hediff = HediffMaker.MakeHediff(hediffDef, pawn); float effect = ((!(severity > 0f)) ? hediffDef.initialSeverity : severity) * ingested.stackCount; - AddictionUtility.ModifyChemicalEffectForToleranceAndBodySize_NewTemp(pawn, toleranceChemical, ref effect, multiplyByGeneToleranceFactors); + AddictionUtility.ModifyChemicalEffectForToleranceAndBodySize(pawn, toleranceChemical, ref effect, multiplyByGeneToleranceFactors); hediff.Severity = effect; pawn.health.AddHediff(hediff); }