Updates and bug fixes

This commit is contained in:
AbstractConcept 2023-01-29 10:54:14 -06:00
parent 299934584e
commit 2256f28cf8
15 changed files with 74 additions and 64 deletions

Binary file not shown.

Binary file not shown.

View File

@ -31,7 +31,7 @@
<baseMoodEffect>0</baseMoodEffect>
</li>
</stages>
<reactionToSexDiscovery>Acceptance</reactionToSexDiscovery>
<reactionToSexDiscovery>Uncaring</reactionToSexDiscovery>
</Privacy_Please.SexActThoughtDef>
<Privacy_Please.SexActThoughtDef>
@ -80,7 +80,7 @@
<baseMoodEffect>0</baseMoodEffect>
</li>
</stages>
<reactionToSexDiscovery>Acceptance</reactionToSexDiscovery>
<reactionToSexDiscovery>Uncaring</reactionToSexDiscovery>
</Privacy_Please.SexActThoughtDef>
<Privacy_Please.SexActThoughtDef>

View File

@ -5,11 +5,11 @@
<li>UnderWhere</li>
</mods>
<match Class="PatchOperationSequence">
<success>Always</success>
<success>Normal</success>
<operations>
<li Class="PatchOperationReplace">
<xpath>Defs/ThingDef[defName="UnderWhere_Panties" or defName="UnderWhere_Boxers" or defName="UnderWhere_Loincloth"]/apparel/bodyPartGroups</xpath>
<xpath>Defs/ThingDef/apparel[layers/li="Underwear" and not(layers/li="UnderwearTop")]/bodyPartGroups</xpath>
<value>
<bodyPartGroups>
<li>GenitalsBPG</li>
@ -18,14 +18,14 @@
</li>
<li Class="PatchOperationReplace">
<xpath>Defs/ThingDef[defName="UnderWhere_Bra" or defName="UnderWhere_Chestwrap"]/apparel/bodyPartGroups</xpath>
<xpath>Defs/ThingDef/apparel[layers/li="UnderwearTop" and not(layers/li="Underwear")]/bodyPartGroups</xpath>
<value>
<bodyPartGroups>
<li>ChestBPG</li>
</bodyPartGroups>
</value>
</li>
</operations>
</match>
</Operation>

Binary file not shown.

View File

