140 lines
4.7 KiB
C#
140 lines
4.7 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Verse;
|
|
using Verse.AI;
|
|
using Verse.AI.Group;
|
|
using RimWorld;
|
|
using rjw;
|
|
using UnityEngine;
|
|
using HarmonyLib;
|
|
|
|
namespace Privacy_Please
|
|
{
|
|
public static class SexInteractionUtility
|
|
{
|
|
public static bool PawnCaughtLovinByWitness(Pawn pawn, Pawn witness)
|
|
{
|
|
if (witness == null || pawn == witness || witness.IsUnableToSenseSex() || witness.CanSee(pawn) == false)
|
|
{ return false; }
|
|
|
|
List<Pawn> sexParticipants = pawn.GetAllSexParticipants();
|
|
bool witnessIsJoiningSex = witness.jobs.curDriver is JobDriver_SexBaseInitiator && sexParticipants.Contains((witness.jobs.curDriver as JobDriver_SexBaseInitiator).Partner);
|
|
|
|
if (sexParticipants.Contains(witness) || witnessIsJoiningSex)
|
|
{ return false; }
|
|
|
|
return true;
|
|
}
|
|
|
|
public static bool PawnIsCheatingOnPartner(Pawn pawn, Pawn partner)
|
|
{
|
|
List<Pawn> spouses = pawn.GetSpouses(false);
|
|
|
|
if (BasicSettings.worryAboutInfidelity == false ||
|
|
partner.IsLoverOfOther(pawn) == false ||
|
|
pawn.HasTrait("Polygamous") ||
|
|
partner.HasTrait("Polygamous") ||
|
|
partner.IsMasturbating() ||
|
|
partner.IsHavingSex() == false ||
|
|
partner.GetSexPartner()?.Dead == true ||
|
|
partner.GetSexPartner()?.IsAnimal() == true ||
|
|
partner.GetAllSexParticipants().Contains(pawn) ||
|
|
(spouses.NullOrEmpty() == false && partner.GetAllSexParticipants().Any(x => spouses.Contains(x))))
|
|
{ return false; }
|
|
|
|
return true;
|
|
}
|
|
|
|
public static bool SexParticipantsIncludesACheatingPartner(Pawn pawn, List<Pawn> participants)
|
|
{
|
|
foreach (Pawn participant in participants)
|
|
{
|
|
if (PawnIsCheatingOnPartner(pawn, participant))
|
|
{ return true; }
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public static bool PasserbyCanBePropositionedForSex(Pawn passerby, List<Pawn> participants)
|
|
{
|
|
if (passerby == null ||
|
|
participants.Contains(passerby) ||
|
|
participants.Any(x => x.CanSee(passerby) == false))
|
|
{ return false; }
|
|
|
|
if (participants.Count > 2 ||
|
|
participants.Any(x => x.IsForbidden(passerby) || x.HostileTo(passerby)) ||
|
|
CasualSex_Helper.CanHaveSex(passerby) == false ||
|
|
xxx.IsTargetPawnOkay(passerby) == false)
|
|
{ return false; }
|
|
|
|
if (SexUtility.ReadyForHookup(passerby) &&
|
|
(passerby?.jobs?.curJob == null || (passerby.jobs.curJob.playerForced == false && CasualSex_Helper.quickieAllowedJobs.Contains(passerby.jobs.curJob.def))) &&
|
|
participants.Any(x => SexAppraiser.would_fuck(x, passerby) > 0.1f && SexAppraiser.would_fuck(passerby, x) > 0.1f) &&
|
|
participants.All(x => SexAppraiser.would_fuck(x, passerby, false, false, true) > 0.1f && SexAppraiser.would_fuck(passerby, x, false, false, true) > 0.1f))
|
|
{ return true; }
|
|
|
|
return false;
|
|
}
|
|
|
|
public static void GetReactionsToSexDiscovery(JobDriver_Sex jobDriver, Pawn witness, out ReactionToSexDiscovery reactionOfPawn, out ReactionToSexDiscovery reactionOfWitness, bool applyThoughtDefs = false)
|
|
{
|
|
Pawn pawn = jobDriver.pawn;
|
|
|
|
reactionOfPawn = ReactionToSexDiscovery.Acceptance;
|
|
reactionOfWitness = ReactionToSexDiscovery.Acceptance;
|
|
|
|
// Determine if there are any issues with the sex event and the witness' morals
|
|
foreach (SexActReactionDef sexActReactionDef in DefDatabase<SexActReactionDef>.AllDefs)
|
|
{
|
|
var methodInfo = AccessTools.Method(typeof(SexInteractionUtility), sexActReactionDef.sexActCheck, null, null);
|
|
|
|
if (methodInfo == null)
|
|
{ DebugMode.Message("Method '" + sexActReactionDef.sexActCheck + "' was not found"); continue; }
|
|
|
|
if ((bool)methodInfo.Invoke(null, new object[] { jobDriver }))
|
|
{
|
|
DebugMode.Message(sexActReactionDef.defName);
|
|
sexActReactionDef.DetermineReactionOfPawns(pawn, witness, out reactionOfPawn, out reactionOfWitness, applyThoughtDefs);
|
|
}
|
|
}
|
|
}
|
|
|
|
public static bool SexActIsNecrophilia(JobDriver_Sex jobDriver)
|
|
{
|
|
return jobDriver.Partner != null && jobDriver.Partner.Dead;
|
|
}
|
|
|
|
public static bool SexActIsBestiality(JobDriver_Sex jobDriver)
|
|
{
|
|
return jobDriver.Partner != null && jobDriver.Partner.RaceProps.Animal;
|
|
}
|
|
|
|
public static bool SexActIsRape(JobDriver_Sex jobDriver)
|
|
{
|
|
return jobDriver is JobDriver_Rape || jobDriver is JobDriver_RapeEnemy || jobDriver is JobDriver_SexBaseRecieverRaped;
|
|
}
|
|
|
|
public static bool SexActIsXenophilia(JobDriver_Sex jobDriver)
|
|
{
|
|
return jobDriver.Partner != null && jobDriver.Partner.def.defName != jobDriver.pawn.def.defName;
|
|
}
|
|
|
|
public static bool SexActIsMasturbation(JobDriver_Sex jobDriver)
|
|
{
|
|
return jobDriver.pawn.IsMasturbating();
|
|
}
|
|
|
|
public static bool SexActIsExhibitionism(JobDriver_Sex jobDriver)
|
|
{
|
|
return jobDriver.pawn.IsHavingSex();
|
|
}
|
|
|
|
public static bool SexActIsInfidelity(JobDriver_Sex jobDriver)
|
|
{
|
|
return jobDriver.pawn.IsHavingSex();
|
|
}
|
|
}
|
|
}
|