mirror of
https://gitgud.io/AbstractConcept/privacy-please.git
synced 2024-08-15 00:03:18 +00:00
Initial commit
This commit is contained in:
parent
fe7c28ad8e
commit
55402b9891
54 changed files with 2515 additions and 92 deletions
16
Source/Scripts/Utilities/DebugMode.cs
Normal file
16
Source/Scripts/Utilities/DebugMode.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Verse;
|
||||
using RimWorld;
|
||||
|
||||
namespace Privacy_Please
|
||||
{
|
||||
public static class DebugMode
|
||||
{
|
||||
public static void Message(string text)
|
||||
{
|
||||
if (BasicSettings.debugMode)
|
||||
{ Log.Message("[DEBUG] " + text); }
|
||||
}
|
||||
}
|
||||
}
|
41
Source/Scripts/Utilities/ModDefOf.cs
Normal file
41
Source/Scripts/Utilities/ModDefOf.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
using Verse;
|
||||
using RimWorld;
|
||||
using AlienRace;
|
||||
|
||||
namespace Privacy_Please
|
||||
{
|
||||
[DefOf]
|
||||
public static class ModBodyPartGroupDefOf
|
||||
{
|
||||
public static BodyPartGroupDef GenitalsBPG;
|
||||
public static BodyPartGroupDef AnusBPG;
|
||||
public static BodyPartGroupDef ChestBPG;
|
||||
}
|
||||
|
||||
[DefOf]
|
||||
public static class ModThoughtDefOf
|
||||
{
|
||||
public static ThoughtDef SeenHavingSex;
|
||||
public static ThoughtDef SeenHavingSexExhibitionist;
|
||||
public static ThoughtDef SeenMasturbating;
|
||||
public static ThoughtDef SeenMasturbatingExhibitionist;
|
||||
public static ThoughtDef SawSex;
|
||||
public static ThoughtDef SawSexVoyeur;
|
||||
public static ThoughtDef SawMasturbation;
|
||||
public static ThoughtDef SawMasturbationVoyeur;
|
||||
public static ThoughtDef CaughtCheating;
|
||||
}
|
||||
|
||||
[DefOf]
|
||||
public static class ModPreceptDefOf
|
||||
{
|
||||
public static PreceptDef Exhibitionism_Acceptable;
|
||||
public static PreceptDef Exhibitionism_Approved;
|
||||
}
|
||||
|
||||
[DefOf]
|
||||
public static class ModFleckDefOf
|
||||
{
|
||||
public static FleckDef Eye;
|
||||
}
|
||||
}
|
303
Source/Scripts/Utilities/SexInteractionUtility.cs
Normal file
303
Source/Scripts/Utilities/SexInteractionUtility.cs
Normal file
|
@ -0,0 +1,303 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Verse;
|
||||
using Verse.AI;
|
||||
using Verse.AI.Group;
|
||||
using RimWorld;
|
||||
using rjw;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Privacy_Please
|
||||
{
|
||||
public static class SexInteractionUtility
|
||||
{
|
||||
public static bool PawnCaughtLovinByWitness(Pawn pawn, Pawn witness)
|
||||
{
|
||||
if (witness == null ||
|
||||
pawn == witness ||
|
||||
(pawn.IsMasturbating() == false && pawn.IsHavingSex() == false) ||
|
||||
witness.UnworriedAboutHumanSex() == false ||
|
||||
witness.CanSee(pawn) == false)
|
||||
{ return false; }
|
||||
|
||||
List<Pawn> sexParticipants = pawn.GetAllSexParticipants();
|
||||
bool witnessIsApproachingSexParticipant = witness.jobs.curDriver is JobDriver_SexBaseInitiator && sexParticipants.Contains((witness.jobs.curDriver as JobDriver_SexBaseInitiator).Partner);
|
||||
|
||||
if (sexParticipants.Contains(witness) || witnessIsApproachingSexParticipant)
|
||||
{ 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 CouldInvitePasserbyForSex(Pawn passerby, List<Pawn> participants)
|
||||
{
|
||||
if (passerby == null ||
|
||||
participants.Contains(passerby) ||
|
||||
passerby.UnworriedAboutHumanSex() == false ||
|
||||
participants.All(x => x.CanSee(passerby) == false))
|
||||
{ return false; }
|
||||
|
||||
if (participants.Count > 2 ||
|
||||
participants.Any(x => x.IsForbidden(passerby) || x.HostileTo(passerby) || PawnIsCheatingOnPartner(x, passerby)) ||
|
||||
CasualSex_Helper.CanHaveSex(passerby) == false ||
|
||||
xxx.IsTargetPawnOkay(passerby) == false)
|
||||
{ return false; }
|
||||
|
||||
if (passerby.MentalState != null ||
|
||||
passerby.jobs.curDriver is JobDriver_Flee ||
|
||||
passerby.jobs.curDriver is JobDriver_AttackMelee ||
|
||||
passerby.jobs.curDriver is JobDriver_Vomit)
|
||||
{ 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 ThoughtDef GetThoughtsAboutSexAct(Pawn pawn, JobDriver_Sex jobDriver, out Precept precept)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
witness.needs.mood.thoughts.memories.TryGainMemory(witnessThoughtDef, pawn, precept);
|
||||
|
||||
if (witnessThoughtDef.stages[0].baseMoodEffect < 0)
|
||||
{ witness?.TryGetComp<CompPawnThoughtData>()?.TryToExclaim(); }
|
||||
|
||||
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"); }
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
public static void TriggerReactionInWitness(Pawn witness, Pawn otherPawn, string reaction)
|
||||
{
|
||||
if (BasicSettings.majorTabooCanStartFights == false || reaction.NullOrEmpty())
|
||||
{ return; }
|
||||
|
||||
if (witness.MentalState != null ||
|
||||
witness.jobs.curDriver is JobDriver_Flee ||
|
||||
witness.jobs.curDriver is JobDriver_AttackMelee ||
|
||||
witness.jobs.curDriver is JobDriver_Vomit)
|
||||
{ return; }
|
||||
|
||||
// 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"); }
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
witness.jobs.EndCurrentJob(JobCondition.InterruptForced, false, false);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue