Moved manual romance rules into XML

This commit is contained in:
amevarashi 2022-11-23 19:42:47 +05:00
parent bcc9feb61a
commit d33fa5e3ea
4 changed files with 42 additions and 18 deletions

View File

@ -111,6 +111,15 @@
<displayOrderInIssue>60</displayOrderInIssue>
<displayOrderInImpact>1000</displayOrderInImpact>
<defaultSelectionWeight>100</defaultSelectionWeight>
<modExtensions>
<li Class="RJWSexperience.Ideology.Precepts.DefExtension_Incest">
<allowManualRomanceOnlyFor>
<li>CloseRelative</li>
<li>FarRelative</li>
<li>NotRelated</li>
</allowManualRomanceOnlyFor>
</li>
</modExtensions>
</PreceptDef>
<PreceptDef>
@ -157,6 +166,12 @@
</li>
</rules>
</li>
<li Class="RJWSexperience.Ideology.Precepts.DefExtension_Incest">
<allowManualRomanceOnlyFor>
<li>FarRelative</li>
<li>NotRelated</li>
</allowManualRomanceOnlyFor>
</li>
</modExtensions>
</PreceptDef>
@ -275,6 +290,12 @@
</li>
</rules>
</li>
<li Class="RJWSexperience.Ideology.Precepts.DefExtension_Incest">
<allowManualRomanceOnlyFor>
<li>CloseRelative</li>
<li>FarRelative</li>
</allowManualRomanceOnlyFor>
</li>
</modExtensions>
</PreceptDef>

View File

@ -53,6 +53,7 @@
<Compile Include="Harmony.cs" />
<Compile Include="HistoryEvents\ArgsNamesCustom.cs" />
<Compile Include="Keyed.cs" />
<Compile Include="Precepts\DefExtension_Incest.cs" />
<Compile Include="PreceptWorkers\ThoughtWorker_Precept_GenitalSize.cs" />
<Compile Include="PreceptWorkers\ThoughtWorker_Precept_GenitalSize_Social.cs" />
<Compile Include="PreceptWorkers\ThoughtWorker_Precept_NonPregnant.cs" />
@ -98,7 +99,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Krafs.Rimworld.Ref">
<Version>1.4.3542</Version>
<Version>1.4.3555</Version>
</PackageReference>
<PackageReference Include="Lib.Harmony">
<Version>2.2.2</Version>

View File

@ -80,29 +80,15 @@ namespace RJWSexperience.Ideology.Patches
public static bool RsiIncestuous(Pawn one, Pawn two)
{
PreceptDef incestuousPrecept = one.Ideo?.PreceptsListForReading.Select(precept => precept.def).FirstOrFallback(def => def.issue == VariousDefOf.Incestuos);
var allowManualRomanceOnlyFor = incestuousPrecept?.GetModExtension<DefExtension_Incest>()?.allowManualRomanceOnlyFor;
BloodRelationDegree relationDegree = RelationHelpers.GetBloodRelationDegree(one, two);
if (incestuousPrecept == null ||
incestuousPrecept == RsiPreceptDefOf.Incestuos_Disapproved ||
incestuousPrecept == RsiPreceptDefOf.Incestuos_Forbidden)
if (allowManualRomanceOnlyFor == null)
{
return relationDegree < BloodRelationDegree.NotRelated;
}
else if (incestuousPrecept == RsiPreceptDefOf.Incestuos_Free)
{
return false;
}
else if (incestuousPrecept == RsiPreceptDefOf.Incestuos_Disapproved_CloseOnly)
{
return relationDegree == BloodRelationDegree.CloseRelative;
}
else if (incestuousPrecept == RsiPreceptDefOf.Incestuos_IncestOnly)
{
return relationDegree == BloodRelationDegree.NotRelated;
}
// Modded incestuous precept?
return true;
return !allowManualRomanceOnlyFor.Contains(relationDegree);
}
}
}

View File

@ -0,0 +1,16 @@
using RJWSexperience.Ideology.Filters;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Verse;
namespace RJWSexperience.Ideology.Precepts
{
/// <summary>
/// Special Def extension for the Incestuous issue precepts
/// </summary>
[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Def loader")]
public class DefExtension_Incest : DefModExtension
{
public List<BloodRelationDegree> allowManualRomanceOnlyFor;
}
}