diff --git a/RJWSexperience/IdeologyAddon/Ideology/HistoryEventDefExtension_AssociatedSextypes.cs b/RJWSexperience/IdeologyAddon/Ideology/HistoryEventDefExtension_AssociatedSextypes.cs deleted file mode 100644 index afdcae0..0000000 --- a/RJWSexperience/IdeologyAddon/Ideology/HistoryEventDefExtension_AssociatedSextypes.cs +++ /dev/null @@ -1,13 +0,0 @@ -using rjw; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using Verse; - -namespace RJWSexperience.Ideology -{ - public class HistoryEventDefExtension_AssociatedSextypes : DefModExtension - { - [SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")] - public List sextypes = new List(); - } -} diff --git a/RJWSexperience/IdeologyAddon/Ideology/IdeoUtility.cs b/RJWSexperience/IdeologyAddon/Ideology/IdeoUtility.cs index e67fa3d..72f93ec 100644 --- a/RJWSexperience/IdeologyAddon/Ideology/IdeoUtility.cs +++ b/RJWSexperience/IdeologyAddon/Ideology/IdeoUtility.cs @@ -76,38 +76,5 @@ namespace RJWSexperience.Ideology } return finalMultiplier; } - - public static HistoryEventDef GetSextypeEventDef(xxx.rjwSextype sextype) - { - if (historyEventBySextype.TryGetValue(sextype, out HistoryEventDef historyEventDef)) - return historyEventDef; - return null; - } - - public static HistoryEventDef GetSextypeEventDef(string sextype) - { - if (!Enum.TryParse(sextype, out xxx.rjwSextype rjwSextype)) - return null; - return GetSextypeEventDef(rjwSextype); - } - - private static readonly Dictionary historyEventBySextype = BuildHistoryEventBySextype(); - - private static Dictionary BuildHistoryEventBySextype() - { - Dictionary dictionary = new Dictionary(); - foreach (HistoryEventDef historyEventDef in DefDatabase.AllDefsListForReading) - { - HistoryEventDefExtension_AssociatedSextypes associatedSextypes = historyEventDef.GetModExtension(); - if (associatedSextypes == null) - continue; - foreach (xxx.rjwSextype sextype in associatedSextypes.sextypes) - { - if (!dictionary.TryAdd(sextype, historyEventDef)) - Log.Error($"[Sexperience.Ideology] Error in HistoryEventDef {historyEventDef.defName}: {sextype} sextype is already associated with {dictionary[sextype].defName} HistoryEventDef"); - } - } - return dictionary; - } } } diff --git a/RJWSexperience/IdeologyAddon/Ideology/InteractionDefExtension_HistoryEvents.cs b/RJWSexperience/IdeologyAddon/Ideology/InteractionDefExtension_HistoryEvents.cs new file mode 100644 index 0000000..b92e0fc --- /dev/null +++ b/RJWSexperience/IdeologyAddon/Ideology/InteractionDefExtension_HistoryEvents.cs @@ -0,0 +1,15 @@ +using RimWorld; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using Verse; + +namespace RJWSexperience.Ideology +{ + public class InteractionDefExtension_HistoryEvents : DefModExtension + { + [SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")] + public List pawnEvents = new List(); + [SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")] + public List partnerEvents = new List(); + } +} diff --git a/RJWSexperience/IdeologyAddon/Ideology/Patches/RJW_Patch_Ideo.cs b/RJWSexperience/IdeologyAddon/Ideology/Patches/RJW_Patch_Ideo.cs index b5af75f..8c143e7 100644 --- a/RJWSexperience/IdeologyAddon/Ideology/Patches/RJW_Patch_Ideo.cs +++ b/RJWSexperience/IdeologyAddon/Ideology/Patches/RJW_Patch_Ideo.cs @@ -5,6 +5,7 @@ using rjw.Modules.Interactions.Internals.Implementation; using rjw.Modules.Interactions.Objects; using RJWSexperience.Ideology.Precepts; using System; +using System.Collections.Generic; using Verse; namespace RJWSexperience.Ideology.Patches @@ -92,20 +93,27 @@ namespace RJWSexperience.Ideology.Patches Pawn pawn = props.pawn; Pawn partner = props.partner; - if (partner != null) + if (props.hasPartner()) { if (xxx.is_human(pawn)) - AfterSexHuman(pawn, partner, props.isRape, props.sexType); + AfterSexHuman(pawn, partner, props.isRape); else if (xxx.is_human(partner)) - AfterSexHuman(partner, pawn, false, props.sexType, true); + AfterSexHuman(partner, pawn, false, true); + } + + InteractionDefExtension_HistoryEvents interactionEvents = props.dictionaryKey.GetModExtension(); + if (interactionEvents != null) + { + foreach (HistoryEventDef eventDef in interactionEvents.pawnEvents) + Find.HistoryEventsManager.RecordEvent(eventDef.CreateEvent(pawn)); + + foreach (HistoryEventDef eventDef in interactionEvents.partnerEvents) + Find.HistoryEventsManager.RecordEvent(eventDef.CreateEvent(partner)); } } - public static void AfterSexHuman(Pawn human, Pawn partner, bool rape, xxx.rjwSextype sextype, bool isHumanReceiving = false) + public static void AfterSexHuman(Pawn human, Pawn partner, bool rape, bool isHumanReceiving = false) { - if (partner.Dead) - Find.HistoryEventsManager.RecordEvent(VariousDefOf.SexWithCorpse.CreateEvent(human)); - if (IdeoUtility.IsIncest(human, partner)) { Find.HistoryEventsManager.RecordEvent(VariousDefOf.RJWSI_IncestuosSex.CreateEvent(human)); @@ -162,15 +170,6 @@ namespace RJWSexperience.Ideology.Patches Find.HistoryEventsManager.RecordEvent(VariousDefOf.WasRaped.CreateTaggedEvent(partner, HETag.BeenRaped + HETag.Gender(partner), human)); } } - else - { - HistoryEventDef sexEventDef = IdeoUtility.GetSextypeEventDef(sextype); - if (sexEventDef != null) - { - Find.HistoryEventsManager.RecordEvent(sexEventDef.CreateEvent(human)); - Find.HistoryEventsManager.RecordEvent(sexEventDef.CreateEvent(partner)); - } - } } } @@ -194,22 +193,28 @@ namespace RJWSexperience.Ideology.Patches { public static void Postfix(InteractionWithExtension interaction, InteractionPawn dominant, InteractionPawn submissive, ref InteractionScore __result) { + InteractionDefExtension_HistoryEvents interactionEvents = interaction.Interaction.GetModExtension(); + 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, interaction); + __result.Dominant = PreceptSextype(ideo, dominant.Pawn.GetStatValue(xxx.sex_drive_stat), __result.Dominant, interactionEvents.pawnEvents); ideo = submissive.Pawn.Ideo; if (ideo != null) - __result.Submissive = PreceptSextype(ideo, submissive.Pawn.GetStatValue(xxx.sex_drive_stat), __result.Submissive, interaction); + __result.Submissive = PreceptSextype(ideo, submissive.Pawn.GetStatValue(xxx.sex_drive_stat), __result.Submissive, interactionEvents.partnerEvents); } - public static float PreceptSextype(Ideo ideo, float sexdrive, float score, InteractionWithExtension interaction) + public static float PreceptSextype(Ideo ideo, float sexdrive, float score, List historyEventDefs) { - HistoryEventDef sexEventDef = IdeoUtility.GetSextypeEventDef(interaction.Extension.rjwSextype); - if (sexEventDef != null && ideo.MemberWillingToDo(new HistoryEvent(sexEventDef))) + foreach(HistoryEventDef eventDef in historyEventDefs) { - float mult = 8.0f * Math.Max(0.3f, 1 / Math.Max(0.01f, sexdrive)); - return score * mult; + if (ideo.MemberWillingToDo(new HistoryEvent(eventDef))) + { + float mult = 8.0f * Math.Max(0.3f, 1 / Math.Max(0.01f, sexdrive)); + return score * mult; + } } return score; } diff --git a/RJWSexperience/IdeologyAddon/IdeologyAddon.csproj b/RJWSexperience/IdeologyAddon/IdeologyAddon.csproj index 5dca738..4e5b461 100644 --- a/RJWSexperience/IdeologyAddon/IdeologyAddon.csproj +++ b/RJWSexperience/IdeologyAddon/IdeologyAddon.csproj @@ -43,7 +43,7 @@ - + diff --git a/RJWSexperience_Ideology/Defs/PreceptDefs/Precepts_Sex.xml b/RJWSexperience_Ideology/Defs/PreceptDefs/Precepts_Sex.xml index 521972c..19c8a52 100644 --- a/RJWSexperience_Ideology/Defs/PreceptDefs/Precepts_Sex.xml +++ b/RJWSexperience_Ideology/Defs/PreceptDefs/Precepts_Sex.xml @@ -11,71 +11,26 @@ VaginalSex - -
  • - -
  • Vaginal
  • - - -
    AnalSex - -
  • - -
  • Anal
  • -
  • Rimming
  • - - -
    OralSex - -
  • - -
  • Cunnilingus
  • -
  • Fellatio
  • - - -
    PromiscuousSex - -
  • - -
  • DoublePenetration
  • -
  • Scissoring
  • -
  • Sixtynine
  • -
  • Fisting
  • - - -
    MiscSex - -
  • - -
  • Masturbation
  • -
  • Boobjob
  • -
  • Handjob
  • -
  • Footjob
  • -
  • Fingering
  • -
  • MutualMasturbation
  • - - -
    diff --git a/RJWSexperience_Ideology/Patches/InteractionDef/Necro.xml b/RJWSexperience_Ideology/Patches/InteractionDef/Necro.xml new file mode 100644 index 0000000..dfb6347 --- /dev/null +++ b/RJWSexperience_Ideology/Patches/InteractionDef/Necro.xml @@ -0,0 +1,25 @@ + + + + + /Defs/InteractionDef[defName="Necro_Anal" or defName="Necro_DoublePenetration" or defName="Necro_DoublePenetrationM" or defName="Necro_Vaginal"] + +
  • + +
  • SexWithCorpse
  • + + +
    +
    + + + /Defs/InteractionDef[defName="Necro_Reverse_Anal" or defName="Necro_Reverse_DoublePenetration" or defName="Necro_Reverse_DoublePenetrationM" or defName="Necro_Reverse_Vaginal"] + +
  • + +
  • SexWithCorpse
  • + + +
    +
    +
    \ No newline at end of file diff --git a/RJWSexperience_Ideology/Patches/InteractionDef/Sex.xml b/RJWSexperience_Ideology/Patches/InteractionDef/Sex.xml new file mode 100644 index 0000000..bdc0b1b --- /dev/null +++ b/RJWSexperience_Ideology/Patches/InteractionDef/Sex.xml @@ -0,0 +1,73 @@ + + + + + /Defs/InteractionDef[defName="Sex_Vaginal"] + +
  • + +
  • VaginalSex
  • + + +
  • VaginalSex
  • +
    + +
    +
    + + + /Defs/InteractionDef[defName="Sex_Anal" or defName="Sex_Rimming"] + +
  • + +
  • AnalSex
  • + + +
  • AnalSex
  • +
    + +
    +
    + + + /Defs/InteractionDef[defName="Sex_Beakjob" or defName="Sex_Cunnilingus" or defName="Sex_Fellatio" or defName="Sex_Makeout" or defName="Sex_Sixtynine"] + +
  • + +
  • OralSex
  • + + +
  • OralSex
  • +
    + +
    +
    + + + /Defs/InteractionDef[defName="Sex_Breastjob" or defName="Sex_Fingering" or defName="Sex_Footjob" or defName="Sex_Handjob" or defName="Sex_MutualHandholding" or defName="Sex_MutualMasturbation" or defName="Sex_MutualTailholding"] + +
  • + +
  • MiscSex
  • + + +
  • MiscSex
  • +
    + +
    +
    + + + /Defs/InteractionDef[defName="Sex_DoublePenetration" or defName="Sex_DoublePenetrationM" or defName="Sex_Fisting" or defName="Sex_Scissoring"] + +
  • + +
  • PromiscuousSex
  • + + +
  • PromiscuousSex
  • +
    + +
    +
    +
    \ No newline at end of file diff --git a/RJWSexperience_Ideology/Patches/InteractionDef/Sex_Reverse.xml b/RJWSexperience_Ideology/Patches/InteractionDef/Sex_Reverse.xml new file mode 100644 index 0000000..2275830 --- /dev/null +++ b/RJWSexperience_Ideology/Patches/InteractionDef/Sex_Reverse.xml @@ -0,0 +1,73 @@ + + + + + /Defs/InteractionDef[defName="Sex_Reverse_Vaginal"] + +
  • + +
  • VaginalSex
  • + + +
  • VaginalSex
  • +
    + +
    +
    + + + /Defs/InteractionDef[defName="Sex_Reverse_Anal" or defName="Sex_Reverse_Rimming"] + +
  • + +
  • AnalSex
  • + + +
  • AnalSex
  • +
    + +
    +
    + + + /Defs/InteractionDef[defName="Sex_Reverse_Beakjob" or defName="Sex_Reverse_Cunnilingus" or defName="Sex_Reverse_Fellatio"] + +
  • + +
  • OralSex
  • + + +
  • OralSex
  • +
    + +
    +
    + + + /Defs/InteractionDef[defName="Sex_Reverse_Breastjob" or defName="Sex_Reverse_Fingering" or defName="Sex_Reverse_Footjob" or defName="Sex_Reverse_Handjob"] + +
  • + +
  • MiscSex
  • + + +
  • MiscSex
  • +
    + +
    +
    + + + /Defs/InteractionDef[defName="Sex_Reverse_DoublePenetration" or defName="Sex_Reverse_DoublePenetrationM" or defName="Sex_Reverse_Fisting"] + +
  • + +
  • PromiscuousSex
  • + + +
  • PromiscuousSex
  • +
    + +
    +
    +
    \ No newline at end of file