@ -45,7 +45,7 @@ namespace Privacy_Please
public SexActThoughtDef replacementThoughtDef;
}
public void DetermineReactionOfPawns(Pawn pawn, Pawn witness, out ReactionToSexDiscovery reactionOfPawn, out ReactionToSexDiscovery reactionOfWitness, bool applyThoughtDefs)
public void DetermineReactionOfPawns(Pawn pawn, Pawn witness, out ReactionToSexDiscovery reactionOfPawn, out ReactionToSexDiscovery reactionOfWitness, bool applyThoughtDefs = false)
{
reactionOfPawn = DetermineReaction(pawn, witness, pawnReaction, applyThoughtDefs);
reactionOfWitness = DetermineReaction(witness, pawn, witnessReaction, applyThoughtDefs);
@ -53,6 +53,17 @@ namespace Privacy_Please
public ReactionToSexDiscovery DetermineReaction(Pawn reactor, Pawn otherPawn, SubSexActReactionDef reaction, bool applyThoughtDef)
{
JobDriver_Sex jobDriver = reactor.jobs.curDriver as JobDriver_Sex;
// Reactors who do not have thoughts applied to them
if (reactor.IsUnableToSenseSex() || reactor.RaceProps.Animal || reactor.RaceProps.IsMechanoid) return ReactionToSexDiscovery.Ignored;
if (otherPawn.RaceProps.Animal || otherPawn.RaceProps.IsMechanoid) return ReactionToSexDiscovery.Uncaring;
if (BasicSettings.slavesIgnoreSex && (reactor.IsPrisoner || reactor.IsSlave)) return ReactionToSexDiscovery.Uncaring;
if (BasicSettings.otherFactionsIgnoreSex && reactor.Faction.IsPlayer == false) return ReactionToSexDiscovery.Uncaring;
if (BasicSettings.copulatorsIgnoreSlaves && (otherPawn.IsPrisoner || otherPawn.IsSlave)) return ReactionToSexDiscovery.Uncaring;
if (BasicSettings.copulatorsIgnoreOtherFactions && otherPawn.Faction.IsPlayer == false) return ReactionToSexDiscovery.Uncaring;
// Apply thoughtDef
SexActThoughtDef thoughtDef = GetThoughtDefForReactor(reactor, reaction, out Precept precept);
ReactionToSexDiscovery reactionToSexAct = thoughtDef.reactionToSexDiscovery;
@ -64,6 +75,11 @@ namespace Privacy_Please
if (thoughtDef.stages[0].baseMoodEffect < 0 && nullifyingTraits?.Any(x => x.HasTrait(reactor)) != true)
{ reactor.TryGetComp<CompPawnThoughtData>()?.TryToExclaim(); }
// Reactors who have their reactions changed after applying thoughtDefs
if (BasicSettings.whoringIsUninteruptable && jobDriver?.Sexprops.isWhoring == true) return ReactionToSexDiscovery.Uncaring;
if (BasicSettings.rapeIsUninteruptable && jobDriver?.Sexprops.isRape == true) return ReactionToSexDiscovery.Uncaring;
if (reactor.HostileTo(otherPawn)) return ReactionToSexDiscovery.StopSex;
return reactionToSexAct;
}
@ -77,13 +93,13 @@ namespace Privacy_Please
{
foreach (ReplacementThought replacementThought in reaction.replacementThoughts)
{
if (replacementThought?.requiredTraits.Any(x => x.HasTrait(reactor)) == true)
if (replacementThought?.requiredTraits?.Any(x => x.HasTrait(reactor)) == true)
{ return replacementThought.replacementThoughtDef; }
if (replacementThought.requiredQuirk != null && xxx.has_quirk(reactor, replacementThought.requiredQuirk))
{ return replacementThought.replacementThoughtDef; }
if (replacementThought.requiredPreceptDef != null && reactor.ideo.Ideo.HasPrecept(replacementThought.requiredPreceptDef))
if (replacementThought.requiredPreceptDef != null && reactor.ideo?.Ideo.HasPrecept(replacementThought.requiredPreceptDef) == true)
{
precept = reactor.ideo.Ideo.GetPrecept(replacementThought.requiredPreceptDef);
return replacementThought.replacementThoughtDef;

View File

@ -21,22 +21,12 @@ namespace Privacy_Please
public static bool IsHavingSex(this Pawn pawn)
{
if (pawn?.jobs?.curDriver == null || pawn.jobs.curDriver is JobDriver_Sex == false)
{ return false; }
JobDriver_Sex jobdriver = pawn.jobs.curDriver as JobDriver_Sex;
return jobdriver.Partner != null && jobdriver.Partner != pawn;
return GetAllSexParticipants(pawn).Count > 1;
}
public static bool IsMasturbating(this Pawn pawn)
{
if (pawn?.jobs?.curDriver == null || pawn.jobs.curDriver is JobDriver_Sex == false)
{ return false; }
JobDriver_Sex jobdriver = pawn.jobs.curDriver as JobDriver_Sex;
return jobdriver.Partner == null || jobdriver.Partner == pawn || (jobdriver.Partner is Pawn) == false;
return GetAllSexParticipants(pawn).Count == 1;
}
public static Pawn GetSexInitiator(this Pawn pawn)
@ -155,8 +145,7 @@ namespace Privacy_Please
{
if (pawn.Dead ||
pawn.Awake() == false ||
pawn.Suspended ||
pawn.MentalState != null)
pawn.Suspended)
{ return true; }
return false;

View File

@ -62,12 +62,20 @@ namespace Privacy_Please
public static class HarmonyPatch_JobDriver_Sex_SexTick
{
// When pawns are having sex, intermittently check their surrounds for privacy
public static void Postfix(ref JobDriver_Sex __instance, Pawn pawn)
public static void Postfix(ref JobDriver_Sex __instance)
{
Pawn pawn = __instance.pawn;
Pawn partner = pawn.GetSexPartner();
if (pawn.IsHashIntervalTick(90))
{
if (pawn.IsMasturbating() || pawn.IsHavingSex())
{ PrivacyUtility.PrivacyCheckForPawn(pawn, 8f); }
{
PrivacyUtility.PrivacyCheckForPawn(pawn, 8f);
if (partner != null)
{ PrivacyUtility.PrivacyCheckForPawn(partner, 8f); }
}
}
}
}

View File

@ -25,6 +25,9 @@ namespace Privacy_Please
public static bool ignoreRitualAndPartySex = true;
public static bool slavesIgnoreSex = false;
public static bool otherFactionsIgnoreSex = false;
public static bool copulatorsIgnoreSlaves = false;
public static bool copulatorsIgnoreOtherFactions = false;
public static bool rapeIsUninteruptable = true;
public static bool whoringIsUninteruptable = true;
@ -49,6 +52,8 @@ namespace Privacy_Please
Scribe_Values.Look(ref ignoreRitualAndPartySex, "ignoreRitualAndPartySex", false);
Scribe_Values.Look(ref slavesIgnoreSex, "slavesIgnoreSex", false);
Scribe_Values.Look(ref otherFactionsIgnoreSex, "otherFactionsIgnoreSex", false);
Scribe_Values.Look(ref copulatorsIgnoreSlaves, "copulatorsIgnoreSlaves", false);
Scribe_Values.Look(ref copulatorsIgnoreOtherFactions, "copulatorsIgnoreOtherFactions", false);
Scribe_Values.Look(ref rapeIsUninteruptable, "slavesIgnoreSex", true);
Scribe_Values.Look(ref whoringIsUninteruptable, "otherFactionsIgnoreSex", true);
Scribe_Values.Look(ref underwearSufficentForIdeos, "underwearSufficentForIdeos", true);
@ -109,6 +114,8 @@ namespace Privacy_Please
listingStandard.CheckboxLabeled("ignore_ritual_and_party_sex".Translate(), ref BasicSettings.ignoreRitualAndPartySex, "ignore_ritual_and_party_sex_desc".Translate());
listingStandard.CheckboxLabeled("slaves_ignore_sex".Translate(), ref BasicSettings.slavesIgnoreSex, "slaves_ignore_sex_desc".Translate());
listingStandard.CheckboxLabeled("other_factions_ignore_sex".Translate(), ref BasicSettings.otherFactionsIgnoreSex, "other_factions_ignore_sex_desc".Translate());
listingStandard.CheckboxLabeled("copulators_ignore_slaves".Translate(), ref BasicSettings.copulatorsIgnoreSlaves, "copulators_ignore_slaves_desc".Translate());
listingStandard.CheckboxLabeled("copulators_ignore_other_factions".Translate(), ref BasicSettings.copulatorsIgnoreOtherFactions, "copulators_ignore_other_factions_desc".Translate());
listingStandard.CheckboxLabeled("major_taboo_can_start_fights".Translate(), ref BasicSettings.majorTabooCanStartFights, "major_taboo_can_start_fights_desc".Translate());
listingStandard.CheckboxLabeled("rape_is_uninteruptable".Translate(), ref BasicSettings.rapeIsUninteruptable, "rape_is_uninteruptable_desc".Translate());
listingStandard.CheckboxLabeled("whoring_is_uninteruptable".Translate(), ref BasicSettings.whoringIsUninteruptable, "whoring_is_uninteruptable".Translate());

View File

@ -3,9 +3,12 @@
public enum ReactionToSexDiscovery
{
Approval = 1,
Acceptance = 0,
Discomfort = -1,
Panic = -2,
Nausea = -3,
Uncaring = 0,
Acceptance = -1,
Discomfort = -2,
Panic = -3,
Nausea = -4,
Ignored = -99,
StopSex = -100,
}
}

View File

@ -34,7 +34,7 @@ namespace Privacy_Please
{
// 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());
bool tryToPropositionTheWitness = Random.value < BasicSettings.chanceForOtherToJoinInSex && jobDriver?.Sexprops.isWhoring != true && SexInteractionUtility.PasserbyCanBePropositionedForSex(witness, pawn.GetAllSexParticipants());
// Try to proposition the witness
if ((int)reactionOfPawn >= (int)ReactionToSexDiscovery.Acceptance && (int)reactionOfWitness >= (int)ReactionToSexDiscovery.Acceptance && tryToPropositionTheWitness)
@ -71,11 +71,16 @@ namespace Privacy_Please
}
// The proposition failed. Is this awkward for those having sex?
else if (SexInteractionUtility.PawnWorriesAboutSexWitness(pawn, witness) && (int)reactionOfPawn < (int)ReactionToSexDiscovery.Approval)
else if ((int)reactionOfPawn < (int)ReactionToSexDiscovery.Uncaring)
{
// The pawn is uncomfortable and is stopping sex
foreach (Pawn participant in pawn.GetAllSexParticipants())
{ participant.jobs.EndCurrentJob(JobCondition.InterruptForced, false, false); }
{
JobDriver_Sex participantJobDriver = participant.jobs.curDriver as JobDriver_Sex;
if (participantJobDriver?.ticks_left > 60)
{ participantJobDriver.ticks_left = 60; }
}
}
}
}

View File

@ -17,32 +17,13 @@ namespace Privacy_Please
if (witness == null || pawn == witness || witness.IsUnableToSenseSex() || witness.CanSee(pawn) == false) return false;
List<Pawn> sexParticipants = pawn.GetAllSexParticipants();
bool witnessIsJoiningSex = 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).Target);
if (sexParticipants.Contains(witness) || witnessIsJoiningSex) return false;
return true;
}
public static bool PawnWorriesAboutSexWitness(Pawn pawn, Pawn witness)
{
JobDriver_Sex jobDriver = pawn.jobs.curDriver as JobDriver_Sex;
if (pawn.IsUnableToSenseSex() || pawn.AnimalOrWildMan() || pawn.RaceProps.IsMechanoid || pawn.Faction.HostileTo(Faction.OfPlayer)) return false;
if (BasicSettings.rapeIsUninteruptable && jobDriver?.Sexprops.isRape == true) return true;
if (witness.HostileTo(pawn)) return true;
if (witness.RaceProps.Animal || witness.RaceProps.IsMechanoid) return false;
if (pawn.Drafted == true || pawn.mindState?.duty?.def?.alwaysShowWeapon == true) return false;
if (BasicSettings.slavesIgnoreSex && (pawn.IsPrisoner || pawn.IsSlave || witness.IsPrisoner || witness.IsSlave)) return false;
if (BasicSettings.otherFactionsIgnoreSex && (pawn.Faction.IsPlayer == false || witness.Faction.IsPlayer == false)) return false;
if (BasicSettings.whoringIsUninteruptable && jobDriver?.Sexprops.isWhoring == true) return true;
return true;
}
public static bool PawnIsCheatingOnPartner(Pawn pawn, Pawn partner)
{
List<Pawn> spouses = pawn.GetSpouses(false);
@ -75,13 +56,14 @@ namespace Privacy_Please
public static bool PasserbyCanBePropositionedForSex(Pawn passerby, List<Pawn> participants)
{
if (passerby == null ||
if (passerby == null ||
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)) ||
participants.Any(x => x.IsForbidden(passerby) ||
x.HostileTo(passerby)) ||
CasualSex_Helper.CanHaveSex(passerby) == false ||
xxx.IsTargetPawnOkay(passerby) == false)
{ return false; }
@ -102,7 +84,7 @@ namespace Privacy_Please
reactionOfPawn = ReactionToSexDiscovery.Acceptance;
reactionOfWitness = ReactionToSexDiscovery.Acceptance;
// Determine if there are any issues with the sex event and the witness' morals
// Determine if there are any issues with the sex event and the witness' morals and apply thoughtDefs as required
foreach (SexActReactionDef sexActReactionDef in DefDatabase<SexActReactionDef>.AllDefs)
{
var methodInfo = AccessTools.Method(typeof(SexInteractionUtility), sexActReactionDef.sexActCheck, null, null);
@ -110,7 +92,7 @@ namespace Privacy_Please
if (methodInfo == null)
{ DebugMode.Message("Method '" + sexActReactionDef.sexActCheck + "' was not found"); continue; }
if ((bool)methodInfo.Invoke(null, new object[] { jobDriver }))
if ((bool)methodInfo.Invoke(null, new object[] { jobDriver, witness }))
{ sexActReactionDef.DetermineReactionOfPawns(pawn, witness, out reactionOfPawn, out reactionOfWitness, applyThoughtDefs); }
}
@ -144,39 +126,39 @@ namespace Privacy_Please
}
}
public static bool SexActIsNecrophilia(JobDriver_Sex jobDriver)
public static bool SexActIsNecrophilia(JobDriver_Sex jobDriver, Pawn witness = null)
{
return jobDriver.Partner != null && jobDriver.Partner.Dead;
}
public static bool SexActIsBestiality(JobDriver_Sex jobDriver)
public static bool SexActIsBestiality(JobDriver_Sex jobDriver, Pawn witness = null)
{
return jobDriver.Partner != null && jobDriver.Partner.RaceProps.Animal;
}
public static bool SexActIsRape(JobDriver_Sex jobDriver)
public static bool SexActIsRape(JobDriver_Sex jobDriver, Pawn witness = null)
{
return jobDriver is JobDriver_Rape || jobDriver is JobDriver_RapeEnemy || jobDriver is JobDriver_SexBaseRecieverRaped;
}
public static bool SexActIsXenophilia(JobDriver_Sex jobDriver)
public static bool SexActIsXenophilia(JobDriver_Sex jobDriver, Pawn witness = null)
{
return jobDriver.Partner != null && jobDriver.Partner.def.defName != jobDriver.pawn.def.defName;
}
public static bool SexActIsMasturbation(JobDriver_Sex jobDriver)
public static bool SexActIsMasturbation(JobDriver_Sex jobDriver, Pawn witness = null)
{
return jobDriver.pawn.IsMasturbating();
}
public static bool SexActIsExhibitionism(JobDriver_Sex jobDriver)
public static bool SexActIsExhibitionism(JobDriver_Sex jobDriver, Pawn witness = null)
{
return jobDriver.pawn.IsHavingSex();
}
public static bool SexActIsInfidelity(JobDriver_Sex jobDriver)
public static bool SexActIsInfidelity(JobDriver_Sex jobDriver, Pawn witness = null)
{
return jobDriver.pawn.IsHavingSex();
return PawnIsCheatingOnPartner(jobDriver.pawn, witness);
}
}
}

Binary file not shown.

Binary file not shown.