Optionally deserialize AudioParams in SoundSpecifier (#8065)

This commit is contained in:
Kara
2022-05-12 16:41:33 -07:00
committed by GitHub
parent 78e9ee48ee
commit 9217cc02af
3 changed files with 11 additions and 4 deletions

View File

@@ -375,7 +375,7 @@ namespace Content.Server.Storage.EntitySystems
UpdateStorageVisualization(uid, storageComp);
if (storageComp.StorageCloseSound is not null)
SoundSystem.Play(Filter.Pvs(uid, entityManager: EntityManager), storageComp.StorageCloseSound.GetSound(), uid, AudioParams.Default);
SoundSystem.Play(Filter.Pvs(uid, entityManager: EntityManager), storageComp.StorageCloseSound.GetSound(), uid, storageComp.StorageCloseSound.Params);
}
}
@@ -584,7 +584,7 @@ namespace Content.Server.Storage.EntitySystems
return;
if (storageComp.StorageOpenSound is not null)
SoundSystem.Play(Filter.Pvs(uid, entityManager: EntityManager), storageComp.StorageOpenSound.GetSound(), uid, AudioParams.Default);
SoundSystem.Play(Filter.Pvs(uid, entityManager: EntityManager), storageComp.StorageOpenSound.GetSound(), uid, storageComp.StorageOpenSound.Params);
Logger.DebugS(storageComp.LoggerName, $"Storage (UID {uid}) \"used\" by player session (UID {player.PlayerSession.AttachedEntity}).");

View File

@@ -199,7 +199,7 @@ public abstract partial class InventorySystem
filter.RemoveWhereAttachedEntity(entity => entity == actor);
}
SoundSystem.Play(filter, item.EquipSound.GetSound(), target, AudioParams.Default.WithVolume(-2f));
SoundSystem.Play(filter, item.EquipSound.GetSound(), target, item.EquipSound.Params.WithVolume(-2f));
}
inventory.Dirty();
@@ -378,7 +378,7 @@ public abstract partial class InventorySystem
filter.RemoveWhereAttachedEntity(entity => entity == actor);
}
SoundSystem.Play(filter, item.UnequipSound.GetSound(), target, AudioParams.Default.WithVolume(-2f));
SoundSystem.Play(filter, item.UnequipSound.GetSound(), target, item.UnequipSound.Params.WithVolume(-2f));
}
inventory.Dirty();

View File

@@ -1,4 +1,6 @@
using Content.Shared.Audio;
using JetBrains.Annotations;
using Robust.Shared.Audio;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
@@ -9,6 +11,9 @@ namespace Content.Shared.Sound
[ImplicitDataDefinitionForInheritors]
public abstract class SoundSpecifier
{
[DataField("params")]
public AudioParams Params = AudioParams.Default;
public abstract string GetSound();
}
@@ -19,6 +24,7 @@ namespace Content.Shared.Sound
[DataField(Node, customTypeSerializer: typeof(ResourcePathSerializer), required: true)]
public ResourcePath? Path { get; }
[UsedImplicitly]
public SoundPathSpecifier()
{
}
@@ -46,6 +52,7 @@ namespace Content.Shared.Sound
[DataField(Node, customTypeSerializer: typeof(PrototypeIdSerializer<SoundCollectionPrototype>), required: true)]
public string? Collection { get; }
[UsedImplicitly]
public SoundCollectionSpecifier()
{
}