Compare commits
3 Commits
315a57e53d
...
66f84a00f3
Author | SHA1 | Date |
---|---|---|
c0ffee | 66f84a00f3 | |
c0ffee | 3f7a7bfdc3 | |
c0ffee | c800084a32 |
Binary file not shown.
|
@ -12,6 +12,7 @@
|
|||
<workerClass>Rimworld_Animations.AnimationWorker_KeyframesExtended</workerClass>
|
||||
<keyframes>
|
||||
<li Class="Rimworld_Animations.ExtendedKeyframe">
|
||||
<sound>Fuck</sound>
|
||||
<tick>30</tick>
|
||||
<angle>0</angle>
|
||||
<visible>true</visible>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue