mirror of
				https://gitgud.io/amevarashi/rjw-sexperience-ideology.git
				synced 2024-08-15 00:43:19 +00:00 
			
		
		
		
	Moved precepts romanceChanceFactor to DefExtention
This commit is contained in:
		
							parent
							
								
									be1e5c5d5d
								
							
						
					
					
						commit
						f7206347da
					
				
					 5 changed files with 159 additions and 83 deletions
				
			
		| 
						 | 
					@ -27,16 +27,9 @@
 | 
				
			||||||
          <li>
 | 
					          <li>
 | 
				
			||||||
            <filter>
 | 
					            <filter>
 | 
				
			||||||
              <relations>
 | 
					              <relations>
 | 
				
			||||||
                <hasOneOfRelations>
 | 
					                <hasOneOfRelationDegrees>
 | 
				
			||||||
                  <li>Parent</li>
 | 
					                  <li>CloseRelative</li>
 | 
				
			||||||
                  <li>Child</li>
 | 
					                </hasOneOfRelationDegrees>
 | 
				
			||||||
                  <li>Sibling</li>
 | 
					 | 
				
			||||||
                  <li>HalfSibling</li>
 | 
					 | 
				
			||||||
                  <li>Grandparent</li>
 | 
					 | 
				
			||||||
                  <li>Grandchild</li>
 | 
					 | 
				
			||||||
                  <li>NephewOrNiece</li>
 | 
					 | 
				
			||||||
                  <li>UncleOrAunt</li>
 | 
					 | 
				
			||||||
                </hasOneOfRelations>
 | 
					 | 
				
			||||||
              </relations>
 | 
					              </relations>
 | 
				
			||||||
            </filter>
 | 
					            </filter>
 | 
				
			||||||
            <historyEventDef>RSI_CloseRelativeMarriage</historyEventDef>
 | 
					            <historyEventDef>RSI_CloseRelativeMarriage</historyEventDef>
 | 
				
			||||||
| 
						 | 
					@ -44,7 +37,9 @@
 | 
				
			||||||
          <li>
 | 
					          <li>
 | 
				
			||||||
            <filter>
 | 
					            <filter>
 | 
				
			||||||
              <relations>
 | 
					              <relations>
 | 
				
			||||||
                <isBloodRelated>true</isBloodRelated>
 | 
					                <hasOneOfRelationDegrees>
 | 
				
			||||||
 | 
					                  <li>FarRelative</li>
 | 
				
			||||||
 | 
					                </hasOneOfRelationDegrees>
 | 
				
			||||||
              </relations>
 | 
					              </relations>
 | 
				
			||||||
            </filter>
 | 
					            </filter>
 | 
				
			||||||
            <historyEventDef>RSI_IncestuosMarriage</historyEventDef>
 | 
					            <historyEventDef>RSI_IncestuosMarriage</historyEventDef>
 | 
				
			||||||
| 
						 | 
					@ -73,16 +68,9 @@
 | 
				
			||||||
          <li>
 | 
					          <li>
 | 
				
			||||||
            <filter>
 | 
					            <filter>
 | 
				
			||||||
              <relations>
 | 
					              <relations>
 | 
				
			||||||
                <hasOneOfRelations>
 | 
					                <hasOneOfRelationDegrees>
 | 
				
			||||||
                  <li>Parent</li>
 | 
					                  <li>CloseRelative</li>
 | 
				
			||||||
                  <li>Child</li>
 | 
					                </hasOneOfRelationDegrees>
 | 
				
			||||||
                  <li>Sibling</li>
 | 
					 | 
				
			||||||
                  <li>HalfSibling</li>
 | 
					 | 
				
			||||||
                  <li>Grandparent</li>
 | 
					 | 
				
			||||||
                  <li>Grandchild</li>
 | 
					 | 
				
			||||||
                  <li>NephewOrNiece</li>
 | 
					 | 
				
			||||||
                  <li>UncleOrAunt</li>
 | 
					 | 
				
			||||||
                </hasOneOfRelations>
 | 
					 | 
				
			||||||
              </relations>
 | 
					              </relations>
 | 
				
			||||||
            </filter>
 | 
					            </filter>
 | 
				
			||||||
            <historyEventDef>RSI_CloseRelativeSex</historyEventDef>
 | 
					            <historyEventDef>RSI_CloseRelativeSex</historyEventDef>
 | 
				
			||||||
