Simplified virginity checks

Updated names in the SexHistoryComp
This commit is contained in:
amevarashi 2023-04-21 20:19:37 +05:00
parent 67c2328ad6
commit ab485c677f
7 changed files with 83 additions and 86 deletions

View file

@ -13,7 +13,7 @@ namespace RJWSexperience
return false;
IEnumerable<PawnRelationDef> relations = pawn.GetRelations(otherpawn);
if (relations.EnumerableNullOrEmpty())
if (relations == null)
return false;
foreach (PawnRelationDef relation in relations)
@ -66,32 +66,31 @@ namespace RJWSexperience
}
/// <summary>
/// If the pawn is virgin, return true.
/// Check if the pawn is virgin
/// </summary>
public static bool IsVirgin(this Pawn pawn)
{
return pawn.records.GetValue(RsDefOf.Record.VaginalSexCount) == 0;
return pawn.records.GetValue(RsDefOf.Record.VaginalSexCount) == 0 ||
pawn.relations?.ChildrenCount > 0; // Male is a virgins unless he stick into vagina? Not sure it should work this way
}
/// <summary>
/// If pawn is virgin, lose his/her virginity.
/// Remove virginity if pawn is virgin and announce it
/// </summary>
public static void PoptheCherry(this Pawn pawn, Pawn partner, SexProps props)
public static void TryRemoveVirginity(this Pawn pawn, Pawn partner, SexProps props)
{
if (props?.sexType != xxx.rjwSextype.Vaginal)
return;
int? removedDegree = Virginity.TraitHandler.RemoveVirginTrait(pawn);
if (pawn.IsVirgin())
if (SexperienceMod.Settings.EnableSexHistory && pawn.IsVirgin())
{
pawn.TryGetComp<SexHistory.SexHistoryComp>()?.RecordFirst(partner, props);
if (removedDegree != null)
Messages.Message(Keyed.RS_LostVirgin(pawn.LabelShort, partner.LabelShort), MessageTypeDefOf.NeutralEvent, true);
pawn.TryGetComp<SexHistory.SexHistoryComp>()?.RecordFirst(partner);
}
if (removedDegree != null)
if (removedDegree != null && removedDegree != Virginity.TraitDegree.FemaleAfterSurgery)
{
Messages.Message(Keyed.RS_LostVirgin(pawn.LabelShort, partner.LabelShort), MessageTypeDefOf.NeutralEvent, true);
RJWUtility.ThrowVirginHistoryEvent(pawn, partner, props, (int)removedDegree);
}
}
}
}

View file

@ -19,11 +19,22 @@ namespace RJWSexperience.ExtensionMethods
public static bool IsBestiality(this SexProps props)
{
if (props.partner != null)
if (props.hasPartner())
{
return props.pawn.IsAnimal() ^ props.partner.IsAnimal();
}
return false;
}
/// <summary>
/// Get a not-so-unique ID. Same interaction between the same partners will return same ID
/// </summary>
public static int GetTempId(this SexProps props)
{
return props.pawn.GetHashCode() ^
(props.partner?.GetHashCode() ?? 0) ^
props.dictionaryKey.GetHashCode() ^
(props.isReceiver ? 0 : 1);
}
}
}