Redo the quirk API to make the rest of the code a bit cleaner

This commit is contained in:
lutepickle 2024-01-08 08:13:52 -08:00
parent 40b23fc9c9
commit 546d121cde
7 changed files with 18 additions and 14 deletions

Binary file not shown.

View File

@ -290,7 +290,7 @@ namespace RJW_Menstruation
{ {
get get
{ {
if (QuirkUtility.HasQuirk(Pawn, QuirkUtility.Quirks.Breeder)) return 0.5f; if (Pawn.IsBreeder()) return 0.5f;
return 1.0f; return 1.0f;
} }
@ -315,7 +315,7 @@ namespace RJW_Menstruation
StatDefOf.Fertility.GetStatPart<StatPart_FertilityByGenderAge>()?.TransformValue(StatRequest.For(Pawn), ref ageFactor); StatDefOf.Fertility.GetStatPart<StatPart_FertilityByGenderAge>()?.TransformValue(StatRequest.For(Pawn), ref ageFactor);
if (ageFactor <= 0.0f) return 0.0f; // Too young or too old if (ageFactor <= 0.0f) return 0.0f; // Too young or too old
if (Pawn.HasQuirk(QuirkUtility.Quirks.Breeder)) ovulationChance *= 10.0f; if (Pawn.IsBreeder()) ovulationChance *= 10.0f;
try try
{ {
calculatingOvulationChance = true; calculatingOvulationChance = true;
@ -886,8 +886,8 @@ namespace RJW_Menstruation
if (!precum && fertility > 0 && IsDangerDay && cummer.relations.GetPregnancyApproachForPartner(Pawn) == PregnancyApproach.AvoidPregnancy) if (!precum && fertility > 0 && IsDangerDay && cummer.relations.GetPregnancyApproachForPartner(Pawn) == PregnancyApproach.AvoidPregnancy)
{ {
float successChance = pulloutSuccessRate; float successChance = pulloutSuccessRate;
if (cummer.HasQuirk(QuirkUtility.Quirks.ImpregnationFetish)) successChance *= fetishPulloutSuccessModifier; if (cummer.HasImpregnationFetish()) successChance *= fetishPulloutSuccessModifier;
if (Pawn.HasQuirk(QuirkUtility.Quirks.ImpregnationFetish)) successChance *= fetishPulloutSuccessModifier; if (Pawn.HasImpregnationFetish()) successChance *= fetishPulloutSuccessModifier;
if (Rand.Chance(successChance)) return; if (Rand.Chance(successChance)) return;
} }
if (Pawn.HasIUD()) fertility /= 100f; if (Pawn.HasIUD()) fertility /= 100f;
@ -1798,7 +1798,7 @@ namespace RJW_Menstruation
MemoryThoughtHandler cummerMemories = cummer.needs.mood.thoughts.memories; MemoryThoughtHandler cummerMemories = cummer.needs.mood.thoughts.memories;
MemoryThoughtHandler pawnMemories = Pawn.needs.mood.thoughts.memories; MemoryThoughtHandler pawnMemories = Pawn.needs.mood.thoughts.memories;
if (cummer.IsProPregnancy(out Precept preceptm) || (cummer.HasQuirk(QuirkUtility.Quirks.Teratophile) != (Pawn.GetStatValue(StatDefOf.PawnBeauty) >= 0))) if (cummer.IsProPregnancy(out Precept preceptm) || (cummer.IsTeratophile() != (Pawn.GetStatValue(StatDefOf.PawnBeauty) >= 0)))
{ {
if (cummer.relations.OpinionOf(Pawn) <= -5) if (cummer.relations.OpinionOf(Pawn) <= -5)
cummerMemories.TryGainMemory(VariousDefOf.HaterCameInsideM, Pawn); cummerMemories.TryGainMemory(VariousDefOf.HaterCameInsideM, Pawn);

View File

@ -453,8 +453,8 @@ namespace RJW_Menstruation
} }
if (precept != null) return true; if (precept != null) return true;
else return pawn.HasQuirk(QuirkUtility.Quirks.Breeder) || else return pawn.IsBreeder() ||
pawn.HasQuirk(QuirkUtility.Quirks.ImpregnationFetish); pawn.HasImpregnationFetish();
} }
public static float DamagePants(this Pawn pawn, float fluidAmount) public static float DamagePants(this Pawn pawn, float fluidAmount)

View File

@ -23,7 +23,7 @@ namespace RJW_Menstruation
{ {
if (is_discovered || if (is_discovered ||
!xxx.is_human(pawn) || !xxx.is_human(pawn) ||
pawn.HasQuirk(QuirkUtility.Quirks.Breeder) || (pawn.Ideo?.HasPrecept(VariousDefOf.Pregnancy_Required) ?? false) || pawn.IsBreeder() || (pawn.Ideo?.HasPrecept(VariousDefOf.Pregnancy_Required) ?? false) ||
(pawn.relations?.DirectRelations?.Find(x => x.def.Equals(PawnRelationDefOf.Spouse) || (pawn.relations?.DirectRelations?.Find(x => x.def.Equals(PawnRelationDefOf.Spouse) ||
x.def.Equals(PawnRelationDefOf.Fiance))) != null) x.def.Equals(PawnRelationDefOf.Fiance))) != null)
return; return;

View File

@ -31,7 +31,7 @@ namespace RJW_Menstruation
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));
HediffComp_Menstruation comp; HediffComp_Menstruation comp;
if (pawn.HasQuirk(QuirkUtility.Quirks.ImpregnationFetish) || partner.HasQuirk(QuirkUtility.Quirks.ImpregnationFetish) || partner.IsInEstrus()) if (pawn.HasImpregnationFetish() || partner.HasImpregnationFetish() || partner.IsInEstrus())
comp = partner.GetFertileMenstruationComp(); comp = partner.GetFertileMenstruationComp();
else comp = partner.GetRandomMenstruationComp(); else comp = partner.GetRandomMenstruationComp();
if (comp == null) return true; if (comp == null) return true;
@ -102,7 +102,7 @@ namespace RJW_Menstruation
{ {
if (!partner.ShouldCycle()) return true; if (!partner.ShouldCycle()) return true;
HediffComp_Menstruation comp; HediffComp_Menstruation comp;
if (pawn.HasQuirk(QuirkUtility.Quirks.ImpregnationFetish) || partner.HasQuirk(QuirkUtility.Quirks.ImpregnationFetish) || partner.IsInEstrus()) if (pawn.HasImpregnationFetish() || partner.HasImpregnationFetish() || partner.IsInEstrus())
comp = partner.GetFertileMenstruationComp(); comp = partner.GetFertileMenstruationComp();
else comp = partner.GetRandomMenstruationComp(); else comp = partner.GetRandomMenstruationComp();
if (comp == null) if (comp == null)
@ -179,7 +179,7 @@ namespace RJW_Menstruation
{ {
// Awkward, but it'll have to do // Awkward, but it'll have to do
Pawn pawn = props.pawn; Pawn pawn = props.pawn;
if (__result == 0 || !pawn.HasQuirk(QuirkUtility.Quirks.ImpregnationFetish) || !props.hasPartner()) return; if (__result == 0 || !pawn.HasImpregnationFetish() || !props.hasPartner()) return;
// Check if the existing code would have added the count // Check if the existing code would have added the count
Pawn partner = props.partner; Pawn partner = props.partner;

View File

@ -6,14 +6,14 @@ namespace RJW_Menstruation
public static class QuirkUtility public static class QuirkUtility
{ {
// All quirks used in Menstruation // All quirks used in Menstruation
public enum Quirks private enum Quirks
{ {
Breeder, Breeder,
ImpregnationFetish, ImpregnationFetish,
Messy, Messy,
Teratophile, Teratophile,
} }
public static bool HasQuirk(this Pawn pawn, Quirks quirk) private static bool HasQuirk(Pawn pawn, Quirks quirk)
{ {
switch (quirk) switch (quirk)
{ {
@ -29,5 +29,9 @@ namespace RJW_Menstruation
return false; return false;
} }
} }
public static bool IsBreeder(this Pawn pawn) => HasQuirk(pawn, Quirks.Breeder);
public static bool HasImpregnationFetish(this Pawn pawn) => HasQuirk(pawn, Quirks.ImpregnationFetish);
public static bool IsMessy(this Pawn pawn) => HasQuirk(pawn, Quirks.Messy);
public static bool IsTeratophile(this Pawn pawn) => HasQuirk(pawn, Quirks.Teratophile);
} }
} }

View File

@ -86,7 +86,7 @@ namespace RJW_Menstruation
{ {
res = 0.0f; res = 0.0f;
} }
if (pawn.HasQuirk(QuirkUtility.Quirks.Messy)) res *= Rand.Range(4.0f, 8.0f); if (pawn.IsMessy()) res *= Rand.Range(4.0f, 8.0f);
return res; return res;
} }