Do not use full buckets

This commit is contained in:
amevarashi 2022-05-24 20:49:01 +05:00
parent eb3eb92ef5
commit 5a68c6ec58

View file

@ -1,198 +1,201 @@
using System.Collections.Generic; using RimWorld;
using rjw; using rjw;
using RimWorld; using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Helpers;
using rjw.Modules.Interactions.Objects;
using System.Collections.Generic;
using System.Linq;
using Verse; using Verse;
using Verse.AI; using Verse.AI;
using rjw.Modules.Interactions.Objects;
using rjw.Modules.Interactions.Helpers;
using rjw.Modules.Interactions.Enums;
namespace RJWSexperience namespace RJWSexperience
{ {
public static class RJWUtility public static class RJWUtility
{ {
public static bool RemoveVirginTrait(Pawn pawn, Pawn partner, SexProps props) public static bool RemoveVirginTrait(Pawn pawn, Pawn partner, SexProps props)
{ {
int degree; int degree;
Trait virgin = pawn.story?.traits?.GetTrait(VariousDefOf.Virgin); Trait virgin = pawn.story?.traits?.GetTrait(VariousDefOf.Virgin);
if (virgin != null) if (virgin != null)
{ {
degree = virgin.Degree; degree = virgin.Degree;
if (pawn.gender == Gender.Female && degree > 0) if (pawn.gender == Gender.Female && degree > 0)
{ {
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);
} }
ThrowVirginHIstoryEvent(pawn, partner, props, degree); ThrowVirginHIstoryEvent(pawn, partner, props, degree);
pawn.story.traits.RemoveTrait(virgin); pawn.story.traits.RemoveTrait(virgin);
return true; return true;
} }
return false; return false;
} }
/// <summary> /// <summary>
/// For ideo patch /// For ideo patch
/// </summary> /// </summary>
public static void ThrowVirginHIstoryEvent(Pawn pawn, Pawn partner, SexProps props, int degree) public static void ThrowVirginHIstoryEvent(Pawn pawn, Pawn partner, SexProps props, int degree)
{ {
//for non-ideo //for non-ideo
if (partner.Ideo == null) if (partner.Ideo == null)
{ {
partner.needs?.mood?.thoughts?.memories.TryGainMemory(xxx.took_virginity, pawn); partner.needs?.mood?.thoughts?.memories.TryGainMemory(xxx.took_virginity, pawn);
} }
} }
/* /*
* Uses RJW 4.9.0's new interactiondefs to determine giver and receiver based on reverse interactiontag * Uses RJW 4.9.0's new interactiondefs to determine giver and receiver based on reverse interactiontag
*/ */
public static void DetermineGiversAndReceivers(SexProps props, out Pawn giver, out Pawn receiver) public static void DetermineGiversAndReceivers(SexProps props, out Pawn giver, out Pawn receiver)
{ {
InteractionWithExtension interaction = InteractionHelper.GetWithExtension(props.dictionaryKey); InteractionWithExtension interaction = InteractionHelper.GetWithExtension(props.dictionaryKey);
if (interaction.HasInteractionTag(InteractionTag.Reverse)) if (interaction.HasInteractionTag(InteractionTag.Reverse))
{ {
receiver = props.partner; receiver = props.partner;
giver = props.pawn; giver = props.pawn;
} }
else else
{ {
receiver = props.pawn; receiver = props.pawn;
giver = props.partner; giver = props.partner;
} }
} }
public static void UpdateSextypeRecords(SexProps props) public static void UpdateSextypeRecords(SexProps props)
{ {
xxx.rjwSextype sextype = props.sexType; xxx.rjwSextype sextype = props.sexType;
Pawn pawn = props.pawn; Pawn pawn = props.pawn;
Pawn partner = props.partner; Pawn partner = props.partner;
DetermineGiversAndReceivers(props, out Pawn giver, out Pawn receiver); DetermineGiversAndReceivers(props, out Pawn giver, out Pawn receiver);
if (partner != null) if (partner != null)
{ {
switch (sextype) switch (sextype)
{ {
case xxx.rjwSextype.Vaginal: case xxx.rjwSextype.Vaginal:
case xxx.rjwSextype.Scissoring: case xxx.rjwSextype.Scissoring:
IncreaseSameRecords(pawn, partner, VariousDefOf.VaginalSexCount); IncreaseSameRecords(pawn, partner, VariousDefOf.VaginalSexCount);
break; break;
case xxx.rjwSextype.Anal: case xxx.rjwSextype.Anal:
IncreaseSameRecords(pawn, partner, VariousDefOf.AnalSexCount); IncreaseSameRecords(pawn, partner, VariousDefOf.AnalSexCount);
break; break;
case xxx.rjwSextype.Oral: case xxx.rjwSextype.Oral:
case xxx.rjwSextype.Fellatio: case xxx.rjwSextype.Fellatio:
if (Genital_Helper.has_penis_fertile(giver) || Genital_Helper.has_penis_infertile(giver)) if (Genital_Helper.has_penis_fertile(giver) || Genital_Helper.has_penis_infertile(giver))
{ {
IncreaseRecords(giver, receiver, VariousDefOf.OralSexCount, VariousDefOf.BlowjobCount); IncreaseRecords(giver, receiver, VariousDefOf.OralSexCount, VariousDefOf.BlowjobCount);
} }
else if (Genital_Helper.has_penis_fertile(receiver) || Genital_Helper.has_penis_infertile(receiver)) else if (Genital_Helper.has_penis_fertile(receiver) || Genital_Helper.has_penis_infertile(receiver))
{ {
IncreaseRecords(giver, receiver, VariousDefOf.BlowjobCount, VariousDefOf.OralSexCount); IncreaseRecords(giver, receiver, VariousDefOf.BlowjobCount, VariousDefOf.OralSexCount);
} }
break; break;
case xxx.rjwSextype.Sixtynine: case xxx.rjwSextype.Sixtynine:
IncreaseSameRecords(pawn, partner, VariousDefOf.OralSexCount); IncreaseSameRecords(pawn, partner, VariousDefOf.OralSexCount);
RecordDef recordpawn, recordpartner; RecordDef recordpawn, recordpartner;
if (Genital_Helper.has_penis_fertile(pawn) || Genital_Helper.has_penis_infertile(pawn)) if (Genital_Helper.has_penis_fertile(pawn) || Genital_Helper.has_penis_infertile(pawn))
{ {
recordpartner = VariousDefOf.BlowjobCount; recordpartner = VariousDefOf.BlowjobCount;
} }
else else
{ {
recordpartner = VariousDefOf.CunnilingusCount; recordpartner = VariousDefOf.CunnilingusCount;
} }
if (Genital_Helper.has_penis_fertile(partner) || Genital_Helper.has_penis_infertile(partner)) if (Genital_Helper.has_penis_fertile(partner) || Genital_Helper.has_penis_infertile(partner))
{ {
recordpawn = VariousDefOf.BlowjobCount; recordpawn = VariousDefOf.BlowjobCount;
} }
else else
{ {
recordpawn = VariousDefOf.CunnilingusCount; recordpawn = VariousDefOf.CunnilingusCount;
} }
IncreaseRecords(pawn, partner, recordpawn, recordpartner); IncreaseRecords(pawn, partner, recordpawn, recordpartner);
break; break;
case xxx.rjwSextype.Cunnilingus: case xxx.rjwSextype.Cunnilingus:
if (Genital_Helper.has_vagina(giver)) if (Genital_Helper.has_vagina(giver))
{ {
IncreaseRecords(giver, receiver, VariousDefOf.OralSexCount, VariousDefOf.CunnilingusCount); IncreaseRecords(giver, receiver, VariousDefOf.OralSexCount, VariousDefOf.CunnilingusCount);
} }
else if (Genital_Helper.has_vagina(receiver)) else if (Genital_Helper.has_vagina(receiver))
{ {
IncreaseRecords(giver, receiver, VariousDefOf.CunnilingusCount, VariousDefOf.OralSexCount); IncreaseRecords(giver, receiver, VariousDefOf.CunnilingusCount, VariousDefOf.OralSexCount);
} }
break; break;
case xxx.rjwSextype.Masturbation: case xxx.rjwSextype.Masturbation:
break; break;
case xxx.rjwSextype.Handjob: case xxx.rjwSextype.Handjob:
if (Genital_Helper.has_penis_fertile(giver) || Genital_Helper.has_penis_infertile(giver)) if (Genital_Helper.has_penis_fertile(giver) || Genital_Helper.has_penis_infertile(giver))
{ {
IncreaseRecords(giver, receiver, VariousDefOf.GenitalCaressCount, VariousDefOf.HandjobCount); IncreaseRecords(giver, receiver, VariousDefOf.GenitalCaressCount, VariousDefOf.HandjobCount);
} }
else else
{ {
IncreaseRecords(giver, receiver, VariousDefOf.HandjobCount, VariousDefOf.GenitalCaressCount); IncreaseRecords(giver, receiver, VariousDefOf.HandjobCount, VariousDefOf.GenitalCaressCount);
} }
break; break;
case xxx.rjwSextype.Fingering: case xxx.rjwSextype.Fingering:
case xxx.rjwSextype.Fisting: case xxx.rjwSextype.Fisting:
if (Genital_Helper.has_vagina(giver)) if (Genital_Helper.has_vagina(giver))
{ {
IncreaseRecords(giver, receiver, VariousDefOf.GenitalCaressCount, VariousDefOf.FingeringCount); IncreaseRecords(giver, receiver, VariousDefOf.GenitalCaressCount, VariousDefOf.FingeringCount);
} }
else else
{ {
IncreaseRecords(giver, receiver, VariousDefOf.FingeringCount, VariousDefOf.GenitalCaressCount); IncreaseRecords(giver, receiver, VariousDefOf.FingeringCount, VariousDefOf.GenitalCaressCount);
} }
break; break;
case xxx.rjwSextype.Footjob: case xxx.rjwSextype.Footjob:
IncreaseSameRecords(pawn, partner, VariousDefOf.FootjobCount); IncreaseSameRecords(pawn, partner, VariousDefOf.FootjobCount);
break; break;
default: default:
IncreaseSameRecords(pawn, partner, VariousDefOf.MiscSexualBehaviorCount); IncreaseSameRecords(pawn, partner, VariousDefOf.MiscSexualBehaviorCount);
break; break;
} }
} }
} }
public static void UpdatePartnerHistory(Pawn pawn, Pawn partner, SexProps props) public static void UpdatePartnerHistory(Pawn pawn, Pawn partner, SexProps props)
{ {
if (partner != null) if (partner != null)
{ {
pawn.TryGetComp<SexHistoryComp>()?.RecordSex(partner, props); pawn.TryGetComp<SexHistoryComp>()?.RecordSex(partner, props);
} }
} }
public static void IncreaseSameRecords(Pawn pawn, Pawn partner, RecordDef record) public static void IncreaseSameRecords(Pawn pawn, Pawn partner, RecordDef record)
{ {
pawn.records?.AddTo(record, 1); pawn.records?.AddTo(record, 1);
partner.records?.AddTo(record, 1); partner.records?.AddTo(record, 1);
} }
public static void IncreaseRecords(Pawn pawn, Pawn partner, RecordDef recordforpawn, RecordDef recordforpartner) public static void IncreaseRecords(Pawn pawn, Pawn partner, RecordDef recordforpawn, RecordDef recordforpartner)
{ {
pawn.records?.AddTo(recordforpawn, 1); pawn.records?.AddTo(recordforpawn, 1);
partner.records?.AddTo(recordforpartner, 1); partner.records?.AddTo(recordforpartner, 1);
} }
// Moved this method back because of Menstruation // Moved this method back because of Menstruation
public static Building_CumBucket FindClosestBucket(this Pawn pawn) public static Building_CumBucket FindClosestBucket(this Pawn pawn)
{ {
List<Building> buckets = pawn.Map.listerBuildings.allBuildingsColonist.FindAll(x => x is Building_CumBucket); List<Building> buckets = pawn.Map.listerBuildings.allBuildingsColonist.FindAll(x => x is Building_CumBucket bucket && bucket.StoredStackCount < VariousDefOf.GatheredCum.stackLimit);
Dictionary<Building, float> targets = new Dictionary<Building, float>(); if (buckets.NullOrEmpty())
if (!buckets.NullOrEmpty()) for (int i = 0; i < buckets.Count; i++) return null;
{
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;
}
} 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;
}
}
} }