2022-11-20 13:47:55 +00:00
|
|
|
|
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())
|
|
|
|
|
{
|
2022-11-20 13:55:13 +00:00
|
|
|
|
if (incestuousPrecept == RsiPreceptDefOf.Incestuos_IncestOnly)
|
2022-11-20 13:47:55 +00:00
|
|
|
|
{
|
|
|
|
|
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)
|
|
|
|
|
{
|
2022-11-20 13:55:13 +00:00
|
|
|
|
if (incestuousPrecept == null || incestuousPrecept == RsiPreceptDefOf.Incestuos_Disapproved) // Default game setup
|
2022-11-20 13:47:55 +00:00
|
|
|
|
{
|
|
|
|
|
return relationDef.romanceChanceFactor;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-20 13:55:13 +00:00
|
|
|
|
if (incestuousPrecept == RsiPreceptDefOf.Incestuos_Free)
|
2022-11-20 13:47:55 +00:00
|
|
|
|
{
|
|
|
|
|
return 1f;
|
|
|
|
|
}
|
2022-11-20 13:55:13 +00:00
|
|
|
|
else if (incestuousPrecept == RsiPreceptDefOf.Incestuos_Disapproved_CloseOnly)
|
2022-11-20 13:47:55 +00:00
|
|
|
|
{
|
|
|
|
|
if (relationDef.familyByBloodRelation && relationDef.importance > PawnRelationDefOf.Cousin.importance)
|
|
|
|
|
{
|
|
|
|
|
return relationDef.romanceChanceFactor;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return 1f;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-11-20 13:55:13 +00:00
|
|
|
|
else if (incestuousPrecept == RsiPreceptDefOf.Incestuos_Forbidden)
|
2022-11-20 13:47:55 +00:00
|
|
|
|
{
|
|
|
|
|
if (relationDef.familyByBloodRelation)
|
|
|
|
|
{
|
|
|
|
|
return parentRomanceChanceFactor;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-11-20 13:55:13 +00:00
|
|
|
|
else if (incestuousPrecept == RsiPreceptDefOf.Incestuos_IncestOnly)
|
2022-11-20 13:47:55 +00:00
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|