mirror of
https://gitgud.io/c0ffeeeeeeee/rimworld-animations.git
synced 2024-08-15 00:43:45 +00:00
playable sounds
This commit is contained in:
parent
315a57e53d
commit
c800084a32
4 changed files with 52 additions and 0 deletions
Binary file not shown.
|
@ -12,6 +12,7 @@
|
||||||
<workerClass>Rimworld_Animations.AnimationWorker_KeyframesExtended</workerClass>
|
<workerClass>Rimworld_Animations.AnimationWorker_KeyframesExtended</workerClass>
|
||||||
<keyframes>
|
<keyframes>
|
||||||
<li Class="Rimworld_Animations.ExtendedKeyframe">
|
<li Class="Rimworld_Animations.ExtendedKeyframe">
|
||||||
|
<sound>Fuck</sound>
|
||||||
<tick>30</tick>
|
<tick>30</tick>
|
||||||
<angle>0</angle>
|
<angle>0</angle>
|
||||||
<visible>true</visible>
|
<visible>true</visible>
|
||||||
|
|
|
@ -22,6 +22,23 @@ namespace Rimworld_Animations
|
||||||
return base.OffsetAtTick(tick, parms);
|
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
|
//use extendedkeyframes to determine addon facing
|
||||||
|
|
|
@ -93,6 +93,9 @@ namespace Rimworld_Animations {
|
||||||
StopAnimating();
|
StopAnimating();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CheckAndPlaySounds();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -198,6 +201,37 @@ 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));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//do the same for all the child nodes
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool AnimationMakesUseOfProp(AnimationPropDef animationProp)
|
public bool AnimationMakesUseOfProp(AnimationPropDef animationProp)
|
||||||
{
|
{
|
||||||
// never true if not animating; anim props shouldn't be attached
|
// never true if not animating; anim props shouldn't be attached
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue