mirror of
https://gitgud.io/amevarashi/rjw-sexperience-ideology.git
synced 2024-08-15 00:43:19 +00:00
Patched manual romance to respect incestuous precepts
This commit is contained in:
parent
180404cee1
commit
3bedfec30e
8 changed files with 254 additions and 10 deletions
|
@ -4,6 +4,7 @@ using rjw;
|
|||
using RJWSexperience.Ideology.HistoryEvents;
|
||||
using RJWSexperience.Ideology.Precepts;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Verse;
|
||||
|
||||
namespace RJWSexperience.Ideology.Patches
|
||||
|
@ -53,4 +54,55 @@ namespace RJWSexperience.Ideology.Patches
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Rimworld_Patch_IncestuousManualRomance
|
||||
{
|
||||
/// <summary>
|
||||
/// Override incestuous check in the manual romance
|
||||
/// </summary>
|
||||
/// <param name="one">Pawn to try do romance</param>
|
||||
/// <param name="two">Target for romance</param>
|
||||
/// <param name="__result">Result of the original method</param>
|
||||
/// <returns>Run original method implementation</returns>
|
||||
[HarmonyPatch(typeof(RelationsUtility), "Incestuous")]
|
||||
public static bool Prefix(Pawn one, Pawn two, ref bool __result)
|
||||
{
|
||||
__result = RsiIncestuous(one, two);
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if Ideology allows romance attempt
|
||||
/// </summary>
|
||||
/// <param name="one">Pawn to try do romance</param>
|
||||
/// <param name="two">Target for romance</param>
|
||||
/// <returns>Forbid romance option</returns>
|
||||
public static bool RsiIncestuous(Pawn one, Pawn two)
|
||||
{
|
||||
PreceptDef incestuousPrecept = one.Ideo?.PreceptsListForReading.Select(precept => precept.def).FirstOrFallback(def => def.issue == VariousDefOf.Incestuos);
|
||||
BloodRelationDegree relationDegree = RelationHelpers.GetBloodRelationDegree(one, two);
|
||||
|
||||
if (incestuousPrecept == null ||
|
||||
incestuousPrecept == VariousDefOf.Incestuos_Disapproved ||
|
||||
incestuousPrecept == VariousDefOf.Incestuos_Forbidden)
|
||||
{
|
||||
return relationDegree < BloodRelationDegree.NotRelated;
|
||||
}
|
||||
else if (incestuousPrecept == VariousDefOf.Incestuos_Free)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (incestuousPrecept == VariousDefOf.Incestuos_Disapproved_CloseOnly)
|
||||
{
|
||||
return relationDegree == BloodRelationDegree.CloseRelative;
|
||||
}
|
||||
else if (incestuousPrecept == VariousDefOf.Incestuos_IncestOnly)
|
||||
{
|
||||
return relationDegree == BloodRelationDegree.NotRelated;
|
||||
}
|
||||
|
||||
// Modded incestuous precept?
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue