diff --git a/1.4/Defs/PreceptDefs/Precepts_Incest.xml b/1.4/Defs/PreceptDefs/Precepts_Incest.xml
index 54c079a..23f82de 100644
--- a/1.4/Defs/PreceptDefs/Precepts_Incest.xml
+++ b/1.4/Defs/PreceptDefs/Precepts_Incest.xml
@@ -27,9 +27,16 @@
-
- CloseRelative
-
+
+ Parent
+ Child
+ Sibling
+ HalfSibling
+ Grandparent
+ Grandchild
+ NephewOrNiece
+ UncleOrAunt
+
RSI_CloseRelativeMarriage
@@ -37,9 +44,7 @@
-
- FarRelative
-
+ true
RSI_IncestuosMarriage
@@ -68,9 +73,16 @@
-
- CloseRelative
-
+
+ Parent
+ Child
+ Sibling
+ HalfSibling
+ Grandparent
+ Grandchild
+ NephewOrNiece
+ UncleOrAunt
+
RSI_CloseRelativeSex
@@ -78,9 +90,7 @@
-
- FarRelative
-
+ true
RSI_IncestuosSex
@@ -108,20 +118,6 @@
FarRelative
NotRelated
-
-
- CloseRelative
- 1
-
-
- FarRelative
- 1
-
-
- NotRelated
- 1
-
-
@@ -151,9 +147,16 @@
-
- CloseRelative
-
+
+ Parent
+ Child
+ Sibling
+ HalfSibling
+ Grandparent
+ Grandchild
+ NephewOrNiece
+ UncleOrAunt
+
Spouse
@@ -168,16 +171,6 @@
FarRelative
NotRelated
-
-
- FarRelative
- 1
-
-
- NotRelated
- 1
-
-
@@ -211,10 +204,7 @@
-
- CloseRelative
- FarRelative
-
+ true
Spouse
@@ -256,10 +246,7 @@
-
- CloseRelative
- FarRelative
-
+ true
Spouse
@@ -269,18 +256,6 @@
-
-
-
- CloseRelative
- 0.03
-
-
- FarRelative
- 0.03
-
-
-
@@ -308,9 +283,7 @@
-
- NotRelated
-
+ false
0.1
@@ -322,20 +295,6 @@
CloseRelative
FarRelative
-
-
- CloseRelative
- 1
-
-
- FarRelative
- 1
-
-
- NotRelated
- 0.03
-
-
diff --git a/Source/IdeologyAddon/Filters/RelationFilter.cs b/Source/IdeologyAddon/Filters/RelationFilter.cs
index 732ed7e..32fa1ed 100644
--- a/Source/IdeologyAddon/Filters/RelationFilter.cs
+++ b/Source/IdeologyAddon/Filters/RelationFilter.cs
@@ -1,6 +1,7 @@
using RimWorld;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
+using System.Linq;
using Verse;
namespace RJWSexperience.Ideology.Filters
@@ -12,14 +13,14 @@ namespace RJWSexperience.Ideology.Filters
public class RelationFilter
{
public bool? isVeneratedAnimal;
+ public bool? isAlien;
+ public bool? isBloodRelated;
public List hasOneOfRelations;
public List hasNoneOfRelations;
- public List hasOneOfRelationDegrees;
private bool initialized = false;
private HashSet hasOneOfRelationsHashed;
private HashSet hasNoneOfRelationsHashed;
- private HashSet hasOneOfRelationDegreesHashed;
///
/// Check if the pair of pawns fits filter conditions
@@ -30,6 +31,9 @@ namespace RJWSexperience.Ideology.Filters
if (isVeneratedAnimal != null && isVeneratedAnimal != pawn.Ideo.IsVeneratedAnimal(partner))
return false;
+ //if (isAlien != null && isAlien != partner)
+ // return false;
+
if (!CheckRelations(pawn, partner))
return false;
@@ -41,16 +45,14 @@ namespace RJWSexperience.Ideology.Filters
if (!initialized)
Initialize();
- if (hasNoneOfRelationsHashed == null && hasOneOfRelationsHashed == null && hasOneOfRelationDegreesHashed == null)
+ if (hasNoneOfRelationsHashed == null && hasOneOfRelationsHashed == null && isBloodRelated == null)
return true;
- if (hasOneOfRelationDegreesHashed != null && !hasOneOfRelationDegreesHashed.Contains(RelationHelpers.GetBloodRelationDegree(pawn, partner)))
- {
- return false;
- }
-
IEnumerable relations = pawn.GetRelations(partner);
+ if (isBloodRelated != null && isBloodRelated != relations.Any(def => def.familyByBloodRelation))
+ return false;
+
if (hasOneOfRelationsHashed != null)
{
if (relations.EnumerableNullOrEmpty())
@@ -76,9 +78,6 @@ namespace RJWSexperience.Ideology.Filters
if (!hasOneOfRelations.NullOrEmpty())
hasOneOfRelationsHashed = new HashSet(hasOneOfRelations);
- if (!hasOneOfRelationDegrees.NullOrEmpty())
- hasOneOfRelationDegreesHashed = new HashSet(hasOneOfRelationDegrees);
-
initialized = true;
}
}
diff --git a/Source/IdeologyAddon/Harmony.cs b/Source/IdeologyAddon/Harmony.cs
index d756855..08a78d0 100644
--- a/Source/IdeologyAddon/Harmony.cs
+++ b/Source/IdeologyAddon/Harmony.cs
@@ -1,14 +1,25 @@
-using System.Reflection;
+using HarmonyLib;
+using RJWSexperience.Ideology.Patches;
+using System.Reflection;
using Verse;
namespace RJWSexperience.Ideology
{
[StaticConstructorOnStartup]
- internal static class Harmony
+ internal static class First
{
- static Harmony()
+ static First()
{
- new HarmonyLib.Harmony("RJW_Sexperience.Ideology").PatchAll(Assembly.GetExecutingAssembly());
+ var harmony = new Harmony("RJW_Sexperience.Ideology");
+ harmony.PatchAll(Assembly.GetExecutingAssembly());
+
+ if (ModLister.HasActiveModWithName("RJW Sexperience"))
+ {
+ harmony.Patch(AccessTools.Method("RJWSexperience.RJWUtility:ThrowVirginHistoryEvent"),
+ prefix: null,
+ postfix: new HarmonyMethod(typeof(Sexperience_Patch_ThrowVirginHistoryEvent), nameof(Sexperience_Patch_ThrowVirginHistoryEvent.Postfix))
+ );
+ }
}
}
}
diff --git a/Source/IdeologyAddon/Patches/Sexperience_Patch.cs b/Source/IdeologyAddon/Patches/Sexperience_Patch.cs
index 1be61cd..6951eea 100644
--- a/Source/IdeologyAddon/Patches/Sexperience_Patch.cs
+++ b/Source/IdeologyAddon/Patches/Sexperience_Patch.cs
@@ -1,15 +1,11 @@
-using HarmonyLib;
-using rjw;
+using rjw;
using RJWSexperience.Ideology.HistoryEvents;
using Verse;
namespace RJWSexperience.Ideology.Patches
{
- [HarmonyPatch("RJWSexperience.RJWUtility", "ThrowVirginHistoryEvent")]
public static class Sexperience_Patch_ThrowVirginHistoryEvent
{
- public static bool Prepare() => ModsConfig.IsActive("rjw.sexperience");
-
public static void Postfix(Pawn exVirgin, Pawn partner, SexProps props, int degree)
{
const int femaleAfterSurgery = 1;
diff --git a/Source/IdeologyAddon/Precepts/DefExtension_Incest.cs b/Source/IdeologyAddon/Precepts/DefExtension_Incest.cs
index caf0ed0..f4e474d 100644
--- a/Source/IdeologyAddon/Precepts/DefExtension_Incest.cs
+++ b/Source/IdeologyAddon/Precepts/DefExtension_Incest.cs
@@ -1,4 +1,5 @@
-using System.Collections.Generic;
+using RJWSexperience.Ideology.Filters;
+using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Verse;
@@ -11,63 +12,5 @@ namespace RJWSexperience.Ideology.Precepts
public class DefExtension_Incest : DefModExtension
{
public List allowManualRomanceOnlyFor;
- public List bloodRelationDegreeRomanceFactors;
-
- private Dictionary _relationDegreeFactorsDict;
-
- public bool TryGetRomanceChanceFactor(BloodRelationDegree relationDegree, out float romanceChanceFactor)
- {
- if (bloodRelationDegreeRomanceFactors.NullOrEmpty())
- {
- romanceChanceFactor = 1f;
- return false;
- }
-
- if (_relationDegreeFactorsDict == null)
- {
- _relationDegreeFactorsDict = new Dictionary();
- foreach (BloodRelationDegreeFactor relationDegreeFactor in bloodRelationDegreeRomanceFactors)
- {
- _relationDegreeFactorsDict.Add((BloodRelationDegree)relationDegreeFactor.bloodRelationDegree, relationDegreeFactor.romanceChanceFactor);
- }
- }
-
- return _relationDegreeFactorsDict.TryGetValue(relationDegree, out romanceChanceFactor);
- }
-
- public override IEnumerable ConfigErrors()
- {
- foreach (string error in base.ConfigErrors())
- {
- yield return error;
- }
-
- foreach (BloodRelationDegreeFactor factor in bloodRelationDegreeRomanceFactors)
- {
- foreach(string error in factor.ConfigErrors())
- {
- yield return error;
- }
- }
- }
-
- public class BloodRelationDegreeFactor
- {
- public BloodRelationDegree? bloodRelationDegree;
- public float romanceChanceFactor;
-
- public IEnumerable ConfigErrors()
- {
- if (bloodRelationDegree == null)
- {
- yield return " is empty";
- }
-
- if (romanceChanceFactor == 0f)
- {
- yield return " should be > 0";
- }
- }
- }
}
}
diff --git a/Source/IdeologyAddon/RelationHelpers.cs b/Source/IdeologyAddon/RelationHelpers.cs
index 1033307..2a5fe77 100644
--- a/Source/IdeologyAddon/RelationHelpers.cs
+++ b/Source/IdeologyAddon/RelationHelpers.cs
@@ -11,11 +11,6 @@ namespace RJWSexperience.Ideology
///
public static BloodRelationDegree GetBloodRelationDegree(Pawn pawn, Pawn partner)
{
- if (!pawn.relations.FamilyByBlood.Contains(partner))
- {
- return BloodRelationDegree.NotRelated;
- }
-
PawnRelationDef closestBloodRelation = pawn
.GetRelations(partner)
?.Where(def => def.familyByBloodRelation)
diff --git a/Source/IdeologyAddon/RomanceChanceFactorHelpers.cs b/Source/IdeologyAddon/RomanceChanceFactorHelpers.cs
index bae549e..298916c 100644
--- a/Source/IdeologyAddon/RomanceChanceFactorHelpers.cs
+++ b/Source/IdeologyAddon/RomanceChanceFactorHelpers.cs
@@ -1,5 +1,4 @@
using RimWorld;
-using RJWSexperience.Ideology.Precepts;
using System.Collections.Generic;
using System.Linq;
using Verse;
@@ -18,11 +17,13 @@ namespace RJWSexperience.Ideology
///
public static float GetRomanceChanceFactor(Pawn pawn, Pawn partner)
{
+ IEnumerable 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 (!pawn.relations.FamilyByBlood.Contains(partner))
+ if (!relations.Any())
{
- if (pawn.Ideo?.HasPrecept(RsiPreceptDefOf.Incestuos_IncestOnly) == true)
+ if (incestuousPrecept == RsiPreceptDefOf.Incestuos_IncestOnly)
{
return parentRomanceChanceFactor;
}
@@ -32,8 +33,6 @@ namespace RJWSexperience.Ideology
}
}
- PreceptDef incestuousPrecept = pawn.Ideo?.PreceptsListForReading.Select(precept => precept.def).FirstOrFallback(def => def.issue == VariousDefOf.Incestuos);
- IEnumerable relations = pawn.GetRelations(partner).Where(def => def.familyByBloodRelation);
foreach (PawnRelationDef relationDef in relations)
{
romanceChanceFactor *= GetRomanceChanceFactor(relationDef, incestuousPrecept);
@@ -47,23 +46,43 @@ namespace RJWSexperience.Ideology
///
public static float GetRomanceChanceFactor(PawnRelationDef relationDef, PreceptDef incestuousPrecept)
{
- if (incestuousPrecept == null)
+ if (incestuousPrecept == null || incestuousPrecept == RsiPreceptDefOf.Incestuos_Disapproved) // Default game setup
{
return relationDef.romanceChanceFactor;
}
- var incestDefExt = incestuousPrecept.GetModExtension();
-
- if (incestDefExt == null)
+ if (incestuousPrecept == RsiPreceptDefOf.Incestuos_Free)
{
- return relationDef.romanceChanceFactor;
+ return 1f;
}
-
- BloodRelationDegree relationDegree = RelationHelpers.GetBloodRelationDegree(relationDef);
-
- if (incestDefExt.TryGetRomanceChanceFactor(relationDegree, out var romanceChanceOverride))
+ else if (incestuousPrecept == RsiPreceptDefOf.Incestuos_Disapproved_CloseOnly)
{
- return 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 relationDef.romanceChanceFactor;
diff --git a/Source/IdeologyAddon/RsiPreceptDefOf.cs b/Source/IdeologyAddon/RsiPreceptDefOf.cs
index 1638e76..977954a 100644
--- a/Source/IdeologyAddon/RsiPreceptDefOf.cs
+++ b/Source/IdeologyAddon/RsiPreceptDefOf.cs
@@ -5,6 +5,10 @@ namespace RJWSexperience.Ideology
[DefOf]
public static class RsiPreceptDefOf
{
+ public static readonly PreceptDef Incestuos_Free;
+ public static readonly PreceptDef Incestuos_Disapproved_CloseOnly;
+ public static readonly PreceptDef Incestuos_Disapproved;
+ public static readonly PreceptDef Incestuos_Forbidden;
public static readonly PreceptDef Incestuos_IncestOnly;
public static readonly PreceptDef Bestiality_OnlyVenerated;
public static readonly PreceptDef BabyFaction_AlwaysFather;