Fixes for 1.5 compatibility

This commit is contained in:
lutepickle 2024-03-13 17:15:13 -07:00
parent 3fe654b88a
commit 81e25a79a9
4 changed files with 19 additions and 18 deletions

View File

@ -1,4 +1,5 @@
using RimWorld; using LudeonTK;
using RimWorld;
using Verse; using Verse;
#pragma warning disable IDE0051 // Remove unused private members #pragma warning disable IDE0051 // Remove unused private members

View File

@ -6,7 +6,7 @@ namespace RJW_Menstruation
{ {
public class FertPillOutcomeDoer : IngestionOutcomeDoer 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()) foreach (HediffComp_Menstruation comp in pawn.GetMenstruationComps())
if (comp.curStage.Equals(HediffComp_Menstruation.Stage.Follicular) if (comp.curStage.Equals(HediffComp_Menstruation.Stage.Follicular)
@ -23,7 +23,7 @@ namespace RJW_Menstruation
public class InduceOvulationOutcomeDoer : IngestionOutcomeDoer 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()) foreach (HediffComp_Menstruation comp in pawn.GetMenstruationComps())
if (comp.curStage.Equals(HediffComp_Menstruation.Stage.Follicular) if (comp.curStage.Equals(HediffComp_Menstruation.Stage.Follicular)
@ -32,7 +32,7 @@ namespace RJW_Menstruation
{ {
comp.SetEstrus(); comp.SetEstrus();
comp.GoNextStage(HediffComp_Menstruation.Stage.Ovulatory); 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 HediffDef hediffDef;
public float severity; 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); 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; 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()) foreach (HediffComp_Menstruation comp in pawn.GetMenstruationComps())
if (Configurations.EnableMenopause) comp.RecoverOvary(1 + effectOffset); if (Configurations.EnableMenopause) comp.RecoverOvary(1 + effectOffset);
@ -64,16 +64,16 @@ namespace RJW_Menstruation
public class SuperOvulationOutcomeDoer : IngestionOutcomeDoer 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()) foreach (HediffComp_Menstruation comp in pawn.GetMenstruationComps())
comp.eggstack += Rand.Range(1, 4); comp.eggstack += Rand.Range(ingestedcount, 4 * ingestedcount);
} }
} }
public class ContraceptiveOutcomeDoer : IngestionOutcomeDoer public class ContraceptiveOutcomeDoer : IngestionOutcomeDoer
{ {
protected override void DoIngestionOutcomeSpecial(Pawn pawn, Thing ingested) protected override void DoIngestionOutcomeSpecial(Pawn pawn, Thing ingested, int ingestedcount)
{ {
List<Thought_Memory> memories = pawn.needs?.mood?.thoughts?.memories?.Memories.FindAll( List<Thought_Memory> memories = pawn.needs?.mood?.thoughts?.memories?.Memories.FindAll(

View File

@ -94,7 +94,7 @@ namespace RJW_Menstruation
Pawn baby = PawnGenerator.GeneratePawn(request); Pawn baby = PawnGenerator.GeneratePawn(request);
if (baby == null) break; if (baby == null) break;
PregnancyCommon.SetupBabyXenotype(mother, father, baby); // Probably redundant with Biotech post-birth xenotyping 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 (division > 1)
{ {
if (i == 0) if (i == 0)
@ -194,14 +194,14 @@ namespace RJW_Menstruation
[HarmonyPatch(typeof(Hediff_LaborPushing), nameof(Hediff_LaborPushing.PreRemoved))] [HarmonyPatch(typeof(Hediff_LaborPushing), nameof(Hediff_LaborPushing.PreRemoved))]
public static class Hediff_LaborPushing_PreRemoved_Patch public static class Hediff_LaborPushing_PreRemoved_Patch
{ {
private static Thing ApplyBirthLoop(OutcomeChance outcome, float quality, Precept_Ritual ritual, List<GeneDef> 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<GeneDef> genes, Pawn geneticMother, Thing birtherThing, Pawn father, Pawn doctor, LordJob_Ritual lordJobRitual, RitualRoleAssignments assignments)
{ {
if (birtherThing is Pawn mother) if (birtherThing is Pawn mother)
{ {
HediffComp_PregeneratedBabies comp = mother.health.hediffSet.GetFirstHediff<Hediff_LaborPushing>().TryGetComp<HediffComp_PregeneratedBabies>(); HediffComp_PregeneratedBabies comp = mother.health.hediffSet.GetFirstHediff<Hediff_LaborPushing>().TryGetComp<HediffComp_PregeneratedBabies>();
if (comp?.HasBaby ?? false) if (comp?.HasBaby ?? false)
{ {
OutcomeChance thisOutcome = outcome; RitualOutcomePossibility thisOutcome = outcome;
Precept_Ritual precept_Ritual = (Precept_Ritual)comp.Pawn.Ideo.GetPrecept(PreceptDefOf.ChildBirth); Precept_Ritual precept_Ritual = (Precept_Ritual)comp.Pawn.Ideo.GetPrecept(PreceptDefOf.ChildBirth);
float birthQuality = PregnancyUtility.GetBirthQualityFor(mother); float birthQuality = PregnancyUtility.GetBirthQualityFor(mother);
do do
@ -229,7 +229,7 @@ namespace RJW_Menstruation
} }
private static readonly MethodInfo ApplyBirthOutcome = typeof(PregnancyUtility).GetMethod(nameof(PregnancyUtility.ApplyBirthOutcome), private static readonly MethodInfo ApplyBirthOutcome = typeof(PregnancyUtility).GetMethod(nameof(PregnancyUtility.ApplyBirthOutcome),
new Type[] {typeof(OutcomeChance), typeof(float), typeof(Precept_Ritual), typeof(List<GeneDef>), typeof(Pawn), typeof(Thing), typeof(Pawn), typeof(Pawn), typeof(LordJob_Ritual), typeof(RitualRoleAssignments)}); new Type[] {typeof(RitualOutcomePossibility), typeof(float), typeof(Precept_Ritual), typeof(List<GeneDef>), typeof(Pawn), typeof(Thing), typeof(Pawn), typeof(Pawn), typeof(LordJob_Ritual), typeof(RitualRoleAssignments)});
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{ {
if (ApplyBirthOutcome?.ReturnType != typeof(Thing)) throw new InvalidOperationException("ApplyBirthOutcome not found"); 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))] [HarmonyPatch(typeof(RitualOutcomeEffectWorker_ChildBirth), nameof (RitualOutcomeEffectWorker_ChildBirth.Apply))]
public static class Ritual_ChildBirth_Apply_Patch public static class Ritual_ChildBirth_Apply_Patch
{ {
private static Thing ApplyBirthLoop(OutcomeChance outcome, float quality, Precept_Ritual ritual, List<GeneDef> 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<GeneDef> genes, Pawn geneticMother, Thing birtherThing, Pawn father, Pawn doctor, LordJob_Ritual lordJobRitual, RitualRoleAssignments assignments)
{ {
if (birtherThing is Pawn mother) 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); return PregnancyUtility.ApplyBirthOutcome(outcome, quality, ritual, genes, geneticMother, birtherThing, father, doctor, lordJobRitual, assignments);
} }
private static readonly MethodInfo ApplyBirthOutcome = typeof(PregnancyUtility).GetMethod(nameof(PregnancyUtility.ApplyBirthOutcome), private static readonly MethodInfo ApplyBirthOutcome = typeof(PregnancyUtility).GetMethod(nameof(PregnancyUtility.ApplyBirthOutcome),
new Type[] { typeof(OutcomeChance), typeof(float), typeof(Precept_Ritual), typeof(List<GeneDef>), typeof(Pawn), typeof(Thing), typeof(Pawn), typeof(Pawn), typeof(LordJob_Ritual), typeof(RitualRoleAssignments) }); new Type[] { typeof(RitualOutcomePossibility), typeof(float), typeof(Precept_Ritual), typeof(List<GeneDef>), typeof(Pawn), typeof(Thing), typeof(Pawn), typeof(Pawn), typeof(LordJob_Ritual), typeof(RitualRoleAssignments) });
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{ {
if (ApplyBirthOutcome?.ReturnType != typeof(Thing)) throw new InvalidOperationException("ApplyBirthOutcome not found"); if (ApplyBirthOutcome?.ReturnType != typeof(Thing)) throw new InvalidOperationException("ApplyBirthOutcome not found");

View File

@ -5,11 +5,11 @@ namespace RJW_Menstruation
{ {
public class IngestionOutcomeDoer_GiveHediff_StackCount : IngestionOutcomeDoer_GiveHediff 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); Hediff hediff = HediffMaker.MakeHediff(hediffDef, pawn);
float effect = ((!(severity > 0f)) ? hediffDef.initialSeverity : severity) * ingested.stackCount; 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; hediff.Severity = effect;
pawn.health.AddHediff(hediff); pawn.health.AddHediff(hediff);
} }