rjw-quirks/RJW-Quirks/Modules/Shared/Selectors/Pawn/HasSkillLevel.cs

37 lines
997 B
C#

using RimWorld;
using System.Collections.Generic;
using Verse;
namespace rjwquirks.Modules.Shared.PawnSelectors
{
public class HasSkillLevel : PawnSelector
{
public SkillDef skill;
public int minLevel = 0;
public int maxLevel = 200; // mods can unlock levels past 20
public override bool PawnSatisfies(Pawn pawn)
{
int skillLevel = pawn.skills?.GetSkill(skill)?.levelInt ?? -1;
return minLevel <= skillLevel && skillLevel <= maxLevel;
}
public override IEnumerable<string> ConfigErrors()
{
foreach (string error in base.ConfigErrors())
{
yield return error;
}
if (skill == null)
{
yield return "<skill> is empty";
}
if (minLevel == 0 && maxLevel == 200)
{
yield return "<minLevel> and/or <maxLevel> should be filled";
}
}
}
}