| 
						 | 
					@ -90,7 +78,9 @@
 | 
				
			||||||
          <li>
 | 
					          <li>
 | 
				
			||||||
            <filter>
 | 
					            <filter>
 | 
				
			||||||
              <relations>
 | 
					              <relations>
 | 
				
			||||||
                <isBloodRelated>true</isBloodRelated>
 | 
					                <hasOneOfRelationDegrees>
 | 
				
			||||||
 | 
					                  <li>FarRelative</li>
 | 
				
			||||||
 | 
					                </hasOneOfRelationDegrees>
 | 
				
			||||||
              </relations>
 | 
					              </relations>
 | 
				
			||||||
            </filter>
 | 
					            </filter>
 | 
				
			||||||
            <historyEventDef>RSI_IncestuosSex</historyEventDef>
 | 
					            <historyEventDef>RSI_IncestuosSex</historyEventDef>
 | 
				
			||||||
| 
						 | 
					@ -118,6 +108,20 @@
 | 
				
			||||||
          <li>FarRelative</li>
 | 
					          <li>FarRelative</li>
 | 
				
			||||||
          <li>NotRelated</li>
 | 
					          <li>NotRelated</li>
 | 
				
			||||||
        </allowManualRomanceOnlyFor>
 | 
					        </allowManualRomanceOnlyFor>
 | 
				
			||||||
 | 
					        <bloodRelationDegreeRomanceFactors>
 | 
				
			||||||
 | 
					          <li>
 | 
				
			||||||
 | 
					            <bloodRelationDegree>CloseRelative</bloodRelationDegree>
 | 
				
			||||||
 | 
					            <romanceChanceFactor>1</romanceChanceFactor>
 | 
				
			||||||
 | 
					          </li>
 | 
				
			||||||
 | 
					          <li>
 | 
				
			||||||
 | 
					            <bloodRelationDegree>FarRelative</bloodRelationDegree>
 | 
				
			||||||
 | 
					            <romanceChanceFactor>1</romanceChanceFactor>
 | 
				
			||||||
 | 
					          </li>
 | 
				
			||||||
 | 
					          <li>
 | 
				
			||||||
 | 
					            <bloodRelationDegree>NotRelated</bloodRelationDegree>
 | 
				
			||||||
 | 
					            <romanceChanceFactor>1</romanceChanceFactor>
 | 
				
			||||||
 | 
					          </li>
 | 
				
			||||||
 | 
					        </bloodRelationDegreeRomanceFactors>
 | 
				
			||||||
      </li>
 | 
					      </li>
 | 
				
			||||||
    </modExtensions>
 | 
					    </modExtensions>
 | 
				
			||||||
  </PreceptDef>
 | 
					  </PreceptDef>
 | 
				
			||||||
| 
						 | 
					@ -147,16 +151,9 @@
 | 
				
			||||||
          <li>
 | 
					          <li>
 | 
				
			||||||
            <filter>
 | 
					            <filter>
 | 
				
			||||||
              <relations>
 | 
					              <relations>
 | 
				
			||||||
                <hasOneOfRelations>
 | 
					                <hasOneOfRelationDegrees>
 | 
				
			||||||
                  <li>Parent</li>
 | 
					                  <li>CloseRelative</li>
 | 
				
			||||||
                  <li>Child</li>
 | 
					                </hasOneOfRelationDegrees>
 | 
				
			||||||
                  <li>Sibling</li>
 | 
					 | 
				
			||||||
                  <li>HalfSibling</li>
 | 
					 | 
				
			||||||
                  <li>Grandparent</li>
 | 
					 | 
				
			||||||
                  <li>Grandchild</li>
 | 
					 | 
				
			||||||
                  <li>NephewOrNiece</li>
 | 
					 | 
				
			||||||
                  <li>UncleOrAunt</li>
 | 
					 | 
				
			||||||
                </hasOneOfRelations>
 | 
					 | 
				
			||||||
                <hasNoneOfRelations>
 | 
					                <hasNoneOfRelations>
 | 
				
			||||||
                  <li>Spouse</li>
 | 
					                  <li>Spouse</li>
 | 
				
			||||||
                </hasNoneOfRelations>
 | 
					                </hasNoneOfRelations>
 | 
				
			||||||
