2022-11-02 05:56:22 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using HarmonyLib;
|
|
|
|
|
using RimWorld;
|
|
|
|
|
using Verse;
|
|
|
|
|
using Verse.AI;
|
|
|
|
|
using rjw;
|
|
|
|
|
|
|
|
|
|
namespace Privacy_Please
|
|
|
|
|
{
|
|
|
|
|
[HarmonyPatch(typeof(JobDriver_Sex), "setup_ticks")]
|
|
|
|
|
public static class HarmonyPatch_JobDriver_Sex_setup_ticks
|
|
|
|
|
{
|
|
|
|
|
public static void Postfix(ref JobDriver_Sex __instance)
|
|
|
|
|
{
|
|
|
|
|
Pawn pawn = __instance.pawn;
|
|
|
|
|
|
|
|
|
|
// Invite another for a threesome?
|
|
|
|
|
if (RJWHookupSettings.QuickHookupsEnabled &&
|
|
|
|
|
__instance is JobDriver_SexBaseInitiator &&
|
|
|
|
|
pawn.GetAllSexParticipants().Count == 2 &&
|
|
|
|
|
(__instance is JobDriver_JoinInSex) == false &&
|
|
|
|
|
Random.value < BasicSettings.chanceForOtherToJoinInSex)
|
|
|
|
|
{
|
|
|
|
|
DebugMode.Message("Find another to join in sex");
|
|
|
|
|
|
|
|
|
|
List<Pawn> candidates = new List<Pawn>();
|
|
|
|
|
float radius = 4f;
|
|
|
|
|
|
|
|
|
|
foreach (Thing thing in GenRadial.RadialDistinctThingsAround(pawn.Position, pawn.Map, radius, true))
|
|
|
|
|
{
|
|
|
|
|
Pawn other = thing as Pawn;
|
2022-11-04 13:52:17 +00:00
|
|
|
|
ThoughtDef thoughtDef = null; // SexInteractionUtility.GetThoughtsAboutSexAct(other, __instance, out Precept precept);
|
2022-11-02 05:56:22 +00:00
|
|
|
|
|
|
|
|
|
// Find candidates to invite
|
2022-11-06 04:14:02 +00:00
|
|
|
|
if (other != null && thoughtDef?.hediff == null && SexInteractionUtility.PasserbyCanBePropositionedForSex(other, pawn.GetAllSexParticipants()))
|
2022-11-02 05:56:22 +00:00
|
|
|
|
{
|
|
|
|
|
DebugMode.Message(other.NameShortColored + " is a potential candidate");
|
|
|
|
|
candidates.Add(other);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Invite a random candidate (weighted by attraction)
|
|
|
|
|
if (candidates.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
Pawn invitedPawn = candidates.RandomElementByWeight(x => SexAppraiser.would_fuck(pawn, x, false, false, true) + SexAppraiser.would_fuck(pawn.GetSexPartner(), x, false, false, true));
|
|
|
|
|
pawn.GetSexInitiator().IsInBed(out Building bed);
|
|
|
|
|
|
|
|
|
|
DebugMode.Message(invitedPawn.NameShortColored + " was invited to join in sex");
|
|
|
|
|
|
|
|
|
|
Job job = new Job(DefDatabase<JobDef>.GetNamed("JoinInSex", false), pawn.GetSexPartner(), bed);
|
|
|
|
|
invitedPawn.jobs.TryTakeOrderedJob(job);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HarmonyPatch(typeof(JobDriver_Sex), "SexTick")]
|
|
|
|
|
public static class HarmonyPatch_JobDriver_Sex_SexTick
|
|
|
|
|
{
|
|
|
|
|
// If pawns don't have privacy, they'll stop having sex
|
|
|
|
|
public static void Postfix(ref JobDriver_Sex __instance, Pawn pawn)
|
|
|
|
|
{
|
|
|
|
|
if (pawn.IsHashIntervalTick(90))
|
|
|
|
|
{
|
2022-11-06 04:14:02 +00:00
|
|
|
|
if (pawn.IsMasturbating() || pawn.IsHavingSex())
|
|
|
|
|
{ PrivacyUtility.PrivacyCheckForPawn(pawn, 8f); }
|
2022-11-02 05:56:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|