No virgin? trait for tribal pawns

This commit is contained in:
amevarashi 2023-12-10 11:34:40 +05:00
parent 0743575d56
commit 3c4060f8bd
2 changed files with 14 additions and 3 deletions

View File

@ -27,16 +27,25 @@ namespace RJWSexperience
[HarmonyPatch(typeof(ParentRelationUtility), nameof(ParentRelationUtility.SetMother))] [HarmonyPatch(typeof(ParentRelationUtility), nameof(ParentRelationUtility.SetMother))]
public static class Rimworld_Patch_RemoveVirginOnSetMother public static class Rimworld_Patch_RemoveVirginOnSetMother
{ {
/// <summary>
/// Retcon virginity if game desides to generate a child for the pawn
/// </summary>
public static void Postfix(Pawn pawn, Pawn newMother) public static void Postfix(Pawn pawn, Pawn newMother)
{ {
if (!pawn.relations.DirectRelationExists(PawnRelationDefOf.Parent, newMother)) if (!pawn.relations.DirectRelationExists(PawnRelationDefOf.Parent, newMother))
return; return; // Failed to add relation?
Trait virgin = newMother.story?.traits?.GetTrait(RsDefOf.Trait.Virgin, Virginity.TraitDegree.FemaleVirgin); Trait virgin = newMother.story?.traits?.GetTrait(RsDefOf.Trait.Virgin, Virginity.TraitDegree.FemaleVirgin);
if (virgin != null) if (virgin != null)
{ {
newMother.story.traits.RemoveTrait(virgin); newMother.story.traits.RemoveTrait(virgin);
newMother.story.traits.GainTrait(new Trait(RsDefOf.Trait.Virgin, Virginity.TraitDegree.FemaleAfterSurgery));
// Player may notice the missing trait on their pawns.
// Doing this for all pawns results in up to a half of tribal raid generating with "virgin?"
if (newMother.IsColonist || newMother.IsPrisonerOfColony)
{
newMother.story.traits.GainTrait(new Trait(RsDefOf.Trait.Virgin, Virginity.TraitDegree.FemaleAfterSurgery));
}
} }
} }
} }

View File

@ -14,7 +14,9 @@ namespace RJWSexperience.Virginity
if (pawn.gender == Gender.Female && !pawn.IsVirgin()) if (pawn.gender == Gender.Female && !pawn.IsVirgin())
{ {
if (Rand.Chance(hymenSurgeryChance)) TechLevel techLevel = pawn.Faction?.def.techLevel ?? TechLevel.Industrial;
if (techLevel >= TechLevel.Industrial && Rand.Chance(hymenSurgeryChance))
{ {
Trait virgin = new Trait(RsDefOf.Trait.Virgin, TraitDegree.FemaleAfterSurgery, true); Trait virgin = new Trait(RsDefOf.Trait.Virgin, TraitDegree.FemaleAfterSurgery, true);
pawn.story.traits.GainTrait(virgin); pawn.story.traits.GainTrait(virgin);