mirror of
https://gitgud.io/c0ffeeeeeeee/rimworld-animations.git
synced 2024-08-15 00:43:45 +00:00
better error handling for missing rootnodes or rendernode animationworkers
This commit is contained in:
parent
c800084a32
commit
3f7a7bfdc3
2 changed files with 3 additions and 3 deletions
Binary file not shown.
|
@ -204,10 +204,10 @@ namespace Rimworld_Animations {
|
||||||
public void CheckAndPlaySounds()
|
public void CheckAndPlaySounds()
|
||||||
{
|
{
|
||||||
|
|
||||||
PawnRenderNode rootNode = pawn.Drawer.renderer.renderTree.rootNode;
|
PawnRenderNode rootNode = pawn.Drawer?.renderer?.renderTree?.rootNode;
|
||||||
|
|
||||||
//check if the rootnode has sounds; if so play it
|
//check if the rootnode has sounds; if so play it
|
||||||
if (rootNode.AnimationWorker is AnimationWorker_KeyframesExtended animWorker)
|
if (rootNode?.AnimationWorker is AnimationWorker_KeyframesExtended animWorker)
|
||||||
{
|
{
|
||||||
SoundDef sound = animWorker.soundAtTick(rootNode.tree.AnimationTick);
|
SoundDef sound = animWorker.soundAtTick(rootNode.tree.AnimationTick);
|
||||||
if (sound != null)
|
if (sound != null)
|
||||||
|
@ -220,7 +220,7 @@ namespace Rimworld_Animations {
|
||||||
//do the same for all the child nodes
|
//do the same for all the child nodes
|
||||||
foreach (PawnRenderNode node in rootNode.children)
|
foreach (PawnRenderNode node in rootNode.children)
|
||||||
{
|
{
|
||||||
if (node.AnimationWorker is AnimationWorker_KeyframesExtended childrenAnimWorker)
|
if (node?.AnimationWorker is AnimationWorker_KeyframesExtended childrenAnimWorker)
|
||||||
{
|
{
|
||||||
SoundDef sound = childrenAnimWorker.soundAtTick(node.tree.AnimationTick);
|
SoundDef sound = childrenAnimWorker.soundAtTick(node.tree.AnimationTick);
|
||||||
if (sound != null)
|
if (sound != null)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue