Remove virgin trait if game generates a child

This commit is contained in:
amevarashi 2022-06-23 21:57:22 +05:00
parent 0bd8d809e0
commit 9e121d1f30

View file

@ -1,4 +1,5 @@
using HarmonyLib; using HarmonyLib;
using RimWorld;
using rjw; using rjw;
using System; using System;
using Verse; using Verse;
@ -22,4 +23,21 @@ namespace RJWSexperience
Virginity.TraitHandler.GenerateVirginTrait(__result); Virginity.TraitHandler.GenerateVirginTrait(__result);
} }
} }
[HarmonyPatch(typeof(ParentRelationUtility), nameof(ParentRelationUtility.SetMother))]
public static class Rimworld_Patch_RemoveVirginOnSetMother
{
public static void Postfix(Pawn pawn, Pawn newMother)
{
if (!pawn.relations.DirectRelationExists(PawnRelationDefOf.Parent, newMother))
return;
Trait virgin = newMother.story?.traits?.GetTrait(VariousDefOf.Virgin, Virginity.TraitDegree.FemaleVirgin);
if (virgin != null)
{
newMother.story.traits.RemoveTrait(virgin);
newMother.story.traits.GainTrait(new Trait(VariousDefOf.Virgin, Virginity.TraitDegree.FemaleAfterSurgery));
}
}
}
} }