| 
						 | 
					@ -171,6 +168,16 @@
 | 
				
			||||||
          <li>FarRelative</li>
 | 
					          <li>FarRelative</li>
 | 
				
			||||||
          <li>NotRelated</li>
 | 
					          <li>NotRelated</li>
 | 
				
			||||||
        </allowManualRomanceOnlyFor>
 | 
					        </allowManualRomanceOnlyFor>
 | 
				
			||||||
 | 
					        <bloodRelationDegreeRomanceFactors>
 | 
				
			||||||
 | 
					          <li>
 | 
				
			||||||
 | 
					            <bloodRelationDegree>FarRelative</bloodRelationDegree>
 | 
				
			||||||
 | 
					            <romanceChanceFactor>1</romanceChanceFactor>
 | 
				
			||||||
 | 
					          </li>
 | 
				
			||||||
 | 
					          <li>
 | 
				
			||||||
 | 
					            <bloodRelationDegree>NotRelated</bloodRelationDegree>
 | 
				
			||||||
 | 
					            <romanceChanceFactor>1</romanceChanceFactor>
 | 
				
			||||||
 | 
					          </li>
 | 
				
			||||||
 | 
					        </bloodRelationDegreeRomanceFactors>
 | 
				
			||||||
      </li>
 | 
					      </li>
 | 
				
			||||||
    </modExtensions>
 | 
					    </modExtensions>
 | 
				
			||||||
  </PreceptDef>
 | 
					  </PreceptDef>
 | 
				
			||||||
| 
						 | 
					@ -204,7 +211,10 @@
 | 
				
			||||||
          <li>
 | 
					          <li>
 | 
				
			||||||
            <filter>
 | 
					            <filter>
 | 
				
			||||||
              <relations>
 | 
					              <relations>
 | 
				
			||||||
                <isBloodRelated>true</isBloodRelated>
 | 
					                <hasOneOfRelationDegrees>
 | 
				
			||||||
 | 
					                  <li>CloseRelative</li>
 | 
				
			||||||
 | 
					                  <li>FarRelative</li>
 | 
				
			||||||
 | 
					                </hasOneOfRelationDegrees>
 | 
				
			||||||
                <hasNoneOfRelations>
 | 
					                <hasNoneOfRelations>
 | 
				
			||||||
                  <li>Spouse</li>
 | 
					                  <li>Spouse</li>
 | 
				
			||||||
                </hasNoneOfRelations>
 | 
					                </hasNoneOfRelations>
 | 
				
			||||||
| 
						 | 
					@ -246,7 +256,10 @@
 | 
				
			||||||
          <li>
 | 
					          <li>
 | 
				
			||||||
            <filter>
 | 
					            <filter>
 | 
				
			||||||
              <relations>
 | 
					              <relations>
 | 
				
			||||||
                <isBloodRelated>true</isBloodRelated>
 | 
					                <hasOneOfRelationDegrees>
 | 
				
			||||||
 | 
					                  <li>CloseRelative</li>
 | 
				
			||||||
 | 
					                  <li>FarRelative</li>
 | 
				
			||||||
 | 
					                </hasOneOfRelationDegrees>
 | 
				
			||||||
                <hasNoneOfRelations>
 | 
					                <hasNoneOfRelations>
 | 
				
			||||||
                  <li>Spouse</li>
 | 
					                  <li>Spouse</li>
 | 
				
			||||||
                </hasNoneOfRelations>
 | 
					                </hasNoneOfRelations>
 | 
				
			||||||
| 
						 | 
					@ -256,6 +269,18 @@
 | 
				
			||||||
          </li>
 | 
					          </li>
 | 
				
			||||||
        </rules>
 | 
					        </rules>
 | 
				
			||||||
      </li>
 | 
					      </li>
 | 
				
			||||||
 | 
					      <li Class="RJWSexperience.Ideology.Precepts.DefExtension_Incest">
 | 
				
			||||||
 | 
					        <bloodRelationDegreeRomanceFactors>
 | 
				
			||||||
 | 
					          <li>
 | 
				
			||||||
 | 
					            <bloodRelationDegree>CloseRelative</bloodRelationDegree>
 | 
				
			||||||
 | 
					            <romanceChanceFactor>0.03</romanceChanceFactor> <!-- same as vanilla "parent" -->
 | 
				
			||||||
 | 
					          </li>
 | 
				
			||||||
 | 
					          <li>
 | 
				
			||||||
 | 
					            <bloodRelationDegree>FarRelative</bloodRelationDegree>
 | 
				
			||||||
 | 
					            <romanceChanceFactor>0.03</romanceChanceFactor>
 | 
				
			||||||
 | 
					          </li>
 | 
				
			||||||
 | 
					        </bloodRelationDegreeRomanceFactors>
 | 
				
			||||||
 | 
					      </li>
 | 
				
			||||||
    </modExtensions>
 | 
					    </modExtensions>
 | 
				
			||||||
  </PreceptDef>
 | 
					  </PreceptDef>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -283,7 +308,9 @@
 | 
				
			||||||
          <li>
 | 
					          <li>
 | 
				
			||||||
            <filter>
 | 
					            <filter>
 | 
				
			||||||
              <relations>
 | 
					              <relations>
 | 
				
			||||||
                <isBloodRelated>false</isBloodRelated>
 | 
					                <hasOneOfRelationDegrees>
 | 
				
			||||||
 | 
					                  <li>NotRelated</li>
 | 
				
			||||||
 | 
					                </hasOneOfRelationDegrees>
 | 
				
			||||||
              </relations>
 | 
					              </relations>
 | 
				
			||||||
            </filter>
 | 
					            </filter>
 | 
				
			||||||
            <multiplier>0.1</multiplier>
 | 
					            <multiplier>0.1</multiplier>
 | 
				
			||||||
| 
						 | 
					@ -295,6 +322,20 @@
 | 
				
			||||||
          <li>CloseRelative</li>
 | 
					          <li>CloseRelative</li>
 | 
				
			||||||
          <li>FarRelative</li>
 | 
					          <li>FarRelative</li>
 | 
				
			||||||
        </allowManualRomanceOnlyFor>
 | 
					        </allowManualRomanceOnlyFor>
 | 
				
			||||||
 | 
					        <bloodRelationDegreeRomanceFactors>
 | 
				
			||||||
 | 
					          <li>
 | 
				
			||||||
 | 
					            <bloodRelationDegree>CloseRelative</bloodRelationDegree>
 | 
				
			||||||
 | 
					            <romanceChanceFactor>1</romanceChanceFactor>
 | 
				
			||||||
 | 
					          </li>
 | 
				
			||||||
 | 
					          <li>
 | 
				
			||||||
 | 
					            <bloodRelationDegree>FarRelative</bloodRelationDegree>
 | 
				
			||||||
 | 
					            <romanceChanceFactor>1</romanceChanceFactor>
 | 
				
			||||||
 | 
					          </li>
 | 
				
			||||||
 | 
					          <li>
 | 
				
			||||||
 | 
					            <bloodRelationDegree>NotRelated</bloodRelationDegree>
 | 
				
			||||||
 | 
					            <romanceChanceFactor>0.03</romanceChanceFactor>
 | 
				
			||||||
 | 
					          </li>
 | 
				
			||||||
 | 
					        </bloodRelationDegreeRomanceFactors>
 | 
				
			||||||
      </li>
 | 
					      </li>
 | 
				
			||||||
    </modExtensions>
 | 
					    </modExtensions>
 | 
				
			||||||
  </PreceptDef>
 | 
					  </PreceptDef>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,6 @@
 | 
				
			||||||
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.Filters
 | 
					namespace RJWSexperience.Ideology.Filters
 | 
				
			||||||
