This commit is contained in:
c0ffee 2024-05-03 04:49:15 -07:00
parent 96986104d5
commit 0e9419b039
9 changed files with 120 additions and 3 deletions

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<Defs>
<Rimworld_Animations.VoiceDef>
<defName>Voice_HumanFemale</defName>
<race>Human</race>
<gender>Female</gender>
<sounds>
<!-- <li><key>Moan</key><value>FemaleMoanSoundDefHere</value></li> -->
</sounds>
</Rimworld_Animations.VoiceDef>
<Rimworld_Animations.VoiceDef>
<defName>Voice_HumanMale</defName>
<race>Human</race>
<gender>Male</gender>
<sounds>
<!-- <li><key>Moan</key><value>MaleMoanSoundDefHere</value></li> -->
</sounds>
</Rimworld_Animations.VoiceDef>
</Defs>

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<Defs>
<!--
<Rimworld_Animations.VoiceDef>
<defName>Voice_Orassan</defName>
<race>Alien_Orassan</race>
<gender>Male</gender>
<traitDefs>
<li>Wimpy</li>
</traitDefs>
<sounds>
<li><key>Moan</key><value>CatMoans</value></li>
</sounds>
</Rimworld_Animations.VoiceDef>
-->
</Defs>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<Defs>
<Rimworld_Animations.VoiceTagDef>
<defName>Moan</defName>
</Rimworld_Animations.VoiceTagDef>
</Defs>

View File

@ -52,7 +52,7 @@ namespace Rimworld_Animations
{
if (context.AnimationPriority() > priority)
{
//get highest priority context for fitting animation
//get highest priority context for fitting animation, and its reorder
priority = context.AnimationPriority();
reorder = context.AnimationReorder();

View File

@ -252,11 +252,11 @@ namespace Rimworld_Animations {
//all voice options
List<VoiceDef> voiceOptions =
DefDatabase<VoiceDef>.AllDefsListForReading
.FindAll(voiceDef => voice.VoiceFitsPawn(pawn));
.FindAll(voiceDef => voiceDef.VoiceFitsPawn(pawn));
//all voice options, with priority (for traitdef specific voices)
List<VoiceDef> voiceOptionsWithPriority =
voiceOptions.FindAll(voiceDef => voice.takesPriority);
voiceOptions.FindAll(voiceDef => voiceDef.takesPriority);
if (!voiceOptionsWithPriority.NullOrEmpty())
{

View File

@ -0,0 +1,39 @@
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 ThingDef race;
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 race
if (pawn.def != race) 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;
}
}
}

View File

@ -0,0 +1,22 @@
using RimWorld;
using rjw;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Rimworld_Animations
{
[DefOf]
public static class VoiceDefOf
{
static VoiceDefOf()
{
DefOfHelper.EnsureInitializedInCtor(typeof(VoiceDefOf));
}
public static VoiceDef Voice_HumanMale;
public static VoiceDef Voice_HumanFemale;
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
namespace Rimworld_Animations
{
public class VoiceTagDef : Def
{
}
}