mirror of
				https://gitgud.io/amevarashi/rjw-sexperience-ideology.git
				synced 2024-08-15 00:43:19 +00:00 
			
		
		
		
	Added isBloodRelated filter attribute
This commit is contained in:
		
							parent
							
								
									765e6c0778
								
							
						
					
					
						commit
						7d6f0d043c
					
				
					 8 changed files with 92 additions and 142 deletions
				
			
		| 
						 | 
					@ -44,24 +44,7 @@
 | 
				
			||||||
          <li>
 | 
					          <li>
 | 
				
			||||||
            <filter>
 | 
					            <filter>
 | 
				
			||||||
              <relations>
 | 
					              <relations>
 | 
				
			||||||
                <hasOneOfRelations>
 | 
					                <isBloodRelated>true</isBloodRelated>
 | 
				
			||||||
                  <li>Parent</li>
 | 
					 | 
				
			||||||
                  <li>Child</li>
 | 
					 | 
				
			||||||
                  <li>Sibling</li>
 | 
					 | 
				
			||||||
                  <li>HalfSibling</li>
 | 
					 | 
				
			||||||
                  <li>Grandparent</li>
 | 
					 | 
				
			||||||
                  <li>Grandchild</li>
 | 
					 | 
				
			||||||
                  <li>NephewOrNiece</li>
 | 
					 | 
				
			||||||
                  <li>UncleOrAunt</li>
 | 
					 | 
				
			||||||
                  <li>GreatGrandparent</li>
 | 
					 | 
				
			||||||
                  <li>GreatGrandchild</li>
 | 
					 | 
				
			||||||
                  <li>GranduncleOrGrandaunt</li>
 | 
					 | 
				
			||||||
                  <li>GrandnephewOrGrandniece</li>
 | 
					 | 
				
			||||||
                  <li>CousinOnceRemoved</li>
 | 
					 | 
				
			||||||
                  <li>SecondCousin</li>
 | 
					 | 
				
			||||||
                  <li>Cousin</li>
 | 
					 | 
				
			||||||
                  <li>Kin</li>
 | 
					 | 
				
			||||||
                </hasOneOfRelations>
 | 
					 | 
				
			||||||
              </relations>
 | 
					              </relations>
 | 
				
			||||||
            </filter>
 | 
					            </filter>
 | 
				
			||||||
            <historyEventDef>RSI_IncestuosMarriage</historyEventDef>
 | 
					            <historyEventDef>RSI_IncestuosMarriage</historyEventDef>
 | 
				
			||||||
| 
						 | 
					@ -107,24 +90,7 @@
 | 
				
			||||||
          <li>
 | 
					          <li>
 | 
				
			||||||
            <filter>
 | 
					            <filter>
 | 
				
			||||||
              <relations>
 | 
					              <relations>
 | 
				
			||||||
                <hasOneOfRelations>
 | 
					                <isBloodRelated>true</isBloodRelated>
 | 
				
			||||||
                  <li>Parent</li>
 | 
					 | 
				
			||||||
                  <li>Child</li>
 | 
					 | 
				
			||||||
                  <li>Sibling</li>
 | 
					 | 
				
			||||||
                  <li>HalfSibling</li>
 | 
					 | 
				
			||||||
                  <li>Grandparent</li>
 | 
					 | 
				
			||||||
                  <li>Grandchild</li>
 | 
					 | 
				
			||||||
                  <li>NephewOrNiece</li>
 | 
					 | 
				
			||||||
                  <li>UncleOrAunt</li>
 | 
					 | 
				
			||||||
                  <li>GreatGrandparent</li>
 | 
					 | 
				
			||||||
                  <li>GreatGrandchild</li>
 | 
					 | 
				
			||||||
                  <li>GranduncleOrGrandaunt</li>
 | 
					 | 
				
			||||||
                  <li>GrandnephewOrGrandniece</li>
 | 
					 | 
				
			||||||
                  <li>CousinOnceRemoved</li>
 | 
					 | 
				
			||||||
                  <li>SecondCousin</li>
 | 
					 | 
				
			||||||
                  <li>Cousin</li>
 | 
					 | 
				
			||||||
                  <li>Kin</li>
 | 
					 | 
				
			||||||
                </hasOneOfRelations>
 | 
					 | 
				
			||||||
              </relations>
 | 
					              </relations>
 | 
				
			||||||
            </filter>
 | 
					            </filter>
 | 
				
			||||||
            <historyEventDef>RSI_IncestuosSex</historyEventDef>
 | 
					            <historyEventDef>RSI_IncestuosSex</historyEventDef>
 | 
				
			||||||
