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

@@ -1,11 +1,13 @@
using System.Linq;
using Content.Shared.Audio;
using Content.Shared.Interaction;
using Content.Shared.Sound;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Player;
using Robust.Shared.Random;
using Robust.Shared.Serialization.Manager.Attributes;
using System.Linq;
namespace Content.Server.Storage.Components
{
@@ -19,6 +21,9 @@ namespace Content.Server.Storage.Components
public override string Name => "CursedEntityStorage";
[DataField("cursedSound")] private SoundSpecifier _cursedSound = new SoundPathSpecifier("/Audio/Effects/teleport_departure.ogg");
[DataField("cursedLockerSound")] private SoundSpecifier _cursedLockerSound = new SoundPathSpecifier("/Audio/Effects/teleport_arrival.ogg");
protected override void CloseStorage()
{
base.CloseStorage();
@@ -46,8 +51,10 @@ namespace Content.Server.Storage.Components
locker.Insert(entity);
}
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/teleport_departure.ogg", Owner, AudioHelpers.WithVariation(0.125f));
SoundSystem.Play(Filter.Pvs(lockerEnt), "/Audio/Effects/teleport_arrival.ogg", lockerEnt, AudioHelpers.WithVariation(0.125f));
if(_cursedSound.TryGetSound(out var cursedSound))
SoundSystem.Play(Filter.Pvs(Owner), cursedSound, Owner, AudioHelpers.WithVariation(0.125f));
if(_cursedLockerSound.TryGetSound(out var cursedLockerSound))
SoundSystem.Play(Filter.Pvs(lockerEnt), cursedLockerSound, lockerEnt, AudioHelpers.WithVariation(0.125f));
}
}
}

View File

@@ -14,6 +14,7 @@ using Content.Shared.Item;
using Content.Shared.Movement;
using Content.Shared.Notification.Managers;
using Content.Shared.Physics;
using Content.Shared.Sound;
using Content.Shared.Storage;
using Content.Shared.Tool;
using Content.Shared.Verbs;
@@ -76,10 +77,10 @@ namespace Content.Server.Storage.Components
private bool _isWeldedShut;
[DataField("closeSound")]
private string _closeSound = "/Audio/Machines/closetclose.ogg";
private SoundSpecifier _closeSound = new SoundPathSpecifier("/Audio/Machines/closetclose.ogg");
[DataField("openSound")]
private string _openSound = "/Audio/Machines/closetopen.ogg";
private SoundSpecifier _openSound = new SoundPathSpecifier("/Audio/Machines/closetopen.ogg");
[ViewVariables]
protected Container Contents = default!;
@@ -219,7 +220,8 @@ namespace Content.Server.Storage.Components
}
ModifyComponents();
SoundSystem.Play(Filter.Pvs(Owner), _closeSound, Owner);
if(_closeSound.TryGetSound(out var closeSound))
SoundSystem.Play(Filter.Pvs(Owner), closeSound, Owner);
_lastInternalOpenAttempt = default;
}
@@ -228,7 +230,8 @@ namespace Content.Server.Storage.Components
Open = true;
EmptyContents();
ModifyComponents();
SoundSystem.Play(Filter.Pvs(Owner), _openSound, Owner);
if(_openSound.TryGetSound(out var openSound))
SoundSystem.Play(Filter.Pvs(Owner), openSound, Owner);
}
private void UpdateAppearance()

View File

@@ -1,8 +1,8 @@
using Content.Server.Access.Components;
using Content.Shared.ActionBlocker;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Content.Shared.Storage;
using Content.Shared.Verbs;
using Robust.Server.GameObjects;
@@ -25,6 +25,9 @@ namespace Content.Server.Storage.Components
[DataField("locked")]
private bool _locked = true;
[DataField("unlockSound")] private SoundSpecifier _unlockSound = new SoundPathSpecifier("/Audio/Machines/door_lock_off.ogg");
[DataField("lockSound")] private SoundSpecifier _lockSound = new SoundPathSpecifier("/Audio/Machines/door_lock_on.ogg");
[ViewVariables(VVAccess.ReadWrite)]
public bool Locked
{
@@ -100,7 +103,8 @@ namespace Content.Server.Storage.Components
if (!CheckAccess(user)) return;
Locked = false;
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/door_lock_off.ogg", Owner, AudioParams.Default.WithVolume(-5));
if(_unlockSound.TryGetSound(out var unlockSound))
SoundSystem.Play(Filter.Pvs(Owner), unlockSound, Owner, AudioParams.Default.WithVolume(-5));
}
private void DoLock(IEntity user)
@@ -108,7 +112,8 @@ namespace Content.Server.Storage.Components
if (!CheckAccess(user)) return;
Locked = true;
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/door_lock_on.ogg", Owner, AudioParams.Default.WithVolume(-5));
if(_lockSound.TryGetSound(out var lockSound))
SoundSystem.Play(Filter.Pvs(Owner), lockSound, Owner, AudioParams.Default.WithVolume(-5));
}
private bool CheckAccess(IEntity user)

View File

@@ -15,6 +15,7 @@ using Content.Shared.Interaction.Helpers;
using Content.Shared.Item;
using Content.Shared.Notification;
using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Content.Shared.Storage;
using Robust.Server.GameObjects;
using Robust.Server.Player;
@@ -59,7 +60,7 @@ namespace Content.Server.Storage.Components
public readonly HashSet<IPlayerSession> SubscribedSessions = new();
[DataField("storageSoundCollection")]
public string? StorageSoundCollection { get; set; }
public SoundSpecifier StorageSoundCollection { get; set; } = default!;
[ViewVariables]
public override IReadOnlyList<IEntity>? StoredEntities => _storage?.ContainedEntities;
@@ -150,7 +151,7 @@ namespace Content.Server.Storage.Components
return;
}
PlaySoundCollection(StorageSoundCollection);
PlaySoundCollection();
EnsureInitialCalculated();
Logger.DebugS(LoggerName, $"Storage (UID {Owner.Uid}) had entity (UID {message.Entity.Uid}) inserted into it.");
@@ -246,7 +247,7 @@ namespace Content.Server.Storage.Components
/// <param name="entity">The entity to open the UI for</param>
public void OpenStorageUI(IEntity entity)
{
PlaySoundCollection(StorageSoundCollection);
PlaySoundCollection();
EnsureInitialCalculated();
var userSession = entity.GetComponent<ActorComponent>().PlayerSession;
@@ -546,7 +547,7 @@ namespace Content.Server.Storage.Components
// If we picked up atleast one thing, play a sound and do a cool animation!
if (successfullyInserted.Count>0)
{
PlaySoundCollection(StorageSoundCollection);
PlaySoundCollection();
SendNetworkMessage(
new AnimateInsertingEntitiesMessage(
successfullyInserted,
@@ -617,15 +618,10 @@ namespace Content.Server.Storage.Components
}
}
protected void PlaySoundCollection(string? name)
private void PlaySoundCollection()
{
if (string.IsNullOrEmpty(name))
{
return;
}
var file = AudioHelpers.GetRandomFileFromSoundCollection(name);
SoundSystem.Play(Filter.Pvs(Owner), file, Owner, AudioParams.Default);
if(StorageSoundCollection.TryGetSound(out var sound))
SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default);
}
}
}