RJW-Sexperience/Source/RJWSexperience/RJWUtility.cs

177 lines
5.7 KiB
C#
Raw Normal View History

2022-05-24 15:49:01 +00:00
using RimWorld;
2021-09-24 15:14:02 +00:00
using rjw;
2022-05-24 15:49:01 +00:00
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Helpers;
using rjw.Modules.Interactions.Objects;
using System.Collections.Generic;
2021-09-24 15:14:02 +00:00
using Verse;
using Verse.AI;
2021-09-24 15:14:02 +00:00
namespace RJWSexperience
{
public static class RJWUtility
2022-05-24 15:49:01 +00:00
{
/// <summary>
/// For ideo patch
/// </summary>
2022-06-11 09:23:28 +00:00
[System.Diagnostics.CodeAnalysis.SuppressMessage("Redundancy", "RCS1163:Unused parameter.", Justification = "All parameters are needed for the ideology patch")]
2023-03-24 15:22:54 +00:00
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "All parameters are needed for the ideology patch")]
2022-07-08 17:48:57 +00:00
public static void ThrowVirginHistoryEvent(Pawn exVirgin, Pawn partner, SexProps props, int degree)
2022-05-24 15:49:01 +00:00
{
//for non-ideo
if (partner.Ideo == null)
{
2022-07-08 17:48:57 +00:00
partner.needs?.mood?.thoughts?.memories.TryGainMemory(xxx.took_virginity, exVirgin);
2022-05-24 15:49:01 +00:00
}
}
2021-09-24 15:14:02 +00:00
2022-05-24 15:49:01 +00:00
/*
* Uses RJW 4.9.0's new interactiondefs to determine giver and receiver based on reverse interactiontag
*/
2022-05-24 15:49:01 +00:00
public static void DetermineGiversAndReceivers(SexProps props, out Pawn giver, out Pawn receiver)
{
InteractionWithExtension interaction = InteractionHelper.GetWithExtension(props.dictionaryKey);
if (interaction.HasInteractionTag(InteractionTag.Reverse))
{
receiver = props.partner;
giver = props.pawn;
}
else
{
receiver = props.pawn;
giver = props.partner;
}
}
2022-05-24 15:49:01 +00:00
public static void UpdateSextypeRecords(SexProps props)
{
xxx.rjwSextype sextype = props.sexType;
Pawn pawn = props.pawn;
Pawn partner = props.partner;
2022-05-24 15:49:01 +00:00
DetermineGiversAndReceivers(props, out Pawn giver, out Pawn receiver);
2022-05-24 15:49:01 +00:00
if (partner != null)
{
switch (sextype)
{
case xxx.rjwSextype.Vaginal:
case xxx.rjwSextype.Scissoring:
IncreaseSameRecords(pawn, partner, VariousDefOf.VaginalSexCount);
break;
case xxx.rjwSextype.Anal:
IncreaseSameRecords(pawn, partner, VariousDefOf.AnalSexCount);
break;
case xxx.rjwSextype.Oral:
case xxx.rjwSextype.Fellatio:
if (Genital_Helper.has_penis_fertile(giver) || Genital_Helper.has_penis_infertile(giver))
{
IncreaseRecords(giver, receiver, VariousDefOf.OralSexCount, VariousDefOf.BlowjobCount);
}
else if (Genital_Helper.has_penis_fertile(receiver) || Genital_Helper.has_penis_infertile(receiver))
{
IncreaseRecords(giver, receiver, VariousDefOf.BlowjobCount, VariousDefOf.OralSexCount);
}
break;
case xxx.rjwSextype.Sixtynine:
IncreaseSameRecords(pawn, partner, VariousDefOf.OralSexCount);
RecordDef recordpawn, recordpartner;
if (Genital_Helper.has_penis_fertile(pawn) || Genital_Helper.has_penis_infertile(pawn))
{
recordpartner = VariousDefOf.BlowjobCount;
}
else
{
recordpartner = VariousDefOf.CunnilingusCount;
}
2021-09-24 15:14:02 +00:00
2022-05-24 15:49:01 +00:00
if (Genital_Helper.has_penis_fertile(partner) || Genital_Helper.has_penis_infertile(partner))
{
recordpawn = VariousDefOf.BlowjobCount;
}
else
{
recordpawn = VariousDefOf.CunnilingusCount;
}
IncreaseRecords(pawn, partner, recordpawn, recordpartner);
break;
case xxx.rjwSextype.Cunnilingus:
if (Genital_Helper.has_vagina(giver))
{
IncreaseRecords(giver, receiver, VariousDefOf.OralSexCount, VariousDefOf.CunnilingusCount);
}
else if (Genital_Helper.has_vagina(receiver))
{
IncreaseRecords(giver, receiver, VariousDefOf.CunnilingusCount, VariousDefOf.OralSexCount);
}
break;
case xxx.rjwSextype.Masturbation:
break;
case xxx.rjwSextype.Handjob:
if (Genital_Helper.has_penis_fertile(giver) || Genital_Helper.has_penis_infertile(giver))
{
IncreaseRecords(giver, receiver, VariousDefOf.GenitalCaressCount, VariousDefOf.HandjobCount);
}
else
{
IncreaseRecords(giver, receiver, VariousDefOf.HandjobCount, VariousDefOf.GenitalCaressCount);
}
break;
case xxx.rjwSextype.Fingering:
case xxx.rjwSextype.Fisting:
if (Genital_Helper.has_vagina(giver))
{
IncreaseRecords(giver, receiver, VariousDefOf.GenitalCaressCount, VariousDefOf.FingeringCount);
}
else
{
IncreaseRecords(giver, receiver, VariousDefOf.FingeringCount, VariousDefOf.GenitalCaressCount);
}
break;
case xxx.rjwSextype.Footjob:
IncreaseSameRecords(pawn, partner, VariousDefOf.FootjobCount);
break;
default:
IncreaseSameRecords(pawn, partner, VariousDefOf.MiscSexualBehaviorCount);
break;
}
}
}
2021-09-24 15:14:02 +00:00
2022-05-24 15:49:01 +00:00
public static void IncreaseSameRecords(Pawn pawn, Pawn partner, RecordDef record)
{
pawn.records?.AddTo(record, 1);
partner.records?.AddTo(record, 1);
}
2021-09-24 15:14:02 +00:00
2022-05-24 15:49:01 +00:00
public static void IncreaseRecords(Pawn pawn, Pawn partner, RecordDef recordforpawn, RecordDef recordforpartner)
{
pawn.records?.AddTo(recordforpawn, 1);
partner.records?.AddTo(recordforpartner, 1);
}
2022-05-24 15:49:01 +00:00
// Moved this method back because of Menstruation
public static Building_CumBucket FindClosestBucket(this Pawn pawn)
{
List<Building> buckets = pawn.Map.listerBuildings.allBuildingsColonist.FindAll(x => x is Building_CumBucket bucket && bucket.StoredStackCount < VariousDefOf.GatheredCum.stackLimit);
if (buckets.NullOrEmpty())
return null;
2022-05-24 15:49:01 +00:00
Dictionary<Building, float> targets = new Dictionary<Building, float>();
for (int i = 0; i < buckets.Count; i++)
{
if (pawn.CanReach(buckets[i], PathEndMode.ClosestTouch, Danger.None))
{
targets.Add(buckets[i], pawn.Position.DistanceTo(buckets[i].Position));
}
}
if (!targets.NullOrEmpty())
{
return (Building_CumBucket)targets.MinBy(x => x.Value).Key;
}
return null;
}
}
2021-09-24 15:14:02 +00:00
}