This commit is contained in:
AbstractConcept 2022-11-04 08:52:17 -05:00
parent 55402b9891
commit 03e634e56c
36 changed files with 866 additions and 491 deletions

View file

@ -10,7 +10,7 @@ namespace Privacy_Please
public static void Message(string text)
{
if (BasicSettings.debugMode)
{ Log.Message("[DEBUG] " + text); }
{ Log.Message("[Privacy, Please!] " + text); }
}
}
}

View file

@ -0,0 +1,10 @@
namespace Privacy_Please
{
public enum ReactionToSexAct
{
Approval = 1,
Acceptance = 0,
Discomfort = -1,
Outrage = -2,
}
}

View file

@ -0,0 +1,84 @@
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<JobDef>.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<JobDef>.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;
}
}
}

View file

@ -6,6 +6,7 @@ using Verse.AI.Group;
using RimWorld;
using rjw;
using UnityEngine;
using HarmonyLib;
namespace Privacy_Please
{
@ -13,10 +14,12 @@ namespace Privacy_Please
{
public static bool PawnCaughtLovinByWitness(Pawn pawn, Pawn witness)
{
return true;
if (witness == null ||
pawn == witness ||
(pawn.IsMasturbating() == false && pawn.IsHavingSex() == false) ||
witness.UnworriedAboutHumanSex() == false ||
witness.IsUnfazedBySex() == false ||
witness.CanSee(pawn) == false)
{ return false; }
@ -25,7 +28,7 @@ namespace Privacy_Please
if (sexParticipants.Contains(witness) || witnessIsApproachingSexParticipant)
{ return false; }
return true;
}
@ -63,7 +66,7 @@ namespace Privacy_Please
{
if (passerby == null ||
participants.Contains(passerby) ||
passerby.UnworriedAboutHumanSex() == false ||
passerby.IsUnfazedBySex() == false ||
participants.All(x => x.CanSee(passerby) == false))
{ return false; }
@ -90,214 +93,62 @@ namespace Privacy_Please
return false;
}
public static ThoughtDef GetThoughtsAboutSexAct(Pawn pawn, JobDriver_Sex jobDriver, out Precept precept)
public static ReactionToSexAct GetReactionToSexAct(Pawn witness, JobDriver_Sex jobDriver, bool applyThoughtDefs = false)
{
ThoughtDef thoughtDef = null;
precept = null;
if (pawn == null || jobDriver == null) return null;
if (BasicSettings.slavesIgnoreSex && (pawn.IsPrisoner || pawn.IsSlave)) return null;
if (BasicSettings.otherFactionsIgnoreSex && pawn.Faction.IsPlayer == false) return null;
bool sexIsNecro = jobDriver.Partner != null && jobDriver.Partner.Dead;
bool sexIsBeastial = jobDriver.Partner != null && jobDriver.Partner.RaceProps.Animal;
bool sexIsRape = sexIsBeastial == false && sexIsNecro == false &&
(jobDriver is JobDriver_Rape || jobDriver is JobDriver_RapeEnemy || jobDriver is JobDriver_SexBaseRecieverRaped);
bool sexIsSlaveRape = sexIsRape && (jobDriver.Partner.IsPrisoner || jobDriver.Partner.IsSlave);
bool sexIsXeno = jobDriver.Partner != null && jobDriver.Partner.def.defName != jobDriver.pawn.def.defName;
bool isXenophobe = pawn.HasTrait("Xenophobia") && pawn.story.traits.DegreeOfTrait(DefDatabase<TraitDef>.GetNamedSilentFail("Xenophobia")) > 0;
bool isXenophile = pawn.HasTrait("Xenophobia") && pawn.story.traits.DegreeOfTrait(DefDatabase<TraitDef>.GetNamedSilentFail("Xenophobia")) < 0;
bool sexIsSolo = jobDriver.pawn.IsMasturbating();
bool sexIsIncest = jobDriver.Partner != null && jobDriver.pawn.GetRelations(jobDriver.Partner).Any(x => x.familyByBloodRelation);
if (BasicSettings.worryAboutNecro && sexIsNecro && xxx.is_necrophiliac(pawn) == false)
{
thoughtDef = xxx.is_necrophiliac(pawn) ? DefDatabase<ThoughtDef>.GetNamedSilentFail("SawNecrophilia_Honorable") :
pawn.HasPreceptForIssue("Necrophilia", out precept) ? DefDatabase<ThoughtDef>.GetNamedSilentFail("Saw" + precept.def.defName) :
DefDatabase<ThoughtDef>.GetNamedSilentFail("SawNecrophilia_Abhorrent");
}
else if (BasicSettings.worryAboutBeastiality && sexIsBeastial)
{
thoughtDef = xxx.is_zoophile(pawn) ? DefDatabase<ThoughtDef>.GetNamedSilentFail("SawBeastility_Honorable") :
pawn.HasPreceptForIssue("Beastility", out precept) ? DefDatabase<ThoughtDef>.GetNamedSilentFail("Saw" + precept.def.defName) :
DefDatabase<ThoughtDef>.GetNamedSilentFail("SawBeastility_Abhorrent");
}
else if (BasicSettings.worryAboutRape && BasicSettings.ignoreSlaveRape == false && sexIsSlaveRape)
{
thoughtDef = xxx.is_rapist(pawn) ? DefDatabase<ThoughtDef>.GetNamedSilentFail("SawRape_Honorable") :
pawn.HasPreceptForIssue("Rape", out precept) ? DefDatabase<ThoughtDef>.GetNamedSilentFail("Saw" + precept.def.defName) :
DefDatabase<ThoughtDef>.GetNamedSilentFail("SawRape_Abhorrent");
}
else if (BasicSettings.worryAboutRape && sexIsRape)
{
thoughtDef = xxx.is_rapist(pawn) ? DefDatabase<ThoughtDef>.GetNamedSilentFail("SawRape_Honorable") :
pawn.HasPreceptForIssue("Rape", out precept) ? DefDatabase<ThoughtDef>.GetNamedSilentFail("Saw" + precept.def.defName) :
DefDatabase<ThoughtDef>.GetNamedSilentFail("SawRape_Abhorrent");
}
else if (BasicSettings.worryAboutXeno && sexIsXeno)
{
thoughtDef = isXenophobe ? DefDatabase<ThoughtDef>.GetNamedSilentFail("SawHAR_AlienDating_Prohibited") :
isXenophile ? DefDatabase<ThoughtDef>.GetNamedSilentFail("SawHAR_AlienDating_Honorable") :
pawn.HasPreceptForIssue("HAR_AlienDating", out precept) ? DefDatabase<ThoughtDef>.GetNamedSilentFail("Saw" + precept.def.defName) :
DefDatabase<ThoughtDef>.GetNamedSilentFail("SawHAR_AlienDating_Acceptable");
}
else if (BasicSettings.worryAboutMasturbation && sexIsSolo)
{
thoughtDef = pawn.HasPreceptForIssue("Masturbation", out precept) ? DefDatabase<ThoughtDef>.GetNamedSilentFail("Saw" + precept.def.defName) :
DefDatabase<ThoughtDef>.GetNamedSilentFail("SawMasturbation_Disapproved");
}
else if (BasicSettings.worryAboutIncest && sexIsIncest)
{
}
DebugMode.Message("Sex job is: " + jobDriver + " Issue is: " + (precept?.def?.issue?.defName).ToStringSafe() + " Opinion is: " + (precept?.def?.defName).ToStringSafe() + " Thought is: " + (thoughtDef?.defName).ToStringSafe());
return thoughtDef;
}
public static bool InvitePasserbyForSex(Pawn pawn, Pawn witness, out bool brokeTaboo)
{
brokeTaboo = false;
bool witnessJoiningSex = Random.value < BasicSettings.chanceForOtherToJoinInSex && CouldInvitePasserbyForSex(witness, pawn.GetAllSexParticipants());
// Exit clauses
if (witness.UnworriedAboutHumanSex() == true)
{ return false; }
// Get basic thoughts
ThoughtDef pawnThoughtDef = BasicSettings.needPrivacy ? ModThoughtDefOf.SeenHavingSex : null;
ThoughtDef witnessThoughtDef = BasicSettings.needPrivacy ? ModThoughtDefOf.SawSex : null;
// Exhibitionist pawn (overrides needPrivacy)
if (xxx.has_quirk(pawn, "Exhibitionist") || pawn?.ideo?.Ideo.HasPrecept(ModPreceptDefOf.Exhibitionism_Approved) == true)
{ pawnThoughtDef = ModThoughtDefOf.SeenHavingSexExhibitionist; }
// Voyeuristic witness (overrides needPrivacy)
if (xxx.has_quirk(witness, "Voyeur"))
{ witnessThoughtDef = ModThoughtDefOf.SawSexVoyeur; }
// Mediating cirumstances
bool sexIsRitual = pawn.GetLord() != null && pawn.GetLord().LordJob is LordJob_Ritual && witness?.Ideo == pawn?.Ideo;
bool sexIsParty = pawn.GetLord() != null && pawn.GetLord().LordJob is LordJob_Joinable_Party;
bool pawnIsVictim = pawn.CurJob.def == xxx.gettin_raped || pawn.Dead;
bool mitigatingCirumstances = sexIsRitual || sexIsParty || pawnIsVictim;
bool pawnIsCheating = mitigatingCirumstances == false && PawnIsCheatingOnPartner(pawn, witness);
// Override thoughts if pawn is a victim
if (pawnIsVictim)
{
pawnThoughtDef = null;
witnessThoughtDef = null;
}
// Add thought if pawn is cheating
else if (pawnIsCheating)
{
if (pawn.needs.mood.thoughts.memories.GetFirstMemoryOfDef(ModThoughtDefOf.CaughtCheating) == null)
{ pawn.needs.mood.thoughts.memories.TryGainMemory(ModThoughtDefOf.CaughtCheating, witness); }
if (witness.needs.mood.thoughts.memories.GetFirstMemoryOfDef(ThoughtDefOf.CheatedOnMe) == null)
{ witness.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.CheatedOnMe, pawn); }
witnessJoiningSex = false;
}
Pawn pawn = jobDriver.pawn;
ReactionToSexAct reactionOfWitness = ReactionToSexAct.Acceptance;
// Determine if there are any issues with the sex event and the witness' morals
ThoughtDef newWitnessThoughtDef = GetThoughtsAboutSexAct(witness, pawn.jobs.curDriver as JobDriver_Sex, out Precept precept);
// Update their thoughts if there are no migitating circumstances or the thought provides a positive morale boost larger than the original
if (newWitnessThoughtDef != null && (mitigatingCirumstances == false || (newWitnessThoughtDef.stages[0].baseMoodEffect > 0 && newWitnessThoughtDef.stages[0].baseMoodEffect > witnessThoughtDef.stages[0].baseMoodEffect)))
{ witnessThoughtDef = newWitnessThoughtDef; }
// Apply thoughts to witness
if (witnessThoughtDef != null)
foreach (SexActReactionDef sexActReactionDef in DefDatabase<SexActReactionDef>.AllDefs)
{
witness.needs.mood.thoughts.memories.TryGainMemory(witnessThoughtDef, pawn, precept);
var methodInfo = AccessTools.Method(typeof(SexInteractionUtility), sexActReactionDef.sexActCheck, null, null);
if (witnessThoughtDef.stages[0].baseMoodEffect < 0)
{ witness?.TryGetComp<CompPawnThoughtData>()?.TryToExclaim(); }
if (methodInfo == null)
{ DebugMode.Message("Method '" + sexActReactionDef.sexActCheck + "' was not found"); continue; }
witnessJoiningSex = witnessThoughtDef.hediff != null ? false : witnessJoiningSex;
brokeTaboo = witnessThoughtDef.hediff != null;
// Trigger extreme reactions
if (witnessThoughtDef?.hediff != null)
{ TriggerReactionInWitness(witness, pawn, witnessThoughtDef.hediff.defName); }
else if (pawnIsCheating)
{ TriggerReactionInWitness(witness, pawn, "Indignant"); }
if ((bool)methodInfo.Invoke(null, new object[] { jobDriver }))
{
DebugMode.Message(sexActReactionDef.defName);
reactionOfWitness = sexActReactionDef.DetermineReactionOfPawns(pawn, witness, applyThoughtDefs);
}
}
// Apply thoughts to pawn
if (pawnThoughtDef != null)
{
pawn.needs.mood.thoughts.memories.TryGainMemory(pawnThoughtDef, witness, null);
if (pawnThoughtDef.stages[0].baseMoodEffect < 0)
{ pawn?.TryGetComp<CompPawnThoughtData>()?.TryToExclaim(); }
}
return witnessJoiningSex;
return reactionOfWitness;
}
public static void TriggerReactionInWitness(Pawn witness, Pawn otherPawn, string reaction)
public static bool SexActIsNecrophilia(JobDriver_Sex jobDriver)
{
if (BasicSettings.majorTabooCanStartFights == false || reaction.NullOrEmpty())
{ return; }
return jobDriver.Partner != null && jobDriver.Partner.Dead;
}
if (witness.MentalState != null ||
witness.jobs.curDriver is JobDriver_Flee ||
witness.jobs.curDriver is JobDriver_AttackMelee ||
witness.jobs.curDriver is JobDriver_Vomit)
{ return; }
public static bool SexActIsBestiality(JobDriver_Sex jobDriver)
{
return jobDriver.Partner != null && jobDriver.Partner.RaceProps.Animal;
}
// Panicked
if (reaction == "Panicked" || (reaction == "Indignant" && Random.value <= 0.5f))
{
// Fight
if (otherPawn.RaceProps.Humanlike && witness.RaceProps.Humanlike && witness.DislikesViolence() == false && (Random.value <= 0.2f || witness.EnjoysViolence()) && witness.HostileTo(otherPawn) == false && InteractionUtility.TryGetRandomVerbForSocialFight(witness, out Verb verbToUse))
{ witness.interactions.StartSocialFight(otherPawn, "MessageSocialFight"); }
public static bool SexActIsRape(JobDriver_Sex jobDriver)
{
return jobDriver is JobDriver_Rape || jobDriver is JobDriver_RapeEnemy || jobDriver is JobDriver_SexBaseRecieverRaped;
}
// Flight
else
{
Job job = JobMaker.MakeJob(JobDefOf.FleeAndCower, CellFinderLoose.GetFleeDest(witness, new List<Thing>() { otherPawn }, 24f), otherPawn);
witness.jobs.EndCurrentJob(JobCondition.InterruptForced, false, false);
witness.jobs.StartJob(job);
}
}
public static bool SexActIsXenophilia(JobDriver_Sex jobDriver)
{
return jobDriver.Partner != null && jobDriver.Partner.def.defName != jobDriver.pawn.def.defName;
}
// Vomit
else if (reaction == "Nauseated")
{
Job jobVomit = JobMaker.MakeJob(JobDefOf.Vomit);
Job jobFlee = JobMaker.MakeJob(JobDefOf.FleeAndCower, CellFinderLoose.GetFleeDest(witness, new List<Thing>() { otherPawn }, 24f), otherPawn);
public static bool SexActIsMasturbation(JobDriver_Sex jobDriver)
{
return jobDriver.pawn.IsMasturbating();
}
witness.jobs.EndCurrentJob(JobCondition.InterruptForced, false, false);
public static bool SexActIsExhibitionism(JobDriver_Sex jobDriver)
{
return jobDriver.pawn.IsHavingSex();
}
if (Random.value <= 0.2f)
{
witness.jobs.StartJob(jobVomit);
witness.jobs.jobQueue.EnqueueFirst(jobFlee);
}
else
{ witness.jobs.StartJob(jobFlee); }
}
// Indignant
else if (reaction == "Indignant")
{
witness.mindState.mentalStateHandler.TryStartMentalState(DefDatabase<MentalStateDef>.GetNamedSilentFail("TargetedInsultingSpree"), null, true, false, null, true, false, false);
(witness.mindState.mentalStateHandler.CurState as MentalState_TargetedInsultingSpree).target = otherPawn;
}
public static bool SexActIsInfidelity(JobDriver_Sex jobDriver)
{
return jobDriver.pawn.IsHavingSex();
}
}
}