replacing sound (collection) names with SoundSpecifier - part 1

This commit is contained in:
Galactic Chimp
2021-07-10 17:35:33 +02:00
parent 4500b66f28
commit ce3c59e0e6
131 changed files with 934 additions and 587 deletions

View File

@@ -9,6 +9,7 @@ using Content.Shared.Interaction.Helpers;
using Content.Shared.Maps;
using Content.Shared.Notification;
using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
@@ -38,6 +39,12 @@ namespace Content.Server.RCD.Components
[ViewVariables(VVAccess.ReadWrite)] [DataField("delay")] private float _delay = 2f;
private DoAfterSystem _doAfterSystem = default!;
[DataField("swapModeSound")]
private SoundSpecifier _swapModeSound = new SoundPathSpecifier("/Audio/Items/genhit.ogg");
[DataField("successSound")]
private SoundSpecifier _successSound = new SoundPathSpecifier("/Audio/Items/deconstruct.ogg");
///Enum to store the different mode states for clarity.
private enum RcdMode
{
@@ -70,8 +77,9 @@ namespace Content.Server.RCD.Components
public void SwapMode(UseEntityEventArgs eventArgs)
{
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Items/genhit.ogg", Owner);
int mode = (int) _mode; //Firstly, cast our RCDmode mode to an int (enums are backed by ints anyway by default)
if(_swapModeSound.TryGetSound(out var swapModeSound))
SoundSystem.Play(Filter.Pvs(Owner), swapModeSound, Owner);
var mode = (int) _mode; //Firstly, cast our RCDmode mode to an int (enums are backed by ints anyway by default)
mode = (++mode) % _modes.Length; //Then, do a rollover on the value so it doesnt hit an invalid state
_mode = (RcdMode) mode; //Finally, cast the newly acquired int mode to an RCDmode so we can use it.
Owner.PopupMessage(eventArgs.User,
@@ -155,7 +163,8 @@ namespace Content.Server.RCD.Components
return true; //I don't know why this would happen, but sure I guess. Get out of here invalid state!
}
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Items/deconstruct.ogg", Owner);
if(_successSound.TryGetSound(out var successSound))
SoundSystem.Play(Filter.Pvs(Owner), successSound, Owner);
_ammo--;
return true;
}