40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
using RimWorld;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Verse;
|
|
|
|
namespace Rimworld_Animations
|
|
{
|
|
public class VoiceDef : Def
|
|
{
|
|
|
|
public List<ThingDef> races = new List<ThingDef>();
|
|
public Gender gender = Gender.None;
|
|
public List<TraitDef> traits = new List<TraitDef>();
|
|
public bool takesPriority = false;
|
|
public float randomChanceFactor = 1;
|
|
|
|
public Dictionary<VoiceTagDef, SoundDef> sounds = new Dictionary<VoiceTagDef, SoundDef>();
|
|
|
|
public bool VoiceFitsPawn(Pawn pawn)
|
|
{
|
|
|
|
//doesn't match any of the races
|
|
if (!races.Exists(x => x == pawn.def)) return false;
|
|
|
|
//doesn't match gender
|
|
if (gender != Gender.None && pawn.gender != gender) return false;
|
|
|
|
//if traits list is not empty, and pawn doesn't have any of the designated traits, doesn't match
|
|
if (!traits.Empty() && !traits.Any(trait => pawn.story.traits.HasTrait(trait))) return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
}
|