| 
						 | 
					@ -223,24 +189,7 @@
 | 
				
			||||||
          <li>
 | 
					          <li>
 | 
				
			||||||
            <filter>
 | 
					            <filter>
 | 
				
			||||||
              <relations>
 | 
					              <relations>
 | 
				
			||||||
                <hasOneOfRelations>
 | 
					                <isBloodRelated>true</isBloodRelated>
 | 
				
			||||||
                  <li>Parent</li>
 | 
					 | 
				
			||||||
                  <li>Child</li>
 | 
					 | 
				
			||||||
                  <li>Sibling</li>
 | 
					 | 
				
			||||||
                  <li>HalfSibling</li>
 | 
					 | 
				
			||||||
                  <li>Grandparent</li>
 | 
					 | 
				
			||||||
                  <li>Grandchild</li>
 | 
					 | 
				
			||||||
                  <li>NephewOrNiece</li>
 | 
					 | 
				
			||||||
                  <li>UncleOrAunt</li>
 | 
					 | 
				
			||||||
                  <li>GreatGrandparent</li>
 | 
					 | 
				
			||||||
                  <li>GreatGrandchild</li>
 | 
					 | 
				
			||||||
                  <li>GranduncleOrGrandaunt</li>
 | 
					 | 
				
			||||||
                  <li>GrandnephewOrGrandniece</li>
 | 
					 | 
				
			||||||
                  <li>CousinOnceRemoved</li>
 | 
					 | 
				
			||||||
                  <li>SecondCousin</li>
 | 
					 | 
				
			||||||
                  <li>Cousin</li>
 | 
					 | 
				
			||||||
                  <li>Kin</li>
 | 
					 | 
				
			||||||
                </hasOneOfRelations>
 | 
					 | 
				
			||||||
                <hasNoneOfRelations>
 | 
					                <hasNoneOfRelations>
 | 
				
			||||||
                  <li>Spouse</li>
 | 
					                  <li>Spouse</li>
 | 
				
			||||||
                </hasNoneOfRelations>
 | 
					                </hasNoneOfRelations>
 | 
				
			||||||
| 
						 | 
					@ -282,24 +231,7 @@
 | 
				
			||||||
          <li>
 | 
					          <li>
 | 
				
			||||||
            <filter>
 | 
					            <filter>
 | 
				
			||||||
              <relations>
 | 
					              <relations>
 | 
				
			||||||
                <hasOneOfRelations>
 | 
					                <isBloodRelated>true</isBloodRelated>
 | 
				
			||||||
                  <li>Parent</li>
 | 
					 | 
				
			||||||
                  <li>Child</li>
 | 
					 | 
				
			||||||
                  <li>Sibling</li>
 | 
					 | 
				
			||||||
                  <li>HalfSibling</li>
 | 
					 | 
				
			||||||
                  <li>Grandparent</li>
 | 
					 | 
				
			||||||
                  <li>Grandchild</li>
 | 
					 | 
				
			||||||
                  <li>NephewOrNiece</li>
 | 
					 | 
				
			||||||
                  <li>UncleOrAunt</li>
 | 
					 | 
				
			||||||
                  <li>GreatGrandparent</li>
 | 
					 | 
				
			||||||
                  <li>GreatGrandchild</li>
 | 
					 | 
				
			||||||
                  <li>GranduncleOrGrandaunt</li>
 | 
					 | 
				
			||||||
                  <li>GrandnephewOrGrandniece</li>
 | 
					 | 
				
			||||||
                  <li>CousinOnceRemoved</li>
 | 
					 | 
				
			||||||
                  <li>SecondCousin</li>
 | 
					 | 
				
			||||||
                  <li>Cousin</li>
 | 
					 | 
				
			||||||
                  <li>Kin</li>
 | 
					 | 
				
			||||||
                </hasOneOfRelations>
 | 
					 | 
				
			||||||
                <hasNoneOfRelations>
 | 
					                <hasNoneOfRelations>
 | 
				
			||||||
                  <li>Spouse</li>
 | 
					                  <li>Spouse</li>
 | 
				
			||||||
                </hasNoneOfRelations>
 | 
					                </hasNoneOfRelations>
 | 
				
			||||||
