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
|
@ -9,4 +9,6 @@
|
||||||
<RSNotAnimal>not animal</RSNotAnimal>
|
<RSNotAnimal>not animal</RSNotAnimal>
|
||||||
<RSShouldCanFuck>capable of sex is required</RSShouldCanFuck>
|
<RSShouldCanFuck>capable of sex is required</RSShouldCanFuck>
|
||||||
|
|
||||||
|
<!-- Rewrite vanilla key -->
|
||||||
|
<CantRomanceTargetIncest>forbidden by ideology</CantRomanceTargetIncest>
|
||||||
</LanguageData>
|
</LanguageData>
|
9
Source/IdeologyAddon/BloodRelationDegree.cs
Normal file
9
Source/IdeologyAddon/BloodRelationDegree.cs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
namespace RJWSexperience.Ideology
|
||||||
|
{
|
||||||
|
public enum BloodRelationDegree
|
||||||
|
{
|
||||||
|
CloseRelative,
|
||||||
|
FarRelative,
|
||||||
|
NotRelated
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
using rjw;
|
using rjw;
|
||||||
using RJWSexperience.Ideology.HistoryEvents;
|
using RJWSexperience.Ideology.HistoryEvents;
|
||||||
|
using RJWSexperience.Ideology.Patches;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Verse;
|
using Verse;
|
||||||
|
|
||||||
|
@ -16,5 +18,20 @@ namespace RJWSexperience.Ideology
|
||||||
RsiHistoryEventDefOf.RSI_NonIncestuosMarriage.RecordEventWithPartner(hero, p);
|
RsiHistoryEventDefOf.RSI_NonIncestuosMarriage.RecordEventWithPartner(hero, p);
|
||||||
RsiHistoryEventDefOf.RSI_NonIncestuosMarriage.RecordEventWithPartner(p, hero);
|
RsiHistoryEventDefOf.RSI_NonIncestuosMarriage.RecordEventWithPartner(p, hero);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[DebugAction("RJW Sexperience Ideology", "Manual romance check", false, true, actionType = DebugActionType.Action, allowedGameStates = AllowedGameStates.PlayingOnMap)]
|
||||||
|
public static void DisplayDebugTable()
|
||||||
|
{
|
||||||
|
IEnumerable<Pawn> pawns = Find.CurrentMap.mapPawns.AllPawnsSpawned.Where(pawn => pawn.IsColonist);
|
||||||
|
|
||||||
|
IEnumerable<TableDataGetter<Pawn>> columns = pawns
|
||||||
|
.Select(pawn => new TableDataGetter<Pawn>(pawn.Name.ToStringShort, (Pawn p) => Rimworld_Patch_IncestuousManualRomance.RsiIncestuous(p, pawn)));
|
||||||
|
|
||||||
|
var name = new TableDataGetter<Pawn>("Name", (Pawn pawn) => pawn.Name.ToStringShort);
|
||||||
|
|
||||||
|
TableDataGetter<Pawn>[] getters = (new List<TableDataGetter<Pawn>>() { name }).Concat(columns).ToArray();
|
||||||
|
|
||||||
|
DebugTables.MakeTablesDialog(pawns, getters);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
<Reference Include="System.Net.Http" />
|
<Reference Include="System.Net.Http" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="BloodRelationDegree.cs" />
|
||||||
<Compile Include="DebugAction.cs" />
|
<Compile Include="DebugAction.cs" />
|
||||||
<Compile Include="GlobalSuppressions.cs" />
|
<Compile Include="GlobalSuppressions.cs" />
|
||||||
<Compile Include="HistoryEvents\DefExtension_SecondaryEvents.cs" />
|
<Compile Include="HistoryEvents\DefExtension_SecondaryEvents.cs" />
|
||||||
|
@ -59,6 +60,8 @@
|
||||||
<Compile Include="PreceptWorkers\ThoughtWorker_Precept_Pregnant.cs" />
|
<Compile Include="PreceptWorkers\ThoughtWorker_Precept_Pregnant.cs" />
|
||||||
<Compile Include="PreceptWorkers\ThoughtWorker_Precept_Pregnant_Social.cs" />
|
<Compile Include="PreceptWorkers\ThoughtWorker_Precept_Pregnant_Social.cs" />
|
||||||
<Compile Include="RelationFilter.cs" />
|
<Compile Include="RelationFilter.cs" />
|
||||||
|
<Compile Include="RelationHelpers.cs" />
|
||||||
|
<Compile Include="RomanceChanceFactorHelpers.cs" />
|
||||||
<Compile Include="RsiHistoryEventDefOf.cs" />
|
<Compile Include="RsiHistoryEventDefOf.cs" />
|
||||||
<Compile Include="TwoPawnFilter.cs" />
|
<Compile Include="TwoPawnFilter.cs" />
|
||||||
<Compile Include="SinglePawnFilter.cs" />
|
<Compile Include="SinglePawnFilter.cs" />
|
||||||
|
@ -94,7 +97,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Krafs.Rimworld.Ref">
|
<PackageReference Include="Krafs.Rimworld.Ref">
|
||||||
<Version>1.4.3537</Version>
|
<Version>1.4.3542</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Lib.Harmony">
|
<PackageReference Include="Lib.Harmony">
|
||||||
<Version>2.2.2</Version>
|
<Version>2.2.2</Version>
|
||||||
|
|
|
@ -4,6 +4,7 @@ using rjw;
|
||||||
using RJWSexperience.Ideology.HistoryEvents;
|
using RJWSexperience.Ideology.HistoryEvents;
|
||||||
using RJWSexperience.Ideology.Precepts;
|
using RJWSexperience.Ideology.Precepts;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using Verse;
|
using Verse;
|
||||||
|
|
||||||
namespace RJWSexperience.Ideology.Patches
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
47
Source/IdeologyAddon/RelationHelpers.cs
Normal file
47
Source/IdeologyAddon/RelationHelpers.cs
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
using RimWorld;
|
||||||
|
using System.Linq;
|
||||||
|
using Verse;
|
||||||
|
|
||||||
|
namespace RJWSexperience.Ideology
|
||||||
|
{
|
||||||
|
public static class RelationHelpers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Get degree of blood relation between two pawns
|
||||||
|
/// </summary>
|
||||||
|
public static BloodRelationDegree GetBloodRelationDegree(Pawn pawn, Pawn partner)
|
||||||
|
{
|
||||||
|
PawnRelationDef closestBloodRelation = pawn
|
||||||
|
.GetRelations(partner)
|
||||||
|
?.Where(def => def.familyByBloodRelation)
|
||||||
|
?.OrderByDescending(def => def.importance)
|
||||||
|
?.FirstOrFallback();
|
||||||
|
|
||||||
|
if (closestBloodRelation == null)
|
||||||
|
{
|
||||||
|
return BloodRelationDegree.NotRelated;
|
||||||
|
}
|
||||||
|
|
||||||
|
return GetBloodRelationDegree(closestBloodRelation);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get degree of blood relation for a relationDef
|
||||||
|
/// </summary>
|
||||||
|
public static BloodRelationDegree GetBloodRelationDegree(PawnRelationDef relationDef)
|
||||||
|
{
|
||||||
|
if (!relationDef.familyByBloodRelation)
|
||||||
|
{
|
||||||
|
return BloodRelationDegree.NotRelated;
|
||||||
|
}
|
||||||
|
else if (relationDef.importance <= PawnRelationDefOf.Cousin.importance)
|
||||||
|
{
|
||||||
|
return BloodRelationDegree.FarRelative;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return BloodRelationDegree.CloseRelative;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,15 +13,21 @@ namespace RJWSexperience.Ideology
|
||||||
public static readonly JobDef GettinDrugSex;
|
public static readonly JobDef GettinDrugSex;
|
||||||
public static readonly JobDef DrugMasturbate;
|
public static readonly JobDef DrugMasturbate;
|
||||||
|
|
||||||
[MayRequireIdeology] public static readonly MemeDef Zoophile;
|
public static readonly MemeDef Zoophile;
|
||||||
[MayRequireIdeology] public static readonly MemeDef Rapist;
|
public static readonly MemeDef Rapist;
|
||||||
[MayRequireIdeology] public static readonly MemeDef Necrophile;
|
public static readonly MemeDef Necrophile;
|
||||||
[MayRequireIdeology] public static readonly PreceptDef Bestiality_OnlyVenerated;
|
public static readonly IssueDef Incestuos;
|
||||||
[MayRequireIdeology] public static readonly PreceptDef BabyFaction_AlwaysFather;
|
public static readonly PreceptDef Incestuos_Free;
|
||||||
[MayRequireIdeology] public static readonly PreceptDef BabyFaction_AlwaysColony;
|
public static readonly PreceptDef Incestuos_Disapproved_CloseOnly;
|
||||||
[MayRequireIdeology] public static readonly PreceptDef Submissive_Male;
|
public static readonly PreceptDef Incestuos_Disapproved;
|
||||||
[MayRequireIdeology] public static readonly PreceptDef Submissive_Female;
|
public static readonly PreceptDef Incestuos_Forbidden;
|
||||||
[MayRequireIdeology] public static readonly PreceptDef ProselyzingByOrgasm;
|
public static readonly PreceptDef Incestuos_IncestOnly;
|
||||||
|
public static readonly PreceptDef Bestiality_OnlyVenerated;
|
||||||
|
public static readonly PreceptDef BabyFaction_AlwaysFather;
|
||||||
|
public static readonly PreceptDef BabyFaction_AlwaysColony;
|
||||||
|
public static readonly PreceptDef Submissive_Male;
|
||||||
|
public static readonly PreceptDef Submissive_Female;
|
||||||
|
public static readonly PreceptDef ProselyzingByOrgasm;
|
||||||
[MayRequireBiotech] public static readonly HediffDef PregnantHuman;
|
[MayRequireBiotech] public static readonly HediffDef PregnantHuman;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue