rjw-sexperience-ideology/Source/IdeologyAddon/IdeoUtility.cs

101 lines
2.8 KiB
C#
Raw Normal View History

2022-07-26 03:55:56 +00:00
using RimWorld;
2022-08-10 18:58:25 +00:00
using rjw;
2022-07-26 03:55:56 +00:00
using Verse;
namespace RJWSexperience.Ideology
{
public static class IdeoUtility
{
public static bool IsSubmissive(this Pawn pawn)
{
Ideo ideo = pawn.Ideo;
if (ideo == null)
return false;
2023-04-23 11:41:27 +00:00
if (ideo.HasPrecept(RsiDefOf.Precept.Submissive_Female) && pawn.gender == Gender.Female)
2022-07-26 03:55:56 +00:00
return true;
2023-04-23 11:41:27 +00:00
else if (ideo.HasPrecept(RsiDefOf.Precept.Submissive_Male) && pawn.gender == Gender.Male)
2022-07-26 03:55:56 +00:00
return true;
return false;
}
public static float GetPreceptsMtbMultiplier<T>(Ideo ideo) where T : Precepts.DefExtension_ModifyMtb
{
float finalMultiplier = 1f;
for (int i = 0; i < ideo.PreceptsListForReading.Count; i++)
{
T defExtension = ideo.PreceptsListForReading[i].def.GetModExtension<T>();
if (defExtension == null)
continue;
finalMultiplier *= defExtension.multiplier;
}
return finalMultiplier;
}
2022-10-14 17:37:55 +00:00
2022-08-10 19:08:21 +00:00
internal static void ConvertPawnBySex(Pawn pawn, Pawn partner, float severity = 0.01f)
{
// Important Note: This is called on "orgasm" - hence when a pawn has the orgasm he is the "pawn" here.
// If Bob fucks Alice, Alice has the orgasm and Alice is the Pawn while Bob is the Partner.
// Hence, the Conversion happens from Partner -> Pawn and not the other way round!
// Short Circuit: Either pawn is null, exit early and do nothing
2022-10-14 17:37:55 +00:00
if (pawn == null || partner == null)
return;
2022-08-10 19:08:21 +00:00
bool sameIdeo = pawn.Ideo == partner.Ideo;
// Option A: Partner has same Ideo as Pawn, increase certainty
if (sameIdeo)
{
if (partner.ideo.Certainty < 1f)
{
partner.ideo.OffsetCertainty(severity);
}
2022-08-10 19:08:21 +00:00
}
// Option B: Partner as different Ideo, try to convert
else
{
pawn.ideo.IdeoConversionAttempt(severity, partner.Ideo);
}
}
2022-08-10 18:58:25 +00:00
2022-10-14 17:37:55 +00:00
public static float GetGenitalSize(Pawn p)
2022-08-10 18:58:25 +00:00
{
if (p == null)
return 0f;
// Iff the pawn has multiple genitalia, the "best" is picked (the biggest penis or tightest vagina)
2022-10-14 17:37:55 +00:00
float bestSeenSize = 0f;
foreach (Hediff part in Genital_Helper.get_AllPartsHediffList(p))
2022-08-10 18:58:25 +00:00
{
// Only check for Vaginas and Penises, not for Anus or for things not categorized as primary sexual parts
if (Genital_Helper.is_penis(part) || Genital_Helper.is_vagina(part))
{
2022-10-14 17:37:55 +00:00
bestSeenSize = part.Severity > bestSeenSize ? part.Severity : bestSeenSize;
2022-08-10 18:58:25 +00:00
}
}
// For Women, the scale is inverted.
if (p.gender == Gender.Female)
2022-10-14 17:37:55 +00:00
return 1 - bestSeenSize;
2022-08-10 18:58:25 +00:00
2022-10-14 17:37:55 +00:00
return bestSeenSize;
2022-08-10 18:58:25 +00:00
}
public static bool IsVisiblyPregnant(Pawn pawn)
{
Hediff pregnancy = PregnancyHelper.GetPregnancy(pawn);
// Currently RJW does not check Biotech pregnancy
2023-04-23 11:41:27 +00:00
if (pregnancy == null && RsiDefOf.Hediff.PregnantHuman != null)
{
pregnancy = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.PregnantHuman);
}
return pregnancy?.Visible == true;
}
2022-07-26 03:55:56 +00:00
}
}