Revert "Revert "Bug fixes""

This reverts commit 127206926b.
This commit is contained in:
AbstractConcept 2022-11-05 23:14:02 -05:00
parent 127206926b
commit 599475390a
26 changed files with 519 additions and 469 deletions

Binary file not shown.

View file

@ -33,7 +33,7 @@ namespace Privacy_Please
public class SubSexActReactionDef
{
public SexActThoughtDef defaultThoughtDef;
public List<SexActThoughtDef> associatedThoughtDefs;
public List<SexActThoughtDef> preceptThoughtDefs;
public List<ReplacementThought> replacementThoughts;
}
@ -41,21 +41,20 @@ namespace Privacy_Please
{
public List<TraitRequirement> requiredTraits;
public string requiredQuirk;
public PreceptDef requiredPreceptDef;
public SexActThoughtDef replacementThoughtDef;
}
public ReactionToSexAct DetermineReactionOfPawns(Pawn pawn, Pawn witness, bool applyThoughtDefs)
public void DetermineReactionOfPawns(Pawn pawn, Pawn witness, out ReactionToSexDiscovery reactionOfPawn, out ReactionToSexDiscovery reactionOfWitness, bool applyThoughtDefs)
{
DetermineReactionOfPawn(pawn, witness, pawnReaction, applyThoughtDefs);
ReactionToSexAct reactionToSexAct = DetermineReactionOfPawn(witness, pawn, witnessReaction, applyThoughtDefs);
return reactionToSexAct;
reactionOfPawn = DetermineReaction(pawn, witness, pawnReaction, applyThoughtDefs);
reactionOfWitness = DetermineReaction(witness, pawn, witnessReaction, applyThoughtDefs);
}
public ReactionToSexAct DetermineReactionOfPawn(Pawn reactor, Pawn otherPawn, SubSexActReactionDef reaction, bool applyThoughtDef)
public ReactionToSexDiscovery DetermineReaction(Pawn reactor, Pawn otherPawn, SubSexActReactionDef reaction, bool applyThoughtDef)
{
SexActThoughtDef thoughtDef = GetThoughtDefForReactor(reactor, reaction, out Precept precept);
ReactionToSexAct reactionToSexAct = thoughtDef.reactionToSexAct;
ReactionToSexDiscovery reactionToSexAct = thoughtDef.reactionToSexDiscovery;
if (applyThoughtDef)
{ reactor.needs.mood.thoughts.memories.TryGainMemory(thoughtDef, otherPawn, precept); }
@ -83,16 +82,22 @@ namespace Privacy_Please
if (replacementThought.requiredQuirk != null && xxx.has_quirk(reactor, replacementThought.requiredQuirk))
{ return replacementThought.replacementThoughtDef; }
if (replacementThought.requiredPreceptDef != null && reactor.ideo.Ideo.HasPrecept(replacementThought.requiredPreceptDef))
{
precept = reactor.ideo.Ideo.GetPrecept(replacementThought.requiredPreceptDef);
return replacementThought.replacementThoughtDef;
}
}
}
precept = reactor.GetPreceptForIssue(issueDef);
if (precept != null && reaction.associatedThoughtDefs.NullOrEmpty() == false)
if (precept != null && reaction.preceptThoughtDefs.NullOrEmpty() == false)
{
string thoughtDefName = precept.def.defName;
foreach (SexActThoughtDef associatedThoughtDef in reaction.associatedThoughtDefs)
foreach (SexActThoughtDef associatedThoughtDef in reaction.preceptThoughtDefs)
{
if (associatedThoughtDef.defName.Contains(thoughtDefName))
{ return associatedThoughtDef; }

View file

@ -9,6 +9,6 @@ namespace Privacy_Please
{
public class SexActThoughtDef : ThoughtDef
{
public ReactionToSexAct reactionToSexAct = ReactionToSexAct.Acceptance;
public ReactionToSexDiscovery reactionToSexDiscovery = ReactionToSexDiscovery.Acceptance;
}
}

View file

@ -19,15 +19,9 @@ namespace Privacy_Please
return bed != null;
}
public static bool IsSeated(this Pawn pawn, out Building seat)
{
seat = pawn.Position.GetThingList(pawn.Map).FirstOrDefault(x => x is Building && x.def.building.isSittable) as Building;
return seat != null;
}
public static bool IsHavingSex(this Pawn pawn)
{
if (pawn?.jobs?.curDriver == null || pawn.Dead || pawn.jobs.curDriver is JobDriver_Sex == false)
if (pawn?.jobs?.curDriver == null || pawn.jobs.curDriver is JobDriver_Sex == false)
{ return false; }
JobDriver_Sex jobdriver = pawn.jobs.curDriver as JobDriver_Sex;
@ -37,7 +31,7 @@ namespace Privacy_Please
public static bool IsMasturbating(this Pawn pawn)
{
if (pawn?.jobs?.curDriver == null || pawn.Dead || pawn.jobs.curDriver is JobDriver_Sex == false)
if (pawn?.jobs?.curDriver == null || pawn.jobs.curDriver is JobDriver_Sex == false)
{ return false; }
JobDriver_Sex jobdriver = pawn.jobs.curDriver as JobDriver_Sex;
@ -47,12 +41,12 @@ namespace Privacy_Please
public static Pawn GetSexInitiator(this Pawn pawn)
{
if (pawn?.jobs?.curDriver != null && pawn.Dead == false && pawn.jobs.curDriver is JobDriver_SexBaseInitiator)
if (pawn?.jobs?.curDriver != null && pawn.jobs.curDriver is JobDriver_SexBaseInitiator)
{ return pawn; }
JobDriver_SexBaseReciever jobDriver = pawn.jobs.curDriver as JobDriver_SexBaseReciever;
if (jobDriver?.Partner?.jobs?.curDriver != null && jobDriver.Partner.Dead == false && jobDriver.Partner.jobs.curDriver is JobDriver_SexBaseInitiator)
if (jobDriver?.Partner?.jobs?.curDriver != null && jobDriver.Partner.jobs.curDriver is JobDriver_SexBaseInitiator)
{ return jobDriver.Partner; }
return null;
@ -65,7 +59,7 @@ namespace Privacy_Please
JobDriver_SexBaseInitiator jobDriver = pawn.jobs.curDriver as JobDriver_SexBaseInitiator;
if (jobDriver?.Partner?.jobs?.curDriver != null && jobDriver.Partner.Dead == false && jobDriver.Partner.jobs.curDriver is JobDriver_SexBaseReciever)
if (jobDriver?.Partner?.jobs?.curDriver != null && jobDriver.Partner.jobs.curDriver is JobDriver_SexBaseReciever)
{ return jobDriver.Partner; }
return null;
@ -119,11 +113,6 @@ namespace Privacy_Please
return lovers.Any(x => x.otherPawn == other);
}
//public static bool GetThoughtOnIssue(this Pawn pawn, string issueDefName, out Precept precept)
//{
//}
public static Precept GetPreceptForIssue(this Pawn pawn, IssueDef issueDef)
{
if (issueDef == null || pawn?.Ideo == null)
@ -164,16 +153,27 @@ namespace Privacy_Please
public static bool IsUnfazedBySex(this Pawn pawn)
{
if (pawn.Dead ||
pawn.AnimalOrWildMan() ||
pawn.RaceProps.IsMechanoid ||
pawn.Awake() == false ||
pawn.Suspended)
if (IsUnableToSenseSex(pawn))
{ return true; }
if (pawn.AnimalOrWildMan() || pawn.RaceProps.IsMechanoid)
{ return true; }
if (BasicSettings.slavesIgnoreSex && (pawn.IsPrisoner || pawn.IsSlave)) return true;
if (BasicSettings.otherFactionsIgnoreSex && pawn.Faction.IsPlayer == false) return true;
if (pawn.Faction.HostileTo(Faction.OfPlayer)) return true;
if (pawn.Drafted == false && pawn.mindState?.duty?.def?.alwaysShowWeapon == true) return true;
return false;
}
public static bool IsUnableToSenseSex(this Pawn pawn)
{
if (pawn.Dead ||
pawn.Awake() == false ||
pawn.Suspended ||
pawn.MentalState != null)
{ return true; }
return false;
}

View file

@ -34,7 +34,7 @@ namespace Privacy_Please
ThoughtDef thoughtDef = null; // SexInteractionUtility.GetThoughtsAboutSexAct(other, __instance, out Precept precept);
// Find candidates to invite
if (other != null && thoughtDef?.hediff == null && SexInteractionUtility.CouldInvitePasserbyForSex(other, pawn.GetAllSexParticipants()))
if (other != null && thoughtDef?.hediff == null && SexInteractionUtility.PasserbyCanBePropositionedForSex(other, pawn.GetAllSexParticipants()))
{
DebugMode.Message(other.NameShortColored + " is a potential candidate");
candidates.Add(other);
@ -64,29 +64,8 @@ namespace Privacy_Please
{
if (pawn.IsHashIntervalTick(90))
{
if (pawn.IsMasturbating() && PrivacyUtility.PawnHasPrivacy(pawn, 8f) == false)
{ pawn.jobs.EndCurrentJob(JobCondition.InterruptForced, false, false); }
else if (pawn.IsHavingSex())
{
bool havePrivacy = true;
List<Pawn> participants = pawn.GetAllSexParticipants();
foreach (Pawn participant in participants)
{
if (PrivacyUtility.PawnHasPrivacy(participant, 8f) == false)
{ havePrivacy = false; }
}
if (__instance.Sexprops != null && (__instance.Sexprops.isRape || __instance.Sexprops.isWhoring))
{ return; }
if (havePrivacy == false)
{
foreach (Pawn participant in participants)
{ participant.jobs.EndCurrentJob(JobCondition.InterruptForced, false, false); }
}
}
if (pawn.IsMasturbating() || pawn.IsHavingSex())
{ PrivacyUtility.PrivacyCheckForPawn(pawn, 8f); }
}
}
}

View file

@ -24,8 +24,8 @@ namespace Privacy_Please
public static bool majorTabooCanStartFights = false;
public static bool ignoreRitualAndPartySex = true;
public static bool slavesIgnoreSex = false;
public static bool ignoreSlaveRape = false;
public static bool otherFactionsIgnoreSex = false;
public static bool whoringIsUninteruptable = true;
public static bool underwearSufficentForIdeos = true;
public static bool exposedUnderwearMood = true;
@ -44,7 +44,6 @@ namespace Privacy_Please
Scribe_Values.Look(ref worryAboutXeno, "worryAboutXeno", true);
Scribe_Values.Look(ref worryAboutMasturbation, "worryAboutMasturbation", true);
Scribe_Values.Look(ref worryAboutIncest, "worryAboutIncest", true);
Scribe_Values.Look(ref ignoreSlaveRape, "ignoreSlaveRape", false);
Scribe_Values.Look(ref majorTabooCanStartFights, "majorTabooCanStartFights", false);
Scribe_Values.Look(ref ignoreRitualAndPartySex, "ignoreRitualAndPartySex", false);
Scribe_Values.Look(ref slavesIgnoreSex, "slavesIgnoreSex", false);
@ -99,10 +98,6 @@ namespace Privacy_Please
listingStandard.CheckboxLabeled("worry_about_infidelity".Translate(), ref BasicSettings.worryAboutInfidelity, "worry_about_infidelity_desc".Translate());
listingStandard.CheckboxLabeled("worry_about_beastiality".Translate(), ref BasicSettings.worryAboutBeastiality, "worry_about_beastiality_desc".Translate());
listingStandard.CheckboxLabeled("worry_about_rape".Translate(), ref BasicSettings.worryAboutRape, "worry_about_rape_desc".Translate());
if (BasicSettings.worryAboutRape)
{ listingStandard.CheckboxLabeled("ignore_slave_rape".Translate(), ref BasicSettings.ignoreSlaveRape); }
listingStandard.CheckboxLabeled("worry_about_necro".Translate(), ref BasicSettings.worryAboutNecro, "worry_about_necro_desc".Translate());
listingStandard.CheckboxLabeled("worry_about_xeno".Translate(), ref BasicSettings.worryAboutXeno, "worry_about_xeno_desc".Translate());

View file

@ -1,10 +1,13 @@
namespace Privacy_Please
{
public enum ReactionToSexAct
public enum ReactionToSexDiscovery
{
Approval = 1,
Acceptance = 0,
Discomfort = -1,
Outrage = -2,
Panick = -3,
Nauseated = -3,
Random = -99,
}
}

View file

@ -1,8 +1,8 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using RimWorld;
using Verse;
using Verse.AI;
@ -13,18 +13,16 @@ namespace Privacy_Please
{
public static class PrivacyUtility
{
public static bool PawnHasPrivacy(Pawn pawn, float radius)
public static void PrivacyCheckForPawn(Pawn pawn, float radius)
{
//if (pawn.IsUnfazedBySex())
//{ return true; }
if (pawn.IsHavingSex() == false && pawn.IsMasturbating() == false)
{ return true; }
{ return; }
//if (pawn.GetLord() != null && (pawn.GetLord().LordJob is LordJob_Ritual || pawn.GetLord().LordJob is LordJob_Joinable_Party) && BasicSettings.ignoreRitualAndPartySex)
//{ return true; }
if (BasicSettings.ignoreRitualAndPartySex && pawn.IsPartOfRitualOrGathering())
{ return; }
bool hasPrivacy = true;
// Local variables
JobDriver_Sex jobDriver = pawn.jobs.curDriver as JobDriver_Sex;
pawn.IsInBed(out Building bed);
foreach (Thing thing in GenRadial.RadialDistinctThingsAround(pawn.Position, pawn.Map, radius, true))
@ -35,18 +33,21 @@ namespace Privacy_Please
// 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
// Get the pawn's and witness' reaction to the discovery
SexInteractionUtility.GetReactionsToSexDiscovery(jobDriver, witness, out ReactionToSexDiscovery reactionOfPawn, out ReactionToSexDiscovery reactionOfWitness, true);
bool tryToPropositionTheWitness = Random.value < BasicSettings.chanceForOtherToJoinInSex && SexInteractionUtility.PasserbyCanBePropositionedForSex(witness, pawn.GetAllSexParticipants());
if (CasualSex_Helper.CanHaveSex(witness) && xxx.IsTargetPawnOkay(witness) &&
(xxx.has_quirk(witness, "Voyeur") || (xxx.has_quirk(witness, "Cuckold") && SexInteractionUtility.SexParticipantsIncludesACheatingPartner(witness, pawn.GetAllSexParticipants()))))
// Try to proposition the witness
if ((int)reactionOfPawn >= (int)ReactionToSexDiscovery.Acceptance && (int)reactionOfWitness >= (int)ReactionToSexDiscovery.Acceptance && tryToPropositionTheWitness)
{
// Voyeurism
if (pawn.IsVoyeur() || (pawn.IsCuckold() && SexInteractionUtility.SexParticipantsIncludesACheatingPartner(witness, pawn.GetAllSexParticipants())))
{
Job job = new Job(DefDatabase<JobDef>.GetNamed("WatchSex", false), pawn.GetSexReceiver(), bed);
witness.jobs.TryTakeOrderedJob(job);
}
// Consensual sex
else if (pawn.IsMasturbating())
{
if (bed == null)
@ -62,6 +63,7 @@ namespace Privacy_Please
}
}
// Threesome
else if (pawn.GetSexReceiver() != null)
{
Job job = new Job(DefDatabase<JobDef>.GetNamed("JoinInSex", false), pawn.GetSexReceiver(), bed);
@ -69,16 +71,18 @@ namespace Privacy_Please
}
}
else
{ hasPrivacy = false; }
// The proposition failed. Awwkkkwaaarrddd....
else if (pawn.IsUnfazedBySex() == false && (int)reactionOfPawn < (int)ReactionToSexDiscovery.Approval)
{
if (BasicSettings.whoringIsUninteruptable && jobDriver?.Sexprops.isWhoring == true)
{ return; }
// The pawn is uncomfortable and is stopping sex
foreach (Pawn participant in pawn.GetAllSexParticipants())
{ participant.jobs.EndCurrentJob(JobCondition.InterruptForced, false, 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

@ -14,19 +14,13 @@ 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.IsUnfazedBySex() == false ||
witness.CanSee(pawn) == false)
if (witness == null || pawn == witness || witness.IsUnableToSenseSex() || 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);
bool witnessIsJoiningSex = witness.jobs.curDriver is JobDriver_SexBaseInitiator && sexParticipants.Contains((witness.jobs.curDriver as JobDriver_SexBaseInitiator).Partner);
if (sexParticipants.Contains(witness) || witnessIsApproachingSexParticipant)
if (sexParticipants.Contains(witness) || witnessIsJoiningSex)
{ return false; }
return true;
@ -62,41 +56,34 @@ namespace Privacy_Please
return false;
}
public static bool CouldInvitePasserbyForSex(Pawn passerby, List<Pawn> participants)
public static bool PasserbyCanBePropositionedForSex(Pawn passerby, List<Pawn> participants)
{
if (passerby == null ||
participants.Contains(passerby) ||
passerby.IsUnfazedBySex() == false ||
participants.All(x => x.CanSee(passerby) == false))
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) || PawnIsCheatingOnPartner(x, passerby)) ||
participants.Any(x => x.IsForbidden(passerby) || x.HostileTo(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)
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 true; }
return false;
}
public static ReactionToSexAct GetReactionToSexAct(Pawn witness, JobDriver_Sex jobDriver, bool applyThoughtDefs = false)
public static void GetReactionsToSexDiscovery(JobDriver_Sex jobDriver, Pawn witness, out ReactionToSexDiscovery reactionOfPawn, out ReactionToSexDiscovery reactionOfWitness, bool applyThoughtDefs = false)
{
Pawn pawn = jobDriver.pawn;
ReactionToSexAct reactionOfWitness = ReactionToSexAct.Acceptance;
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)
@ -109,11 +96,9 @@ namespace Privacy_Please
if ((bool)methodInfo.Invoke(null, new object[] { jobDriver }))
{
DebugMode.Message(sexActReactionDef.defName);
reactionOfWitness = sexActReactionDef.DetermineReactionOfPawns(pawn, witness, applyThoughtDefs);
sexActReactionDef.DetermineReactionOfPawns(pawn, witness, out reactionOfPawn, out reactionOfWitness, applyThoughtDefs);
}
}
return reactionOfWitness;
}
public static bool SexActIsNecrophilia(JobDriver_Sex jobDriver)

Binary file not shown.

Binary file not shown.