From 6941293212915eb6f51c7c505b9df4c5cc39558d Mon Sep 17 00:00:00 2001 From: amevarashi Date: Fri, 8 Jul 2022 19:35:05 +0500 Subject: [PATCH] Refactor Submissive precepts --- .../IdeologyAddon/Ideology/PartnerFilter.cs | 5 + .../Patches/RJW_Patch_ChancePerHour.cs | 23 ++++- .../Ideology/Patches/RJW_Patch_Ideo.cs | 34 +++---- .../Comp_KnowsMemoryThought_Gendered.cs | 19 ++++ .../Comp_SelfTookMemoryThought_Gendered.cs | 48 +++++++++ .../IdeologyAddon/IdeologyAddon.csproj | 2 + RJWSexperience/IdeologyAddon/VariousDefOf.cs | 5 +- .../Defs/PreceptDefs/Precepts_Necrophilia.xml | 8 +- .../Defs/PreceptDefs/Precepts_Rape.xml | 69 ++++++++----- .../Defs/PreceptDefs/Precepts_Submissive.xml | 99 ++++++++++--------- 10 files changed, 203 insertions(+), 109 deletions(-) create mode 100644 RJWSexperience/IdeologyAddon/Ideology/Precepts/Comp_KnowsMemoryThought_Gendered.cs create mode 100644 RJWSexperience/IdeologyAddon/Ideology/Precepts/Comp_SelfTookMemoryThought_Gendered.cs diff --git a/RJWSexperience/IdeologyAddon/Ideology/PartnerFilter.cs b/RJWSexperience/IdeologyAddon/Ideology/PartnerFilter.cs index c0f4439..00019a4 100644 --- a/RJWSexperience/IdeologyAddon/Ideology/PartnerFilter.cs +++ b/RJWSexperience/IdeologyAddon/Ideology/PartnerFilter.cs @@ -15,6 +15,8 @@ namespace RJWSexperience.Ideology [SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")] public bool? isSlave; [SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")] + public bool? isPrisoner; + [SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")] public bool? isAlien; [SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")] public List hasOneOfRelations; @@ -36,6 +38,9 @@ namespace RJWSexperience.Ideology if (isSlave != null && isSlave != partner.IsSlave) return false; + if (isPrisoner != null && isPrisoner != partner.IsPrisoner) + return false; + //if (isAlien != null && isAlien != partner) // return false; diff --git a/RJWSexperience/IdeologyAddon/Ideology/Patches/RJW_Patch_ChancePerHour.cs b/RJWSexperience/IdeologyAddon/Ideology/Patches/RJW_Patch_ChancePerHour.cs index 8904d26..1e88613 100644 --- a/RJWSexperience/IdeologyAddon/Ideology/Patches/RJW_Patch_ChancePerHour.cs +++ b/RJWSexperience/IdeologyAddon/Ideology/Patches/RJW_Patch_ChancePerHour.cs @@ -1,4 +1,5 @@ using HarmonyLib; +using RimWorld; using rjw; using RJWSexperience.Ideology.Precepts; using Verse; @@ -20,8 +21,15 @@ namespace RJWSexperience.Ideology.Patches { public static void Postfix(Pawn pawn, ref float __result) { - if (__result > 0f && pawn.Ideo != null) // ideo is null if don't have dlc - __result *= IdeoUtility.GetPreceptsMtbMultiplier(pawn.Ideo); + if (__result < 0f || pawn.Ideo == null) // ideo is null if don't have dlc + return; + + if (!VariousDefOf.RSI_Raped.CreateEvent(pawn).DoerWillingToDo()) + { + __result = -2f; + return; + } + __result *= IdeoUtility.GetPreceptsMtbMultiplier(pawn.Ideo); } } [HarmonyPatch(typeof(ThinkNode_ChancePerHour_Necro), "MtbHours")] @@ -29,8 +37,15 @@ namespace RJWSexperience.Ideology.Patches { public static void Postfix(Pawn pawn, ref float __result) { - if (__result > 0f && pawn.Ideo != null) // ideo is null if don't have dlc - __result *= IdeoUtility.GetPreceptsMtbMultiplier(pawn.Ideo); + if (__result < 0f || pawn.Ideo == null) // ideo is null if don't have dlc + return; + + if (!VariousDefOf.SexWithCorpse.CreateEvent(pawn).DoerWillingToDo()) + { + __result = -2f; + return; + } + __result *= IdeoUtility.GetPreceptsMtbMultiplier(pawn.Ideo); } } diff --git a/RJWSexperience/IdeologyAddon/Ideology/Patches/RJW_Patch_Ideo.cs b/RJWSexperience/IdeologyAddon/Ideology/Patches/RJW_Patch_Ideo.cs index c0e507c..e0140c2 100644 --- a/RJWSexperience/IdeologyAddon/Ideology/Patches/RJW_Patch_Ideo.cs +++ b/RJWSexperience/IdeologyAddon/Ideology/Patches/RJW_Patch_Ideo.cs @@ -3,7 +3,6 @@ using RimWorld; using rjw; using rjw.Modules.Interactions.Internals.Implementation; using rjw.Modules.Interactions.Objects; -using RJWSexperience.Ideology.HistoryEvents; using RJWSexperience.Ideology.Precepts; using System; using System.Collections.Generic; @@ -104,21 +103,14 @@ namespace RJWSexperience.Ideology.Patches { if (rape) { + VariousDefOf.RSI_Raped.RecordEventWithPartner(human, partner); + if (partner.IsSlave) - { - Find.HistoryEventsManager.RecordEvent(VariousDefOf.RapedSlave.CreateTaggedEvent(human, Tag.Gender(human), partner)); - Find.HistoryEventsManager.RecordEvent(VariousDefOf.WasRapedSlave.CreateTaggedEvent(partner, Tag.Gender(partner), human)); - } + VariousDefOf.WasRapedSlave.RecordEventWithPartner(partner, human); else if (partner.IsPrisoner) - { - Find.HistoryEventsManager.RecordEvent(VariousDefOf.RapedPrisoner.CreateTaggedEvent(human, Tag.Gender(human), partner)); - Find.HistoryEventsManager.RecordEvent(VariousDefOf.WasRapedPrisoner.CreateTaggedEvent(partner, Tag.Gender(partner), human)); - } + VariousDefOf.WasRapedPrisoner.RecordEventWithPartner(partner, human); else - { - Find.HistoryEventsManager.RecordEvent(VariousDefOf.Raped.CreateTaggedEvent(human, Tag.Gender(human), partner)); - Find.HistoryEventsManager.RecordEvent(VariousDefOf.WasRaped.CreateTaggedEvent(partner, Tag.Gender(partner), human)); - } + VariousDefOf.WasRaped.RecordEventWithPartner(partner, human); } } } @@ -147,22 +139,20 @@ namespace RJWSexperience.Ideology.Patches if (interactionEvents == null) return; - Ideo ideo = dominant.Pawn.Ideo; - if (ideo != null) - __result.Dominant = PreceptSextype(ideo, dominant.Pawn.GetStatValue(xxx.sex_drive_stat), __result.Dominant, interactionEvents.pawnEvents); + if (dominant.Pawn.Ideo != null) + __result.Dominant = PreceptSextype(dominant.Pawn, submissive.Pawn, __result.Dominant, interactionEvents.pawnEvents); - ideo = submissive.Pawn.Ideo; - if (ideo != null) - __result.Submissive = PreceptSextype(ideo, submissive.Pawn.GetStatValue(xxx.sex_drive_stat), __result.Submissive, interactionEvents.partnerEvents); + if (submissive.Pawn.Ideo != null) + __result.Submissive = PreceptSextype(submissive.Pawn, dominant.Pawn, __result.Submissive, interactionEvents.partnerEvents); } - public static float PreceptSextype(Ideo ideo, float sexdrive, float score, List historyEventDefs) + public static float PreceptSextype(Pawn pawn, Pawn partner, float score, List historyEventDefs) { foreach(HistoryEventDef eventDef in historyEventDefs) { - if (ideo.MemberWillingToDo(new HistoryEvent(eventDef))) + if (eventDef.CreateEventWithPartner(pawn, partner).DoerWillingToDo()) { - float mult = 8.0f * Math.Max(0.3f, 1 / Math.Max(0.01f, sexdrive)); + float mult = 8.0f * Math.Max(0.3f, 1 / Math.Max(0.01f, pawn.GetStatValue(xxx.sex_drive_stat))); return score * mult; } } diff --git a/RJWSexperience/IdeologyAddon/Ideology/Precepts/Comp_KnowsMemoryThought_Gendered.cs b/RJWSexperience/IdeologyAddon/Ideology/Precepts/Comp_KnowsMemoryThought_Gendered.cs new file mode 100644 index 0000000..648f196 --- /dev/null +++ b/RJWSexperience/IdeologyAddon/Ideology/Precepts/Comp_KnowsMemoryThought_Gendered.cs @@ -0,0 +1,19 @@ +using RimWorld; +using System.Diagnostics.CodeAnalysis; +using Verse; + +namespace RJWSexperience.Ideology.Precepts +{ + public class Comp_KnowsMemoryThought_Gendered : PreceptComp_KnowsMemoryThought + { + [SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")] + public Gender doersGender; + + public override void Notify_MemberWitnessedAction(HistoryEvent ev, Precept precept, Pawn member) + { + Pawn doer = ev.args.GetArg(HistoryEventArgsNames.Doer); + if (doer.gender == doersGender) + base.Notify_MemberWitnessedAction(ev, precept, member); + } + } +} diff --git a/RJWSexperience/IdeologyAddon/Ideology/Precepts/Comp_SelfTookMemoryThought_Gendered.cs b/RJWSexperience/IdeologyAddon/Ideology/Precepts/Comp_SelfTookMemoryThought_Gendered.cs new file mode 100644 index 0000000..66c651b --- /dev/null +++ b/RJWSexperience/IdeologyAddon/Ideology/Precepts/Comp_SelfTookMemoryThought_Gendered.cs @@ -0,0 +1,48 @@ +using RimWorld; +using System.Diagnostics.CodeAnalysis; +using Verse; + +namespace RJWSexperience.Ideology.Precepts +{ + public class Comp_SelfTookMemoryThought_Gendered : PreceptComp_SelfTookMemoryThought + { + [SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")] + public Gender gender; + + public override void Notify_MemberTookAction(HistoryEvent ev, Precept precept, bool canApplySelfTookThoughts) + { + Pawn doer = ev.args.GetArg(HistoryEventArgsNames.Doer); + if (doer.gender == gender) + TakeThought(ev, precept, canApplySelfTookThoughts, doer); + } + + /// + /// This is a copy of base.Notify_MemberTookAction, but with partner handling + /// + protected void TakeThought(HistoryEvent ev, Precept precept, bool canApplySelfTookThoughts, Pawn doer) + { + if (ev.def != eventDef || !canApplySelfTookThoughts) + { + return; + } + Pawn partner = ev.args.GetArg(HistoryEvents.ArgsNamesCustom.Partner); + if (doer.needs?.mood != null && (!onlyForNonSlaves || !doer.IsSlave)) + { + if (thought.minExpectationForNegativeThought != null && ExpectationsUtility.CurrentExpectationFor(doer).order < thought.minExpectationForNegativeThought.order) + { + return; + } + Thought_Memory thought_Memory = ThoughtMaker.MakeThought(thought, precept); + if (thought_Memory is Thought_KilledInnocentAnimal thought_KilledInnocentAnimal && ev.args.TryGetArg(HistoryEventArgsNames.Victim, out Pawn animal)) + { + thought_KilledInnocentAnimal.SetAnimal(animal); + } + if (thought_Memory is Thought_MemoryObservation thought_MemoryObservation && ev.args.TryGetArg(HistoryEventArgsNames.Subject, out Corpse target)) + { + thought_MemoryObservation.Target = target; + } + doer.needs.mood.thoughts.memories.TryGainMemory(thought_Memory, partner); + } + } + } +} diff --git a/RJWSexperience/IdeologyAddon/IdeologyAddon.csproj b/RJWSexperience/IdeologyAddon/IdeologyAddon.csproj index 9e1bd81..50114e7 100644 --- a/RJWSexperience/IdeologyAddon/IdeologyAddon.csproj +++ b/RJWSexperience/IdeologyAddon/IdeologyAddon.csproj @@ -53,6 +53,8 @@ + + diff --git a/RJWSexperience/IdeologyAddon/VariousDefOf.cs b/RJWSexperience/IdeologyAddon/VariousDefOf.cs index e94e176..9703bd3 100644 --- a/RJWSexperience/IdeologyAddon/VariousDefOf.cs +++ b/RJWSexperience/IdeologyAddon/VariousDefOf.cs @@ -17,14 +17,13 @@ namespace RJWSexperience.Ideology [MayRequireIdeology] public static readonly MemeDef Rapist; [MayRequireIdeology] public static readonly MemeDef Necrophile; [MayRequireIdeology] public static readonly HistoryEventDef RSI_SexWithAnimal; - [MayRequireIdeology] public static readonly HistoryEventDef Raped; - [MayRequireIdeology] public static readonly HistoryEventDef RapedSlave; - [MayRequireIdeology] public static readonly HistoryEventDef RapedPrisoner; + [MayRequireIdeology] public static readonly HistoryEventDef RSI_Raped; [MayRequireIdeology] public static readonly HistoryEventDef WasRaped; [MayRequireIdeology] public static readonly HistoryEventDef WasRapedSlave; [MayRequireIdeology] public static readonly HistoryEventDef WasRapedPrisoner; [MayRequireIdeology] public static readonly HistoryEventDef RSI_NonIncestuosMarriage; [MayRequireIdeology] public static readonly HistoryEventDef RSI_NonIncestuosSex; + [MayRequireIdeology] public static readonly HistoryEventDef SexWithCorpse; [MayRequireIdeology] public static readonly HistoryEventDef Virgin_TakenF; [MayRequireIdeology] public static readonly HistoryEventDef Virgin_TakenM; [MayRequireIdeology] public static readonly HistoryEventDef Virgin_TookF; diff --git a/RJWSexperience_Ideology/Defs/PreceptDefs/Precepts_Necrophilia.xml b/RJWSexperience_Ideology/Defs/PreceptDefs/Precepts_Necrophilia.xml index daadb5f..6daf99d 100644 --- a/RJWSexperience_Ideology/Defs/PreceptDefs/Precepts_Necrophilia.xml +++ b/RJWSexperience_Ideology/Defs/PreceptDefs/Precepts_Necrophilia.xml @@ -28,6 +28,9 @@
  • Necrophile
  • +
  • + SexWithCorpse +
  • SexWithCorpse Necrophilia_Abhorrent @@ -37,11 +40,6 @@ Necrophilia_Know_Abhorrent
  • - -
  • - true -
  • -
    diff --git a/RJWSexperience_Ideology/Defs/PreceptDefs/Precepts_Rape.xml b/RJWSexperience_Ideology/Defs/PreceptDefs/Precepts_Rape.xml index 32dd6af..3dfaa59 100644 --- a/RJWSexperience_Ideology/Defs/PreceptDefs/Precepts_Rape.xml +++ b/RJWSexperience_Ideology/Defs/PreceptDefs/Precepts_Rape.xml @@ -9,17 +9,35 @@ - Raped + RSI_Raped + +
  • + +
  • + + true + + RSI_RapedSlave +
  • +
  • + + true + + RSI_RapedPrisoner +
  • + + +
    - RapedSlave + RSI_RapedSlave - RapedPrisoner + RSI_RapedPrisoner @@ -37,6 +55,7 @@ WasRapedPrisoner
    + @@ -59,41 +78,39 @@
  • Collectivist
  • +
  • + RSI_Raped +
  • - Raped + RSI_Raped Rape_Abhorrent
  • - Raped + RSI_Raped Rape_Know_Abhorrent Someone raped other
  • - RapedPrisoner + RSI_RapedPrisoner Rape_Horrible Raped prisoner
  • - RapedPrisoner + RSI_RapedPrisoner Rape_Know_Horrible Someone raped prisoner
  • - RapedSlave + RSI_RapedSlave Rape_Disapproved Raped slave
  • - RapedSlave + RSI_RapedSlave Rape_Know_Disapproved Someone raped slave
  • - -
  • - true -
  • -
    @@ -116,21 +133,21 @@
  • - Raped + RSI_Raped Rape_Horrible
  • - Raped + RSI_Raped Rape_Know_Horrible Someone raped other
  • - RapedPrisoner + RSI_RapedPrisoner Rape_Disapproved Raped prisoner
  • - RapedPrisoner + RSI_RapedPrisoner Rape_Know_Disapproved Someone raped prisoner
  • @@ -162,11 +179,11 @@
  • - Raped + RSI_Raped Rape_Disapproved
  • - Raped + RSI_Raped Rape_Know_Disapproved Someone raped other
  • @@ -208,34 +225,34 @@
  • - Raped + RSI_Raped BloodlustStoleSomeLovin true
  • - Raped + RSI_Raped Rape_Know_Honorable Someone raped other true
  • - RapedPrisoner + RSI_RapedPrisoner BloodlustStoleSomeLovin true
  • - RapedPrisoner + RSI_RapedPrisoner Rape_Know_Honorable Someone raped other true
  • - RapedSlave + RSI_RapedSlave BloodlustStoleSomeLovin true
  • - RapedSlave + RSI_RapedSlave Rape_Know_Honorable Someone raped other true diff --git a/RJWSexperience_Ideology/Defs/PreceptDefs/Precepts_Submissive.xml b/RJWSexperience_Ideology/Defs/PreceptDefs/Precepts_Submissive.xml index 5a48715..62ebb21 100644 --- a/RJWSexperience_Ideology/Defs/PreceptDefs/Precepts_Submissive.xml +++ b/RJWSexperience_Ideology/Defs/PreceptDefs/Precepts_Submissive.xml @@ -32,53 +32,54 @@
  • FemaleSupremacy
  • -
  • +
  • + RSI_Raped + Male +
  • +
  • WasRaped BeenRaped_Submissive - Male + Male
  • -
  • +
  • WasRaped BeenRaped_NotSubmissive - Female + Female
  • -
  • - Raped +
  • + RSI_Raped Raped_Know_NotBeingSubmissive - not obedient - Female + Male
  • -
  • +
  • WasRapedPrisoner BeenRaped_Submissive - Male + Male
  • -
  • +
  • WasRapedPrisoner BeenRaped_NotSubmissive - Female + Female
  • -
  • - RapedPrisoner +
  • + RSI_RapedPrisoner Raped_Know_NotBeingSubmissive - not obedient - Female + Male
  • -
  • +
  • WasRapedSlave BeenRaped_Submissive - Male + Male
  • -
  • +
  • WasRapedSlave BeenRaped_NotSubmissive - Female + Female
  • -
  • - RapedSlave +
  • + RSI_RapedSlave Raped_Know_NotBeingSubmissive - not obedient - Female + Male
  • @@ -95,60 +96,60 @@
  • MaleSupremacy
  • -
  • +
  • + RSI_Raped + Female +
  • +
  • WasRaped BeenRaped_Submissive - Female + Female
  • -
  • +
  • WasRaped BeenRaped_NotSubmissive - Male + Male
  • -
  • - Raped +
  • + RSI_Raped Raped_Know_NotBeingSubmissive - not obedient - Male + Female
  • -
  • +
  • WasRapedPrisoner BeenRaped_Submissive - Female + Female
  • -
  • +
  • WasRapedPrisoner BeenRaped_NotSubmissive - Male + Male
  • -
  • - RapedPrisoner +
  • + RSI_RapedPrisoner Raped_Know_NotBeingSubmissive - not obedient - Male + Female
  • -
  • +
  • WasRapedSlave BeenRaped_Submissive - Female + Female
  • -
  • +
  • WasRapedSlave BeenRaped_NotSubmissive - Male + Male
  • -
  • - RapedSlave +
  • + RSI_RapedSlave Raped_Know_NotBeingSubmissive - not obedient - Male + Female
  • - BeenRaped_Submissive