mirror of
https://gitgud.io/amevarashi/rjw-sexperience-ideology.git
synced 2024-08-15 00:43:19 +00:00
Moved precepts romanceChanceFactor to DefExtention
This commit is contained in:
parent
be1e5c5d5d
commit
f7206347da
5 changed files with 159 additions and 83 deletions
|
@ -1,4 +1,5 @@
|
|||
using RimWorld;
|
||||
using RJWSexperience.Ideology.Precepts;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Verse;
|
||||
|
@ -17,12 +18,11 @@ namespace RJWSexperience.Ideology
|
|||
/// </summary>
|
||||
public static float GetRomanceChanceFactor(Pawn pawn, Pawn partner)
|
||||
{
|
||||
PreceptDef incestuousPrecept = pawn.Ideo?.PreceptsListForReading.Select(precept => precept.def).FirstOrFallback(def => def.issue == VariousDefOf.Incestuos);
|
||||
float romanceChanceFactor = 1f;
|
||||
|
||||
if (!pawn.relations.FamilyByBlood.Contains(partner))
|
||||
{
|
||||
if (incestuousPrecept == RsiPreceptDefOf.Incestuos_IncestOnly)
|
||||
if (pawn.Ideo?.HasPrecept(RsiPreceptDefOf.Incestuos_IncestOnly) == true)
|
||||
{
|
||||
return parentRomanceChanceFactor;
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ namespace RJWSexperience.Ideology
|
|||
}
|
||||
}
|
||||
|
||||
PreceptDef incestuousPrecept = pawn.Ideo?.PreceptsListForReading.Select(precept => precept.def).FirstOrFallback(def => def.issue == VariousDefOf.Incestuos);
|
||||
IEnumerable<PawnRelationDef> relations = pawn.GetRelations(partner).Where(def => def.familyByBloodRelation);
|
||||
foreach (PawnRelationDef relationDef in relations)
|
||||
{
|
||||
|
@ -46,43 +47,23 @@ namespace RJWSexperience.Ideology
|
|||
/// </summary>
|
||||
public static float GetRomanceChanceFactor(PawnRelationDef relationDef, PreceptDef incestuousPrecept)
|
||||
{
|
||||
if (incestuousPrecept == null || incestuousPrecept == RsiPreceptDefOf.Incestuos_Disapproved) // Default game setup
|
||||
if (incestuousPrecept == null)
|
||||
{
|
||||
return relationDef.romanceChanceFactor;
|
||||
}
|
||||
|
||||
if (incestuousPrecept == RsiPreceptDefOf.Incestuos_Free)
|
||||
var incestDefExt = incestuousPrecept.GetModExtension<DefExtension_Incest>();
|
||||
|
||||
if (incestDefExt == null)
|
||||
{
|
||||
return 1f;
|
||||
return relationDef.romanceChanceFactor;
|
||||
}
|
||||
else if (incestuousPrecept == RsiPreceptDefOf.Incestuos_Disapproved_CloseOnly)
|
||||
|
||||
BloodRelationDegree relationDegree = RelationHelpers.GetBloodRelationDegree(relationDef);
|
||||
|
||||
if (incestDefExt.TryGetRomanceChanceFactor(relationDegree, out var romanceChanceOverride))
|
||||
{
|
||||
if (relationDef.familyByBloodRelation && relationDef.importance > PawnRelationDefOf.Cousin.importance)
|
||||
{
|
||||
return relationDef.romanceChanceFactor;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1f;
|
||||
}
|
||||
}
|
||||
else if (incestuousPrecept == RsiPreceptDefOf.Incestuos_Forbidden)
|
||||
{
|
||||
if (relationDef.familyByBloodRelation)
|
||||
{
|
||||
return parentRomanceChanceFactor;
|
||||
}
|
||||
}
|
||||
else if (incestuousPrecept == RsiPreceptDefOf.Incestuos_IncestOnly)
|
||||
{
|
||||
if (!relationDef.familyByBloodRelation)
|
||||
{
|
||||
return parentRomanceChanceFactor;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1f;
|
||||
}
|
||||
return romanceChanceOverride;
|
||||
}
|
||||
|
||||
return relationDef.romanceChanceFactor;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue