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
108
Source/IdeologyAddon/RomanceChanceFactorHelpers.cs
Normal file
108
Source/IdeologyAddon/RomanceChanceFactorHelpers.cs
Normal file
|
@ -0,0 +1,108 @@
|
|||
using RimWorld;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Verse;
|
||||
|
||||
namespace RJWSexperience.Ideology
|
||||
{
|
||||
public static class RomanceChanceFactorHelpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Default value for parent relation
|
||||
/// </summary>
|
||||
private const float parentRomanceChanceFactor = 0.03f;
|
||||
|
||||
/// <summary>
|
||||
/// Get ideology adjusted romanceChanceFactor
|
||||
/// </summary>
|
||||
public static float GetRomanceChanceFactor(Pawn pawn, Pawn partner)
|
||||
{
|
||||
IEnumerable<PawnRelationDef> relations = pawn.GetRelations(partner).Where(def => def.familyByBloodRelation);
|
||||
PreceptDef incestuousPrecept = pawn.Ideo?.PreceptsListForReading.Select(precept => precept.def).FirstOrFallback(def => def.issue == VariousDefOf.Incestuos);
|
||||
float romanceChanceFactor = 1f;
|
||||
|
||||
if (!relations.Any())
|
||||
{
|
||||
if (incestuousPrecept == VariousDefOf.Incestuos_IncestOnly)
|
||||
{
|
||||
return parentRomanceChanceFactor;
|
||||
}
|
||||
else
|
||||
{
|
||||
return romanceChanceFactor;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (PawnRelationDef relationDef in relations)
|
||||
{
|
||||
romanceChanceFactor *= GetRomanceChanceFactor(relationDef, incestuousPrecept);
|
||||
}
|
||||
|
||||
return romanceChanceFactor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get ideology adjusted romanceChanceFactor for the relation
|
||||
/// </summary>
|
||||
public static float GetRomanceChanceFactor(PawnRelationDef relationDef, PreceptDef incestuousPrecept)
|
||||
{
|
||||
if (incestuousPrecept == null || incestuousPrecept == VariousDefOf.Incestuos_Disapproved) // Default game setup
|
||||
{
|
||||
return relationDef.romanceChanceFactor;
|
||||
}
|
||||
|
||||
if (incestuousPrecept == VariousDefOf.Incestuos_Free)
|
||||
{
|
||||
return 1f;
|
||||
}
|
||||
else if (incestuousPrecept == VariousDefOf.Incestuos_Disapproved_CloseOnly)
|
||||
{
|
||||
if (relationDef.familyByBloodRelation && relationDef.importance > PawnRelationDefOf.Cousin.importance)
|
||||
{
|
||||
return relationDef.romanceChanceFactor;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1f;
|
||||
}
|
||||
}
|
||||
else if (incestuousPrecept == VariousDefOf.Incestuos_Forbidden)
|
||||
{
|
||||
if (relationDef.familyByBloodRelation)
|
||||
{
|
||||
return parentRomanceChanceFactor;
|
||||
}
|
||||
}
|
||||
else if (incestuousPrecept == VariousDefOf.Incestuos_IncestOnly)
|
||||
{
|
||||
if (!relationDef.familyByBloodRelation)
|
||||
{
|
||||
return parentRomanceChanceFactor;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1f;
|
||||
}
|
||||
}
|
||||
|
||||
return relationDef.romanceChanceFactor;
|
||||
}
|
||||
|
||||
[DebugAction("RJW Sexperience Ideology", "Show romanceChanceFactors", false, true, actionType = DebugActionType.Action, allowedGameStates = AllowedGameStates.Entry)]
|
||||
public static void DisplayDebugTable()
|
||||
{
|
||||
IEnumerable<PreceptDef> incestuousPrecepts = DefDatabase<PreceptDef>
|
||||
.AllDefsListForReading
|
||||
.Where(def => def.issue == VariousDefOf.Incestuos);
|
||||
|
||||
IEnumerable<TableDataGetter<PawnRelationDef>> preceptGetters = incestuousPrecepts
|
||||
.Select(precept => new TableDataGetter<PawnRelationDef>(precept.defName,(PawnRelationDef rel) => GetRomanceChanceFactor(rel, precept)));
|
||||
|
||||
var relName = new TableDataGetter<PawnRelationDef>("Relation Def", (PawnRelationDef rel) => rel.defName);
|
||||
|
||||
TableDataGetter<PawnRelationDef>[] getters = (new List<TableDataGetter<PawnRelationDef>>() { relName }).Concat(preceptGetters).ToArray();
|
||||
|
||||
DebugTables.MakeTablesDialog(DefDatabase<PawnRelationDef>.AllDefsListForReading, getters);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue