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
|
@ -1,30 +1,41 @@
|
|||
using System.Collections.Generic;
|
||||
using RJWSexperience.Ideology.Filters;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Verse;
|
||||
|
||||
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
|
||||
{
|
||||
[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
|
||||
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)
|
||||
{
|
||||
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
|
||||
{
|
||||
[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
|
||||
public float multiplier = 1f;
|
||||
[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
|
||||
public TwoPawnFilter filter;
|
||||
|
||||
/// <summary>
|
||||
/// Check if the pair of pawns fits filter conditions
|
||||
/// </summary>
|
||||
public bool Applies(Pawn pawn, Pawn partner)
|
||||
{
|
||||
if (filter == null)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue