2022-07-26 03:55:56 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
|
|
using Verse;
|
|
|
|
|
|
2022-10-14 15:57:17 +00:00
|
|
|
|
namespace RJWSexperience.Ideology
|
2022-07-26 03:55:56 +00:00
|
|
|
|
{
|
2022-10-14 15:57:17 +00:00
|
|
|
|
public class ThoughtDefExtension_StageFromValue : DefModExtension
|
2022-07-26 03:55:56 +00:00
|
|
|
|
{
|
|
|
|
|
[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
|
|
|
|
|
public List<float> minimumValueforStage = new List<float>();
|
2022-08-01 14:21:13 +00:00
|
|
|
|
|
2022-10-14 15:57:17 +00:00
|
|
|
|
public int GetStageIndex(float value)
|
|
|
|
|
{
|
|
|
|
|
for (int i = minimumValueforStage.Count - 1; i > 0; i--)
|
|
|
|
|
{
|
|
|
|
|
if (minimumValueforStage[i] < value)
|
|
|
|
|
{
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-01 14:21:13 +00:00
|
|
|
|
public override IEnumerable<string> ConfigErrors()
|
|
|
|
|
{
|
|
|
|
|
foreach (string error in base.ConfigErrors())
|
|
|
|
|
{
|
|
|
|
|
yield return error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (minimumValueforStage.NullOrEmpty())
|
|
|
|
|
{
|
|
|
|
|
yield return "<minimumValueforStage> should have an entry for every stage";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < minimumValueforStage.Count - 1; i++)
|
|
|
|
|
{
|
|
|
|
|
if (minimumValueforStage[i] > minimumValueforStage[i + 1])
|
|
|
|
|
{
|
|
|
|
|
yield return "Values in <minimumValueforStage> should be ordered from the lowest to the highest";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-07-26 03:55:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|