using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using RimWorld; using Verse; using Verse.AI; using Verse.AI.Group; using rjw; namespace Privacy_Please { public static class PrivacyUtility { public static bool PawnHasPrivacy(Pawn pawn, float radius) { //if (pawn.IsUnfazedBySex()) //{ return true; } if (pawn.IsHavingSex() == false && pawn.IsMasturbating() == false) { return true; } //if (pawn.GetLord() != null && (pawn.GetLord().LordJob is LordJob_Ritual || pawn.GetLord().LordJob is LordJob_Joinable_Party) && BasicSettings.ignoreRitualAndPartySex) //{ return true; } bool hasPrivacy = true; pawn.IsInBed(out Building bed); foreach (Thing thing in GenRadial.RadialDistinctThingsAround(pawn.Position, pawn.Map, radius, true)) { Pawn witness = thing as Pawn; if (witness == null) continue; // Caught having sex if (SexInteractionUtility.PawnCaughtLovinByWitness(pawn, witness)) { // Try to invite intruder to join in if (SexInteractionUtility.GetReactionToSexAct(witness, pawn.jobs.curDriver as JobDriver_Sex) >= (int)ReactionToSexAct.Acceptance) { // TODO roll for sex if (CasualSex_Helper.CanHaveSex(witness) && xxx.IsTargetPawnOkay(witness) && (xxx.has_quirk(witness, "Voyeur") || (xxx.has_quirk(witness, "Cuckold") && SexInteractionUtility.SexParticipantsIncludesACheatingPartner(witness, pawn.GetAllSexParticipants())))) { Job job = new Job(DefDatabase.GetNamed("WatchSex", false), pawn.GetSexReceiver(), bed); witness.jobs.TryTakeOrderedJob(job); } else if (pawn.IsMasturbating()) { if (bed == null) { Job job = new Job(xxx.quick_sex, pawn); witness.jobs.TryTakeOrderedJob(job); } else { Job job = new Job(xxx.casual_sex, pawn, bed); witness.jobs.TryTakeOrderedJob(job); } } else if (pawn.GetSexReceiver() != null) { Job job = new Job(DefDatabase.GetNamed("JoinInSex", false), pawn.GetSexReceiver(), bed); witness.jobs.TryTakeOrderedJob(job); } } else { hasPrivacy = false; } } } return BasicSettings.needPrivacy == false || hasPrivacy || xxx.has_quirk(pawn, "Exhibitionist") || pawn?.ideo?.Ideo.HasPrecept(ModPreceptDefOf.Exhibitionism_Acceptable) == true || pawn?.ideo?.Ideo.HasPrecept(ModPreceptDefOf.Exhibitionism_Approved) == true; } } }