Move event generation out of trait handler

This commit is contained in:
amevarashi 2022-06-17 19:47:49 +05:00
parent bb65120dd9
commit 758121ff4c
2 changed files with 18 additions and 13 deletions

View file

@ -83,19 +83,25 @@ namespace RJWSexperience
/// </summary> /// </summary>
public static void PoptheCherry(this Pawn pawn, Pawn partner, SexProps props) public static void PoptheCherry(this Pawn pawn, Pawn partner, SexProps props)
{ {
if (props?.sexType == xxx.rjwSextype.Vaginal) if (props?.sexType != xxx.rjwSextype.Vaginal)
return;
if (pawn.IsVirgin())
{ {
if (pawn.IsVirgin()) pawn.TryGetComp<SexHistory.SexHistoryComp>()?.RecordFirst(partner, props);
int? removedDegree = Virginity.TraitHandler.RemoveVirginTrait(pawn);
if (removedDegree != null)
{ {
pawn.TryGetComp<SexHistory.SexHistoryComp>()?.RecordFirst(partner, props); RJWUtility.ThrowVirginHIstoryEvent(pawn, partner, props, (int)removedDegree);
if (Virginity.TraitHandler.RemoveVirginTrait(pawn, partner, props)) Messages.Message(Keyed.RS_LostVirgin(pawn.LabelShort, partner.LabelShort), MessageTypeDefOf.NeutralEvent, true);
{
Messages.Message(Keyed.RS_LostVirgin(pawn.LabelShort, partner.LabelShort), MessageTypeDefOf.NeutralEvent, true);
}
} }
else }
else
{
int? removedDegree = Virginity.TraitHandler.RemoveVirginTrait(pawn);
if (removedDegree != null)
{ {
Virginity.TraitHandler.RemoveVirginTrait(pawn, partner, props); RJWUtility.ThrowVirginHIstoryEvent(pawn, partner, props, (int)removedDegree);
} }
} }
} }

View file

@ -46,20 +46,19 @@ namespace RJWSexperience.Virginity
} }
} }
public static bool RemoveVirginTrait(Pawn pawn, Pawn partner, SexProps props) public static int? RemoveVirginTrait(Pawn pawn)
{ {
Trait virgin = pawn.story?.traits?.GetTrait(VariousDefOf.Virgin); Trait virgin = pawn.story?.traits?.GetTrait(VariousDefOf.Virgin);
if (virgin == null) if (virgin == null)
return false; return null;
int degree = virgin.Degree; int degree = virgin.Degree;
if (pawn.gender == Gender.Female && degree > 0 && !pawn.Dead) if (pawn.gender == Gender.Female && degree > 0 && !pawn.Dead)
{ {
FilthMaker.TryMakeFilth(pawn.Position, pawn.Map, ThingDefOf.Filth_Blood, pawn.LabelShort, 1, FilthSourceFlags.Pawn); FilthMaker.TryMakeFilth(pawn.Position, pawn.Map, ThingDefOf.Filth_Blood, pawn.LabelShort, 1, FilthSourceFlags.Pawn);
} }
RJWUtility.ThrowVirginHIstoryEvent(pawn, partner, props, degree);
pawn.story.traits.RemoveTrait(virgin); pawn.story.traits.RemoveTrait(virgin);
return true; return degree;
} }
} }
} }