| 
						 | 
					@ -13,14 +12,14 @@ namespace RJWSexperience.Ideology.Filters
 | 
				
			||||||
	public class RelationFilter
 | 
						public class RelationFilter
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		public bool? isVeneratedAnimal;
 | 
							public bool? isVeneratedAnimal;
 | 
				
			||||||
		public bool? isAlien;
 | 
					 | 
				
			||||||
		public bool? isBloodRelated;
 | 
					 | 
				
			||||||
		public List<PawnRelationDef> hasOneOfRelations;
 | 
							public List<PawnRelationDef> hasOneOfRelations;
 | 
				
			||||||
		public List<PawnRelationDef> hasNoneOfRelations;
 | 
							public List<PawnRelationDef> hasNoneOfRelations;
 | 
				
			||||||
 | 
							public List<BloodRelationDegree> hasOneOfRelationDegrees;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		private bool initialized = false;
 | 
							private bool initialized = false;
 | 
				
			||||||
		private HashSet<PawnRelationDef> hasOneOfRelationsHashed;
 | 
							private HashSet<PawnRelationDef> hasOneOfRelationsHashed;
 | 
				
			||||||
		private HashSet<PawnRelationDef> hasNoneOfRelationsHashed;
 | 
							private HashSet<PawnRelationDef> hasNoneOfRelationsHashed;
 | 
				
			||||||
 | 
							private HashSet<BloodRelationDegree> hasOneOfRelationDegreesHashed;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/// <summary>
 | 
							/// <summary>
 | 
				
			||||||
		/// Check if the pair of pawns fits filter conditions
 | 
							/// Check if the pair of pawns fits filter conditions
 | 
				
			||||||
| 
						 | 
					@ -31,9 +30,6 @@ namespace RJWSexperience.Ideology.Filters
 | 
				
			||||||
			if (isVeneratedAnimal != null && isVeneratedAnimal != pawn.Ideo.IsVeneratedAnimal(partner))
 | 
								if (isVeneratedAnimal != null && isVeneratedAnimal != pawn.Ideo.IsVeneratedAnimal(partner))
 | 
				
			||||||
				return false;
 | 
									return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			//if (isAlien != null && isAlien != partner)
 | 
					 | 
				
			||||||
			//	return false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if (!CheckRelations(pawn, partner))
 | 
								if (!CheckRelations(pawn, partner))
 | 
				
			||||||
				return false;
 | 
									return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -45,13 +41,15 @@ namespace RJWSexperience.Ideology.Filters
 | 
				
			||||||
			if (!initialized)
 | 
								if (!initialized)
 | 
				
			||||||
				Initialize();
 | 
									Initialize();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (hasNoneOfRelationsHashed == null && hasOneOfRelationsHashed == null && isBloodRelated == null)
 | 
								if (hasNoneOfRelationsHashed == null && hasOneOfRelationsHashed == null && hasOneOfRelationDegreesHashed == null)
 | 
				
			||||||
				return true;
 | 
									return true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			IEnumerable<PawnRelationDef> relations = pawn.GetRelations(partner);
 | 
								if (hasOneOfRelationDegreesHashed != null && !hasOneOfRelationDegreesHashed.Contains(RelationHelpers.GetBloodRelationDegree(pawn, partner)))
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
			if (isBloodRelated != null && isBloodRelated != relations.Any(def => def.familyByBloodRelation))
 | 
					 | 
				
			||||||
				return false;
 | 
									return false;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								IEnumerable<PawnRelationDef> relations = pawn.GetRelations(partner);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (hasOneOfRelationsHashed != null)
 | 
								if (hasOneOfRelationsHashed != null)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
