Sound track in animations can now take a function that returns an AudioParam (#1125)

This commit is contained in:
Víctor Aguilera Puerto
2020-06-12 12:47:34 +02:00
committed by GitHub
parent 28b3cd5a52
commit 4d93b0c533

View File

@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using Robust.Client.GameObjects.EntitySystems;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
@@ -38,7 +40,7 @@ namespace Robust.Client.Animations
var keyFrame = KeyFrames[keyFrameIndex];
EntitySystem.Get<AudioSystem>()
.Play(keyFrame.Resource, entity);
.Play(keyFrame.Resource, entity, keyFrame.AudioParamsFunc.Invoke());
}
return (keyFrameIndex, playingTime);
@@ -51,15 +53,23 @@ namespace Robust.Client.Animations
/// </summary>
public readonly string Resource;
/// <summary>
/// A function that returns the audio parameter to be used.
/// The reason this is a function is so that this can return
/// an AudioParam with different parameters each time, such as random pitch.
/// </summary>
public readonly Func<AudioParams> AudioParamsFunc;
/// <summary>
/// The time between this keyframe and the last.
/// </summary>
public readonly float KeyTime;
public KeyFrame(string resource, float keyTime)
public KeyFrame(string resource, float keyTime, Func<AudioParams> audioParams = null)
{
Resource = resource;
KeyTime = keyTime;
AudioParamsFunc = audioParams ?? (() => AudioParams.Default);
}
}
}