diff --git a/1.5/Assemblies/Rimworld-Animations.dll b/1.5/Assemblies/Rimworld-Animations.dll index 9ecd083..9f4b569 100644 Binary files a/1.5/Assemblies/Rimworld-Animations.dll and b/1.5/Assemblies/Rimworld-Animations.dll differ diff --git a/1.5/Defs/AnimationDefs/TestAnimation1.xml b/1.5/Defs/AnimationDefs/TestAnimation1.xml index 466bbb4..60362c4 100644 --- a/1.5/Defs/AnimationDefs/TestAnimation1.xml +++ b/1.5/Defs/AnimationDefs/TestAnimation1.xml @@ -12,6 +12,7 @@ Rimworld_Animations.AnimationWorker_KeyframesExtended
  • + Fuck 30 0 true diff --git a/1.5/Source/Animations/AnimationWorkers/AnimationWorker_KeyframesExtended.cs b/1.5/Source/Animations/AnimationWorkers/AnimationWorker_KeyframesExtended.cs index 1b41241..0b74719 100644 --- a/1.5/Source/Animations/AnimationWorkers/AnimationWorker_KeyframesExtended.cs +++ b/1.5/Source/Animations/AnimationWorkers/AnimationWorker_KeyframesExtended.cs @@ -22,6 +22,23 @@ namespace Rimworld_Animations return base.OffsetAtTick(tick, parms); } + public SoundDef soundAtTick(int tick) + { + + //Verse.Keyframe keyframe = this.part.keyframes[0]; + Verse.Keyframe keyframe2 = this.part.keyframes[this.part.keyframes.Count - 1]; + foreach (Verse.Keyframe keyframe in this.part.keyframes) + { + if (tick == keyframe.tick) + { + return (keyframe as ExtendedKeyframe).sound; + } + + } + + return null; + } + //use extendedkeyframes to determine addon facing diff --git a/1.5/Source/Comps/CompExtendedAnimator.cs b/1.5/Source/Comps/CompExtendedAnimator.cs index 463dd3f..442a0fb 100644 --- a/1.5/Source/Comps/CompExtendedAnimator.cs +++ b/1.5/Source/Comps/CompExtendedAnimator.cs @@ -93,6 +93,9 @@ namespace Rimworld_Animations { StopAnimating(); } } + + CheckAndPlaySounds(); + } @@ -198,6 +201,42 @@ namespace Rimworld_Animations { } + public void CheckAndPlaySounds() + { + + PawnRenderNode rootNode = pawn.Drawer?.renderer?.renderTree?.rootNode; + + //check if the rootnode has sounds; if so play it + if (rootNode?.AnimationWorker is AnimationWorker_KeyframesExtended animWorker) + { + SoundDef sound = animWorker.soundAtTick(rootNode.tree.AnimationTick); + if (sound != null) + { + sound.PlayOneShot(new TargetInfo(pawn.Position, pawn.Map)); + } + + } + + + if (rootNode?.children != null) + { + foreach (PawnRenderNode node in rootNode?.children) + { + if (node?.AnimationWorker is AnimationWorker_KeyframesExtended childrenAnimWorker) + { + 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) { // never true if not animating; anim props shouldn't be attached