| 
						 | 
					@ -78,6 +76,9 @@ namespace RJWSexperience.Ideology.Filters
 | 
				
			||||||
			if (!hasOneOfRelations.NullOrEmpty())
 | 
								if (!hasOneOfRelations.NullOrEmpty())
 | 
				
			||||||
				hasOneOfRelationsHashed = new HashSet<PawnRelationDef>(hasOneOfRelations);
 | 
									hasOneOfRelationsHashed = new HashSet<PawnRelationDef>(hasOneOfRelations);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (!hasOneOfRelationDegrees.NullOrEmpty())
 | 
				
			||||||
 | 
									hasOneOfRelationDegreesHashed = new HashSet<BloodRelationDegree>(hasOneOfRelationDegrees);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			initialized = true;
 | 
								initialized = true;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,4 @@
 | 
				
			||||||
using RJWSexperience.Ideology.Filters;
 | 
					using System.Collections.Generic;
 | 
				
			||||||
using System.Collections.Generic;
 | 
					 | 
				
			||||||
using System.Diagnostics.CodeAnalysis;
 | 
					using System.Diagnostics.CodeAnalysis;
 | 
				
			||||||
using Verse;
 | 
					using Verse;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -12,5 +11,63 @@ namespace RJWSexperience.Ideology.Precepts
 | 
				
			||||||
	public class DefExtension_Incest : DefModExtension
 | 
						public class DefExtension_Incest : DefModExtension
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		public List<BloodRelationDegree> allowManualRomanceOnlyFor;
 | 
							public List<BloodRelationDegree> allowManualRomanceOnlyFor;
 | 
				
			||||||
 | 
							public List<BloodRelationDegreeFactor> bloodRelationDegreeRomanceFactors;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							private Dictionary<BloodRelationDegree, float> _relationDegreeFactorsDict;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							public bool TryGetRomanceChanceFactor(BloodRelationDegree relationDegree, out float romanceChanceFactor)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								if (bloodRelationDegreeRomanceFactors.NullOrEmpty())
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									romanceChanceFactor = 1f;
 | 
				
			||||||
 | 
									return false;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (_relationDegreeFactorsDict == null)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									_relationDegreeFactorsDict = new Dictionary<BloodRelationDegree, float>();
 | 
				
			||||||
 | 
									foreach (BloodRelationDegreeFactor relationDegreeFactor in bloodRelationDegreeRomanceFactors)
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										_relationDegreeFactorsDict.Add((BloodRelationDegree)relationDegreeFactor.bloodRelationDegree, relationDegreeFactor.romanceChanceFactor);
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								return _relationDegreeFactorsDict.TryGetValue(relationDegree, out romanceChanceFactor);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							public override IEnumerable<string> 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<string> ConfigErrors()
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									if (bloodRelationDegree == null)
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										yield return "<bloodRelationDegree> is empty";
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									if (romanceChanceFactor == 0f)
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										yield return "<romanceChanceFactor> should be > 0";
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,5 @@
 | 
				
			||||||
using RimWorld;
 | 
					using RimWorld;
 | 
				
			||||||
 | 
					using RJWSexperience.Ideology.Precepts;
 | 
				
			||||||
using System.Collections.Generic;
 | 
					using System.Collections.Generic;
 | 
				
			||||||
using System.Linq;
 | 
					using System.Linq;
 | 
				
			||||||
using Verse;
 | 
					using Verse;
 | 
				
			||||||
| 
						 | 
					@ -17,12 +18,11 @@ namespace RJWSexperience.Ideology
 | 
				
			||||||
		/// </summary>
 | 
							/// </summary>
 | 
				
			||||||
		public static float GetRomanceChanceFactor(Pawn pawn, Pawn partner)
 | 
							public static float GetRomanceChanceFactor(Pawn pawn, Pawn partner)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			PreceptDef incestuousPrecept = pawn.Ideo?.PreceptsListForReading.Select(precept => precept.def).FirstOrFallback(def => def.issue == VariousDefOf.Incestuos);
 | 
					 | 
				
			||||||
			float romanceChanceFactor = 1f;
 | 
								float romanceChanceFactor = 1f;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (!pawn.relations.FamilyByBlood.Contains(partner))
 | 
								if (!pawn.relations.FamilyByBlood.Contains(partner))
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				if (incestuousPrecept == RsiPreceptDefOf.Incestuos_IncestOnly)
 | 
									if (pawn.Ideo?.HasPrecept(RsiPreceptDefOf.Incestuos_IncestOnly) == true)
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					return parentRomanceChanceFactor;
 | 
										return parentRomanceChanceFactor;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
| 
						 | 
					@ -32,6 +32,7 @@ namespace RJWSexperience.Ideology
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								PreceptDef incestuousPrecept = pawn.Ideo?.PreceptsListForReading.Select(precept => precept.def).FirstOrFallback(def => def.issue == VariousDefOf.Incestuos);
 | 
				
			||||||
			IEnumerable<PawnRelationDef> relations = pawn.GetRelations(partner).Where(def => def.familyByBloodRelation);
 | 
								IEnumerable<PawnRelationDef> relations = pawn.GetRelations(partner).Where(def => def.familyByBloodRelation);
 | 
				
			||||||
			foreach (PawnRelationDef relationDef in relations)
 | 
								foreach (PawnRelationDef relationDef in relations)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
| 
						 | 
					@ -46,43 +47,23 @@ namespace RJWSexperience.Ideology
 | 
				
			||||||
		/// </summary>
 | 
							/// </summary>
 | 
				
			||||||
		public static float GetRomanceChanceFactor(PawnRelationDef relationDef, PreceptDef incestuousPrecept)
 | 
							public static float GetRomanceChanceFactor(PawnRelationDef relationDef, PreceptDef incestuousPrecept)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			if (incestuousPrecept == null || incestuousPrecept == RsiPreceptDefOf.Incestuos_Disapproved) // Default game setup
 | 
								if (incestuousPrecept == null)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				return relationDef.romanceChanceFactor;
 | 
									return relationDef.romanceChanceFactor;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (incestuousPrecept == RsiPreceptDefOf.Incestuos_Free)
 | 
								var incestDefExt = incestuousPrecept.GetModExtension<DefExtension_Incest>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (incestDefExt == null)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				return 1f;
 | 
									return relationDef.romanceChanceFactor;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			else if (incestuousPrecept == RsiPreceptDefOf.Incestuos_Disapproved_CloseOnly)
 | 
					
 | 
				
			||||||
 | 
								BloodRelationDegree relationDegree = RelationHelpers.GetBloodRelationDegree(relationDef);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (incestDefExt.TryGetRomanceChanceFactor(relationDegree, out var romanceChanceOverride))
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				if (relationDef.familyByBloodRelation && relationDef.importance > PawnRelationDefOf.Cousin.importance)
 | 
									return romanceChanceOverride;
 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
					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;
 | 
								return relationDef.romanceChanceFactor;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,10 +5,6 @@ namespace RJWSexperience.Ideology
 | 
				
			||||||
	[DefOf]
 | 
						[DefOf]
 | 
				
			||||||
	public static class RsiPreceptDefOf
 | 
						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 Incestuos_IncestOnly;
 | 
				
			||||||
		public static readonly PreceptDef Bestiality_OnlyVenerated;
 | 
							public static readonly PreceptDef Bestiality_OnlyVenerated;
 | 
				
			||||||
		public static readonly PreceptDef BabyFaction_AlwaysFather;
 | 
							public static readonly PreceptDef BabyFaction_AlwaysFather;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue