better error handling for checkandplaysounds

This commit is contained in:
c0ffee 2024-04-22 17:38:30 -07:00
parent 3f7a7bfdc3
commit 66f84a00f3
2 changed files with 12 additions and 7 deletions

View File

@ -217,19 +217,24 @@ namespace Rimworld_Animations {
}
//do the same for all the child nodes
foreach (PawnRenderNode node in rootNode.children)
if (rootNode?.children != null)
{
if (node?.AnimationWorker is AnimationWorker_KeyframesExtended childrenAnimWorker)
foreach (PawnRenderNode node in rootNode?.children)
{
SoundDef sound = childrenAnimWorker.soundAtTick(node.tree.AnimationTick);
if (sound != null)
if (node?.AnimationWorker is AnimationWorker_KeyframesExtended childrenAnimWorker)
{
sound.PlayOneShot(new TargetInfo(pawn.Position, pawn.Map));
SoundDef sound = childrenAnimWorker.soundAtTick(node.tree.AnimationTick);
if (sound != null)
{
sound.PlayOneShot(new TargetInfo(pawn.Position, pawn.Map));
}
}
}
}
//do the same for all the child nodes
}
public bool AnimationMakesUseOfProp(AnimationPropDef animationProp)