| 
						 | 
					@ -336,24 +268,7 @@
 | 
				
			||||||
          <li>
 | 
					          <li>
 | 
				
			||||||
            <filter>
 | 
					            <filter>
 | 
				
			||||||
              <relations>
 | 
					              <relations>
 | 
				
			||||||
                <hasOneOfRelations>
 | 
					                <isBloodRelated>true</isBloodRelated>
 | 
				
			||||||
                  <li>Parent</li>
 | 
					 | 
				
			||||||
                  <li>Child</li>
 | 
					 | 
				
			||||||
                  <li>Sibling</li>
 | 
					 | 
				
			||||||
                  <li>HalfSibling</li>
 | 
					 | 
				
			||||||
                  <li>Grandparent</li>
 | 
					 | 
				
			||||||
                  <li>Grandchild</li>
 | 
					 | 
				
			||||||
                  <li>NephewOrNiece</li>
 | 
					 | 
				
			||||||
                  <li>UncleOrAunt</li>
 | 
					 | 
				
			||||||
                  <li>GreatGrandparent</li>
 | 
					 | 
				
			||||||
                  <li>GreatGrandchild</li>
 | 
					 | 
				
			||||||
                  <li>GranduncleOrGrandaunt</li>
 | 
					 | 
				
			||||||
                  <li>GrandnephewOrGrandniece</li>
 | 
					 | 
				
			||||||
                  <li>CousinOnceRemoved</li>
 | 
					 | 
				
			||||||
                  <li>SecondCousin</li>
 | 
					 | 
				
			||||||
                  <li>Cousin</li>
 | 
					 | 
				
			||||||
                  <li>Kin</li>
 | 
					 | 
				
			||||||
                </hasOneOfRelations>
 | 
					 | 
				
			||||||
              </relations>
 | 
					              </relations>
 | 
				
			||||||
            </filter>
 | 
					            </filter>
 | 
				
			||||||
            <multiplier>2.0</multiplier>
 | 
					            <multiplier>2.0</multiplier>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,27 +1,33 @@
 | 
				
			||||||
using RimWorld;
 | 
					using RimWorld;
 | 
				
			||||||
using System.Collections.Generic;
 | 
					using System.Collections.Generic;
 | 
				
			||||||
using System.Diagnostics.CodeAnalysis;
 | 
					using System.Diagnostics.CodeAnalysis;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
