From 4fd4b4f6f37c134a97ac8bbc878a9a7e04b89791 Mon Sep 17 00:00:00 2001 From: zumorica Date: Thu, 14 May 2020 15:55:53 +0200 Subject: [PATCH] Add method to AudioHelpers to get a random file from a sound collection --- Content.Shared/Audio/AudioHelpers.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Content.Shared/Audio/AudioHelpers.cs b/Content.Shared/Audio/AudioHelpers.cs index f6a920f479..41f8262df0 100644 --- a/Content.Shared/Audio/AudioHelpers.cs +++ b/Content.Shared/Audio/AudioHelpers.cs @@ -1,10 +1,14 @@ using System; using Content.Shared.GameObjects.Components.Sound; +using Robust.Client.GameObjects.EntitySystems; using Robust.Shared.Audio; using Robust.Shared.GameObjects; +using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.Random; using Robust.Shared.IoC; using Robust.Shared.Log; +using Robust.Shared.Map; +using Robust.Shared.Prototypes; using Robust.Shared.Random; namespace Content.Shared.Audio @@ -18,5 +22,11 @@ namespace Content.Shared.Audio var scale = (float)(IoCManager.Resolve().NextGaussian(1, amplitude)); return AudioParams.Default.WithPitchScale(scale); } + + public static string GetRandomFileFromSoundCollection(string name) + { + var soundCollection = IoCManager.Resolve().Index(name); + return IoCManager.Resolve().Pick(soundCollection.PickFiles); + } } }