Stop redefining incest with precepts

This commit is contained in:
amevarashi 2022-07-02 23:05:19 +05:00
parent a5d2c4fbd8
commit 226c09eca5
7 changed files with 29 additions and 22 deletions

View file

@ -15,10 +15,6 @@ namespace RJWSexperience.Ideology
if (ModLister.HasActiveModWithName("RJW Sexperience")) if (ModLister.HasActiveModWithName("RJW Sexperience"))
{ {
harmony.Patch(AccessTools.Method("RJWSexperience.PawnExtensions:IsIncest"),
prefix: new HarmonyMethod(typeof(Sexperience_Patch_IsIncest), nameof(Sexperience_Patch_IsIncest.Prefix)),
postfix: null
);
harmony.Patch(AccessTools.Method("RJWSexperience.RJWUtility:ThrowVirginHIstoryEvent"), harmony.Patch(AccessTools.Method("RJWSexperience.RJWUtility:ThrowVirginHIstoryEvent"),
prefix: null, prefix: null,
postfix: new HarmonyMethod(typeof(Sexperience_Patch_ThrowVirginHIstoryEvent), nameof(Sexperience_Patch_ThrowVirginHIstoryEvent.Postfix)) postfix: new HarmonyMethod(typeof(Sexperience_Patch_ThrowVirginHIstoryEvent), nameof(Sexperience_Patch_ThrowVirginHIstoryEvent.Postfix))

View file

@ -37,16 +37,15 @@ namespace RJWSexperience.Ideology
return true; return true;
} }
public static bool IsIncest(Pawn pawn, Pawn partner) public static bool IsIncest(Pawn pawn, Pawn partner, bool close)
{ {
IEnumerable<PawnRelationDef> relations = pawn.GetRelations(partner); IEnumerable<PawnRelationDef> relations = pawn.GetRelations(partner);
if (relations.EnumerableNullOrEmpty()) if (relations.EnumerableNullOrEmpty())
return false; return false;
bool wide = pawn.Ideo?.HasPrecept(VariousDefOf.Incestuos_Disapproved_CloseOnly) == true;
foreach (PawnRelationDef relation in relations) foreach (PawnRelationDef relation in relations)
{ {
if (wide) if (close)
{ {
if (relation.incestOpinionOffset < 0) if (relation.incestOpinionOffset < 0)
return true; return true;

View file

@ -114,8 +114,13 @@ namespace RJWSexperience.Ideology.Patches
public static void AfterSexHuman(Pawn human, Pawn partner, bool rape, bool isHumanReceiving = false) public static void AfterSexHuman(Pawn human, Pawn partner, bool rape, bool isHumanReceiving = false)
{ {
if (IdeoUtility.IsIncest(human, partner)) if (IdeoUtility.IsIncest(human, partner, false))
{ {
if (IdeoUtility.IsIncest(human, partner, true))
{
Find.HistoryEventsManager.RecordEvent(VariousDefOf.RJWSI_CloseRelativeSex.CreateEvent(human));
Find.HistoryEventsManager.RecordEvent(VariousDefOf.RJWSI_CloseRelativeSex.CreateEvent(partner));
}
Find.HistoryEventsManager.RecordEvent(VariousDefOf.RJWSI_IncestuosSex.CreateEvent(human)); Find.HistoryEventsManager.RecordEvent(VariousDefOf.RJWSI_IncestuosSex.CreateEvent(human));
Find.HistoryEventsManager.RecordEvent(VariousDefOf.RJWSI_IncestuosSex.CreateEvent(partner)); Find.HistoryEventsManager.RecordEvent(VariousDefOf.RJWSI_IncestuosSex.CreateEvent(partner));
} }

View file

@ -12,8 +12,13 @@ namespace RJWSexperience.Ideology.Patches
{ {
public static void Postfix(Pawn firstPawn, Pawn secondPawn) public static void Postfix(Pawn firstPawn, Pawn secondPawn)
{ {
if (IdeoUtility.IsIncest(firstPawn, secondPawn)) if (IdeoUtility.IsIncest(firstPawn, secondPawn, false))
{ {
if (IdeoUtility.IsIncest(firstPawn, secondPawn, true))
{
Find.HistoryEventsManager.RecordEvent(VariousDefOf.RJWSI_CloseRelativeMarriage.CreateEvent(firstPawn));
Find.HistoryEventsManager.RecordEvent(VariousDefOf.RJWSI_CloseRelativeMarriage.CreateEvent(secondPawn));
}
Find.HistoryEventsManager.RecordEvent(VariousDefOf.Incestuos_Marriage.CreateEvent(firstPawn)); Find.HistoryEventsManager.RecordEvent(VariousDefOf.Incestuos_Marriage.CreateEvent(firstPawn));
Find.HistoryEventsManager.RecordEvent(VariousDefOf.Incestuos_Marriage.CreateEvent(secondPawn)); Find.HistoryEventsManager.RecordEvent(VariousDefOf.Incestuos_Marriage.CreateEvent(secondPawn));
} }
@ -31,7 +36,7 @@ namespace RJWSexperience.Ideology.Patches
public static void Postfix(Pawn otherPawn, Pawn ___pawn, ref float __result) public static void Postfix(Pawn otherPawn, Pawn ___pawn, ref float __result)
{ {
Ideo ideo = ___pawn.Ideo; Ideo ideo = ___pawn.Ideo;
if (ideo?.HasPrecept(VariousDefOf.Incestuos_IncestOnly) == true && IdeoUtility.IsIncest(___pawn, otherPawn)) if (ideo?.HasPrecept(VariousDefOf.Incestuos_IncestOnly) == true && IdeoUtility.IsIncest(___pawn, otherPawn, false))
{ {
__result *= 8f; __result *= 8f;
} }

View file

@ -31,14 +31,4 @@ namespace RJWSexperience.Ideology.Patches
} }
} }
} }
public static class Sexperience_Patch_IsIncest
{
public static bool Prefix(Pawn pawn, Pawn otherpawn, ref bool __result)
{
__result = IdeoUtility.IsIncest(pawn, otherpawn);
return false;
}
}
} }

View file

@ -31,8 +31,10 @@ namespace RJWSexperience.Ideology
[MayRequireIdeology] public static readonly HistoryEventDef OralSex = DefDatabase<HistoryEventDef>.GetNamed("OralSex"); [MayRequireIdeology] public static readonly HistoryEventDef OralSex = DefDatabase<HistoryEventDef>.GetNamed("OralSex");
[MayRequireIdeology] public static readonly HistoryEventDef MiscSex = DefDatabase<HistoryEventDef>.GetNamed("MiscSex"); [MayRequireIdeology] public static readonly HistoryEventDef MiscSex = DefDatabase<HistoryEventDef>.GetNamed("MiscSex");
[MayRequireIdeology] public static readonly HistoryEventDef PromiscuousSex = DefDatabase<HistoryEventDef>.GetNamed("PromiscuousSex"); [MayRequireIdeology] public static readonly HistoryEventDef PromiscuousSex = DefDatabase<HistoryEventDef>.GetNamed("PromiscuousSex");
[MayRequireIdeology] public static readonly HistoryEventDef RJWSI_CloseRelativeMarriage = DefDatabase<HistoryEventDef>.GetNamed("RJWSI_CloseRelativeMarriage");
[MayRequireIdeology] public static readonly HistoryEventDef Incestuos_Marriage = DefDatabase<HistoryEventDef>.GetNamed("Incestuos_Marriage"); [MayRequireIdeology] public static readonly HistoryEventDef Incestuos_Marriage = DefDatabase<HistoryEventDef>.GetNamed("Incestuos_Marriage");
[MayRequireIdeology] public static readonly HistoryEventDef RJWSI_NonIncestuosMarriage = DefDatabase<HistoryEventDef>.GetNamed("RJWSI_NonIncestuosMarriage"); [MayRequireIdeology] public static readonly HistoryEventDef RJWSI_NonIncestuosMarriage = DefDatabase<HistoryEventDef>.GetNamed("RJWSI_NonIncestuosMarriage");
[MayRequireIdeology] public static readonly HistoryEventDef RJWSI_CloseRelativeSex = DefDatabase<HistoryEventDef>.GetNamed("RJWSI_CloseRelativeSex");
[MayRequireIdeology] public static readonly HistoryEventDef RJWSI_IncestuosSex = DefDatabase<HistoryEventDef>.GetNamed("RJWSI_IncestuosSex"); [MayRequireIdeology] public static readonly HistoryEventDef RJWSI_IncestuosSex = DefDatabase<HistoryEventDef>.GetNamed("RJWSI_IncestuosSex");
[MayRequireIdeology] public static readonly HistoryEventDef RJWSI_NonIncestuosSex = DefDatabase<HistoryEventDef>.GetNamed("RJWSI_NonIncestuosSex"); [MayRequireIdeology] public static readonly HistoryEventDef RJWSI_NonIncestuosSex = DefDatabase<HistoryEventDef>.GetNamed("RJWSI_NonIncestuosSex");
[MayRequireIdeology] public static readonly HistoryEventDef SexWithCorpse = DefDatabase<HistoryEventDef>.GetNamed("SexWithCorpse"); [MayRequireIdeology] public static readonly HistoryEventDef SexWithCorpse = DefDatabase<HistoryEventDef>.GetNamed("SexWithCorpse");

View file

@ -8,6 +8,11 @@
<iconPath>UI/Issues/Incest</iconPath> <iconPath>UI/Issues/Incest</iconPath>
</IssueDef> </IssueDef>
<HistoryEventDef>
<defName>RJWSI_CloseRelativeMarriage</defName>
<label>Marriage between close relatives</label>
</HistoryEventDef>
<HistoryEventDef> <HistoryEventDef>
<defName>Incestuos_Marriage</defName> <defName>Incestuos_Marriage</defName>
<label>Incestuos marriage</label> <label>Incestuos marriage</label>
@ -18,6 +23,11 @@
<label>Non-incestuos marriage</label> <label>Non-incestuos marriage</label>
</HistoryEventDef> </HistoryEventDef>
<HistoryEventDef>
<defName>RJWSI_CloseRelativeSex</defName>
<label>Sex between close relatives</label>
</HistoryEventDef>
<HistoryEventDef> <HistoryEventDef>
<defName>RJWSI_IncestuosSex</defName> <defName>RJWSI_IncestuosSex</defName>
<label>Incestuos sex</label> <label>Incestuos sex</label>
@ -52,11 +62,11 @@
<defaultSelectionWeight>100</defaultSelectionWeight> <defaultSelectionWeight>100</defaultSelectionWeight>
<comps> <comps>
<li Class="PreceptComp_SelfTookMemoryThought"> <li Class="PreceptComp_SelfTookMemoryThought">
<eventDef>Incestuos_Marriage</eventDef> <eventDef>RJWSI_CloseRelativeMarriage</eventDef>
<thought>IncestuosMarriage_Disapproved</thought> <thought>IncestuosMarriage_Disapproved</thought>
</li> </li>
<li Class="PreceptComp_KnowsMemoryThought"> <li Class="PreceptComp_KnowsMemoryThought">
<eventDef>RJWSI_IncestuosSex</eventDef> <eventDef>RJWSI_CloseRelativeSex</eventDef>
<thought>Sex_Know_Incest_Disapproved</thought> <thought>Sex_Know_Incest_Disapproved</thought>
</li> </li>
</comps> </comps>