RJW tends not to set usedCondom on both participants in sex, so check for both

This commit is contained in:
lutepickle 2024-03-27 11:44:49 -07:00
parent e4bd9a1f3c
commit c9369028fa
3 changed files with 18 additions and 6 deletions

View file

@ -244,7 +244,8 @@ namespace RJW_Menstruation
isInduced && isInduced &&
comp.Pawn.jobs.curDriver is JobDriver_Sex job && comp.Pawn.jobs.curDriver is JobDriver_Sex job &&
job.Sexprops != null && job.Sexprops != null &&
!job.Sexprops.usedCondom && //!job.Sexprops.usedCondom &&
!UsingCondom(comp.Pawn, job.Partner) &&
(job.Sexprops.sexType == xxx.rjwSextype.Vaginal || job.Sexprops.sexType == xxx.rjwSextype.DoublePenetration)) (job.Sexprops.sexType == xxx.rjwSextype.Vaginal || job.Sexprops.sexType == xxx.rjwSextype.DoublePenetration))
ovulatoryProgress = 0.0f; ovulatoryProgress = 0.0f;
else if (comp.curStage == HediffComp_Menstruation.Stage.Ovulatory) ovulatoryProgress = isInduced ? Mathf.Max(ovaryChanceToShow_01, comp.StageProgessNextUpdate) : comp.StageProgessNextUpdate; else if (comp.curStage == HediffComp_Menstruation.Stage.Ovulatory) ovulatoryProgress = isInduced ? Mathf.Max(ovaryChanceToShow_01, comp.StageProgessNextUpdate) : comp.StageProgessNextUpdate;
@ -466,5 +467,14 @@ namespace RJW_Menstruation
return damage.totalDamageDealt; return damage.totalDamageDealt;
} }
// RJW only sets usedCondom on the sexprops of the initiator, so work around that by checking for either pawn having it set
public static bool UsingCondom(Pawn pawn, Pawn partner)
{
return
((pawn?.jobs?.curDriver as JobDriver_Sex)?.Sexprops.usedCondom ?? false)
||
((partner?.jobs?.curDriver as JobDriver_Sex)?.Sexprops.usedCondom ?? false);
}
} }
} }

View file

@ -19,13 +19,11 @@ namespace RJW_Menstruation
public static bool Prefix(SexProps props) public static bool Prefix(SexProps props)
{ {
xxx.rjwSextype sextype = props.sexType; xxx.rjwSextype sextype = props.sexType;
Pawn pawn = props.pawn; Pawn pawn = props.pawn; // Penis
Pawn partner = props.partner; Pawn partner = props.partner; // Womb
if (sextype != xxx.rjwSextype.Vaginal && sextype != xxx.rjwSextype.DoublePenetration) return true; if (sextype != xxx.rjwSextype.Vaginal && sextype != xxx.rjwSextype.DoublePenetration) return true;
if (!partner.ShouldCycle()) return true; if (!partner.ShouldCycle()) return true;
if (!InteractionCanCausePregnancy(props)) return false; if (!InteractionCanCausePregnancy(props)) return false;
List<Hediff> pawnparts = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn)); List<Hediff> pawnparts = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn));
@ -38,6 +36,8 @@ namespace RJW_Menstruation
if (Genital_Helper.has_penis_fertile(pawn, pawnparts) && PregnancyHelper.CanImpregnate(pawn, partner, sextype)) if (Genital_Helper.has_penis_fertile(pawn, pawnparts) && PregnancyHelper.CanImpregnate(pawn, partner, sextype))
{ {
if (MenstruationUtility.UsingCondom(pawn, partner)) return false; // Shouldn't be needed, but RJW has a bug in the condom checks
PregnancyHelper.DoImpregnate(pawn, partner); PregnancyHelper.DoImpregnate(pawn, partner);
return false; return false;
} }
@ -344,7 +344,8 @@ namespace RJW_Menstruation
xxx.rjwSextype sextype = __instance.Sexprops.sexType; xxx.rjwSextype sextype = __instance.Sexprops.sexType;
if (!(target is Pawn partner)) return; if (!(target is Pawn partner)) return;
if (sextype != xxx.rjwSextype.Vaginal && sextype != xxx.rjwSextype.DoublePenetration) return; if (sextype != xxx.rjwSextype.Vaginal && sextype != xxx.rjwSextype.DoublePenetration) return;
if (__instance.Sexprops.usedCondom) return; //if (__instance.Sexprops.usedCondom) return;
if (MenstruationUtility.UsingCondom(pawn, partner)) return;
if (AndroidsCompatibility.IsAndroid(pawn)) return; if (AndroidsCompatibility.IsAndroid(pawn)) return;
if (!Impregnate_Patch.InteractionCanCausePregnancy(__instance.Sexprops)) return; if (!Impregnate_Patch.InteractionCanCausePregnancy(__instance.Sexprops)) return;
if (!partner.ShouldCycle()) return; if (!partner.ShouldCycle()) return;

View file

@ -1,5 +1,6 @@
Version 1.5.0.0 Version 1.5.0.0
- Support for RimWorld 1.5. All future changes to Menstruation will only be for Rimworld 1.5. - Support for RimWorld 1.5. All future changes to Menstruation will only be for Rimworld 1.5.
- More reliably detect the usage of condoms.
Version 1.0.9.4 Version 1.0.9.4
- Added graphics for the menstruation genes with thanks to Alpenglow. - Added graphics for the menstruation genes with thanks to Alpenglow.