using Verse;
 | 
					using Verse;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace RJWSexperience.Ideology
 | 
					namespace RJWSexperience.Ideology.Filters
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						/// <summary>
 | 
				
			||||||
 | 
						/// Filter to describe how one pawn sees another
 | 
				
			||||||
 | 
						/// </summary>
 | 
				
			||||||
 | 
						[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Def loader")]
 | 
				
			||||||
	public class RelationFilter
 | 
						public class RelationFilter
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
 | 
					 | 
				
			||||||
		public bool? isVeneratedAnimal;
 | 
							public bool? isVeneratedAnimal;
 | 
				
			||||||
		[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
 | 
					 | 
				
			||||||
		public bool? isAlien;
 | 
							public bool? isAlien;
 | 
				
			||||||
		[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
 | 
							public bool? isBloodRelated;
 | 
				
			||||||
		public List<PawnRelationDef> hasOneOfRelations;
 | 
							public List<PawnRelationDef> hasOneOfRelations;
 | 
				
			||||||
		[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
 | 
					 | 
				
			||||||
		public List<PawnRelationDef> hasNoneOfRelations;
 | 
							public List<PawnRelationDef> hasNoneOfRelations;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		private bool initialized = false;
 | 
							private bool initialized = false;
 | 
				
			||||||
		private HashSet<PawnRelationDef> hasOneOfRelationsHashed;
 | 
							private HashSet<PawnRelationDef> hasOneOfRelationsHashed;
 | 
				
			||||||
		private HashSet<PawnRelationDef> hasNoneOfRelationsHashed;
 | 
							private HashSet<PawnRelationDef> hasNoneOfRelationsHashed;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							/// <summary>
 | 
				
			||||||
 | 
							/// Check if the pair of pawns fits filter conditions
 | 
				
			||||||
 | 
							/// </summary>
 | 
				
			||||||
		public bool Applies(Pawn pawn, Pawn partner)
 | 
							public bool Applies(Pawn pawn, Pawn partner)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
 | 
								// Fail if any single condition fails
 | 
				
			||||||
			if (isVeneratedAnimal != null && isVeneratedAnimal != pawn.Ideo.IsVeneratedAnimal(partner))
 | 
								if (isVeneratedAnimal != null && isVeneratedAnimal != pawn.Ideo.IsVeneratedAnimal(partner))
 | 
				
			||||||
				return false;
 | 
									return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -39,11 +45,14 @@ namespace RJWSexperience.Ideology
 | 
				
			||||||
			if (!initialized)
 | 
								if (!initialized)
 | 
				
			||||||
				Initialize();
 | 
									Initialize();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (hasNoneOfRelationsHashed == null && hasOneOfRelationsHashed == null)
 | 
								if (hasNoneOfRelationsHashed == null && hasOneOfRelationsHashed == null && isBloodRelated == null)
 | 
				
			||||||
				return true;
 | 
									return true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			IEnumerable<PawnRelationDef> relations = pawn.GetRelations(partner);
 | 
								IEnumerable<PawnRelationDef> relations = pawn.GetRelations(partner);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (isBloodRelated != null && isBloodRelated != relations.Any(def => def.familyByBloodRelation))
 | 
				
			||||||
 | 
									return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (hasOneOfRelationsHashed != null)
 | 
								if (hasOneOfRelationsHashed != null)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				if (relations.EnumerableNullOrEmpty())
 | 
									if (relations.EnumerableNullOrEmpty())
 | 
				
			||||||
| 
						 | 
					@ -2,19 +2,24 @@
 | 
				
			||||||
using System.Diagnostics.CodeAnalysis;
 | 
					using System.Diagnostics.CodeAnalysis;
 | 
				
			||||||
using Verse;
 | 
					using Verse;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace RJWSexperience.Ideology
 | 
					namespace RJWSexperience.Ideology.Filters
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						/// <summary>
 | 
				
			||||||
 | 
						/// Filter to describe one pawn
 | 
				
			||||||
 | 
						/// </summary>
 | 
				
			||||||
 | 
						[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Def loader")]
 | 
				
			||||||
	public class SinglePawnFilter
 | 
						public class SinglePawnFilter
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
 | 
					 | 
				
			||||||
		public bool? isAnimal;
 | 
							public bool? isAnimal;
 | 
				
			||||||
		[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
 | 
					 | 
				
			||||||
		public bool? isSlave;
 | 
							public bool? isSlave;
 | 
				
			||||||
		[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
 | 
					 | 
				
			||||||
		public bool? isPrisoner;
 | 
							public bool? isPrisoner;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							/// <summary>
 | 
				
			||||||
 | 
							/// Check if pawn fits filter conditions
 | 
				
			||||||
 | 
							/// </summary>
 | 
				
			||||||
		public bool Applies(Pawn pawn)
 | 
							public bool Applies(Pawn pawn)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
 | 
								// Fail if any single condition fails
 | 
				
			||||||
			if (isAnimal != null && isAnimal != pawn.IsAnimal())
 | 
								if (isAnimal != null && isAnimal != pawn.IsAnimal())
 | 
				
			||||||
				return false;
 | 
									return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										34
									
								
								Source/IdeologyAddon/Filters/TwoPawnFilter.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								Source/IdeologyAddon/Filters/TwoPawnFilter.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,34 @@
 | 
				
			||||||
 | 
					using System.Diagnostics.CodeAnalysis;
 | 
				
			||||||
 | 
					using Verse;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace RJWSexperience.Ideology.Filters
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						/// <summary>
 | 
				
			||||||
 | 
						/// Filter to describe two pawns and relations between them
 | 
				
			||||||
 | 
						/// </summary>
 | 
				
			||||||
 | 
						[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Def loader")]
 | 
				
			||||||
 | 
						public class TwoPawnFilter
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							public SinglePawnFilter doer;
 | 
				
			||||||
 | 
							public SinglePawnFilter partner;
 | 
				
			||||||
 | 
							public RelationFilter relations;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							/// <summary>
 | 
				
			||||||
 | 
							/// Check if the pair of pawns fits filter conditions
 | 
				
			||||||
 | 
							/// </summary>
 | 
				
			||||||
 | 
							public bool Applies(Pawn pawn, Pawn partner)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								// Fail if any single condition fails
 | 
				
			||||||
 | 
								if (doer?.Applies(pawn) == false)
 | 
				
			||||||
 | 
									return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (this.partner?.Applies(partner) == false)
 | 
				
			||||||
 | 
									return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (relations?.Applies(pawn, partner) == false)
 | 
				
			||||||
 | 
									return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								return true;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1,16 +1,22 @@
 | 
				
			||||||
using RimWorld;
 | 
					using RimWorld;
 | 
				
			||||||
 | 
					using RJWSexperience.Ideology.Filters;
 | 
				
			||||||
using System.Diagnostics.CodeAnalysis;
 | 
					using System.Diagnostics.CodeAnalysis;
 | 
				
			||||||
using Verse;
 | 
					using Verse;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace RJWSexperience.Ideology.HistoryEvents
 | 
					namespace RJWSexperience.Ideology.HistoryEvents
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						/// <summary>
 | 
				
			||||||
 | 
						/// Type to associate single HistoryEventDef with a TwoPawnFilter
 | 
				
			||||||
 | 
						/// </summary>
 | 
				
			||||||
 | 
						[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Def loader")]
 | 
				
			||||||
	public class TwoPawnEventRule
 | 
						public class TwoPawnEventRule
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
 | 
					 | 
				
			||||||
		public HistoryEventDef historyEventDef;
 | 
							public HistoryEventDef historyEventDef;
 | 
				
			||||||
		[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
 | 
					 | 
				
			||||||
		public TwoPawnFilter filter;
 | 
							public TwoPawnFilter filter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							/// <summary>
 | 
				
			||||||
 | 
							/// Check if the pair of pawns fits filter conditions
 | 
				
			||||||
 | 
							/// </summary>
 | 
				
			||||||
		public bool Applies(Pawn pawn, Pawn partner) => filter?.Applies(pawn, partner) == true;
 | 
							public bool Applies(Pawn pawn, Pawn partner) => filter?.Applies(pawn, partner) == true;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -59,13 +59,13 @@
 | 
				
			||||||
    <Compile Include="PreceptWorkers\ThoughtWorker_Precept_NonPregnant_Social.cs" />
 | 
					    <Compile Include="PreceptWorkers\ThoughtWorker_Precept_NonPregnant_Social.cs" />
 | 
				
			||||||
    <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="Filters\RelationFilter.cs" />
 | 
				
			||||||
    <Compile Include="RelationHelpers.cs" />
 | 
					    <Compile Include="RelationHelpers.cs" />
 | 
				
			||||||
    <Compile Include="RomanceChanceFactorHelpers.cs" />
 | 
					    <Compile Include="RomanceChanceFactorHelpers.cs" />
 | 
				
			||||||
    <Compile Include="RsiHistoryEventDefOf.cs" />
 | 
					    <Compile Include="RsiHistoryEventDefOf.cs" />
 | 
				
			||||||
    <Compile Include="RsiPreceptDefOf.cs" />
 | 
					    <Compile Include="RsiPreceptDefOf.cs" />
 | 
				
			||||||
    <Compile Include="TwoPawnFilter.cs" />
 | 
					    <Compile Include="Filters\TwoPawnFilter.cs" />
 | 
				
			||||||
    <Compile Include="SinglePawnFilter.cs" />
 | 
					    <Compile Include="Filters\SinglePawnFilter.cs" />
 | 
				
			||||||
    <Compile Include="Precepts\Comp_SelfTookMemoryThought_Gendered.cs" />
 | 
					    <Compile Include="Precepts\Comp_SelfTookMemoryThought_Gendered.cs" />
 | 
				
			||||||
    <Compile Include="Precepts\Comp_KnowsMemoryThought_Gendered.cs" />
 | 
					    <Compile Include="Precepts\Comp_KnowsMemoryThought_Gendered.cs" />
 | 
				
			||||||
    <Compile Include="HistoryEvents\HistoryEventDefExtensionMethods.cs" />
 | 
					    <Compile Include="HistoryEvents\HistoryEventDefExtensionMethods.cs" />
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,30 +1,41 @@
 | 
				
			||||||
using System.Collections.Generic;
 | 
					using RJWSexperience.Ideology.Filters;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
using System.Diagnostics.CodeAnalysis;
 | 
					using System.Diagnostics.CodeAnalysis;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
using Verse;
 | 
					using Verse;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace RJWSexperience.Ideology.Precepts
 | 
					namespace RJWSexperience.Ideology.Precepts
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						/// <summary>
 | 
				
			||||||
 | 
						/// Def extension to enable changing SexAppraiser results based on filters
 | 
				
			||||||
 | 
						/// </summary>
 | 
				
			||||||
 | 
						[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Def loader")]
 | 
				
			||||||
	public class DefExtension_ModifyPreference : DefModExtension
 | 
						public class DefExtension_ModifyPreference : DefModExtension
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
 | 
					 | 
				
			||||||
		public List<Rule> rules;
 | 
							public List<Rule> rules;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							/// <summary>
 | 
				
			||||||
 | 
							/// Apply SexAppraiser modifiers from rules with a satisfied filter
 | 
				
			||||||
 | 
							/// </summary>
 | 
				
			||||||
		public void Apply(Pawn pawn, Pawn partner, ref float preference)
 | 
							public void Apply(Pawn pawn, Pawn partner, ref float preference)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			foreach (Rule rule in rules)
 | 
								foreach (Rule rule in rules.Where(rule => rule.Applies(pawn, partner)))
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				if (rule.Applies(pawn, partner))
 | 
									preference *= rule.multiplier;
 | 
				
			||||||
					preference *= rule.multiplier;
 | 
					 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							/// <summary>
 | 
				
			||||||
 | 
							/// Type to associate SexAppraiser result modifier with a TwoPawnFilter
 | 
				
			||||||
 | 
							/// </summary>
 | 
				
			||||||
		public class Rule
 | 
							public class Rule
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
 | 
					 | 
				
			||||||
			public float multiplier = 1f;
 | 
								public float multiplier = 1f;
 | 
				
			||||||
			[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
 | 
					 | 
				
			||||||
			public TwoPawnFilter filter;
 | 
								public TwoPawnFilter filter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								/// <summary>
 | 
				
			||||||
 | 
								/// Check if the pair of pawns fits filter conditions
 | 
				
			||||||
 | 
								/// </summary>
 | 
				
			||||||
			public bool Applies(Pawn pawn, Pawn partner)
 | 
								public bool Applies(Pawn pawn, Pawn partner)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				if (filter == null)
 | 
									if (filter == null)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,30 +0,0 @@
 | 
				
			||||||
using rjw;
 | 
					 | 
				
			||||||
using System.Diagnostics.CodeAnalysis;
 | 
					 | 
				
			||||||
using Verse;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace RJWSexperience.Ideology
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	public class TwoPawnFilter
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
 | 
					 | 
				
			||||||
		public SinglePawnFilter doer;
 | 
					 | 
				
			||||||
		[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
 | 
					 | 
				
			||||||
		public SinglePawnFilter partner;
 | 
					 | 
				
			||||||
		[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
 | 
					 | 
				
			||||||
		public RelationFilter relations;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		public bool Applies(Pawn pawn, Pawn partner)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			if (doer?.Applies(pawn) == false)
 | 
					 | 
				
			||||||
				return false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if (this.partner?.Applies(partner) == false)
 | 
					 | 
				
			||||||
				return false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if (relations?.Applies(pawn, partner) == false)
 | 
					 | 
				
			||||||
				return false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			return true;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue