using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Verse;
namespace RJWSexperience.Ideology.Precepts
{
///
/// Special Def extension for the Incestuous issue precepts
///
[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Def loader")]
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";
}
}
}
}
}