From c8e3775ea5df62a2d1786fa322c8a258f0c35c72 Mon Sep 17 00:00:00 2001 From: Galactic Chimp Date: Sun, 27 Jun 2021 21:27:59 +0200 Subject: [PATCH 01/18] Revert "#3935 implemented suggestions from PR" This reverts commit a9b1c7b96333ca570067d6a9df1954481005892a. --- .../Sound/BaseEmitSoundComponent.cs | 6 +++-- Content.Server/Sound/EmitSoundSystem.cs | 23 ++++++++++++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Content.Server/Sound/BaseEmitSoundComponent.cs b/Content.Server/Sound/BaseEmitSoundComponent.cs index a1a4df3a56..6b0535a384 100644 --- a/Content.Server/Sound/BaseEmitSoundComponent.cs +++ b/Content.Server/Sound/BaseEmitSoundComponent.cs @@ -6,10 +6,12 @@ namespace Content.Server.Sound { /// /// Base sound emitter which defines most of the data fields. + /// Default behavior first try to play the sound collection, + /// and if one isn't assigned, then it will try to play the single sound. /// public abstract class BaseEmitSoundComponent : Component { - [ViewVariables(VVAccess.ReadWrite)] [DataField("variation")] public float PitchVariation { get; set; } = 0.0f; - [ViewVariables(VVAccess.ReadWrite)] [DataField("soundCollection", required: true)] public string SoundCollectionName { get; set; } = default!; + [ViewVariables(VVAccess.ReadWrite)] [DataField("variation")] public float PitchVariation { get; set; } + [ViewVariables(VVAccess.ReadWrite)] [DataField("soundCollection")] public string? SoundCollectionName { get; set; } } } diff --git a/Content.Server/Sound/EmitSoundSystem.cs b/Content.Server/Sound/EmitSoundSystem.cs index 3459522a3e..b10bbe74da 100644 --- a/Content.Server/Sound/EmitSoundSystem.cs +++ b/Content.Server/Sound/EmitSoundSystem.cs @@ -1,3 +1,4 @@ +#nullable enable using Content.Shared.Audio; using Content.Shared.Interaction; using Content.Shared.Throwing; @@ -10,6 +11,7 @@ using Robust.Shared.IoC; using Robust.Shared.Prototypes; using Robust.Shared.Player; using Robust.Shared.Random; +using Robust.Shared.Log; namespace Content.Server.Sound { @@ -31,7 +33,14 @@ namespace Content.Server.Sound private void PlaySound(BaseEmitSoundComponent component) { - PlayRandomSoundFromCollection(component); + if (!string.IsNullOrWhiteSpace(component.SoundCollectionName)) + { + PlayRandomSoundFromCollection(component); + } + else + { + Logger.Warning($"{nameof(component)}: {component.Owner} has no {nameof(component.SoundCollectionName)} to play."); + } } private void PlayRandomSoundFromCollection(BaseEmitSoundComponent component) @@ -48,8 +57,16 @@ namespace Content.Server.Sound private static void PlaySingleSound(string soundName, BaseEmitSoundComponent component) { - SoundSystem.Play(Filter.Pvs(component.Owner), soundName, component.Owner, - AudioHelpers.WithVariation(component.PitchVariation).WithVolume(-2f)); + if (component.PitchVariation > 0.0) + { + SoundSystem.Play(Filter.Pvs(component.Owner), soundName, component.Owner, + AudioHelpers.WithVariation(component.PitchVariation).WithVolume(-2f)); + } + else + { + SoundSystem.Play(Filter.Pvs(component.Owner), soundName, component.Owner, + AudioParams.Default.WithVolume(-2f)); + } } } } From a0889a915129a598d9dad491cfd90a44939a3cc0 Mon Sep 17 00:00:00 2001 From: Galactic Chimp Date: Sun, 27 Jun 2021 21:30:28 +0200 Subject: [PATCH 02/18] #4219 revert of single sound removal in EmitSoundSystem --- .../Components/EmitSoundOnUseComponent.cs | 1 + .../Sound/BaseEmitSoundComponent.cs | 5 ++-- .../Sound/EmitSoundOnActivateComponent.cs | 1 + .../Sound/EmitSoundOnLandComponent.cs | 1 + Content.Server/Sound/EmitSoundSystem.cs | 29 ++++++++++++++----- .../Throwing/EmitSoundOnThrowComponent.cs | 1 + 6 files changed, 28 insertions(+), 10 deletions(-) diff --git a/Content.Server/Interaction/Components/EmitSoundOnUseComponent.cs b/Content.Server/Interaction/Components/EmitSoundOnUseComponent.cs index c4f2070b78..f2fb39ddab 100644 --- a/Content.Server/Interaction/Components/EmitSoundOnUseComponent.cs +++ b/Content.Server/Interaction/Components/EmitSoundOnUseComponent.cs @@ -10,6 +10,7 @@ namespace Content.Server.Interaction.Components public class EmitSoundOnUseComponent : BaseEmitSoundComponent { /// + /// public override string Name => "EmitSoundOnUse"; } } diff --git a/Content.Server/Sound/BaseEmitSoundComponent.cs b/Content.Server/Sound/BaseEmitSoundComponent.cs index 6b0535a384..be5838efa6 100644 --- a/Content.Server/Sound/BaseEmitSoundComponent.cs +++ b/Content.Server/Sound/BaseEmitSoundComponent.cs @@ -11,7 +11,8 @@ namespace Content.Server.Sound /// public abstract class BaseEmitSoundComponent : Component { - [ViewVariables(VVAccess.ReadWrite)] [DataField("variation")] public float PitchVariation { get; set; } - [ViewVariables(VVAccess.ReadWrite)] [DataField("soundCollection")] public string? SoundCollectionName { get; set; } + [ViewVariables(VVAccess.ReadWrite)] [DataField("sound")] public string? _soundName; + [ViewVariables(VVAccess.ReadWrite)] [DataField("variation")] public float _pitchVariation; + [ViewVariables(VVAccess.ReadWrite)] [DataField("soundCollection")] public string? _soundCollectionName; } } diff --git a/Content.Server/Sound/EmitSoundOnActivateComponent.cs b/Content.Server/Sound/EmitSoundOnActivateComponent.cs index fdbb9f7aed..de7e1dff2a 100644 --- a/Content.Server/Sound/EmitSoundOnActivateComponent.cs +++ b/Content.Server/Sound/EmitSoundOnActivateComponent.cs @@ -9,6 +9,7 @@ namespace Content.Server.Sound public class EmitSoundOnActivateComponent : BaseEmitSoundComponent { /// + /// public override string Name => "EmitSoundOnActivate"; } } diff --git a/Content.Server/Sound/EmitSoundOnLandComponent.cs b/Content.Server/Sound/EmitSoundOnLandComponent.cs index 1d6286abdd..4d93640b87 100644 --- a/Content.Server/Sound/EmitSoundOnLandComponent.cs +++ b/Content.Server/Sound/EmitSoundOnLandComponent.cs @@ -9,6 +9,7 @@ namespace Content.Server.Sound public class EmitSoundOnLandComponent : BaseEmitSoundComponent { /// + /// public override string Name => "EmitSoundOnLand"; } } diff --git a/Content.Server/Sound/EmitSoundSystem.cs b/Content.Server/Sound/EmitSoundSystem.cs index b10bbe74da..22930bf5f5 100644 --- a/Content.Server/Sound/EmitSoundSystem.cs +++ b/Content.Server/Sound/EmitSoundSystem.cs @@ -1,8 +1,8 @@ -#nullable enable using Content.Shared.Audio; using Content.Shared.Interaction; using Content.Shared.Throwing; using Content.Server.Interaction.Components; +using Content.Server.Sound; using Content.Server.Throwing; using JetBrains.Annotations; using Robust.Shared.Audio; @@ -13,7 +13,8 @@ using Robust.Shared.Player; using Robust.Shared.Random; using Robust.Shared.Log; -namespace Content.Server.Sound + +namespace Content.Server.GameObjects.EntitySystems { [UsedImplicitly] public class EmitSoundSystem : EntitySystem @@ -33,20 +34,27 @@ namespace Content.Server.Sound private void PlaySound(BaseEmitSoundComponent component) { - if (!string.IsNullOrWhiteSpace(component.SoundCollectionName)) + if (!string.IsNullOrWhiteSpace(component._soundCollectionName)) { PlayRandomSoundFromCollection(component); } + else if(!string.IsNullOrWhiteSpace(component._soundName)) + { + PlaySingleSound(component._soundName, component); + } else { - Logger.Warning($"{nameof(component)}: {component.Owner} has no {nameof(component.SoundCollectionName)} to play."); + Logger.Warning($"{nameof(component)} Uid:{component.Owner.Uid} has neither {nameof(component._soundCollectionName)} nor {nameof(component._soundName)} to play."); } } private void PlayRandomSoundFromCollection(BaseEmitSoundComponent component) { - var file = SelectRandomSoundFromSoundCollection(component.SoundCollectionName!); - PlaySingleSound(file, component); + if (!string.IsNullOrWhiteSpace(component._soundCollectionName)) + { + var file = SelectRandomSoundFromSoundCollection(component._soundCollectionName); + PlaySingleSound(file, component); + } } private string SelectRandomSoundFromSoundCollection(string soundCollectionName) @@ -57,10 +65,15 @@ namespace Content.Server.Sound private static void PlaySingleSound(string soundName, BaseEmitSoundComponent component) { - if (component.PitchVariation > 0.0) + if (string.IsNullOrWhiteSpace(soundName)) + { + return; + } + + if (component._pitchVariation > 0.0) { SoundSystem.Play(Filter.Pvs(component.Owner), soundName, component.Owner, - AudioHelpers.WithVariation(component.PitchVariation).WithVolume(-2f)); + AudioHelpers.WithVariation(component._pitchVariation).WithVolume(-2f)); } else { diff --git a/Content.Server/Throwing/EmitSoundOnThrowComponent.cs b/Content.Server/Throwing/EmitSoundOnThrowComponent.cs index d56af69811..cb23ac001a 100644 --- a/Content.Server/Throwing/EmitSoundOnThrowComponent.cs +++ b/Content.Server/Throwing/EmitSoundOnThrowComponent.cs @@ -10,6 +10,7 @@ namespace Content.Server.Throwing public class EmitSoundOnThrowComponent : BaseEmitSoundComponent { /// + /// public override string Name => "EmitSoundOnThrow"; } } From 4a2b9832ce6403fb1b6d158c3b54b80dfacfd402 Mon Sep 17 00:00:00 2001 From: Galactic Chimp Date: Sun, 27 Jun 2021 21:48:57 +0200 Subject: [PATCH 03/18] #4219 single sounds in EmitSoundSystem should work now --- .../Components/EmitSoundOnUseComponent.cs | 1 - .../Sound/BaseEmitSoundComponent.cs | 10 +++--- .../Sound/EmitSoundOnActivateComponent.cs | 1 - .../Sound/EmitSoundOnLandComponent.cs | 1 - Content.Server/Sound/EmitSoundSystem.cs | 36 +++++-------------- .../Throwing/EmitSoundOnThrowComponent.cs | 1 - 6 files changed, 14 insertions(+), 36 deletions(-) diff --git a/Content.Server/Interaction/Components/EmitSoundOnUseComponent.cs b/Content.Server/Interaction/Components/EmitSoundOnUseComponent.cs index f2fb39ddab..c4f2070b78 100644 --- a/Content.Server/Interaction/Components/EmitSoundOnUseComponent.cs +++ b/Content.Server/Interaction/Components/EmitSoundOnUseComponent.cs @@ -10,7 +10,6 @@ namespace Content.Server.Interaction.Components public class EmitSoundOnUseComponent : BaseEmitSoundComponent { /// - /// public override string Name => "EmitSoundOnUse"; } } diff --git a/Content.Server/Sound/BaseEmitSoundComponent.cs b/Content.Server/Sound/BaseEmitSoundComponent.cs index be5838efa6..3e2aa8f976 100644 --- a/Content.Server/Sound/BaseEmitSoundComponent.cs +++ b/Content.Server/Sound/BaseEmitSoundComponent.cs @@ -6,13 +6,13 @@ namespace Content.Server.Sound { /// /// Base sound emitter which defines most of the data fields. - /// Default behavior first try to play the sound collection, - /// and if one isn't assigned, then it will try to play the single sound. + /// Default behavior is to first try to play the sound collection, + /// and if one isn't assigned, then try to play the single sound. /// public abstract class BaseEmitSoundComponent : Component { - [ViewVariables(VVAccess.ReadWrite)] [DataField("sound")] public string? _soundName; - [ViewVariables(VVAccess.ReadWrite)] [DataField("variation")] public float _pitchVariation; - [ViewVariables(VVAccess.ReadWrite)] [DataField("soundCollection")] public string? _soundCollectionName; + [ViewVariables(VVAccess.ReadWrite)] [DataField("sound")] public string? SoundName { get; set; } = default!; + [ViewVariables(VVAccess.ReadWrite)] [DataField("variation")] public float PitchVariation { get; set; } = 0.0f; + [ViewVariables(VVAccess.ReadWrite)] [DataField("soundCollection")] public string? SoundCollectionName { get; set; } = default!; } } diff --git a/Content.Server/Sound/EmitSoundOnActivateComponent.cs b/Content.Server/Sound/EmitSoundOnActivateComponent.cs index de7e1dff2a..fdbb9f7aed 100644 --- a/Content.Server/Sound/EmitSoundOnActivateComponent.cs +++ b/Content.Server/Sound/EmitSoundOnActivateComponent.cs @@ -9,7 +9,6 @@ namespace Content.Server.Sound public class EmitSoundOnActivateComponent : BaseEmitSoundComponent { /// - /// public override string Name => "EmitSoundOnActivate"; } } diff --git a/Content.Server/Sound/EmitSoundOnLandComponent.cs b/Content.Server/Sound/EmitSoundOnLandComponent.cs index 4d93640b87..1d6286abdd 100644 --- a/Content.Server/Sound/EmitSoundOnLandComponent.cs +++ b/Content.Server/Sound/EmitSoundOnLandComponent.cs @@ -9,7 +9,6 @@ namespace Content.Server.Sound public class EmitSoundOnLandComponent : BaseEmitSoundComponent { /// - /// public override string Name => "EmitSoundOnLand"; } } diff --git a/Content.Server/Sound/EmitSoundSystem.cs b/Content.Server/Sound/EmitSoundSystem.cs index 22930bf5f5..ad653c780a 100644 --- a/Content.Server/Sound/EmitSoundSystem.cs +++ b/Content.Server/Sound/EmitSoundSystem.cs @@ -2,7 +2,6 @@ using Content.Shared.Audio; using Content.Shared.Interaction; using Content.Shared.Throwing; using Content.Server.Interaction.Components; -using Content.Server.Sound; using Content.Server.Throwing; using JetBrains.Annotations; using Robust.Shared.Audio; @@ -13,8 +12,7 @@ using Robust.Shared.Player; using Robust.Shared.Random; using Robust.Shared.Log; - -namespace Content.Server.GameObjects.EntitySystems +namespace Content.Server.Sound { [UsedImplicitly] public class EmitSoundSystem : EntitySystem @@ -34,27 +32,24 @@ namespace Content.Server.GameObjects.EntitySystems private void PlaySound(BaseEmitSoundComponent component) { - if (!string.IsNullOrWhiteSpace(component._soundCollectionName)) + if (!string.IsNullOrWhiteSpace(component.SoundCollectionName)) { PlayRandomSoundFromCollection(component); } - else if(!string.IsNullOrWhiteSpace(component._soundName)) + else if (!string.IsNullOrWhiteSpace(component.SoundName)) { - PlaySingleSound(component._soundName, component); + PlaySingleSound(component.SoundName, component); } else { - Logger.Warning($"{nameof(component)} Uid:{component.Owner.Uid} has neither {nameof(component._soundCollectionName)} nor {nameof(component._soundName)} to play."); + Logger.Warning($"{nameof(component)} Uid:{component.Owner.Uid} has neither {nameof(component.SoundCollectionName)} nor {nameof(component.SoundName)} to play."); } } private void PlayRandomSoundFromCollection(BaseEmitSoundComponent component) { - if (!string.IsNullOrWhiteSpace(component._soundCollectionName)) - { - var file = SelectRandomSoundFromSoundCollection(component._soundCollectionName); - PlaySingleSound(file, component); - } + var file = SelectRandomSoundFromSoundCollection(component.SoundCollectionName!); + PlaySingleSound(file, component); } private string SelectRandomSoundFromSoundCollection(string soundCollectionName) @@ -65,21 +60,8 @@ namespace Content.Server.GameObjects.EntitySystems private static void PlaySingleSound(string soundName, BaseEmitSoundComponent component) { - if (string.IsNullOrWhiteSpace(soundName)) - { - return; - } - - if (component._pitchVariation > 0.0) - { - SoundSystem.Play(Filter.Pvs(component.Owner), soundName, component.Owner, - AudioHelpers.WithVariation(component._pitchVariation).WithVolume(-2f)); - } - else - { - SoundSystem.Play(Filter.Pvs(component.Owner), soundName, component.Owner, - AudioParams.Default.WithVolume(-2f)); - } + SoundSystem.Play(Filter.Pvs(component.Owner), soundName, component.Owner, + AudioHelpers.WithVariation(component.PitchVariation).WithVolume(-2f)); } } } diff --git a/Content.Server/Throwing/EmitSoundOnThrowComponent.cs b/Content.Server/Throwing/EmitSoundOnThrowComponent.cs index cb23ac001a..d56af69811 100644 --- a/Content.Server/Throwing/EmitSoundOnThrowComponent.cs +++ b/Content.Server/Throwing/EmitSoundOnThrowComponent.cs @@ -10,7 +10,6 @@ namespace Content.Server.Throwing public class EmitSoundOnThrowComponent : BaseEmitSoundComponent { /// - /// public override string Name => "EmitSoundOnThrow"; } } From 6cae00bb13c2b6f8c88ff224dc17ca8ff074d56e Mon Sep 17 00:00:00 2001 From: Galactic Chimp Date: Sun, 27 Jun 2021 21:55:18 +0200 Subject: [PATCH 04/18] #4219 some small project tweaks --- .../Components/EmitSoundOnUseComponent.cs | 2 +- .../Components/ExpendableLightComponent.cs | 2 +- .../BaseEmitSoundComponent.cs | 2 +- .../EmitSoundOnActivateComponent.cs | 2 +- .../EmitSoundOnLandComponent.cs | 2 +- .../LoopingLoopingSoundComponent.cs | 2 +- Content.Server/Sound/EmitSoundSystem.cs | 1 + .../Throwing/EmitSoundOnThrowComponent.cs | 2 +- Content.Server/Toys/ToysComponent.cs | 59 ------------------- 9 files changed, 8 insertions(+), 66 deletions(-) rename Content.Server/Sound/{ => Components}/BaseEmitSoundComponent.cs (95%) rename Content.Server/Sound/{ => Components}/EmitSoundOnActivateComponent.cs (88%) rename Content.Server/Sound/{ => Components}/EmitSoundOnLandComponent.cs (88%) rename Content.Server/Sound/{ => Components}/LoopingLoopingSoundComponent.cs (98%) delete mode 100644 Content.Server/Toys/ToysComponent.cs diff --git a/Content.Server/Interaction/Components/EmitSoundOnUseComponent.cs b/Content.Server/Interaction/Components/EmitSoundOnUseComponent.cs index c4f2070b78..a90eef8d76 100644 --- a/Content.Server/Interaction/Components/EmitSoundOnUseComponent.cs +++ b/Content.Server/Interaction/Components/EmitSoundOnUseComponent.cs @@ -1,4 +1,4 @@ -using Content.Server.Sound; +using Content.Server.Sound.Components; using Robust.Shared.GameObjects; namespace Content.Server.Interaction.Components diff --git a/Content.Server/Light/Components/ExpendableLightComponent.cs b/Content.Server/Light/Components/ExpendableLightComponent.cs index 0e8be41061..1f1c4a9df5 100644 --- a/Content.Server/Light/Components/ExpendableLightComponent.cs +++ b/Content.Server/Light/Components/ExpendableLightComponent.cs @@ -1,6 +1,6 @@ using Content.Server.Clothing.Components; using Content.Server.Items; -using Content.Server.Sound; +using Content.Server.Sound.Components; using Content.Shared.ActionBlocker; using Content.Shared.Interaction; using Content.Shared.Interaction.Events; diff --git a/Content.Server/Sound/BaseEmitSoundComponent.cs b/Content.Server/Sound/Components/BaseEmitSoundComponent.cs similarity index 95% rename from Content.Server/Sound/BaseEmitSoundComponent.cs rename to Content.Server/Sound/Components/BaseEmitSoundComponent.cs index 3e2aa8f976..dc68cca91f 100644 --- a/Content.Server/Sound/BaseEmitSoundComponent.cs +++ b/Content.Server/Sound/Components/BaseEmitSoundComponent.cs @@ -2,7 +2,7 @@ using Robust.Shared.GameObjects; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; -namespace Content.Server.Sound +namespace Content.Server.Sound.Components { /// /// Base sound emitter which defines most of the data fields. diff --git a/Content.Server/Sound/EmitSoundOnActivateComponent.cs b/Content.Server/Sound/Components/EmitSoundOnActivateComponent.cs similarity index 88% rename from Content.Server/Sound/EmitSoundOnActivateComponent.cs rename to Content.Server/Sound/Components/EmitSoundOnActivateComponent.cs index fdbb9f7aed..2cbc83516a 100644 --- a/Content.Server/Sound/EmitSoundOnActivateComponent.cs +++ b/Content.Server/Sound/Components/EmitSoundOnActivateComponent.cs @@ -1,6 +1,6 @@ using Robust.Shared.GameObjects; -namespace Content.Server.Sound +namespace Content.Server.Sound.Components { /// /// Simple sound emitter that emits sound on ActivateInWorld diff --git a/Content.Server/Sound/EmitSoundOnLandComponent.cs b/Content.Server/Sound/Components/EmitSoundOnLandComponent.cs similarity index 88% rename from Content.Server/Sound/EmitSoundOnLandComponent.cs rename to Content.Server/Sound/Components/EmitSoundOnLandComponent.cs index 1d6286abdd..96782fe985 100644 --- a/Content.Server/Sound/EmitSoundOnLandComponent.cs +++ b/Content.Server/Sound/Components/EmitSoundOnLandComponent.cs @@ -1,6 +1,6 @@ using Robust.Shared.GameObjects; -namespace Content.Server.Sound +namespace Content.Server.Sound.Components { /// /// Simple sound emitter that emits sound on LandEvent diff --git a/Content.Server/Sound/LoopingLoopingSoundComponent.cs b/Content.Server/Sound/Components/LoopingLoopingSoundComponent.cs similarity index 98% rename from Content.Server/Sound/LoopingLoopingSoundComponent.cs rename to Content.Server/Sound/Components/LoopingLoopingSoundComponent.cs index 38796fe874..4230e39d8e 100644 --- a/Content.Server/Sound/LoopingLoopingSoundComponent.cs +++ b/Content.Server/Sound/Components/LoopingLoopingSoundComponent.cs @@ -3,7 +3,7 @@ using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.Network; -namespace Content.Server.Sound +namespace Content.Server.Sound.Components { [RegisterComponent] public class LoopingLoopingSoundComponent : SharedLoopingSoundComponent diff --git a/Content.Server/Sound/EmitSoundSystem.cs b/Content.Server/Sound/EmitSoundSystem.cs index ad653c780a..0e777cf5a5 100644 --- a/Content.Server/Sound/EmitSoundSystem.cs +++ b/Content.Server/Sound/EmitSoundSystem.cs @@ -2,6 +2,7 @@ using Content.Shared.Audio; using Content.Shared.Interaction; using Content.Shared.Throwing; using Content.Server.Interaction.Components; +using Content.Server.Sound.Components; using Content.Server.Throwing; using JetBrains.Annotations; using Robust.Shared.Audio; diff --git a/Content.Server/Throwing/EmitSoundOnThrowComponent.cs b/Content.Server/Throwing/EmitSoundOnThrowComponent.cs index d56af69811..d0b75d8d2b 100644 --- a/Content.Server/Throwing/EmitSoundOnThrowComponent.cs +++ b/Content.Server/Throwing/EmitSoundOnThrowComponent.cs @@ -1,4 +1,4 @@ -using Content.Server.Sound; +using Content.Server.Sound.Components; using Robust.Shared.GameObjects; namespace Content.Server.Throwing diff --git a/Content.Server/Toys/ToysComponent.cs b/Content.Server/Toys/ToysComponent.cs deleted file mode 100644 index e8deeee074..0000000000 --- a/Content.Server/Toys/ToysComponent.cs +++ /dev/null @@ -1,59 +0,0 @@ -using Content.Shared.Audio; -using Content.Shared.Interaction; -using Content.Shared.Throwing; -using Robust.Shared.Audio; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using Robust.Shared.Player; -using Robust.Shared.Prototypes; -using Robust.Shared.Random; -using Robust.Shared.Serialization.Manager.Attributes; -using Robust.Shared.ViewVariables; - -namespace Content.Server.Toys -{ - [RegisterComponent] - public class ToysComponent : Component, IActivate, IUse, ILand - { - [Dependency] private readonly IPrototypeManager _prototypeManager = default!; - [Dependency] private readonly IRobustRandom _random = default!; - - public override string Name => "Toys"; - - [ViewVariables] - [DataField("toySqueak")] - public string _soundCollectionName = "ToySqueak"; - - public void Squeak() - { - PlaySqueakEffect(); - } - - public void PlaySqueakEffect() - { - if (!string.IsNullOrWhiteSpace(_soundCollectionName)) - { - var soundCollection = _prototypeManager.Index(_soundCollectionName); - var file = _random.Pick(soundCollection.PickFiles); - SoundSystem.Play(Filter.Pvs(Owner), file, Owner, AudioParams.Default); - } - } - - void IActivate.Activate(ActivateEventArgs eventArgs) - { - Squeak(); - } - - bool IUse.UseEntity(UseEntityEventArgs eventArgs) - { - Squeak(); - return false; - } - - void ILand.Land(LandEventArgs eventArgs) - { - Squeak(); - } - } -} - From 4500b66f28f6de43dcfa9309d164d1ba4b0ebd20 Mon Sep 17 00:00:00 2001 From: Galactic Chimp Date: Sat, 10 Jul 2021 11:20:23 +0200 Subject: [PATCH 05/18] #4219 upgraded EmitSoundSystem to use SoundSpecifier --- .../Components/BaseEmitSoundComponent.cs | 14 +++-- Content.Server/Sound/EmitSoundSystem.cs | 56 +++++++------------ .../Entities/Objects/Fun/bike_horn.yml | 3 +- .../Prototypes/Entities/Objects/Fun/skub.yml | 3 +- .../Prototypes/Entities/Objects/Fun/toys.yml | 51 +++++++++++------ 5 files changed, 66 insertions(+), 61 deletions(-) diff --git a/Content.Server/Sound/Components/BaseEmitSoundComponent.cs b/Content.Server/Sound/Components/BaseEmitSoundComponent.cs index dc68cca91f..6b9ee8ff75 100644 --- a/Content.Server/Sound/Components/BaseEmitSoundComponent.cs +++ b/Content.Server/Sound/Components/BaseEmitSoundComponent.cs @@ -1,3 +1,4 @@ +using Content.Shared.Sound; using Robust.Shared.GameObjects; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; @@ -6,13 +7,16 @@ namespace Content.Server.Sound.Components { /// /// Base sound emitter which defines most of the data fields. - /// Default behavior is to first try to play the sound collection, - /// and if one isn't assigned, then try to play the single sound. + /// Accepts both single sounds and sound collections. /// public abstract class BaseEmitSoundComponent : Component { - [ViewVariables(VVAccess.ReadWrite)] [DataField("sound")] public string? SoundName { get; set; } = default!; - [ViewVariables(VVAccess.ReadWrite)] [DataField("variation")] public float PitchVariation { get; set; } = 0.0f; - [ViewVariables(VVAccess.ReadWrite)] [DataField("soundCollection")] public string? SoundCollectionName { get; set; } = default!; + [ViewVariables(VVAccess.ReadWrite)] + [DataField("sound")] + public SoundSpecifier Sound { get; set; } = default!; + + [ViewVariables(VVAccess.ReadWrite)] + [DataField("variation")] + public float PitchVariation { get; set; } = 0.0f; } } diff --git a/Content.Server/Sound/EmitSoundSystem.cs b/Content.Server/Sound/EmitSoundSystem.cs index 0e777cf5a5..af8efc8213 100644 --- a/Content.Server/Sound/EmitSoundSystem.cs +++ b/Content.Server/Sound/EmitSoundSystem.cs @@ -1,68 +1,50 @@ -using Content.Shared.Audio; -using Content.Shared.Interaction; -using Content.Shared.Throwing; using Content.Server.Interaction.Components; using Content.Server.Sound.Components; using Content.Server.Throwing; +using Content.Shared.Audio; +using Content.Shared.Interaction; +using Content.Shared.Throwing; using JetBrains.Annotations; using Robust.Shared.Audio; using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using Robust.Shared.Prototypes; -using Robust.Shared.Player; -using Robust.Shared.Random; using Robust.Shared.Log; +using Robust.Shared.Player; namespace Content.Server.Sound { + /// + /// Will play a sound on various events if the affected entity has a component derived from BaseEmitSoundComponent + /// [UsedImplicitly] public class EmitSoundSystem : EntitySystem { - [Dependency] private readonly IPrototypeManager _prototypeManager = default!; - [Dependency] private readonly IRobustRandom _random = default!; - /// public override void Initialize() { base.Initialize(); - SubscribeLocalEvent((eUI, comp, arg) => PlaySound(comp)); - SubscribeLocalEvent((eUI, comp, arg) => PlaySound(comp)); - SubscribeLocalEvent((eUI, comp, arg) => PlaySound(comp)); - SubscribeLocalEvent((eUI, comp, args) => PlaySound(comp)); + SubscribeLocalEvent((eUI, comp, arg) => HandleEmitSoundOn(comp)); + SubscribeLocalEvent((eUI, comp, arg) => HandleEmitSoundOn(comp)); + SubscribeLocalEvent((eUI, comp, arg) => HandleEmitSoundOn(comp)); + SubscribeLocalEvent((eUI, comp, args) => HandleEmitSoundOn(comp)); } - private void PlaySound(BaseEmitSoundComponent component) + private void HandleEmitSoundOn(BaseEmitSoundComponent component) { - if (!string.IsNullOrWhiteSpace(component.SoundCollectionName)) - { - PlayRandomSoundFromCollection(component); - } - else if (!string.IsNullOrWhiteSpace(component.SoundName)) - { - PlaySingleSound(component.SoundName, component); + var soundName = component.Sound.GetSound(); + + if (!string.IsNullOrWhiteSpace(soundName)) + { + PlaySingleSound(soundName, component); } else { - Logger.Warning($"{nameof(component)} Uid:{component.Owner.Uid} has neither {nameof(component.SoundCollectionName)} nor {nameof(component.SoundName)} to play."); + Logger.Warning($"{nameof(component)} Uid:{component.Owner.Uid} has no {nameof(component.Sound)} to play."); } } - private void PlayRandomSoundFromCollection(BaseEmitSoundComponent component) - { - var file = SelectRandomSoundFromSoundCollection(component.SoundCollectionName!); - PlaySingleSound(file, component); - } - - private string SelectRandomSoundFromSoundCollection(string soundCollectionName) - { - var soundCollection = _prototypeManager.Index(soundCollectionName); - return _random.Pick(soundCollection.PickFiles); - } - private static void PlaySingleSound(string soundName, BaseEmitSoundComponent component) { - SoundSystem.Play(Filter.Pvs(component.Owner), soundName, component.Owner, - AudioHelpers.WithVariation(component.PitchVariation).WithVolume(-2f)); + SoundSystem.Play(Filter.Pvs(component.Owner), soundName, component.Owner, AudioHelpers.WithVariation(component.PitchVariation).WithVolume(-2f)); } } } diff --git a/Resources/Prototypes/Entities/Objects/Fun/bike_horn.yml b/Resources/Prototypes/Entities/Objects/Fun/bike_horn.yml index 29b4d5647e..8e7c24eb47 100644 --- a/Resources/Prototypes/Entities/Objects/Fun/bike_horn.yml +++ b/Resources/Prototypes/Entities/Objects/Fun/bike_horn.yml @@ -14,7 +14,8 @@ QuickEquip: false - type: ItemCooldown - type: EmitSoundOnUse - sound: /Audio/Items/bikehorn.ogg + sound: + path: /Audio/Items/bikehorn.ogg semitoneVariation: 6 - type: UseDelay delay: 0.5 diff --git a/Resources/Prototypes/Entities/Objects/Fun/skub.yml b/Resources/Prototypes/Entities/Objects/Fun/skub.yml index d885ac09a7..e4695f5062 100644 --- a/Resources/Prototypes/Entities/Objects/Fun/skub.yml +++ b/Resources/Prototypes/Entities/Objects/Fun/skub.yml @@ -12,6 +12,7 @@ - type: ItemCooldown - type: LoopingSound - type: EmitSoundOnUse - sound: /Audio/Items/skub.ogg + sound: + path: /Audio/Items/skub.ogg - type: UseDelay delay: 2.0 diff --git a/Resources/Prototypes/Entities/Objects/Fun/toys.yml b/Resources/Prototypes/Entities/Objects/Fun/toys.yml index 442133249c..0d8babe815 100644 --- a/Resources/Prototypes/Entities/Objects/Fun/toys.yml +++ b/Resources/Prototypes/Entities/Objects/Fun/toys.yml @@ -5,11 +5,14 @@ id: BasePlushie components: - type: EmitSoundOnUse - soundCollection: ToySqueak + sound: + collection: ToySqueak - type: EmitSoundOnLand - soundCollection: ToySqueak + sound: + collection: ToySqueak - type: EmitSoundOnActivate - soundCollection: ToySqueak + sound: + collection: ToySqueak - type: LoopingSound - type: ItemCooldown - type: UseDelay @@ -90,7 +93,8 @@ - type: ItemCooldown - type: LoopingSound - type: EmitSoundOnUse - sound: /Audio/Items/Toys/rattle.ogg + sound: + path: /Audio/Items/Toys/rattle.ogg - type: UseDelay delay: 1.0 @@ -106,7 +110,8 @@ - type: ItemCooldown - type: LoopingSound - type: EmitSoundOnUse - sound: /Audio/Items/Toys/mousesqueek.ogg + sound: + path: /Audio/Items/Toys/mousesqueek.ogg - type: UseDelay delay: 1.0 @@ -122,7 +127,8 @@ - type: ItemCooldown - type: LoopingSound - type: EmitSoundOnUse - sound: /Audio/Voice/Vox/shriek1.ogg + sound: + path: /Audio/Voice/Vox/shriek1.ogg - type: UseDelay delay: 1.0 @@ -142,11 +148,13 @@ - type: Item sprite: Objects/Misc/carvings.rsi - type: EmitSoundOnThrow - sound: /Audio/Items/Toys/helpme.ogg + sound: + path: /Audio/Items/Toys/helpme.ogg - type: ItemCooldown - type: LoopingSound - type: EmitSoundOnUse - sound: /Audio/Items/Toys/helpme.ogg + sound: + path: /Audio/Items/Toys/helpme.ogg - type: UseDelay delay: 1.0 @@ -162,11 +170,13 @@ - type: Item sprite: Objects/Misc/carvings.rsi - type: EmitSoundOnThrow - sound: /Audio/Items/Toys/hellothere.ogg + sound: + path: /Audio/Items/Toys/hellothere.ogg - type: ItemCooldown - type: LoopingSound - type: EmitSoundOnUse - sound: /Audio/Items/Toys/hellothere.ogg + sound: + path: /Audio/Items/Toys/hellothere.ogg - type: UseDelay delay: 1.0 @@ -182,11 +192,13 @@ - type: Item sprite: Objects/Misc/carvings.rsi - type: EmitSoundOnThrow - sound: /Audio/Items/Toys/thankyou.ogg + sound: + path: /Audio/Items/Toys/thankyou.ogg - type: ItemCooldown - type: LoopingSound - type: EmitSoundOnUse - sound: /Audio/Items/Toys/thankyou.ogg + sound: + path: /Audio/Items/Toys/thankyou.ogg - type: UseDelay delay: 1.0 @@ -202,11 +214,13 @@ - type: Item sprite: Objects/Misc/carvings.rsi - type: EmitSoundOnThrow - sound: /Audio/Items/Toys/verygood.ogg + sound: + path: /Audio/Items/Toys/verygood.ogg - type: ItemCooldown - type: LoopingSound - type: EmitSoundOnUse - sound: /Audio/Items/Toys/verygood.ogg + sound: + path: /Audio/Items/Toys/verygood.ogg - type: UseDelay delay: 1.0 @@ -222,11 +236,13 @@ - type: Item sprite: Objects/Misc/carvings.rsi - type: EmitSoundOnThrow - sound: /Audio/Items/Toys/imsorry.ogg + sound: + path: /Audio/Items/Toys/imsorry.ogg - type: ItemCooldown - type: LoopingSound - type: EmitSoundOnUse - sound: /Audio/Items/Toys/imsorry.ogg + sound: + path: /Audio/Items/Toys/imsorry.ogg - type: UseDelay delay: 1.0 @@ -297,7 +313,8 @@ - type: ItemCooldown - type: LoopingSound - type: EmitSoundOnUse - sound: /Audio/Items/Toys/ian.ogg + sound: + path: /Audio/Items/Toys/ian.ogg - type: UseDelay delay: 1.0 From ce3c59e0e63bda15788f08a9a8f4274ae5ae4a04 Mon Sep 17 00:00:00 2001 From: Galactic Chimp Date: Sat, 10 Jul 2021 17:35:33 +0200 Subject: [PATCH 06/18] replacing sound (collection) names with SoundSpecifier - part 1 --- Content.Client/PDA/PDAComponent.cs | 21 +++++++-- .../DestructibleThresholdActivationTest.cs | 8 ++-- .../AME/Components/AMEControllerComponent.cs | 10 +++- .../AME/Components/AMEPartComponent.cs | 8 ++-- .../Actions/Actions/DisarmAction.cs | 24 +++++++--- .../Actions/Actions/ScreamAction.cs | 27 +++++------ .../Actions/Spells/GiveItemSpell.cs | 7 +-- .../Components/SpaceVillainArcadeComponent.cs | 36 ++++++++++---- .../Atmos/Components/GasTankComponent.cs | 7 ++- Content.Server/Body/BodyComponent.cs | 8 +++- .../Botany/Components/PlantHolderComponent.cs | 4 +- .../Buckle/Components/BuckleComponent.cs | 12 +++-- .../Buckle/Components/StrapComponent.cs | 5 +- .../Cabinet/ItemCabinetComponent.cs | 5 +- Content.Server/Cabinet/ItemCabinetSystem.cs | 8 ++-- .../Cargo/Components/CargoConsoleComponent.cs | 17 +++++-- .../Cargo/Components/CargoTelepadComponent.cs | 6 ++- .../Components/ChemMasterComponent.cs | 7 ++- .../Components/HyposprayComponent.cs | 7 ++- .../Chemistry/Components/PillComponent.cs | 7 +-- .../Components/ReagentDispenserComponent.cs | 6 ++- .../EntitySystems/ChemicalReactionSystem.cs | 4 +- .../ReactionEffects/AreaReactionEffect.cs | 7 +-- .../Construction/Completions/PlaySound.cs | 16 ++----- Content.Server/Crayon/CrayonComponent.cs | 7 +-- .../Cuffs/Components/CuffableComponent.cs | 12 ++--- .../Cuffs/Components/HandcuffComponent.cs | 19 ++++---- .../DamageOnHighSpeedImpactComponent.cs | 9 ++-- .../Thresholds/Behaviors/PlaySoundBehavior.cs | 13 +++-- .../Behaviors/PlaySoundCollectionBehavior.cs | 33 ------------- Content.Server/Dice/DiceComponent.cs | 3 +- .../Mailing/DisposalMailingUnitComponent.cs | 8 +++- .../Components/DisposalRouterComponent.cs | 7 ++- .../Components/DisposalTaggerComponent.cs | 7 ++- .../Tube/Components/DisposalTubeComponent.cs | 6 ++- .../Unit/Components/DisposalUnitComponent.cs | 6 ++- .../Doors/Components/AirlockComponent.cs | 17 ++++++- .../Doors/Components/ServerDoorComponent.cs | 10 ++-- .../Components/FlashExplosiveComponent.cs | 7 +-- Content.Server/Explosion/ExplosionHelper.cs | 5 +- .../Extinguisher/FireExtinguisherComponent.cs | 7 ++- .../Flash/Components/FlashComponent.cs | 5 ++ .../Flash/Components/FlashableComponent.cs | 7 +-- Content.Server/Flash/FlashSystem.cs | 6 +-- .../Fluids/Components/BucketComponent.cs | 7 +-- .../Fluids/Components/MopComponent.cs | 7 +-- .../Fluids/Components/PuddleComponent.cs | 6 ++- .../Fluids/Components/SprayComponent.cs | 10 ++-- .../GameTicking/Rules/RuleSuspicion.cs | 8 +++- .../GameTicking/Rules/RuleTraitor.cs | 8 +++- .../Gravity/EntitySystems/GravitySystem.cs | 14 ++++-- .../Hands/Components/HandsComponent.cs | 8 +++- .../Components/KitchenSpikeComponent.cs | 4 +- .../Kitchen/Components/MicrowaveComponent.cs | 21 ++++++--- .../Components/ReagentGrinderComponent.cs | 13 +++-- .../Components/ExpendableLightComponent.cs | 8 ++-- .../Components/HandheldLightComponent.cs | 20 ++++---- .../Light/Components/LightBulbComponent.cs | 10 ++-- .../Light/Components/MatchstickComponent.cs | 7 +-- .../Light/Components/PoweredLightComponent.cs | 13 ++++- .../Components/AsteroidRockComponent.cs | 11 +++-- .../Mining/Components/PickaxeComponent.cs | 8 ++-- .../CrematoriumEntityStorageComponent.cs | 13 +++-- .../MorgueEntityStorageComponent.cs | 29 ++++++++---- .../Components/FootstepModifierComponent.cs | 18 ++----- .../Nutrition/Components/CreamPieComponent.cs | 8 +++- .../Nutrition/Components/DrinkComponent.cs | 20 ++++---- .../Nutrition/Components/FoodComponent.cs | 7 +-- .../Components/SliceableFoodComponent.cs | 8 ++-- .../Nutrition/Components/UtensilComponent.cs | 7 +-- Content.Server/PDA/PDAComponent.cs | 14 ++++-- .../Physics/Controllers/MoverController.cs | 24 +++++----- .../Components/PottedPlantHideComponent.cs | 6 ++- .../Components/RoguePointingArrowComponent.cs | 7 ++- .../Portal/Components/PortalComponent.cs | 11 +++-- .../Portal/Components/TeleporterComponent.cs | 17 ++++--- .../Power/Components/ApcComponent.cs | 7 ++- .../Components/PowerCellSlotComponent.cs | 13 ++--- .../Components/HitscanComponent.cs | 6 ++- .../Components/ProjectileComponent.cs | 15 ++---- Content.Server/RCD/Components/RCDComponent.cs | 15 ++++-- .../Radiation/RadiationPulseComponent.cs | 7 +-- .../Radiation/RadiationPulseSystem.cs | 3 +- .../Components/ResearchConsoleComponent.cs | 10 ++-- Content.Server/RoundEnd/RoundEndSystem.cs | 2 +- .../Components/EmitterComponent.cs | 8 ++-- .../Components/ServerSingularityComponent.cs | 14 ++++-- Content.Server/Sound/EmitSoundSystem.cs | 13 ++--- .../StationEvents/Events/GasLeak.cs | 1 + .../CursedEntityStorageComponent.cs | 13 +++-- .../Components/EntityStorageComponent.cs | 11 +++-- .../SecureEntityStorageComponent.cs | 11 +++-- .../Components/ServerStorageComponent.cs | 20 ++++---- .../Components/StunbatonComponent.cs | 10 ++++ .../Components/StunnableComponent.cs | 11 +++-- Content.Server/Stunnable/StunbatonSystem.cs | 26 ++++++---- .../Tiles/FloorTileItemComponent.cs | 8 +++- Content.Server/Toilet/ToiletComponent.cs | 7 ++- .../Tools/Components/MultitoolComponent.cs | 15 +++--- .../Tools/Components/ToolComponent.cs | 32 ++----------- .../Tools/Components/WelderComponent.cs | 37 +++++++++++---- .../VendingMachineComponent.cs | 11 +++-- .../Melee/Components/MeleeWeaponComponent.cs | 5 +- .../Weapon/Melee/MeleeWeaponSystem.cs | 12 +++-- .../Ammunition/Components/AmmoComponent.cs | 3 +- .../Components/BoltActionBarrelComponent.cs | 31 ++++++------ .../Barrels/Components/PumpBarrelComponent.cs | 15 +++--- .../Components/RevolverBarrelComponent.cs | 21 +++++---- .../ServerBatteryBarrelComponent.cs | 13 ++--- .../ServerMagazineBarrelComponent.cs | 47 ++++++++++--------- .../Components/ServerRangedBarrelComponent.cs | 29 +++++------- .../Ranged/ServerRangedWeaponComponent.cs | 17 +++++-- Content.Server/Window/WindowComponent.cs | 9 +++- Content.Server/WireHacking/WiresComponent.cs | 30 ++++++++++-- .../Chemistry/Reaction/ReactionPrototype.cs | 3 +- Content.Shared/Gravity/GravityComponent.cs | 5 ++ .../Components/SharedKitchenSpikeComponent.cs | 3 +- .../SharedExpendableLightComponent.cs | 9 ++-- Content.Shared/Maps/ContentTileDefinition.cs | 7 +-- Content.Shared/Slippery/SlipperyComponent.cs | 13 ++--- Content.Shared/Sound/SoundSpecifier.cs | 21 +++++++-- .../Standing/StandingStateComponent.cs | 3 +- .../Standing/StandingStateSystem.cs | 7 +-- Resources/Prototypes/Actions/actions.yml | 23 ++++----- Resources/Prototypes/Actions/spells.yml | 3 +- .../Walls/extinguisher_cabinet.yml | 3 +- .../Constructible/Walls/fireaxe_cabinet.yml | 3 +- .../Objects/Misc/fire_extinguisher.yml | 3 +- .../Objects/Specific/Janitorial/spray.yml | 3 +- .../Weapons/Guns/Projectiles/projectiles.yml | 3 +- .../Prototypes/SoundCollections/screams.yml | 18 +++++++ 131 files changed, 934 insertions(+), 587 deletions(-) delete mode 100644 Content.Server/Destructible/Thresholds/Behaviors/PlaySoundCollectionBehavior.cs create mode 100644 Resources/Prototypes/SoundCollections/screams.yml diff --git a/Content.Client/PDA/PDAComponent.cs b/Content.Client/PDA/PDAComponent.cs index b9e0c206dc..7538b70906 100644 --- a/Content.Client/PDA/PDAComponent.cs +++ b/Content.Client/PDA/PDAComponent.cs @@ -1,26 +1,39 @@ using Content.Shared.PDA; +using Content.Shared.Sound; using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.Network; using Robust.Shared.Player; using Robust.Shared.Players; +using Robust.Shared.Serialization.Manager.Attributes; +using Robust.Shared.ViewVariables; namespace Content.Client.PDA { [RegisterComponent] public class PDAComponent : SharedPDAComponent { + [ViewVariables] + [DataField("buySuccessSound")] + private SoundSpecifier BuySuccessSound { get; } = new SoundPathSpecifier("/Audio/Effects/kaching.ogg"); + + [ViewVariables] + [DataField("insufficientFundsSound")] + private SoundSpecifier InsufficientFundsSound { get; } = new SoundPathSpecifier("/Audio/Effects/error.ogg"); + public override void HandleNetworkMessage(ComponentMessage message, INetChannel netChannel, ICommonSession? session = null) { base.HandleNetworkMessage(message, netChannel, session); switch(message) { - case PDAUplinkBuySuccessMessage _ : - SoundSystem.Play(Filter.Local(), "/Audio/Effects/kaching.ogg", Owner, AudioParams.Default.WithVolume(-2f)); + case PDAUplinkBuySuccessMessage: + if(BuySuccessSound.TryGetSound(out var buySuccessSound)) + SoundSystem.Play(Filter.Local(), buySuccessSound, Owner, AudioParams.Default.WithVolume(-2f)); break; - case PDAUplinkInsufficientFundsMessage _ : - SoundSystem.Play(Filter.Local(), "/Audio/Effects/error.ogg", Owner, AudioParams.Default); + case PDAUplinkInsufficientFundsMessage: + if(InsufficientFundsSound.TryGetSound(out var insufficientFundsSound)) + SoundSystem.Play(Filter.Local(), insufficientFundsSound, Owner, AudioParams.Default); break; } } diff --git a/Content.IntegrationTests/Tests/Destructible/DestructibleThresholdActivationTest.cs b/Content.IntegrationTests/Tests/Destructible/DestructibleThresholdActivationTest.cs index 00ba58d930..d206ba6507 100644 --- a/Content.IntegrationTests/Tests/Destructible/DestructibleThresholdActivationTest.cs +++ b/Content.IntegrationTests/Tests/Destructible/DestructibleThresholdActivationTest.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; using System.Threading.Tasks; using Content.Server.Destructible; using Content.Server.Destructible.Thresholds; @@ -100,7 +100,7 @@ namespace Content.IntegrationTests.Tests.Destructible var actsThreshold = (DoActsBehavior) threshold.Behaviors[2]; Assert.That(actsThreshold.Acts, Is.EqualTo(ThresholdActs.Breakage)); - Assert.That(soundThreshold.Sound, Is.EqualTo("/Audio/Effects/woodhit.ogg")); + Assert.That(soundThreshold.Sound.GetSound(), Is.EqualTo("/Audio/Effects/woodhit.ogg")); Assert.That(spawnThreshold.Spawn, Is.Not.Null); Assert.That(spawnThreshold.Spawn.Count, Is.EqualTo(1)); Assert.That(spawnThreshold.Spawn.Single().Key, Is.EqualTo(SpawnedEntityId)); @@ -164,7 +164,7 @@ namespace Content.IntegrationTests.Tests.Destructible // Check that it matches the YAML prototype Assert.That(actsThreshold.Acts, Is.EqualTo(ThresholdActs.Breakage)); - Assert.That(soundThreshold.Sound, Is.EqualTo("/Audio/Effects/woodhit.ogg")); + Assert.That(soundThreshold.Sound.GetSound(), Is.EqualTo("/Audio/Effects/woodhit.ogg")); Assert.That(spawnThreshold.Spawn, Is.Not.Null); Assert.That(spawnThreshold.Spawn.Count, Is.EqualTo(1)); Assert.That(spawnThreshold.Spawn.Single().Key, Is.EqualTo(SpawnedEntityId)); @@ -215,7 +215,7 @@ namespace Content.IntegrationTests.Tests.Destructible // Check that it matches the YAML prototype Assert.That(actsThreshold.Acts, Is.EqualTo(ThresholdActs.Breakage)); - Assert.That(soundThreshold.Sound, Is.EqualTo("/Audio/Effects/woodhit.ogg")); + Assert.That(soundThreshold.Sound.GetSound(), Is.EqualTo("/Audio/Effects/woodhit.ogg")); Assert.That(spawnThreshold.Spawn, Is.Not.Null); Assert.That(spawnThreshold.Spawn.Count, Is.EqualTo(1)); Assert.That(spawnThreshold.Spawn.Single().Key, Is.EqualTo(SpawnedEntityId)); diff --git a/Content.Server/AME/Components/AMEControllerComponent.cs b/Content.Server/AME/Components/AMEControllerComponent.cs index 54873aa4e8..4a4a064b28 100644 --- a/Content.Server/AME/Components/AMEControllerComponent.cs +++ b/Content.Server/AME/Components/AMEControllerComponent.cs @@ -11,12 +11,14 @@ using Content.Shared.AME; using Content.Shared.Interaction; using Content.Shared.Interaction.Events; using Content.Shared.Notification.Managers; +using Content.Shared.Sound; using Robust.Server.GameObjects; using Robust.Shared.Audio; using Robust.Shared.Containers; using Robust.Shared.GameObjects; using Robust.Shared.Localization; using Robust.Shared.Player; +using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; namespace Content.Server.AME.Components @@ -32,6 +34,8 @@ namespace Content.Server.AME.Components private AppearanceComponent? _appearance; private PowerSupplierComponent? _powerSupplier; + [DataField("clickSound")] private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg"); + [DataField("injectSound")] private SoundSpecifier _injectSound = new SoundPathSpecifier("/Audio/Effects/bang.ogg"); private bool Powered => !Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) || receiver.Powered; @@ -312,12 +316,14 @@ namespace Content.Server.AME.Components private void ClickSound() { - SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/machine_switch.ogg", Owner, AudioParams.Default.WithVolume(-2f)); + if(_clickSound.TryGetSound(out var clickSound)) + SoundSystem.Play(Filter.Pvs(Owner), clickSound, Owner, AudioParams.Default.WithVolume(-2f)); } private void InjectSound(bool overloading) { - SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/bang.ogg", Owner, AudioParams.Default.WithVolume(overloading ? 10f : 0f)); + if(_injectSound.TryGetSound(out var injectSound)) + SoundSystem.Play(Filter.Pvs(Owner), injectSound, Owner, AudioParams.Default.WithVolume(overloading ? 10f : 0f)); } async Task IInteractUsing.InteractUsing(InteractUsingEventArgs args) diff --git a/Content.Server/AME/Components/AMEPartComponent.cs b/Content.Server/AME/Components/AMEPartComponent.cs index 42fc2de82e..8b0b140a73 100644 --- a/Content.Server/AME/Components/AMEPartComponent.cs +++ b/Content.Server/AME/Components/AMEPartComponent.cs @@ -4,8 +4,8 @@ using System.Threading.Tasks; using Content.Server.Hands.Components; using Content.Server.Tools.Components; using Content.Shared.Interaction; -using Content.Shared.Notification; using Content.Shared.Notification.Managers; +using Content.Shared.Sound; using Content.Shared.Tool; using Robust.Server.GameObjects; using Robust.Shared.Audio; @@ -14,6 +14,7 @@ using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Map; using Robust.Shared.Player; +using Robust.Shared.Serialization.Manager.Attributes; namespace Content.Server.AME.Components { @@ -25,7 +26,7 @@ namespace Content.Server.AME.Components [Dependency] private readonly IServerEntityManager _serverEntityManager = default!; public override string Name => "AMEPart"; - private string _unwrap = "/Audio/Effects/unwrap.ogg"; + [DataField("unwrapSound")] private SoundSpecifier _unwrapSound = new SoundPathSpecifier("/Audio/Effects/unwrap.ogg"); async Task IInteractUsing.InteractUsing(InteractUsingEventArgs args) { @@ -51,7 +52,8 @@ namespace Content.Server.AME.Components var ent = _serverEntityManager.SpawnEntity("AMEShielding", mapGrid.GridTileToLocal(snapPos)); ent.Transform.LocalRotation = Owner.Transform.LocalRotation; - SoundSystem.Play(Filter.Pvs(Owner), _unwrap, Owner); + if(_unwrapSound.TryGetSound(out var unwrapSound)) + SoundSystem.Play(Filter.Pvs(Owner), unwrapSound, Owner); Owner.Delete(); diff --git a/Content.Server/Actions/Actions/DisarmAction.cs b/Content.Server/Actions/Actions/DisarmAction.cs index a54992a282..fc06630b98 100644 --- a/Content.Server/Actions/Actions/DisarmAction.cs +++ b/Content.Server/Actions/Actions/DisarmAction.cs @@ -1,6 +1,4 @@ #nullable enable -using System; -using System.Linq; using Content.Server.Act; using Content.Server.Interaction; using Content.Server.Notification; @@ -11,9 +9,9 @@ using Content.Shared.Actions.Behaviors; using Content.Shared.Actions.Components; using Content.Shared.Audio; using Content.Shared.Cooldown; -using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Helpers; using Content.Shared.Notification.Managers; +using Content.Shared.Sound; using JetBrains.Annotations; using Robust.Server.GameObjects; using Robust.Shared.Audio; @@ -24,6 +22,9 @@ using Robust.Shared.Maths; using Robust.Shared.Player; using Robust.Shared.Random; using Robust.Shared.Serialization.Manager.Attributes; +using Robust.Shared.ViewVariables; +using System; +using System.Linq; namespace Content.Server.Actions.Actions { @@ -35,6 +36,14 @@ namespace Content.Server.Actions.Actions [DataField("pushProb")] private float _pushProb = 0.4f; [DataField("cooldown")] private float _cooldown = 1.5f; + [ViewVariables] + [DataField("punchMissSound")] + private SoundSpecifier PunchMissSound { get; } = new SoundPathSpecifier("/Audio/Weapons/punchmiss.ogg"); + + [ViewVariables] + [DataField("disarmSuccessSound")] + private SoundSpecifier DisarmSuccessSound { get; } = new SoundPathSpecifier("/Audio/Effects/thudswoosh.ogg"); + public void DoTargetEntityAction(TargetEntityActionEventArgs args) { var disarmedActs = args.Target.GetAllComponents().ToArray(); @@ -70,8 +79,9 @@ namespace Content.Server.Actions.Actions if (random.Prob(_failProb)) { - SoundSystem.Play(Filter.Pvs(args.Performer), "/Audio/Weapons/punchmiss.ogg", args.Performer, - AudioHelpers.WithVariation(0.025f)); + if(PunchMissSound.TryGetSound(out var punchMissSound)) + SoundSystem.Play(Filter.Pvs(args.Performer), punchMissSound, args.Performer, AudioHelpers.WithVariation(0.025f)); + args.Performer.PopupMessageOtherClients(Loc.GetString("disarm-action-popup-message-other-clients", ("performerName", args.Performer.Name), ("targetName", args.Target.Name))); @@ -94,8 +104,8 @@ namespace Content.Server.Actions.Actions return; } - SoundSystem.Play(Filter.Pvs(args.Performer), "/Audio/Effects/thudswoosh.ogg", args.Performer.Transform.Coordinates, - AudioHelpers.WithVariation(0.025f)); + if(DisarmSuccessSound.TryGetSound(out var disarmSuccessSound)) + SoundSystem.Play(Filter.Pvs(args.Performer), disarmSuccessSound, args.Performer.Transform.Coordinates, AudioHelpers.WithVariation(0.025f)); } } } diff --git a/Content.Server/Actions/Actions/ScreamAction.cs b/Content.Server/Actions/Actions/ScreamAction.cs index 0f1fa8cfdb..fdad420c57 100644 --- a/Content.Server/Actions/Actions/ScreamAction.cs +++ b/Content.Server/Actions/Actions/ScreamAction.cs @@ -1,6 +1,4 @@ #nullable enable -using System; -using System.Collections.Generic; using Content.Server.CharacterAppearance.Components; using Content.Shared.ActionBlocker; using Content.Shared.Actions.Behaviors; @@ -8,7 +6,7 @@ using Content.Shared.Actions.Components; using Content.Shared.Audio; using Content.Shared.CharacterAppearance; using Content.Shared.Cooldown; -using Content.Shared.Speech; +using Content.Shared.Sound; using JetBrains.Annotations; using Robust.Shared.Audio; using Robust.Shared.GameObjects; @@ -16,6 +14,7 @@ using Robust.Shared.IoC; using Robust.Shared.Player; using Robust.Shared.Random; using Robust.Shared.Serialization.Manager.Attributes; +using System; namespace Content.Server.Actions.Actions { @@ -28,9 +27,9 @@ namespace Content.Server.Actions.Actions [Dependency] private readonly IRobustRandom _random = default!; - [DataField("male")] private List? _male; - [DataField("female")] private List? _female; - [DataField("wilhelm")] private string? _wilhelm; + [DataField("male")] private SoundSpecifier _male = default!; + [DataField("female")] private SoundSpecifier _female = default!; + [DataField("wilhelm")] private SoundSpecifier _wilhelm = default!; /// seconds [DataField("cooldown")] private float _cooldown = 10; @@ -46,31 +45,27 @@ namespace Content.Server.Actions.Actions if (!args.Performer.TryGetComponent(out var humanoid)) return; if (!args.Performer.TryGetComponent(out var actions)) return; - if (_random.Prob(.01f) && !string.IsNullOrWhiteSpace(_wilhelm)) + if (_random.Prob(.01f) && _wilhelm.TryGetSound(out var wilhelm)) { - SoundSystem.Play(Filter.Pvs(args.Performer), _wilhelm, args.Performer, AudioParams.Default.WithVolume(Volume)); + SoundSystem.Play(Filter.Pvs(args.Performer), wilhelm, args.Performer, AudioParams.Default.WithVolume(Volume)); } else { switch (humanoid.Sex) { case Sex.Male: - if (_male == null) break; - SoundSystem.Play(Filter.Pvs(args.Performer), _random.Pick(_male), args.Performer, - AudioHelpers.WithVariation(Variation).WithVolume(Volume)); + if (_male.TryGetSound(out var male)) + SoundSystem.Play(Filter.Pvs(args.Performer), male, args.Performer, AudioHelpers.WithVariation(Variation).WithVolume(Volume)); break; case Sex.Female: - if (_female == null) break; - SoundSystem.Play(Filter.Pvs(args.Performer), _random.Pick(_female), args.Performer, - AudioHelpers.WithVariation(Variation).WithVolume(Volume)); + if (_female.TryGetSound(out var female)) + SoundSystem.Play(Filter.Pvs(args.Performer), female, args.Performer, AudioHelpers.WithVariation(Variation).WithVolume(Volume)); break; default: throw new ArgumentOutOfRangeException(); } } - - actions.Cooldown(args.ActionType, Cooldowns.SecondsFromNow(_cooldown)); } } diff --git a/Content.Server/Actions/Spells/GiveItemSpell.cs b/Content.Server/Actions/Spells/GiveItemSpell.cs index d7cac3a1b2..01d4826fde 100644 --- a/Content.Server/Actions/Spells/GiveItemSpell.cs +++ b/Content.Server/Actions/Spells/GiveItemSpell.cs @@ -6,6 +6,7 @@ using Content.Shared.Actions.Behaviors; using Content.Shared.Actions.Components; using Content.Shared.Cooldown; using Content.Shared.Notification.Managers; +using Content.Shared.Sound; using JetBrains.Annotations; using Robust.Shared.Audio; using Robust.Shared.GameObjects; @@ -27,7 +28,7 @@ namespace Content.Server.Actions.Spells [ViewVariables] [DataField("cooldown")] public float CoolDown { get; set; } = 1f; [ViewVariables] [DataField("spellItem")] public string ItemProto { get; set; } = default!; - [ViewVariables] [DataField("castSound")] public string? CastSound { get; set; } = default!; + [ViewVariables] [DataField("castSound")] public SoundSpecifier CastSound { get; set; } = default!; //Rubber-band snapping items into player's hands, originally was a workaround, later found it works quite well with stuns //Not sure if needs fixing @@ -68,8 +69,8 @@ namespace Content.Server.Actions.Spells handsComponent.PutInHandOrDrop(itemComponent); - if (CastSound != null) - SoundSystem.Play(Filter.Pvs(caster), CastSound, caster); + if (CastSound.TryGetSound(out var castSound)) + SoundSystem.Play(Filter.Pvs(caster), castSound, caster); } } } diff --git a/Content.Server/Arcade/Components/SpaceVillainArcadeComponent.cs b/Content.Server/Arcade/Components/SpaceVillainArcadeComponent.cs index d2aae64b6a..3654ad9a96 100644 --- a/Content.Server/Arcade/Components/SpaceVillainArcadeComponent.cs +++ b/Content.Server/Arcade/Components/SpaceVillainArcadeComponent.cs @@ -8,6 +8,7 @@ using Content.Shared.ActionBlocker; using Content.Shared.Arcade; using Content.Shared.Interaction; using Content.Shared.Interaction.Events; +using Content.Shared.Sound; using Content.Shared.Wires; using Robust.Server.GameObjects; using Robust.Shared.Audio; @@ -39,6 +40,13 @@ namespace Content.Server.Arcade.Components [ViewVariables] private bool _enemyInvincibilityFlag; [ViewVariables] private SpaceVillainGame _game = null!; + [DataField("newGameSound")] private SoundSpecifier _newGameSound = new SoundPathSpecifier("/Audio/Effects/Arcade/newgame.ogg"); + [DataField("playerAttackSound")] private SoundSpecifier _playerAttackSound = new SoundPathSpecifier("/Audio/Effects/Arcade/player_attack.ogg"); + [DataField("playerHealSound")] private SoundSpecifier _playerHealSound = new SoundPathSpecifier("/Audio/Effects/Arcade/player_heal.ogg"); + [DataField("playerChargeSound")] private SoundSpecifier _playerChargeSound = new SoundPathSpecifier("/Audio/Effects/Arcade/player_charge.ogg"); + [DataField("winSound")] private SoundSpecifier _winSound = new SoundPathSpecifier("/Audio/Effects/Arcade/win.ogg"); + [DataField("gameOverSound")] private SoundSpecifier _gameOverSound = new SoundPathSpecifier("/Audio/Effects/Arcade/gameover.ogg"); + [ViewVariables(VVAccess.ReadWrite)] [DataField("possibleFightVerbs")] private List _possibleFightVerbs = new List() {"Defeat", "Annihilate", "Save", "Strike", "Stop", "Destroy", "Robust", "Romance", "Pwn", "Own"}; [ViewVariables(VVAccess.ReadWrite)] [DataField("possibleFirstEnemyNames")] private List _possibleFirstEnemyNames = new List(){ @@ -124,7 +132,9 @@ namespace Content.Server.Arcade.Components _game?.ExecutePlayerAction(msg.PlayerAction); break; case PlayerAction.NewGame: - SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/Arcade/newgame.ogg", Owner, AudioParams.Default.WithVolume(-4f)); + if(_newGameSound.TryGetSound(out var sound)) + SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default.WithVolume(-4f)); + _game = new SpaceVillainGame(this); UserInterface?.SendMessage(_game.GenerateMetaDataMessage()); break; @@ -292,8 +302,10 @@ namespace Content.Server.Arcade.Components _latestPlayerActionMessage = Loc.GetString("space-villain-game-player-attack-message", ("enemyName", _enemyName), ("attackAmount", attackAmount)); - SoundSystem.Play(Filter.Pvs(_owner.Owner), "/Audio/Effects/Arcade/player_attack.ogg", _owner.Owner, AudioParams.Default.WithVolume(-4f)); - if(!_owner._enemyInvincibilityFlag) _enemyHp -= attackAmount; + if(_owner._playerAttackSound.TryGetSound(out var playerAttackSound)) + SoundSystem.Play(Filter.Pvs(_owner.Owner), playerAttackSound, _owner.Owner, AudioParams.Default.WithVolume(-4f)); + if(!_owner._enemyInvincibilityFlag) + _enemyHp -= attackAmount; _turtleTracker -= _turtleTracker > 0 ? 1 : 0; break; case PlayerAction.Heal: @@ -302,15 +314,18 @@ namespace Content.Server.Arcade.Components _latestPlayerActionMessage = Loc.GetString("space-villain-game-player-heal-message", ("magicPointAmount", pointAmount), ("healAmount", healAmount)); - SoundSystem.Play(Filter.Pvs(_owner.Owner), "/Audio/Effects/Arcade/player_heal.ogg", _owner.Owner, AudioParams.Default.WithVolume(-4f)); - if(!_owner._playerInvincibilityFlag) _playerMp -= pointAmount; + if(_owner._playerHealSound.TryGetSound(out var playerHealSound)) + SoundSystem.Play(Filter.Pvs(_owner.Owner), playerHealSound, _owner.Owner, AudioParams.Default.WithVolume(-4f)); + if(!_owner._playerInvincibilityFlag) + _playerMp -= pointAmount; _playerHp += healAmount; _turtleTracker++; break; case PlayerAction.Recharge: var chargeAmount = _random.Next(4, 7); _latestPlayerActionMessage = Loc.GetString("space-villain-game-player-recharge-message",("regainedPoints", chargeAmount)); - SoundSystem.Play(Filter.Pvs(_owner.Owner), "/Audio/Effects/Arcade/player_charge.ogg", _owner.Owner, AudioParams.Default.WithVolume(-4f)); + if(_owner._playerChargeSound.TryGetSound(out var playerChargeSound)) + SoundSystem.Play(Filter.Pvs(_owner.Owner), playerChargeSound, _owner.Owner, AudioParams.Default.WithVolume(-4f)); _playerMp += chargeAmount; _turtleTracker -= _turtleTracker > 0 ? 1 : 0; break; @@ -344,7 +359,8 @@ namespace Content.Server.Arcade.Components UpdateUi(Loc.GetString("space-villain-game-player-wins-message"), Loc.GetString("space-villain-game-enemy-dies-message",("enemyName", _enemyName)), true); - SoundSystem.Play(Filter.Pvs(_owner.Owner), "/Audio/Effects/Arcade/win.ogg", _owner.Owner, AudioParams.Default.WithVolume(-4f)); + if(_owner._winSound.TryGetSound(out var winSound)) + SoundSystem.Play(Filter.Pvs(_owner.Owner), winSound, _owner.Owner, AudioParams.Default.WithVolume(-4f)); _owner.ProcessWin(); return false; } @@ -357,7 +373,8 @@ namespace Content.Server.Arcade.Components UpdateUi(Loc.GetString("space-villain-game-player-loses-message"), Loc.GetString("space-villain-game-enemy-cheers-message",("enemyName", _enemyName)), true); - SoundSystem.Play(Filter.Pvs(_owner.Owner), "/Audio/Effects/Arcade/gameover.ogg", _owner.Owner, AudioParams.Default.WithVolume(-4f)); + if(_owner._gameOverSound.TryGetSound(out var gameOverSound)) + SoundSystem.Play(Filter.Pvs(_owner.Owner), gameOverSound, _owner.Owner, AudioParams.Default.WithVolume(-4f)); return false; } if (_enemyHp <= 0 || _enemyMp <= 0) @@ -366,7 +383,8 @@ namespace Content.Server.Arcade.Components UpdateUi(Loc.GetString("space-villain-game-player-loses-message"), Loc.GetString("space-villain-game-enemy-dies-with-player-message ", ("enemyName", _enemyName)), true); - SoundSystem.Play(Filter.Pvs(_owner.Owner), "/Audio/Effects/Arcade/gameover.ogg", _owner.Owner, AudioParams.Default.WithVolume(-4f)); + if (_owner._gameOverSound.TryGetSound(out var gameOverSound)) + SoundSystem.Play(Filter.Pvs(_owner.Owner), gameOverSound, _owner.Owner, AudioParams.Default.WithVolume(-4f)); return false; } diff --git a/Content.Server/Atmos/Components/GasTankComponent.cs b/Content.Server/Atmos/Components/GasTankComponent.cs index d30494b082..81f1706817 100644 --- a/Content.Server/Atmos/Components/GasTankComponent.cs +++ b/Content.Server/Atmos/Components/GasTankComponent.cs @@ -18,6 +18,7 @@ using Content.Shared.Audio; using Content.Shared.DragDrop; using Content.Shared.Examine; using Content.Shared.Interaction; +using Content.Shared.Sound; using Content.Shared.Verbs; using JetBrains.Annotations; using Robust.Server.GameObjects; @@ -48,6 +49,8 @@ namespace Content.Server.Atmos.Components [ViewVariables] private BoundUserInterface? _userInterface; + [DataField("ruptureSound")] private SoundSpecifier _ruptureSound = new SoundPathSpecifier("Audio/Effects/spray.ogg"); + [DataField("air")] [ViewVariables] public GasMixture Air { get; set; } = new(); /// @@ -282,8 +285,8 @@ namespace Content.Server.Atmos.Components var tileAtmos = Owner.Transform.Coordinates.GetTileAtmosphere(); tileAtmos?.AssumeAir(Air); - SoundSystem.Play(Filter.Pvs(Owner), "Audio/Effects/spray.ogg", Owner.Transform.Coordinates, - AudioHelpers.WithVariation(0.125f)); + if(_ruptureSound.TryGetSound(out var sound)) + SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.125f)); Owner.QueueDelete(); return; diff --git a/Content.Server/Body/BodyComponent.cs b/Content.Server/Body/BodyComponent.cs index 9710f58a51..5c4b81a6d5 100644 --- a/Content.Server/Body/BodyComponent.cs +++ b/Content.Server/Body/BodyComponent.cs @@ -9,6 +9,7 @@ using Content.Shared.Body.Slot; using Content.Shared.MobState; using Content.Shared.Movement.Components; using Content.Shared.Random.Helpers; +using Content.Shared.Sound; using Robust.Shared.Audio; using Robust.Shared.Containers; using Robust.Shared.GameObjects; @@ -16,6 +17,7 @@ using Robust.Shared.IoC; using Robust.Shared.Log; using Robust.Shared.Player; using Robust.Shared.Players; +using Robust.Shared.Serialization.Manager.Attributes; namespace Content.Server.Body { @@ -26,6 +28,8 @@ namespace Content.Server.Body { private Container _partContainer = default!; + [DataField("gibSound")] private SoundSpecifier _gibSound = new SoundCollectionSpecifier("gib"); + protected override bool CanAddPart(string slotId, SharedBodyPartComponent part) { return base.CanAddPart(slotId, part) && @@ -101,8 +105,8 @@ namespace Content.Server.Body { base.Gib(gibParts); - SoundSystem.Play(Filter.Pvs(Owner), AudioHelpers.GetRandomFileFromSoundCollection("gib"), Owner.Transform.Coordinates, - AudioHelpers.WithVariation(0.025f)); + if(_gibSound.TryGetSound(out var sound)) + SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.025f)); if (Owner.TryGetComponent(out ContainerManagerComponent? container)) { diff --git a/Content.Server/Botany/Components/PlantHolderComponent.cs b/Content.Server/Botany/Components/PlantHolderComponent.cs index d3af8dc4b8..6c283dc626 100644 --- a/Content.Server/Botany/Components/PlantHolderComponent.cs +++ b/Content.Server/Botany/Components/PlantHolderComponent.cs @@ -724,9 +724,9 @@ namespace Content.Server.Botany.Components sprayed = true; amount = ReagentUnit.New(1); - if (!string.IsNullOrEmpty(spray.SpraySound)) + if (spray.SpraySound.TryGetSound(out var spraySound)) { - SoundSystem.Play(Filter.Pvs(usingItem), spray.SpraySound, usingItem, AudioHelpers.WithVariation(0.125f)); + SoundSystem.Play(Filter.Pvs(usingItem), spraySound, usingItem, AudioHelpers.WithVariation(0.125f)); } } diff --git a/Content.Server/Buckle/Components/BuckleComponent.cs b/Content.Server/Buckle/Components/BuckleComponent.cs index 2291bbb4e0..fce20fc6f8 100644 --- a/Content.Server/Buckle/Components/BuckleComponent.cs +++ b/Content.Server/Buckle/Components/BuckleComponent.cs @@ -242,7 +242,10 @@ namespace Content.Server.Buckle.Components return false; } - SoundSystem.Play(Filter.Pvs(Owner), strap.BuckleSound, Owner); + if(strap.BuckleSound.TryGetSound(out var buckleSound)) + { + SoundSystem.Play(Filter.Pvs(Owner), buckleSound, Owner); + } if (!strap.TryAdd(this)) { @@ -350,8 +353,11 @@ namespace Content.Server.Buckle.Components UpdateBuckleStatus(); oldBuckledTo.Remove(this); - SoundSystem.Play(Filter.Pvs(Owner), oldBuckledTo.UnbuckleSound, Owner); - + if (oldBuckledTo.UnbuckleSound.TryGetSound(out var unbuckleSound)) + { + SoundSystem.Play(Filter.Pvs(Owner), unbuckleSound, Owner); + } + SendMessage(new UnbuckleMessage(Owner, oldBuckledTo.Owner)); return true; diff --git a/Content.Server/Buckle/Components/StrapComponent.cs b/Content.Server/Buckle/Components/StrapComponent.cs index e27355a13e..699523a0f2 100644 --- a/Content.Server/Buckle/Components/StrapComponent.cs +++ b/Content.Server/Buckle/Components/StrapComponent.cs @@ -9,6 +9,7 @@ using Content.Shared.DragDrop; using Content.Shared.Interaction; using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Helpers; +using Content.Shared.Sound; using Content.Shared.Verbs; using Robust.Server.GameObjects; using Robust.Shared.GameObjects; @@ -56,14 +57,14 @@ namespace Content.Server.Buckle.Components /// [ViewVariables] [DataField("buckleSound")] - public string BuckleSound { get; } = "/Audio/Effects/buckle.ogg"; + public SoundSpecifier BuckleSound { get; } = new SoundPathSpecifier("/Audio/Effects/buckle.ogg"); /// /// The sound to be played when a mob is unbuckled /// [ViewVariables] [DataField("unbuckleSound")] - public string UnbuckleSound { get; } = "/Audio/Effects/unbuckle.ogg"; + public SoundSpecifier UnbuckleSound { get; } = new SoundPathSpecifier("/Audio/Effects/unbuckle.ogg"); /// /// ID of the alert to show when buckled diff --git a/Content.Server/Cabinet/ItemCabinetComponent.cs b/Content.Server/Cabinet/ItemCabinetComponent.cs index f85f311ce2..dd72e2d3d5 100644 --- a/Content.Server/Cabinet/ItemCabinetComponent.cs +++ b/Content.Server/Cabinet/ItemCabinetComponent.cs @@ -1,5 +1,6 @@ -using Content.Shared.ActionBlocker; +using Content.Shared.ActionBlocker; using Content.Shared.Interaction.Events; +using Content.Shared.Sound; using Content.Shared.Verbs; using Content.Shared.Whitelist; using Robust.Shared.Containers; @@ -24,7 +25,7 @@ namespace Content.Server.Cabinet /// [ViewVariables(VVAccess.ReadWrite)] [DataField("doorSound")] - public string? DoorSound { get; set; } + public SoundSpecifier DoorSound { get; set; } = default!; /// /// The prototype that should be spawned inside the cabinet when it is map initialized. diff --git a/Content.Server/Cabinet/ItemCabinetSystem.cs b/Content.Server/Cabinet/ItemCabinetSystem.cs index b0e49e0821..39772ee9b6 100644 --- a/Content.Server/Cabinet/ItemCabinetSystem.cs +++ b/Content.Server/Cabinet/ItemCabinetSystem.cs @@ -1,4 +1,4 @@ -using Content.Server.Hands.Components; +using Content.Server.Hands.Components; using Content.Server.Items; using Content.Shared.Audio; using Content.Shared.Cabinet; @@ -146,8 +146,10 @@ namespace Content.Server.Cabinet private static void ClickLatchSound(ItemCabinetComponent comp) { - if (comp.DoorSound == null) return; - SoundSystem.Play(Filter.Pvs(comp.Owner), comp.DoorSound, comp.Owner, AudioHelpers.WithVariation(0.15f)); + if(comp.DoorSound.TryGetSound(out var doorSound)) + { + SoundSystem.Play(Filter.Pvs(comp.Owner), doorSound, comp.Owner, AudioHelpers.WithVariation(0.15f)); + } } } diff --git a/Content.Server/Cargo/Components/CargoConsoleComponent.cs b/Content.Server/Cargo/Components/CargoConsoleComponent.cs index 4a53d52b48..d975e159fa 100644 --- a/Content.Server/Cargo/Components/CargoConsoleComponent.cs +++ b/Content.Server/Cargo/Components/CargoConsoleComponent.cs @@ -6,6 +6,7 @@ using Content.Server.UserInterface; using Content.Shared.Cargo; using Content.Shared.Cargo.Components; using Content.Shared.Interaction; +using Content.Shared.Sound; using Robust.Server.GameObjects; using Robust.Shared.Audio; using Robust.Shared.GameObjects; @@ -59,6 +60,9 @@ namespace Content.Server.Cargo.Components [DataField("requestOnly")] private bool _requestOnly = false; + [DataField("errorSound")] + private SoundSpecifier _errorSound = new SoundPathSpecifier("/Audio/Effects/error.ogg"); + private bool Powered => !Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) || receiver.Powered; private CargoConsoleSystem _cargoConsoleSystem = default!; @@ -112,9 +116,10 @@ namespace Content.Server.Cargo.Components } if (!_cargoConsoleSystem.AddOrder(orders.Database.Id, msg.Requester, msg.Reason, msg.ProductId, - msg.Amount, _bankAccount.Id)) + msg.Amount, _bankAccount.Id) && + _errorSound.TryGetSound(out var errorSound)) { - SoundSystem.Play(Filter.Local(), "/Audio/Effects/error.ogg", Owner, AudioParams.Default); + SoundSystem.Play(Filter.Local(), errorSound, Owner, AudioParams.Default); } break; } @@ -137,14 +142,16 @@ namespace Content.Server.Cargo.Components break; var capacity = _cargoConsoleSystem.GetCapacity(orders.Database.Id); if ( - capacity.CurrentCapacity == capacity.MaxCapacity + (capacity.CurrentCapacity == capacity.MaxCapacity || capacity.CurrentCapacity + order.Amount > capacity.MaxCapacity || !_cargoConsoleSystem.CheckBalance(_bankAccount.Id, (-product.PointCost) * order.Amount) || !_cargoConsoleSystem.ApproveOrder(orders.Database.Id, msg.OrderNumber) - || !_cargoConsoleSystem.ChangeBalance(_bankAccount.Id, (-product.PointCost) * order.Amount) + || !_cargoConsoleSystem.ChangeBalance(_bankAccount.Id, (-product.PointCost) * order.Amount)) + && + _errorSound.TryGetSound(out var errorSound) ) { - SoundSystem.Play(Filter.Local(), "/Audio/Effects/error.ogg", Owner, AudioParams.Default); + SoundSystem.Play(Filter.Local(), errorSound, Owner, AudioParams.Default); break; } UpdateUIState(); diff --git a/Content.Server/Cargo/Components/CargoTelepadComponent.cs b/Content.Server/Cargo/Components/CargoTelepadComponent.cs index ba31eb3d13..099ec71451 100644 --- a/Content.Server/Cargo/Components/CargoTelepadComponent.cs +++ b/Content.Server/Cargo/Components/CargoTelepadComponent.cs @@ -2,10 +2,12 @@ using System.Collections.Generic; using Content.Server.Power.Components; using Content.Shared.Cargo; +using Content.Shared.Sound; using Robust.Server.GameObjects; using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.Player; +using Robust.Shared.Serialization.Manager.Attributes; namespace Content.Server.Cargo.Components { @@ -21,6 +23,7 @@ namespace Content.Server.Cargo.Components private const float TeleportDelay = 15f; private List _teleportQueue = new List(); private CargoTelepadState _currentState = CargoTelepadState.Unpowered; + [DataField("teleportSound")] private SoundSpecifier _teleportSound = new SoundPathSpecifier("/Audio/Machines/phasein.ogg"); public override void HandleMessage(ComponentMessage message, IComponent? component) { @@ -72,7 +75,8 @@ namespace Content.Server.Cargo.Components { if (!Deleted && !Owner.Deleted && _currentState == CargoTelepadState.Teleporting && _teleportQueue.Count > 0) { - SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/phasein.ogg", Owner, AudioParams.Default.WithVolume(-8f)); + if (_teleportSound.TryGetSound(out var teleportSound)) + SoundSystem.Play(Filter.Pvs(Owner), teleportSound, Owner, AudioParams.Default.WithVolume(-8f)); Owner.EntityManager.SpawnEntity(_teleportQueue[0].Product, Owner.Transform.Coordinates); _teleportQueue.RemoveAt(0); if (Owner.TryGetComponent(out var spriteComponent) && spriteComponent.LayerCount > 0) diff --git a/Content.Server/Chemistry/Components/ChemMasterComponent.cs b/Content.Server/Chemistry/Components/ChemMasterComponent.cs index 7ae9b4193f..e67d231ae8 100644 --- a/Content.Server/Chemistry/Components/ChemMasterComponent.cs +++ b/Content.Server/Chemistry/Components/ChemMasterComponent.cs @@ -14,6 +14,7 @@ using Content.Shared.Chemistry.Solution; using Content.Shared.Interaction; using Content.Shared.Notification.Managers; using Content.Shared.Random.Helpers; +using Content.Shared.Sound; using Content.Shared.Verbs; using Robust.Server.GameObjects; using Robust.Shared.Audio; @@ -21,6 +22,7 @@ using Robust.Shared.Containers; using Robust.Shared.GameObjects; using Robust.Shared.Localization; using Robust.Shared.Player; +using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; namespace Content.Server.Chemistry.Components @@ -46,6 +48,8 @@ namespace Content.Server.Chemistry.Components [ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(ChemMasterUiKey.Key); + [DataField("clickSound")] private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg"); + /// /// Called once per instance of this component. Gets references to any other components needed /// by this component and initializes it's UI and other data. @@ -417,7 +421,8 @@ namespace Content.Server.Chemistry.Components private void ClickSound() { - SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/machine_switch.ogg", Owner, AudioParams.Default.WithVolume(-2f)); + if(_clickSound.TryGetSound(out var sound)) + SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default.WithVolume(-2f)); } [Verb] diff --git a/Content.Server/Chemistry/Components/HyposprayComponent.cs b/Content.Server/Chemistry/Components/HyposprayComponent.cs index 0e2c688f47..fd3974fac6 100644 --- a/Content.Server/Chemistry/Components/HyposprayComponent.cs +++ b/Content.Server/Chemistry/Components/HyposprayComponent.cs @@ -5,6 +5,7 @@ using Content.Shared.Chemistry; using Content.Shared.Chemistry.Components; using Content.Shared.Chemistry.Reagent; using Content.Shared.Notification.Managers; +using Content.Shared.Sound; using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.Localization; @@ -27,6 +28,9 @@ namespace Content.Server.Chemistry.Components [ViewVariables(VVAccess.ReadWrite)] public ReagentUnit TransferAmount { get; set; } = ReagentUnit.New(5); + [DataField("InjectSound")] + private SoundSpecifier _injectSound = new SoundPathSpecifier("/Audio/Items/hypospray.ogg"); + [ComponentDependency] private readonly SolutionContainerComponent? _solution = default!; protected override void Initialize() @@ -68,7 +72,8 @@ namespace Content.Server.Chemistry.Components meleeSys.SendLunge(angle, user); } - SoundSystem.Play(Filter.Pvs(user), "/Audio/Items/hypospray.ogg", user); + if(_injectSound.TryGetSound(out var injectSound)) + SoundSystem.Play(Filter.Pvs(user), injectSound, user); var targetSolution = target.GetComponent(); diff --git a/Content.Server/Chemistry/Components/PillComponent.cs b/Content.Server/Chemistry/Components/PillComponent.cs index 770558ca59..5454744f0b 100644 --- a/Content.Server/Chemistry/Components/PillComponent.cs +++ b/Content.Server/Chemistry/Components/PillComponent.cs @@ -7,6 +7,7 @@ using Content.Shared.Chemistry.Reagent; using Content.Shared.Interaction; using Content.Shared.Interaction.Helpers; using Content.Shared.Notification.Managers; +using Content.Shared.Sound; using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.Localization; @@ -23,7 +24,7 @@ namespace Content.Server.Chemistry.Components [ViewVariables] [DataField("useSound")] - protected override string? UseSound { get; set; } = default; + protected override SoundSpecifier UseSound { get; set; } = default!; [ViewVariables] [DataField("trash")] @@ -98,9 +99,9 @@ namespace Content.Server.Chemistry.Components firstStomach.TryTransferSolution(split); - if (UseSound != null) + if (UseSound.TryGetSound(out var sound)) { - SoundSystem.Play(Filter.Pvs(trueTarget), UseSound, trueTarget, AudioParams.Default.WithVolume(-1f)); + SoundSystem.Play(Filter.Pvs(trueTarget), sound, trueTarget, AudioParams.Default.WithVolume(-1f)); } trueTarget.PopupMessage(user, Loc.GetString("pill-component-swallow-success-message")); diff --git a/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs b/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs index 938f009b8e..eb090d63e0 100644 --- a/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs +++ b/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs @@ -14,6 +14,7 @@ using Content.Shared.Chemistry.Reagent; using Content.Shared.Chemistry.Solution; using Content.Shared.Interaction; using Content.Shared.Notification.Managers; +using Content.Shared.Sound; using Content.Shared.Verbs; using JetBrains.Annotations; using Robust.Server.GameObjects; @@ -47,6 +48,8 @@ namespace Content.Server.Chemistry.Components [ViewVariables] private ContainerSlot _beakerContainer = default!; [ViewVariables] [DataField("pack")] private string _packPrototypeId = ""; + [DataField("clickSound")] private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg"); + [ViewVariables] private bool HasBeaker => _beakerContainer.ContainedEntity != null; [ViewVariables] private ReagentUnit _dispenseAmount = ReagentUnit.New(10); [UsedImplicitly] [ViewVariables] private SolutionContainerComponent? Solution => _beakerContainer.ContainedEntity?.GetComponent(); @@ -359,7 +362,8 @@ namespace Content.Server.Chemistry.Components private void ClickSound() { - SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/machine_switch.ogg", Owner, AudioParams.Default.WithVolume(-2f)); + if(_clickSound.TryGetSound(out var sound)) + SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default.WithVolume(-2f)); } [Verb] diff --git a/Content.Server/Chemistry/EntitySystems/ChemicalReactionSystem.cs b/Content.Server/Chemistry/EntitySystems/ChemicalReactionSystem.cs index f60c5417c7..b95ffa1207 100644 --- a/Content.Server/Chemistry/EntitySystems/ChemicalReactionSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/ChemicalReactionSystem.cs @@ -13,8 +13,8 @@ namespace Content.Server.Chemistry.EntitySystems { base.OnReaction(reaction, owner, unitReactions); - if (reaction.Sound != null) - SoundSystem.Play(Filter.Pvs(owner), reaction.Sound, owner.Transform.Coordinates); + if (reaction.Sound.TryGetSound(out var sound)) + SoundSystem.Play(Filter.Pvs(owner), sound, owner.Transform.Coordinates); } } } diff --git a/Content.Server/Chemistry/ReactionEffects/AreaReactionEffect.cs b/Content.Server/Chemistry/ReactionEffects/AreaReactionEffect.cs index ed9f447f0e..bf4ba13e66 100644 --- a/Content.Server/Chemistry/ReactionEffects/AreaReactionEffect.cs +++ b/Content.Server/Chemistry/ReactionEffects/AreaReactionEffect.cs @@ -4,6 +4,7 @@ using Content.Server.Chemistry.Components; using Content.Server.Coordinates.Helpers; using Content.Shared.Audio; using Content.Shared.Chemistry.Reaction; +using Content.Shared.Sound; using JetBrains.Annotations; using Robust.Server.GameObjects; using Robust.Shared.Audio; @@ -80,7 +81,7 @@ namespace Content.Server.Chemistry.ReactionEffects /// /// Sound that will get played when this reaction effect occurs. /// - [DataField("sound")] private string? _sound; + [DataField("sound")] private SoundSpecifier _sound = default!; protected AreaReactionEffect() { @@ -136,9 +137,9 @@ namespace Content.Server.Chemistry.ReactionEffects areaEffectComponent.TryAddSolution(solution); areaEffectComponent.Start(amount, _duration, _spreadDelay, _removeDelay); - if (!string.IsNullOrEmpty(_sound)) + if (_sound.TryGetSound(out var sound)) { - SoundSystem.Play(Filter.Pvs(solutionEntity), _sound, solutionEntity, AudioHelpers.WithVariation(0.125f)); + SoundSystem.Play(Filter.Pvs(solutionEntity), sound, solutionEntity, AudioHelpers.WithVariation(0.125f)); } } diff --git a/Content.Server/Construction/Completions/PlaySound.cs b/Content.Server/Construction/Completions/PlaySound.cs index 6d0f7de98c..8386d08678 100644 --- a/Content.Server/Construction/Completions/PlaySound.cs +++ b/Content.Server/Construction/Completions/PlaySound.cs @@ -2,6 +2,7 @@ using System.Threading.Tasks; using Content.Shared.Audio; using Content.Shared.Construction; +using Content.Shared.Sound; using JetBrains.Annotations; using Robust.Shared.Audio; using Robust.Shared.GameObjects; @@ -14,21 +15,12 @@ namespace Content.Server.Construction.Completions [DataDefinition] public class PlaySound : IGraphAction { - [DataField("soundCollection")] public string SoundCollection { get; private set; } = string.Empty; - [DataField("sound")] public string Sound { get; private set; } = string.Empty; + [DataField("sound")] public SoundSpecifier Sound { get; private set; } = default!; public async Task PerformAction(IEntity entity, IEntity? user) { - var sound = GetSound(); - - if (string.IsNullOrEmpty(sound)) return; - - SoundSystem.Play(Filter.Pvs(entity), sound, entity, AudioHelpers.WithVariation(0.125f)); - } - - private string GetSound() - { - return !string.IsNullOrEmpty(SoundCollection) ? AudioHelpers.GetRandomFileFromSoundCollection(SoundCollection) : Sound; + if(Sound.TryGetSound(out var sound)) + SoundSystem.Play(Filter.Pvs(entity), sound, entity, AudioHelpers.WithVariation(0.125f)); } } } diff --git a/Content.Server/Crayon/CrayonComponent.cs b/Content.Server/Crayon/CrayonComponent.cs index 13d0f4b90b..c06457ef13 100644 --- a/Content.Server/Crayon/CrayonComponent.cs +++ b/Content.Server/Crayon/CrayonComponent.cs @@ -9,6 +9,7 @@ using Content.Shared.Interaction; using Content.Shared.Interaction.Helpers; 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; @@ -31,7 +32,7 @@ namespace Content.Server.Crayon //TODO: useSound [DataField("useSound")] - private string? _useSound = string.Empty; + private SoundSpecifier _useSound = default!; [ViewVariables] public Color Color { get; set; } @@ -135,9 +136,9 @@ namespace Content.Server.Crayon appearance.SetData(CrayonVisuals.Rotation, eventArgs.User.Transform.LocalRotation); } - if (!string.IsNullOrEmpty(_useSound)) + if (_useSound.TryGetSound(out var useSound)) { - SoundSystem.Play(Filter.Pvs(Owner), _useSound, Owner, AudioHelpers.WithVariation(0.125f)); + SoundSystem.Play(Filter.Pvs(Owner), useSound, Owner, AudioHelpers.WithVariation(0.125f)); } // Decrease "Ammo" diff --git a/Content.Server/Cuffs/Components/CuffableComponent.cs b/Content.Server/Cuffs/Components/CuffableComponent.cs index 4293558043..6ed45b2cd1 100644 --- a/Content.Server/Cuffs/Components/CuffableComponent.cs +++ b/Content.Server/Cuffs/Components/CuffableComponent.cs @@ -232,13 +232,13 @@ namespace Content.Server.Cuffs.Components if (isOwner) { - if (cuff.StartBreakoutSound != null) - SoundSystem.Play(Filter.Pvs(Owner), cuff.StartBreakoutSound, Owner); + if (cuff.StartBreakoutSound.TryGetSound(out var startBreakoutSound)) + SoundSystem.Play(Filter.Pvs(Owner), startBreakoutSound, Owner); } else { - if (cuff.StartUncuffSound != null) - SoundSystem.Play(Filter.Pvs(Owner), cuff.StartUncuffSound, Owner); + if (cuff.StartUncuffSound.TryGetSound(out var startUncuffSound)) + SoundSystem.Play(Filter.Pvs(Owner), startUncuffSound, Owner); } var uncuffTime = isOwner ? cuff.BreakoutTime : cuff.UncuffTime; @@ -259,8 +259,8 @@ namespace Content.Server.Cuffs.Components if (result != DoAfterStatus.Cancelled) { - if (cuff.EndUncuffSound != null) - SoundSystem.Play(Filter.Pvs(Owner), cuff.EndUncuffSound, Owner); + if (cuff.EndUncuffSound.TryGetSound(out var endUncuffSound)) + SoundSystem.Play(Filter.Pvs(Owner), endUncuffSound, Owner); Container.ForceRemove(cuffsToRemove); cuffsToRemove.Transform.AttachToGridOrMap(); diff --git a/Content.Server/Cuffs/Components/HandcuffComponent.cs b/Content.Server/Cuffs/Components/HandcuffComponent.cs index bac2720916..f93bb55d6b 100644 --- a/Content.Server/Cuffs/Components/HandcuffComponent.cs +++ b/Content.Server/Cuffs/Components/HandcuffComponent.cs @@ -10,6 +10,7 @@ using Content.Shared.Interaction; using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Helpers; using Content.Shared.Notification.Managers; +using Content.Shared.Sound; using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.Localization; @@ -114,18 +115,18 @@ namespace Content.Server.Cuffs.Components } [DataField("startCuffSound")] - public string StartCuffSound { get; set; } = "/Audio/Items/Handcuffs/cuff_start.ogg"; + public SoundSpecifier StartCuffSound { get; set; } = new SoundPathSpecifier("/Audio/Items/Handcuffs/cuff_start.ogg"); - [DataField("endCuffSound")] public string EndCuffSound { get; set; } = "/Audio/Items/Handcuffs/cuff_end.ogg"; + [DataField("endCuffSound")] public SoundSpecifier EndCuffSound { get; set; } = new SoundPathSpecifier("/Audio/Items/Handcuffs/cuff_end.ogg"); [DataField("startBreakoutSound")] - public string StartBreakoutSound { get; set; } = "/Audio/Items/Handcuffs/cuff_breakout_start.ogg"; + public SoundSpecifier StartBreakoutSound { get; set; } = new SoundPathSpecifier("/Audio/Items/Handcuffs/cuff_breakout_start.ogg"); [DataField("startUncuffSound")] - public string StartUncuffSound { get; set; } = "/Audio/Items/Handcuffs/cuff_takeoff_start.ogg"; + public SoundSpecifier StartUncuffSound { get; set; } = new SoundPathSpecifier("/Audio/Items/Handcuffs/cuff_takeoff_start.ogg"); [DataField("endUncuffSound")] - public string EndUncuffSound { get; set; } = "/Audio/Items/Handcuffs/cuff_takeoff_end.ogg"; + public SoundSpecifier EndUncuffSound { get; set; } = new SoundPathSpecifier("/Audio/Items/Handcuffs/cuff_takeoff_end.ogg"); [DataField("color")] public Color Color { get; set; } = Color.White; @@ -184,8 +185,8 @@ namespace Content.Server.Cuffs.Components eventArgs.User.PopupMessage(Loc.GetString("handcuff-component-start-cuffing-target-message",("targetName", eventArgs.Target))); eventArgs.User.PopupMessage(eventArgs.Target, Loc.GetString("handcuff-component-start-cuffing-by-other-message",("otherName", eventArgs.User))); - if (StartCuffSound != null) - SoundSystem.Play(Filter.Pvs(Owner), StartCuffSound, Owner); + if (StartCuffSound.TryGetSound(out var startCuffSound)) + SoundSystem.Play(Filter.Pvs(Owner), startCuffSound, Owner); TryUpdateCuff(eventArgs.User, eventArgs.Target, cuffed); return true; @@ -222,8 +223,8 @@ namespace Content.Server.Cuffs.Components { if (cuffs.TryAddNewCuffs(user, Owner)) { - if (EndCuffSound != null) - SoundSystem.Play(Filter.Pvs(Owner), EndCuffSound, Owner); + if (EndCuffSound.TryGetSound(out var endCuffSound)) + SoundSystem.Play(Filter.Pvs(Owner), endCuffSound, Owner); user.PopupMessage(Loc.GetString("handcuff-component-cuff-other-success-message",("otherName", target))); target.PopupMessage(Loc.GetString("handcuff-component-cuff-by-other-success-message", ("otherName", user))); diff --git a/Content.Server/Damage/Components/DamageOnHighSpeedImpactComponent.cs b/Content.Server/Damage/Components/DamageOnHighSpeedImpactComponent.cs index 7d1b1a38ee..83a5ca51be 100644 --- a/Content.Server/Damage/Components/DamageOnHighSpeedImpactComponent.cs +++ b/Content.Server/Damage/Components/DamageOnHighSpeedImpactComponent.cs @@ -1,8 +1,9 @@ -using System; +using System; using Content.Server.Stunnable.Components; using Content.Shared.Audio; using Content.Shared.Damage; using Content.Shared.Damage.Components; +using Content.Shared.Sound; using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.IoC; @@ -32,7 +33,7 @@ namespace Content.Server.Damage.Components [DataField("factor")] public float Factor { get; set; } = 1f; [DataField("soundHit")] - public string SoundHit { get; set; } = ""; + public SoundSpecifier SoundHit { get; set; } = default!; [DataField("stunChance")] public float StunChance { get; set; } = 0.25f; [DataField("stunMinimumDamage")] @@ -51,8 +52,8 @@ namespace Content.Server.Damage.Components if (speed < MinimumSpeed) return; - if (!string.IsNullOrEmpty(SoundHit)) - SoundSystem.Play(Filter.Pvs(otherFixture.Body.Owner), SoundHit, otherFixture.Body.Owner, AudioHelpers.WithVariation(0.125f).WithVolume(-0.125f)); + if (SoundHit.TryGetSound(out var soundHit)) + SoundSystem.Play(Filter.Pvs(otherFixture.Body.Owner), soundHit, otherFixture.Body.Owner, AudioHelpers.WithVariation(0.125f).WithVolume(-0.125f)); if ((_gameTiming.CurTime - _lastHit).TotalSeconds < DamageCooldown) return; diff --git a/Content.Server/Destructible/Thresholds/Behaviors/PlaySoundBehavior.cs b/Content.Server/Destructible/Thresholds/Behaviors/PlaySoundBehavior.cs index 2e531a9d59..67fad570ed 100644 --- a/Content.Server/Destructible/Thresholds/Behaviors/PlaySoundBehavior.cs +++ b/Content.Server/Destructible/Thresholds/Behaviors/PlaySoundBehavior.cs @@ -1,5 +1,6 @@ using System; using Content.Shared.Audio; +using Content.Shared.Sound; using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.Player; @@ -14,17 +15,15 @@ namespace Content.Server.Destructible.Thresholds.Behaviors /// /// Sound played upon destruction. /// - [DataField("sound")] public string Sound { get; set; } = string.Empty; + [DataField("sound")] public SoundSpecifier Sound { get; set; } = default!; public void Execute(IEntity owner, DestructibleSystem system) { - if (string.IsNullOrEmpty(Sound)) + if (Sound.TryGetSound(out var sound)) { - return; - } - - var pos = owner.Transform.Coordinates; - SoundSystem.Play(Filter.Pvs(pos), Sound, pos, AudioHelpers.WithVariation(0.125f)); + var pos = owner.Transform.Coordinates; + SoundSystem.Play(Filter.Pvs(pos), sound, pos, AudioHelpers.WithVariation(0.125f)); + } } } } diff --git a/Content.Server/Destructible/Thresholds/Behaviors/PlaySoundCollectionBehavior.cs b/Content.Server/Destructible/Thresholds/Behaviors/PlaySoundCollectionBehavior.cs deleted file mode 100644 index e3ec950665..0000000000 --- a/Content.Server/Destructible/Thresholds/Behaviors/PlaySoundCollectionBehavior.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using Content.Shared.Audio; -using Robust.Shared.Audio; -using Robust.Shared.GameObjects; -using Robust.Shared.Player; -using Robust.Shared.Serialization.Manager.Attributes; - -namespace Content.Server.Destructible.Thresholds.Behaviors -{ - [Serializable] - [DataDefinition] - public class PlaySoundCollectionBehavior : IThresholdBehavior - { - /// - /// Sound collection from which to pick a random sound to play. - /// - [DataField("soundCollection")] - private string SoundCollection { get; set; } = string.Empty; - - public void Execute(IEntity owner, DestructibleSystem system) - { - if (string.IsNullOrEmpty(SoundCollection)) - { - return; - } - - var sound = AudioHelpers.GetRandomFileFromSoundCollection(SoundCollection); - var pos = owner.Transform.Coordinates; - - SoundSystem.Play(Filter.Pvs(pos), sound, pos, AudioHelpers.WithVariation(0.125f)); - } - } -} diff --git a/Content.Server/Dice/DiceComponent.cs b/Content.Server/Dice/DiceComponent.cs index 99bdf36eaa..09abb9ade4 100644 --- a/Content.Server/Dice/DiceComponent.cs +++ b/Content.Server/Dice/DiceComponent.cs @@ -64,7 +64,8 @@ namespace Content.Server.Dice public void PlayDiceEffect() { - SoundSystem.Play(Filter.Pvs(Owner), _sound.GetSound(), Owner, AudioParams.Default); + if(_sound.TryGetSound(out var sound)) + SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default); } void IActivate.Activate(ActivateEventArgs eventArgs) diff --git a/Content.Server/Disposal/Mailing/DisposalMailingUnitComponent.cs b/Content.Server/Disposal/Mailing/DisposalMailingUnitComponent.cs index bc202065f2..9059ba2aa9 100644 --- a/Content.Server/Disposal/Mailing/DisposalMailingUnitComponent.cs +++ b/Content.Server/Disposal/Mailing/DisposalMailingUnitComponent.cs @@ -24,6 +24,7 @@ using Content.Shared.Interaction; using Content.Shared.Movement; using Content.Shared.Notification; using Content.Shared.Notification.Managers; +using Content.Shared.Sound; using Content.Shared.Verbs; using Robust.Server.GameObjects; using Robust.Shared.Audio; @@ -88,6 +89,9 @@ namespace Content.Server.Disposal.Mailing [DataField("entryDelay")] private float _entryDelay = 0.5f; + [DataField("receivedMessageSound")] + private SoundSpecifier _receivedMessageSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg"); + /// /// Token used to cancel the automatic engage of a disposal unit /// after an entity enters it. @@ -432,8 +436,8 @@ namespace Content.Server.Disposal.Mailing break; case UiButton.Power: TogglePower(); - SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/machine_switch.ogg", Owner, AudioParams.Default.WithVolume(-2f)); - + if(_receivedMessageSound.TryGetSound(out var sound)) + SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default.WithVolume(-2f)); break; default: throw new ArgumentOutOfRangeException(); diff --git a/Content.Server/Disposal/Tube/Components/DisposalRouterComponent.cs b/Content.Server/Disposal/Tube/Components/DisposalRouterComponent.cs index 33c7a83feb..2f25c091d1 100644 --- a/Content.Server/Disposal/Tube/Components/DisposalRouterComponent.cs +++ b/Content.Server/Disposal/Tube/Components/DisposalRouterComponent.cs @@ -9,6 +9,7 @@ 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.Verbs; using Robust.Server.Console; using Robust.Server.GameObjects; @@ -20,6 +21,7 @@ using Robust.Shared.Localization; using Robust.Shared.Maths; using Robust.Shared.Physics; using Robust.Shared.Player; +using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; using static Content.Shared.Disposal.Components.SharedDisposalRouterComponent; @@ -42,6 +44,8 @@ namespace Content.Server.Disposal.Tube.Components [ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(DisposalRouterUiKey.Key); + [DataField("clickSound")] private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg"); + public override Direction NextDirection(DisposalHolderComponent holder) { var directions = ConnectableDirections(); @@ -150,7 +154,8 @@ namespace Content.Server.Disposal.Tube.Components private void ClickSound() { - SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/machine_switch.ogg", Owner, AudioParams.Default.WithVolume(-2f)); + if(_clickSound.TryGetSound(out var sound)) + SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default.WithVolume(-2f)); } /// diff --git a/Content.Server/Disposal/Tube/Components/DisposalTaggerComponent.cs b/Content.Server/Disposal/Tube/Components/DisposalTaggerComponent.cs index 3dde6dee78..d2e9b19b9c 100644 --- a/Content.Server/Disposal/Tube/Components/DisposalTaggerComponent.cs +++ b/Content.Server/Disposal/Tube/Components/DisposalTaggerComponent.cs @@ -6,6 +6,7 @@ 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.Verbs; using Robust.Server.Console; using Robust.Server.GameObjects; @@ -17,6 +18,7 @@ using Robust.Shared.Localization; using Robust.Shared.Maths; using Robust.Shared.Physics; using Robust.Shared.Player; +using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; using static Content.Shared.Disposal.Components.SharedDisposalTaggerComponent; @@ -39,6 +41,8 @@ namespace Content.Server.Disposal.Tube.Components [ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(DisposalTaggerUiKey.Key); + [DataField("clickSound")] private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg"); + public override Direction NextDirection(DisposalHolderComponent holder) { holder.Tags.Add(_tag); @@ -116,7 +120,8 @@ namespace Content.Server.Disposal.Tube.Components private void ClickSound() { - SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/machine_switch.ogg", Owner, AudioParams.Default.WithVolume(-2f)); + if(_clickSound.TryGetSound(out var sound)) + SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default.WithVolume(-2f)); } /// diff --git a/Content.Server/Disposal/Tube/Components/DisposalTubeComponent.cs b/Content.Server/Disposal/Tube/Components/DisposalTubeComponent.cs index 27e5d2b6e7..d247e01323 100644 --- a/Content.Server/Disposal/Tube/Components/DisposalTubeComponent.cs +++ b/Content.Server/Disposal/Tube/Components/DisposalTubeComponent.cs @@ -8,6 +8,7 @@ using Content.Shared.Disposal.Components; using Content.Shared.Movement; using Content.Shared.Notification; using Content.Shared.Notification.Managers; +using Content.Shared.Sound; using Content.Shared.Verbs; using Robust.Server.Console; using Robust.Server.GameObjects; @@ -37,7 +38,7 @@ namespace Content.Server.Disposal.Tube.Components private bool _connected; private bool _broken; [DataField("clangSound")] - private string _clangSound = "/Audio/Effects/clang.ogg"; + private SoundSpecifier _clangSound = new SoundPathSpecifier("/Audio/Effects/clang.ogg"); /// /// Container of entities that are currently inside this tube @@ -266,7 +267,8 @@ namespace Content.Server.Disposal.Tube.Components } _lastClang = _gameTiming.CurTime; - SoundSystem.Play(Filter.Pvs(Owner), _clangSound, Owner.Transform.Coordinates); + if(_clangSound.TryGetSound(out var clangSound)) + SoundSystem.Play(Filter.Pvs(Owner), clangSound, Owner.Transform.Coordinates); break; } } diff --git a/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs b/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs index c040169240..a6ec72f33f 100644 --- a/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs +++ b/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs @@ -20,6 +20,7 @@ using Content.Shared.DragDrop; using Content.Shared.Interaction; using Content.Shared.Movement; using Content.Shared.Notification.Managers; +using Content.Shared.Sound; using Content.Shared.Throwing; using Content.Shared.Verbs; using Robust.Server.GameObjects; @@ -78,6 +79,8 @@ namespace Content.Server.Disposal.Unit.Components [DataField("flushDelay")] private readonly TimeSpan _flushDelay = TimeSpan.FromSeconds(3); + [DataField("clickSound")] private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg"); + /// /// Delay from trying to enter disposals ourselves. /// @@ -377,7 +380,8 @@ namespace Content.Server.Disposal.Unit.Components break; case UiButton.Power: TogglePower(); - SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/machine_switch.ogg", Owner, AudioParams.Default.WithVolume(-2f)); + if(_clickSound.TryGetSound(out var clickSound)) + SoundSystem.Play(Filter.Pvs(Owner), clickSound, Owner, AudioParams.Default.WithVolume(-2f)); break; default: throw new ArgumentOutOfRangeException(); diff --git a/Content.Server/Doors/Components/AirlockComponent.cs b/Content.Server/Doors/Components/AirlockComponent.cs index ae59d4a65c..22df7199f9 100644 --- a/Content.Server/Doors/Components/AirlockComponent.cs +++ b/Content.Server/Doors/Components/AirlockComponent.cs @@ -8,12 +8,14 @@ using Content.Shared.Doors; using Content.Shared.Interaction; 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; using Robust.Shared.Localization; using Robust.Shared.Maths; using Robust.Shared.Player; +using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; using static Content.Shared.Wires.SharedWiresComponent; using static Content.Shared.Wires.SharedWiresComponent.WiresAction; @@ -92,6 +94,10 @@ namespace Content.Server.Doors.Components } } + [DataField("setBoltsDownSound")] private SoundSpecifier _setBoltsDownSound = new SoundPathSpecifier("/Audio/Machines/boltsdown.ogg"); + + [DataField("setBoltsUpSound")] private SoundSpecifier _setBoltsUpSound = new SoundPathSpecifier("/Audio/Machines/boltsup.ogg"); + private static readonly TimeSpan AutoCloseDelayFast = TimeSpan.FromSeconds(1); [ViewVariables(VVAccess.ReadWrite)] @@ -456,7 +462,16 @@ namespace Content.Server.Doors.Components BoltsDown = newBolts; - SoundSystem.Play(Filter.Broadcast(), newBolts ? "/Audio/Machines/boltsdown.ogg" : "/Audio/Machines/boltsup.ogg", Owner); + if (newBolts) + { + if (_setBoltsDownSound.TryGetSound(out var boltsDownSound)) + SoundSystem.Play(Filter.Broadcast(), boltsDownSound, Owner); + } + else + { + if (_setBoltsUpSound.TryGetSound(out var boltsUpSound)) + SoundSystem.Play(Filter.Broadcast(), boltsUpSound, Owner); + } } } } diff --git a/Content.Server/Doors/Components/ServerDoorComponent.cs b/Content.Server/Doors/Components/ServerDoorComponent.cs index b608dc5304..b6890bed14 100644 --- a/Content.Server/Doors/Components/ServerDoorComponent.cs +++ b/Content.Server/Doors/Components/ServerDoorComponent.cs @@ -14,6 +14,7 @@ using Content.Shared.Damage; using Content.Shared.Damage.Components; using Content.Shared.Doors; using Content.Shared.Interaction; +using Content.Shared.Sound; using Content.Shared.Tool; using Robust.Shared.Audio; using Robust.Shared.Containers; @@ -43,6 +44,9 @@ namespace Content.Server.Doors.Components [DataField("board")] private string? _boardPrototype; + [DataField("tryOpenDoorSound")] + private SoundSpecifier _tryOpenDoorSound = new SoundPathSpecifier("/Audio/Effects/bang.ogg"); + public override DoorState State { get => base.State; @@ -235,10 +239,10 @@ namespace Content.Server.Doors.Components { Open(); - if (user.TryGetComponent(out HandsComponent? hands) && hands.Count == 0) + if (user.TryGetComponent(out HandsComponent? hands) && hands.Count == 0 + && _tryOpenDoorSound.TryGetSound(out var tryOpenDoorSound)) { - SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/bang.ogg", Owner, - AudioParams.Default.WithVolume(-2)); + SoundSystem.Play(Filter.Pvs(Owner), tryOpenDoorSound, Owner, AudioParams.Default.WithVolume(-2)); } } else diff --git a/Content.Server/Explosion/Components/FlashExplosiveComponent.cs b/Content.Server/Explosion/Components/FlashExplosiveComponent.cs index 7762e3e8ab..5c0cff4dc8 100644 --- a/Content.Server/Explosion/Components/FlashExplosiveComponent.cs +++ b/Content.Server/Explosion/Components/FlashExplosiveComponent.cs @@ -1,6 +1,7 @@ using Content.Server.Flash.Components; using Content.Server.Storage.Components; using Content.Shared.Acts; +using Content.Shared.Sound; using Robust.Shared.Audio; using Robust.Shared.Containers; using Robust.Shared.GameObjects; @@ -22,7 +23,7 @@ namespace Content.Server.Explosion.Components [DataField("duration")] private float _duration = 8.0f; [DataField("sound")] - private string _sound = "/Audio/Effects/flash_bang.ogg"; + private SoundSpecifier _sound = new SoundPathSpecifier("/Audio/Effects/flash_bang.ogg"); [DataField("deleteOnFlash")] private bool _deleteOnFlash = true; @@ -35,9 +36,9 @@ namespace Content.Server.Explosion.Components FlashableComponent.FlashAreaHelper(Owner, _range, _duration); } - if (_sound != null) + if (_sound.TryGetSound(out var sound)) { - SoundSystem.Play(Filter.Pvs(Owner), _sound, Owner.Transform.Coordinates); + SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates); } if (_deleteOnFlash && !Owner.Deleted) diff --git a/Content.Server/Explosion/ExplosionHelper.cs b/Content.Server/Explosion/ExplosionHelper.cs index c85e1036fa..7f5e35e899 100644 --- a/Content.Server/Explosion/ExplosionHelper.cs +++ b/Content.Server/Explosion/ExplosionHelper.cs @@ -8,6 +8,7 @@ using Content.Shared.Acts; using Content.Shared.Interaction.Helpers; using Content.Shared.Maps; using Content.Shared.Physics; +using Content.Shared.Sound; using Content.Shared.Tag; using Robust.Server.GameObjects; using Robust.Server.Player; @@ -36,6 +37,7 @@ namespace Content.Server.Explosion /// private static readonly float LightBreakChance = 0.3f; private static readonly float HeavyBreakChance = 0.8f; + private static SoundSpecifier _explosionSound = new SoundPathSpecifier("/Audio/Effects/explosion.ogg"); private static bool IgnoreExplosivePassable(IEntity e) => e.HasTag("ExplosivePassable"); @@ -311,7 +313,8 @@ namespace Content.Server.Explosion var boundingBox = new Box2(epicenterMapPos - new Vector2(maxRange, maxRange), epicenterMapPos + new Vector2(maxRange, maxRange)); - SoundSystem.Play(Filter.Broadcast(), "/Audio/Effects/explosion.ogg", epicenter); + if(_explosionSound.TryGetSound(out var explosionSound)) + SoundSystem.Play(Filter.Broadcast(), explosionSound, epicenter); DamageEntitiesInRange(epicenter, boundingBox, devastationRange, heavyImpactRange, maxRange, mapId); var mapGridsNear = mapManager.FindGridsIntersecting(mapId, boundingBox); diff --git a/Content.Server/Extinguisher/FireExtinguisherComponent.cs b/Content.Server/Extinguisher/FireExtinguisherComponent.cs index a09bdf4e20..19f573d3ba 100644 --- a/Content.Server/Extinguisher/FireExtinguisherComponent.cs +++ b/Content.Server/Extinguisher/FireExtinguisherComponent.cs @@ -5,10 +5,12 @@ using Content.Shared.Chemistry.Solution.Components; using Content.Shared.Interaction; using Content.Shared.Notification; using Content.Shared.Notification.Managers; +using Content.Shared.Sound; using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.Localization; using Robust.Shared.Player; +using Robust.Shared.Serialization.Manager.Attributes; #nullable enable @@ -19,6 +21,8 @@ namespace Content.Server.Extinguisher { public override string Name => "FireExtinguisher"; + [DataField("refillSound")] SoundSpecifier _refillSound = new SoundPathSpecifier("/Audio/Effects/refill.ogg"); + // Higher priority than sprays. int IAfterInteract.Priority => 1; @@ -40,7 +44,8 @@ namespace Content.Server.Extinguisher var drained = targetSolution.Drain(trans); container.TryAddSolution(drained); - SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/refill.ogg", Owner); + if(_refillSound.TryGetSound(out var sound)) + SoundSystem.Play(Filter.Pvs(Owner), sound, Owner); eventArgs.Target.PopupMessage(eventArgs.User, Loc.GetString("fire-extinguisher-component-after-interact-refilled-message",("owner", Owner))); } diff --git a/Content.Server/Flash/Components/FlashComponent.cs b/Content.Server/Flash/Components/FlashComponent.cs index 3b2d77f70e..47b93c14d8 100644 --- a/Content.Server/Flash/Components/FlashComponent.cs +++ b/Content.Server/Flash/Components/FlashComponent.cs @@ -1,3 +1,4 @@ +using Content.Shared.Sound; using Robust.Shared.GameObjects; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; @@ -29,6 +30,10 @@ namespace Content.Server.Flash.Components [ViewVariables(VVAccess.ReadWrite)] public float SlowTo { get; set; } = 0.5f; + [ViewVariables(VVAccess.ReadWrite)] + [DataField("sound")] + public SoundSpecifier Sound { get; set; } = new SoundPathSpecifier("/Audio/Weapons/flash.ogg"); + public bool Flashing; public bool HasUses => Uses > 0; diff --git a/Content.Server/Flash/Components/FlashableComponent.cs b/Content.Server/Flash/Components/FlashableComponent.cs index 10aa9baf52..0653114aa7 100644 --- a/Content.Server/Flash/Components/FlashableComponent.cs +++ b/Content.Server/Flash/Components/FlashableComponent.cs @@ -2,6 +2,7 @@ using System; using Content.Shared.Flash; using Content.Shared.Interaction.Helpers; using Content.Shared.Physics; +using Content.Shared.Sound; using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.IoC; @@ -31,7 +32,7 @@ namespace Content.Server.Flash.Components return new FlashComponentState(_duration, _lastFlash); } - public static void FlashAreaHelper(IEntity source, float range, float duration, string? sound = null) + public static void FlashAreaHelper(IEntity source, float range, float duration, SoundSpecifier? sound = null) { foreach (var entity in IoCManager.Resolve().GetEntitiesInRange(source.Transform.Coordinates, range)) { @@ -41,9 +42,9 @@ namespace Content.Server.Flash.Components flashable.Flash(duration); } - if (!string.IsNullOrEmpty(sound)) + if (sound != null && sound.TryGetSound(out var soundName)) { - SoundSystem.Play(Filter.Pvs(source), sound, source.Transform.Coordinates); + SoundSystem.Play(Filter.Pvs(source), soundName, source.Transform.Coordinates); } } } diff --git a/Content.Server/Flash/FlashSystem.cs b/Content.Server/Flash/FlashSystem.cs index 80995e48a3..bb8746def1 100644 --- a/Content.Server/Flash/FlashSystem.cs +++ b/Content.Server/Flash/FlashSystem.cs @@ -1,4 +1,4 @@ -using Content.Server.Flash.Components; +using Content.Server.Flash.Components; using Content.Server.Stunnable.Components; using Content.Server.Weapon.Melee; using Content.Shared.Examine; @@ -93,8 +93,8 @@ namespace Content.Server.Flash }); } - SoundSystem.Play(Filter.Pvs(comp.Owner), "/Audio/Weapons/flash.ogg", comp.Owner.Transform.Coordinates, - AudioParams.Default); + if(comp.Sound.TryGetSound(out var sound)) + SoundSystem.Play(Filter.Pvs(comp.Owner), sound, comp.Owner.Transform.Coordinates, AudioParams.Default); return true; } diff --git a/Content.Server/Fluids/Components/BucketComponent.cs b/Content.Server/Fluids/Components/BucketComponent.cs index 2774549cb8..2f3521ab17 100644 --- a/Content.Server/Fluids/Components/BucketComponent.cs +++ b/Content.Server/Fluids/Components/BucketComponent.cs @@ -8,6 +8,7 @@ using Content.Shared.Interaction; using Content.Shared.Interaction.Helpers; using Content.Shared.Notification; using Content.Shared.Notification.Managers; +using Content.Shared.Sound; using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.Localization; @@ -43,7 +44,7 @@ namespace Content.Server.Fluids.Components : ReagentUnit.Zero; [DataField("sound")] - private string? _sound = "/Audio/Effects/Fluids/watersplash.ogg"; + private SoundSpecifier _sound = new SoundPathSpecifier("/Audio/Effects/Fluids/watersplash.ogg"); /// protected override void Initialize() @@ -114,9 +115,9 @@ namespace Content.Server.Fluids.Components return false; } - if (_sound != null) + if (_sound.TryGetSound(out var sound)) { - SoundSystem.Play(Filter.Pvs(Owner), _sound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), sound, Owner); } return true; diff --git a/Content.Server/Fluids/Components/MopComponent.cs b/Content.Server/Fluids/Components/MopComponent.cs index fa0c7ec11e..52c45cb1ad 100644 --- a/Content.Server/Fluids/Components/MopComponent.cs +++ b/Content.Server/Fluids/Components/MopComponent.cs @@ -7,6 +7,7 @@ using Content.Shared.Interaction; using Content.Shared.Interaction.Helpers; using Content.Shared.Notification; using Content.Shared.Notification.Managers; +using Content.Shared.Sound; using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.Localization; @@ -54,7 +55,7 @@ namespace Content.Server.Fluids.Components public ReagentUnit PickupAmount { get; } = ReagentUnit.New(5); [DataField("pickup_sound")] - private string? _pickupSound = "/Audio/Effects/Fluids/slosh.ogg"; + private SoundSpecifier _pickupSound = new SoundPathSpecifier("/Audio/Effects/Fluids/slosh.ogg"); /// /// Multiplier for the do_after delay for how fast the mop works. @@ -163,9 +164,9 @@ namespace Content.Server.Fluids.Components contents.SplitSolution(transferAmount); } - if (!string.IsNullOrWhiteSpace(_pickupSound)) + if (_pickupSound.TryGetSound(out var pickupSound)) { - SoundSystem.Play(Filter.Pvs(Owner), _pickupSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), pickupSound, Owner); } return true; diff --git a/Content.Server/Fluids/Components/PuddleComponent.cs b/Content.Server/Fluids/Components/PuddleComponent.cs index b54d4bdba0..103b733267 100644 --- a/Content.Server/Fluids/Components/PuddleComponent.cs +++ b/Content.Server/Fluids/Components/PuddleComponent.cs @@ -11,6 +11,7 @@ using Content.Shared.Examine; using Content.Shared.Maps; using Content.Shared.Physics; using Content.Shared.Slippery; +using Content.Shared.Sound; using Robust.Server.GameObjects; using Robust.Shared.Audio; using Robust.Shared.GameObjects; @@ -71,7 +72,7 @@ namespace Content.Server.Fluids.Components public float EvaporateTime { get; private set; } = 5f; [DataField("spill_sound")] - private string _spillSound = "/Audio/Effects/Fluids/splat.ogg"; + private SoundSpecifier _spillSound = new SoundPathSpecifier("/Audio/Effects/Fluids/splat.ogg"); /// /// Whether or not this puddle is currently overflowing onto its neighbors @@ -189,7 +190,8 @@ namespace Content.Server.Fluids.Components return true; } - SoundSystem.Play(Filter.Pvs(Owner), _spillSound, Owner.Transform.Coordinates); + if(_spillSound.TryGetSound(out var spillSound)) + SoundSystem.Play(Filter.Pvs(Owner), spillSound, Owner.Transform.Coordinates); return true; } diff --git a/Content.Server/Fluids/Components/SprayComponent.cs b/Content.Server/Fluids/Components/SprayComponent.cs index a843ba0bbc..105f4537e2 100644 --- a/Content.Server/Fluids/Components/SprayComponent.cs +++ b/Content.Server/Fluids/Components/SprayComponent.cs @@ -10,6 +10,7 @@ using Content.Shared.Fluids; using Content.Shared.Interaction; using Content.Shared.Interaction.Events; using Content.Shared.Notification.Managers; +using Content.Shared.Sound; using Content.Shared.Vapor; using Robust.Server.GameObjects; using Robust.Shared.Audio; @@ -35,8 +36,6 @@ namespace Content.Server.Fluids.Components [DataField("transferAmount")] private ReagentUnit _transferAmount = ReagentUnit.New(10); - [DataField("spraySound")] - private string? _spraySound; [DataField("sprayVelocity")] private float _sprayVelocity = 1.5f; [DataField("sprayAliveTime")] @@ -78,7 +77,8 @@ namespace Content.Server.Fluids.Components set => _sprayVelocity = value; } - public string? SpraySound => _spraySound; + [DataField("spraySound")] + public SoundSpecifier SpraySound { get; } = default!; public ReagentUnit CurrentVolume => Owner.GetComponentOrNull()?.CurrentVolume ?? ReagentUnit.Zero; @@ -172,9 +172,9 @@ namespace Content.Server.Fluids.Components } //Play sound - if (!string.IsNullOrEmpty(_spraySound)) + if (SpraySound.TryGetSound(out var spraySound)) { - SoundSystem.Play(Filter.Pvs(Owner), _spraySound, Owner, AudioHelpers.WithVariation(0.125f)); + SoundSystem.Play(Filter.Pvs(Owner), spraySound, Owner, AudioHelpers.WithVariation(0.125f)); } _lastUseTime = curTime; diff --git a/Content.Server/GameTicking/Rules/RuleSuspicion.cs b/Content.Server/GameTicking/Rules/RuleSuspicion.cs index 9b0bb0a5ce..e1080ef625 100644 --- a/Content.Server/GameTicking/Rules/RuleSuspicion.cs +++ b/Content.Server/GameTicking/Rules/RuleSuspicion.cs @@ -9,6 +9,7 @@ using Content.Server.Suspicion.Roles; using Content.Shared; using Content.Shared.CCVar; using Content.Shared.MobState; +using Content.Shared.Sound; using Robust.Server.Player; using Robust.Shared.Audio; using Robust.Shared.Configuration; @@ -16,6 +17,7 @@ using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Player; +using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Timing; using Timer = Robust.Shared.Timing.Timer; @@ -33,6 +35,8 @@ namespace Content.Server.GameTicking.Rules [Dependency] private readonly IConfigurationManager _cfg = default!; [Dependency] private readonly IGameTiming _timing = default!; + [DataField("addedSound")] private SoundSpecifier _addedSound = new SoundPathSpecifier("/Audio/Misc/tatoralert.ogg"); + private readonly CancellationTokenSource _checkTimerCancel = new(); private TimeSpan _endTime; @@ -49,7 +53,9 @@ namespace Content.Server.GameTicking.Rules var filter = Filter.Empty() .AddWhere(session => ((IPlayerSession)session).ContentData()?.Mind?.HasRole() ?? false); - SoundSystem.Play(filter, "/Audio/Misc/tatoralert.ogg", AudioParams.Default); + + if(_addedSound.TryGetSound(out var addedSound)) + SoundSystem.Play(filter, addedSound, AudioParams.Default); EntitySystem.Get().EndTime = _endTime; EntitySystem.Get().AccessType = DoorSystem.AccessTypes.AllowAllNoExternal; diff --git a/Content.Server/GameTicking/Rules/RuleTraitor.cs b/Content.Server/GameTicking/Rules/RuleTraitor.cs index 4bf40c835c..ca697bc3d8 100644 --- a/Content.Server/GameTicking/Rules/RuleTraitor.cs +++ b/Content.Server/GameTicking/Rules/RuleTraitor.cs @@ -1,11 +1,13 @@ using Content.Server.Chat.Managers; using Content.Server.Players; using Content.Server.Traitor; +using Content.Shared.Sound; using Robust.Server.Player; using Robust.Shared.Audio; using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Player; +using Robust.Shared.Serialization.Manager.Attributes; namespace Content.Server.GameTicking.Rules { @@ -13,13 +15,17 @@ namespace Content.Server.GameTicking.Rules { [Dependency] private readonly IChatManager _chatManager = default!; + [DataField("addedSound")] private SoundSpecifier _addedSound = new SoundPathSpecifier("/Audio/Misc/tatoralert.ogg"); + public override void Added() { _chatManager.DispatchServerAnnouncement(Loc.GetString("rule-traitor-added-announcement")); var filter = Filter.Empty() .AddWhere(session => ((IPlayerSession)session).ContentData()?.Mind?.HasRole() ?? false); - SoundSystem.Play(filter, "/Audio/Misc/tatoralert.ogg", AudioParams.Default); + + if(_addedSound.TryGetSound(out var addedSound)) + SoundSystem.Play(filter, addedSound, AudioParams.Default); } } } diff --git a/Content.Server/Gravity/EntitySystems/GravitySystem.cs b/Content.Server/Gravity/EntitySystems/GravitySystem.cs index 3141128599..92fa41fa92 100644 --- a/Content.Server/Gravity/EntitySystems/GravitySystem.cs +++ b/Content.Server/Gravity/EntitySystems/GravitySystem.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using Content.Server.Camera; using Content.Shared.Gravity; +using Content.Shared.Sound; using JetBrains.Annotations; using Robust.Server.Player; using Robust.Shared.Audio; @@ -108,7 +109,7 @@ namespace Content.Server.Gravity.EntitySystems comp.Enabled = true; var gridId = comp.Owner.Transform.GridID; - ScheduleGridToShake(gridId, ShakeTimes); + ScheduleGridToShake(gridId, ShakeTimes, comp); var message = new GravityChangedMessage(gridId, true); RaiseLocalEvent(message); @@ -120,13 +121,13 @@ namespace Content.Server.Gravity.EntitySystems comp.Enabled = false; var gridId = comp.Owner.Transform.GridID; - ScheduleGridToShake(gridId, ShakeTimes); + ScheduleGridToShake(gridId, ShakeTimes, comp); var message = new GravityChangedMessage(gridId, false); RaiseLocalEvent(message); } - private void ScheduleGridToShake(GridId gridId, uint shakeTimes) + private void ScheduleGridToShake(GridId gridId, uint shakeTimes, GravityComponent comp) { if (!_gridsToShake.Keys.Contains(gridId)) { @@ -140,8 +141,11 @@ namespace Content.Server.Gravity.EntitySystems foreach (var player in _playerManager.GetAllPlayers()) { if (player.AttachedEntity == null - || player.AttachedEntity.Transform.GridID != gridId) continue; - SoundSystem.Play(Filter.Pvs(player.AttachedEntity), "/Audio/Effects/alert.ogg", player.AttachedEntity); + || player.AttachedEntity.Transform.GridID != gridId) + continue; + + if(comp.GravityShakeSound.TryGetSound(out var gravityShakeSound)) + SoundSystem.Play(Filter.Pvs(player.AttachedEntity), gravityShakeSound, player.AttachedEntity); } } diff --git a/Content.Server/Hands/Components/HandsComponent.cs b/Content.Server/Hands/Components/HandsComponent.cs index 61a4b53661..4a322cb525 100644 --- a/Content.Server/Hands/Components/HandsComponent.cs +++ b/Content.Server/Hands/Components/HandsComponent.cs @@ -13,6 +13,7 @@ using Content.Shared.Hands.Components; using Content.Shared.Notification.Managers; using Content.Shared.Physics.Pull; using Content.Shared.Pulling.Components; +using Content.Shared.Sound; using Robust.Server.GameObjects; using Robust.Shared.Audio; using Robust.Shared.Containers; @@ -23,6 +24,7 @@ using Robust.Shared.Map; using Robust.Shared.Network; using Robust.Shared.Player; using Robust.Shared.Players; +using Robust.Shared.Serialization.Manager.Attributes; namespace Content.Server.Hands.Components { @@ -34,6 +36,8 @@ namespace Content.Server.Hands.Components { [Dependency] private readonly IEntitySystemManager _entitySystemManager = default!; + [DataField("disarmedSound")] SoundSpecifier _disarmedSound = new SoundPathSpecifier("/Audio/Effects/thudswoosh.ogg"); + int IDisarmedAct.Priority => int.MaxValue; // We want this to be the last disarm act to run. public override void HandleMessage(ComponentMessage message, IComponent? component) @@ -175,8 +179,8 @@ namespace Content.Server.Hands.Components if (source != null) { - SoundSystem.Play(Filter.Pvs(source), "/Audio/Effects/thudswoosh.ogg", source, - AudioHelpers.WithVariation(0.025f)); + if(_disarmedSound.TryGetSound(out var disarmedSound)) + SoundSystem.Play(Filter.Pvs(source), disarmedSound, source, AudioHelpers.WithVariation(0.025f)); if (target != null) { diff --git a/Content.Server/Kitchen/Components/KitchenSpikeComponent.cs b/Content.Server/Kitchen/Components/KitchenSpikeComponent.cs index 8e5c27d0fd..7144e30f2f 100644 --- a/Content.Server/Kitchen/Components/KitchenSpikeComponent.cs +++ b/Content.Server/Kitchen/Components/KitchenSpikeComponent.cs @@ -161,8 +161,8 @@ namespace Content.Server.Kitchen.Components // TODO: Need to be able to leave them on the spike to do DoT, see ss13. victim.Delete(); - if (SpikeSound != null) - SoundSystem.Play(Filter.Pvs(Owner), SpikeSound, Owner); + if (SpikeSound.TryGetSound(out var spikeSound)) + SoundSystem.Play(Filter.Pvs(Owner), spikeSound, Owner); } SuicideKind ISuicideAct.Suicide(IEntity victim, IChatManager chat) diff --git a/Content.Server/Kitchen/Components/MicrowaveComponent.cs b/Content.Server/Kitchen/Components/MicrowaveComponent.cs index a6453558c5..f6132c1e96 100644 --- a/Content.Server/Kitchen/Components/MicrowaveComponent.cs +++ b/Content.Server/Kitchen/Components/MicrowaveComponent.cs @@ -24,6 +24,7 @@ using Content.Shared.Kitchen.Components; using Content.Shared.Notification; using Content.Shared.Notification.Managers; using Content.Shared.Power; +using Content.Shared.Sound; using Robust.Server.GameObjects; using Robust.Shared.Audio; using Robust.Shared.Containers; @@ -50,12 +51,14 @@ namespace Content.Server.Kitchen.Components [DataField("failureResult")] private string _badRecipeName = "FoodBadRecipe"; [DataField("beginCookingSound")] - private string _startCookingSound = "/Audio/Machines/microwave_start_beep.ogg"; + private SoundSpecifier _startCookingSound = new SoundPathSpecifier("/Audio/Machines/microwave_start_beep.ogg"); [DataField("foodDoneSound")] - private string _cookingCompleteSound = "/Audio/Machines/microwave_done_beep.ogg"; -#endregion + private SoundSpecifier _cookingCompleteSound = new SoundPathSpecifier("/Audio/Machines/microwave_done_beep.ogg"); + [DataField("clickSound")] + private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg"); + #endregion YAMLSERIALIZE -[ViewVariables] + [ViewVariables] private bool _busy = false; private bool _broken; @@ -335,7 +338,8 @@ namespace Content.Server.Kitchen.Components } SetAppearance(MicrowaveVisualState.Cooking); - SoundSystem.Play(Filter.Pvs(Owner), _startCookingSound, Owner, AudioParams.Default); + if(_startCookingSound.TryGetSound(out var startCookingSound)) + SoundSystem.Play(Filter.Pvs(Owner), startCookingSound, Owner, AudioParams.Default); Owner.SpawnTimer((int)(_currentCookTimerTime * _cookTimeMultiplier), (Action)(() => { if (_lostPower) @@ -362,7 +366,9 @@ namespace Content.Server.Kitchen.Components Owner.EntityManager.SpawnEntity(_badRecipeName, Owner.Transform.Coordinates); } } - SoundSystem.Play(Filter.Pvs(Owner), _cookingCompleteSound, Owner, AudioParams.Default.WithVolume(-1f)); + + if(_cookingCompleteSound.TryGetSound(out var cookingCompleteSound)) + SoundSystem.Play(Filter.Pvs(Owner), cookingCompleteSound, Owner, AudioParams.Default.WithVolume(-1f)); SetAppearance(MicrowaveVisualState.Idle); _busy = false; @@ -495,7 +501,8 @@ namespace Content.Server.Kitchen.Components private void ClickSound() { - SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/machine_switch.ogg",Owner,AudioParams.Default.WithVolume(-2f)); + if(_clickSound.TryGetSound(out var clickSound)) + SoundSystem.Play(Filter.Pvs(Owner), clickSound, Owner,AudioParams.Default.WithVolume(-2f)); } SuicideKind ISuicideAct.Suicide(IEntity victim, IChatManager chat) diff --git a/Content.Server/Kitchen/Components/ReagentGrinderComponent.cs b/Content.Server/Kitchen/Components/ReagentGrinderComponent.cs index 4a9ff99166..c6e202cb63 100644 --- a/Content.Server/Kitchen/Components/ReagentGrinderComponent.cs +++ b/Content.Server/Kitchen/Components/ReagentGrinderComponent.cs @@ -13,6 +13,7 @@ using Content.Shared.Kitchen.Components; using Content.Shared.Notification; using Content.Shared.Notification.Managers; using Content.Shared.Random.Helpers; +using Content.Shared.Sound; using Content.Shared.Tag; using Robust.Server.GameObjects; using Robust.Shared.Audio; @@ -67,6 +68,9 @@ namespace Content.Server.Kitchen.Components //YAML serialization vars [ViewVariables(VVAccess.ReadWrite)] [DataField("chamberCapacity")] private int _storageCap = 16; [ViewVariables(VVAccess.ReadWrite)] [DataField("workTime")] private int _workTime = 3500; //3.5 seconds, completely arbitrary for now. + [DataField("clickSound")] private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg"); + [DataField("grindSound")] private SoundSpecifier _grindSound = new SoundPathSpecifier("/Audio/Machines/blender.ogg"); + [DataField("juiceSound")] private SoundSpecifier _juiceSound = new SoundPathSpecifier("/Audio/Machines/juicer.ogg"); protected override void Initialize() { @@ -163,7 +167,8 @@ namespace Content.Server.Kitchen.Components private void ClickSound() { - SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/machine_switch.ogg", Owner, AudioParams.Default.WithVolume(-2f)); + if(_clickSound.TryGetSound(out var sound)) + SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default.WithVolume(-2f)); } private void SetAppearance() @@ -327,7 +332,8 @@ namespace Content.Server.Kitchen.Components switch (program) { case GrinderProgram.Grind: - SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/blender.ogg", Owner, AudioParams.Default); + if(_grindSound.TryGetSound(out var grindSound)) + SoundSystem.Play(Filter.Pvs(Owner), grindSound, Owner, AudioParams.Default); //Get each item inside the chamber and get the reagents it contains. Transfer those reagents to the beaker, given we have one in. Owner.SpawnTimer(_workTime, (Action) (() => { @@ -348,7 +354,8 @@ namespace Content.Server.Kitchen.Components break; case GrinderProgram.Juice: - SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/juicer.ogg", Owner, AudioParams.Default); + if(_juiceSound.TryGetSound(out var juiceSound)) + SoundSystem.Play(Filter.Pvs(Owner), juiceSound, Owner, AudioParams.Default); Owner.SpawnTimer(_workTime, (Action) (() => { foreach (var item in _chamber.ContainedEntities.ToList()) diff --git a/Content.Server/Light/Components/ExpendableLightComponent.cs b/Content.Server/Light/Components/ExpendableLightComponent.cs index 1f1c4a9df5..0a834773e1 100644 --- a/Content.Server/Light/Components/ExpendableLightComponent.cs +++ b/Content.Server/Light/Components/ExpendableLightComponent.cs @@ -106,9 +106,9 @@ namespace Content.Server.Light.Components loopingSound.Play(LoopedSound, LoopedSoundParams); } - if (LitSound != string.Empty) + if (LitSound.TryGetSound(out var litSound)) { - SoundSystem.Play(Filter.Pvs(Owner), LitSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), litSound, Owner); } if (IconStateLit != string.Empty) @@ -126,9 +126,9 @@ namespace Content.Server.Light.Components default: case ExpendableLightState.Dead: - if (DieSound != string.Empty) + if (DieSound.TryGetSound(out var dieSound)) { - SoundSystem.Play(Filter.Pvs(Owner), DieSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), dieSound, Owner); } if (LoopedSound != string.Empty && Owner.TryGetComponent(out var loopSound)) diff --git a/Content.Server/Light/Components/HandheldLightComponent.cs b/Content.Server/Light/Components/HandheldLightComponent.cs index a2bc02aed3..35dc969031 100644 --- a/Content.Server/Light/Components/HandheldLightComponent.cs +++ b/Content.Server/Light/Components/HandheldLightComponent.cs @@ -13,6 +13,7 @@ using Content.Shared.Interaction.Events; using Content.Shared.Light.Component; using Content.Shared.Notification.Managers; using Content.Shared.Rounding; +using Content.Shared.Sound; using Content.Shared.Verbs; using JetBrains.Annotations; using Robust.Server.GameObjects; @@ -46,9 +47,9 @@ namespace Content.Server.Light.Components [ViewVariables] protected override bool HasCell => _cellSlot.HasCell; - [ViewVariables(VVAccess.ReadWrite)] [DataField("turnOnSound")] public string? TurnOnSound = "/Audio/Items/flashlight_toggle.ogg"; - [ViewVariables(VVAccess.ReadWrite)] [DataField("turnOnFailSound")] public string? TurnOnFailSound = "/Audio/Machines/button.ogg"; - [ViewVariables(VVAccess.ReadWrite)] [DataField("turnOffSound")] public string? TurnOffSound = "/Audio/Items/flashlight_toggle.ogg"; + [ViewVariables(VVAccess.ReadWrite)] [DataField("turnOnSound")] public SoundSpecifier TurnOnSound = new SoundPathSpecifier("/Audio/Items/flashlight_toggle.ogg"); + [ViewVariables(VVAccess.ReadWrite)] [DataField("turnOnFailSound")] public SoundSpecifier TurnOnFailSound = new SoundPathSpecifier("/Audio/Machines/button.ogg"); + [ViewVariables(VVAccess.ReadWrite)] [DataField("turnOffSound")] public SoundSpecifier TurnOffSound = new SoundPathSpecifier("/Audio/Items/flashlight_toggle.ogg"); [ComponentDependency] private readonly ItemActionsComponent? _itemActions = null; @@ -120,9 +121,9 @@ namespace Content.Server.Light.Components UpdateLightAction(); Owner.EntityManager.EventBus.QueueEvent(EventSource.Local, new DeactivateHandheldLightMessage(this)); - if (makeNoise) + if (makeNoise && TurnOffSound.TryGetSound(out var turnOffSound)) { - if (TurnOffSound != null) SoundSystem.Play(Filter.Pvs(Owner), TurnOffSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), turnOffSound, Owner); } return true; @@ -137,7 +138,8 @@ namespace Content.Server.Light.Components if (Cell == null) { - if (TurnOnFailSound != null) SoundSystem.Play(Filter.Pvs(Owner), TurnOnFailSound, Owner); + if (TurnOnFailSound.TryGetSound(out var turnOnFailSound)) + SoundSystem.Play(Filter.Pvs(Owner), turnOnFailSound, Owner); Owner.PopupMessage(user, Loc.GetString("handheld-light-component-cell-missing-message")); UpdateLightAction(); return false; @@ -148,7 +150,8 @@ namespace Content.Server.Light.Components // Simple enough. if (Wattage > Cell.CurrentCharge) { - if (TurnOnFailSound != null) SoundSystem.Play(Filter.Pvs(Owner), TurnOnFailSound, Owner); + if (TurnOnFailSound.TryGetSound(out var turnOnFailSound)) + SoundSystem.Play(Filter.Pvs(Owner), turnOnFailSound, Owner); Owner.PopupMessage(user, Loc.GetString("handheld-light-component-cell-dead-message")); UpdateLightAction(); return false; @@ -159,7 +162,8 @@ namespace Content.Server.Light.Components SetState(true); Owner.EntityManager.EventBus.QueueEvent(EventSource.Local, new ActivateHandheldLightMessage(this)); - if (TurnOnSound != null) SoundSystem.Play(Filter.Pvs(Owner), TurnOnSound, Owner); + if (TurnOnSound.TryGetSound(out var turnOnSound)) + SoundSystem.Play(Filter.Pvs(Owner), turnOnSound, Owner); return true; } diff --git a/Content.Server/Light/Components/LightBulbComponent.cs b/Content.Server/Light/Components/LightBulbComponent.cs index 68d849a808..a00af4352d 100644 --- a/Content.Server/Light/Components/LightBulbComponent.cs +++ b/Content.Server/Light/Components/LightBulbComponent.cs @@ -2,6 +2,7 @@ using System; using Content.Shared.Acts; using Content.Shared.Audio; +using Content.Shared.Sound; using Content.Shared.Throwing; using Robust.Server.GameObjects; using Robust.Shared.Audio; @@ -71,6 +72,9 @@ namespace Content.Server.Light.Components private int _powerUse = 40; public int PowerUse => _powerUse; + [DataField("breakSound")] + private SoundSpecifier _breakSound = new SoundCollectionSpecifier("GlassBreak"); + /// /// The current state of the light bulb. Invokes the OnLightBulbStateChange event when set. /// It also updates the bulb's sprite accordingly. @@ -129,10 +133,8 @@ namespace Content.Server.Light.Components public void PlayBreakSound() { - var soundCollection = _prototypeManager.Index("GlassBreak"); - var file = _random.Pick(soundCollection.PickFiles); - - SoundSystem.Play(Filter.Pvs(Owner), file, Owner); + if(_breakSound.TryGetSound(out var breakSound)) + SoundSystem.Play(Filter.Pvs(Owner), breakSound, Owner); } } } diff --git a/Content.Server/Light/Components/MatchstickComponent.cs b/Content.Server/Light/Components/MatchstickComponent.cs index 670527effe..c3fffae599 100644 --- a/Content.Server/Light/Components/MatchstickComponent.cs +++ b/Content.Server/Light/Components/MatchstickComponent.cs @@ -3,6 +3,7 @@ using System.Threading.Tasks; using Content.Shared.Audio; using Content.Shared.Interaction; using Content.Shared.Smoking; +using Content.Shared.Sound; using Content.Shared.Temperature; using Robust.Server.GameObjects; using Robust.Shared.Audio; @@ -30,7 +31,7 @@ namespace Content.Server.Light.Components /// /// Sound played when you ignite the matchstick. /// - [DataField("igniteSound")] private string? _igniteSound; + [DataField("igniteSound")] private SoundSpecifier _igniteSound = default!; /// /// Point light component. Gives matches a glow in dark effect. @@ -69,9 +70,9 @@ namespace Content.Server.Light.Components public void Ignite(IEntity user) { // Play Sound - if (!string.IsNullOrEmpty(_igniteSound)) + if (_igniteSound.TryGetSound(out var igniteSound)) { - SoundSystem.Play(Filter.Pvs(Owner), _igniteSound, Owner, + SoundSystem.Play(Filter.Pvs(Owner), igniteSound, Owner, AudioHelpers.WithVariation(0.125f).WithVolume(-0.125f)); } diff --git a/Content.Server/Light/Components/PoweredLightComponent.cs b/Content.Server/Light/Components/PoweredLightComponent.cs index 3e5ecd5b19..c8a2401756 100644 --- a/Content.Server/Light/Components/PoweredLightComponent.cs +++ b/Content.Server/Light/Components/PoweredLightComponent.cs @@ -15,6 +15,7 @@ using Content.Shared.Interaction; using Content.Shared.Light; using Content.Shared.Notification; using Content.Shared.Notification.Managers; +using Content.Shared.Sound; using Robust.Server.GameObjects; using Robust.Shared.Audio; using Robust.Shared.Containers; @@ -49,6 +50,12 @@ namespace Content.Server.Light.Components private TimeSpan _lastThunk; private TimeSpan? _lastGhostBlink; + [DataField("burnHandSound")] + private SoundSpecifier _burnHandSound = new SoundPathSpecifier("/Audio/Effects/lightburn.ogg"); + + [DataField("turnOnSound")] + private SoundSpecifier _turnOnSound = new SoundPathSpecifier("/Audio/Machines/light_tube_on.ogg"); + [DataField("hasLampOnSpawn")] private bool _hasLampOnSpawn = true; @@ -119,7 +126,8 @@ namespace Content.Server.Light.Components { Owner.PopupMessage(eventArgs.User, Loc.GetString("powered-light-component-burn-hand")); damageableComponent.ChangeDamage(DamageType.Heat, 20, false, Owner); - SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/lightburn.ogg", Owner); + if(_burnHandSound.TryGetSound(out var burnHandSound)) + SoundSystem.Play(Filter.Pvs(Owner), burnHandSound, Owner); } void Eject() @@ -221,7 +229,8 @@ namespace Content.Server.Light.Components if (time > _lastThunk + _thunkDelay) { _lastThunk = time; - SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/light_tube_on.ogg", Owner, AudioParams.Default.WithVolume(-10f)); + if(_turnOnSound.TryGetSound(out var turnOnSound)) + SoundSystem.Play(Filter.Pvs(Owner), turnOnSound, Owner, AudioParams.Default.WithVolume(-10f)); } } else diff --git a/Content.Server/Mining/Components/AsteroidRockComponent.cs b/Content.Server/Mining/Components/AsteroidRockComponent.cs index 000c575fff..246f49ceee 100644 --- a/Content.Server/Mining/Components/AsteroidRockComponent.cs +++ b/Content.Server/Mining/Components/AsteroidRockComponent.cs @@ -34,14 +34,17 @@ namespace Content.Server.Mining.Components async Task IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) { var item = eventArgs.Using; - if (!item.TryGetComponent(out MeleeWeaponComponent? meleeWeaponComponent)) return false; + if (!item.TryGetComponent(out MeleeWeaponComponent? meleeWeaponComponent)) + return false; Owner.GetComponent().ChangeDamage(DamageType.Blunt, meleeWeaponComponent.Damage, false, item); - if (!item.TryGetComponent(out PickaxeComponent? pickaxeComponent)) return true; - if (!string.IsNullOrWhiteSpace(pickaxeComponent.MiningSound)) + if (!item.TryGetComponent(out PickaxeComponent? pickaxeComponent)) + return true; + + if (pickaxeComponent.MiningSound.TryGetSound(out var miningSound)) { - SoundSystem.Play(Filter.Pvs(Owner), pickaxeComponent.MiningSound, Owner, AudioParams.Default); + SoundSystem.Play(Filter.Pvs(Owner), miningSound, Owner, AudioParams.Default); } return true; } diff --git a/Content.Server/Mining/Components/PickaxeComponent.cs b/Content.Server/Mining/Components/PickaxeComponent.cs index 5d64163182..4d9638a184 100644 --- a/Content.Server/Mining/Components/PickaxeComponent.cs +++ b/Content.Server/Mining/Components/PickaxeComponent.cs @@ -1,3 +1,4 @@ +using Content.Shared.Sound; using Robust.Shared.GameObjects; using Robust.Shared.Serialization.Manager.Attributes; @@ -5,12 +6,13 @@ namespace Content.Server.Mining.Components { [RegisterComponent] public class PickaxeComponent : Component - { public override string Name => "Pickaxe"; + [DataField("miningSound")] - public string MiningSound = "/Audio/Items/Mining/pickaxe.ogg"; + public SoundSpecifier MiningSound { get; set; } = new SoundPathSpecifier("/Audio/Items/Mining/pickaxe.ogg"); + [DataField("miningSpeedMultiplier")] - public float MiningSpeedMultiplier = 1f; + public float MiningSpeedMultiplier { get; set; } = 1f; } } diff --git a/Content.Server/Morgue/Components/CrematoriumEntityStorageComponent.cs b/Content.Server/Morgue/Components/CrematoriumEntityStorageComponent.cs index cd254c9e70..830d70ced8 100644 --- a/Content.Server/Morgue/Components/CrematoriumEntityStorageComponent.cs +++ b/Content.Server/Morgue/Components/CrematoriumEntityStorageComponent.cs @@ -12,6 +12,7 @@ using Content.Shared.Interaction; using Content.Shared.Interaction.Events; using Content.Shared.Morgue; using Content.Shared.Notification.Managers; +using Content.Shared.Sound; using Content.Shared.Standing; using Content.Shared.Verbs; using Robust.Server.Player; @@ -20,6 +21,7 @@ using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Player; +using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Utility; using Robust.Shared.ViewVariables; @@ -34,6 +36,8 @@ namespace Content.Server.Morgue.Components { public override string Name => "CrematoriumEntityStorage"; + [DataField("cremateFinishSound")] private SoundSpecifier _cremateFinishSound = new SoundPathSpecifier("/Audio/Machines/ding.ogg"); + [ViewVariables] public bool Cooking { get; private set; } @@ -50,7 +54,7 @@ namespace Content.Server.Morgue.Components { if (Appearance.TryGetData(CrematoriumVisuals.Burning, out bool isBurning) && isBurning) { - message.AddMarkup(Loc.GetString("crematorium-entity-storage-component-on-examine-details-is-burning",("owner", Owner)) + "\n"); + message.AddMarkup(Loc.GetString("crematorium-entity-storage-component-on-examine-details-is-burning", ("owner", Owner)) + "\n"); } if (Appearance.TryGetData(MorgueVisuals.HasContents, out bool hasContents) && hasContents) @@ -68,7 +72,8 @@ namespace Content.Server.Morgue.Components { if (Cooking) { - if (!silent) Owner.PopupMessage(user, Loc.GetString("crematorium-entity-storage-component-is-cooking-safety-message")); + if (!silent) + Owner.PopupMessage(user, Loc.GetString("crematorium-entity-storage-component-is-cooking-safety-message")); return false; } return base.CanOpen(user, silent); @@ -116,7 +121,9 @@ namespace Content.Server.Morgue.Components TryOpenStorage(Owner); - SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/ding.ogg", Owner); + if (_cremateFinishSound.TryGetSound(out var cremateFinishSound)) + SoundSystem.Play(Filter.Pvs(Owner), cremateFinishSound, Owner); + }, _cremateCancelToken.Token); } diff --git a/Content.Server/Morgue/Components/MorgueEntityStorageComponent.cs b/Content.Server/Morgue/Components/MorgueEntityStorageComponent.cs index 5c6d77b47c..50ba5d47c2 100644 --- a/Content.Server/Morgue/Components/MorgueEntityStorageComponent.cs +++ b/Content.Server/Morgue/Components/MorgueEntityStorageComponent.cs @@ -8,6 +8,7 @@ using Content.Shared.Interaction.Helpers; using Content.Shared.Morgue; using Content.Shared.Notification.Managers; using Content.Shared.Physics; +using Content.Shared.Sound; using Content.Shared.Standing; using Robust.Server.GameObjects; using Robust.Shared.Audio; @@ -44,6 +45,9 @@ namespace Content.Server.Morgue.Components [DataField("doSoulBeep")] public bool DoSoulBeep = true; + [DataField("occupantHasSoulAlarmSound")] + private SoundSpecifier _occupantHasSoulAlarmSound = new SoundPathSpecifier("/Audio/Weapons/Guns/EmptyAlarm/smg_empty_alarm.ogg"); + [ViewVariables] [ComponentDependency] protected readonly AppearanceComponent? Appearance = null; @@ -56,13 +60,15 @@ namespace Content.Server.Morgue.Components public override Vector2 ContentsDumpPosition() { - if (_tray != null) return _tray.Transform.WorldPosition; + if (_tray != null) + return _tray.Transform.WorldPosition; return base.ContentsDumpPosition(); } protected override bool AddToContents(IEntity entity) { - if (entity.HasComponent() && !EntitySystem.Get().IsDown(entity)) return false; + if (entity.HasComponent() && !EntitySystem.Get().IsDown(entity)) + return false; return base.AddToContents(entity); } @@ -73,7 +79,8 @@ namespace Content.Server.Morgue.Components collisionMask: CollisionGroup.Impassable | CollisionGroup.VaultImpassable )) { - if(!silent) Owner.PopupMessage(user, Loc.GetString("morgue-entity-storage-component-cannot-open-no-space")); + if (!silent) + Owner.PopupMessage(user, Loc.GetString("morgue-entity-storage-component-cannot-open-no-space")); return false; } @@ -112,8 +119,10 @@ namespace Content.Server.Morgue.Components foreach (var entity in Contents.ContainedEntities) { count++; - if (!hasMob && entity.HasComponent()) hasMob = true; - if (!hasSoul && entity.TryGetComponent(out var actor) && actor.PlayerSession != null) hasSoul = true; + if (!hasMob && entity.HasComponent()) + hasMob = true; + if (!hasSoul && entity.TryGetComponent(out var actor) && actor.PlayerSession != null) + hasSoul = true; } Appearance?.SetData(MorgueVisuals.HasContents, count > 0); Appearance?.SetData(MorgueVisuals.HasMob, hasMob); @@ -138,8 +147,11 @@ namespace Content.Server.Morgue.Components { CheckContents(); - if(DoSoulBeep && Appearance !=null && Appearance.TryGetData(MorgueVisuals.HasSoul, out bool hasSoul) && hasSoul) - SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Weapons/Guns/EmptyAlarm/smg_empty_alarm.ogg", Owner); + if (DoSoulBeep && Appearance != null && Appearance.TryGetData(MorgueVisuals.HasSoul, out bool hasSoul) && hasSoul && + _occupantHasSoulAlarmSound.TryGetSound(out var occupantHasSoulAlarmSound)) + { + SoundSystem.Play(Filter.Pvs(Owner), occupantHasSoulAlarmSound, Owner); + } } void IExamine.Examine(FormattedMessage message, bool inDetailsRange) @@ -159,7 +171,8 @@ namespace Content.Server.Morgue.Components else if (Appearance.TryGetData(MorgueVisuals.HasContents, out bool hasContents) && hasContents) { message.AddMarkup(Loc.GetString("morgue-entity-storage-component-on-examine-details-has-contents")); - } else + } + else { message.AddMarkup(Loc.GetString("morgue-entity-storage-component-on-examine-details-empty")); } diff --git a/Content.Server/Movement/Components/FootstepModifierComponent.cs b/Content.Server/Movement/Components/FootstepModifierComponent.cs index 10453c8f13..c61ec76cc3 100644 --- a/Content.Server/Movement/Components/FootstepModifierComponent.cs +++ b/Content.Server/Movement/Components/FootstepModifierComponent.cs @@ -1,10 +1,7 @@ -using Content.Shared.Audio; +using Content.Shared.Sound; using Robust.Shared.Audio; using Robust.Shared.GameObjects; -using Robust.Shared.IoC; using Robust.Shared.Player; -using Robust.Shared.Prototypes; -using Robust.Shared.Random; using Robust.Shared.Serialization.Manager.Attributes; namespace Content.Server.Movement.Components @@ -15,23 +12,16 @@ namespace Content.Server.Movement.Components [RegisterComponent] public class FootstepModifierComponent : Component { - [Dependency] private readonly IPrototypeManager _prototypeManager = default!; - [Dependency] private readonly IRobustRandom _footstepRandom = default!; - /// public override string Name => "FootstepModifier"; [DataField("footstepSoundCollection")] - public string? _soundCollectionName; + public SoundSpecifier _soundCollection = default!; public void PlayFootstep() { - if (!string.IsNullOrWhiteSpace(_soundCollectionName)) - { - var soundCollection = _prototypeManager.Index(_soundCollectionName); - var file = _footstepRandom.Pick(soundCollection.PickFiles); - SoundSystem.Play(Filter.Pvs(Owner), file, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2f)); - } + if (_soundCollection.TryGetSound(out var footstepSound)) + SoundSystem.Play(Filter.Pvs(Owner), footstepSound, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2f)); } } } diff --git a/Content.Server/Nutrition/Components/CreamPieComponent.cs b/Content.Server/Nutrition/Components/CreamPieComponent.cs index 8d4c7ef9c5..e59a084fe5 100644 --- a/Content.Server/Nutrition/Components/CreamPieComponent.cs +++ b/Content.Server/Nutrition/Components/CreamPieComponent.cs @@ -1,6 +1,7 @@ using Content.Server.Chemistry.Components; using Content.Server.Fluids.Components; using Content.Shared.Audio; +using Content.Shared.Sound; using Content.Shared.Throwing; using Robust.Shared.Audio; using Robust.Shared.GameObjects; @@ -19,10 +20,13 @@ namespace Content.Server.Nutrition.Components [DataField("paralyzeTime")] public float ParalyzeTime { get; set; } = 1f; + [DataField("sound")] + private SoundSpecifier _sound = new SoundCollectionSpecifier("desacration"); + public void PlaySound() { - SoundSystem.Play(Filter.Pvs(Owner), AudioHelpers.GetRandomFileFromSoundCollection("desecration"), Owner, - AudioHelpers.WithVariation(0.125f)); + if(_sound.TryGetSound(out var sound)) + SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioHelpers.WithVariation(0.125f)); } void IThrowCollide.DoHit(ThrowCollideEventArgs eventArgs) diff --git a/Content.Server/Nutrition/Components/DrinkComponent.cs b/Content.Server/Nutrition/Components/DrinkComponent.cs index 62a05b7703..b659cbb30e 100644 --- a/Content.Server/Nutrition/Components/DrinkComponent.cs +++ b/Content.Server/Nutrition/Components/DrinkComponent.cs @@ -15,6 +15,7 @@ using Content.Shared.Interaction.Helpers; using Content.Shared.Notification; using Content.Shared.Notification.Managers; using Content.Shared.Nutrition.Components; +using Content.Shared.Sound; using Content.Shared.Throwing; using JetBrains.Annotations; using Robust.Server.GameObjects; @@ -46,7 +47,7 @@ namespace Content.Server.Nutrition.Components [ViewVariables] [DataField("useSound")] - private string _useSound = "/Audio/Items/drink.ogg"; + private SoundSpecifier _useSound = new SoundPathSpecifier("/Audio/Items/drink.ogg"); [ViewVariables] [DataField("isOpen")] @@ -75,11 +76,11 @@ namespace Content.Server.Nutrition.Components public bool Empty => Owner.GetComponentOrNull()?.DrainAvailable <= 0; [DataField("openSounds")] - private string _soundCollection = "canOpenSounds"; + private SoundSpecifier _openSounds = new SoundCollectionSpecifier("canOpenSounds"); [DataField("pressurized")] private bool _pressurized = default; [DataField("burstSound")] - private string _burstSound = "/Audio/Effects/flash_bang.ogg"; + private SoundSpecifier _burstSound = new SoundPathSpecifier("/Audio/Effects/flash_bang.ogg"); protected override void Initialize() { @@ -127,10 +128,9 @@ namespace Content.Server.Nutrition.Components if (!Opened) { //Do the opening stuff like playing the sounds. - var soundCollection = _prototypeManager.Index(_soundCollection); - var file = _random.Pick(soundCollection.PickFiles); + if(_openSounds.TryGetSound(out var openSound)) + SoundSystem.Play(Filter.Pvs(args.User), openSound, args.User, AudioParams.Default); - SoundSystem.Play(Filter.Pvs(args.User), file, args.User, AudioParams.Default); Opened = true; return false; } @@ -220,9 +220,9 @@ namespace Content.Server.Nutrition.Components return false; } - if (!string.IsNullOrEmpty(_useSound)) + if (_useSound.TryGetSound(out var useSound)) { - SoundSystem.Play(Filter.Pvs(target), _useSound, target, AudioParams.Default.WithVolume(-2f)); + SoundSystem.Play(Filter.Pvs(target), useSound, target, AudioParams.Default.WithVolume(-2f)); } target.PopupMessage(Loc.GetString("drink-component-try-use-drink-success-slurp")); @@ -254,8 +254,8 @@ namespace Content.Server.Nutrition.Components var solution = interactions.Drain(interactions.DrainAvailable); solution.SpillAt(Owner, "PuddleSmear"); - SoundSystem.Play(Filter.Pvs(Owner), _burstSound, Owner, - AudioParams.Default.WithVolume(-4)); + if(_burstSound.TryGetSound(out var burstSound)) + SoundSystem.Play(Filter.Pvs(Owner), burstSound, Owner, AudioParams.Default.WithVolume(-4)); } } } diff --git a/Content.Server/Nutrition/Components/FoodComponent.cs b/Content.Server/Nutrition/Components/FoodComponent.cs index 161e9e426e..00f0fd3fe5 100644 --- a/Content.Server/Nutrition/Components/FoodComponent.cs +++ b/Content.Server/Nutrition/Components/FoodComponent.cs @@ -13,6 +13,7 @@ using Content.Shared.Interaction; using Content.Shared.Interaction.Helpers; using Content.Shared.Notification; using Content.Shared.Notification.Managers; +using Content.Shared.Sound; using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.Localization; @@ -30,7 +31,7 @@ namespace Content.Server.Nutrition.Components { public override string Name => "Food"; - [ViewVariables] [DataField("useSound")] protected virtual string? UseSound { get; set; } = "/Audio/Items/eatfood.ogg"; + [ViewVariables] [DataField("useSound")] protected virtual SoundSpecifier UseSound { get; set; } = new SoundPathSpecifier("/Audio/Items/eatfood.ogg"); [ViewVariables] [DataField("trash", customTypeSerializer: typeof(PrototypeIdSerializer))] protected virtual string? TrashPrototype { get; set; } @@ -160,9 +161,9 @@ namespace Content.Server.Nutrition.Components firstStomach.TryTransferSolution(split); - if (UseSound != null) + if (UseSound.TryGetSound(out var useSound)) { - SoundSystem.Play(Filter.Pvs(trueTarget), UseSound, trueTarget, AudioParams.Default.WithVolume(-1f)); + SoundSystem.Play(Filter.Pvs(trueTarget), useSound, trueTarget, AudioParams.Default.WithVolume(-1f)); } trueTarget.PopupMessage(user, Loc.GetString("food-nom")); diff --git a/Content.Server/Nutrition/Components/SliceableFoodComponent.cs b/Content.Server/Nutrition/Components/SliceableFoodComponent.cs index 32733e65c1..cc1f4502e2 100644 --- a/Content.Server/Nutrition/Components/SliceableFoodComponent.cs +++ b/Content.Server/Nutrition/Components/SliceableFoodComponent.cs @@ -5,6 +5,7 @@ using Content.Server.Items; using Content.Shared.Chemistry.Reagent; using Content.Shared.Examine; using Content.Shared.Interaction; +using Content.Shared.Sound; using Robust.Shared.Audio; using Robust.Shared.Containers; using Robust.Shared.GameObjects; @@ -27,7 +28,7 @@ namespace Content.Server.Nutrition.Components private string _slice = string.Empty; [DataField("sound")] [ViewVariables(VVAccess.ReadWrite)] - private string _sound = "/Audio/Items/Culinary/chop.ogg"; + private SoundSpecifier _sound = new SoundPathSpecifier("/Audio/Items/Culinary/chop.ogg"); [DataField("count")] [ViewVariables(VVAccess.ReadWrite)] private ushort _totalCount = 5; @@ -66,8 +67,9 @@ namespace Content.Server.Nutrition.Components } } - SoundSystem.Play(Filter.Pvs(Owner), _sound, Owner.Transform.Coordinates, - AudioParams.Default.WithVolume(-2)); + if(_sound.TryGetSound(out var sound)) + SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, + AudioParams.Default.WithVolume(-2)); Count--; if (Count < 1) diff --git a/Content.Server/Nutrition/Components/UtensilComponent.cs b/Content.Server/Nutrition/Components/UtensilComponent.cs index ca243f04af..e705e1231a 100644 --- a/Content.Server/Nutrition/Components/UtensilComponent.cs +++ b/Content.Server/Nutrition/Components/UtensilComponent.cs @@ -3,6 +3,7 @@ using System; using System.Threading.Tasks; using Content.Shared.Interaction; using Content.Shared.Interaction.Helpers; +using Content.Shared.Sound; using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.IoC; @@ -47,7 +48,7 @@ namespace Content.Server.Nutrition.Components /// [ViewVariables] [DataField("breakSound")] - private string? _breakSound = "/Audio/Items/snap.ogg"; + private SoundSpecifier _breakSound = new SoundPathSpecifier("/Audio/Items/snap.ogg"); public void AddType(UtensilType type) { @@ -71,9 +72,9 @@ namespace Content.Server.Nutrition.Components internal void TryBreak(IEntity user) { - if (_breakSound != null && IoCManager.Resolve().Prob(_breakChance)) + if (_breakSound.TryGetSound(out var breakSound) && IoCManager.Resolve().Prob(_breakChance)) { - SoundSystem.Play(Filter.Pvs(user), _breakSound, user, AudioParams.Default.WithVolume(-2f)); + SoundSystem.Play(Filter.Pvs(user), breakSound, user, AudioParams.Default.WithVolume(-2f)); Owner.Delete(); } } diff --git a/Content.Server/PDA/PDAComponent.cs b/Content.Server/PDA/PDAComponent.cs index 0b01d5ed7d..fd3b6864ee 100644 --- a/Content.Server/PDA/PDAComponent.cs +++ b/Content.Server/PDA/PDAComponent.cs @@ -15,6 +15,7 @@ using Content.Shared.Interaction; using Content.Shared.Interaction.Events; using Content.Shared.Notification.Managers; using Content.Shared.PDA; +using Content.Shared.Sound; using Content.Shared.Tag; using Content.Shared.Verbs; using Robust.Server.GameObjects; @@ -59,6 +60,10 @@ namespace Content.Server.PDA [ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(PDAUiKey.Key); + [DataField("insertIdSound")] private SoundSpecifier _insertIdSound = new SoundPathSpecifier("/Audio/Weapons/Guns/MagIn/batrifle_magin.ogg"); + [DataField("toggleFlashlightSound")] private SoundSpecifier _toggleFlashlightSound = new SoundPathSpecifier("/Audio/Items/flashlight_toggle.ogg"); + [DataField("ejectIdSound")] private SoundSpecifier _ejectIdSound = new SoundPathSpecifier("/Audio/Machines/id_swipe.ogg"); + public PDAComponent() { _accessSet = new PdaAccessSet(this); @@ -301,7 +306,8 @@ namespace Content.Server.PDA { _idSlot.Insert(card.Owner); ContainedID = card; - SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Weapons/Guns/MagIn/batrifle_magin.ogg", Owner); + if(_insertIdSound.TryGetSound(out var insertIdSound)) + SoundSystem.Play(Filter.Pvs(Owner), insertIdSound, Owner); } /// @@ -330,7 +336,8 @@ namespace Content.Server.PDA _lightOn = !_lightOn; light.Enabled = _lightOn; - SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Items/flashlight_toggle.ogg", Owner); + if(_toggleFlashlightSound.TryGetSound(out var toggleFlashlightSound)) + SoundSystem.Play(Filter.Pvs(Owner), toggleFlashlightSound, Owner); UpdatePDAUserInterface(); } @@ -349,7 +356,8 @@ namespace Content.Server.PDA hands.PutInHandOrDrop(cardItemComponent); ContainedID = null; - SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/id_swipe.ogg", Owner); + if(_ejectIdSound.TryGetSound(out var ejectIdSound)) + SoundSystem.Play(Filter.Pvs(Owner), ejectIdSound, Owner); UpdatePDAUserInterface(); } diff --git a/Content.Server/Physics/Controllers/MoverController.cs b/Content.Server/Physics/Controllers/MoverController.cs index e3f24a800f..0ec5a812fe 100644 --- a/Content.Server/Physics/Controllers/MoverController.cs +++ b/Content.Server/Physics/Controllers/MoverController.cs @@ -9,6 +9,7 @@ using Content.Shared.Inventory; using Content.Shared.Maps; using Content.Shared.Movement; using Content.Shared.Movement.Components; +using Content.Shared.Sound; using Content.Shared.Tag; using Robust.Server.GameObjects; using Robust.Shared.Audio; @@ -154,38 +155,37 @@ namespace Content.Server.Physics.Controllers // If the coordinates have a FootstepModifier component // i.e. component that emit sound on footsteps emit that sound - string? soundCollectionName = null; + string? soundToPlay = null; foreach (var maybeFootstep in grid.GetAnchoredEntities(tile.GridIndices)) { - if (EntityManager.ComponentManager.TryGetComponent(maybeFootstep, out FootstepModifierComponent? footstep)) + if (EntityManager.ComponentManager.TryGetComponent(maybeFootstep, out FootstepModifierComponent? footstep) && + footstep._soundCollection.TryGetSound(out var footstepSound)) { - soundCollectionName = footstep._soundCollectionName; + soundToPlay = footstepSound; break; } } // if there is no FootstepModifierComponent, determine sound based on tiles - if (soundCollectionName == null) + if (soundToPlay == null) { // Walking on a tile. var def = (ContentTileDefinition) _tileDefinitionManager[tile.Tile.TypeId]; - if (string.IsNullOrEmpty(def.FootstepSounds)) + if (def.FootstepSounds.TryGetSound(out var footstepSound)) { - // Nothing to play, oh well. + soundToPlay = footstepSound; return; - } - - soundCollectionName = def.FootstepSounds; + } } - if (!_prototypeManager.TryIndex(soundCollectionName, out SoundCollectionPrototype? soundCollection)) + if (string.IsNullOrWhiteSpace(soundToPlay)) { - Logger.ErrorS("sound", $"Unable to find sound collection for {soundCollectionName}"); + Logger.ErrorS("sound", $"Unable to find sound in {nameof(PlayFootstepSound)}"); return; } SoundSystem.Play( Filter.Pvs(coordinates), - _robustRandom.Pick(soundCollection.PickFiles), + soundToPlay, mover.Transform.Coordinates, sprinting ? AudioParams.Default.WithVolume(0.75f) : null); } diff --git a/Content.Server/Plants/Components/PottedPlantHideComponent.cs b/Content.Server/Plants/Components/PottedPlantHideComponent.cs index 13efc18346..2a64e494c4 100644 --- a/Content.Server/Plants/Components/PottedPlantHideComponent.cs +++ b/Content.Server/Plants/Components/PottedPlantHideComponent.cs @@ -4,10 +4,12 @@ using Content.Shared.Audio; using Content.Shared.Interaction; using Content.Shared.Notification; using Content.Shared.Notification.Managers; +using Content.Shared.Sound; using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.Localization; using Robust.Shared.Player; +using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; namespace Content.Server.Plants.Components @@ -18,6 +20,7 @@ namespace Content.Server.Plants.Components public override string Name => "PottedPlantHide"; [ViewVariables] private SecretStashComponent _secretStash = default!; + [DataField("rustleSound")] private SoundSpecifier _rustleSound = new SoundPathSpecifier("/Audio/Effects/plant_rustle.ogg"); protected override void Initialize() { @@ -46,7 +49,8 @@ namespace Content.Server.Plants.Components private void Rustle() { - SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/plant_rustle.ogg", Owner, AudioHelpers.WithVariation(0.25f)); + if(_rustleSound.TryGetSound(out var rustleSound)) + SoundSystem.Play(Filter.Pvs(Owner), rustleSound, Owner, AudioHelpers.WithVariation(0.25f)); } } } diff --git a/Content.Server/Pointing/Components/RoguePointingArrowComponent.cs b/Content.Server/Pointing/Components/RoguePointingArrowComponent.cs index 7ce21d39ea..d065e65db6 100644 --- a/Content.Server/Pointing/Components/RoguePointingArrowComponent.cs +++ b/Content.Server/Pointing/Components/RoguePointingArrowComponent.cs @@ -2,6 +2,7 @@ using System.Linq; using Content.Server.Explosion; using Content.Shared.Pointing.Components; +using Content.Shared.Sound; using Robust.Server.GameObjects; using Robust.Server.Player; using Robust.Shared.Audio; @@ -41,6 +42,9 @@ namespace Content.Server.Pointing.Components [DataField("chasingTime")] private float _chasingTime = 1; + [DataField("explosionSound")] + private SoundSpecifier _explosionSound = new SoundPathSpecifier("/Audio/Effects/explosion.ogg"); + private IEntity? RandomNearbyPlayer() { var players = _playerManager @@ -120,7 +124,8 @@ namespace Content.Server.Pointing.Components } Owner.SpawnExplosion(0, 2, 1, 1); - SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/explosion.ogg", Owner); + if(_explosionSound.TryGetSound(out var explosionSound)) + SoundSystem.Play(Filter.Pvs(Owner), explosionSound, Owner); Owner.Delete(); } diff --git a/Content.Server/Portal/Components/PortalComponent.cs b/Content.Server/Portal/Components/PortalComponent.cs index ada1fa19ce..a4581eda43 100644 --- a/Content.Server/Portal/Components/PortalComponent.cs +++ b/Content.Server/Portal/Components/PortalComponent.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using Content.Shared.Portal.Components; +using Content.Shared.Sound; using Content.Shared.Tag; using Robust.Server.GameObjects; using Robust.Shared.Audio; @@ -28,8 +29,8 @@ namespace Content.Server.Portal.Components [ViewVariables(VVAccess.ReadWrite)] [DataField("individual_cooldown")] private float _individualPortalCooldown = 2.1f; [ViewVariables] [DataField("overall_cooldown")] private float _overallPortalCooldown = 2.0f; [ViewVariables] private bool _onCooldown; - [ViewVariables] [DataField("departure_sound")] private string _departureSound = "/Audio/Effects/teleport_departure.ogg"; - [ViewVariables] [DataField("arrival_sound")] private string _arrivalSound = "/Audio/Effects/teleport_arrival.ogg"; + [ViewVariables] [DataField("departure_sound")] private SoundSpecifier _departureSound = new SoundPathSpecifier("/Audio/Effects/teleport_departure.ogg"); + [ViewVariables] [DataField("arrival_sound")] private SoundSpecifier _arrivalSound = new SoundPathSpecifier("/Audio/Effects/teleport_arrival.ogg"); public readonly List ImmuneEntities = new(); // K [ViewVariables(VVAccess.ReadWrite)] [DataField("alive_time")] private float _aliveTime = 10f; @@ -143,9 +144,11 @@ namespace Content.Server.Portal.Components // Departure // Do we need to rate-limit sounds to stop ear BLAST? - SoundSystem.Play(Filter.Pvs(entity), _departureSound, entity.Transform.Coordinates); + if(_departureSound.TryGetSound(out var departureSound)) + SoundSystem.Play(Filter.Pvs(entity), departureSound, entity.Transform.Coordinates); entity.Transform.Coordinates = position; - SoundSystem.Play(Filter.Pvs(entity), _arrivalSound, entity.Transform.Coordinates); + if(_arrivalSound.TryGetSound(out var arrivalSound)) + SoundSystem.Play(Filter.Pvs(entity), arrivalSound, entity.Transform.Coordinates); TryChangeState(PortalState.RecentlyTeleported); // To stop spam teleporting. Could potentially look at adding a timer to flush this from the portal diff --git a/Content.Server/Portal/Components/TeleporterComponent.cs b/Content.Server/Portal/Components/TeleporterComponent.cs index b066c2cd22..7d945943e7 100644 --- a/Content.Server/Portal/Components/TeleporterComponent.cs +++ b/Content.Server/Portal/Components/TeleporterComponent.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Threading.Tasks; using Content.Shared.Interaction; using Content.Shared.Portal.Components; +using Content.Shared.Sound; using Robust.Server.GameObjects; using Robust.Shared.Audio; using Robust.Shared.GameObjects; @@ -38,9 +39,9 @@ namespace Content.Server.Portal.Components [ViewVariables] private ItemTeleporterState _state; [DataField("teleporter_type")] [ViewVariables] private TeleporterType _teleporterType = TeleporterType.Random; - [ViewVariables] [DataField("departure_sound")] private string _departureSound = "/Audio/Effects/teleport_departure.ogg"; - [ViewVariables] [DataField("arrival_sound")] private string _arrivalSound = "/Audio/Effects/teleport_arrival.ogg"; - [ViewVariables] [DataField("cooldown_sound")] private string? _cooldownSound = default; + [ViewVariables] [DataField("departure_sound")] private SoundSpecifier _departureSound = new SoundPathSpecifier("/Audio/Effects/teleport_departure.ogg"); + [ViewVariables] [DataField("arrival_sound")] private SoundSpecifier _arrivalSound = new SoundPathSpecifier("/Audio/Effects/teleport_arrival.ogg"); + [ViewVariables] [DataField("cooldown_sound")] private SoundSpecifier _cooldownSound = default!; // If the direct OR random teleport will try to avoid hitting collidables [DataField("avoid_walls")] [ViewVariables] private bool _avoidCollidable = true; @@ -124,9 +125,9 @@ namespace Content.Server.Portal.Components { SetState(ItemTeleporterState.Cooldown); Owner.SpawnTimer(TimeSpan.FromSeconds(_chargeTime + _cooldown), () => SetState(ItemTeleporterState.Off)); - if (_cooldownSound != null) + if (_cooldownSound.TryGetSound(out var cooldownSound)) { - SoundSystem.Play(Filter.Pvs(Owner), _cooldownSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), cooldownSound, Owner); } } @@ -229,12 +230,14 @@ namespace Content.Server.Portal.Components else { // Departure - SoundSystem.Play(Filter.Pvs(user), _departureSound, user.Transform.Coordinates); + if(_departureSound.TryGetSound(out var departureSound)) + SoundSystem.Play(Filter.Pvs(user), departureSound, user.Transform.Coordinates); // Arrival user.Transform.AttachToGridOrMap(); user.Transform.WorldPosition = vector; - SoundSystem.Play(Filter.Pvs(user), _arrivalSound, user.Transform.Coordinates); + if(_arrivalSound.TryGetSound(out var arrivalSound)) + SoundSystem.Play(Filter.Pvs(user), arrivalSound, user.Transform.Coordinates); } } } diff --git a/Content.Server/Power/Components/ApcComponent.cs b/Content.Server/Power/Components/ApcComponent.cs index 5182551775..22a997a8ba 100644 --- a/Content.Server/Power/Components/ApcComponent.cs +++ b/Content.Server/Power/Components/ApcComponent.cs @@ -6,6 +6,7 @@ using Content.Server.UserInterface; using Content.Shared.APC; using Content.Shared.Interaction; using Content.Shared.Notification.Managers; +using Content.Shared.Sound; using Robust.Server.GameObjects; using Robust.Shared.Audio; using Robust.Shared.GameObjects; @@ -13,6 +14,7 @@ using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Maths; using Robust.Shared.Player; +using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Timing; using Robust.Shared.ViewVariables; @@ -28,6 +30,8 @@ namespace Content.Server.Power.Components public bool MainBreakerEnabled { get; private set; } = true; + [DataField("onReceiveMessageSound")] private SoundSpecifier _onReceiveMessageSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg"); + private ApcChargeState _lastChargeState; private TimeSpan _lastChargeStateChange; @@ -90,7 +94,8 @@ namespace Content.Server.Power.Components Owner.GetComponent().CanDischarge = MainBreakerEnabled; _uiDirty = true; - SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/machine_switch.ogg", Owner, AudioParams.Default.WithVolume(-2f)); + if(_onReceiveMessageSound.TryGetSound(out var onReceiveMessageSound)) + SoundSystem.Play(Filter.Pvs(Owner), onReceiveMessageSound, Owner, AudioParams.Default.WithVolume(-2f)); } else { diff --git a/Content.Server/PowerCell/Components/PowerCellSlotComponent.cs b/Content.Server/PowerCell/Components/PowerCellSlotComponent.cs index 5423f01441..990ffd3695 100644 --- a/Content.Server/PowerCell/Components/PowerCellSlotComponent.cs +++ b/Content.Server/PowerCell/Components/PowerCellSlotComponent.cs @@ -6,6 +6,7 @@ using Content.Shared.ActionBlocker; using Content.Shared.Audio; using Content.Shared.Examine; using Content.Shared.Interaction.Events; +using Content.Shared.Sound; using Content.Shared.Verbs; using Robust.Shared.Audio; using Robust.Shared.Containers; @@ -63,7 +64,7 @@ namespace Content.Server.PowerCell.Components /// "/Audio/Items/pistol_magout.ogg" [ViewVariables(VVAccess.ReadWrite)] [DataField("cellRemoveSound")] - public string? CellRemoveSound { get; set; } = "/Audio/Items/pistol_magin.ogg"; + public SoundSpecifier CellRemoveSound { get; set; } = new SoundPathSpecifier("/Audio/Items/pistol_magin.ogg"); /// /// File path to a sound file that should be played when a cell is inserted. @@ -71,7 +72,7 @@ namespace Content.Server.PowerCell.Components /// "/Audio/Items/pistol_magin.ogg" [ViewVariables(VVAccess.ReadWrite)] [DataField("cellInsertSound")] - public string? CellInsertSound { get; set; } = "/Audio/Items/pistol_magout.ogg"; + public SoundSpecifier CellInsertSound { get; set; } = new SoundPathSpecifier("/Audio/Items/pistol_magout.ogg"); [ViewVariables] private ContainerSlot _cellContainer = default!; @@ -144,9 +145,9 @@ namespace Content.Server.PowerCell.Components cell.Owner.Transform.Coordinates = Owner.Transform.Coordinates; } - if (playSound && CellRemoveSound != null) + if (playSound && CellRemoveSound.TryGetSound(out var cellRemoveSound)) { - SoundSystem.Play(Filter.Pvs(Owner), CellRemoveSound, Owner, AudioHelpers.WithVariation(0.125f)); + SoundSystem.Play(Filter.Pvs(Owner), cellRemoveSound, Owner, AudioHelpers.WithVariation(0.125f)); } Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new PowerCellChangedEvent(true), false); @@ -167,9 +168,9 @@ namespace Content.Server.PowerCell.Components if (cellComponent.CellSize != SlotSize) return false; if (!_cellContainer.Insert(cell)) return false; //Dirty(); - if (playSound && CellInsertSound != null) + if (playSound && CellInsertSound.TryGetSound(out var cellInsertSound)) { - SoundSystem.Play(Filter.Pvs(Owner), CellInsertSound, Owner, AudioHelpers.WithVariation(0.125f)); + SoundSystem.Play(Filter.Pvs(Owner), cellInsertSound, Owner, AudioHelpers.WithVariation(0.125f)); } Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new PowerCellChangedEvent(false), false); diff --git a/Content.Server/Projectiles/Components/HitscanComponent.cs b/Content.Server/Projectiles/Components/HitscanComponent.cs index e4ebd554e6..073ed091e6 100644 --- a/Content.Server/Projectiles/Components/HitscanComponent.cs +++ b/Content.Server/Projectiles/Components/HitscanComponent.cs @@ -1,6 +1,7 @@ using System; using Content.Shared.Damage; using Content.Shared.Physics; +using Content.Shared.Sound; using Robust.Server.GameObjects; using Robust.Shared.Audio; using Robust.Shared.GameObjects; @@ -50,7 +51,7 @@ namespace Content.Server.Projectiles.Components [DataField("impactFlash")] private string? _impactFlash; [DataField("soundHitWall")] - private string _soundHitWall = "/Audio/Weapons/Guns/Hits/laser_sear_wall.ogg"; + private SoundSpecifier _soundHitWall = new SoundPathSpecifier("/Audio/Weapons/Guns/Hits/laser_sear_wall.ogg"); public void FireEffects(IEntity user, float distance, Angle angle, IEntity? hitEntity = null) { @@ -85,7 +86,8 @@ namespace Content.Server.Projectiles.Components // TODO: No wall component so ? var offset = angle.ToVec().Normalized / 2; var coordinates = user.Transform.Coordinates.Offset(offset); - SoundSystem.Play(Filter.Pvs(coordinates), _soundHitWall, coordinates); + if(_soundHitWall.TryGetSound(out var soundHitWall)) + SoundSystem.Play(Filter.Pvs(coordinates), soundHitWall, coordinates); } Owner.SpawnTimer((int) _deathTime.TotalMilliseconds, () => diff --git a/Content.Server/Projectiles/Components/ProjectileComponent.cs b/Content.Server/Projectiles/Components/ProjectileComponent.cs index ef41b8b735..d5bef34248 100644 --- a/Content.Server/Projectiles/Components/ProjectileComponent.cs +++ b/Content.Server/Projectiles/Components/ProjectileComponent.cs @@ -1,8 +1,9 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Content.Server.Camera; using Content.Shared.Damage; using Content.Shared.Damage.Components; using Content.Shared.Projectiles; +using Content.Shared.Sound; using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.Physics.Collision; @@ -33,9 +34,7 @@ namespace Content.Server.Projectiles.Components // Get that juicy FPS hit sound [DataField("soundHit")] - private string? _soundHit = default; - [DataField("soundHitSpecies")] - private string? _soundHitSpecies = default; + private SoundSpecifier _soundHit = default!; private bool _damagedEntity; @@ -64,13 +63,9 @@ namespace Content.Server.Projectiles.Components var coordinates = otherFixture.Body.Owner.Transform.Coordinates; var playerFilter = Filter.Pvs(coordinates); - if (otherFixture.Body.Owner.TryGetComponent(out IDamageableComponent? damage) && _soundHitSpecies != null) + if (otherFixture.Body.Owner.TryGetComponent(out IDamageableComponent? damage) && _soundHit.TryGetSound(out var soundHit)) { - SoundSystem.Play(playerFilter, _soundHitSpecies, coordinates); - } - else if (_soundHit != null) - { - SoundSystem.Play(playerFilter, _soundHit, coordinates); + SoundSystem.Play(playerFilter, soundHit, coordinates); } if (damage != null) diff --git a/Content.Server/RCD/Components/RCDComponent.cs b/Content.Server/RCD/Components/RCDComponent.cs index 1f6f229023..bde50fec51 100644 --- a/Content.Server/RCD/Components/RCDComponent.cs +++ b/Content.Server/RCD/Components/RCDComponent.cs @@ -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; } diff --git a/Content.Server/Radiation/RadiationPulseComponent.cs b/Content.Server/Radiation/RadiationPulseComponent.cs index 5101397ee2..e5851f600e 100644 --- a/Content.Server/Radiation/RadiationPulseComponent.cs +++ b/Content.Server/Radiation/RadiationPulseComponent.cs @@ -1,5 +1,6 @@ using System; using Content.Shared.Radiation; +using Content.Shared.Sound; using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.IoC; @@ -57,7 +58,7 @@ namespace Content.Server.Radiation } } - [DataField("sound")] public string? Sound { get; set; } = "/Audio/Weapons/Guns/Gunshots/laser3.ogg"; + [DataField("sound")] public SoundSpecifier Sound { get; set; } = new SoundPathSpecifier("/Audio/Weapons/Guns/Gunshots/laser3.ogg"); [DataField("range")] public override float Range @@ -92,8 +93,8 @@ namespace Content.Server.Radiation _endTime = currentTime + TimeSpan.FromSeconds(_duration); } - if(!string.IsNullOrEmpty(Sound)) - SoundSystem.Play(Filter.Pvs(Owner), Sound, Owner.Transform.Coordinates); + if(Sound.TryGetSound(out var sound)) + SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates); Dirty(); } diff --git a/Content.Server/Radiation/RadiationPulseSystem.cs b/Content.Server/Radiation/RadiationPulseSystem.cs index 96b14b5db1..b00939b334 100644 --- a/Content.Server/Radiation/RadiationPulseSystem.cs +++ b/Content.Server/Radiation/RadiationPulseSystem.cs @@ -1,5 +1,6 @@ using System.Linq; using Content.Shared.Radiation; +using Content.Shared.Sound; using JetBrains.Annotations; using Robust.Shared.GameObjects; using Robust.Shared.IoC; @@ -19,7 +20,7 @@ namespace Content.Server.Radiation bool decay = true, float minPulseLifespan = 0.8f, float maxPulseLifespan = 2.5f, - string? sound = null) + SoundSpecifier sound = default!) { var radiationEntity = EntityManager.SpawnEntity(RadiationPrototype, coordinates); var radiation = radiationEntity.GetComponent(); diff --git a/Content.Server/Research/Components/ResearchConsoleComponent.cs b/Content.Server/Research/Components/ResearchConsoleComponent.cs index da1dea4ff9..5952c07dba 100644 --- a/Content.Server/Research/Components/ResearchConsoleComponent.cs +++ b/Content.Server/Research/Components/ResearchConsoleComponent.cs @@ -5,6 +5,7 @@ using Content.Shared.Audio; using Content.Shared.Interaction; using Content.Shared.Research.Components; using Content.Shared.Research.Prototypes; +using Content.Shared.Sound; using Robust.Server.GameObjects; using Robust.Server.Player; using Robust.Shared.Audio; @@ -13,6 +14,7 @@ using Robust.Shared.IoC; using Robust.Shared.Player; using Robust.Shared.Prototypes; using Robust.Shared.Random; +using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; namespace Content.Server.Research.Components @@ -24,7 +26,8 @@ namespace Content.Server.Research.Components [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IRobustRandom _random = default!; - private const string SoundCollectionName = "keyboard"; + [DataField("sound")] + private SoundSpecifier _soundCollectionName = new SoundCollectionSpecifier("keyboard"); [ViewVariables] private bool Powered => !Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) || receiver.Powered; @@ -123,9 +126,8 @@ namespace Content.Server.Research.Components private void PlayKeyboardSound() { - var soundCollection = _prototypeManager.Index(SoundCollectionName); - var file = _random.Pick(soundCollection.PickFiles); - SoundSystem.Play(Filter.Pvs(Owner), file,Owner,AudioParams.Default); + if (_soundCollectionName.TryGetSound(out var sound)) + SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default); } } } diff --git a/Content.Server/RoundEnd/RoundEndSystem.cs b/Content.Server/RoundEnd/RoundEndSystem.cs index 2e52ae73f8..87a6c96c9d 100644 --- a/Content.Server/RoundEnd/RoundEndSystem.cs +++ b/Content.Server/RoundEnd/RoundEndSystem.cs @@ -127,7 +127,7 @@ namespace Content.Server.RoundEnd private void EndRound() { OnRoundEndCountdownFinished?.Invoke(); - var gameTicker = EntitySystem.Get(); + var gameTicker = Get(); gameTicker.EndRound(); _chatManager.DispatchServerAnnouncement(Loc.GetString("round-end-system-round-restart-eta-announcement", ("seconds", RestartRoundTime))); diff --git a/Content.Server/Singularity/Components/EmitterComponent.cs b/Content.Server/Singularity/Components/EmitterComponent.cs index cf87e7955c..a6867aa84c 100644 --- a/Content.Server/Singularity/Components/EmitterComponent.cs +++ b/Content.Server/Singularity/Components/EmitterComponent.cs @@ -10,6 +10,7 @@ using Content.Shared.Interaction; using Content.Shared.Notification; using Content.Shared.Notification.Managers; using Content.Shared.Singularity.Components; +using Content.Shared.Sound; using Robust.Server.GameObjects; using Robust.Shared.Audio; using Robust.Shared.GameObjects; @@ -56,7 +57,7 @@ namespace Content.Server.Singularity.Components [ViewVariables(VVAccess.ReadWrite)] private int _fireShotCounter; - [ViewVariables(VVAccess.ReadWrite)] [DataField("fireSound")] private string _fireSound = "/Audio/Weapons/emitter.ogg"; + [ViewVariables(VVAccess.ReadWrite)] [DataField("fireSound")] private SoundSpecifier _fireSound = new SoundPathSpecifier("/Audio/Weapons/emitter.ogg"); [ViewVariables(VVAccess.ReadWrite)] [DataField("boltType")] private string _boltType = "EmitterBolt"; [ViewVariables(VVAccess.ReadWrite)] [DataField("powerUseActive")] private int _powerUseActive = 500; [ViewVariables(VVAccess.ReadWrite)] [DataField("fireBurstSize")] private int _fireBurstSize = 3; @@ -227,8 +228,9 @@ namespace Content.Server.Singularity.Components // TODO: Move to projectile's code. Timer.Spawn(3000, () => projectile.Delete()); - SoundSystem.Play(Filter.Pvs(Owner), _fireSound, Owner, - AudioHelpers.WithVariation(Variation).WithVolume(Volume).WithMaxDistance(Distance)); + if(_fireSound.TryGetSound(out var fireSound)) + SoundSystem.Play(Filter.Pvs(Owner), fireSound, Owner, + AudioHelpers.WithVariation(Variation).WithVolume(Volume).WithMaxDistance(Distance)); } private void UpdateAppearance() diff --git a/Content.Server/Singularity/Components/ServerSingularityComponent.cs b/Content.Server/Singularity/Components/ServerSingularityComponent.cs index 2588e68c1e..3cc65e74e7 100644 --- a/Content.Server/Singularity/Components/ServerSingularityComponent.cs +++ b/Content.Server/Singularity/Components/ServerSingularityComponent.cs @@ -1,6 +1,7 @@ #nullable enable using Content.Shared.Singularity; using Content.Shared.Singularity.Components; +using Content.Shared.Sound; using Robust.Shared.Audio; using Robust.Shared.Containers; using Robust.Shared.GameObjects; @@ -8,6 +9,7 @@ using Robust.Shared.Physics.Collision; using Robust.Shared.Physics.Dynamics; using Robust.Shared.Player; using Robust.Shared.Players; +using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Timing; using Robust.Shared.ViewVariables; @@ -69,6 +71,10 @@ namespace Content.Server.Singularity.Components private IPlayingAudioStream? _playingSound; + [DataField("singularityFormingSound")] private SoundSpecifier _singularityFormingSound = new SoundPathSpecifier("/Audio/Effects/singularity_form.ogg"); + [DataField("singularitySound")] private SoundSpecifier _singularitySound = new SoundPathSpecifier("/Audio/Effects/singularity.ogg"); + [DataField("singularityCollapsingSound")] private SoundSpecifier _singularityCollapsingSound = new SoundPathSpecifier("/Audio/Effects/singularity_collapse.ogg"); + public override ComponentState GetComponentState(ICommonSession player) { return new SingularityComponentState(Level); @@ -84,8 +90,9 @@ namespace Content.Server.Singularity.Components audioParams.Loop = true; audioParams.MaxDistance = 20f; audioParams.Volume = 5; - SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/singularity_form.ogg", Owner); - Timer.Spawn(5200,() => _playingSound = SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/singularity.ogg", Owner, audioParams)); + if(_singularityFormingSound.TryGetSound(out var singuloFormingSound)) + SoundSystem.Play(Filter.Pvs(Owner), singuloFormingSound, Owner); + Timer.Spawn(5200,() => _playingSound = SoundSystem.Play(Filter.Pvs(Owner), _singularitySound.GetSound(), Owner, audioParams)); _singularitySystem.ChangeSingularityLevel(this, 1); } @@ -138,7 +145,8 @@ namespace Content.Server.Singularity.Components protected override void OnRemove() { _playingSound?.Stop(); - SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/singularity_collapse.ogg", Owner.Transform.Coordinates); + if(_singularityCollapsingSound.TryGetSound(out var singuloCollapseSound)) + SoundSystem.Play(Filter.Pvs(Owner), singuloCollapseSound, Owner.Transform.Coordinates); base.OnRemove(); } } diff --git a/Content.Server/Sound/EmitSoundSystem.cs b/Content.Server/Sound/EmitSoundSystem.cs index af8efc8213..c579fa54e1 100644 --- a/Content.Server/Sound/EmitSoundSystem.cs +++ b/Content.Server/Sound/EmitSoundSystem.cs @@ -30,22 +30,15 @@ namespace Content.Server.Sound private void HandleEmitSoundOn(BaseEmitSoundComponent component) { - var soundName = component.Sound.GetSound(); - - if (!string.IsNullOrWhiteSpace(soundName)) - { - PlaySingleSound(soundName, component); + if (component.Sound.TryGetSound(out var soundName)) + { + SoundSystem.Play(Filter.Pvs(component.Owner), soundName, component.Owner, AudioHelpers.WithVariation(component.PitchVariation).WithVolume(-2f)); } else { Logger.Warning($"{nameof(component)} Uid:{component.Owner.Uid} has no {nameof(component.Sound)} to play."); } } - - private static void PlaySingleSound(string soundName, BaseEmitSoundComponent component) - { - SoundSystem.Play(Filter.Pvs(component.Owner), soundName, component.Owner, AudioHelpers.WithVariation(component.PitchVariation).WithVolume(-2f)); - } } } diff --git a/Content.Server/StationEvents/Events/GasLeak.cs b/Content.Server/StationEvents/Events/GasLeak.cs index 1b1a759993..f72ee6d5b3 100644 --- a/Content.Server/StationEvents/Events/GasLeak.cs +++ b/Content.Server/StationEvents/Events/GasLeak.cs @@ -1,6 +1,7 @@ using Content.Server.Atmos.Components; using Content.Server.GameTicking; using Content.Shared.Atmos; +using Content.Shared.Sound; using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.IoC; diff --git a/Content.Server/Storage/Components/CursedEntityStorageComponent.cs b/Content.Server/Storage/Components/CursedEntityStorageComponent.cs index 6bceb104c4..5b943e5f77 100644 --- a/Content.Server/Storage/Components/CursedEntityStorageComponent.cs +++ b/Content.Server/Storage/Components/CursedEntityStorageComponent.cs @@ -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)); } } } diff --git a/Content.Server/Storage/Components/EntityStorageComponent.cs b/Content.Server/Storage/Components/EntityStorageComponent.cs index 44993c0c19..ccdce8d8a8 100644 --- a/Content.Server/Storage/Components/EntityStorageComponent.cs +++ b/Content.Server/Storage/Components/EntityStorageComponent.cs @@ -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() diff --git a/Content.Server/Storage/Components/SecureEntityStorageComponent.cs b/Content.Server/Storage/Components/SecureEntityStorageComponent.cs index 5dcaf78cf4..8c3df45b4a 100644 --- a/Content.Server/Storage/Components/SecureEntityStorageComponent.cs +++ b/Content.Server/Storage/Components/SecureEntityStorageComponent.cs @@ -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) diff --git a/Content.Server/Storage/Components/ServerStorageComponent.cs b/Content.Server/Storage/Components/ServerStorageComponent.cs index 41def850b7..df6994069f 100644 --- a/Content.Server/Storage/Components/ServerStorageComponent.cs +++ b/Content.Server/Storage/Components/ServerStorageComponent.cs @@ -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 SubscribedSessions = new(); [DataField("storageSoundCollection")] - public string? StorageSoundCollection { get; set; } + public SoundSpecifier StorageSoundCollection { get; set; } = default!; [ViewVariables] public override IReadOnlyList? 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 /// The entity to open the UI for public void OpenStorageUI(IEntity entity) { - PlaySoundCollection(StorageSoundCollection); + PlaySoundCollection(); EnsureInitialCalculated(); var userSession = entity.GetComponent().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); } } } diff --git a/Content.Server/Stunnable/Components/StunbatonComponent.cs b/Content.Server/Stunnable/Components/StunbatonComponent.cs index 1c1a754948..46b5baa913 100644 --- a/Content.Server/Stunnable/Components/StunbatonComponent.cs +++ b/Content.Server/Stunnable/Components/StunbatonComponent.cs @@ -1,4 +1,5 @@ #nullable enable +using Content.Shared.Sound; using Robust.Shared.GameObjects; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; @@ -31,5 +32,14 @@ namespace Content.Server.Stunnable.Components [ViewVariables(VVAccess.ReadWrite)] [DataField("energyPerUse")] public float EnergyPerUse { get; set; } = 50; + + [DataField("stunSound")] + public SoundSpecifier StunSound { get; set; } = new SoundPathSpecifier("/Audio/Weapons/egloves.ogg"); + + [DataField("sparksSound")] + public SoundSpecifier SparksSound { get; set; } = new SoundCollectionSpecifier("sparks"); + + [DataField("turnOnFailSound")] + public SoundSpecifier TurnOnFailSound { get; set; } = new SoundPathSpecifier("/Audio/Machines/button.ogg"); } } diff --git a/Content.Server/Stunnable/Components/StunnableComponent.cs b/Content.Server/Stunnable/Components/StunnableComponent.cs index 1fec345fdb..9cd866f68a 100644 --- a/Content.Server/Stunnable/Components/StunnableComponent.cs +++ b/Content.Server/Stunnable/Components/StunnableComponent.cs @@ -4,6 +4,7 @@ using Content.Server.Notification; using Content.Shared.Audio; using Content.Shared.MobState; using Content.Shared.Notification.Managers; +using Content.Shared.Sound; using Content.Shared.Standing; using Content.Shared.Stunnable; using Robust.Shared.Audio; @@ -12,6 +13,7 @@ using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Player; using Robust.Shared.Random; +using Robust.Shared.Serialization.Manager.Attributes; namespace Content.Server.Stunnable.Components { @@ -19,6 +21,8 @@ namespace Content.Server.Stunnable.Components [ComponentReference(typeof(SharedStunnableComponent))] public class StunnableComponent : SharedStunnableComponent, IDisarmedAct { + [DataField("stunAttemptSound")] private SoundSpecifier _stunAttemptSound = new SoundPathSpecifier("/Audio/Effects/thudswoosh.ogg"); + protected override void OnKnockdown() { EntitySystem.Get().Down(Owner); @@ -54,7 +58,8 @@ namespace Content.Server.Stunnable.Components protected override void OnInteractHand() { - SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/thudswoosh.ogg", Owner, AudioHelpers.WithVariation(0.05f)); + if(_stunAttemptSound.TryGetSound(out var sound)) + SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioHelpers.WithVariation(0.05f)); } bool IDisarmedAct.Disarmed(DisarmedActEventArgs eventArgs) @@ -69,8 +74,8 @@ namespace Content.Server.Stunnable.Components if (source != null) { - SoundSystem.Play(Filter.Pvs(source), "/Audio/Effects/thudswoosh.ogg", source, - AudioHelpers.WithVariation(0.025f)); + if (_stunAttemptSound.TryGetSound(out var sound)) + SoundSystem.Play(Filter.Pvs(source), sound, source, AudioHelpers.WithVariation(0.025f)); if (target != null) { source.PopupMessageOtherClients(Loc.GetString("stunnable-component-disarm-success-others", ("source", source.Name),("target", target.Name))); diff --git a/Content.Server/Stunnable/StunbatonSystem.cs b/Content.Server/Stunnable/StunbatonSystem.cs index 683d44ebfb..fc705d77a0 100644 --- a/Content.Server/Stunnable/StunbatonSystem.cs +++ b/Content.Server/Stunnable/StunbatonSystem.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; using Content.Server.Items; using Content.Server.PowerCell.Components; using Content.Server.Stunnable.Components; @@ -119,7 +119,8 @@ namespace Content.Server.Stunnable { if (!entity.TryGetComponent(out StunnableComponent? stunnable) || !comp.Activated) return; - SoundSystem.Play(Filter.Pvs(comp.Owner), "/Audio/Weapons/egloves.ogg", comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); + if(comp.StunSound.TryGetSound(out var stunSound)) + SoundSystem.Play(Filter.Pvs(comp.Owner), stunSound, comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); if(!stunnable.SlowedDown) { if(_robustRandom.Prob(comp.ParalyzeChanceNoSlowdown)) @@ -136,9 +137,11 @@ namespace Content.Server.Stunnable } - if (!comp.Owner.TryGetComponent(out var slot) || slot.Cell == null || !(slot.Cell.CurrentCharge < comp.EnergyPerUse)) return; + if (!comp.Owner.TryGetComponent(out var slot) || slot.Cell == null || !(slot.Cell.CurrentCharge < comp.EnergyPerUse)) + return; - SoundSystem.Play(Filter.Pvs(comp.Owner), AudioHelpers.GetRandomFileFromSoundCollection("sparks"), comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); + if(comp.SparksSound.TryGetSound(out var sparksSound)) + SoundSystem.Play(Filter.Pvs(comp.Owner), sparksSound, comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); TurnOff(comp); } @@ -152,7 +155,8 @@ namespace Content.Server.Stunnable if (!comp.Owner.TryGetComponent(out var sprite) || !comp.Owner.TryGetComponent(out var item)) return; - SoundSystem.Play(Filter.Pvs(comp.Owner), AudioHelpers.GetRandomFileFromSoundCollection("sparks"), comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); + if(comp.SparksSound.TryGetSound(out var sparksSound)) + SoundSystem.Play(Filter.Pvs(comp.Owner), sparksSound, comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); item.EquippedPrefix = "off"; // TODO stunbaton visualizer sprite.LayerSetState(0, "stunbaton_off"); @@ -167,7 +171,8 @@ namespace Content.Server.Stunnable } if (!comp.Owner.TryGetComponent(out var sprite) || - !comp.Owner.TryGetComponent(out var item)) return; + !comp.Owner.TryGetComponent(out var item)) + return; var playerFilter = Filter.Pvs(comp.Owner); if (!comp.Owner.TryGetComponent(out var slot)) @@ -175,19 +180,22 @@ namespace Content.Server.Stunnable if (slot.Cell == null) { - SoundSystem.Play(playerFilter, "/Audio/Machines/button.ogg", comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); + if(comp.TurnOnFailSound.TryGetSound(out var turnOnFailSound)) + SoundSystem.Play(playerFilter, turnOnFailSound, comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); user.PopupMessage(Loc.GetString("comp-stunbaton-activated-missing-cell")); return; } if (slot.Cell != null && slot.Cell.CurrentCharge < comp.EnergyPerUse) { - SoundSystem.Play(playerFilter, "/Audio/Machines/button.ogg", comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); + if(comp.TurnOnFailSound.TryGetSound(out var turnOnFailSound)) + SoundSystem.Play(playerFilter, turnOnFailSound, comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); user.PopupMessage(Loc.GetString("comp-stunbaton-activated-dead-cell")); return; } - SoundSystem.Play(playerFilter, AudioHelpers.GetRandomFileFromSoundCollection("sparks"), comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); + if(comp.SparksSound.TryGetSound(out var sparksSound)) + SoundSystem.Play(playerFilter, sparksSound, comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); item.EquippedPrefix = "on"; sprite.LayerSetState(0, "stunbaton_on"); diff --git a/Content.Server/Tiles/FloorTileItemComponent.cs b/Content.Server/Tiles/FloorTileItemComponent.cs index ff9f224162..6399fadc63 100644 --- a/Content.Server/Tiles/FloorTileItemComponent.cs +++ b/Content.Server/Tiles/FloorTileItemComponent.cs @@ -5,6 +5,7 @@ using Content.Shared.Audio; using Content.Shared.Interaction; using Content.Shared.Interaction.Helpers; using Content.Shared.Maps; +using Content.Shared.Sound; using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.IoC; @@ -25,6 +26,8 @@ namespace Content.Server.Tiles [DataField("outputs", customTypeSerializer:typeof(PrototypeIdListSerializer))] private List? _outputTiles; + [DataField("placeTileSound")] SoundSpecifier _placeTileSound = new SoundPathSpecifier("/Audio/Items/genhit.ogg"); + protected override void Initialize() { base.Initialize(); @@ -46,8 +49,9 @@ namespace Content.Server.Tiles private void PlaceAt(IMapGrid mapGrid, EntityCoordinates location, ushort tileId, float offset = 0) { - mapGrid.SetTile(location.Offset(new Vector2(offset, offset)), new Robust.Shared.Map.Tile(tileId)); - SoundSystem.Play(Filter.Pvs(location), "/Audio/Items/genhit.ogg", location, AudioHelpers.WithVariation(0.125f)); + mapGrid.SetTile(location.Offset(new Vector2(offset, offset)), new Tile(tileId)); + if(_placeTileSound.TryGetSound(out var sound)) + SoundSystem.Play(Filter.Pvs(location), sound, location, AudioHelpers.WithVariation(0.125f)); } async Task IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs) diff --git a/Content.Server/Toilet/ToiletComponent.cs b/Content.Server/Toilet/ToiletComponent.cs index be6f3b6e4e..ad51e85d56 100644 --- a/Content.Server/Toilet/ToiletComponent.cs +++ b/Content.Server/Toilet/ToiletComponent.cs @@ -13,6 +13,7 @@ using Content.Shared.Examine; using Content.Shared.Interaction; using Content.Shared.Notification; using Content.Shared.Notification.Managers; +using Content.Shared.Sound; using Content.Shared.Toilet; using Content.Shared.Tool; using Robust.Server.GameObjects; @@ -22,6 +23,7 @@ using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Player; using Robust.Shared.Random; +using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Utility; using Robust.Shared.ViewVariables; @@ -42,6 +44,8 @@ namespace Content.Server.Toilet [ViewVariables] private SecretStashComponent _secretStash = default!; + [DataField("toggleSound")] SoundSpecifier _toggleSound = new SoundPathSpecifier("/Audio/Effects/toilet_seat_down.ogg"); + protected override void Initialize() { base.Initialize(); @@ -127,7 +131,8 @@ namespace Content.Server.Toilet public void ToggleToiletSeat() { IsSeatUp = !IsSeatUp; - SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/toilet_seat_down.ogg", Owner, AudioHelpers.WithVariation(0.05f)); + if(_toggleSound.TryGetSound(out var sound)) + SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioHelpers.WithVariation(0.05f)); UpdateSprite(); } diff --git a/Content.Server/Tools/Components/MultitoolComponent.cs b/Content.Server/Tools/Components/MultitoolComponent.cs index bc7508f373..267438618d 100644 --- a/Content.Server/Tools/Components/MultitoolComponent.cs +++ b/Content.Server/Tools/Components/MultitoolComponent.cs @@ -1,6 +1,7 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Content.Shared.Interaction; using Content.Shared.NetIDs; +using Content.Shared.Sound; using Content.Shared.Tool; using Robust.Server.GameObjects; using Robust.Shared.Audio; @@ -32,13 +33,10 @@ namespace Content.Server.Tools.Components public string Sprite { get; } = string.Empty; [DataField("useSound")] - public string Sound { get; } = string.Empty; - - [DataField("useSoundCollection")] - public string SoundCollection { get; } = string.Empty; + public SoundSpecifier Sound { get; } = default!; [DataField("changeSound")] - public string ChangeSound { get; } = string.Empty; + public SoundSpecifier ChangeSound { get; } = default!; } public override string Name => "MultiTool"; @@ -62,8 +60,8 @@ namespace Content.Server.Tools.Components _currentTool = (_currentTool + 1) % _tools.Count; SetTool(); var current = _tools[_currentTool]; - if(!string.IsNullOrEmpty(current.ChangeSound)) - SoundSystem.Play(Filter.Pvs(Owner), current.ChangeSound, Owner); + if(current.ChangeSound.TryGetSound(out var changeSound)) + SoundSystem.Play(Filter.Pvs(Owner), changeSound, Owner); } private void SetTool() @@ -73,7 +71,6 @@ namespace Content.Server.Tools.Components var current = _tools[_currentTool]; _tool.UseSound = current.Sound; - _tool.UseSoundCollection = current.SoundCollection; _tool.Qualities = current.Behavior; if (_sprite == null) return; diff --git a/Content.Server/Tools/Components/ToolComponent.cs b/Content.Server/Tools/Components/ToolComponent.cs index 8eff4dd539..9213c1877c 100644 --- a/Content.Server/Tools/Components/ToolComponent.cs +++ b/Content.Server/Tools/Components/ToolComponent.cs @@ -4,6 +4,7 @@ using Content.Server.DoAfter; using Content.Shared.ActionBlocker; using Content.Shared.Audio; using Content.Shared.Interaction.Events; +using Content.Shared.Sound; using Content.Shared.Tool; using Robust.Shared.Audio; using Robust.Shared.GameObjects; @@ -44,10 +45,7 @@ namespace Content.Server.Tools.Components public float SpeedModifier { get; set; } = 1; [DataField("useSound")] - public string? UseSound { get; set; } - - [DataField("useSoundCollection")] - public string? UseSoundCollection { get; set; } + public SoundSpecifier UseSound { get; set; } = default!; public void AddQuality(ToolQuality quality) { @@ -96,30 +94,10 @@ namespace Content.Server.Tools.Components return true; } - protected void PlaySoundCollection(string? name, float volume = -5f) + public void PlayUseSound(float volume = -5f) { - if (string.IsNullOrEmpty(name)) - { - return; - } - - var file = AudioHelpers.GetRandomFileFromSoundCollection(name); - SoundSystem.Play(Filter.Pvs(Owner), file, Owner, AudioHelpers.WithVariation(0.15f).WithVolume(volume)); - } - - public void PlayUseSound(float volume=-5f) - { - if (string.IsNullOrEmpty(UseSoundCollection)) - { - if (!string.IsNullOrEmpty(UseSound)) - { - SoundSystem.Play(Filter.Pvs(Owner), UseSound, Owner, AudioHelpers.WithVariation(0.15f).WithVolume(volume)); - } - } - else - { - PlaySoundCollection(UseSoundCollection, volume); - } + if(UseSound.TryGetSound(out var useSound)) + SoundSystem.Play(Filter.Pvs(Owner), useSound, Owner, AudioHelpers.WithVariation(0.15f).WithVolume(volume)); } } } diff --git a/Content.Server/Tools/Components/WelderComponent.cs b/Content.Server/Tools/Components/WelderComponent.cs index 2394ea0e39..d7c29b6f82 100644 --- a/Content.Server/Tools/Components/WelderComponent.cs +++ b/Content.Server/Tools/Components/WelderComponent.cs @@ -8,6 +8,7 @@ using Content.Server.Chemistry.Components; using Content.Server.Explosion; using Content.Server.Items; using Content.Server.Notification; +using Content.Shared.Audio; using Content.Shared.Chemistry; using Content.Shared.Chemistry.Reagent; using Content.Shared.Chemistry.Solution.Components; @@ -16,6 +17,7 @@ using Content.Shared.Interaction; using Content.Shared.NetIDs; using Content.Shared.Notification; using Content.Shared.Notification.Managers; +using Content.Shared.Sound; using Content.Shared.Temperature; using Content.Shared.Tool; using Robust.Server.GameObjects; @@ -58,8 +60,17 @@ namespace Content.Server.Tools.Components private SolutionContainerComponent? _solutionComponent; private PointLightComponent? _pointLightComponent; - [DataField("weldSoundCollection")] - public string? WeldSoundCollection { get; set; } + [DataField("weldSounds")] + private SoundSpecifier WeldSounds { get; set; } = default!; + + [DataField("welderOffSounds")] + private SoundSpecifier WelderOffSounds { get; set; } = new SoundCollectionSpecifier("WelderOff"); + + [DataField("welderOnSounds")] + private SoundSpecifier WelderOnSounds { get; set; } = new SoundCollectionSpecifier("WelderOn"); + + [DataField("welderRefill")] + private SoundSpecifier WelderRefill { get; set; } = new SoundPathSpecifier("/Audio/Effects/refill.ogg"); [ViewVariables] public float Fuel => _solutionComponent?.Solution?.GetReagentQuantity("WeldingFuel").Float() ?? 0f; @@ -160,9 +171,9 @@ namespace Content.Server.Tools.Components var succeeded = _solutionComponent.TryRemoveReagent("WeldingFuel", ReagentUnit.New(value)); - if (succeeded && !silent) + if (succeeded && !silent && WeldSounds.TryGetSound(out var weldSounds)) { - PlaySoundCollection(WeldSoundCollection); + PlaySound(weldSounds); } return succeeded; } @@ -193,7 +204,8 @@ namespace Content.Server.Tools.Components if (_pointLightComponent != null) _pointLightComponent.Enabled = false; - PlaySoundCollection("WelderOff", -5); + if(WelderOffSounds.TryGetSound(out var welderOffSOunds)) + PlaySound(welderOffSOunds, -5); _welderSystem.Unsubscribe(this); return true; } @@ -210,7 +222,8 @@ namespace Content.Server.Tools.Components if (_pointLightComponent != null) _pointLightComponent.Enabled = true; - PlaySoundCollection("WelderOn", -5); + if (WelderOnSounds.TryGetSound(out var welderOnSOunds)) + PlaySound(welderOnSOunds, -5); _welderSystem.Subscribe(this); Owner.Transform.Coordinates @@ -272,7 +285,8 @@ namespace Content.Server.Tools.Components if (TryWeld(5, victim, silent: true)) { - PlaySoundCollection(WeldSoundCollection); + if(WeldSounds.TryGetSound(out var weldSound)) + PlaySound(weldSound); othersMessage = Loc.GetString("welder-component-suicide-lit-others-message", @@ -325,13 +339,18 @@ namespace Content.Server.Tools.Components { var drained = targetSolution.Drain(trans); _solutionComponent.TryAddSolution(drained); - - SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/refill.ogg", Owner); + if(WelderRefill.TryGetSound(out var welderRefillSound)) + SoundSystem.Play(Filter.Pvs(Owner), welderRefillSound, Owner); eventArgs.Target.PopupMessage(eventArgs.User, Loc.GetString("welder-component-after-interact-refueled-message")); } } return true; } + + private void PlaySound(string soundName, float volume = -5f) + { + SoundSystem.Play(Filter.Pvs(Owner), soundName, Owner, AudioHelpers.WithVariation(0.15f).WithVolume(volume)); + } } } diff --git a/Content.Server/VendingMachines/VendingMachineComponent.cs b/Content.Server/VendingMachines/VendingMachineComponent.cs index 4b4bd3bca6..409a59dcb7 100644 --- a/Content.Server/VendingMachines/VendingMachineComponent.cs +++ b/Content.Server/VendingMachines/VendingMachineComponent.cs @@ -11,6 +11,7 @@ using Content.Server.WireHacking; using Content.Shared.Acts; using Content.Shared.Examine; using Content.Shared.Interaction; +using Content.Shared.Sound; using Content.Shared.VendingMachines; using Robust.Server.GameObjects; using Robust.Shared.Audio; @@ -46,10 +47,10 @@ namespace Content.Server.VendingMachines [DataField("soundVend")] // Grabbed from: https://github.com/discordia-space/CEV-Eris/blob/f702afa271136d093ddeb415423240a2ceb212f0/sound/machines/vending_drop.ogg - private string _soundVend = "/Audio/Machines/machine_vend.ogg"; + private SoundSpecifier _soundVend = new SoundPathSpecifier("/Audio/Machines/machine_vend.ogg"); [DataField("soundDeny")] // Yoinked from: https://github.com/discordia-space/CEV-Eris/blob/35bbad6764b14e15c03a816e3e89aa1751660ba9/sound/machines/Custom_deny.ogg - private string _soundDeny = "/Audio/Machines/custom_deny.ogg"; + private SoundSpecifier _soundDeny = new SoundPathSpecifier("/Audio/Machines/custom_deny.ogg"); [ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(VendingMachineUiKey.Key); @@ -202,7 +203,8 @@ namespace Content.Server.VendingMachines Owner.EntityManager.SpawnEntity(id, Owner.Transform.Coordinates); }); - SoundSystem.Play(Filter.Pvs(Owner), _soundVend, Owner, AudioParams.Default.WithVolume(-2f)); + if(_soundVend.TryGetSound(out var soundVend)) + SoundSystem.Play(Filter.Pvs(Owner), soundVend, Owner, AudioParams.Default.WithVolume(-2f)); } private void TryEject(string id, IEntity? sender) @@ -221,7 +223,8 @@ namespace Content.Server.VendingMachines private void Deny() { - SoundSystem.Play(Filter.Pvs(Owner), _soundDeny, Owner, AudioParams.Default.WithVolume(-2f)); + if(_soundDeny.TryGetSound(out var soundDeny)) + SoundSystem.Play(Filter.Pvs(Owner), soundDeny, Owner, AudioParams.Default.WithVolume(-2f)); // Play the Deny animation TrySetVisualState(VendingMachineVisualState.Deny); diff --git a/Content.Server/Weapon/Melee/Components/MeleeWeaponComponent.cs b/Content.Server/Weapon/Melee/Components/MeleeWeaponComponent.cs index fcf2719638..23c2a45a3d 100644 --- a/Content.Server/Weapon/Melee/Components/MeleeWeaponComponent.cs +++ b/Content.Server/Weapon/Melee/Components/MeleeWeaponComponent.cs @@ -1,5 +1,6 @@ using System; using Content.Shared.Damage; +using Content.Shared.Sound; using Robust.Shared.GameObjects; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; @@ -13,11 +14,11 @@ namespace Content.Server.Weapon.Melee.Components [ViewVariables(VVAccess.ReadWrite)] [DataField("hitSound")] - public string HitSound { get; set; } = "/Audio/Weapons/genhit1.ogg"; + public SoundSpecifier HitSound { get; set; } = new SoundPathSpecifier("/Audio/Weapons/genhit1.ogg"); [ViewVariables(VVAccess.ReadWrite)] [DataField("missSound")] - public string MissSound { get; set; } = "/Audio/Weapons/punchmiss.ogg"; + public SoundSpecifier MissSound { get; set; } = new SoundPathSpecifier("/Audio/Weapons/punchmiss.ogg"); [ViewVariables] [DataField("arcCooldownTime")] diff --git a/Content.Server/Weapon/Melee/MeleeWeaponSystem.cs b/Content.Server/Weapon/Melee/MeleeWeaponSystem.cs index 0c7a42785c..5d8541fe48 100644 --- a/Content.Server/Weapon/Melee/MeleeWeaponSystem.cs +++ b/Content.Server/Weapon/Melee/MeleeWeaponSystem.cs @@ -91,12 +91,14 @@ namespace Content.Server.Weapon.Melee damageableComponent.ChangeDamage(comp.DamageType, comp.Damage, false, owner); } - SoundSystem.Play(Filter.Pvs(owner), comp.HitSound, target); + if(comp.HitSound.TryGetSound(out var hitSound)) + SoundSystem.Play(Filter.Pvs(owner), hitSound, target); } } else { - SoundSystem.Play(Filter.Pvs(owner), comp.MissSound, args.User); + if(comp.MissSound.TryGetSound(out var missSound)) + SoundSystem.Play(Filter.Pvs(owner), missSound, args.User); return; } @@ -146,11 +148,13 @@ namespace Content.Server.Weapon.Melee { if (entities.Count != 0) { - SoundSystem.Play(Filter.Pvs(owner), comp.HitSound, entities.First().Transform.Coordinates); + if(comp.HitSound.TryGetSound(out var hitSound)) + SoundSystem.Play(Filter.Pvs(owner), hitSound, entities.First().Transform.Coordinates); } else { - SoundSystem.Play(Filter.Pvs(owner), comp.MissSound, args.User.Transform.Coordinates); + if(comp.MissSound.TryGetSound(out var missSound)) + SoundSystem.Play(Filter.Pvs(owner), missSound, args.User.Transform.Coordinates); } foreach (var entity in hitEntities) diff --git a/Content.Server/Weapon/Ranged/Ammunition/Components/AmmoComponent.cs b/Content.Server/Weapon/Ranged/Ammunition/Components/AmmoComponent.cs index e4605731c8..2d6ab30457 100644 --- a/Content.Server/Weapon/Ranged/Ammunition/Components/AmmoComponent.cs +++ b/Content.Server/Weapon/Ranged/Ammunition/Components/AmmoComponent.cs @@ -1,5 +1,6 @@ using System; using Content.Shared.Examine; +using Content.Shared.Sound; using Content.Shared.Weapons.Ranged.Barrels.Components; using Robust.Server.GameObjects; using Robust.Shared.GameObjects; @@ -82,7 +83,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components private string _muzzleFlashSprite = "Objects/Weapons/Guns/Projectiles/bullet_muzzle.png"; [DataField("soundCollectionEject")] - public string? SoundCollectionEject { get; } = "CasingEject"; + public SoundSpecifier SoundCollectionEject { get; } = new SoundCollectionSpecifier("CasingEject"); void ISerializationHooks.AfterDeserialization() { diff --git a/Content.Server/Weapon/Ranged/Barrels/Components/BoltActionBarrelComponent.cs b/Content.Server/Weapon/Ranged/Barrels/Components/BoltActionBarrelComponent.cs index 55a74605eb..1d3a93a5c0 100644 --- a/Content.Server/Weapon/Ranged/Barrels/Components/BoltActionBarrelComponent.cs +++ b/Content.Server/Weapon/Ranged/Barrels/Components/BoltActionBarrelComponent.cs @@ -7,6 +7,7 @@ using Content.Shared.Interaction; using Content.Shared.Interaction.Events; using Content.Shared.NetIDs; using Content.Shared.Notification.Managers; +using Content.Shared.Sound; using Content.Shared.Verbs; using Content.Shared.Weapons.Ranged.Barrels.Components; using Robust.Server.GameObjects; @@ -74,17 +75,17 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components if (value) { TryEjectChamber(); - if (_soundBoltOpen != null) + if (_soundBoltOpen.TryGetSound(out var soundBoltOpen)) { - SoundSystem.Play(Filter.Pvs(Owner), _soundBoltOpen, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); + SoundSystem.Play(Filter.Pvs(Owner), soundBoltOpen, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } } else { TryFeedChamber(); - if (_soundBoltClosed != null) + if (_soundBoltClosed.TryGetSound(out var soundBoltClosed)) { - SoundSystem.Play(Filter.Pvs(Owner), _soundBoltClosed, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); + SoundSystem.Play(Filter.Pvs(Owner), soundBoltClosed, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } } @@ -101,13 +102,13 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components // Sounds [DataField("soundCycle")] - private string _soundCycle = "/Audio/Weapons/Guns/Cock/sf_rifle_cock.ogg"; + private SoundSpecifier _soundCycle = new SoundPathSpecifier( "/Audio/Weapons/Guns/Cock/sf_rifle_cock.ogg"); [DataField("soundBoltOpen")] - private string _soundBoltOpen = "/Audio/Weapons/Guns/Bolt/rifle_bolt_open.ogg"; + private SoundSpecifier _soundBoltOpen = new SoundPathSpecifier("/Audio/Weapons/Guns/Bolt/rifle_bolt_open.ogg"); [DataField("soundBoltClosed")] - private string _soundBoltClosed = "/Audio/Weapons/Guns/Bolt/rifle_bolt_closed.ogg"; + private SoundSpecifier _soundBoltClosed = new SoundPathSpecifier("/Audio/Weapons/Guns/Bolt/rifle_bolt_closed.ogg"); [DataField("soundInsert")] - private string _soundInsert = "/Audio/Weapons/Guns/MagIn/bullet_insert.ogg"; + private SoundSpecifier _soundInsert = new SoundPathSpecifier("/Audio/Weapons/Guns/MagIn/bullet_insert.ogg"); void IMapInit.MapInit() { @@ -140,7 +141,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components chamber, FireRateSelector, count, - SoundGunshot); + SoundGunshot.GetSound()); } protected override void Initialize() @@ -224,9 +225,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components } else { - if (!string.IsNullOrEmpty(_soundCycle)) + if (_soundCycle.TryGetSound(out var soundCycle)) { - SoundSystem.Play(Filter.Pvs(Owner), _soundCycle, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); + SoundSystem.Play(Filter.Pvs(Owner), soundCycle, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } } @@ -256,9 +257,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components if (_chamberContainer.ContainedEntity == null) { _chamberContainer.Insert(ammo); - if (_soundInsert != null) + if (_soundInsert.TryGetSound(out var soundInsert)) { - SoundSystem.Play(Filter.Pvs(Owner), _soundInsert, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); + SoundSystem.Play(Filter.Pvs(Owner), soundInsert, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } Dirty(); UpdateAppearance(); @@ -269,9 +270,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components { _ammoContainer.Insert(ammo); _spawnedAmmo.Push(ammo); - if (_soundInsert != null) + if (_soundInsert.TryGetSound(out var soundInsert)) { - SoundSystem.Play(Filter.Pvs(Owner), _soundInsert, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); + SoundSystem.Play(Filter.Pvs(Owner), soundInsert, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } Dirty(); UpdateAppearance(); diff --git a/Content.Server/Weapon/Ranged/Barrels/Components/PumpBarrelComponent.cs b/Content.Server/Weapon/Ranged/Barrels/Components/PumpBarrelComponent.cs index df514a4417..ab3424102c 100644 --- a/Content.Server/Weapon/Ranged/Barrels/Components/PumpBarrelComponent.cs +++ b/Content.Server/Weapon/Ranged/Barrels/Components/PumpBarrelComponent.cs @@ -5,6 +5,7 @@ using Content.Shared.Interaction; using Content.Shared.NetIDs; using Content.Shared.Notification; using Content.Shared.Notification.Managers; +using Content.Shared.Sound; using Content.Shared.Weapons.Ranged.Barrels.Components; using Robust.Server.GameObjects; using Robust.Shared.Audio; @@ -65,10 +66,10 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components // Sounds [DataField("soundCycle")] - private string _soundCycle = "/Audio/Weapons/Guns/Cock/sf_rifle_cock.ogg"; + private SoundSpecifier _soundCycle = new SoundPathSpecifier("/Audio/Weapons/Guns/Cock/sf_rifle_cock.ogg"); [DataField("soundInsert")] - private string _soundInsert = "/Audio/Weapons/Guns/MagIn/bullet_insert.ogg"; + private SoundSpecifier _soundInsert = new SoundPathSpecifier("/Audio/Weapons/Guns/MagIn/bullet_insert.ogg"); void IMapInit.MapInit() { @@ -94,7 +95,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components chamber, FireRateSelector, count, - SoundGunshot); + SoundGunshot.GetSound()); } void ISerializationHooks.AfterDeserialization() @@ -189,9 +190,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components if (manual) { - if (!string.IsNullOrEmpty(_soundCycle)) + if (_soundCycle.TryGetSound(out var sound)) { - SoundSystem.Play(Filter.Pvs(Owner), _soundCycle, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); + SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } } @@ -218,9 +219,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components _spawnedAmmo.Push(eventArgs.Using); Dirty(); UpdateAppearance(); - if (_soundInsert != null) + if (_soundInsert.TryGetSound(out var soundInsert)) { - SoundSystem.Play(Filter.Pvs(Owner), _soundInsert, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); + SoundSystem.Play(Filter.Pvs(Owner), soundInsert, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } return true; } diff --git a/Content.Server/Weapon/Ranged/Barrels/Components/RevolverBarrelComponent.cs b/Content.Server/Weapon/Ranged/Barrels/Components/RevolverBarrelComponent.cs index 4ec03a3b28..ee82935f3f 100644 --- a/Content.Server/Weapon/Ranged/Barrels/Components/RevolverBarrelComponent.cs +++ b/Content.Server/Weapon/Ranged/Barrels/Components/RevolverBarrelComponent.cs @@ -6,6 +6,7 @@ using Content.Shared.Interaction; using Content.Shared.Interaction.Events; using Content.Shared.NetIDs; using Content.Shared.Notification.Managers; +using Content.Shared.Sound; using Content.Shared.Verbs; using Content.Shared.Weapons.Ranged.Barrels.Components; using Robust.Server.GameObjects; @@ -60,13 +61,13 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components // Sounds [DataField("soundEject")] - private string _soundEject = "/Audio/Weapons/Guns/MagOut/revolver_magout.ogg"; + private SoundSpecifier _soundEject = new SoundPathSpecifier("/Audio/Weapons/Guns/MagOut/revolver_magout.ogg"); [DataField("soundInsert")] - private string _soundInsert = "/Audio/Weapons/Guns/MagIn/revolver_magin.ogg"; + private SoundSpecifier _soundInsert = new SoundPathSpecifier("/Audio/Weapons/Guns/MagIn/revolver_magin.ogg"); [DataField("soundSpin")] - private string _soundSpin = "/Audio/Weapons/Guns/Misc/revolver_spin.ogg"; + private SoundSpecifier _soundSpin = new SoundPathSpecifier("/Audio/Weapons/Guns/Misc/revolver_spin.ogg"); void ISerializationHooks.BeforeSerialization() { @@ -96,7 +97,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components _currentSlot, FireRateSelector, slotsSpent, - SoundGunshot); + SoundGunshot.GetSound()); } protected override void Initialize() @@ -164,9 +165,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components _currentSlot = i; _ammoSlots[i] = entity; _ammoContainer.Insert(entity); - if (_soundInsert != null) + if (_soundInsert.TryGetSound(out var sound)) { - SoundSystem.Play(Filter.Pvs(Owner), _soundInsert, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); + SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } Dirty(); @@ -194,9 +195,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components { var random = _random.Next(_ammoSlots.Length - 1); _currentSlot = random; - if (!string.IsNullOrEmpty(_soundSpin)) + if (_soundSpin.TryGetSound(out var sound)) { - SoundSystem.Play(Filter.Pvs(Owner), _soundSpin, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); + SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } Dirty(); } @@ -248,9 +249,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components if (_ammoContainer.ContainedEntities.Count > 0) { - if (_soundEject != null) + if (_soundEject.TryGetSound(out var sound)) { - SoundSystem.Play(Filter.Pvs(Owner), _soundEject, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-1)); + SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-1)); } } diff --git a/Content.Server/Weapon/Ranged/Barrels/Components/ServerBatteryBarrelComponent.cs b/Content.Server/Weapon/Ranged/Barrels/Components/ServerBatteryBarrelComponent.cs index 9909470dac..25a91c47eb 100644 --- a/Content.Server/Weapon/Ranged/Barrels/Components/ServerBatteryBarrelComponent.cs +++ b/Content.Server/Weapon/Ranged/Barrels/Components/ServerBatteryBarrelComponent.cs @@ -10,6 +10,7 @@ using Content.Shared.Damage; using Content.Shared.Interaction; using Content.Shared.Interaction.Events; using Content.Shared.NetIDs; +using Content.Shared.Sound; using Content.Shared.Verbs; using Content.Shared.Weapons.Ranged.Barrels.Components; using Robust.Server.GameObjects; @@ -83,9 +84,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components // Sounds [DataField("soundPowerCellInsert")] - private string? _soundPowerCellInsert = default; + private SoundSpecifier _soundPowerCellInsert = default!; [DataField("soundPowerCellEject")] - private string? _soundPowerCellEject = default; + private SoundSpecifier _soundPowerCellEject = default!; public override ComponentState GetComponentState(ICommonSession player) { @@ -222,9 +223,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components return false; } - if (_soundPowerCellInsert != null) + if (_soundPowerCellInsert.TryGetSound(out var sound)) { - SoundSystem.Play(Filter.Pvs(Owner), _soundPowerCellInsert, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); + SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } _powerCellContainer.Insert(entity); @@ -275,9 +276,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components cell.Owner.Transform.Coordinates = user.Transform.Coordinates; } - if (_soundPowerCellEject != null) + if (_soundPowerCellEject.TryGetSound(out var sound)) { - SoundSystem.Play(Filter.Pvs(Owner), _soundPowerCellEject, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); + SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } return true; } diff --git a/Content.Server/Weapon/Ranged/Barrels/Components/ServerMagazineBarrelComponent.cs b/Content.Server/Weapon/Ranged/Barrels/Components/ServerMagazineBarrelComponent.cs index 15916e16bd..75a3eb3b43 100644 --- a/Content.Server/Weapon/Ranged/Barrels/Components/ServerMagazineBarrelComponent.cs +++ b/Content.Server/Weapon/Ranged/Barrels/Components/ServerMagazineBarrelComponent.cs @@ -10,6 +10,7 @@ using Content.Shared.Interaction; using Content.Shared.Interaction.Events; using Content.Shared.NetIDs; using Content.Shared.Notification.Managers; +using Content.Shared.Sound; using Content.Shared.Verbs; using Content.Shared.Weapons.Ranged; using Content.Shared.Weapons.Ranged.Barrels.Components; @@ -97,17 +98,17 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components if (value) { TryEjectChamber(); - if (_soundBoltOpen != null) + if (_soundBoltOpen.TryGetSound(out var soundBoltOpen)) { - SoundSystem.Play(Filter.Pvs(Owner), _soundBoltOpen, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); + SoundSystem.Play(Filter.Pvs(Owner), soundBoltOpen, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } } else { TryFeedChamber(); - if (_soundBoltClosed != null) + if (_soundBoltClosed.TryGetSound(out var soundBoltClosed)) { - SoundSystem.Play(Filter.Pvs(Owner), _soundBoltClosed, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); + SoundSystem.Play(Filter.Pvs(Owner), soundBoltClosed, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } } @@ -129,17 +130,17 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components // Sounds [DataField("soundBoltOpen")] - private string? _soundBoltOpen = default; + private SoundSpecifier _soundBoltOpen = default!; [DataField("soundBoltClosed")] - private string? _soundBoltClosed = default; + private SoundSpecifier _soundBoltClosed = default!; [DataField("soundRack")] - private string? _soundRack = default; + private SoundSpecifier _soundRack = default!; [DataField("soundMagInsert")] - private string? _soundMagInsert = default; + private SoundSpecifier _soundMagInsert = default!; [DataField("soundMagEject")] - private string? _soundMagEject = default; + private SoundSpecifier _soundMagEject = default!; [DataField("soundAutoEject")] - private string _soundAutoEject = "/Audio/Weapons/Guns/EmptyAlarm/smg_empty_alarm.ogg"; + private SoundSpecifier _soundAutoEject = new SoundPathSpecifier("/Audio/Weapons/Guns/EmptyAlarm/smg_empty_alarm.ogg"); private List GetMagazineTypes() { @@ -169,7 +170,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components _chamberContainer.ContainedEntity != null, FireRateSelector, count, - SoundGunshot); + SoundGunshot.GetSound()); } protected override void Initialize() @@ -228,9 +229,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components if (_chamberContainer.ContainedEntity == null && !BoltOpen) { - if (_soundBoltOpen != null) + if (_soundBoltOpen.TryGetSound(out var soundBoltOpen)) { - SoundSystem.Play(Filter.Pvs(Owner), _soundBoltOpen, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-5)); + SoundSystem.Play(Filter.Pvs(Owner), soundBoltOpen, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-5)); } if (Owner.TryGetContainer(out var container)) @@ -243,9 +244,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components if (manual) { - if (_soundRack != null) + if (_soundRack.TryGetSound(out var soundRack)) { - SoundSystem.Play(Filter.Pvs(Owner), _soundRack, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); + SoundSystem.Play(Filter.Pvs(Owner), soundRack, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } } @@ -271,9 +272,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components if (BoltOpen) { - if (_soundBoltClosed != null) + if (_soundBoltClosed.TryGetSound(out var soundBoltClosed)) { - SoundSystem.Play(Filter.Pvs(Owner), _soundBoltClosed, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-5)); + SoundSystem.Play(Filter.Pvs(Owner), soundBoltClosed, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-5)); } Owner.PopupMessage(eventArgs.User, Loc.GetString("server-magazine-barrel-component-use-entity-bolt-closed")); BoltOpen = false; @@ -325,9 +326,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components if (_autoEjectMag && magazine != null && magazine.GetComponent().ShotsLeft == 0) { - if (_soundAutoEject != null) + if (_soundAutoEject.TryGetSound(out var soundAutoEject)) { - SoundSystem.Play(Filter.Pvs(Owner), _soundAutoEject, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); + SoundSystem.Play(Filter.Pvs(Owner), soundAutoEject, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } _magazineContainer.Remove(magazine); @@ -352,9 +353,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components } _magazineContainer.Remove(mag); - if (_soundMagEject != null) + if (_soundMagEject.TryGetSound(out var soundMagEject)) { - SoundSystem.Play(Filter.Pvs(Owner), _soundMagEject, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); + SoundSystem.Play(Filter.Pvs(Owner), soundMagEject, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } if (user.TryGetComponent(out HandsComponent? handsComponent)) @@ -391,9 +392,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components if (_magazineContainer.ContainedEntity == null) { - if (_soundMagInsert != null) + if (_soundMagInsert.TryGetSound(out var soundMagInsert)) { - SoundSystem.Play(Filter.Pvs(Owner), _soundMagInsert, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); + SoundSystem.Play(Filter.Pvs(Owner), soundMagInsert, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } Owner.PopupMessage(eventArgs.User, Loc.GetString("server-magazine-barrel-component-interact-using-success")); _magazineContainer.Insert(eventArgs.Using); diff --git a/Content.Server/Weapon/Ranged/Barrels/Components/ServerRangedBarrelComponent.cs b/Content.Server/Weapon/Ranged/Barrels/Components/ServerRangedBarrelComponent.cs index 754757d7e9..4946167267 100644 --- a/Content.Server/Weapon/Ranged/Barrels/Components/ServerRangedBarrelComponent.cs +++ b/Content.Server/Weapon/Ranged/Barrels/Components/ServerRangedBarrelComponent.cs @@ -9,6 +9,7 @@ using Content.Shared.Audio; using Content.Shared.Damage.Components; using Content.Shared.Examine; using Content.Shared.Interaction; +using Content.Shared.Sound; using Content.Shared.Weapons.Ranged.Components; using Robust.Shared.Audio; using Robust.Shared.GameObjects; @@ -97,10 +98,10 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components // Sounds [DataField("soundGunshot")] - public string? SoundGunshot { get; set; } + public SoundSpecifier SoundGunshot { get; set; } = default!; [DataField("soundEmpty")] - public string SoundEmpty { get; } = "/Audio/Weapons/Guns/Empty/empty.ogg"; + public SoundSpecifier SoundEmpty { get; } = new SoundPathSpecifier("/Audio/Weapons/Guns/Empty/empty.ogg"); void ISerializationHooks.BeforeSerialization() { @@ -196,9 +197,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components { if (ShotsLeft == 0) { - if (SoundEmpty != null) + if (SoundEmpty.TryGetSound(out var sound)) { - SoundSystem.Play(Filter.Broadcast(), SoundEmpty, Owner.Transform.Coordinates); + SoundSystem.Play(Filter.Broadcast(), sound, Owner.Transform.Coordinates); } return; } @@ -207,7 +208,8 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components var projectile = TakeProjectile(shooter.Transform.Coordinates); if (projectile == null) { - SoundSystem.Play(Filter.Broadcast(), SoundEmpty, Owner.Transform.Coordinates); + if(SoundEmpty.TryGetSound(out var soundEmpty)) + SoundSystem.Play(Filter.Broadcast(), soundEmpty, Owner.Transform.Coordinates); return; } @@ -220,7 +222,6 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components recoilComponent.Kick(-angle.ToVec() * 0.15f); } - // This section probably needs tweaking so there can be caseless hitscan etc. if (projectile.TryGetComponent(out HitscanComponent? hitscan)) { @@ -248,9 +249,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components throw new InvalidOperationException(); } - if (!string.IsNullOrEmpty(SoundGunshot)) + if (SoundGunshot.TryGetSound(out var soundGunshot)) { - SoundSystem.Play(Filter.Broadcast(), SoundGunshot, Owner.Transform.Coordinates); + SoundSystem.Play(Filter.Broadcast(), soundGunshot, Owner.Transform.Coordinates); } _lastFire = _gameTiming.CurTime; @@ -282,16 +283,10 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components entity.Transform.Coordinates = entity.Transform.Coordinates.Offset(offsetPos); entity.Transform.LocalRotation = robustRandom.Pick(ejectDirections).ToAngle(); - if (ammo.SoundCollectionEject == null || !playSound) + if (ammo.SoundCollectionEject.TryGetSound(out var ejectSounds) && playSound) { - return; - } - - prototypeManager ??= IoCManager.Resolve(); - - var soundCollection = prototypeManager.Index(ammo.SoundCollectionEject); - var randomFile = robustRandom.Pick(soundCollection.PickFiles); - SoundSystem.Play(Filter.Broadcast(), randomFile, entity.Transform.Coordinates, AudioParams.Default.WithVolume(-1)); + SoundSystem.Play(Filter.Broadcast(), ejectSounds, entity.Transform.Coordinates, AudioParams.Default.WithVolume(-1)); + } } /// diff --git a/Content.Server/Weapon/Ranged/ServerRangedWeaponComponent.cs b/Content.Server/Weapon/Ranged/ServerRangedWeaponComponent.cs index 360786624d..a95ccc86f3 100644 --- a/Content.Server/Weapon/Ranged/ServerRangedWeaponComponent.cs +++ b/Content.Server/Weapon/Ranged/ServerRangedWeaponComponent.cs @@ -11,6 +11,7 @@ using Content.Shared.Damage.Components; using Content.Shared.Hands; using Content.Shared.Interaction.Events; using Content.Shared.Notification.Managers; +using Content.Shared.Sound; using Content.Shared.Weapons.Ranged.Components; using Robust.Shared.Audio; using Robust.Shared.GameObjects; @@ -48,6 +49,12 @@ namespace Content.Server.Weapon.Ranged [DataField("canHotspot")] private bool _canHotspot = true; + [DataField("clumsyWeaponHandlingSound")] + private SoundSpecifier _clumsyWeaponHandlingSound = new SoundPathSpecifier("/Audio/Items/bikehorn.ogg"); + + [DataField("clumsyWeaponShotSound")] + private SoundSpecifier _clumsyWeaponShotSound = new SoundPathSpecifier("/Audio/Weapons/Guns/Gunshots/bang.ogg"); + public Func? WeaponCanFireHandler; public Func? UserCanFireHandler; public Action? FireHandler; @@ -159,11 +166,13 @@ namespace Content.Server.Weapon.Ranged if (ClumsyCheck && ClumsyComponent.TryRollClumsy(user, ClumsyExplodeChance)) { - SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Items/bikehorn.ogg", - Owner.Transform.Coordinates, AudioParams.Default.WithMaxDistance(5)); + if(_clumsyWeaponHandlingSound.TryGetSound(out var clumsyWeaponHandlingSound)) + SoundSystem.Play(Filter.Pvs(Owner), clumsyWeaponHandlingSound, + Owner.Transform.Coordinates, AudioParams.Default.WithMaxDistance(5)); - SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Weapons/Guns/Gunshots/bang.ogg", - Owner.Transform.Coordinates, AudioParams.Default.WithMaxDistance(5)); + if(_clumsyWeaponShotSound.TryGetSound(out var clumsyWeaponShotSound)) + SoundSystem.Play(Filter.Pvs(Owner), clumsyWeaponShotSound, + Owner.Transform.Coordinates, AudioParams.Default.WithMaxDistance(5)); if (user.TryGetComponent(out IDamageableComponent? health)) { diff --git a/Content.Server/Window/WindowComponent.cs b/Content.Server/Window/WindowComponent.cs index 1a200d65e7..8e7d3cf2e3 100644 --- a/Content.Server/Window/WindowComponent.cs +++ b/Content.Server/Window/WindowComponent.cs @@ -9,6 +9,7 @@ using Content.Shared.Damage.Components; using Content.Shared.Examine; using Content.Shared.Interaction; using Content.Shared.Rounding; +using Content.Shared.Sound; using Content.Shared.Window; using Robust.Server.GameObjects; using Robust.Shared.Audio; @@ -37,6 +38,9 @@ namespace Content.Server.Window [DataField("rateLimitedKnocking")] [ViewVariables(VVAccess.ReadWrite)] private bool _rateLimitedKnocking = true; + [DataField("knockSound")] + private SoundSpecifier _knockSound = new SoundPathSpecifier("/Audio/Effects/glass_knock.ogg"); + public override void HandleMessage(ComponentMessage message, IComponent? component) { base.HandleMessage(message, component); @@ -130,8 +134,9 @@ namespace Content.Server.Window return false; } - SoundSystem.Play(Filter.Pvs(eventArgs.Target), "/Audio/Effects/glass_knock.ogg", - eventArgs.Target.Transform.Coordinates, AudioHelpers.WithVariation(0.05f)); + if(_knockSound.TryGetSound(out var sound)) + SoundSystem.Play(Filter.Pvs(eventArgs.Target), sound, + eventArgs.Target.Transform.Coordinates, AudioHelpers.WithVariation(0.05f)); eventArgs.Target.PopupMessageEveryone(Loc.GetString("comp-window-knock")); _lastKnockTime = _gameTiming.CurTime; diff --git a/Content.Server/WireHacking/WiresComponent.cs b/Content.Server/WireHacking/WiresComponent.cs index e48b1959dc..22051ab1e6 100644 --- a/Content.Server/WireHacking/WiresComponent.cs +++ b/Content.Server/WireHacking/WiresComponent.cs @@ -11,6 +11,7 @@ using Content.Shared.Examine; using Content.Shared.Interaction; using Content.Shared.Interaction.Helpers; using Content.Shared.Notification.Managers; +using Content.Shared.Sound; using Content.Shared.Tool; using Content.Shared.Wires; using JetBrains.Annotations; @@ -146,6 +147,15 @@ namespace Content.Server.WireHacking [DataField("LayoutId")] private string? _layoutId = default; + [DataField("pulseSound")] + private SoundSpecifier _pulseSound = new SoundPathSpecifier("/Audio/Effects/multitool_pulse.ogg"); + + [DataField("screwdriverOpenSound")] + private SoundSpecifier _screwdriverOpenSound = new SoundPathSpecifier("/Audio/Machines/screwdriveropen.ogg"); + + [DataField("screwdriverCloseSound")] + private SoundSpecifier _screwdriverCloseSound = new SoundPathSpecifier("/Audio/Machines/screwdriverclose.ogg"); + [ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(WiresUiKey.Key); protected override void Initialize() @@ -447,7 +457,8 @@ namespace Content.Server.WireHacking return; } - SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/multitool_pulse.ogg", Owner); + if(_pulseSound.TryGetSound(out var pulseSound)) + SoundSystem.Play(Filter.Pvs(Owner), pulseSound, Owner); break; } @@ -497,8 +508,21 @@ namespace Content.Server.WireHacking else if (await tool.UseTool(eventArgs.User, Owner, 0.5f, ToolQuality.Screwing)) { IsPanelOpen = !IsPanelOpen; - SoundSystem.Play(Filter.Pvs(Owner), IsPanelOpen ? "/Audio/Machines/screwdriveropen.ogg" : "/Audio/Machines/screwdriverclose.ogg", - Owner); + if (IsPanelOpen) + { + if(_screwdriverOpenSound.TryGetSound(out var openSound)) + { + SoundSystem.Play(Filter.Pvs(Owner), openSound, Owner); + } + } + else + { + if (_screwdriverCloseSound.TryGetSound(out var closeSound)) + { + SoundSystem.Play(Filter.Pvs(Owner), closeSound, Owner); + } + } + return true; } diff --git a/Content.Shared/Chemistry/Reaction/ReactionPrototype.cs b/Content.Shared/Chemistry/Reaction/ReactionPrototype.cs index c538ba8339..7e091ff651 100644 --- a/Content.Shared/Chemistry/Reaction/ReactionPrototype.cs +++ b/Content.Shared/Chemistry/Reaction/ReactionPrototype.cs @@ -1,6 +1,7 @@ #nullable enable using System.Collections.Generic; using Content.Shared.Chemistry.Reagent; +using Content.Shared.Sound; using Robust.Shared.Prototypes; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; @@ -38,7 +39,7 @@ namespace Content.Shared.Chemistry.Reaction public IReadOnlyList Effects => _effects; // TODO SERV3: Empty on the client, (de)serialize on the server with module manager is server module - [DataField("sound", serverOnly: true)] public string? Sound { get; private set; } = "/Audio/Effects/Chemistry/bubbles.ogg"; + [DataField("sound", serverOnly: true)] public SoundSpecifier Sound { get; private set; } = new SoundPathSpecifier("/Audio/Effects/Chemistry/bubbles.ogg"); } /// diff --git a/Content.Shared/Gravity/GravityComponent.cs b/Content.Shared/Gravity/GravityComponent.cs index 3dae237516..7050f236ca 100644 --- a/Content.Shared/Gravity/GravityComponent.cs +++ b/Content.Shared/Gravity/GravityComponent.cs @@ -1,9 +1,11 @@ using System; using Content.Shared.NetIDs; +using Content.Shared.Sound; using Robust.Shared.GameObjects; using Robust.Shared.Log; using Robust.Shared.Players; using Robust.Shared.Serialization; +using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; namespace Content.Shared.Gravity @@ -14,6 +16,9 @@ namespace Content.Shared.Gravity public override string Name => "Gravity"; public override uint? NetID => ContentNetIDs.GRAVITY; + [DataField("gravityShakeSound")] + public SoundSpecifier GravityShakeSound { get; set; } = new SoundPathSpecifier("/Audio/Effects/alert.ogg"); + [ViewVariables(VVAccess.ReadWrite)] public bool Enabled { diff --git a/Content.Shared/Kitchen/Components/SharedKitchenSpikeComponent.cs b/Content.Shared/Kitchen/Components/SharedKitchenSpikeComponent.cs index 020d4b23a5..6ac9122c65 100644 --- a/Content.Shared/Kitchen/Components/SharedKitchenSpikeComponent.cs +++ b/Content.Shared/Kitchen/Components/SharedKitchenSpikeComponent.cs @@ -1,6 +1,7 @@ #nullable enable using Content.Shared.DragDrop; using Content.Shared.Nutrition.Components; +using Content.Shared.Sound; using Robust.Shared.GameObjects; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; @@ -17,7 +18,7 @@ namespace Content.Shared.Kitchen.Components [ViewVariables(VVAccess.ReadWrite)] [DataField("sound")] - protected string? SpikeSound = "/Audio/Effects/Fluids/splat.ogg"; + protected SoundSpecifier SpikeSound = new SoundPathSpecifier("/Audio/Effects/Fluids/splat.ogg"); bool IDragDropOn.CanDragDropOn(DragDropEvent eventArgs) { diff --git a/Content.Shared/Light/Component/SharedExpendableLightComponent.cs b/Content.Shared/Light/Component/SharedExpendableLightComponent.cs index 618b0edfc1..2898549e92 100644 --- a/Content.Shared/Light/Component/SharedExpendableLightComponent.cs +++ b/Content.Shared/Light/Component/SharedExpendableLightComponent.cs @@ -1,5 +1,6 @@ -#nullable enable +#nullable enable using System; +using Content.Shared.Sound; using Robust.Shared.Serialization; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; @@ -62,14 +63,14 @@ namespace Content.Shared.Light.Component [ViewVariables] [DataField("litSound")] - protected string LitSound { get; set; } = string.Empty; + protected SoundSpecifier LitSound { get; set; } = default!; [ViewVariables] [DataField("loopedSound")] - protected string LoopedSound { get; set; } = string.Empty; + protected string LoopedSound { get; set; } = default!; [ViewVariables] [DataField("dieSound")] - protected string DieSound { get; set; } = string.Empty; + protected SoundSpecifier DieSound { get; set; } = default!; } } diff --git a/Content.Shared/Maps/ContentTileDefinition.cs b/Content.Shared/Maps/ContentTileDefinition.cs index 7e9849502e..bfff430f8b 100644 --- a/Content.Shared/Maps/ContentTileDefinition.cs +++ b/Content.Shared/Maps/ContentTileDefinition.cs @@ -1,11 +1,12 @@ -#nullable enable -using System.Collections.Generic; +#nullable enable +using Content.Shared.Sound; using JetBrains.Annotations; using Robust.Shared.Map; using Robust.Shared.Prototypes; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; using Robust.Shared.ViewVariables; +using System.Collections.Generic; namespace Content.Shared.Maps { @@ -30,7 +31,7 @@ namespace Content.Shared.Maps [DataField("can_crowbar")] public bool CanCrowbar { get; private set; } - [DataField("footstep_sounds")] public string FootstepSounds { get; } = string.Empty; + [DataField("footstep_sounds")] public SoundSpecifier FootstepSounds { get; } = default!; [DataField("friction")] public float Friction { get; set; } diff --git a/Content.Shared/Slippery/SlipperyComponent.cs b/Content.Shared/Slippery/SlipperyComponent.cs index 12053612ae..d06a108383 100644 --- a/Content.Shared/Slippery/SlipperyComponent.cs +++ b/Content.Shared/Slippery/SlipperyComponent.cs @@ -6,6 +6,7 @@ using Content.Shared.Audio; using Content.Shared.EffectBlocker; using Content.Shared.Module; using Content.Shared.NetIDs; +using Content.Shared.Sound; using Content.Shared.Stunnable; using Robust.Shared.Audio; using Robust.Shared.Containers; @@ -36,7 +37,7 @@ namespace Content.Shared.Slippery private float _requiredSlipSpeed = 0.1f; private float _launchForwardsMultiplier = 1f; private bool _slippery = true; - private string _slipSound = "/Audio/Effects/slip.ogg"; + private SoundSpecifier _slipSound = new SoundPathSpecifier("/Audio/Effects/slip.ogg"); /// /// List of entities that are currently colliding with the entity. @@ -53,7 +54,7 @@ namespace Content.Shared.Slippery /// [ViewVariables] [DataField("slipSound")] - public string SlipSound + public SoundSpecifier SlipSound { get => _slipSound; set @@ -184,9 +185,9 @@ namespace Content.Shared.Slippery _slipped.Add(otherBody.Owner.Uid); Dirty(); - if (!string.IsNullOrEmpty(SlipSound) && _moduleManager.IsServerModule) + if (SlipSound.TryGetSound(out var slipSound) && _moduleManager.IsServerModule) { - SoundSystem.Play(Filter.Broadcast(), SlipSound, Owner, AudioHelpers.WithVariation(0.2f)); + SoundSystem.Play(Filter.Broadcast(), slipSound, Owner, AudioHelpers.WithVariation(0.2f)); } return true; @@ -232,7 +233,7 @@ namespace Content.Shared.Slippery public override ComponentState GetComponentState(ICommonSession player) { - return new SlipperyComponentState(ParalyzeTime, IntersectPercentage, RequiredSlipSpeed, LaunchForwardsMultiplier, Slippery, SlipSound, _slipped.ToArray()); + return new SlipperyComponentState(ParalyzeTime, IntersectPercentage, RequiredSlipSpeed, LaunchForwardsMultiplier, Slippery, SlipSound.GetSound(), _slipped.ToArray()); } public override void HandleComponentState(ComponentState? curState, ComponentState? nextState) @@ -244,7 +245,7 @@ namespace Content.Shared.Slippery _paralyzeTime = state.ParalyzeTime; _requiredSlipSpeed = state.RequiredSlipSpeed; _launchForwardsMultiplier = state.LaunchForwardsMultiplier; - _slipSound = state.SlipSound; + _slipSound = new SoundPathSpecifier(state.SlipSound); _slipped.Clear(); foreach (var slipped in state.Slipped) diff --git a/Content.Shared/Sound/SoundSpecifier.cs b/Content.Shared/Sound/SoundSpecifier.cs index 616ccf9551..dff9987880 100644 --- a/Content.Shared/Sound/SoundSpecifier.cs +++ b/Content.Shared/Sound/SoundSpecifier.cs @@ -1,10 +1,9 @@ -using System; using Content.Shared.Audio; -using Robust.Shared; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.TypeSerializers.Implementations; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; using Robust.Shared.Utility; +using System.Diagnostics.CodeAnalysis; namespace Content.Shared.Sound { @@ -12,6 +11,8 @@ namespace Content.Shared.Sound public abstract class SoundSpecifier { public abstract string GetSound(); + + public abstract bool TryGetSound([NotNullWhen(true)] out string? sound); } [DataDefinition] @@ -19,7 +20,7 @@ namespace Content.Shared.Sound { public const string Node = "path"; - [DataField(Node, customTypeSerializer:typeof(ResourcePathSerializer), required:true)] + [DataField(Node, customTypeSerializer: typeof(ResourcePathSerializer), required: true)] public ResourcePath? Path { get; } public SoundPathSpecifier() @@ -40,6 +41,12 @@ namespace Content.Shared.Sound { return Path == null ? string.Empty : Path.ToString(); } + + public override bool TryGetSound([NotNullWhen(true)] out string? sound) + { + sound = GetSound(); + return !string.IsNullOrWhiteSpace(sound); + } } [DataDefinition] @@ -47,7 +54,7 @@ namespace Content.Shared.Sound { public const string Node = "collection"; - [DataField(Node, customTypeSerializer:typeof(PrototypeIdSerializer), required:true)] + [DataField(Node, customTypeSerializer: typeof(PrototypeIdSerializer), required: true)] public string? Collection { get; } public SoundCollectionSpecifier() @@ -63,5 +70,11 @@ namespace Content.Shared.Sound { return Collection == null ? string.Empty : AudioHelpers.GetRandomFileFromSoundCollection(Collection); } + + public override bool TryGetSound([NotNullWhen(true)] out string? sound) + { + sound = GetSound(); + return !string.IsNullOrWhiteSpace(sound); + } } } diff --git a/Content.Shared/Standing/StandingStateComponent.cs b/Content.Shared/Standing/StandingStateComponent.cs index 1ed4fcd8c0..dcba6f3490 100644 --- a/Content.Shared/Standing/StandingStateComponent.cs +++ b/Content.Shared/Standing/StandingStateComponent.cs @@ -1,6 +1,7 @@ using System; using Content.Shared.EffectBlocker; using Content.Shared.NetIDs; +using Content.Shared.Sound; using Robust.Shared.GameObjects; using Robust.Shared.Players; using Robust.Shared.Serialization; @@ -18,7 +19,7 @@ namespace Content.Shared.Standing [ViewVariables(VVAccess.ReadWrite)] [DataField("downSoundCollection")] - public string? DownSoundCollection { get; } = "BodyFall"; + public SoundSpecifier DownSoundCollection { get; } = new SoundCollectionSpecifier("BodyFall"); [ViewVariables] [DataField("standing")] diff --git a/Content.Shared/Standing/StandingStateSystem.cs b/Content.Shared/Standing/StandingStateSystem.cs index 51b98b7070..3932e5d0f7 100644 --- a/Content.Shared/Standing/StandingStateSystem.cs +++ b/Content.Shared/Standing/StandingStateSystem.cs @@ -62,12 +62,9 @@ namespace Content.Shared.Standing } // Currently shit is only downed by server but when it's predicted we can probably only play this on server / client - var sound = component.DownSoundCollection; - - if (playSound && !string.IsNullOrEmpty(sound)) + if (playSound && component.DownSoundCollection.TryGetSound(out var sound)) { - var file = AudioHelpers.GetRandomFileFromSoundCollection(sound); - SoundSystem.Play(Filter.Pvs(entity), file, entity, AudioHelpers.WithVariation(0.25f)); + SoundSystem.Play(Filter.Pvs(entity), sound, entity, AudioHelpers.WithVariation(0.25f)); } } diff --git a/Resources/Prototypes/Actions/actions.yml b/Resources/Prototypes/Actions/actions.yml index 12cd4632c6..bfa19e8785 100644 --- a/Resources/Prototypes/Actions/actions.yml +++ b/Resources/Prototypes/Actions/actions.yml @@ -29,19 +29,11 @@ behavior: !type:ScreamAction cooldown: 10 male: - - /Audio/Voice/Human/malescream_1.ogg - - /Audio/Voice/Human/malescream_2.ogg - - /Audio/Voice/Human/malescream_3.ogg - - /Audio/Voice/Human/malescream_4.ogg - - /Audio/Voice/Human/malescream_5.ogg - - /Audio/Voice/Human/malescream_6.ogg + collection: MaleScreams female: - - /Audio/Voice/Human/femalescream_1.ogg - - /Audio/Voice/Human/femalescream_2.ogg - - /Audio/Voice/Human/femalescream_3.ogg - - /Audio/Voice/Human/femalescream_4.ogg - - /Audio/Voice/Human/femalescream_5.ogg - wilhelm: /Audio/Voice/Human/wilhelm_scream.ogg + collection: FemaleScreams + wilhelm: + path: /Audio/Voice/Human/wilhelm_scream.ogg - type: action actionType: VoxScream @@ -53,10 +45,11 @@ behavior: !type:ScreamAction cooldown: 10 male: - - /Audio/Voice/Vox/shriek1.ogg + path: /Audio/Voice/Vox/shriek1.ogg female: - - /Audio/Voice/Vox/shriek1.ogg - wilhelm: /Audio/Voice/Human/wilhelm_scream.ogg + path: /Audio/Voice/Vox/shriek1.ogg + wilhelm: + path: /Audio/Voice/Human/wilhelm_scream.ogg - type: action actionType: GhostBoo diff --git a/Resources/Prototypes/Actions/spells.yml b/Resources/Prototypes/Actions/spells.yml index cfcb1709ce..f7a93149b8 100644 --- a/Resources/Prototypes/Actions/spells.yml +++ b/Resources/Prototypes/Actions/spells.yml @@ -10,4 +10,5 @@ spellItem: FoodPieBananaCream castMessage: I NEED A PIE! cooldown: 15 - castSound: /Audio/Items/bikehorn.ogg + castSound: + path: /Audio/Items/bikehorn.ogg diff --git a/Resources/Prototypes/Entities/Constructible/Walls/extinguisher_cabinet.yml b/Resources/Prototypes/Entities/Constructible/Walls/extinguisher_cabinet.yml index d4b64963df..f4e7e8ce3d 100644 --- a/Resources/Prototypes/Entities/Constructible/Walls/extinguisher_cabinet.yml +++ b/Resources/Prototypes/Entities/Constructible/Walls/extinguisher_cabinet.yml @@ -10,7 +10,8 @@ netsync: false state: extinguisher_closed - type: ItemCabinet - doorSound: /Audio/Machines/machine_switch.ogg + doorSound: + path: /Audio/Machines/machine_switch.ogg whitelist: components: - FireExtinguisher diff --git a/Resources/Prototypes/Entities/Constructible/Walls/fireaxe_cabinet.yml b/Resources/Prototypes/Entities/Constructible/Walls/fireaxe_cabinet.yml index 1d5e811f09..1eff1df28e 100644 --- a/Resources/Prototypes/Entities/Constructible/Walls/fireaxe_cabinet.yml +++ b/Resources/Prototypes/Entities/Constructible/Walls/fireaxe_cabinet.yml @@ -10,7 +10,8 @@ netsync: false state: cabinet-filled-closed - type: ItemCabinet - doorSound: /Audio/Machines/machine_switch.ogg + doorSound: + path: /Audio/Machines/machine_switch.ogg whitelist: tags: - FireAxe diff --git a/Resources/Prototypes/Entities/Objects/Misc/fire_extinguisher.yml b/Resources/Prototypes/Entities/Objects/Misc/fire_extinguisher.yml index a024fba25d..40fffbd0a8 100644 --- a/Resources/Prototypes/Entities/Objects/Misc/fire_extinguisher.yml +++ b/Resources/Prototypes/Entities/Objects/Misc/fire_extinguisher.yml @@ -21,7 +21,8 @@ Quantity: 100 - type: ItemCooldown - type: Spray - spraySound: /Audio/Effects/extinguish.ogg + spraySound: + path: /Audio/Effects/extinguish.ogg sprayedPrototype: ExtinguisherSpray hasSafety: true vaporAmount: 3 diff --git a/Resources/Prototypes/Entities/Objects/Specific/Janitorial/spray.yml b/Resources/Prototypes/Entities/Objects/Specific/Janitorial/spray.yml index 0bae25cef0..bd7595458f 100644 --- a/Resources/Prototypes/Entities/Objects/Specific/Janitorial/spray.yml +++ b/Resources/Prototypes/Entities/Objects/Specific/Janitorial/spray.yml @@ -21,7 +21,8 @@ - type: Spray transferAmount: 10 sprayVelocity: 2 - spraySound: /Audio/Effects/spray2.ogg + spraySound: + path: /Audio/Effects/spray2.ogg - type: entity name: spray bottle diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/projectiles.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/projectiles.yml index 8237a11655..b59bb177f8 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/projectiles.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/projectiles.yml @@ -102,7 +102,8 @@ ammoVelocity: 20 caliber: Energy - type: Projectile - soundHitSpecies: "/Audio/Weapons/Guns/Hits/taser_hit.ogg" + soundHit: + path: "/Audio/Weapons/Guns/Hits/taser_hit.ogg" damages: Heat: 5 - type: StunnableProjectile diff --git a/Resources/Prototypes/SoundCollections/screams.yml b/Resources/Prototypes/SoundCollections/screams.yml new file mode 100644 index 0000000000..5f8b9690ba --- /dev/null +++ b/Resources/Prototypes/SoundCollections/screams.yml @@ -0,0 +1,18 @@ +- type: soundCollection + id: MaleScreams + files: + - /Audio/Voice/Human/malescream_1.ogg + - /Audio/Voice/Human/malescream_2.ogg + - /Audio/Voice/Human/malescream_3.ogg + - /Audio/Voice/Human/malescream_4.ogg + - /Audio/Voice/Human/malescream_5.ogg + - /Audio/Voice/Human/malescream_6.ogg + +- type: soundCollection + id: FemaleScreams + files: + - /Audio/Voice/Human/femalescream_1.ogg + - /Audio/Voice/Human/femalescream_2.ogg + - /Audio/Voice/Human/femalescream_3.ogg + - /Audio/Voice/Human/femalescream_4.ogg + - /Audio/Voice/Human/femalescream_5.ogg From 26f9a6085885a3a257c26e7145fcc56452c0b37a Mon Sep 17 00:00:00 2001 From: Galactic Chimp Date: Mon, 12 Jul 2021 13:38:05 +0200 Subject: [PATCH 07/18] #4219 pr tweaks --- Content.Server/Sound/EmitSoundSystem.cs | 30 ++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/Content.Server/Sound/EmitSoundSystem.cs b/Content.Server/Sound/EmitSoundSystem.cs index c579fa54e1..42207d9eae 100644 --- a/Content.Server/Sound/EmitSoundSystem.cs +++ b/Content.Server/Sound/EmitSoundSystem.cs @@ -22,13 +22,33 @@ namespace Content.Server.Sound public override void Initialize() { base.Initialize(); - SubscribeLocalEvent((eUI, comp, arg) => HandleEmitSoundOn(comp)); - SubscribeLocalEvent((eUI, comp, arg) => HandleEmitSoundOn(comp)); - SubscribeLocalEvent((eUI, comp, arg) => HandleEmitSoundOn(comp)); - SubscribeLocalEvent((eUI, comp, args) => HandleEmitSoundOn(comp)); + SubscribeLocalEvent(HandleEmitSoundOnLand); + SubscribeLocalEvent(HandleEmitSoundOnUseInHand); + SubscribeLocalEvent(HandleEmitSoundOnThrown); + SubscribeLocalEvent(HandleEmitSoundOnActivateInWorld); } - private void HandleEmitSoundOn(BaseEmitSoundComponent component) + private void HandleEmitSoundOnLand(EntityUid eUI, BaseEmitSoundComponent component, LandEvent arg) + { + TryEmitSound(component); + } + + private void HandleEmitSoundOnUseInHand(EntityUid eUI, BaseEmitSoundComponent component, UseInHandEvent arg) + { + TryEmitSound(component); + } + + private void HandleEmitSoundOnThrown(EntityUid eUI, BaseEmitSoundComponent component, ThrownEvent arg) + { + TryEmitSound(component); + } + + private void HandleEmitSoundOnActivateInWorld(EntityUid eUI, BaseEmitSoundComponent component, ActivateInWorldEvent arg) + { + TryEmitSound(component); + } + + private static void TryEmitSound(BaseEmitSoundComponent component) { if (component.Sound.TryGetSound(out var soundName)) { From aff9d99dc702b6bffde4d88f85985b0f6c560391 Mon Sep 17 00:00:00 2001 From: Galactic Chimp Date: Mon, 12 Jul 2021 13:43:54 +0200 Subject: [PATCH 08/18] #4219 pr tweak (cherry picked from commit 00b80cb1df2434259ab5df45188e176be57603af) --- Content.Server/Sound/EmitSoundSystem.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Content.Server/Sound/EmitSoundSystem.cs b/Content.Server/Sound/EmitSoundSystem.cs index 42207d9eae..240ee28f3d 100644 --- a/Content.Server/Sound/EmitSoundSystem.cs +++ b/Content.Server/Sound/EmitSoundSystem.cs @@ -50,9 +50,9 @@ namespace Content.Server.Sound private static void TryEmitSound(BaseEmitSoundComponent component) { - if (component.Sound.TryGetSound(out var soundName)) + if (!string.IsNullOrWhiteSpace(component.Sound.GetSound())) { - SoundSystem.Play(Filter.Pvs(component.Owner), soundName, component.Owner, AudioHelpers.WithVariation(component.PitchVariation).WithVolume(-2f)); + SoundSystem.Play(Filter.Pvs(component.Owner), component.Sound.GetSound(), component.Owner, AudioHelpers.WithVariation(component.PitchVariation).WithVolume(-2f)); } else { From f3ef50c1d9cf1dbbb9b93ea7a6763eb5b31086cf Mon Sep 17 00:00:00 2001 From: Galactic Chimp Date: Mon, 12 Jul 2021 13:45:35 +0200 Subject: [PATCH 09/18] emitsoundsystem tweak --- Content.Server/Sound/EmitSoundSystem.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Content.Server/Sound/EmitSoundSystem.cs b/Content.Server/Sound/EmitSoundSystem.cs index 240ee28f3d..e397d51d01 100644 --- a/Content.Server/Sound/EmitSoundSystem.cs +++ b/Content.Server/Sound/EmitSoundSystem.cs @@ -50,9 +50,9 @@ namespace Content.Server.Sound private static void TryEmitSound(BaseEmitSoundComponent component) { - if (!string.IsNullOrWhiteSpace(component.Sound.GetSound())) + if (component.Sound.TryGetSound(out var sound)) { - SoundSystem.Play(Filter.Pvs(component.Owner), component.Sound.GetSound(), component.Owner, AudioHelpers.WithVariation(component.PitchVariation).WithVolume(-2f)); + SoundSystem.Play(Filter.Pvs(component.Owner), sound, component.Owner, AudioHelpers.WithVariation(component.PitchVariation).WithVolume(-2f)); } else { From b2e40d540f2e3afeca99c86359a140a021e200c8 Mon Sep 17 00:00:00 2001 From: Galactic Chimp Date: Sat, 31 Jul 2021 15:17:16 +0200 Subject: [PATCH 10/18] Inserted SoundSpecifier where appropiate --- .../Visualizers/DisposalUnitVisualizer.cs | 9 +- Content.Client/Doors/AirlockVisualizer.cs | 20 ++-- .../Visualizers/PoweredLightVisualizer.cs | 7 +- .../Trigger/TimerTriggerVisualizer.cs | 9 +- .../Components/ProjectileComponent.cs | 5 +- .../Projectiles/ProjectileSystem.cs | 8 +- Resources/Maps/saltern.yml | 4 +- .../Entities/Clothing/Back/backpacks.yml | 3 +- .../Entities/Clothing/Back/duffel.yml | 3 +- .../Entities/Clothing/Back/satchel.yml | 3 +- .../Entities/Clothing/Shoes/specific.yml | 3 +- .../Entities/Debugging/spanisharmyknife.yml | 24 ++-- .../Prototypes/Entities/Effects/puddle.yml | 3 +- .../Entities/Mobs/NPCs/simplemob.yml | 3 +- .../Entities/Mobs/Species/human.yml | 3 +- .../Consumable/Food/Containers/bowl.yml | 4 +- .../Consumable/Food/Containers/box.yml | 4 +- .../Consumable/Food/Containers/condiments.yml | 9 +- .../Consumable/Food/Containers/plate.yml | 8 +- .../Consumable/Food/Containers/tin.yml | 16 +-- .../Entities/Objects/Consumable/Food/egg.yml | 4 +- .../Objects/Consumable/Food/ingredients.yml | 14 ++- .../Objects/Consumable/Food/produce.yml | 4 +- .../Entities/Objects/Consumable/Food/soup.yml | 4 +- .../Entities/Objects/Consumable/drinks.yml | 4 +- .../Objects/Consumable/drinks_bottles.yml | 7 +- .../Objects/Consumable/drinks_cans.yml | 3 +- .../Prototypes/Entities/Objects/Fun/toys.yml | 18 ++- .../Objects/Misc/fire_extinguisher.yml | 3 +- .../Entities/Objects/Misc/fluff_lights.yml | 6 +- .../Entities/Objects/Misc/handcuffs.yml | 15 ++- .../Entities/Objects/Misc/torch.yml | 3 +- .../Entities/Objects/Power/lights.yml | 8 +- .../Objects/Specific/Janitorial/trashbag.yml | 6 +- .../Objects/Specific/Medical/morgue.yml | 6 +- .../Objects/Specific/Medical/surgery.yml | 24 ++-- .../Entities/Objects/Specific/chemistry.yml | 4 +- .../Entities/Objects/Tools/cowtools.yml | 9 +- .../Entities/Objects/Tools/flare.yml | 3 +- .../Entities/Objects/Tools/glowstick.yml | 15 ++- .../Entities/Objects/Tools/jaws_of_life.yml | 12 +- .../Entities/Objects/Tools/matches.yml | 3 +- .../Entities/Objects/Tools/toolbox.yml | 3 +- .../Entities/Objects/Tools/tools.yml | 24 ++-- .../Guns/Ammunition/Cartridges/shotgun.yml | 3 +- .../Weapons/Guns/Battery/battery_guns.yml | 15 ++- .../Weapons/Guns/Explosives/grenades.yml | 12 +- .../Objects/Weapons/Guns/LMGs/lmgs.yml | 24 ++-- .../Weapons/Guns/Launchers/launchers.yml | 27 +++-- .../Objects/Weapons/Guns/Pistols/pistols.yml | 60 ++++++---- .../Weapons/Guns/Projectiles/projectiles.yml | 21 ++-- .../Weapons/Guns/Revolvers/revolvers.yml | 33 ++++-- .../Objects/Weapons/Guns/Rifles/rifles.yml | 105 ++++++++++++------ .../Objects/Weapons/Guns/SMGs/smgs.yml | 21 ++-- .../Weapons/Guns/Shotguns/shotguns.yml | 60 ++++++---- .../Objects/Weapons/Guns/Snipers/snipers.yml | 9 +- .../Entities/Objects/Weapons/Melee/knife.yml | 3 +- .../Entities/Structures/Dispensers/base.yml | 3 +- .../Structures/Doors/Airlocks/base.yml | 9 +- .../Structures/Doors/Airlocks/external.yml | 9 +- .../Structures/Doors/Firelocks/firelock.yml | 9 +- .../Structures/Furniture/Tables/tables.yml | 30 +++-- .../Structures/Furniture/bookshelf.yml | 3 +- .../Structures/Furniture/potted_plants.yml | 3 +- .../Entities/Structures/Furniture/seats.yml | 6 +- .../Structures/Machines/Computers/frame.yml | 7 +- .../Entities/Structures/Machines/base.yml | 3 +- .../Entities/Structures/Machines/research.yml | 6 +- .../Structures/Piping/Disposal/units.yml | 6 +- .../Power/Generation/PA/particles.yml | 3 +- .../Power/Generation/Singularity/emitter.yml | 3 +- .../Structures/Storage/Canisters/base.yml | 3 +- .../Storage/Canisters/gas_canisters.yml | 27 +++-- .../Storage/Closets/Lockers/base.yml | 3 +- .../Structures/Storage/Closets/base.yml | 6 +- .../Structures/Storage/Crates/crates.yml | 3 +- .../Entities/Structures/Storage/morgue.yml | 12 +- .../Entities/Structures/Storage/storage.yml | 3 +- .../Structures/Wallmounts/lighting.yml | 3 +- .../Entities/Structures/Walls/walls.yml | 6 +- .../Entities/Structures/Windows/plasma.yml | 4 +- .../Structures/Windows/reinforced.yml | 4 +- .../Entities/Structures/Windows/window.yml | 4 +- .../Entities/Structures/catwalk.yml | 3 +- .../Entities/Structures/meat_spike.yml | 3 +- .../Recipes/Reactions/chemicals.yml | 3 +- Resources/Prototypes/Tiles/floors.yml | 87 ++++++++++----- Resources/Prototypes/Tiles/plating.yml | 9 +- Resources/Prototypes/Tiles/wood.yml | 3 +- RobustToolbox | 2 +- 90 files changed, 663 insertions(+), 368 deletions(-) diff --git a/Content.Client/Disposal/Visualizers/DisposalUnitVisualizer.cs b/Content.Client/Disposal/Visualizers/DisposalUnitVisualizer.cs index ecd176750c..df9b94be07 100644 --- a/Content.Client/Disposal/Visualizers/DisposalUnitVisualizer.cs +++ b/Content.Client/Disposal/Visualizers/DisposalUnitVisualizer.cs @@ -1,4 +1,5 @@ -using System; +using System; +using Content.Shared.Sound; using JetBrains.Annotations; using Robust.Client.Animations; using Robust.Client.GameObjects; @@ -39,7 +40,7 @@ namespace Content.Client.Disposal.Visualizers private string? _stateFlush; [DataField("flush_sound", required: true)] - private string? _flushSound; + private SoundSpecifier _flushSound = default!; [DataField("flush_time", required: true)] private float _flushTime; @@ -58,9 +59,9 @@ namespace Content.Client.Disposal.Visualizers var sound = new AnimationTrackPlaySound(); _flushAnimation.AnimationTracks.Add(sound); - if (_flushSound != null) + if (_flushSound.TryGetSound(out var flushSound)) { - sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(_flushSound, 0)); + sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(flushSound, 0)); } } diff --git a/Content.Client/Doors/AirlockVisualizer.cs b/Content.Client/Doors/AirlockVisualizer.cs index 8f6c0651b1..4f5a745e01 100644 --- a/Content.Client/Doors/AirlockVisualizer.cs +++ b/Content.Client/Doors/AirlockVisualizer.cs @@ -1,8 +1,8 @@ using System; -using Content.Client.Wires; using Content.Client.Wires.Visualizers; using Content.Shared.Audio; using Content.Shared.Doors; +using Content.Shared.Sound; using JetBrains.Annotations; using Robust.Client.Animations; using Robust.Client.GameObjects; @@ -18,13 +18,13 @@ namespace Content.Client.Doors private const string AnimationKey = "airlock_animation"; [DataField("open_sound", required: true)] - private string _openSound = default!; + private SoundSpecifier _openSound = default!; [DataField("close_sound", required: true)] - private string _closeSound = default!; + private SoundSpecifier _closeSound = default!; [DataField("deny_sound", required: true)] - private string _denySound = default!; + private SoundSpecifier _denySound = default!; [DataField("animation_time")] private float _delay = 0.8f; @@ -55,9 +55,9 @@ namespace Content.Client.Doors var sound = new AnimationTrackPlaySound(); CloseAnimation.AnimationTracks.Add(sound); - if (_closeSound != null) + if (_closeSound.TryGetSound(out var closeSound)) { - sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(_closeSound, 0)); + sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(closeSound, 0)); } } @@ -81,9 +81,9 @@ namespace Content.Client.Doors var sound = new AnimationTrackPlaySound(); OpenAnimation.AnimationTracks.Add(sound); - if (_openSound != null) + if (_openSound.TryGetSound(out var openSound)) { - sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(_openSound, 0)); + sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(openSound, 0)); } } @@ -97,9 +97,9 @@ namespace Content.Client.Doors var sound = new AnimationTrackPlaySound(); DenyAnimation.AnimationTracks.Add(sound); - if (_denySound != null) + if (_denySound.TryGetSound(out var denySound)) { - sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(_denySound, 0, () => AudioHelpers.WithVariation(0.05f))); + sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(denySound, 0, () => AudioHelpers.WithVariation(0.05f))); } } } diff --git a/Content.Client/Light/Visualizers/PoweredLightVisualizer.cs b/Content.Client/Light/Visualizers/PoweredLightVisualizer.cs index 703c76a14a..4d629dcd67 100644 --- a/Content.Client/Light/Visualizers/PoweredLightVisualizer.cs +++ b/Content.Client/Light/Visualizers/PoweredLightVisualizer.cs @@ -1,5 +1,6 @@ using System; using Content.Shared.Light; +using Content.Shared.Sound; using JetBrains.Annotations; using Robust.Client.Animations; using Robust.Client.GameObjects; @@ -17,7 +18,7 @@ namespace Content.Client.Light.Visualizers { [DataField("minBlinkingTime")] private float _minBlinkingTime = 0.5f; [DataField("maxBlinkingTime")] private float _maxBlinkingTime = 2; - [DataField("blinkingSound")] private string? _blinkingSound; + [DataField("blinkingSound")] private SoundSpecifier _blinkingSound = default!; private bool _wasBlinking; @@ -124,13 +125,13 @@ namespace Content.Client.Light.Visualizers } }; - if (_blinkingSound != null) + if (_blinkingSound.TryGetSound(out var blinkingSound)) { blinkingAnim.AnimationTracks.Add(new AnimationTrackPlaySound() { KeyFrames = { - new AnimationTrackPlaySound.KeyFrame(_blinkingSound, 0.5f) + new AnimationTrackPlaySound.KeyFrame(blinkingSound, 0.5f) } }); } diff --git a/Content.Client/Trigger/TimerTriggerVisualizer.cs b/Content.Client/Trigger/TimerTriggerVisualizer.cs index 96d16890a2..246a4c181a 100644 --- a/Content.Client/Trigger/TimerTriggerVisualizer.cs +++ b/Content.Client/Trigger/TimerTriggerVisualizer.cs @@ -1,4 +1,5 @@ -using System; +using System; +using Content.Shared.Sound; using Content.Shared.Trigger; using JetBrains.Annotations; using Robust.Client.Animations; @@ -15,7 +16,7 @@ namespace Content.Client.Trigger private const string AnimationKey = "priming_animation"; [DataField("countdown_sound", required: true)] - private string? _countdownSound; + private SoundSpecifier _countdownSound = default!; private Animation PrimingAnimation = default!; @@ -28,11 +29,11 @@ namespace Content.Client.Trigger flick.LayerKey = TriggerVisualLayers.Base; flick.KeyFrames.Add(new AnimationTrackSpriteFlick.KeyFrame("primed", 0f)); - if (_countdownSound != null) + if (_countdownSound.TryGetSound(out var countdownSound)) { var sound = new AnimationTrackPlaySound(); PrimingAnimation.AnimationTracks.Add(sound); - sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(_countdownSound, 0)); + sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(countdownSound, 0)); } } } diff --git a/Content.Server/Projectiles/Components/ProjectileComponent.cs b/Content.Server/Projectiles/Components/ProjectileComponent.cs index ca176e9c39..64a56ef03a 100644 --- a/Content.Server/Projectiles/Components/ProjectileComponent.cs +++ b/Content.Server/Projectiles/Components/ProjectileComponent.cs @@ -26,9 +26,8 @@ namespace Content.Server.Projectiles.Components public bool DeleteOnCollide { get; } = true; // Get that juicy FPS hit sound - [DataField("soundHit")] public string? SoundHit = default; - private SoundSpecifier _soundHit = default!; - [DataField("soundHitSpecies")] public string? SoundHitSpecies = default; + [DataField("soundHit")] public SoundSpecifier SoundHit = default!; + [DataField("soundHitSpecies")] public SoundSpecifier SoundHitSpecies = default!; public bool DamagedEntity; diff --git a/Content.Server/Projectiles/ProjectileSystem.cs b/Content.Server/Projectiles/ProjectileSystem.cs index cb05bcf8aa..76b1b7c32a 100644 --- a/Content.Server/Projectiles/ProjectileSystem.cs +++ b/Content.Server/Projectiles/ProjectileSystem.cs @@ -33,13 +33,13 @@ namespace Content.Server.Projectiles var playerFilter = Filter.Pvs(coordinates); if (!otherEntity.Deleted && - otherEntity.HasComponent() && component.SoundHitSpecies != null) + otherEntity.HasComponent() && component.SoundHitSpecies.TryGetSound(out var soundHitSpecies)) { - SoundSystem.Play(playerFilter, component.SoundHitSpecies, coordinates); + SoundSystem.Play(playerFilter, soundHitSpecies, coordinates); } - else if (component.SoundHit != null) + else if (component.SoundHit.TryGetSound(out var soundHit)) { - SoundSystem.Play(playerFilter, component.SoundHit, coordinates); + SoundSystem.Play(playerFilter, soundHit, coordinates); } if (!otherEntity.Deleted && otherEntity.TryGetComponent(out IDamageableComponent? damage)) diff --git a/Resources/Maps/saltern.yml b/Resources/Maps/saltern.yml index 8ca177e8e3..c7ccddd253 100644 --- a/Resources/Maps/saltern.yml +++ b/Resources/Maps/saltern.yml @@ -499,8 +499,8 @@ entities: pos: 39.53893,-0.77325034 parent: 853 type: Transform - - useSoundCollection: '' - useSound: /Audio/Items/jaws_pry.ogg + - useSound: + path: /Audio/Items/jaws_pry.ogg type: Tool - uid: 54 type: ClothingHandsGlovesLatex diff --git a/Resources/Prototypes/Entities/Clothing/Back/backpacks.yml b/Resources/Prototypes/Entities/Clothing/Back/backpacks.yml index 67ef75c4fa..dc884e1a04 100644 --- a/Resources/Prototypes/Entities/Clothing/Back/backpacks.yml +++ b/Resources/Prototypes/Entities/Clothing/Back/backpacks.yml @@ -15,7 +15,8 @@ sprite: Clothing/Back/Backpacks/backpack.rsi - type: Storage capacity: 100 - storageSoundCollection : storageRustle + storageSoundCollection: + collection: storageRustle - type: entity parent: ClothingBackpack diff --git a/Resources/Prototypes/Entities/Clothing/Back/duffel.yml b/Resources/Prototypes/Entities/Clothing/Back/duffel.yml index b00d921e26..8aa43092ee 100644 --- a/Resources/Prototypes/Entities/Clothing/Back/duffel.yml +++ b/Resources/Prototypes/Entities/Clothing/Back/duffel.yml @@ -15,7 +15,8 @@ - back - type: Storage capacity: 100 - storageSoundCollection : storageRustle + storageSoundCollection: + collection: storageRustle - type: entity parent: ClothingBackpackDuffel diff --git a/Resources/Prototypes/Entities/Clothing/Back/satchel.yml b/Resources/Prototypes/Entities/Clothing/Back/satchel.yml index c2b7944466..73c04b2c56 100644 --- a/Resources/Prototypes/Entities/Clothing/Back/satchel.yml +++ b/Resources/Prototypes/Entities/Clothing/Back/satchel.yml @@ -15,7 +15,8 @@ sprite: Clothing/Back/Satchels/satchel.rsi - type: Storage capacity: 100 - storageSoundCollection : storageRustle + storageSoundCollection: + collection: storageRustle - type: entity parent: ClothingBackpackSatchel diff --git a/Resources/Prototypes/Entities/Clothing/Shoes/specific.yml b/Resources/Prototypes/Entities/Clothing/Shoes/specific.yml index 8863546e1c..69a594bab6 100644 --- a/Resources/Prototypes/Entities/Clothing/Shoes/specific.yml +++ b/Resources/Prototypes/Entities/Clothing/Shoes/specific.yml @@ -20,7 +20,8 @@ - type: Clothing sprite: Clothing/Shoes/Specific/clown.rsi - type: FootstepModifier - footstepSoundCollection: footstep_clown + footstepSoundCollection: + collection: footstep_clown - type: entity parent: ClothingShoesBase diff --git a/Resources/Prototypes/Entities/Debugging/spanisharmyknife.yml b/Resources/Prototypes/Entities/Debugging/spanisharmyknife.yml index b73a7f60b3..e1d93ccc3b 100644 --- a/Resources/Prototypes/Entities/Debugging/spanisharmyknife.yml +++ b/Resources/Prototypes/Entities/Debugging/spanisharmyknife.yml @@ -23,17 +23,25 @@ tools: - behavior: Prying state: icon - useSound: /Audio/Items/jaws_pry.ogg - changeSound: /Audio/Items/change_jaws.ogg + useSound: + path: /Audio/Items/jaws_pry.ogg + changeSound: + path: /Audio/Items/change_jaws.ogg - behavior: Cutting state: icon - useSound: /Audio/Items/jaws_cut.ogg - changeSound: /Audio/Items/change_jaws.ogg + useSound: + path: /Audio/Items/jaws_cut.ogg + changeSound: + path: /Audio/Items/change_jaws.ogg - behavior: Screwing state: icon - useSound: /Audio/Items/drill_use.ogg - changeSound: /Audio/Items/change_drill.ogg + useSound: + path: /Audio/Items/drill_use.ogg + changeSound: + path: /Audio/Items/change_drill.ogg - behavior: Anchoring state: icon - useSound: /Audio/Items/drill_use.ogg - changeSound: /Audio/Items/change_drill.ogg + useSound: + path: /Audio/Items/drill_use.ogg + changeSound: + path: /Audio/Items/change_drill.ogg diff --git a/Resources/Prototypes/Entities/Effects/puddle.yml b/Resources/Prototypes/Entities/Effects/puddle.yml index 6e018f8f0b..1e03310877 100644 --- a/Resources/Prototypes/Entities/Effects/puddle.yml +++ b/Resources/Prototypes/Entities/Effects/puddle.yml @@ -8,7 +8,8 @@ drawdepth: FloorObjects - type: SolutionContainer - type: Puddle - spill_sound: /Audio/Effects/Fluids/splat.ogg + spill_sound: + path: /Audio/Effects/Fluids/splat.ogg recolor: true - type: Clickable - type: Slippery diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/simplemob.yml b/Resources/Prototypes/Entities/Mobs/NPCs/simplemob.yml index cef117e5da..d7bbe39452 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/simplemob.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/simplemob.yml @@ -34,7 +34,8 @@ - type: MovedByPressure - type: Barotrauma - type: DamageOnHighSpeedImpact - soundHit: /Audio/Effects/hit_kick.ogg + soundHit: + path: /Audio/Effects/hit_kick.ogg - type: Sprite noRot: true drawdepth: Mobs diff --git a/Resources/Prototypes/Entities/Mobs/Species/human.yml b/Resources/Prototypes/Entities/Mobs/Species/human.yml index 915d97340a..0b9407b025 100644 --- a/Resources/Prototypes/Entities/Mobs/Species/human.yml +++ b/Resources/Prototypes/Entities/Mobs/Species/human.yml @@ -35,7 +35,8 @@ - type: MovedByPressure - type: Barotrauma - type: DamageOnHighSpeedImpact - soundHit: /Audio/Effects/hit_kick.ogg + soundHit: + path: /Audio/Effects/hit_kick.ogg - type: Hunger - type: Thirst # Organs diff --git a/Resources/Prototypes/Entities/Objects/Consumable/Food/Containers/bowl.yml b/Resources/Prototypes/Entities/Objects/Consumable/Food/Containers/bowl.yml index 07ff40713f..3dafbe4a9d 100644 --- a/Resources/Prototypes/Entities/Objects/Consumable/Food/Containers/bowl.yml +++ b/Resources/Prototypes/Entities/Objects/Consumable/Food/Containers/bowl.yml @@ -24,8 +24,8 @@ !type:DamageTrigger damage: 5 behaviors: - - !type:PlaySoundCollectionBehavior - soundCollection: GlassBreak + - !type:PlaySoundBehavior + collection:: GlassBreak - !type:SpillBehavior { } - !type:SpawnEntitiesBehavior spawn: diff --git a/Resources/Prototypes/Entities/Objects/Consumable/Food/Containers/box.yml b/Resources/Prototypes/Entities/Objects/Consumable/Food/Containers/box.yml index b80ef6f762..a610a361f4 100644 --- a/Resources/Prototypes/Entities/Objects/Consumable/Food/Containers/box.yml +++ b/Resources/Prototypes/Entities/Objects/Consumable/Food/Containers/box.yml @@ -103,8 +103,8 @@ # !type:DamageTrigger # damage: 10 # behaviors: - # - !type:PlaySoundCollectionBehavior - # soundCollection: desecration + # - !type:PlaySoundBehavior + # collection:: desecration # - !type:SpawnEntitiesBehavior # spawn: # EggBoxBroken: diff --git a/Resources/Prototypes/Entities/Objects/Consumable/Food/Containers/condiments.yml b/Resources/Prototypes/Entities/Objects/Consumable/Food/Containers/condiments.yml index 51b70bb466..2768df6b6b 100644 --- a/Resources/Prototypes/Entities/Objects/Consumable/Food/Containers/condiments.yml +++ b/Resources/Prototypes/Entities/Objects/Consumable/Food/Containers/condiments.yml @@ -10,7 +10,8 @@ description: A small plastic pack with condiments to put on your food. components: - type: Drink - openSounds: packetOpenSounds + openSounds: + collection: packetOpenSounds - type: SolutionContainer maxVol: 10 - type: SolutionTransfer @@ -309,7 +310,8 @@ description: A thin glass bottle used to store condiments. components: - type: Drink - openSounds: pop + openSounds: + collection: pop - type: SolutionContainer maxVol: 30 - type: SolutionTransfer @@ -444,7 +446,8 @@ description: A smaller glass bottle used to store condiments. components: - type: Drink - openSounds: pop + openSounds: + collection: pop - type: SolutionContainer maxVol: 15 - type: SolutionTransfer diff --git a/Resources/Prototypes/Entities/Objects/Consumable/Food/Containers/plate.yml b/Resources/Prototypes/Entities/Objects/Consumable/Food/Containers/plate.yml index 061ab23fe9..02d0bc4015 100644 --- a/Resources/Prototypes/Entities/Objects/Consumable/Food/Containers/plate.yml +++ b/Resources/Prototypes/Entities/Objects/Consumable/Food/Containers/plate.yml @@ -27,8 +27,8 @@ !type:DamageTrigger damage: 5 behaviors: - - !type:PlaySoundCollectionBehavior - soundCollection: GlassBreak + - !type:PlaySoundBehavior + collection:: GlassBreak - !type:SpawnEntitiesBehavior spawn: FoodPlateTrash: @@ -66,8 +66,8 @@ !type:DamageTrigger damage: 5 behaviors: - - !type:PlaySoundCollectionBehavior - soundCollection: GlassBreak + - !type:PlaySoundBehavior + collection:: GlassBreak - !type:SpawnEntitiesBehavior spawn: FoodPlateSmallTrash: diff --git a/Resources/Prototypes/Entities/Objects/Consumable/Food/Containers/tin.yml b/Resources/Prototypes/Entities/Objects/Consumable/Food/Containers/tin.yml index fa7bc163fa..dbb7781c35 100644 --- a/Resources/Prototypes/Entities/Objects/Consumable/Food/Containers/tin.yml +++ b/Resources/Prototypes/Entities/Objects/Consumable/Food/Containers/tin.yml @@ -55,8 +55,8 @@ !type:DamageTrigger damage: 6 behaviors: - - !type:PlaySoundCollectionBehavior - soundCollection: canOpenSounds + - !type:PlaySoundBehavior + collection:: canOpenSounds - !type:SpawnEntitiesBehavior spawn: FoodTinPeachesOpen: @@ -103,8 +103,8 @@ !type:DamageTrigger damage: 6 behaviors: - - !type:PlaySoundCollectionBehavior - soundCollection: canOpenSounds + - !type:PlaySoundBehavior + collection:: canOpenSounds - !type:SpawnEntitiesBehavior spawn: FoodTinPeachesMaintOpen: @@ -151,8 +151,8 @@ !type:DamageTrigger damage: 6 behaviors: - - !type:PlaySoundCollectionBehavior - soundCollection: canOpenSounds + - !type:PlaySoundBehavior + collection:: canOpenSounds - !type:SpawnEntitiesBehavior spawn: FoodTinBeansOpen: @@ -201,8 +201,8 @@ !type:DamageTrigger damage: 6 behaviors: - - !type:PlaySoundCollectionBehavior - soundCollection: canOpenSounds + - !type:PlaySoundBehavior + collection:: canOpenSounds - !type:SpawnEntitiesBehavior spawn: FoodTinMREOpen: diff --git a/Resources/Prototypes/Entities/Objects/Consumable/Food/egg.yml b/Resources/Prototypes/Entities/Objects/Consumable/Food/egg.yml index 06c818d1b9..1ecdb853b0 100644 --- a/Resources/Prototypes/Entities/Objects/Consumable/Food/egg.yml +++ b/Resources/Prototypes/Entities/Objects/Consumable/Food/egg.yml @@ -34,8 +34,8 @@ !type:DamageTrigger damage: 1 behaviors: - - !type:PlaySoundCollectionBehavior - soundCollection: desecration + - !type:PlaySoundBehavior + collection:: desecration - !type:SpawnEntitiesBehavior spawn: Eggshells: diff --git a/Resources/Prototypes/Entities/Objects/Consumable/Food/ingredients.yml b/Resources/Prototypes/Entities/Objects/Consumable/Food/ingredients.yml index 59703f8286..28db9749cd 100644 --- a/Resources/Prototypes/Entities/Objects/Consumable/Food/ingredients.yml +++ b/Resources/Prototypes/Entities/Objects/Consumable/Food/ingredients.yml @@ -28,8 +28,10 @@ maxVol: 50 - type: SolutionTransfer - type: Drink - openSounds: packetOpenSounds - useSound: /Audio/Items/eating_1.ogg + openSounds: + collection: packetOpenSounds + useSound: + path: /Audio/Items/eating_1.ogg - type: Spillable - type: entity @@ -56,8 +58,8 @@ !type:DamageTrigger damage: 2 behaviors: - - !type:PlaySoundCollectionBehavior - soundCollection: desecration + - !type:PlaySoundBehavior + collection:: desecration - !type:SpawnEntitiesBehavior spawn: PuddleFlour: @@ -91,8 +93,8 @@ !type:DamageTrigger damage: 2 behaviors: - - !type:PlaySoundCollectionBehavior - soundCollection: desecration + - !type:PlaySoundBehavior + collection:: desecration - !type:SpawnEntitiesBehavior spawn: PuddleFlour: diff --git a/Resources/Prototypes/Entities/Objects/Consumable/Food/produce.yml b/Resources/Prototypes/Entities/Objects/Consumable/Food/produce.yml index 5d40cb2ea7..9bb1b60596 100644 --- a/Resources/Prototypes/Entities/Objects/Consumable/Food/produce.yml +++ b/Resources/Prototypes/Entities/Objects/Consumable/Food/produce.yml @@ -254,8 +254,8 @@ !type:DamageTrigger damage: 1 behaviors: - - !type:PlaySoundCollectionBehavior - soundCollection: desecration + - !type:PlaySoundBehavior + collection:: desecration - !type:SpawnEntitiesBehavior spawn: PuddleTomato: diff --git a/Resources/Prototypes/Entities/Objects/Consumable/Food/soup.yml b/Resources/Prototypes/Entities/Objects/Consumable/Food/soup.yml index d7a7ab1de6..507493fb6e 100644 --- a/Resources/Prototypes/Entities/Objects/Consumable/Food/soup.yml +++ b/Resources/Prototypes/Entities/Objects/Consumable/Food/soup.yml @@ -27,8 +27,8 @@ !type:DamageTrigger damage: 5 behaviors: - - !type:PlaySoundCollectionBehavior - soundCollection: GlassBreak + - !type:PlaySoundBehavior + collection:: GlassBreak - !type:SpillBehavior { } - !type:SpawnEntitiesBehavior spawn: diff --git a/Resources/Prototypes/Entities/Objects/Consumable/drinks.yml b/Resources/Prototypes/Entities/Objects/Consumable/drinks.yml index c11de84171..fbe99e7b01 100644 --- a/Resources/Prototypes/Entities/Objects/Consumable/drinks.yml +++ b/Resources/Prototypes/Entities/Objects/Consumable/drinks.yml @@ -33,8 +33,8 @@ !type:DamageTrigger damage: 5 behaviors: - - !type:PlaySoundCollectionBehavior - soundCollection: GlassBreak + - !type:PlaySoundBehavior + collection:: GlassBreak - !type:SpillBehavior { } - !type:SpawnEntitiesBehavior spawn: diff --git a/Resources/Prototypes/Entities/Objects/Consumable/drinks_bottles.yml b/Resources/Prototypes/Entities/Objects/Consumable/drinks_bottles.yml index fb0c40b4f8..36106a0d09 100644 --- a/Resources/Prototypes/Entities/Objects/Consumable/drinks_bottles.yml +++ b/Resources/Prototypes/Entities/Objects/Consumable/drinks_bottles.yml @@ -4,7 +4,8 @@ abstract: true components: - type: Drink - openSounds: bottleOpenSounds + openSounds: + collection: bottleOpenSounds - type: SolutionContainer maxVol: 100 - type: SolutionTransfer @@ -27,8 +28,8 @@ !type:DamageTrigger damage: 5 behaviors: - - !type:PlaySoundCollectionBehavior - soundCollection: GlassBreak + - !type:PlaySoundBehavior + collection:: GlassBreak - !type:SpillBehavior { } - !type:SpawnEntitiesBehavior spawn: diff --git a/Resources/Prototypes/Entities/Objects/Consumable/drinks_cans.yml b/Resources/Prototypes/Entities/Objects/Consumable/drinks_cans.yml index 0999937871..16ab842b8a 100644 --- a/Resources/Prototypes/Entities/Objects/Consumable/drinks_cans.yml +++ b/Resources/Prototypes/Entities/Objects/Consumable/drinks_cans.yml @@ -4,7 +4,8 @@ abstract: true components: - type: Drink - openSounds: canOpenSounds + openSounds: + collection: canOpenSounds pressurized: true - type: SolutionContainer maxVol: 20 diff --git a/Resources/Prototypes/Entities/Objects/Fun/toys.yml b/Resources/Prototypes/Entities/Objects/Fun/toys.yml index 3ab1f035c5..a626670610 100644 --- a/Resources/Prototypes/Entities/Objects/Fun/toys.yml +++ b/Resources/Prototypes/Entities/Objects/Fun/toys.yml @@ -478,9 +478,12 @@ - Single fireRate: 0.5 capacity: 1 - soundEmpty: /Audio/Weapons/Guns/Empty/empty.ogg - soundGunshot: /Audio/Weapons/Guns/Gunshots/click.ogg - soundInsert: /Audio/Weapons/Guns/MagIn/drawbow2.ogg + soundEmpty: + path: /Audio/Weapons/Guns/Empty/empty.ogg + soundGunshot: + path: /Audio/Weapons/Guns/Gunshots/click.ogg + soundInsert: + path: /Audio/Weapons/Guns/MagIn/drawbow2.ogg - type: entity parent: BaseItem @@ -517,9 +520,12 @@ caliber: Cap capacity: 6 autoCycle: true - soundGunshot: /Audio/Weapons/Guns/Gunshots/revolver.ogg - soundEmpty: /Audio/Weapons/Guns/Empty/empty.ogg - soundInsert: /Audio/Weapons/Guns/MagIn/revolver_magin.ogg + soundGunshot: + path: /Audio/Weapons/Guns/Gunshots/revolver.ogg + soundEmpty: + path: /Audio/Weapons/Guns/Empty/empty.ogg + soundInsert: + path: /Audio/Weapons/Guns/MagIn/revolver_magin.ogg - type: Appearance visuals: - type: BarrelBoltVisualizer diff --git a/Resources/Prototypes/Entities/Objects/Misc/fire_extinguisher.yml b/Resources/Prototypes/Entities/Objects/Misc/fire_extinguisher.yml index 40fffbd0a8..b97334b339 100644 --- a/Resources/Prototypes/Entities/Objects/Misc/fire_extinguisher.yml +++ b/Resources/Prototypes/Entities/Objects/Misc/fire_extinguisher.yml @@ -35,7 +35,8 @@ - type: MeleeWeapon damage: 10 damageType: Blunt - hitSound: /Audio/Weapons/smash.ogg + hitSound: + path: /Audio/Weapons/smash.ogg - type: Appearance visuals: - type: SprayVisualizer diff --git a/Resources/Prototypes/Entities/Objects/Misc/fluff_lights.yml b/Resources/Prototypes/Entities/Objects/Misc/fluff_lights.yml index 81b3b2c0c5..3ac0747b96 100644 --- a/Resources/Prototypes/Entities/Objects/Misc/fluff_lights.yml +++ b/Resources/Prototypes/Entities/Objects/Misc/fluff_lights.yml @@ -110,7 +110,8 @@ damage: 10 behaviors: - !type:PlaySoundBehavior - sound: /Audio/Effects/glass_break1.ogg + sound: + path: /Audio/Effects/glass_break1.ogg - !type:SpawnEntitiesBehavior spawn: FloodlightBroken: @@ -141,7 +142,8 @@ damage: 20 behaviors: - !type:PlaySoundBehavior - sound: /Audio/Effects/metalbreak.ogg + sound: + path: /Audio/Effects/metalbreak.ogg - !type:SpawnEntitiesBehavior spawn: SheetSteel1: diff --git a/Resources/Prototypes/Entities/Objects/Misc/handcuffs.yml b/Resources/Prototypes/Entities/Objects/Misc/handcuffs.yml index 23229182c1..d84ce1cb34 100644 --- a/Resources/Prototypes/Entities/Objects/Misc/handcuffs.yml +++ b/Resources/Prototypes/Entities/Objects/Misc/handcuffs.yml @@ -37,11 +37,16 @@ brokenIconState: cuff-broken brokenName: broken cables brokenDesc: These cables are broken in several places and don't seem very useful. - startCuffSound: /Audio/Items/Handcuffs/rope_start.ogg - endCuffSound: /Audio/Items/Handcuffs/rope_end.ogg - startUncuffSound: /Audio/Items/Handcuffs/rope_start.ogg - endUncuffSound: /Audio/Items/Handcuffs/rope_breakout.ogg - startBreakoutSound: /Audio/Items/Handcuffs/rope_takeoff.ogg + startCuffSound: + path: /Audio/Items/Handcuffs/rope_start.ogg + endCuffSound: + path: /Audio/Items/Handcuffs/rope_end.ogg + startUncuffSound: + path: /Audio/Items/Handcuffs/rope_start.ogg + endUncuffSound: + path: /Audio/Items/Handcuffs/rope_breakout.ogg + startBreakoutSound: + path: /Audio/Items/Handcuffs/rope_takeoff.ogg - type: Construction graph: makeshifthandcuffs node: cuffscable diff --git a/Resources/Prototypes/Entities/Objects/Misc/torch.yml b/Resources/Prototypes/Entities/Objects/Misc/torch.yml index 605ac31e3b..d0e78cfd95 100644 --- a/Resources/Prototypes/Entities/Objects/Misc/torch.yml +++ b/Resources/Prototypes/Entities/Objects/Misc/torch.yml @@ -13,7 +13,8 @@ turnOnBehaviourID: turn_on fadeOutBehaviourID: fade_out # Sounds legit nuff - litSound: /Audio/Items/Flare/flare_on.ogg + litSound: + path: /Audio/Items/Flare/flare_on.ogg loopedSound: /Audio/Items/Flare/flare_burn.ogg - type: Sprite sprite: Objects/Misc/torch.rsi diff --git a/Resources/Prototypes/Entities/Objects/Power/lights.yml b/Resources/Prototypes/Entities/Objects/Power/lights.yml index 8d4066c16c..b888015807 100644 --- a/Resources/Prototypes/Entities/Objects/Power/lights.yml +++ b/Resources/Prototypes/Entities/Objects/Power/lights.yml @@ -16,16 +16,16 @@ !type:DamageTrigger damage: 5 behaviors: - - !type:PlaySoundCollectionBehavior - soundCollection: GlassBreak + - !type:PlaySoundBehavior + collection: GlassBreak - !type:DoActsBehavior acts: [ "Breakage" ] - trigger: !type:DamageTrigger damage: 10 behaviors: - - !type:PlaySoundCollectionBehavior - soundCollection: GlassBreak + - !type:PlaySoundBehavior + collection: GlassBreak - !type:SpawnEntitiesBehavior spawn: ShardGlass: diff --git a/Resources/Prototypes/Entities/Objects/Specific/Janitorial/trashbag.yml b/Resources/Prototypes/Entities/Objects/Specific/Janitorial/trashbag.yml index b325f2d340..2e65461a29 100644 --- a/Resources/Prototypes/Entities/Objects/Specific/Janitorial/trashbag.yml +++ b/Resources/Prototypes/Entities/Objects/Specific/Janitorial/trashbag.yml @@ -12,7 +12,8 @@ capacity: 125 quickInsert: true areaInsert: true - storageSoundCollection: trashBagRustle + storageSoundCollection: + collection: trashBagRustle - type: entity name: trash bag @@ -29,4 +30,5 @@ capacity: 125 quickInsert: true areaInsert: true - storageSoundCollection: trashBagRustle + storageSoundCollection: + collection: trashBagRustle diff --git a/Resources/Prototypes/Entities/Objects/Specific/Medical/morgue.yml b/Resources/Prototypes/Entities/Objects/Specific/Medical/morgue.yml index a6d63ea250..5ef8d09cc8 100644 --- a/Resources/Prototypes/Entities/Objects/Specific/Medical/morgue.yml +++ b/Resources/Prototypes/Entities/Objects/Specific/Medical/morgue.yml @@ -28,8 +28,10 @@ - type: BodyBagEntityStorage CanWeldShut: false Capacity: 1 - closeSound: /Audio/Misc/zip.ogg - openSound: /Audio/Misc/zip.ogg + closeSound: + path: /Audio/Misc/zip.ogg + openSound: + path: /Audio/Misc/zip.ogg - type: Appearance visuals: - type: StorageVisualizer diff --git a/Resources/Prototypes/Entities/Objects/Specific/Medical/surgery.yml b/Resources/Prototypes/Entities/Objects/Specific/Medical/surgery.yml index 0bf360a9d2..7d5e861912 100644 --- a/Resources/Prototypes/Entities/Objects/Specific/Medical/surgery.yml +++ b/Resources/Prototypes/Entities/Objects/Specific/Medical/surgery.yml @@ -49,7 +49,8 @@ sprite: Objects/Specific/Medical/Surgery/drill.rsi - type: ItemCooldown - type: MeleeWeapon - hitSound: /Audio/Items/drill_hit.ogg + hitSound: + path: /Audio/Items/drill_hit.ogg # Scalpel @@ -72,7 +73,8 @@ sprite: Objects/Specific/Medical/Surgery/scalpel.rsi - type: ItemCooldown - type: MeleeWeapon - hitSound: /Audio/Weapons/bladeslice.ogg + hitSound: + path: /Audio/Weapons/bladeslice.ogg damage: 12 - type: entity @@ -140,12 +142,15 @@ # tools: # - behavior: VesselCompression # state: hemostat -# useSound: /Audio/Items/jaws_pry.ogg -# changeSound: /Audio/Items/change_jaws.ogg +# useSound: +# path: /Audio/Items/jaws_pry.ogg +# changeSound: +# path: /Audio/Items/change_jaws.ogg # - behavior: Setting # state: setter # useSound: -# changeSound: /Audio/Items/change_jaws.ogg +# changeSound: +# path: /Audio/Items/change_jaws.ogg - type: entity name: hemostat @@ -209,7 +214,8 @@ - type: Item HeldPrefix: improv - type: MeleeWeapon - hitSound: /Audio/Weapons/bladeslice.ogg + hitSound: + path: /Audio/Weapons/bladeslice.ogg damage: 10 - type: entity @@ -227,7 +233,8 @@ - type: Item HeldPrefix: electric - type: MeleeWeapon - hitSound: /Audio/Items/drill_hit.ogg + hitSound: + path: /Audio/Items/drill_hit.ogg damage: 15 - type: entity @@ -245,5 +252,6 @@ - type: Item HeldPrefix: advanced - type: MeleeWeapon - hitSound: /Audio/Items/drill_hit.ogg + hitSound: + path: /Audio/Items/drill_hit.ogg damage: 20 diff --git a/Resources/Prototypes/Entities/Objects/Specific/chemistry.yml b/Resources/Prototypes/Entities/Objects/Specific/chemistry.yml index ccde62dfbd..4b65806d9d 100644 --- a/Resources/Prototypes/Entities/Objects/Specific/chemistry.yml +++ b/Resources/Prototypes/Entities/Objects/Specific/chemistry.yml @@ -41,8 +41,8 @@ !type:DamageTrigger damage: 5 behaviors: - - !type:PlaySoundCollectionBehavior - soundCollection: GlassBreak + - !type:PlaySoundBehavior + collection:: GlassBreak - !type:SpillBehavior { } - !type:SpawnEntitiesBehavior spawn: diff --git a/Resources/Prototypes/Entities/Objects/Tools/cowtools.yml b/Resources/Prototypes/Entities/Objects/Tools/cowtools.yml index 10703a68e0..cbe6c707b3 100644 --- a/Resources/Prototypes/Entities/Objects/Tools/cowtools.yml +++ b/Resources/Prototypes/Entities/Objects/Tools/cowtools.yml @@ -15,7 +15,8 @@ - type: Tool qualities: - Cutting - useSound: /Audio/Items/wirecutter.ogg + useSound: + path: /Audio/Items/wirecutter.ogg speed: 0.05 - type: Item sprite: Objects/Tools/Cowtools/haycutters.rsi @@ -55,7 +56,8 @@ - type: Tool qualities: - Anchoring - useSound: /Audio/Items/ratchet.ogg + useSound: + path: /Audio/Items/ratchet.ogg speed: 0.05 - type: entity @@ -74,7 +76,8 @@ - type: Tool qualities: - Prying - useSound: /Audio/Items/crowbar.ogg + useSound: + path: /Audio/Items/crowbar.ogg speed: 0.05 - type: TilePrying diff --git a/Resources/Prototypes/Entities/Objects/Tools/flare.yml b/Resources/Prototypes/Entities/Objects/Tools/flare.yml index cf2d18ee78..984b99cabe 100644 --- a/Resources/Prototypes/Entities/Objects/Tools/flare.yml +++ b/Resources/Prototypes/Entities/Objects/Tools/flare.yml @@ -13,7 +13,8 @@ iconStateSpent: flare_spent turnOnBehaviourID: turn_on fadeOutBehaviourID: fade_out - litSound: /Audio/Items/Flare/flare_on.ogg + litSound: + path: /Audio/Items/Flare/flare_on.ogg loopedSound: /Audio/Items/Flare/flare_burn.ogg - type: Sprite sprite: Objects/Misc/flare.rsi diff --git a/Resources/Prototypes/Entities/Objects/Tools/glowstick.yml b/Resources/Prototypes/Entities/Objects/Tools/glowstick.yml index 7f14e7b9aa..36193d19d0 100644 --- a/Resources/Prototypes/Entities/Objects/Tools/glowstick.yml +++ b/Resources/Prototypes/Entities/Objects/Tools/glowstick.yml @@ -13,7 +13,8 @@ iconStateSpent: glowstick_unlit turnOnBehaviourID: turn_on fadeOutBehaviourID: fade_out - litSound: /Audio/Items/Handcuffs/rope_breakout.ogg + litSound: + path: /Audio/Items/Handcuffs/rope_breakout.ogg - type: Sprite sprite: Objects/Misc/glowstick.rsi layers: @@ -74,7 +75,8 @@ iconStateSpent: glowstick_unlit turnOnBehaviourID: turn_on fadeOutBehaviourID: fade_out - litSound: /Audio/Items/Handcuffs/rope_breakout.ogg + litSound: + path: /Audio/Items/Handcuffs/rope_breakout.ogg - type: Sprite sprite: Objects/Misc/glowstick.rsi layers: @@ -109,7 +111,8 @@ iconStateSpent: glowstick_unlit turnOnBehaviourID: turn_on fadeOutBehaviourID: fade_out - litSound: /Audio/Items/Handcuffs/rope_breakout.ogg + litSound: + path: /Audio/Items/Handcuffs/rope_breakout.ogg - type: Sprite sprite: Objects/Misc/glowstick.rsi layers: @@ -144,7 +147,8 @@ iconStateSpent: glowstick_unlit turnOnBehaviourID: turn_on fadeOutBehaviourID: fade_out - litSound: /Audio/Items/Handcuffs/rope_breakout.ogg + litSound: + path: /Audio/Items/Handcuffs/rope_breakout.ogg - type: Sprite sprite: Objects/Misc/glowstick.rsi layers: @@ -179,7 +183,8 @@ iconStateSpent: glowstick_unlit turnOnBehaviourID: turn_on fadeOutBehaviourID: fade_out - litSound: /Audio/Items/Handcuffs/rope_breakout.ogg + litSound: + path: /Audio/Items/Handcuffs/rope_breakout.ogg - type: Sprite sprite: Objects/Misc/glowstick.rsi layers: diff --git a/Resources/Prototypes/Entities/Objects/Tools/jaws_of_life.yml b/Resources/Prototypes/Entities/Objects/Tools/jaws_of_life.yml index 532d847ac8..a9f3d16df9 100644 --- a/Resources/Prototypes/Entities/Objects/Tools/jaws_of_life.yml +++ b/Resources/Prototypes/Entities/Objects/Tools/jaws_of_life.yml @@ -25,12 +25,16 @@ tools: - behavior: Prying state: jaws_pry - useSound: /Audio/Items/jaws_pry.ogg - changeSound: /Audio/Items/change_jaws.ogg + useSound: + path: /Audio/Items/jaws_pry.ogg + changeSound: + path: /Audio/Items/change_jaws.ogg - behavior: Cutting state: jaws_cutter - useSound: /Audio/Items/jaws_cut.ogg - changeSound: /Audio/Items/change_jaws.ogg + useSound: + path: /Audio/Items/jaws_cut.ogg + changeSound: + path: /Audio/Items/change_jaws.ogg - type: entity name: syndicate jaws of life diff --git a/Resources/Prototypes/Entities/Objects/Tools/matches.yml b/Resources/Prototypes/Entities/Objects/Tools/matches.yml index b1ed42b7fb..b87e081f3e 100644 --- a/Resources/Prototypes/Entities/Objects/Tools/matches.yml +++ b/Resources/Prototypes/Entities/Objects/Tools/matches.yml @@ -24,7 +24,8 @@ sprite: Objects/Tools/matches.rsi - type: Matchstick duration: 10 - igniteSound: /Audio/Items/match_strike.ogg + igniteSound: + path: /Audio/Items/match_strike.ogg - type: PointLight enabled: false radius: 1.1 diff --git a/Resources/Prototypes/Entities/Objects/Tools/toolbox.yml b/Resources/Prototypes/Entities/Objects/Tools/toolbox.yml index ec91c98612..9f1e302eff 100644 --- a/Resources/Prototypes/Entities/Objects/Tools/toolbox.yml +++ b/Resources/Prototypes/Entities/Objects/Tools/toolbox.yml @@ -10,7 +10,8 @@ - type: ItemCooldown - type: MeleeWeapon damage: 10 - hitSound: "/Audio/Weapons/smash.ogg" + hitSound: + path: "/Audio/Weapons/smash.ogg" - type: entity name: emergency toolbox diff --git a/Resources/Prototypes/Entities/Objects/Tools/tools.yml b/Resources/Prototypes/Entities/Objects/Tools/tools.yml index 990ad18342..b2f2ff1f24 100644 --- a/Resources/Prototypes/Entities/Objects/Tools/tools.yml +++ b/Resources/Prototypes/Entities/Objects/Tools/tools.yml @@ -18,7 +18,8 @@ - type: Tool qualities: - Cutting - useSound: /Audio/Items/wirecutter.ogg + useSound: + path: /Audio/Items/wirecutter.ogg - type: RandomSpriteColor state: cutters colors: @@ -85,7 +86,8 @@ - type: Tool qualities: - Anchoring - useSound: /Audio/Items/ratchet.ogg + useSound: + path: /Audio/Items/ratchet.ogg - type: entity name: crowbar @@ -108,7 +110,8 @@ - type: Tool qualities: - Prying - useSound: /Audio/Items/crowbar.ogg + useSound: + path: /Audio/Items/crowbar.ogg - type: TilePrying - type: entity @@ -132,7 +135,8 @@ - type: Tool qualities: - Prying - useSound: /Audio/Items/crowbar.ogg + useSound: + path: /Audio/Items/crowbar.ogg - type: TilePrying - type: entity @@ -181,12 +185,16 @@ tools: - behavior: Screwing state: drill_screw - useSound: /Audio/Items/drill_use.ogg - changeSound: /Audio/Items/change_drill.ogg + useSound: + path: /Audio/Items/drill_use.ogg + changeSound: + path: /Audio/Items/change_drill.ogg - behavior: Anchoring state: drill_bolt - useSound: /Audio/Items/drill_use.ogg - changeSound: /Audio/Items/change_drill.ogg + useSound: + path: /Audio/Items/drill_use.ogg + changeSound: + path: /Audio/Items/change_drill.ogg - type: entity name: RCD diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Cartridges/shotgun.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Cartridges/shotgun.yml index d8be2765fa..24790b676f 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Cartridges/shotgun.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Cartridges/shotgun.yml @@ -8,7 +8,8 @@ caliber: Shotgun ammoSpread: 40 projectilesFired: 6 - soundCollectionEject: ShellEject + soundCollectionEject: + collection: ShellEject - type: Sprite netsync: false noRot: false diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml index e853d05048..75d69d611e 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml @@ -29,7 +29,8 @@ powerCellPrototype: PowerCellSmallStandard powerCellRemovable: true ammoPrototype: RedLaser - soundGunshot: /Audio/Weapons/Guns/Gunshots/laser.ogg + soundGunshot: + path: /Audio/Weapons/Guns/Gunshots/laser.ogg - type: Appearance visuals: - type: MagVisualizer @@ -68,7 +69,8 @@ powerCellPrototype: PowerCellSmallSuper powerCellRemovable: true ammoPrototype: RedHeavyLaser - soundGunshot: /Audio/Weapons/Guns/Gunshots/laser_cannon.ogg + soundGunshot: + path: /Audio/Weapons/Guns/Gunshots/laser_cannon.ogg - type: Appearance visuals: - type: MagVisualizer @@ -109,7 +111,8 @@ powerCellRemovable: true fireCost: 600 ammoPrototype: XrayLaser - soundGunshot: /Audio/Weapons/Guns/Gunshots/laser3.ogg + soundGunshot: + path: /Audio/Weapons/Guns/Gunshots/laser3.ogg - type: Appearance visuals: - type: MagVisualizer @@ -152,7 +155,8 @@ powerCellPrototype: PowerCellSmallStandard powerCellRemovable: false ammoPrototype: BulletTaser - soundGunshot: /Audio/Weapons/Guns/Gunshots/taser.ogg + soundGunshot: + path: /Audio/Weapons/Guns/Gunshots/taser.ogg - type: Appearance visuals: - type: MagVisualizer @@ -191,7 +195,8 @@ powerCellPrototype: PowerCellMediumStandard powerCellRemovable: true ammoPrototype: RedLaser - soundGunshot: /Audio/Weapons/Guns/Gunshots/laser.ogg + soundGunshot: + path: /Audio/Weapons/Guns/Gunshots/laser.ogg - type: Appearance visuals: - type: MagVisualizer diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Explosives/grenades.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Explosives/grenades.yml index 2cbb0b05eb..52c1b400c6 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Explosives/grenades.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Explosives/grenades.yml @@ -35,7 +35,8 @@ - type: Appearance visuals: - type: TimerTriggerVisualizer - countdown_sound: /Audio/Effects/countdown.ogg + countdown_sound: + path: /Audio/Effects/countdown.ogg - type: entity name: flashbang @@ -74,7 +75,8 @@ - type: Appearance visuals: - type: TimerTriggerVisualizer - countdown_sound: /Audio/Effects/countdown.ogg + countdown_sound: + path: /Audio/Effects/countdown.ogg - type: entity name: Syndicate minibomb @@ -109,7 +111,8 @@ - type: Appearance visuals: - type: TimerTriggerVisualizer - countdown_sound: /Audio/Effects/countdown.ogg + countdown_sound: + path: /Audio/Effects/countdown.ogg - type: entity name: the nuclear option @@ -143,4 +146,5 @@ - type: Appearance visuals: - type: TimerTriggerVisualizer - countdown_sound: /Audio/Effects/countdown.ogg + countdown_sound: + path: /Audio/Effects/countdown.ogg diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/LMGs/lmgs.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/LMGs/lmgs.yml index bb216bbad4..38386baca6 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/LMGs/lmgs.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/LMGs/lmgs.yml @@ -24,14 +24,22 @@ angleIncrease: 10 angleDecay: 60 magNeedsOpenBolt: true - soundGunshot: /Audio/Weapons/Guns/Gunshots/lmg.ogg - soundEmpty: /Audio/Weapons/Guns/Empty/lmg_empty.ogg - soundRack: /Audio/Weapons/Guns/Cock/lmg_cock.ogg - soundBoltOpen: /Audio/Weapons/Guns/Bolt/rifle_bolt_open.ogg - soundBoltClosed: /Audio/Weapons/Guns/Bolt/rifle_bolt_closed.ogg - soundAutoEject: /Audio/Weapons/Guns/EmptyAlarm/lmg_empty_alarm.ogg - soundMagInsert: /Audio/Weapons/Guns/MagIn/lmg_magin.ogg - soundMagEject: /Audio/Weapons/Guns/MagOut/lmg_magout.ogg + soundGunshot: + path: /Audio/Weapons/Guns/Gunshots/lmg.ogg + soundEmpty: + path: /Audio/Weapons/Guns/Empty/lmg_empty.ogg + soundRack: + path: /Audio/Weapons/Guns/Cock/lmg_cock.ogg + soundBoltOpen: + path: /Audio/Weapons/Guns/Bolt/rifle_bolt_open.ogg + soundBoltClosed: + path: /Audio/Weapons/Guns/Bolt/rifle_bolt_closed.ogg + soundAutoEject: + path: /Audio/Weapons/Guns/EmptyAlarm/lmg_empty_alarm.ogg + soundMagInsert: + path: /Audio/Weapons/Guns/MagIn/lmg_magin.ogg + soundMagEject: + path: /Audio/Weapons/Guns/MagOut/lmg_magout.ogg - type: entity name: L6 SAW diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Launchers/launchers.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Launchers/launchers.yml index 2a8652cfaf..7edcff9e9d 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Launchers/launchers.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Launchers/launchers.yml @@ -35,9 +35,12 @@ fillPrototype: GrenadeFrag fireRate: 1 capacity: 3 - soundEmpty: /Audio/Weapons/Guns/Empty/empty.ogg - soundGunshot: /Audio/Weapons/Guns/Gunshots/grenade_launcher.ogg - soundInsert: /Audio/Weapons/Guns/MagIn/batrifle_magin.ogg + soundEmpty: + path: /Audio/Weapons/Guns/Empty/empty.ogg + soundGunshot: + path: /Audio/Weapons/Guns/Gunshots/grenade_launcher.ogg + soundInsert: + path: /Audio/Weapons/Guns/MagIn/batrifle_magin.ogg - type: Appearance visuals: - type: BarrelBoltVisualizer @@ -67,9 +70,12 @@ fillPrototype: RocketAmmo fireRate: 0.5 capacity: 1 - soundEmpty: /Audio/Weapons/Guns/Empty/empty.ogg - soundGunshot: /Audio/Weapons/Guns/Gunshots/rpgfire.ogg - soundInsert: /Audio/Weapons/Guns/MagIn/batrifle_magin.ogg + soundEmpty: + path: /Audio/Weapons/Guns/Empty/empty.ogg + soundGunshot: + path: /Audio/Weapons/Guns/Gunshots/rpgfire.ogg + soundInsert: + path: /Audio/Weapons/Guns/MagIn/batrifle_magin.ogg - type: Appearance visuals: - type: MagVisualizer @@ -99,6 +105,9 @@ fillPrototype: FoodPieBananaCream fireRate: 5 capacity: 5 - soundEmpty: /Audio/Weapons/Guns/Empty/empty.ogg - soundGunshot: /Audio/Effects/bang.ogg - soundInsert: /Audio/Items/bikehorn.ogg + soundEmpty: + path: /Audio/Weapons/Guns/Empty/empty.ogg + soundGunshot: + path: /Audio/Effects/bang.ogg + soundInsert: + path: /Audio/Items/bikehorn.ogg diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Pistols/pistols.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Pistols/pistols.yml index 401ce2a41d..aa6d2bac1c 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Pistols/pistols.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Pistols/pistols.yml @@ -31,13 +31,20 @@ angleIncrease: 10 angleDecay: 60 magFillPrototype: MagazinePistol - soundGunshot: /Audio/Weapons/Guns/Gunshots/pistol.ogg - soundEmpty: /Audio/Weapons/Guns/Empty/empty.ogg - soundRack: /Audio/Weapons/Guns/Cock/pistol_cock.ogg - soundBoltOpen: /Audio/Weapons/Guns/Bolt/rifle_bolt_open.ogg - soundBoltClosed: /Audio/Weapons/Guns/Bolt/rifle_bolt_closed.ogg - soundMagInsert: /Audio/Weapons/Guns/MagIn/pistol_magin.ogg - soundMagEject: /Audio/Weapons/Guns/MagOut/pistol_magout.ogg + soundGunshot: + path: /Audio/Weapons/Guns/Gunshots/pistol.ogg + soundEmpty: + path: /Audio/Weapons/Guns/Empty/empty.ogg + soundRack: + path: /Audio/Weapons/Guns/Cock/pistol_cock.ogg + soundBoltOpen: + path: /Audio/Weapons/Guns/Bolt/rifle_bolt_open.ogg + soundBoltClosed: + path: /Audio/Weapons/Guns/Bolt/rifle_bolt_closed.ogg + soundMagInsert: + path: /Audio/Weapons/Guns/MagIn/pistol_magin.ogg + soundMagEject: + path: /Audio/Weapons/Guns/MagOut/pistol_magout.ogg - type: Appearance visuals: - type: BarrelBoltVisualizer @@ -160,13 +167,20 @@ angleIncrease: 10 angleDecay: 60 magFillPrototype: MagazinePistol - soundGunshot: /Audio/Weapons/Guns/Gunshots/pistol.ogg - soundEmpty: /Audio/Weapons/Guns/Empty/empty.ogg - soundRack: /Audio/Weapons/Guns/Cock/pistol_cock.ogg - soundBoltOpen: /Audio/Weapons/Guns/Bolt/rifle_bolt_open.ogg - soundBoltClosed: /Audio/Weapons/Guns/Bolt/rifle_bolt_closed.ogg - soundMagInsert: /Audio/Weapons/Guns/MagIn/pistol_magin.ogg - soundMagEject: /Audio/Weapons/Guns/MagOut/pistol_magout.ogg + soundGunshot: + path: /Audio/Weapons/Guns/Gunshots/pistol.ogg + soundEmpty: + path: /Audio/Weapons/Guns/Empty/empty.ogg + soundRack: + path: /Audio/Weapons/Guns/Cock/pistol_cock.ogg + soundBoltOpen: + path: /Audio/Weapons/Guns/Bolt/rifle_bolt_open.ogg + soundBoltClosed: + path: /Audio/Weapons/Guns/Bolt/rifle_bolt_closed.ogg + soundMagInsert: + path: /Audio/Weapons/Guns/MagIn/pistol_magin.ogg + soundMagEject: + path: /Audio/Weapons/Guns/MagOut/pistol_magout.ogg - type: Appearance visuals: - type: BarrelBoltVisualizer @@ -201,11 +215,16 @@ maxAngle: 45 angleIncrease: 20 angleDecay: 60 - soundGunshot: /Audio/Weapons/Guns/Gunshots/hpistol.ogg - soundEmpty: /Audio/Weapons/Guns/Empty/empty.ogg - soundRack: /Audio/Weapons/Guns/Cock/hpistol_cock.ogg - soundMagInsert: /Audio/Weapons/Guns/MagIn/hpistol_magin.ogg - soundMagEject: /Audio/Weapons/Guns/MagOut/hpistol_magout.ogg + soundGunshot: + path: /Audio/Weapons/Guns/Gunshots/hpistol.ogg + soundEmpty: + path: /Audio/Weapons/Guns/Empty/empty.ogg + soundRack: + path: /Audio/Weapons/Guns/Cock/hpistol_cock.ogg + soundMagInsert: + path: /Audio/Weapons/Guns/MagIn/hpistol_magin.ogg + soundMagEject: + path: /Audio/Weapons/Guns/MagOut/hpistol_magout.ogg - type: Appearance visuals: - type: MagVisualizer @@ -245,7 +264,8 @@ maxAngle: 45 angleIncrease: 20 angleDecay: 60 - soundGunshot: /Audio/Weapons/Guns/Gunshots/silenced.ogg + soundGunshot: + path: /Audio/Weapons/Guns/Gunshots/silenced.ogg - type: entity name: mk 58 diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/projectiles.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/projectiles.yml index 6a1d9694b8..8e39dd3c38 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/projectiles.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/projectiles.yml @@ -25,7 +25,8 @@ linearDamping: 0 angularDamping: 0 - type: Projectile - soundHit: /Audio/Weapons/Guns/Hits/bullet_hit.ogg + soundHit: + path: /Audio/Weapons/Guns/Hits/bullet_hit.ogg damages: Piercing: 20 @@ -36,7 +37,8 @@ abstract: true components: - type: Projectile - soundHit: /Audio/Weapons/Guns/Hits/snap.ogg + soundHit: + path: /Audio/Weapons/Guns/Hits/snap.ogg damages: Piercing: 10 - type: FlashOnTrigger @@ -74,7 +76,8 @@ abstract: true components: - type: Projectile - soundHit: /Audio/Weapons/Guns/Hits/snap.ogg + soundHit: + path: /Audio/Weapons/Guns/Hits/snap.ogg damages: Blunt: 3 - type: StunOnCollide @@ -139,7 +142,8 @@ mask: - Opaque - type: Projectile - soundHit: /Audio/Weapons/Guns/Hits/bullet_hit.ogg + soundHit: + path: /Audio/Weapons/Guns/Hits/bullet_hit.ogg damages: Heat: 20 - type: Tag @@ -184,7 +188,8 @@ state: grenade - type: Projectile deleteOnCollide: false - soundHit: /Audio/Effects/gen_hit.ogg + soundHit: + path: /Audio/Effects/gen_hit.ogg - type: StunOnCollide stunAmount: 8 knockdownAmount: 8 @@ -222,7 +227,8 @@ state: grenade - type: Projectile deleteOnCollide: false - soundHit: /Audio/Effects/flash_bang.ogg + soundHit: + path: /Audio/Effects/flash_bang.ogg - type: FlashOnTrigger range: 7 - type: SoundOnTrigger @@ -265,7 +271,8 @@ state: foamdart - type: Projectile deleteOnCollide: true - soundHit: /Audio/Guns/Hits/snap.ogg + soundHit: + path: /Audio/Guns/Hits/snap.ogg damages: Blunt: 2 diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Revolvers/revolvers.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Revolvers/revolvers.yml index 86e9184f21..e8db31c29f 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Revolvers/revolvers.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Revolvers/revolvers.yml @@ -37,9 +37,12 @@ caliber: Magnum capacity: 5 autoCycle: true - soundGunshot: /Audio/Weapons/Guns/Gunshots/revolver.ogg - soundEmpty: /Audio/Weapons/Guns/Empty/empty.ogg - soundInsert: /Audio/Weapons/Guns/MagIn/revolver_magin.ogg + soundGunshot: + path: /Audio/Weapons/Guns/Gunshots/revolver.ogg + soundEmpty: + path: /Audio/Weapons/Guns/Empty/empty.ogg + soundInsert: + path: /Audio/Weapons/Guns/MagIn/revolver_magin.ogg - type: Appearance visuals: - type: BarrelBoltVisualizer @@ -67,10 +70,14 @@ fillPrototype: CartridgeMagnum caliber: Magnum capacity: 7 - soundEmpty: /Audio/Weapons/Guns/Empty/empty.ogg - soundGunshot: /Audio/Weapons/Guns/Gunshots/revolver.ogg - soundEject: /Audio/Weapons/Guns/MagOut/revolver_magout.ogg - soundInsert: /Audio/Weapons/Guns/MagIn/revolver_magin.ogg + soundEmpty: + path: /Audio/Weapons/Guns/Empty/empty.ogg + soundGunshot: + path: /Audio/Weapons/Guns/Gunshots/revolver.ogg + soundEject: + path: /Audio/Weapons/Guns/MagOut/revolver_magout.ogg + soundInsert: + path: /Audio/Weapons/Guns/MagIn/revolver_magin.ogg - type: entity name: Mateba @@ -91,7 +98,11 @@ fillPrototype: CartridgeMagnum caliber: Magnum capacity: 7 - soundEmpty: /Audio/Weapons/Guns/Empty/empty.ogg - soundGunshot: /Audio/Weapons/Guns/Gunshots/revolver.ogg - soundEject: /Audio/Weapons/Guns/MagOut/revolver_magout.ogg - soundInsert: /Audio/Weapons/Guns/MagIn/revolver_magin.ogg + soundEmpty: + path: /Audio/Weapons/Guns/Empty/empty.ogg + soundGunshot: + path: /Audio/Weapons/Guns/Gunshots/revolver.ogg + soundEject: + path: /Audio/Weapons/Guns/MagOut/revolver_magout.ogg + soundInsert: + path: /Audio/Weapons/Guns/MagIn/revolver_magin.ogg diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Rifles/rifles.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Rifles/rifles.yml index 161e87fa22..691ab0bf61 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Rifles/rifles.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Rifles/rifles.yml @@ -22,13 +22,20 @@ maxAngle: 45 angleIncrease: 20 angleDecay: 90 - soundGunshot: /Audio/Weapons/Guns/Gunshots/batrifle.ogg - soundEmpty: /Audio/Weapons/Guns/Empty/empty.ogg - soundRack: /Audio/Weapons/Guns/Cock/sf_rifle_cock.ogg - soundBoltOpen: /Audio/Weapons/Guns/Bolt/rifle_bolt_open.ogg - soundBoltClosed: /Audio/Weapons/Guns/Bolt/rifle_bolt_closed.ogg - soundMagInsert: /Audio/Weapons/Guns/MagIn/batrifle_magin.ogg - soundMagEject: /Audio/Weapons/Guns/MagOut/batrifle_magout.ogg + soundGunshot: + path: /Audio/Weapons/Guns/Gunshots/batrifle.ogg + soundEmpty: + path: /Audio/Weapons/Guns/Empty/empty.ogg + soundRack: + path: /Audio/Weapons/Guns/Cock/sf_rifle_cock.ogg + soundBoltOpen: + path: /Audio/Weapons/Guns/Bolt/rifle_bolt_open.ogg + soundBoltClosed: + path: /Audio/Weapons/Guns/Bolt/rifle_bolt_closed.ogg + soundMagInsert: + path: /Audio/Weapons/Guns/MagIn/batrifle_magin.ogg + soundMagEject: + path: /Audio/Weapons/Guns/MagOut/batrifle_magout.ogg - type: entity name: AKMS @@ -58,10 +65,14 @@ maxAngle: 45 angleIncrease: 20 angleDecay: 90 - soundGunshot: /Audio/Weapons/Guns/Gunshots/rifle2.ogg - soundRack: /Audio/Weapons/Guns/Cock/ltrifle_cock.ogg - soundMagInsert: /Audio/Weapons/Guns/MagIn/ltrifle_magin.ogg - soundMagEject: /Audio/Weapons/Guns/MagOut/ltrifle_magout.ogg + soundGunshot: + path: /Audio/Weapons/Guns/Gunshots/rifle2.ogg + soundRack: + path: /Audio/Weapons/Guns/Cock/ltrifle_cock.ogg + soundMagInsert: + path: /Audio/Weapons/Guns/MagIn/ltrifle_magin.ogg + soundMagEject: + path: /Audio/Weapons/Guns/MagOut/ltrifle_magout.ogg - type: Appearance visuals: - type: MagVisualizer @@ -97,10 +108,14 @@ maxAngle: 60 angleIncrease: 15 angleDecay: 60 - soundGunshot: /Audio/Weapons/Guns/Gunshots/rifle2.ogg - soundRack: /Audio/Weapons/Guns/Cock/ltrifle_cock.ogg - soundMagInsert: /Audio/Weapons/Guns/MagIn/ltrifle_magin.ogg - soundMagEject: /Audio/Weapons/Guns/MagOut/ltrifle_magout.ogg + soundGunshot: + path: /Audio/Weapons/Guns/Gunshots/rifle2.ogg + soundRack: + path: /Audio/Weapons/Guns/Cock/ltrifle_cock.ogg + soundMagInsert: + path: /Audio/Weapons/Guns/MagIn/ltrifle_magin.ogg + soundMagEject: + path: /Audio/Weapons/Guns/MagOut/ltrifle_magout.ogg - type: Appearance visuals: - type: MagVisualizer @@ -139,10 +154,14 @@ maxAngle: 45 angleIncrease: 15 angleDecay: 60 - soundGunshot: /Audio/Weapons/Guns/Gunshots/batrifle.ogg - soundRack: /Audio/Weapons/Guns/Cock/batrifle_cock.ogg - soundMagInsert: /Audio/Weapons/Guns/MagIn/batrifle_magin.ogg - soundMagEject: /Audio/Weapons/Guns/MagOut/batrifle_magout.ogg + soundGunshot: + path: /Audio/Weapons/Guns/Gunshots/batrifle.ogg + soundRack: + path: /Audio/Weapons/Guns/Cock/batrifle_cock.ogg + soundMagInsert: + path: /Audio/Weapons/Guns/MagIn/batrifle_magin.ogg + soundMagEject: + path: /Audio/Weapons/Guns/MagOut/batrifle_magout.ogg - type: Appearance visuals: - type: BarrelBoltVisualizer @@ -180,10 +199,14 @@ maxAngle: 60 angleIncrease: 10 angleDecay: 60 - soundGunshot: /Audio/Weapons/Guns/Gunshots/m41.ogg - soundRack: /Audio/Weapons/Guns/Cock/m41_cock.ogg - soundMagInsert: /Audio/Weapons/Guns/MagIn/m41_reload.ogg - soundMagEject: /Audio/Weapons/Guns/MagOut/ltrifle_magout.ogg + soundGunshot: + path: /Audio/Weapons/Guns/Gunshots/m41.ogg + soundRack: + path: /Audio/Weapons/Guns/Cock/m41_cock.ogg + soundMagInsert: + path: /Audio/Weapons/Guns/MagIn/m41_reload.ogg + soundMagEject: + path: /Audio/Weapons/Guns/MagOut/ltrifle_magout.ogg - type: Appearance visuals: - type: MagVisualizer @@ -221,10 +244,14 @@ maxAngle: 45 angleIncrease: 15 angleDecay: 60 - soundGunshot: /Audio/Weapons/Guns/Gunshots/ltrifle.ogg - soundRack: /Audio/Weapons/Guns/Cock/ltrifle_cock.ogg - soundMagInsert: /Audio/Weapons/Guns/MagIn/ltrifle_magin.ogg - soundMagEject: /Audio/Weapons/Guns/MagOut/ltrifle_magout.ogg + soundGunshot: + path: /Audio/Weapons/Guns/Gunshots/ltrifle.ogg + soundRack: + path: /Audio/Weapons/Guns/Cock/ltrifle_cock.ogg + soundMagInsert: + path: /Audio/Weapons/Guns/MagIn/ltrifle_magin.ogg + soundMagEject: + path: /Audio/Weapons/Guns/MagOut/ltrifle_magout.ogg - type: Appearance visuals: - type: BarrelBoltVisualizer @@ -304,10 +331,14 @@ maxAngle: 45 angleIncrease: 15 angleDecay: 60 - soundGunshot: /Audio/Weapons/Guns/Gunshots/ltrifle.ogg - soundRack: /Audio/Weapons/Guns/Cock/ltrifle_cock.ogg - soundMagInsert: /Audio/Weapons/Guns/MagIn/ltrifle_magin.ogg - soundMagEject: /Audio/Weapons/Guns/MagOut/ltrifle_magout.ogg + soundGunshot: + path: /Audio/Weapons/Guns/Gunshots/ltrifle.ogg + soundRack: + path: /Audio/Weapons/Guns/Cock/ltrifle_cock.ogg + soundMagInsert: + path: /Audio/Weapons/Guns/MagIn/ltrifle_magin.ogg + soundMagEject: + path: /Audio/Weapons/Guns/MagOut/ltrifle_magout.ogg - type: Appearance visuals: - type: BarrelBoltVisualizer @@ -345,10 +376,14 @@ maxAngle: 25 angleIncrease: 15 angleDecay: 25 - soundGunshot: /Audio/Weapons/Guns/Gunshots/rifle2.ogg - soundRack: /Audio/Weapons/Guns/Cock/ltrifle_cock.ogg - soundMagInsert: /Audio/Weapons/Guns/MagIn/ltrifle_magin.ogg - soundMagEject: /Audio/Weapons/Guns/MagOut/ltrifle_magout.ogg + soundGunshot: + path: /Audio/Weapons/Guns/Gunshots/rifle2.ogg + soundRack: + path: /Audio/Weapons/Guns/Cock/ltrifle_cock.ogg + soundMagInsert: + path: /Audio/Weapons/Guns/MagIn/ltrifle_magin.ogg + soundMagEject: + path: /Audio/Weapons/Guns/MagOut/ltrifle_magout.ogg - type: Appearance visuals: - type: MagVisualizer diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/SMGs/smgs.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/SMGs/smgs.yml index 88a8167472..2aa0e7fc77 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/SMGs/smgs.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/SMGs/smgs.yml @@ -25,13 +25,20 @@ angleIncrease: 10 angleDecay: 60 magFillPrototype: MagazinePistolSmg - soundGunshot: /Audio/Weapons/Guns/Gunshots/smg.ogg - soundEmpty: /Audio/Weapons/Guns/Empty/empty.ogg - soundRack: /Audio/Weapons/Guns/Cock/smg_cock.ogg - soundBoltOpen: /Audio/Weapons/Guns/Bolt/rifle_bolt_open.ogg - soundBoltClosed: /Audio/Weapons/Guns/Bolt/rifle_bolt_closed.ogg - soundMagInsert: /Audio/Weapons/Guns/MagIn/smg_magin.ogg - soundMagEject: /Audio/Weapons/Guns/MagOut/smg_magout.ogg + soundGunshot: + path: /Audio/Weapons/Guns/Gunshots/smg.ogg + soundEmpty: + path: /Audio/Weapons/Guns/Empty/empty.ogg + soundRack: + path: /Audio/Weapons/Guns/Cock/smg_cock.ogg + soundBoltOpen: + path: /Audio/Weapons/Guns/Bolt/rifle_bolt_open.ogg + soundBoltClosed: + path: /Audio/Weapons/Guns/Bolt/rifle_bolt_closed.ogg + soundMagInsert: + path: /Audio/Weapons/Guns/MagIn/smg_magin.ogg + soundMagEject: + path: /Audio/Weapons/Guns/MagOut/smg_magout.ogg - type: entity name: Atreides diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Shotguns/shotguns.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Shotguns/shotguns.yml index aa7fd8de1e..068ecd6242 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Shotguns/shotguns.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Shotguns/shotguns.yml @@ -24,9 +24,12 @@ maxAngle: 60 angleIncrease: 30 angleDecay: 30 - soundGunshot: /Audio/Weapons/Guns/Gunshots/shotgun.ogg - soundEmpty: /Audio/Weapons/Guns/Empty/empty.ogg - soundInsert: /Audio/Weapons/Guns/MagIn/shotgun_insert.ogg + soundGunshot: + path: /Audio/Weapons/Guns/Gunshots/shotgun.ogg + soundEmpty: + path: /Audio/Weapons/Guns/Empty/empty.ogg + soundInsert: + path: /Audio/Weapons/Guns/MagIn/shotgun_insert.ogg - type: entity name: Bojevic @@ -58,13 +61,20 @@ magazineTypes: - Rifle magFillPrototype: MagazineShotgun - soundGunshot: /Audio/Weapons/Guns/Gunshots/shotgun.ogg - soundEmpty: /Audio/Weapons/Guns/Empty/empty.ogg - soundRack: /Audio/Weapons/Guns/Cock/smg_cock.ogg - soundBoltOpen: /Audio/Weapons/Guns/Bolt/rifle_bolt_open.ogg - soundBoltClosed: /Audio/Weapons/Guns/Bolt/rifle_bolt_closed.ogg - soundMagInsert: /Audio/Weapons/Guns/MagIn/smg_magin.ogg - soundMagEject: /Audio/Weapons/Guns/MagOut/smg_magout.ogg + soundGunshot: + path: /Audio/Weapons/Guns/Gunshots/shotgun.ogg + soundEmpty: + path: /Audio/Weapons/Guns/Empty/empty.ogg + soundRack: + path: /Audio/Weapons/Guns/Cock/smg_cock.ogg + soundBoltOpen: + path: /Audio/Weapons/Guns/Bolt/rifle_bolt_open.ogg + soundBoltClosed: + path: /Audio/Weapons/Guns/Bolt/rifle_bolt_closed.ogg + soundMagInsert: + path: /Audio/Weapons/Guns/MagIn/smg_magin.ogg + soundMagEject: + path: /Audio/Weapons/Guns/MagOut/smg_magout.ogg - type: Appearance visuals: - type: BarrelBoltVisualizer @@ -106,11 +116,16 @@ angleIncrease: 30 angleDecay: 30 ammoSpreadRatio: 0.7 - soundGunshot: /Audio/Weapons/Guns/Gunshots/shotgun.ogg - soundEmpty: /Audio/Weapons/Guns/Empty/empty.ogg - soundInsert: /Audio/Weapons/Guns/MagIn/shotgun_insert.ogg - soundBoltOpen: /Audio/Weapons/Guns/Cock/shotgun_open.ogg - soundBoltClosed: /Audio/Weapons/Guns/Cock/shotgun_close.ogg + soundGunshot: + path: /Audio/Weapons/Guns/Gunshots/shotgun.ogg + soundEmpty: + path: /Audio/Weapons/Guns/Empty/empty.ogg + soundInsert: + path: /Audio/Weapons/Guns/MagIn/shotgun_insert.ogg + soundBoltOpen: + path: /Audio/Weapons/Guns/Cock/shotgun_open.ogg + soundBoltClosed: + path: /Audio/Weapons/Guns/Cock/shotgun_close.ogg - type: Appearance visuals: - type: BarrelBoltVisualizer @@ -228,11 +243,16 @@ maxAngle: 90 angleIncrease: 45 angleDecay: 30 - soundGunshot: /Audio/Weapons/Guns/Gunshots/shotgun.ogg - soundEmpty: /Audio/Weapons/Guns/Empty/empty.ogg - soundInsert: /Audio/Weapons/Guns/MagIn/shotgun_insert.ogg - soundBoltOpen: /Audio/Weapons/Guns/Cock/shotgun_open.ogg - soundBoltClosed: /Audio/Weapons/Guns/Cock/shotgun_close.ogg + soundGunshot: + path: /Audio/Weapons/Guns/Gunshots/shotgun.ogg + soundEmpty: + path: /Audio/Weapons/Guns/Empty/empty.ogg + soundInsert: + path: /Audio/Weapons/Guns/MagIn/shotgun_insert.ogg + soundBoltOpen: + path: /Audio/Weapons/Guns/Cock/shotgun_open.ogg + soundBoltClosed: + path: /Audio/Weapons/Guns/Cock/shotgun_close.ogg - type: Appearance visuals: - type: BarrelBoltVisualizer diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Snipers/snipers.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Snipers/snipers.yml index 3b7cb37869..dc784e2b92 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Snipers/snipers.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Snipers/snipers.yml @@ -26,9 +26,12 @@ maxAngle: 45 angleIncrease: 20 angleDecay: 15 - soundGunshot: /Audio/Weapons/Guns/Gunshots/sniper.ogg - soundEmpty: /Audio/Weapons/Guns/Empty/empty.ogg - soundInsert: /Audio/Weapons/Guns/MagIn/bullet_insert.ogg + soundGunshot: + path: /Audio/Weapons/Guns/Gunshots/sniper.ogg + soundEmpty: + path: /Audio/Weapons/Guns/Empty/empty.ogg + soundInsert: + path: /Audio/Weapons/Guns/MagIn/bullet_insert.ogg - type: entity name: Kardashev-Mosin diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Melee/knife.yml b/Resources/Prototypes/Entities/Objects/Weapons/Melee/knife.yml index f26e4bd96d..05b7e46d44 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Melee/knife.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Melee/knife.yml @@ -8,7 +8,8 @@ - Knife - type: ItemCooldown - type: MeleeWeapon - hitSound: /Audio/Weapons/bladeslice.ogg + hitSound: + path: /Audio/Weapons/bladeslice.ogg damage: 12 - type: Sprite netsync: false diff --git a/Resources/Prototypes/Entities/Structures/Dispensers/base.yml b/Resources/Prototypes/Entities/Structures/Dispensers/base.yml index 2f33762b74..9db9c1b2ab 100644 --- a/Resources/Prototypes/Entities/Structures/Dispensers/base.yml +++ b/Resources/Prototypes/Entities/Structures/Dispensers/base.yml @@ -39,4 +39,5 @@ - !type:DoActsBehavior acts: ["Destruction"] - !type:PlaySoundBehavior - sound: /Audio/Effects/metalbreak.ogg + sound: + path: /Audio/Effects/metalbreak.ogg diff --git a/Resources/Prototypes/Entities/Structures/Doors/Airlocks/base.yml b/Resources/Prototypes/Entities/Structures/Doors/Airlocks/base.yml index 7b88ff7002..96eee35691 100644 --- a/Resources/Prototypes/Entities/Structures/Doors/Airlocks/base.yml +++ b/Resources/Prototypes/Entities/Structures/Doors/Airlocks/base.yml @@ -42,9 +42,12 @@ - type: Appearance visuals: - type: AirlockVisualizer - open_sound: /Audio/Machines/airlock_open.ogg - close_sound: /Audio/Machines/airlock_close.ogg - deny_sound: /Audio/Machines/airlock_deny.ogg + open_sound: + path: /Audio/Machines/airlock_open.ogg + close_sound: + path: /Audio/Machines/airlock_close.ogg + deny_sound: + path: /Audio/Machines/airlock_deny.ogg - type: WiresVisualizer - type: ApcPowerReceiver - type: Wires diff --git a/Resources/Prototypes/Entities/Structures/Doors/Airlocks/external.yml b/Resources/Prototypes/Entities/Structures/Doors/Airlocks/external.yml index b33fa434c7..8d3fc73512 100644 --- a/Resources/Prototypes/Entities/Structures/Doors/Airlocks/external.yml +++ b/Resources/Prototypes/Entities/Structures/Doors/Airlocks/external.yml @@ -11,7 +11,10 @@ - type: Appearance visuals: - type: AirlockVisualizer - open_sound: /Audio/Machines/airlock_ext_open.ogg - close_sound: /Audio/Machines/airlock_ext_close.ogg - deny_sound: /Audio/Machines/airlock_deny.ogg + open_sound: + path: /Audio/Machines/airlock_ext_open.ogg + close_sound: + path: /Audio/Machines/airlock_ext_close.ogg + deny_sound: + path: /Audio/Machines/airlock_deny.ogg - type: WiresVisualizer diff --git a/Resources/Prototypes/Entities/Structures/Doors/Firelocks/firelock.yml b/Resources/Prototypes/Entities/Structures/Doors/Firelocks/firelock.yml index 40fad456b0..e8f8e3e43a 100644 --- a/Resources/Prototypes/Entities/Structures/Doors/Firelocks/firelock.yml +++ b/Resources/Prototypes/Entities/Structures/Doors/Firelocks/firelock.yml @@ -58,9 +58,12 @@ - type: Appearance visuals: - type: AirlockVisualizer - open_sound: /Audio/Machines/airlock_open.ogg - close_sound: /Audio/Machines/airlock_close.ogg - deny_sound: /Audio/Machines/airlock_deny.ogg + open_sound: + path: /Audio/Machines/airlock_open.ogg + close_sound: + path: /Audio/Machines/airlock_close.ogg + deny_sound: + path: /Audio/Machines/airlock_deny.ogg animation_time: 0.6 - type: WiresVisualizer - type: Wires diff --git a/Resources/Prototypes/Entities/Structures/Furniture/Tables/tables.yml b/Resources/Prototypes/Entities/Structures/Furniture/Tables/tables.yml index e9c2fc3f2a..fe92c46e4d 100644 --- a/Resources/Prototypes/Entities/Structures/Furniture/Tables/tables.yml +++ b/Resources/Prototypes/Entities/Structures/Furniture/Tables/tables.yml @@ -17,7 +17,8 @@ damage: 1 behaviors: - !type:PlaySoundBehavior - sound: /Audio/Effects/metalbreak.ogg + sound: + path: /Audio/Effects/metalbreak.ogg - !type:SpawnEntitiesBehavior spawn: PartRodMetal1: @@ -48,7 +49,8 @@ damage: 15 behaviors: - !type:PlaySoundBehavior - sound: /Audio/Effects/metalbreak.ogg + sound: + path: /Audio/Effects/metalbreak.ogg - !type:SpawnEntitiesBehavior spawn: SheetSteel1: @@ -77,7 +79,8 @@ damage: 1 behaviors: - !type:PlaySoundBehavior - sound: /Audio/Effects/metalbreak.ogg + sound: + path: /Audio/Effects/metalbreak.ogg - !type:SpawnEntitiesBehavior spawn: SheetSteel1: @@ -109,7 +112,8 @@ damage: 15 behaviors: - !type:PlaySoundBehavior - sound: /Audio/Effects/metalbreak.ogg + sound: + path: /Audio/Effects/metalbreak.ogg - !type:SpawnEntitiesBehavior spawn: SheetSteel1: @@ -135,7 +139,8 @@ damage: 75 behaviors: - !type:PlaySoundBehavior - sound: /Audio/Effects/metalbreak.ogg + sound: + path: /Audio/Effects/metalbreak.ogg - !type:SpawnEntitiesBehavior spawn: SheetSteel1: @@ -164,7 +169,8 @@ damage: 5 behaviors: - !type:PlaySoundBehavior - sound: /Audio/Effects/glass_break2.ogg + sound: + path: /Audio/Effects/glass_break2.ogg - !type:SpawnEntitiesBehavior spawn: ShardGlass: @@ -193,7 +199,8 @@ damage: 20 behaviors: - !type:PlaySoundBehavior - sound: /Audio/Effects/glass_break2.ogg + sound: + path: /Audio/Effects/glass_break2.ogg - !type:SpawnEntitiesBehavior spawn: ShardGlass: @@ -225,7 +232,8 @@ damage: 15 behaviors: - !type:PlaySoundBehavior - sound: /Audio/Effects/woodhit.ogg + sound: + path: /Audio/Effects/woodhit.ogg - !type:SpawnEntitiesBehavior spawn: MaterialWoodPlank: @@ -254,7 +262,8 @@ damage: 15 behaviors: - !type:PlaySoundBehavior - sound: /Audio/Effects/woodhit.ogg + sound: + path: /Audio/Effects/woodhit.ogg - !type:SpawnEntitiesBehavior spawn: MaterialWoodPlank: @@ -286,7 +295,8 @@ damage: 50 behaviors: - !type:PlaySoundBehavior - sound: /Audio/Effects/picaxe2.ogg + sound: + path: /Audio/Effects/picaxe2.ogg - !type:DoActsBehavior acts: [ "Destruction" ] diff --git a/Resources/Prototypes/Entities/Structures/Furniture/bookshelf.yml b/Resources/Prototypes/Entities/Structures/Furniture/bookshelf.yml index 4e4cf4e074..d3121f063b 100644 --- a/Resources/Prototypes/Entities/Structures/Furniture/bookshelf.yml +++ b/Resources/Prototypes/Entities/Structures/Furniture/bookshelf.yml @@ -27,7 +27,8 @@ damage: 30 behaviors: - !type:PlaySoundBehavior - sound: /Audio/Effects/woodhit.ogg + sound: + path: /Audio/Effects/woodhit.ogg - !type:SpawnEntitiesBehavior spawn: MaterialWoodPlank: diff --git a/Resources/Prototypes/Entities/Structures/Furniture/potted_plants.yml b/Resources/Prototypes/Entities/Structures/Furniture/potted_plants.yml index 07a2513d2a..121e4523da 100644 --- a/Resources/Prototypes/Entities/Structures/Furniture/potted_plants.yml +++ b/Resources/Prototypes/Entities/Structures/Furniture/potted_plants.yml @@ -34,7 +34,8 @@ - !type:DoActsBehavior acts: ["Destruction"] - !type:PlaySoundBehavior - sound: /Audio/Effects/plant_rustle.ogg + sound: + path: /Audio/Effects/plant_rustle.ogg - type: entity id: PottedPlantRandom diff --git a/Resources/Prototypes/Entities/Structures/Furniture/seats.yml b/Resources/Prototypes/Entities/Structures/Furniture/seats.yml index 4965150328..219af9a839 100644 --- a/Resources/Prototypes/Entities/Structures/Furniture/seats.yml +++ b/Resources/Prototypes/Entities/Structures/Furniture/seats.yml @@ -34,7 +34,8 @@ - !type:DoActsBehavior acts: ["Destruction"] - !type:PlaySoundBehavior - sound: /Audio/Effects/metalbreak.ogg + sound: + path: /Audio/Effects/metalbreak.ogg - type: entity name: chair @@ -193,7 +194,8 @@ - !type:DoActsBehavior acts: ["Destruction"] - !type:PlaySoundBehavior - sound: /Audio/Effects/woodhit.ogg + sound: + path: /Audio/Effects/woodhit.ogg - !type:SpawnEntitiesBehavior spawn: MaterialWoodPlank: diff --git a/Resources/Prototypes/Entities/Structures/Machines/Computers/frame.yml b/Resources/Prototypes/Entities/Structures/Machines/Computers/frame.yml index 77cba8a15c..8c3b3a7836 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/Computers/frame.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/Computers/frame.yml @@ -35,8 +35,8 @@ !type:DamageTrigger damage: 100 behaviors: - - !type:PlaySoundCollectionBehavior - soundCollection: GlassBreak + - !type:PlaySoundBehavior + collection: GlassBreak - !type:ChangeConstructionNodeBehavior node: monitorBroken - !type:DoActsBehavior @@ -61,7 +61,8 @@ damage: 50 behaviors: - !type:PlaySoundBehavior - sound: /Audio/Effects/metalbreak.ogg + sound: + path: /Audio/Effects/metalbreak.ogg - !type:SpawnEntitiesBehavior spawn: SheetSteel1: diff --git a/Resources/Prototypes/Entities/Structures/Machines/base.yml b/Resources/Prototypes/Entities/Structures/Machines/base.yml index 9f7d7faad1..a251c4dfed 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/base.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/base.yml @@ -28,7 +28,8 @@ - !type:DoActsBehavior acts: ["Destruction"] - !type:PlaySoundBehavior - sound: /Audio/Effects/metalbreak.ogg + sound: + path: /Audio/Effects/metalbreak.ogg - type: entity abstract: true diff --git a/Resources/Prototypes/Entities/Structures/Machines/research.yml b/Resources/Prototypes/Entities/Structures/Machines/research.yml index 2ac286ab18..c52e37616e 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/research.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/research.yml @@ -21,7 +21,8 @@ - !type:DoActsBehavior acts: ["Destruction"] - !type:PlaySoundBehavior - sound: /Audio/Effects/metalbreak.ogg + sound: + path: /Audio/Effects/metalbreak.ogg - !type:SpawnEntitiesBehavior spawn: SheetSteel1: @@ -60,7 +61,8 @@ - !type:DoActsBehavior acts: ["Destruction"] - !type:PlaySoundBehavior - sound: /Audio/Effects/metalbreak.ogg + sound: + path: /Audio/Effects/metalbreak.ogg - !type:SpawnEntitiesBehavior spawn: SheetSteel1: diff --git a/Resources/Prototypes/Entities/Structures/Piping/Disposal/units.yml b/Resources/Prototypes/Entities/Structures/Piping/Disposal/units.yml index d8cb9c3f48..6579cfb242 100644 --- a/Resources/Prototypes/Entities/Structures/Piping/Disposal/units.yml +++ b/Resources/Prototypes/Entities/Structures/Piping/Disposal/units.yml @@ -40,7 +40,8 @@ - !type:DoActsBehavior acts: ["Destruction"] - !type:PlaySoundBehavior - sound: /Audio/Effects/metalbreak.ogg + sound: + path: /Audio/Effects/metalbreak.ogg - !type:SpawnEntitiesBehavior spawn: SheetSteel1: @@ -57,7 +58,8 @@ overlay_full: dispover-full overlay_engaged: dispover-handle state_flush: disposal-flush - flush_sound: /Audio/Machines/disposalflush.ogg + flush_sound: + path: /Audio/Machines/disposalflush.ogg flush_time: 2 - type: UserInterface interfaces: diff --git a/Resources/Prototypes/Entities/Structures/Power/Generation/PA/particles.yml b/Resources/Prototypes/Entities/Structures/Power/Generation/PA/particles.yml index 146ba2fa58..356549836d 100644 --- a/Resources/Prototypes/Entities/Structures/Power/Generation/PA/particles.yml +++ b/Resources/Prototypes/Entities/Structures/Power/Generation/PA/particles.yml @@ -11,7 +11,8 @@ shader: unshaded - type: Projectile deleteOnCollide: false - soundHit: /Audio/Weapons/Guns/Hits/bullet_hit.ogg + soundHit: + path: /Audio/Weapons/Guns/Hits/bullet_hit.ogg damages: Radiation: 10 - type: Physics diff --git a/Resources/Prototypes/Entities/Structures/Power/Generation/Singularity/emitter.yml b/Resources/Prototypes/Entities/Structures/Power/Generation/Singularity/emitter.yml index ba39a44907..bad4f42819 100644 --- a/Resources/Prototypes/Entities/Structures/Power/Generation/Singularity/emitter.yml +++ b/Resources/Prototypes/Entities/Structures/Power/Generation/Singularity/emitter.yml @@ -52,7 +52,8 @@ damage: 200 behaviors: - !type:PlaySoundBehavior - sound: /Audio/Effects/metalbreak.ogg + sound: + path: /Audio/Effects/metalbreak.ogg - !type:SpawnEntitiesBehavior spawn: SheetSteel1: diff --git a/Resources/Prototypes/Entities/Structures/Storage/Canisters/base.yml b/Resources/Prototypes/Entities/Structures/Storage/Canisters/base.yml index 2be102cc95..b0d71322f7 100644 --- a/Resources/Prototypes/Entities/Structures/Storage/Canisters/base.yml +++ b/Resources/Prototypes/Entities/Structures/Storage/Canisters/base.yml @@ -32,7 +32,8 @@ damage: 300 behaviors: - !type:PlaySoundBehavior - sound: /Audio/Effects/metalbreak.ogg + sound: + path: /Audio/Effects/metalbreak.ogg - !type:SpawnEntitiesBehavior spawn: GasCanisterBrokenBase: diff --git a/Resources/Prototypes/Entities/Structures/Storage/Canisters/gas_canisters.yml b/Resources/Prototypes/Entities/Structures/Storage/Canisters/gas_canisters.yml index 7144edd6f1..6420621d67 100644 --- a/Resources/Prototypes/Entities/Structures/Storage/Canisters/gas_canisters.yml +++ b/Resources/Prototypes/Entities/Structures/Storage/Canisters/gas_canisters.yml @@ -23,7 +23,8 @@ damage: 300 behaviors: - !type:PlaySoundBehavior - sound: /Audio/Effects/metalbreak.ogg + sound: + path: /Audio/Effects/metalbreak.ogg - !type:SpawnEntitiesBehavior spawn: StorageCanisterBroken: @@ -55,7 +56,8 @@ damage: 300 behaviors: - !type:PlaySoundBehavior - sound: /Audio/Effects/metalbreak.ogg + sound: + path: /Audio/Effects/metalbreak.ogg - !type:SpawnEntitiesBehavior spawn: AirCanisterBroken: @@ -84,7 +86,8 @@ damage: 300 behaviors: - !type:PlaySoundBehavior - sound: /Audio/Effects/metalbreak.ogg + sound: + path: /Audio/Effects/metalbreak.ogg - !type:SpawnEntitiesBehavior spawn: OxygenCanisterBroken: @@ -114,7 +117,8 @@ damage: 300 behaviors: - !type:PlaySoundBehavior - sound: /Audio/Effects/metalbreak.ogg + sound: + path: /Audio/Effects/metalbreak.ogg - !type:SpawnEntitiesBehavior spawn: NitrogenCanisterBroken: @@ -145,7 +149,8 @@ damage: 300 behaviors: - !type:PlaySoundBehavior - sound: /Audio/Effects/metalbreak.ogg + sound: + path: /Audio/Effects/metalbreak.ogg - !type:SpawnEntitiesBehavior spawn: CarbonDioxideCanisterBroken: @@ -177,7 +182,8 @@ damage: 300 behaviors: - !type:PlaySoundBehavior - sound: /Audio/Effects/metalbreak.ogg + sound: + path: /Audio/Effects/metalbreak.ogg - !type:SpawnEntitiesBehavior spawn: PlasmaCanisterBroken: @@ -210,7 +216,8 @@ damage: 300 behaviors: - !type:PlaySoundBehavior - sound: /Audio/Effects/metalbreak.ogg + sound: + path: /Audio/Effects/metalbreak.ogg - !type:SpawnEntitiesBehavior spawn: TritiumCanisterBroken: @@ -244,7 +251,8 @@ damage: 300 behaviors: - !type:PlaySoundBehavior - sound: /Audio/Effects/metalbreak.ogg + sound: + path: /Audio/Effects/metalbreak.ogg - !type:SpawnEntitiesBehavior spawn: WaterVaporCanisterBroken: @@ -269,7 +277,8 @@ damage: 100 behaviors: - !type:PlaySoundBehavior - sound: /Audio/Effects/metalbreak.ogg + sound: + path: /Audio/Effects/metalbreak.ogg - !type:SpawnEntitiesBehavior spawn: SheetPlasteel1: diff --git a/Resources/Prototypes/Entities/Structures/Storage/Closets/Lockers/base.yml b/Resources/Prototypes/Entities/Structures/Storage/Closets/Lockers/base.yml index a8fe9b1a7e..f5f95c1f70 100644 --- a/Resources/Prototypes/Entities/Structures/Storage/Closets/Lockers/base.yml +++ b/Resources/Prototypes/Entities/Structures/Storage/Closets/Lockers/base.yml @@ -28,7 +28,8 @@ - !type:DoActsBehavior acts: ["Destruction"] - !type:PlaySoundBehavior - sound: /Audio/Effects/metalbreak.ogg + sound: + path: /Audio/Effects/metalbreak.ogg - !type:SpawnEntitiesBehavior spawn: SheetSteel1: diff --git a/Resources/Prototypes/Entities/Structures/Storage/Closets/base.yml b/Resources/Prototypes/Entities/Structures/Storage/Closets/base.yml index b64910f093..25add8d12a 100644 --- a/Resources/Prototypes/Entities/Structures/Storage/Closets/base.yml +++ b/Resources/Prototypes/Entities/Structures/Storage/Closets/base.yml @@ -16,7 +16,8 @@ map: ["enum.StorageVisualLayers.Welded"] - type: MovedByPressure - type: DamageOnHighSpeedImpact - soundHit: /Audio/Effects/bang.ogg + soundHit: + path: /Audio/Effects/bang.ogg - type: InteractionOutline - type: Physics fixtures: @@ -46,7 +47,8 @@ - !type:DoActsBehavior acts: ["Destruction"] - !type:PlaySoundBehavior - sound: /Audio/Effects/metalbreak.ogg + sound: + path: /Audio/Effects/metalbreak.ogg - !type:SpawnEntitiesBehavior spawn: SheetSteel1: diff --git a/Resources/Prototypes/Entities/Structures/Storage/Crates/crates.yml b/Resources/Prototypes/Entities/Structures/Storage/Crates/crates.yml index 70e4f09b5d..4f02fb8c52 100644 --- a/Resources/Prototypes/Entities/Structures/Storage/Crates/crates.yml +++ b/Resources/Prototypes/Entities/Structures/Storage/Crates/crates.yml @@ -538,7 +538,8 @@ damage: 15 behaviors: - !type:PlaySoundBehavior - sound: /Audio/Effects/woodhit.ogg + sound: + path: /Audio/Effects/woodhit.ogg - !type:SpawnEntitiesBehavior spawn: MaterialWoodPlank1: diff --git a/Resources/Prototypes/Entities/Structures/Storage/morgue.yml b/Resources/Prototypes/Entities/Structures/Storage/morgue.yml index 92e4e35a4e..4c6a1251f6 100644 --- a/Resources/Prototypes/Entities/Structures/Storage/morgue.yml +++ b/Resources/Prototypes/Entities/Structures/Storage/morgue.yml @@ -36,8 +36,10 @@ CanWeldShut: false IsCollidableWhenOpen: true Capacity: 1 - closeSound: /Audio/Items/deconstruct.ogg - openSound: /Audio/Items/deconstruct.ogg + closeSound: + path: /Audio/Items/deconstruct.ogg + openSound: + path: /Audio/Items/deconstruct.ogg trayPrototype: MorgueTray - type: Appearance visuals: @@ -101,8 +103,10 @@ CanWeldShut: false IsCollidableWhenOpen: true Capacity: 1 - closeSound: /Audio/Items/deconstruct.ogg - openSound: /Audio/Items/deconstruct.ogg + closeSound: + path: /Audio/Items/deconstruct.ogg + openSound: + path: /Audio/Items/deconstruct.ogg trayPrototype: CrematoriumTray doSoulBeep: false - type: Appearance diff --git a/Resources/Prototypes/Entities/Structures/Storage/storage.yml b/Resources/Prototypes/Entities/Structures/Storage/storage.yml index c2704fb71d..9d572776f4 100644 --- a/Resources/Prototypes/Entities/Structures/Storage/storage.yml +++ b/Resources/Prototypes/Entities/Structures/Storage/storage.yml @@ -34,7 +34,8 @@ damage: 30 behaviors: - !type:PlaySoundBehavior - sound: /Audio/Effects/metalbreak.ogg + sound: + path: /Audio/Effects/metalbreak.ogg - !type:SpawnEntitiesBehavior spawn: SheetSteel1: diff --git a/Resources/Prototypes/Entities/Structures/Wallmounts/lighting.yml b/Resources/Prototypes/Entities/Structures/Wallmounts/lighting.yml index de20894f6d..ff22cbf7c8 100644 --- a/Resources/Prototypes/Entities/Structures/Wallmounts/lighting.yml +++ b/Resources/Prototypes/Entities/Structures/Wallmounts/lighting.yml @@ -66,7 +66,8 @@ - type: Appearance visuals: - type: PoweredLightVisualizer - blinkingSound: "/Audio/Machines/light_tube_on.ogg" + blinkingSound: + path: "/Audio/Machines/light_tube_on.ogg" - type: entity id: PoweredlightEmpty diff --git a/Resources/Prototypes/Entities/Structures/Walls/walls.yml b/Resources/Prototypes/Entities/Structures/Walls/walls.yml index 365ecd9b81..bf73758531 100644 --- a/Resources/Prototypes/Entities/Structures/Walls/walls.yml +++ b/Resources/Prototypes/Entities/Structures/Walls/walls.yml @@ -431,12 +431,14 @@ damage: 300 behaviors: - !type:PlaySoundBehavior - sound: /Audio/Effects/metalbreak.ogg + sound: + path: /Audio/Effects/metalbreak.ogg - !type:ChangeConstructionNodeBehavior node: girder - !type:DoActsBehavior acts: ["Destruction"] - destroySound: /Audio/Effects/metalbreak.ogg + destroySound: + path: /Audio/Effects/metalbreak.ogg - type: IconSmooth key: walls base: solid diff --git a/Resources/Prototypes/Entities/Structures/Windows/plasma.yml b/Resources/Prototypes/Entities/Structures/Windows/plasma.yml index 1672f3ac9a..b16e990e6c 100644 --- a/Resources/Prototypes/Entities/Structures/Windows/plasma.yml +++ b/Resources/Prototypes/Entities/Structures/Windows/plasma.yml @@ -16,8 +16,8 @@ !type:DamageTrigger damage: 200 behaviors: - - !type:PlaySoundCollectionBehavior - soundCollection: GlassBreak + - !type:PlaySoundBehavior + collection: GlassBreak - !type:SpawnEntitiesBehavior spawn: ShardGlassPlasma: diff --git a/Resources/Prototypes/Entities/Structures/Windows/reinforced.yml b/Resources/Prototypes/Entities/Structures/Windows/reinforced.yml index 2b34fc4eee..42ffc0b5f6 100644 --- a/Resources/Prototypes/Entities/Structures/Windows/reinforced.yml +++ b/Resources/Prototypes/Entities/Structures/Windows/reinforced.yml @@ -17,8 +17,8 @@ !type:DamageTrigger damage: 150 behaviors: - - !type:PlaySoundCollectionBehavior - soundCollection: GlassBreak + - !type:PlaySoundBehavior + collection: GlassBreak - !type:SpawnEntitiesBehavior spawn: ShardGlassReinforced: diff --git a/Resources/Prototypes/Entities/Structures/Windows/window.yml b/Resources/Prototypes/Entities/Structures/Windows/window.yml index 49aff00bc0..944683d950 100644 --- a/Resources/Prototypes/Entities/Structures/Windows/window.yml +++ b/Resources/Prototypes/Entities/Structures/Windows/window.yml @@ -38,8 +38,8 @@ !type:DamageTrigger damage: 15 behaviors: - - !type:PlaySoundCollectionBehavior - soundCollection: GlassBreak + - !type:PlaySoundBehavior + collection: GlassBreak - !type:SpawnEntitiesBehavior spawn: ShardGlass: diff --git a/Resources/Prototypes/Entities/Structures/catwalk.yml b/Resources/Prototypes/Entities/Structures/catwalk.yml index fcb1cfc7e6..9e51b58796 100644 --- a/Resources/Prototypes/Entities/Structures/catwalk.yml +++ b/Resources/Prototypes/Entities/Structures/catwalk.yml @@ -25,7 +25,8 @@ key: catwalk base: catwalk_ - type: FootstepModifier - footstepSoundCollection: footstep_catwalk + footstepSoundCollection: + collection: footstep_catwalk - type: Construction graph: Catwalk node: Catwalk diff --git a/Resources/Prototypes/Entities/Structures/meat_spike.yml b/Resources/Prototypes/Entities/Structures/meat_spike.yml index c5ac6e35f1..5aa05a11f3 100644 --- a/Resources/Prototypes/Entities/Structures/meat_spike.yml +++ b/Resources/Prototypes/Entities/Structures/meat_spike.yml @@ -21,7 +21,8 @@ - !type:DoActsBehavior acts: ["Destruction"] - !type:PlaySoundBehavior - sound: /Audio/Effects/metalbreak.ogg + sound: + path: /Audio/Effects/metalbreak.ogg - !type:SpawnEntitiesBehavior spawn: SheetSteel1: diff --git a/Resources/Prototypes/Recipes/Reactions/chemicals.yml b/Resources/Prototypes/Recipes/Reactions/chemicals.yml index e719e598fe..e6a4204143 100644 --- a/Resources/Prototypes/Recipes/Reactions/chemicals.yml +++ b/Resources/Prototypes/Recipes/Reactions/chemicals.yml @@ -90,7 +90,8 @@ removeDelay: 0.5 diluteReagents: false prototypeId: Smoke - sound: /Audio/Effects/smoke.ogg + sound: + path: /Audio/Effects/smoke.ogg - type: reaction id: Foam diff --git a/Resources/Prototypes/Tiles/floors.yml b/Resources/Prototypes/Tiles/floors.yml index 38e6d2c26e..e29e1b349a 100644 --- a/Resources/Prototypes/Tiles/floors.yml +++ b/Resources/Prototypes/Tiles/floors.yml @@ -6,7 +6,8 @@ - plating is_subfloor: false can_crowbar: true - footstep_sounds: footstep_floor + footstep_sounds: + collection: footstep_floor friction: 0.30 item_drop: FloorTileItemDark @@ -18,7 +19,8 @@ - plating is_subfloor: false can_crowbar: true - footstep_sounds: footstep_floor + footstep_sounds: + collection: footstep_floor friction: 0.30 - type: tile @@ -29,7 +31,8 @@ - plating is_subfloor: false can_crowbar: true - footstep_sounds: footstep_floor + footstep_sounds: + collection: footstep_floor friction: 0.30 item_drop: FloorTileItemFreezer @@ -41,7 +44,8 @@ - plating is_subfloor: false can_crowbar: true - footstep_sounds: footstep_floor + footstep_sounds: + collection: footstep_floor friction: 0.30 - type: tile @@ -52,7 +56,8 @@ - plating is_subfloor: false can_crowbar: true - footstep_sounds: footstep_floor + footstep_sounds: + collection: footstep_floor friction: 0.30 item_drop: FloorTileItemGCircuit @@ -64,7 +69,8 @@ - plating is_subfloor: false can_crowbar: true - footstep_sounds: footstep_floor + footstep_sounds: + collection: footstep_floor friction: 0.30 item_drop: FloorTileItemLino @@ -76,7 +82,8 @@ - plating is_subfloor: false can_crowbar: true - footstep_sounds: footstep_floor + footstep_sounds: + collection: footstep_floor friction: 0.30 item_drop: FloorTileItemMono @@ -88,7 +95,8 @@ - plating is_subfloor: false can_crowbar: true - footstep_sounds: footstep_floor + footstep_sounds: + collection: footstep_floor friction: 0.30 item_drop: FloorTileItemReinforced @@ -100,7 +108,8 @@ - plating is_subfloor: false can_crowbar: true - footstep_sounds: footstep_floor + footstep_sounds: + collection: footstep_floor friction: 0.30 - type: tile @@ -111,7 +120,8 @@ - plating is_subfloor: false can_crowbar: true - footstep_sounds: footstep_floor + footstep_sounds: + collection: footstep_floor friction: 0.30 item_drop: FloorTileItemShowroom @@ -123,7 +133,8 @@ - plating is_subfloor: false can_crowbar: true - footstep_sounds: footstep_floor + footstep_sounds: + collection: footstep_floor friction: 0.30 item_drop: FloorTileItemSteel @@ -135,7 +146,8 @@ - plating is_subfloor: false can_crowbar: true - footstep_sounds: footstep_floor + footstep_sounds: + collection: footstep_floor friction: 0.30 item_drop: FloorTileItemDirty @@ -147,7 +159,8 @@ - plating is_subfloor: false can_crowbar: true - footstep_sounds: footstep_floor + footstep_sounds: + collection: footstep_floor friction: 0.30 item_drop: FloorTileItemTechmaint @@ -159,7 +172,8 @@ - plating is_subfloor: false can_crowbar: true - footstep_sounds: footstep_floor + footstep_sounds: + collection: footstep_floor friction: 0.25 item_drop: FloorTileItemWhite @@ -171,7 +185,8 @@ - space is_subfloor: false can_crowbar: false - footstep_sounds: footstep_asteroid + footstep_sounds: + collection: footstep_asteroid friction: 0.30 - type: tile @@ -182,7 +197,8 @@ - plating is_subfloor: false can_crowbar: true - footstep_sounds: footstep_asteroid + footstep_sounds: + collection: footstep_asteroid friction: 0.30 - type: tile @@ -193,7 +209,8 @@ - space is_subfloor: false can_crowbar: false - footstep_sounds: footstep_asteroid + footstep_sounds: + collection: footstep_asteroid friction: 0.30 - type: tile @@ -204,7 +221,8 @@ - space is_subfloor: false can_crowbar: false - footstep_sounds: footstep_asteroid + footstep_sounds: + collection: footstep_asteroid friction: 0.30 - type: tile @@ -215,7 +233,8 @@ - space is_subfloor: false can_crowbar: false - footstep_sounds: footstep_asteroid + footstep_sounds: + collection: footstep_asteroid friction: 0.30 - type: tile @@ -226,7 +245,8 @@ - space is_subfloor: false can_crowbar: false - footstep_sounds: footstep_asteroid + footstep_sounds: + collection: footstep_asteroid friction: 0.30 - type: tile @@ -237,7 +257,8 @@ - space is_subfloor: false can_crowbar: false - footstep_sounds: footstep_snow + footstep_sounds: + collection: footstep_snow friction: 0.30 - type: tile @@ -248,7 +269,8 @@ - plating is_subfloor: false can_crowbar: true - footstep_sounds: footstep_floor + footstep_sounds: + collection: footstep_floor friction: 0.30 item_drop: FloorTileItemGold @@ -260,7 +282,8 @@ - plating is_subfloor: false can_crowbar: true - footstep_sounds: footstep_floor + footstep_sounds: + collection: footstep_floor friction: 0.30 item_drop: SheetGlass1 @@ -272,7 +295,8 @@ - plating is_subfloor: false can_crowbar: true - footstep_sounds: footstep_floor + footstep_sounds: + collection: footstep_floor friction: 0.30 item_drop: SheetRGlass1 @@ -284,7 +308,8 @@ - plating is_subfloor: false can_crowbar: true - footstep_sounds: footstep_floor + footstep_sounds: + collection: footstep_floor friction: 0.30 - type: tile @@ -295,7 +320,8 @@ - plating is_subfloor: false can_crowbar: true - footstep_sounds: footstep_floor + footstep_sounds: + collection: footstep_floor friction: 0.30 - type: tile @@ -306,7 +332,8 @@ - plating is_subfloor: false can_crowbar: true - footstep_sounds: footstep_floor + footstep_sounds: + collection: footstep_floor friction: 0.30 - type: tile @@ -317,7 +344,8 @@ - plating is_subfloor: false can_crowbar: true - footstep_sounds: footstep_floor + footstep_sounds: + collection: footstep_floor friction: 0.30 - type: tile @@ -328,5 +356,6 @@ - plating is_subfloor: false can_crowbar: true - footstep_sounds: footstep_floor + footstep_sounds: + collection: footstep_floor friction: 0.30 diff --git a/Resources/Prototypes/Tiles/plating.yml b/Resources/Prototypes/Tiles/plating.yml index cd9e3c5178..559c56631f 100644 --- a/Resources/Prototypes/Tiles/plating.yml +++ b/Resources/Prototypes/Tiles/plating.yml @@ -5,7 +5,8 @@ base_turfs: - underplating is_subfloor: true - footstep_sounds: footstep_plating + footstep_sounds: + collection: footstep_plating friction: 0.5 - type: tile @@ -15,7 +16,8 @@ base_turfs: - space is_subfloor: true - footstep_sounds: footstep_plating + footstep_sounds: + collection: footstep_plating friction: 0.5 is_space: true @@ -26,5 +28,6 @@ base_turfs: - lattice is_subfloor: true - footstep_sounds: footstep_plating + footstep_sounds: + collection: footstep_plating friction: 0.5 diff --git a/Resources/Prototypes/Tiles/wood.yml b/Resources/Prototypes/Tiles/wood.yml index c6c1149a23..60d835aa40 100644 --- a/Resources/Prototypes/Tiles/wood.yml +++ b/Resources/Prototypes/Tiles/wood.yml @@ -7,6 +7,7 @@ - plating is_subfloor: false can_crowbar: true - footstep_sounds: footstep_wood + footstep_sounds: + collection: footstep_wood friction: 0.30 item_drop: FloorTileItemWood diff --git a/RobustToolbox b/RobustToolbox index 8fea42ff9a..9397cc4a6b 160000 --- a/RobustToolbox +++ b/RobustToolbox @@ -1 +1 @@ -Subproject commit 8fea42ff9ac05dfef40f9fec0dfd051ba054dbfa +Subproject commit 9397cc4a6b91c04087540319de58d469d9ceb42e From 8ff703c3389e3cbe3514d3ea3682ec23552d262f Mon Sep 17 00:00:00 2001 From: Galactic Chimp Date: Sat, 31 Jul 2021 17:22:08 +0200 Subject: [PATCH 11/18] added comment --- Content.Server/Storage/Components/ServerStorageComponent.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Content.Server/Storage/Components/ServerStorageComponent.cs b/Content.Server/Storage/Components/ServerStorageComponent.cs index 14654a38ac..f96da5ced6 100644 --- a/Content.Server/Storage/Components/ServerStorageComponent.cs +++ b/Content.Server/Storage/Components/ServerStorageComponent.cs @@ -631,7 +631,8 @@ namespace Content.Server.Storage.Components private void PlaySoundCollection() { - if(StorageSoundCollection.TryGetSound(out var sound)) + // TODO this doesn't compile or work + if(StorageSoundCollection?.TryGetSound(out var sound)) SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default); } } From 57016d14b4310b5b48a53681c199c1f3353ade76 Mon Sep 17 00:00:00 2001 From: Galactic Chimp Date: Sat, 31 Jul 2021 19:52:33 +0200 Subject: [PATCH 12/18] removed TryGetSound + made some SoundSpecifier datafields required --- .../Visualizers/DisposalUnitVisualizer.cs | 5 +- Content.Client/Doors/AirlockVisualizer.cs | 15 +- .../Visualizers/PoweredLightVisualizer.cs | 19 +-- Content.Client/PDA/PDAComponent.cs | 8 +- .../Trigger/TimerTriggerVisualizer.cs | 11 +- .../AME/Components/AMEControllerComponent.cs | 20 ++- .../AME/Components/AMEPartComponent.cs | 3 +- .../Actions/Actions/DisarmAction.cs | 10 +- .../Actions/Actions/ScreamAction.cs | 16 +- .../Actions/Spells/GiveItemSpell.cs | 5 +- .../Components/SpaceVillainArcadeComponent.cs | 66 ++++---- .../Atmos/Components/GasTankComponent.cs | 3 +- Content.Server/Body/BodyComponent.cs | 3 +- .../Botany/Components/PlantHolderComponent.cs | 5 +- .../Buckle/Components/BuckleComponent.cs | 22 +-- .../Cabinet/ItemCabinetComponent.cs | 2 +- Content.Server/Cabinet/ItemCabinetSystem.cs | 7 +- .../Cargo/Components/CargoConsoleComponent.cs | 9 +- .../Cargo/Components/CargoTelepadComponent.cs | 3 +- .../Components/ChemMasterComponent.cs | 3 +- .../Components/HyposprayComponent.cs | 3 +- .../Chemistry/Components/PillComponent.cs | 7 +- .../Components/ReagentDispenserComponent.cs | 6 +- .../EntitySystems/ChemicalReactionSystem.cs | 3 +- .../ReactionEffects/AreaReactionEffect.cs | 7 +- .../Construction/Completions/PlaySound.cs | 5 +- Content.Server/Crayon/CrayonComponent.cs | 7 +- .../Cuffs/Components/CuffableComponent.cs | 13 +- .../Cuffs/Components/HandcuffComponent.cs | 6 +- .../DamageOnHighSpeedImpactComponent.cs | 2 +- .../Damage/DamageOnHighSpeedImpactSystem.cs | 3 +- .../Thresholds/Behaviors/PlaySoundBehavior.cs | 9 +- Content.Server/Dice/DiceComponent.cs | 3 +- .../Mailing/DisposalMailingUnitComponent.cs | 3 +- .../Components/DisposalRouterComponent.cs | 5 +- .../Components/DisposalTaggerComponent.cs | 3 +- .../Tube/Components/DisposalTubeComponent.cs | 3 +- .../Unit/Components/DisposalUnitComponent.cs | 3 +- .../Doors/Components/AirlockComponent.cs | 8 +- .../Doors/Components/ServerDoorComponent.cs | 5 +- .../Components/SoundOnTriggerComponent.cs | 2 +- Content.Server/Explosion/ExplosionHelper.cs | 3 +- .../Extinguisher/FireExtinguisherComponent.cs | 3 +- .../Flash/Components/FlashableComponent.cs | 4 +- Content.Server/Flash/FlashSystem.cs | 3 +- .../Fluids/Components/BucketComponent.cs | 5 +- .../Fluids/Components/MopComponent.cs | 5 +- .../Fluids/Components/PuddleComponent.cs | 3 +- .../Fluids/Components/SprayComponent.cs | 8 +- .../GameTicking/Rules/RuleSuspicion.cs | 7 +- .../GameTicking/Rules/RuleTraitor.cs | 3 +- .../Gravity/EntitySystems/GravitySystem.cs | 3 +- .../Hands/Components/HandsComponent.cs | 3 +- .../Components/KitchenSpikeComponent.cs | 3 +- .../Kitchen/Components/MicrowaveComponent.cs | 91 +++++------ .../Components/ReagentGrinderComponent.cs | 6 +- .../EntitySystems/ReagentGrinderSystem.cs | 8 +- .../Components/ExpendableLightComponent.cs | 13 +- .../Components/HandheldLightComponent.cs | 13 +- .../Light/Components/LightBulbComponent.cs | 9 +- .../Light/Components/MatchstickComponent.cs | 13 +- .../Light/Components/PoweredLightComponent.cs | 19 +-- Content.Server/Lock/LockComponent.cs | 4 +- .../Components/AsteroidRockComponent.cs | 5 +- .../CrematoriumEntityStorageComponent.cs | 3 +- .../MorgueEntityStorageComponent.cs | 5 +- .../Components/FootstepModifierComponent.cs | 7 +- .../Nutrition/Components/CreamPieComponent.cs | 3 +- .../Nutrition/Components/DrinkComponent.cs | 23 ++- .../Nutrition/Components/FoodComponent.cs | 9 +- .../Components/SliceableFoodComponent.cs | 14 +- .../Nutrition/Components/UtensilComponent.cs | 4 +- Content.Server/PDA/PDAComponent.cs | 81 +++++----- .../Physics/Controllers/MoverController.cs | 12 +- .../Components/PottedPlantHideComponent.cs | 3 +- .../Components/RoguePointingArrowComponent.cs | 3 +- .../Power/Components/ApcComponent.cs | 5 +- .../Components/PowerCellSlotComponent.cs | 8 +- .../Components/HitscanComponent.cs | 3 +- .../Components/ProjectileComponent.cs | 4 +- .../Projectiles/ProjectileSystem.cs | 9 +- Content.Server/RCD/Components/RCDComponent.cs | 10 +- .../Radiation/RadiationPulseComponent.cs | 5 +- .../Components/ResearchConsoleComponent.cs | 3 +- .../Components/ServerSingularityComponent.cs | 8 +- Content.Server/Slippery/SlipperySystem.cs | 5 +- .../Components/BaseEmitSoundComponent.cs | 2 +- Content.Server/Sound/EmitSoundSystem.cs | 10 +- .../CursedEntityStorageComponent.cs | 10 +- .../Components/EntityStorageComponent.cs | 6 +- .../Components/ServerStorageComponent.cs | 150 +++++++++--------- .../Components/SpawnItemsOnUseComponent.cs | 4 +- .../Components/StunnableComponent.cs | 12 +- Content.Server/Stunnable/StunbatonSystem.cs | 24 ++- .../Tiles/FloorTileItemComponent.cs | 5 +- Content.Server/Toilet/ToiletComponent.cs | 3 +- .../Tools/Components/MultitoolComponent.cs | 7 +- .../Tools/Components/ToolComponent.cs | 5 +- .../Tools/Components/WelderComponent.cs | 22 ++- .../VendingMachineComponent.cs | 6 +- .../Weapon/Melee/MeleeWeaponSystem.cs | 16 +- .../Components/BoltActionBarrelComponent.cs | 29 +--- .../Barrels/Components/PumpBarrelComponent.cs | 14 +- .../Components/RevolverBarrelComponent.cs | 15 +- .../ServerBatteryBarrelComponent.cs | 14 +- .../ServerMagazineBarrelComponent.cs | 56 ++----- .../Components/ServerRangedBarrelComponent.cs | 20 +-- .../Ranged/ServerRangedWeaponComponent.cs | 15 +- Content.Server/Window/WindowComponent.cs | 19 +-- Content.Server/WireHacking/WiresComponent.cs | 13 +- .../SharedExpendableLightComponent.cs | 4 +- Content.Shared/Maps/ContentTileDefinition.cs | 2 +- Content.Shared/Sound/SoundSpecifier.cs | 15 -- .../Standing/StandingStateSystem.cs | 4 +- 114 files changed, 519 insertions(+), 785 deletions(-) diff --git a/Content.Client/Disposal/Visualizers/DisposalUnitVisualizer.cs b/Content.Client/Disposal/Visualizers/DisposalUnitVisualizer.cs index df9b94be07..264dfd64cb 100644 --- a/Content.Client/Disposal/Visualizers/DisposalUnitVisualizer.cs +++ b/Content.Client/Disposal/Visualizers/DisposalUnitVisualizer.cs @@ -59,10 +59,7 @@ namespace Content.Client.Disposal.Visualizers var sound = new AnimationTrackPlaySound(); _flushAnimation.AnimationTracks.Add(sound); - if (_flushSound.TryGetSound(out var flushSound)) - { - sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(flushSound, 0)); - } + sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(_flushSound.GetSound(), 0)); } private void ChangeState(AppearanceComponent appearance) diff --git a/Content.Client/Doors/AirlockVisualizer.cs b/Content.Client/Doors/AirlockVisualizer.cs index 4f5a745e01..ef05e75125 100644 --- a/Content.Client/Doors/AirlockVisualizer.cs +++ b/Content.Client/Doors/AirlockVisualizer.cs @@ -55,10 +55,7 @@ namespace Content.Client.Doors var sound = new AnimationTrackPlaySound(); CloseAnimation.AnimationTracks.Add(sound); - if (_closeSound.TryGetSound(out var closeSound)) - { - sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(closeSound, 0)); - } + sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(_closeSound.GetSound(), 0)); } OpenAnimation = new Animation {Length = TimeSpan.FromSeconds(_delay)}; @@ -81,10 +78,7 @@ namespace Content.Client.Doors var sound = new AnimationTrackPlaySound(); OpenAnimation.AnimationTracks.Add(sound); - if (_openSound.TryGetSound(out var openSound)) - { - sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(openSound, 0)); - } + sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(_openSound.GetSound(), 0)); } DenyAnimation = new Animation {Length = TimeSpan.FromSeconds(0.3f)}; @@ -97,10 +91,7 @@ namespace Content.Client.Doors var sound = new AnimationTrackPlaySound(); DenyAnimation.AnimationTracks.Add(sound); - if (_denySound.TryGetSound(out var denySound)) - { - sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(denySound, 0, () => AudioHelpers.WithVariation(0.05f))); - } + sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(_denySound.GetSound(), 0, () => AudioHelpers.WithVariation(0.05f))); } } diff --git a/Content.Client/Light/Visualizers/PoweredLightVisualizer.cs b/Content.Client/Light/Visualizers/PoweredLightVisualizer.cs index 4d629dcd67..368e465c74 100644 --- a/Content.Client/Light/Visualizers/PoweredLightVisualizer.cs +++ b/Content.Client/Light/Visualizers/PoweredLightVisualizer.cs @@ -18,7 +18,7 @@ namespace Content.Client.Light.Visualizers { [DataField("minBlinkingTime")] private float _minBlinkingTime = 0.5f; [DataField("maxBlinkingTime")] private float _maxBlinkingTime = 2; - [DataField("blinkingSound")] private SoundSpecifier _blinkingSound = default!; + [DataField("blinkingSound", required: true)] private SoundSpecifier _blinkingSound = default!; private bool _wasBlinking; @@ -97,7 +97,7 @@ namespace Content.Client.Light.Visualizers var randomTime = random.NextFloat() * (_maxBlinkingTime - _minBlinkingTime) + _minBlinkingTime; - var blinkingAnim = new Animation() + var blinkingAnim = new Animation() { Length = TimeSpan.FromSeconds(randomTime), AnimationTracks = @@ -123,18 +123,15 @@ namespace Content.Client.Light.Visualizers } } } - }; + }; - if (_blinkingSound.TryGetSound(out var blinkingSound)) + blinkingAnim.AnimationTracks.Add(new AnimationTrackPlaySound() { - blinkingAnim.AnimationTracks.Add(new AnimationTrackPlaySound() + KeyFrames = { - KeyFrames = - { - new AnimationTrackPlaySound.KeyFrame(blinkingSound, 0.5f) - } - }); - } + new AnimationTrackPlaySound.KeyFrame(_blinkingSound.GetSound(), 0.5f) + } + }); return blinkingAnim; } diff --git a/Content.Client/PDA/PDAComponent.cs b/Content.Client/PDA/PDAComponent.cs index 7538b70906..353e9675a5 100644 --- a/Content.Client/PDA/PDAComponent.cs +++ b/Content.Client/PDA/PDAComponent.cs @@ -24,16 +24,14 @@ namespace Content.Client.PDA public override void HandleNetworkMessage(ComponentMessage message, INetChannel netChannel, ICommonSession? session = null) { base.HandleNetworkMessage(message, netChannel, session); - switch(message) + switch (message) { case PDAUplinkBuySuccessMessage: - if(BuySuccessSound.TryGetSound(out var buySuccessSound)) - SoundSystem.Play(Filter.Local(), buySuccessSound, Owner, AudioParams.Default.WithVolume(-2f)); + SoundSystem.Play(Filter.Local(), BuySuccessSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f)); break; case PDAUplinkInsufficientFundsMessage: - if(InsufficientFundsSound.TryGetSound(out var insufficientFundsSound)) - SoundSystem.Play(Filter.Local(), insufficientFundsSound, Owner, AudioParams.Default); + SoundSystem.Play(Filter.Local(), InsufficientFundsSound.GetSound(), Owner, AudioParams.Default); break; } } diff --git a/Content.Client/Trigger/TimerTriggerVisualizer.cs b/Content.Client/Trigger/TimerTriggerVisualizer.cs index 246a4c181a..c712c88c3c 100644 --- a/Content.Client/Trigger/TimerTriggerVisualizer.cs +++ b/Content.Client/Trigger/TimerTriggerVisualizer.cs @@ -15,7 +15,7 @@ namespace Content.Client.Trigger { private const string AnimationKey = "priming_animation"; - [DataField("countdown_sound", required: true)] + [DataField("countdown_sound")] private SoundSpecifier _countdownSound = default!; private Animation PrimingAnimation = default!; @@ -29,12 +29,9 @@ namespace Content.Client.Trigger flick.LayerKey = TriggerVisualLayers.Base; flick.KeyFrames.Add(new AnimationTrackSpriteFlick.KeyFrame("primed", 0f)); - if (_countdownSound.TryGetSound(out var countdownSound)) - { - var sound = new AnimationTrackPlaySound(); - PrimingAnimation.AnimationTracks.Add(sound); - sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(countdownSound, 0)); - } + var sound = new AnimationTrackPlaySound(); + PrimingAnimation.AnimationTracks.Add(sound); + sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(_countdownSound.GetSound(), 0)); } } diff --git a/Content.Server/AME/Components/AMEControllerComponent.cs b/Content.Server/AME/Components/AMEControllerComponent.cs index 785431be0e..f25c93b023 100644 --- a/Content.Server/AME/Components/AMEControllerComponent.cs +++ b/Content.Server/AME/Components/AMEControllerComponent.cs @@ -75,7 +75,7 @@ namespace Content.Server.AME.Components internal void OnUpdate(float frameTime) { - if(!_injecting) + if (!_injecting) { return; } @@ -88,11 +88,11 @@ namespace Content.Server.AME.Components } var jar = _jarSlot.ContainedEntity; - if(jar is null) + if (jar is null) return; jar.TryGetComponent(out var fuelJar); - if(fuelJar != null && _powerSupplier != null) + if (fuelJar != null && _powerSupplier != null) { var availableInject = fuelJar.FuelAmount >= InjectionAmount ? InjectionAmount : fuelJar.FuelAmount; _powerSupplier.MaxSupply = group.InjectFuel(availableInject, out var overloading); @@ -105,7 +105,7 @@ namespace Content.Server.AME.Components UpdateDisplay(_stability); - if(_stability <= 0) { group.ExplodeCores(); } + if (_stability <= 0) { group.ExplodeCores(); } } @@ -229,7 +229,7 @@ namespace Content.Server.AME.Components return; var jar = _jarSlot.ContainedEntity; - if(jar is null) + if (jar is null) return; _jarSlot.Remove(jar); @@ -262,7 +262,7 @@ namespace Content.Server.AME.Components private void UpdateDisplay(int stability) { - if(_appearance == null) { return; } + if (_appearance == null) { return; } _appearance.TryGetData(AMEControllerVisuals.DisplayState, out var state); @@ -291,7 +291,7 @@ namespace Content.Server.AME.Components private bool IsMasterController() { - if(GetAMENodeGroup()?.MasterController == this) + if (GetAMENodeGroup()?.MasterController == this) { return true; } @@ -315,14 +315,12 @@ namespace Content.Server.AME.Components private void ClickSound() { - if(_clickSound.TryGetSound(out var clickSound)) - SoundSystem.Play(Filter.Pvs(Owner), clickSound, Owner, AudioParams.Default.WithVolume(-2f)); + SoundSystem.Play(Filter.Pvs(Owner), _clickSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f)); } private void InjectSound(bool overloading) { - if(_injectSound.TryGetSound(out var injectSound)) - SoundSystem.Play(Filter.Pvs(Owner), injectSound, Owner, AudioParams.Default.WithVolume(overloading ? 10f : 0f)); + SoundSystem.Play(Filter.Pvs(Owner), _injectSound.GetSound(), Owner, AudioParams.Default.WithVolume(overloading ? 10f : 0f)); } async Task IInteractUsing.InteractUsing(InteractUsingEventArgs args) diff --git a/Content.Server/AME/Components/AMEPartComponent.cs b/Content.Server/AME/Components/AMEPartComponent.cs index 8dacbf8763..d7971c0f00 100644 --- a/Content.Server/AME/Components/AMEPartComponent.cs +++ b/Content.Server/AME/Components/AMEPartComponent.cs @@ -51,8 +51,7 @@ namespace Content.Server.AME.Components var ent = _serverEntityManager.SpawnEntity("AMEShielding", mapGrid.GridTileToLocal(snapPos)); ent.Transform.LocalRotation = Owner.Transform.LocalRotation; - if(_unwrapSound.TryGetSound(out var unwrapSound)) - SoundSystem.Play(Filter.Pvs(Owner), unwrapSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), _unwrapSound.GetSound(), Owner); Owner.Delete(); diff --git a/Content.Server/Actions/Actions/DisarmAction.cs b/Content.Server/Actions/Actions/DisarmAction.cs index 2af0fe9a88..a9d1074f22 100644 --- a/Content.Server/Actions/Actions/DisarmAction.cs +++ b/Content.Server/Actions/Actions/DisarmAction.cs @@ -78,8 +78,7 @@ namespace Content.Server.Actions.Actions if (random.Prob(_failProb)) { - if(PunchMissSound.TryGetSound(out var punchMissSound)) - SoundSystem.Play(Filter.Pvs(args.Performer), punchMissSound, args.Performer, AudioHelpers.WithVariation(0.025f)); + SoundSystem.Play(Filter.Pvs(args.Performer), PunchMissSound.GetSound(), args.Performer, AudioHelpers.WithVariation(0.025f)); args.Performer.PopupMessageOtherClients(Loc.GetString("disarm-action-popup-message-other-clients", ("performerName", args.Performer.Name), @@ -90,9 +89,9 @@ namespace Content.Server.Actions.Actions return; } - system.SendAnimation("disarm", angle, args.Performer, args.Performer, new []{ args.Target }); + system.SendAnimation("disarm", angle, args.Performer, args.Performer, new[] { args.Target }); - var eventArgs = new DisarmedActEventArgs() {Target = args.Target, Source = args.Performer, PushProbability = _pushProb}; + var eventArgs = new DisarmedActEventArgs() { Target = args.Target, Source = args.Performer, PushProbability = _pushProb }; // Sort by priority. Array.Sort(disarmedActs, (a, b) => a.Priority.CompareTo(b.Priority)); @@ -103,8 +102,7 @@ namespace Content.Server.Actions.Actions return; } - if(DisarmSuccessSound.TryGetSound(out var disarmSuccessSound)) - SoundSystem.Play(Filter.Pvs(args.Performer), disarmSuccessSound, args.Performer.Transform.Coordinates, AudioHelpers.WithVariation(0.025f)); + SoundSystem.Play(Filter.Pvs(args.Performer), DisarmSuccessSound.GetSound(), args.Performer.Transform.Coordinates, AudioHelpers.WithVariation(0.025f)); } } } diff --git a/Content.Server/Actions/Actions/ScreamAction.cs b/Content.Server/Actions/Actions/ScreamAction.cs index a98c5d3599..c07f3b5858 100644 --- a/Content.Server/Actions/Actions/ScreamAction.cs +++ b/Content.Server/Actions/Actions/ScreamAction.cs @@ -26,9 +26,9 @@ namespace Content.Server.Actions.Actions [Dependency] private readonly IRobustRandom _random = default!; - [DataField("male")] private SoundSpecifier _male = default!; - [DataField("female")] private SoundSpecifier _female = default!; - [DataField("wilhelm")] private SoundSpecifier _wilhelm = default!; + [DataField("male", required: true)] private SoundSpecifier _male = default!; + [DataField("female", required: true)] private SoundSpecifier _female = default!; + [DataField("wilhelm", required: true)] private SoundSpecifier _wilhelm = default!; /// seconds [DataField("cooldown")] private float _cooldown = 10; @@ -44,21 +44,19 @@ namespace Content.Server.Actions.Actions if (!args.Performer.TryGetComponent(out var humanoid)) return; if (!args.Performer.TryGetComponent(out var actions)) return; - if (_random.Prob(.01f) && _wilhelm.TryGetSound(out var wilhelm)) + if (_random.Prob(.01f)) { - SoundSystem.Play(Filter.Pvs(args.Performer), wilhelm, args.Performer, AudioParams.Default.WithVolume(Volume)); + SoundSystem.Play(Filter.Pvs(args.Performer), _wilhelm.GetSound(), args.Performer, AudioParams.Default.WithVolume(Volume)); } else { switch (humanoid.Sex) { case Sex.Male: - if (_male.TryGetSound(out var male)) - SoundSystem.Play(Filter.Pvs(args.Performer), male, args.Performer, AudioHelpers.WithVariation(Variation).WithVolume(Volume)); + SoundSystem.Play(Filter.Pvs(args.Performer), _male.GetSound(), args.Performer, AudioHelpers.WithVariation(Variation).WithVolume(Volume)); break; case Sex.Female: - if (_female.TryGetSound(out var female)) - SoundSystem.Play(Filter.Pvs(args.Performer), female, args.Performer, AudioHelpers.WithVariation(Variation).WithVolume(Volume)); + SoundSystem.Play(Filter.Pvs(args.Performer), _female.GetSound(), args.Performer, AudioHelpers.WithVariation(Variation).WithVolume(Volume)); break; default: throw new ArgumentOutOfRangeException(); diff --git a/Content.Server/Actions/Spells/GiveItemSpell.cs b/Content.Server/Actions/Spells/GiveItemSpell.cs index 01d4826fde..f5151c4ae0 100644 --- a/Content.Server/Actions/Spells/GiveItemSpell.cs +++ b/Content.Server/Actions/Spells/GiveItemSpell.cs @@ -28,7 +28,7 @@ namespace Content.Server.Actions.Spells [ViewVariables] [DataField("cooldown")] public float CoolDown { get; set; } = 1f; [ViewVariables] [DataField("spellItem")] public string ItemProto { get; set; } = default!; - [ViewVariables] [DataField("castSound")] public SoundSpecifier CastSound { get; set; } = default!; + [ViewVariables] [DataField("castSound", required: true)] public SoundSpecifier CastSound { get; set; } = default!; //Rubber-band snapping items into player's hands, originally was a workaround, later found it works quite well with stuns //Not sure if needs fixing @@ -69,8 +69,7 @@ namespace Content.Server.Actions.Spells handsComponent.PutInHandOrDrop(itemComponent); - if (CastSound.TryGetSound(out var castSound)) - SoundSystem.Play(Filter.Pvs(caster), castSound, caster); + SoundSystem.Play(Filter.Pvs(caster), CastSound.GetSound(), caster); } } } diff --git a/Content.Server/Arcade/Components/SpaceVillainArcadeComponent.cs b/Content.Server/Arcade/Components/SpaceVillainArcadeComponent.cs index 01e97629cc..a9018095fb 100644 --- a/Content.Server/Arcade/Components/SpaceVillainArcadeComponent.cs +++ b/Content.Server/Arcade/Components/SpaceVillainArcadeComponent.cs @@ -45,18 +45,26 @@ namespace Content.Server.Arcade.Components [DataField("winSound")] private SoundSpecifier _winSound = new SoundPathSpecifier("/Audio/Effects/Arcade/win.ogg"); [DataField("gameOverSound")] private SoundSpecifier _gameOverSound = new SoundPathSpecifier("/Audio/Effects/Arcade/gameover.ogg"); - [ViewVariables(VVAccess.ReadWrite)] [DataField("possibleFightVerbs")] private List _possibleFightVerbs = new List() + [ViewVariables(VVAccess.ReadWrite)] + [DataField("possibleFightVerbs")] + private List _possibleFightVerbs = new List() {"Defeat", "Annihilate", "Save", "Strike", "Stop", "Destroy", "Robust", "Romance", "Pwn", "Own"}; - [ViewVariables(VVAccess.ReadWrite)] [DataField("possibleFirstEnemyNames")] private List _possibleFirstEnemyNames = new List(){ + [ViewVariables(VVAccess.ReadWrite)] + [DataField("possibleFirstEnemyNames")] + private List _possibleFirstEnemyNames = new List(){ "the Automatic", "Farmer", "Lord", "Professor", "the Cuban", "the Evil", "the Dread King", "the Space", "Lord", "the Great", "Duke", "General" }; - [ViewVariables(VVAccess.ReadWrite)] [DataField("possibleLastEnemyNames")] private List _possibleLastEnemyNames = new List() + [ViewVariables(VVAccess.ReadWrite)] + [DataField("possibleLastEnemyNames")] + private List _possibleLastEnemyNames = new List() { "Melonoid", "Murdertron", "Sorcerer", "Ruin", "Jeff", "Ectoplasm", "Crushulon", "Uhangoid", "Vhakoid", "Peteoid", "slime", "Griefer", "ERPer", "Lizard Man", "Unicorn" }; - [ViewVariables(VVAccess.ReadWrite)] [DataField("possibleRewards")] private List _possibleRewards = new List() + [ViewVariables(VVAccess.ReadWrite)] + [DataField("possibleRewards")] + private List _possibleRewards = new List() { "ToyMouse", "ToyAi", "ToyNuke", "ToyAssistant", "ToyGriffin", "ToyHonk", "ToyIan", "ToyMarauder", "ToyMauler", "ToyGygax", "ToyOdysseus", "ToyOwlman", "ToyDeathRipley", @@ -65,10 +73,10 @@ namespace Content.Server.Arcade.Components void IActivate.Activate(ActivateEventArgs eventArgs) { - if(!Powered || !eventArgs.User.TryGetComponent(out ActorComponent? actor)) + if (!Powered || !eventArgs.User.TryGetComponent(out ActorComponent? actor)) return; - if(!EntitySystem.Get().CanInteract(eventArgs.User)) + if (!EntitySystem.Get().CanInteract(eventArgs.User)) return; _game ??= new SpaceVillainGame(this); @@ -76,7 +84,8 @@ namespace Content.Server.Arcade.Components if (_wiresComponent?.IsPanelOpen == true) { _wiresComponent.OpenInterface(actor.PlayerSession); - } else + } + else { UserInterface?.Toggle(actor.PlayerSession); } @@ -105,7 +114,7 @@ namespace Content.Server.Arcade.Components private void OnOnPowerStateChanged(PowerChangedMessage e) { - if(e.Powered) return; + if (e.Powered) return; UserInterface?.CloseAll(); } @@ -130,8 +139,7 @@ namespace Content.Server.Arcade.Components _game?.ExecutePlayerAction(msg.PlayerAction); break; case PlayerAction.NewGame: - if(_newGameSound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default.WithVolume(-4f)); + SoundSystem.Play(Filter.Pvs(Owner), _newGameSound.GetSound(), Owner, AudioParams.Default.WithVolume(-4f)); _game = new SpaceVillainGame(this); UserInterface?.SendMessage(_game.GenerateMetaDataMessage()); @@ -260,7 +268,7 @@ namespace Content.Server.Arcade.Components private string _latestPlayerActionMessage = ""; private string _latestEnemyActionMessage = ""; - public SpaceVillainGame(SpaceVillainArcadeComponent owner) : this(owner, owner.GenerateFightVerb(), owner.GenerateEnemyName()){} + public SpaceVillainGame(SpaceVillainArcadeComponent owner) : this(owner, owner.GenerateFightVerb(), owner.GenerateEnemyName()) { } public SpaceVillainGame(SpaceVillainArcadeComponent owner, string fightVerb, string enemyName) { @@ -277,7 +285,7 @@ namespace Content.Server.Arcade.Components /// private void ValidateVars() { - if(_owner._overflowFlag) return; + if (_owner._overflowFlag) return; if (_playerHp > _playerHpMax) _playerHp = _playerHpMax; if (_playerMp > _playerMpMax) _playerMp = _playerMpMax; @@ -300,9 +308,8 @@ namespace Content.Server.Arcade.Components _latestPlayerActionMessage = Loc.GetString("space-villain-game-player-attack-message", ("enemyName", _enemyName), ("attackAmount", attackAmount)); - if(_owner._playerAttackSound.TryGetSound(out var playerAttackSound)) - SoundSystem.Play(Filter.Pvs(_owner.Owner), playerAttackSound, _owner.Owner, AudioParams.Default.WithVolume(-4f)); - if(!_owner._enemyInvincibilityFlag) + SoundSystem.Play(Filter.Pvs(_owner.Owner), _owner._playerAttackSound.GetSound(), _owner.Owner, AudioParams.Default.WithVolume(-4f)); + if (!_owner._enemyInvincibilityFlag) _enemyHp -= attackAmount; _turtleTracker -= _turtleTracker > 0 ? 1 : 0; break; @@ -312,18 +319,16 @@ namespace Content.Server.Arcade.Components _latestPlayerActionMessage = Loc.GetString("space-villain-game-player-heal-message", ("magicPointAmount", pointAmount), ("healAmount", healAmount)); - if(_owner._playerHealSound.TryGetSound(out var playerHealSound)) - SoundSystem.Play(Filter.Pvs(_owner.Owner), playerHealSound, _owner.Owner, AudioParams.Default.WithVolume(-4f)); - if(!_owner._playerInvincibilityFlag) + SoundSystem.Play(Filter.Pvs(_owner.Owner), _owner._playerHealSound.GetSound(), _owner.Owner, AudioParams.Default.WithVolume(-4f)); + if (!_owner._playerInvincibilityFlag) _playerMp -= pointAmount; _playerHp += healAmount; _turtleTracker++; break; case PlayerAction.Recharge: var chargeAmount = _random.Next(4, 7); - _latestPlayerActionMessage = Loc.GetString("space-villain-game-player-recharge-message",("regainedPoints", chargeAmount)); - if(_owner._playerChargeSound.TryGetSound(out var playerChargeSound)) - SoundSystem.Play(Filter.Pvs(_owner.Owner), playerChargeSound, _owner.Owner, AudioParams.Default.WithVolume(-4f)); + _latestPlayerActionMessage = Loc.GetString("space-villain-game-player-recharge-message", ("regainedPoints", chargeAmount)); + SoundSystem.Play(Filter.Pvs(_owner.Owner), _owner._playerChargeSound.GetSound(), _owner.Owner, AudioParams.Default.WithVolume(-4f)); _playerMp += chargeAmount; _turtleTracker -= _turtleTracker > 0 ? 1 : 0; break; @@ -355,10 +360,9 @@ namespace Content.Server.Arcade.Components { _running = false; UpdateUi(Loc.GetString("space-villain-game-player-wins-message"), - Loc.GetString("space-villain-game-enemy-dies-message",("enemyName", _enemyName)), + Loc.GetString("space-villain-game-enemy-dies-message", ("enemyName", _enemyName)), true); - if(_owner._winSound.TryGetSound(out var winSound)) - SoundSystem.Play(Filter.Pvs(_owner.Owner), winSound, _owner.Owner, AudioParams.Default.WithVolume(-4f)); + SoundSystem.Play(Filter.Pvs(_owner.Owner), _owner._winSound.GetSound(), _owner.Owner, AudioParams.Default.WithVolume(-4f)); _owner.ProcessWin(); return false; } @@ -369,10 +373,9 @@ namespace Content.Server.Arcade.Components { _running = false; UpdateUi(Loc.GetString("space-villain-game-player-loses-message"), - Loc.GetString("space-villain-game-enemy-cheers-message",("enemyName", _enemyName)), + Loc.GetString("space-villain-game-enemy-cheers-message", ("enemyName", _enemyName)), true); - if(_owner._gameOverSound.TryGetSound(out var gameOverSound)) - SoundSystem.Play(Filter.Pvs(_owner.Owner), gameOverSound, _owner.Owner, AudioParams.Default.WithVolume(-4f)); + SoundSystem.Play(Filter.Pvs(_owner.Owner), _owner._gameOverSound.GetSound(), _owner.Owner, AudioParams.Default.WithVolume(-4f)); return false; } if (_enemyHp <= 0 || _enemyMp <= 0) @@ -381,8 +384,7 @@ namespace Content.Server.Arcade.Components UpdateUi(Loc.GetString("space-villain-game-player-loses-message"), Loc.GetString("space-villain-game-enemy-dies-with-player-message ", ("enemyName", _enemyName)), true); - if (_owner._gameOverSound.TryGetSound(out var gameOverSound)) - SoundSystem.Play(Filter.Pvs(_owner.Owner), gameOverSound, _owner.Owner, AudioParams.Default.WithVolume(-4f)); + SoundSystem.Play(Filter.Pvs(_owner.Owner), _owner._gameOverSound.GetSound(), _owner.Owner, AudioParams.Default.WithVolume(-4f)); return false; } @@ -419,7 +421,8 @@ namespace Content.Server.Arcade.Components if (_owner._playerInvincibilityFlag) return; _playerHp -= boomAmount; _turtleTracker--; - }else if (_enemyMp <= 5 && _random.Prob(0.7f)) + } + else if (_enemyMp <= 5 && _random.Prob(0.7f)) { var stealAmount = _random.Next(2, 3); _latestEnemyActionMessage = Loc.GetString("space-villain-game-enemy-steals-player-power-message", @@ -428,7 +431,8 @@ namespace Content.Server.Arcade.Components if (_owner._playerInvincibilityFlag) return; _playerMp -= stealAmount; _enemyMp += stealAmount; - }else if (_enemyHp <= 10 && _enemyMp > 4) + } + else if (_enemyHp <= 10 && _enemyMp > 4) { _enemyHp += 4; _enemyMp -= 4; diff --git a/Content.Server/Atmos/Components/GasTankComponent.cs b/Content.Server/Atmos/Components/GasTankComponent.cs index cf341e3c01..bd1f2ac7b9 100644 --- a/Content.Server/Atmos/Components/GasTankComponent.cs +++ b/Content.Server/Atmos/Components/GasTankComponent.cs @@ -284,8 +284,7 @@ namespace Content.Server.Atmos.Components if(environment != null) atmosphereSystem.Merge(environment, Air); - if(_ruptureSound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.125f)); + SoundSystem.Play(Filter.Pvs(Owner), _ruptureSound.GetSound(), Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.125f)); Owner.QueueDelete(); return; diff --git a/Content.Server/Body/BodyComponent.cs b/Content.Server/Body/BodyComponent.cs index 87d14a05c3..d1940ff73a 100644 --- a/Content.Server/Body/BodyComponent.cs +++ b/Content.Server/Body/BodyComponent.cs @@ -104,8 +104,7 @@ namespace Content.Server.Body { base.Gib(gibParts); - if(_gibSound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.025f)); + SoundSystem.Play(Filter.Pvs(Owner), _gibSound.GetSound(), Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.025f)); if (Owner.TryGetComponent(out ContainerManagerComponent? container)) { diff --git a/Content.Server/Botany/Components/PlantHolderComponent.cs b/Content.Server/Botany/Components/PlantHolderComponent.cs index 3ee1a289ad..9b43f34f59 100644 --- a/Content.Server/Botany/Components/PlantHolderComponent.cs +++ b/Content.Server/Botany/Components/PlantHolderComponent.cs @@ -723,10 +723,7 @@ namespace Content.Server.Botany.Components sprayed = true; amount = ReagentUnit.New(1); - if (spray.SpraySound.TryGetSound(out var spraySound)) - { - SoundSystem.Play(Filter.Pvs(usingItem), spraySound, usingItem, AudioHelpers.WithVariation(0.125f)); - } + SoundSystem.Play(Filter.Pvs(usingItem), spray.SpraySound.GetSound(), usingItem, AudioHelpers.WithVariation(0.125f)); } var split = solution.Drain(amount); diff --git a/Content.Server/Buckle/Components/BuckleComponent.cs b/Content.Server/Buckle/Components/BuckleComponent.cs index a3c4c705c0..2232045831 100644 --- a/Content.Server/Buckle/Components/BuckleComponent.cs +++ b/Content.Server/Buckle/Components/BuckleComponent.cs @@ -50,7 +50,7 @@ namespace Content.Server.Buckle.Components /// [DataField("delay")] [ViewVariables] - private TimeSpan _unbuckleDelay = TimeSpan.FromSeconds(0.25f); + private TimeSpan _unbuckleDelay = TimeSpan.FromSeconds(0.25f); /// /// The time that this entity buckled at. @@ -199,7 +199,7 @@ namespace Content.Server.Buckle.Components { var message = Loc.GetString(Owner == user ? "buckle-component-already-buckled-message" - : "buckle-component-other-already-buckled-message",("owner", Owner)); + : "buckle-component-other-already-buckled-message", ("owner", Owner)); Owner.PopupMessage(user, message); return false; @@ -212,7 +212,7 @@ namespace Content.Server.Buckle.Components { var message = Loc.GetString(Owner == user ? "buckle-component-cannot-buckle-message" - : "buckle-component-other-cannot-buckle-message",("owner", Owner)); + : "buckle-component-other-cannot-buckle-message", ("owner", Owner)); Owner.PopupMessage(user, message); return false; @@ -225,7 +225,7 @@ namespace Content.Server.Buckle.Components { var message = Loc.GetString(Owner == user ? "buckle-component-cannot-fit-message" - : "buckle-component-other-cannot-fit-message",("owner", Owner)); + : "buckle-component-other-cannot-fit-message", ("owner", Owner)); Owner.PopupMessage(user, message); return false; @@ -241,16 +241,13 @@ namespace Content.Server.Buckle.Components return false; } - if(strap.BuckleSound.TryGetSound(out var buckleSound)) - { - SoundSystem.Play(Filter.Pvs(Owner), buckleSound, Owner); - } + SoundSystem.Play(Filter.Pvs(Owner), strap.BuckleSound.GetSound(), Owner); if (!strap.TryAdd(this)) { var message = Loc.GetString(Owner == user ? "buckle-component-cannot-buckle-message" - : "buckle-component-other-cannot-buckle-message",("owner", Owner)); + : "buckle-component-other-cannot-buckle-message", ("owner", Owner)); Owner.PopupMessage(user, message); return false; } @@ -352,11 +349,8 @@ namespace Content.Server.Buckle.Components UpdateBuckleStatus(); oldBuckledTo.Remove(this); - if (oldBuckledTo.UnbuckleSound.TryGetSound(out var unbuckleSound)) - { - SoundSystem.Play(Filter.Pvs(Owner), unbuckleSound, Owner); - } - + SoundSystem.Play(Filter.Pvs(Owner), oldBuckledTo.UnbuckleSound.GetSound(), Owner); + SendMessage(new UnbuckleMessage(Owner, oldBuckledTo.Owner)); return true; diff --git a/Content.Server/Cabinet/ItemCabinetComponent.cs b/Content.Server/Cabinet/ItemCabinetComponent.cs index dd72e2d3d5..89eb94363b 100644 --- a/Content.Server/Cabinet/ItemCabinetComponent.cs +++ b/Content.Server/Cabinet/ItemCabinetComponent.cs @@ -24,7 +24,7 @@ namespace Content.Server.Cabinet /// Sound to be played when the cabinet door is opened. /// [ViewVariables(VVAccess.ReadWrite)] - [DataField("doorSound")] + [DataField("doorSound", required: true)] public SoundSpecifier DoorSound { get; set; } = default!; /// diff --git a/Content.Server/Cabinet/ItemCabinetSystem.cs b/Content.Server/Cabinet/ItemCabinetSystem.cs index 39772ee9b6..b56e1d52cd 100644 --- a/Content.Server/Cabinet/ItemCabinetSystem.cs +++ b/Content.Server/Cabinet/ItemCabinetSystem.cs @@ -36,7 +36,7 @@ namespace Content.Server.Cabinet comp.ItemContainer = owner.EnsureContainer("item_cabinet", out _); - if(comp.SpawnPrototype != null) + if (comp.SpawnPrototype != null) comp.ItemContainer.Insert(EntityManager.SpawnEntity(comp.SpawnPrototype, owner.Transform.Coordinates)); UpdateVisuals(comp); @@ -146,10 +146,7 @@ namespace Content.Server.Cabinet private static void ClickLatchSound(ItemCabinetComponent comp) { - if(comp.DoorSound.TryGetSound(out var doorSound)) - { - SoundSystem.Play(Filter.Pvs(comp.Owner), doorSound, comp.Owner, AudioHelpers.WithVariation(0.15f)); - } + SoundSystem.Play(Filter.Pvs(comp.Owner), comp.DoorSound.GetSound(), comp.Owner, AudioHelpers.WithVariation(0.15f)); } } diff --git a/Content.Server/Cargo/Components/CargoConsoleComponent.cs b/Content.Server/Cargo/Components/CargoConsoleComponent.cs index 77b31ab890..35c51caa80 100644 --- a/Content.Server/Cargo/Components/CargoConsoleComponent.cs +++ b/Content.Server/Cargo/Components/CargoConsoleComponent.cs @@ -115,10 +115,9 @@ namespace Content.Server.Cargo.Components } if (!_cargoConsoleSystem.AddOrder(orders.Database.Id, msg.Requester, msg.Reason, msg.ProductId, - msg.Amount, _bankAccount.Id) && - _errorSound.TryGetSound(out var errorSound)) + msg.Amount, _bankAccount.Id)) { - SoundSystem.Play(Filter.Local(), errorSound, Owner, AudioParams.Default); + SoundSystem.Play(Filter.Local(), _errorSound.GetSound(), Owner, AudioParams.Default); } break; } @@ -146,11 +145,9 @@ namespace Content.Server.Cargo.Components || !_cargoConsoleSystem.CheckBalance(_bankAccount.Id, (-product.PointCost) * order.Amount) || !_cargoConsoleSystem.ApproveOrder(orders.Database.Id, msg.OrderNumber) || !_cargoConsoleSystem.ChangeBalance(_bankAccount.Id, (-product.PointCost) * order.Amount)) - && - _errorSound.TryGetSound(out var errorSound) ) { - SoundSystem.Play(Filter.Local(), errorSound, Owner, AudioParams.Default); + SoundSystem.Play(Filter.Local(), _errorSound.GetSound(), Owner, AudioParams.Default); break; } UpdateUIState(); diff --git a/Content.Server/Cargo/Components/CargoTelepadComponent.cs b/Content.Server/Cargo/Components/CargoTelepadComponent.cs index d26d0834e6..30becc9650 100644 --- a/Content.Server/Cargo/Components/CargoTelepadComponent.cs +++ b/Content.Server/Cargo/Components/CargoTelepadComponent.cs @@ -74,8 +74,7 @@ namespace Content.Server.Cargo.Components { if (!Deleted && !Owner.Deleted && _currentState == CargoTelepadState.Teleporting && _teleportQueue.Count > 0) { - if (_teleportSound.TryGetSound(out var teleportSound)) - SoundSystem.Play(Filter.Pvs(Owner), teleportSound, Owner, AudioParams.Default.WithVolume(-8f)); + SoundSystem.Play(Filter.Pvs(Owner), _teleportSound.GetSound(), Owner, AudioParams.Default.WithVolume(-8f)); Owner.EntityManager.SpawnEntity(_teleportQueue[0].Product, Owner.Transform.Coordinates); _teleportQueue.RemoveAt(0); if (Owner.TryGetComponent(out var spriteComponent) && spriteComponent.LayerCount > 0) diff --git a/Content.Server/Chemistry/Components/ChemMasterComponent.cs b/Content.Server/Chemistry/Components/ChemMasterComponent.cs index 9f4ca18bc5..55d8a45600 100644 --- a/Content.Server/Chemistry/Components/ChemMasterComponent.cs +++ b/Content.Server/Chemistry/Components/ChemMasterComponent.cs @@ -420,8 +420,7 @@ namespace Content.Server.Chemistry.Components private void ClickSound() { - if(_clickSound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default.WithVolume(-2f)); + SoundSystem.Play(Filter.Pvs(Owner), _clickSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f)); } [Verb] diff --git a/Content.Server/Chemistry/Components/HyposprayComponent.cs b/Content.Server/Chemistry/Components/HyposprayComponent.cs index fd3974fac6..63f3520283 100644 --- a/Content.Server/Chemistry/Components/HyposprayComponent.cs +++ b/Content.Server/Chemistry/Components/HyposprayComponent.cs @@ -72,8 +72,7 @@ namespace Content.Server.Chemistry.Components meleeSys.SendLunge(angle, user); } - if(_injectSound.TryGetSound(out var injectSound)) - SoundSystem.Play(Filter.Pvs(user), injectSound, user); + SoundSystem.Play(Filter.Pvs(user), _injectSound.GetSound(), user); var targetSolution = target.GetComponent(); diff --git a/Content.Server/Chemistry/Components/PillComponent.cs b/Content.Server/Chemistry/Components/PillComponent.cs index 5454744f0b..f3be401e3b 100644 --- a/Content.Server/Chemistry/Components/PillComponent.cs +++ b/Content.Server/Chemistry/Components/PillComponent.cs @@ -23,7 +23,7 @@ namespace Content.Server.Chemistry.Components public override string Name => "Pill"; [ViewVariables] - [DataField("useSound")] + [DataField("useSound", required: true)] protected override SoundSpecifier UseSound { get; set; } = default!; [ViewVariables] @@ -99,10 +99,7 @@ namespace Content.Server.Chemistry.Components firstStomach.TryTransferSolution(split); - if (UseSound.TryGetSound(out var sound)) - { - SoundSystem.Play(Filter.Pvs(trueTarget), sound, trueTarget, AudioParams.Default.WithVolume(-1f)); - } + SoundSystem.Play(Filter.Pvs(trueTarget), UseSound.GetSound(), trueTarget, AudioParams.Default.WithVolume(-1f)); trueTarget.PopupMessage(user, Loc.GetString("pill-component-swallow-success-message")); diff --git a/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs b/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs index 74b316f315..03e239e5c9 100644 --- a/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs +++ b/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs @@ -47,7 +47,8 @@ namespace Content.Server.Chemistry.Components [ViewVariables] private ContainerSlot _beakerContainer = default!; [ViewVariables] [DataField("pack")] private string _packPrototypeId = ""; - [DataField("clickSound")] private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg"); + [DataField("clickSound")] + private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg"); [ViewVariables] private bool HasBeaker => _beakerContainer.ContainedEntity != null; [ViewVariables] private ReagentUnit _dispenseAmount = ReagentUnit.New(10); @@ -361,8 +362,7 @@ namespace Content.Server.Chemistry.Components private void ClickSound() { - if(_clickSound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default.WithVolume(-2f)); + SoundSystem.Play(Filter.Pvs(Owner), _clickSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f)); } [Verb] diff --git a/Content.Server/Chemistry/EntitySystems/ChemicalReactionSystem.cs b/Content.Server/Chemistry/EntitySystems/ChemicalReactionSystem.cs index d9dfd5d502..cecc997ecf 100644 --- a/Content.Server/Chemistry/EntitySystems/ChemicalReactionSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/ChemicalReactionSystem.cs @@ -12,8 +12,7 @@ namespace Content.Server.Chemistry.EntitySystems { base.OnReaction(reaction, owner, unitReactions); - if (reaction.Sound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(owner), sound, owner.Transform.Coordinates); + SoundSystem.Play(Filter.Pvs(owner), reaction.Sound.GetSound(), owner.Transform.Coordinates); } } } diff --git a/Content.Server/Chemistry/ReactionEffects/AreaReactionEffect.cs b/Content.Server/Chemistry/ReactionEffects/AreaReactionEffect.cs index 2b08dabbda..cf3ab9882c 100644 --- a/Content.Server/Chemistry/ReactionEffects/AreaReactionEffect.cs +++ b/Content.Server/Chemistry/ReactionEffects/AreaReactionEffect.cs @@ -80,7 +80,7 @@ namespace Content.Server.Chemistry.ReactionEffects /// /// Sound that will get played when this reaction effect occurs. /// - [DataField("sound")] private SoundSpecifier _sound = default!; + [DataField("sound", required: true)] private SoundSpecifier _sound = default!; protected AreaReactionEffect() { @@ -136,10 +136,7 @@ namespace Content.Server.Chemistry.ReactionEffects areaEffectComponent.TryAddSolution(solution); areaEffectComponent.Start(amount, _duration, _spreadDelay, _removeDelay); - if (_sound.TryGetSound(out var sound)) - { - SoundSystem.Play(Filter.Pvs(solutionEntity), sound, solutionEntity, AudioHelpers.WithVariation(0.125f)); - } + SoundSystem.Play(Filter.Pvs(solutionEntity), _sound.GetSound(), solutionEntity, AudioHelpers.WithVariation(0.125f)); } protected abstract SolutionAreaEffectComponent? GetAreaEffectComponent(IEntity entity); diff --git a/Content.Server/Construction/Completions/PlaySound.cs b/Content.Server/Construction/Completions/PlaySound.cs index a336d70827..3fbf6f5a1b 100644 --- a/Content.Server/Construction/Completions/PlaySound.cs +++ b/Content.Server/Construction/Completions/PlaySound.cs @@ -14,12 +14,11 @@ namespace Content.Server.Construction.Completions [DataDefinition] public class PlaySound : IGraphAction { - [DataField("sound")] public SoundSpecifier Sound { get; private set; } = default!; + [DataField("sound", required: true)] public SoundSpecifier Sound { get; private set; } = default!; public async Task PerformAction(IEntity entity, IEntity? user) { - if(Sound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(entity), sound, entity, AudioHelpers.WithVariation(0.125f)); + SoundSystem.Play(Filter.Pvs(entity), Sound.GetSound(), entity, AudioHelpers.WithVariation(0.125f)); } } } diff --git a/Content.Server/Crayon/CrayonComponent.cs b/Content.Server/Crayon/CrayonComponent.cs index d942a08a21..97df4f961a 100644 --- a/Content.Server/Crayon/CrayonComponent.cs +++ b/Content.Server/Crayon/CrayonComponent.cs @@ -30,7 +30,7 @@ namespace Content.Server.Crayon [Dependency] private readonly IPrototypeManager _prototypeManager = default!; //TODO: useSound - [DataField("useSound")] + [DataField("useSound", required: true)] private SoundSpecifier _useSound = default!; [ViewVariables] @@ -139,10 +139,7 @@ namespace Content.Server.Crayon appearance.SetData(CrayonVisuals.Rotation, eventArgs.User.Transform.LocalRotation); } - if (_useSound.TryGetSound(out var useSound)) - { - SoundSystem.Play(Filter.Pvs(Owner), useSound, Owner, AudioHelpers.WithVariation(0.125f)); - } + SoundSystem.Play(Filter.Pvs(Owner), _useSound.GetSound(), Owner, AudioHelpers.WithVariation(0.125f)); // Decrease "Ammo" Charges--; diff --git a/Content.Server/Cuffs/Components/CuffableComponent.cs b/Content.Server/Cuffs/Components/CuffableComponent.cs index 2bdb62c3e8..fd550d228d 100644 --- a/Content.Server/Cuffs/Components/CuffableComponent.cs +++ b/Content.Server/Cuffs/Components/CuffableComponent.cs @@ -231,13 +231,11 @@ namespace Content.Server.Cuffs.Components if (isOwner) { - if (cuff.StartBreakoutSound.TryGetSound(out var startBreakoutSound)) - SoundSystem.Play(Filter.Pvs(Owner), startBreakoutSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), cuff.StartBreakoutSound.GetSound(), Owner); } else { - if (cuff.StartUncuffSound.TryGetSound(out var startUncuffSound)) - SoundSystem.Play(Filter.Pvs(Owner), startUncuffSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), cuff.StartUncuffSound.GetSound(), Owner); } var uncuffTime = isOwner ? cuff.BreakoutTime : cuff.UncuffTime; @@ -258,8 +256,7 @@ namespace Content.Server.Cuffs.Components if (result != DoAfterStatus.Cancelled) { - if (cuff.EndUncuffSound.TryGetSound(out var endUncuffSound)) - SoundSystem.Play(Filter.Pvs(Owner), endUncuffSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), cuff.EndUncuffSound.GetSound(), Owner); Container.ForceRemove(cuffsToRemove); cuffsToRemove.Transform.AttachToGridOrMap(); @@ -289,7 +286,7 @@ namespace Content.Server.Cuffs.Components if (!isOwner) { - user.PopupMessage(Owner, Loc.GetString("cuffable-component-remove-cuffs-by-other-success-message",("otherName", user))); + user.PopupMessage(Owner, Loc.GetString("cuffable-component-remove-cuffs-by-other-success-message", ("otherName", user))); } } else @@ -305,7 +302,7 @@ namespace Content.Server.Cuffs.Components } else { - user.PopupMessage(Loc.GetString("cuffable-component-remove-cuffs-partial-success-message",("cuffedHandCount", CuffedHandCount))); + user.PopupMessage(Loc.GetString("cuffable-component-remove-cuffs-partial-success-message", ("cuffedHandCount", CuffedHandCount))); } } } diff --git a/Content.Server/Cuffs/Components/HandcuffComponent.cs b/Content.Server/Cuffs/Components/HandcuffComponent.cs index 036c289af4..c652e00e2e 100644 --- a/Content.Server/Cuffs/Components/HandcuffComponent.cs +++ b/Content.Server/Cuffs/Components/HandcuffComponent.cs @@ -184,8 +184,7 @@ namespace Content.Server.Cuffs.Components eventArgs.User.PopupMessage(Loc.GetString("handcuff-component-start-cuffing-target-message",("targetName", eventArgs.Target))); eventArgs.User.PopupMessage(eventArgs.Target, Loc.GetString("handcuff-component-start-cuffing-by-other-message",("otherName", eventArgs.User))); - if (StartCuffSound.TryGetSound(out var startCuffSound)) - SoundSystem.Play(Filter.Pvs(Owner), startCuffSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), StartCuffSound.GetSound(), Owner); TryUpdateCuff(eventArgs.User, eventArgs.Target, cuffed); return true; @@ -222,8 +221,7 @@ namespace Content.Server.Cuffs.Components { if (cuffs.TryAddNewCuffs(user, Owner)) { - if (EndCuffSound.TryGetSound(out var endCuffSound)) - SoundSystem.Play(Filter.Pvs(Owner), endCuffSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), EndCuffSound.GetSound(), Owner); user.PopupMessage(Loc.GetString("handcuff-component-cuff-other-success-message",("otherName", target))); target.PopupMessage(Loc.GetString("handcuff-component-cuff-by-other-success-message", ("otherName", user))); diff --git a/Content.Server/Damage/Components/DamageOnHighSpeedImpactComponent.cs b/Content.Server/Damage/Components/DamageOnHighSpeedImpactComponent.cs index aca43b5425..6632f13c97 100644 --- a/Content.Server/Damage/Components/DamageOnHighSpeedImpactComponent.cs +++ b/Content.Server/Damage/Components/DamageOnHighSpeedImpactComponent.cs @@ -22,7 +22,7 @@ namespace Content.Server.Damage.Components public int BaseDamage { get; set; } = 5; [DataField("factor")] public float Factor { get; set; } = 1f; - [DataField("soundHit")] + [DataField("soundHit", required: true)] public SoundSpecifier SoundHit { get; set; } = default!; [DataField("stunChance")] public float StunChance { get; set; } = 0.25f; diff --git a/Content.Server/Damage/DamageOnHighSpeedImpactSystem.cs b/Content.Server/Damage/DamageOnHighSpeedImpactSystem.cs index db2ea230aa..9b11b23dd1 100644 --- a/Content.Server/Damage/DamageOnHighSpeedImpactSystem.cs +++ b/Content.Server/Damage/DamageOnHighSpeedImpactSystem.cs @@ -34,8 +34,7 @@ namespace Content.Server.Damage if (speed < component.MinimumSpeed) return; - if (component.SoundHit.TryGetSound(out var soundHit)) - SoundSystem.Play(Filter.Pvs(otherBody), soundHit, otherBody, AudioHelpers.WithVariation(0.125f).WithVolume(-0.125f)); + SoundSystem.Play(Filter.Pvs(otherBody), component.SoundHit.GetSound(), otherBody, AudioHelpers.WithVariation(0.125f).WithVolume(-0.125f)); if ((_gameTiming.CurTime - component.LastHit).TotalSeconds < component.DamageCooldown) return; diff --git a/Content.Server/Destructible/Thresholds/Behaviors/PlaySoundBehavior.cs b/Content.Server/Destructible/Thresholds/Behaviors/PlaySoundBehavior.cs index 67fad570ed..7847fb8f37 100644 --- a/Content.Server/Destructible/Thresholds/Behaviors/PlaySoundBehavior.cs +++ b/Content.Server/Destructible/Thresholds/Behaviors/PlaySoundBehavior.cs @@ -15,15 +15,12 @@ namespace Content.Server.Destructible.Thresholds.Behaviors /// /// Sound played upon destruction. /// - [DataField("sound")] public SoundSpecifier Sound { get; set; } = default!; + [DataField("sound", required: true)] public SoundSpecifier Sound { get; set; } = default!; public void Execute(IEntity owner, DestructibleSystem system) { - if (Sound.TryGetSound(out var sound)) - { - var pos = owner.Transform.Coordinates; - SoundSystem.Play(Filter.Pvs(pos), sound, pos, AudioHelpers.WithVariation(0.125f)); - } + var pos = owner.Transform.Coordinates; + SoundSystem.Play(Filter.Pvs(pos), Sound.GetSound(), pos, AudioHelpers.WithVariation(0.125f)); } } } diff --git a/Content.Server/Dice/DiceComponent.cs b/Content.Server/Dice/DiceComponent.cs index 09abb9ade4..99bdf36eaa 100644 --- a/Content.Server/Dice/DiceComponent.cs +++ b/Content.Server/Dice/DiceComponent.cs @@ -64,8 +64,7 @@ namespace Content.Server.Dice public void PlayDiceEffect() { - if(_sound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default); + SoundSystem.Play(Filter.Pvs(Owner), _sound.GetSound(), Owner, AudioParams.Default); } void IActivate.Activate(ActivateEventArgs eventArgs) diff --git a/Content.Server/Disposal/Mailing/DisposalMailingUnitComponent.cs b/Content.Server/Disposal/Mailing/DisposalMailingUnitComponent.cs index c0e0eb8be1..fac13e2b7c 100644 --- a/Content.Server/Disposal/Mailing/DisposalMailingUnitComponent.cs +++ b/Content.Server/Disposal/Mailing/DisposalMailingUnitComponent.cs @@ -435,8 +435,7 @@ namespace Content.Server.Disposal.Mailing break; case UiButton.Power: TogglePower(); - if(_receivedMessageSound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default.WithVolume(-2f)); + SoundSystem.Play(Filter.Pvs(Owner), _receivedMessageSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f)); break; default: throw new ArgumentOutOfRangeException(); diff --git a/Content.Server/Disposal/Tube/Components/DisposalRouterComponent.cs b/Content.Server/Disposal/Tube/Components/DisposalRouterComponent.cs index a8cca2dbf4..5c1256202d 100644 --- a/Content.Server/Disposal/Tube/Components/DisposalRouterComponent.cs +++ b/Content.Server/Disposal/Tube/Components/DisposalRouterComponent.cs @@ -127,7 +127,7 @@ namespace Content.Server.Disposal.Tube.Components /// Returns a private DisposalRouterUserInterfaceState GetUserInterfaceState() { - if(_tags.Count <= 0) + if (_tags.Count <= 0) { return new DisposalRouterUserInterfaceState(""); } @@ -153,8 +153,7 @@ namespace Content.Server.Disposal.Tube.Components private void ClickSound() { - if(_clickSound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default.WithVolume(-2f)); + SoundSystem.Play(Filter.Pvs(Owner), _clickSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f)); } /// diff --git a/Content.Server/Disposal/Tube/Components/DisposalTaggerComponent.cs b/Content.Server/Disposal/Tube/Components/DisposalTaggerComponent.cs index d5bb6e2098..03a4bd73b2 100644 --- a/Content.Server/Disposal/Tube/Components/DisposalTaggerComponent.cs +++ b/Content.Server/Disposal/Tube/Components/DisposalTaggerComponent.cs @@ -119,8 +119,7 @@ namespace Content.Server.Disposal.Tube.Components private void ClickSound() { - if(_clickSound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default.WithVolume(-2f)); + SoundSystem.Play(Filter.Pvs(Owner), _clickSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f)); } /// diff --git a/Content.Server/Disposal/Tube/Components/DisposalTubeComponent.cs b/Content.Server/Disposal/Tube/Components/DisposalTubeComponent.cs index 00a92f09f8..1483a7b906 100644 --- a/Content.Server/Disposal/Tube/Components/DisposalTubeComponent.cs +++ b/Content.Server/Disposal/Tube/Components/DisposalTubeComponent.cs @@ -266,8 +266,7 @@ namespace Content.Server.Disposal.Tube.Components } _lastClang = _gameTiming.CurTime; - if(_clangSound.TryGetSound(out var clangSound)) - SoundSystem.Play(Filter.Pvs(Owner), clangSound, Owner.Transform.Coordinates); + SoundSystem.Play(Filter.Pvs(Owner), _clangSound.GetSound(), Owner.Transform.Coordinates); break; } } diff --git a/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs b/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs index 14c3c502f3..4b6987611a 100644 --- a/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs +++ b/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs @@ -373,8 +373,7 @@ namespace Content.Server.Disposal.Unit.Components break; case UiButton.Power: TogglePower(); - if(_clickSound.TryGetSound(out var clickSound)) - SoundSystem.Play(Filter.Pvs(Owner), clickSound, Owner, AudioParams.Default.WithVolume(-2f)); + SoundSystem.Play(Filter.Pvs(Owner), _clickSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f)); break; default: throw new ArgumentOutOfRangeException(); diff --git a/Content.Server/Doors/Components/AirlockComponent.cs b/Content.Server/Doors/Components/AirlockComponent.cs index 93fd5fba36..eee426e02e 100644 --- a/Content.Server/Doors/Components/AirlockComponent.cs +++ b/Content.Server/Doors/Components/AirlockComponent.cs @@ -359,7 +359,7 @@ namespace Content.Server.Doors.Components public void WiresUpdate(WiresUpdateEventArgs args) { - if(_doorComponent == null) + if (_doorComponent == null) { return; } @@ -463,13 +463,11 @@ namespace Content.Server.Doors.Components if (newBolts) { - if (_setBoltsDownSound.TryGetSound(out var boltsDownSound)) - SoundSystem.Play(Filter.Broadcast(), boltsDownSound, Owner); + SoundSystem.Play(Filter.Broadcast(), _setBoltsDownSound.GetSound(), Owner); } else { - if (_setBoltsUpSound.TryGetSound(out var boltsUpSound)) - SoundSystem.Play(Filter.Broadcast(), boltsUpSound, Owner); + SoundSystem.Play(Filter.Broadcast(), _setBoltsUpSound.GetSound(), Owner); } } } diff --git a/Content.Server/Doors/Components/ServerDoorComponent.cs b/Content.Server/Doors/Components/ServerDoorComponent.cs index dfa0e8e448..23ee6c3778 100644 --- a/Content.Server/Doors/Components/ServerDoorComponent.cs +++ b/Content.Server/Doors/Components/ServerDoorComponent.cs @@ -222,10 +222,9 @@ namespace Content.Server.Doors.Components { Open(); - if (user.TryGetComponent(out HandsComponent? hands) && hands.Count == 0 - && _tryOpenDoorSound.TryGetSound(out var tryOpenDoorSound)) + if (user.TryGetComponent(out HandsComponent? hands) && hands.Count == 0) { - SoundSystem.Play(Filter.Pvs(Owner), tryOpenDoorSound, Owner, AudioParams.Default.WithVolume(-2)); + SoundSystem.Play(Filter.Pvs(Owner), _tryOpenDoorSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2)); } } else diff --git a/Content.Server/Explosion/Components/SoundOnTriggerComponent.cs b/Content.Server/Explosion/Components/SoundOnTriggerComponent.cs index d1acbe4087..83ea9bca05 100644 --- a/Content.Server/Explosion/Components/SoundOnTriggerComponent.cs +++ b/Content.Server/Explosion/Components/SoundOnTriggerComponent.cs @@ -14,7 +14,7 @@ namespace Content.Server.Explosion.Components public override string Name => "SoundOnTrigger"; [ViewVariables(VVAccess.ReadWrite)] - [DataField("sound")] + [DataField("sound", required: true)] public SoundSpecifier? Sound { get; set; } = null; } } diff --git a/Content.Server/Explosion/ExplosionHelper.cs b/Content.Server/Explosion/ExplosionHelper.cs index 234415799f..c2b1aa7e32 100644 --- a/Content.Server/Explosion/ExplosionHelper.cs +++ b/Content.Server/Explosion/ExplosionHelper.cs @@ -314,8 +314,7 @@ namespace Content.Server.Explosion var boundingBox = new Box2(epicenterMapPos - new Vector2(maxRange, maxRange), epicenterMapPos + new Vector2(maxRange, maxRange)); - if(_explosionSound.TryGetSound(out var explosionSound)) - SoundSystem.Play(Filter.Broadcast(), explosionSound, epicenter); + SoundSystem.Play(Filter.Broadcast(), _explosionSound.GetSound(), epicenter); DamageEntitiesInRange(epicenter, boundingBox, devastationRange, heavyImpactRange, maxRange, mapId); var mapGridsNear = mapManager.FindGridsIntersecting(mapId, boundingBox); diff --git a/Content.Server/Extinguisher/FireExtinguisherComponent.cs b/Content.Server/Extinguisher/FireExtinguisherComponent.cs index 8b87152686..6492ff6803 100644 --- a/Content.Server/Extinguisher/FireExtinguisherComponent.cs +++ b/Content.Server/Extinguisher/FireExtinguisherComponent.cs @@ -43,8 +43,7 @@ namespace Content.Server.Extinguisher var drained = targetSolution.Drain(trans); container.TryAddSolution(drained); - if(_refillSound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), _refillSound.GetSound(), Owner); eventArgs.Target.PopupMessage(eventArgs.User, Loc.GetString("fire-extinguisher-component-after-interact-refilled-message",("owner", Owner))); } diff --git a/Content.Server/Flash/Components/FlashableComponent.cs b/Content.Server/Flash/Components/FlashableComponent.cs index 0653114aa7..f96d9c51a6 100644 --- a/Content.Server/Flash/Components/FlashableComponent.cs +++ b/Content.Server/Flash/Components/FlashableComponent.cs @@ -42,9 +42,9 @@ namespace Content.Server.Flash.Components flashable.Flash(duration); } - if (sound != null && sound.TryGetSound(out var soundName)) + if (sound != null) { - SoundSystem.Play(Filter.Pvs(source), soundName, source.Transform.Coordinates); + SoundSystem.Play(Filter.Pvs(source), sound.GetSound(), source.Transform.Coordinates); } } } diff --git a/Content.Server/Flash/FlashSystem.cs b/Content.Server/Flash/FlashSystem.cs index 1e223aaed9..c40a09062b 100644 --- a/Content.Server/Flash/FlashSystem.cs +++ b/Content.Server/Flash/FlashSystem.cs @@ -92,8 +92,7 @@ namespace Content.Server.Flash }); } - if(comp.Sound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(comp.Owner), sound, comp.Owner.Transform.Coordinates, AudioParams.Default); + SoundSystem.Play(Filter.Pvs(comp.Owner), comp.Sound.GetSound(), comp.Owner.Transform.Coordinates, AudioParams.Default); return true; } diff --git a/Content.Server/Fluids/Components/BucketComponent.cs b/Content.Server/Fluids/Components/BucketComponent.cs index 87709c52a8..2e7b3f771c 100644 --- a/Content.Server/Fluids/Components/BucketComponent.cs +++ b/Content.Server/Fluids/Components/BucketComponent.cs @@ -114,10 +114,7 @@ namespace Content.Server.Fluids.Components return false; } - if (_sound.TryGetSound(out var sound)) - { - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner); - } + SoundSystem.Play(Filter.Pvs(Owner), _sound.GetSound(), Owner); return true; } diff --git a/Content.Server/Fluids/Components/MopComponent.cs b/Content.Server/Fluids/Components/MopComponent.cs index 615bc5552a..379830be24 100644 --- a/Content.Server/Fluids/Components/MopComponent.cs +++ b/Content.Server/Fluids/Components/MopComponent.cs @@ -163,10 +163,7 @@ namespace Content.Server.Fluids.Components contents.SplitSolution(transferAmount); } - if (_pickupSound.TryGetSound(out var pickupSound)) - { - SoundSystem.Play(Filter.Pvs(Owner), pickupSound, Owner); - } + SoundSystem.Play(Filter.Pvs(Owner), _pickupSound.GetSound(), Owner); return true; } diff --git a/Content.Server/Fluids/Components/PuddleComponent.cs b/Content.Server/Fluids/Components/PuddleComponent.cs index 103b733267..9949856faf 100644 --- a/Content.Server/Fluids/Components/PuddleComponent.cs +++ b/Content.Server/Fluids/Components/PuddleComponent.cs @@ -190,8 +190,7 @@ namespace Content.Server.Fluids.Components return true; } - if(_spillSound.TryGetSound(out var spillSound)) - SoundSystem.Play(Filter.Pvs(Owner), spillSound, Owner.Transform.Coordinates); + SoundSystem.Play(Filter.Pvs(Owner), _spillSound.GetSound(), Owner.Transform.Coordinates); return true; } diff --git a/Content.Server/Fluids/Components/SprayComponent.cs b/Content.Server/Fluids/Components/SprayComponent.cs index 1057df52d6..4824ffd6be 100644 --- a/Content.Server/Fluids/Components/SprayComponent.cs +++ b/Content.Server/Fluids/Components/SprayComponent.cs @@ -76,7 +76,7 @@ namespace Content.Server.Fluids.Components set => _sprayVelocity = value; } - [DataField("spraySound")] + [DataField("spraySound", required: true)] public SoundSpecifier SpraySound { get; } = default!; public ReagentUnit CurrentVolume => Owner.GetComponentOrNull()?.CurrentVolume ?? ReagentUnit.Zero; @@ -173,11 +173,7 @@ namespace Content.Server.Fluids.Components } } - //Play sound - if (SpraySound.TryGetSound(out var spraySound)) - { - SoundSystem.Play(Filter.Pvs(Owner), spraySound, Owner, AudioHelpers.WithVariation(0.125f)); - } + SoundSystem.Play(Filter.Pvs(Owner), SpraySound.GetSound(), Owner, AudioHelpers.WithVariation(0.125f)); _lastUseTime = curTime; _cooldownEnd = _lastUseTime + TimeSpan.FromSeconds(_cooldownTime); diff --git a/Content.Server/GameTicking/Rules/RuleSuspicion.cs b/Content.Server/GameTicking/Rules/RuleSuspicion.cs index e1080ef625..130ddf8614 100644 --- a/Content.Server/GameTicking/Rules/RuleSuspicion.cs +++ b/Content.Server/GameTicking/Rules/RuleSuspicion.cs @@ -52,10 +52,9 @@ namespace Content.Server.GameTicking.Rules _chatManager.DispatchServerAnnouncement(Loc.GetString("rule-suspicion-added-announcement")); var filter = Filter.Empty() - .AddWhere(session => ((IPlayerSession)session).ContentData()?.Mind?.HasRole() ?? false); + .AddWhere(session => ((IPlayerSession) session).ContentData()?.Mind?.HasRole() ?? false); - if(_addedSound.TryGetSound(out var addedSound)) - SoundSystem.Play(filter, addedSound, AudioParams.Default); + SoundSystem.Play(filter, _addedSound.GetSound(), AudioParams.Default); EntitySystem.Get().EndTime = _endTime; EntitySystem.Get().AccessType = DoorSystem.AccessTypes.AllowAllNoExternal; @@ -160,7 +159,7 @@ namespace Content.Server.GameTicking.Rules var gameTicker = EntitySystem.Get(); gameTicker.EndRound(text); - _chatManager.DispatchServerAnnouncement(Loc.GetString("rule-restarting-in-seconds",("seconds", (int) RoundEndDelay.TotalSeconds))); + _chatManager.DispatchServerAnnouncement(Loc.GetString("rule-restarting-in-seconds", ("seconds", (int) RoundEndDelay.TotalSeconds))); _checkTimerCancel.Cancel(); Timer.Spawn(RoundEndDelay, () => gameTicker.RestartRound()); diff --git a/Content.Server/GameTicking/Rules/RuleTraitor.cs b/Content.Server/GameTicking/Rules/RuleTraitor.cs index ca697bc3d8..83d1df18c1 100644 --- a/Content.Server/GameTicking/Rules/RuleTraitor.cs +++ b/Content.Server/GameTicking/Rules/RuleTraitor.cs @@ -24,8 +24,7 @@ namespace Content.Server.GameTicking.Rules var filter = Filter.Empty() .AddWhere(session => ((IPlayerSession)session).ContentData()?.Mind?.HasRole() ?? false); - if(_addedSound.TryGetSound(out var addedSound)) - SoundSystem.Play(filter, addedSound, AudioParams.Default); + SoundSystem.Play(filter, _addedSound.GetSound(), AudioParams.Default); } } } diff --git a/Content.Server/Gravity/EntitySystems/GravitySystem.cs b/Content.Server/Gravity/EntitySystems/GravitySystem.cs index 92fa41fa92..3778b8a3c5 100644 --- a/Content.Server/Gravity/EntitySystems/GravitySystem.cs +++ b/Content.Server/Gravity/EntitySystems/GravitySystem.cs @@ -144,8 +144,7 @@ namespace Content.Server.Gravity.EntitySystems || player.AttachedEntity.Transform.GridID != gridId) continue; - if(comp.GravityShakeSound.TryGetSound(out var gravityShakeSound)) - SoundSystem.Play(Filter.Pvs(player.AttachedEntity), gravityShakeSound, player.AttachedEntity); + SoundSystem.Play(Filter.Pvs(player.AttachedEntity), comp.GravityShakeSound.GetSound(), player.AttachedEntity); } } diff --git a/Content.Server/Hands/Components/HandsComponent.cs b/Content.Server/Hands/Components/HandsComponent.cs index c6e2ac4896..daf034ddb6 100644 --- a/Content.Server/Hands/Components/HandsComponent.cs +++ b/Content.Server/Hands/Components/HandsComponent.cs @@ -143,8 +143,7 @@ namespace Content.Server.Hands.Components if (source != null) { - if(_disarmedSound.TryGetSound(out var disarmedSound)) - SoundSystem.Play(Filter.Pvs(source), disarmedSound, source, AudioHelpers.WithVariation(0.025f)); + SoundSystem.Play(Filter.Pvs(source), _disarmedSound.GetSound(), source, AudioHelpers.WithVariation(0.025f)); if (target != null) { diff --git a/Content.Server/Kitchen/Components/KitchenSpikeComponent.cs b/Content.Server/Kitchen/Components/KitchenSpikeComponent.cs index eb15186f25..f4cb1e6022 100644 --- a/Content.Server/Kitchen/Components/KitchenSpikeComponent.cs +++ b/Content.Server/Kitchen/Components/KitchenSpikeComponent.cs @@ -160,8 +160,7 @@ namespace Content.Server.Kitchen.Components // TODO: Need to be able to leave them on the spike to do DoT, see ss13. victim.Delete(); - if (SpikeSound.TryGetSound(out var spikeSound)) - SoundSystem.Play(Filter.Pvs(Owner), spikeSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), SpikeSound.GetSound(), Owner); } SuicideKind ISuicideAct.Suicide(IEntity victim, IChatManager chat) diff --git a/Content.Server/Kitchen/Components/MicrowaveComponent.cs b/Content.Server/Kitchen/Components/MicrowaveComponent.cs index 8737ad1159..a0786f7fe0 100644 --- a/Content.Server/Kitchen/Components/MicrowaveComponent.cs +++ b/Content.Server/Kitchen/Components/MicrowaveComponent.cs @@ -107,10 +107,10 @@ namespace Content.Server.Kitchen.Components switch (message.Message) { - case MicrowaveStartCookMessage msg : + case MicrowaveStartCookMessage msg: Wzhzhzh(); break; - case MicrowaveEjectMessage msg : + case MicrowaveEjectMessage msg: if (_hasContents) { VaporizeReagents(); @@ -271,7 +271,7 @@ namespace Content.Server.Kitchen.Components } Owner.PopupMessage(eventArgs.User, Loc.GetString("microwave-component-interact-using-transfer-success", - ("amount",removedSolution.TotalVolume))); + ("amount", removedSolution.TotalVolume))); return true; } @@ -300,14 +300,14 @@ namespace Content.Server.Kitchen.Components _busy = true; // Convert storage into Dictionary of ingredients var solidsDict = new Dictionary(); - foreach(var item in _storage.ContainedEntities) + foreach (var item in _storage.ContainedEntities) { if (item.Prototype == null) { continue; } - if(solidsDict.ContainsKey(item.Prototype.ID)) + if (solidsDict.ContainsKey(item.Prototype.ID)) { solidsDict[item.Prototype.ID]++; } @@ -318,9 +318,9 @@ namespace Content.Server.Kitchen.Components } var failState = MicrowaveSuccessState.RecipeFail; - foreach(var id in solidsDict.Keys) + foreach (var id in solidsDict.Keys) { - if(_recipeManager.SolidAppears(id)) + if (_recipeManager.SolidAppears(id)) { continue; } @@ -337,43 +337,41 @@ namespace Content.Server.Kitchen.Components } SetAppearance(MicrowaveVisualState.Cooking); - if(_startCookingSound.TryGetSound(out var startCookingSound)) - SoundSystem.Play(Filter.Pvs(Owner), startCookingSound, Owner, AudioParams.Default); - Owner.SpawnTimer((int)(_currentCookTimerTime * _cookTimeMultiplier), (Action)(() => - { - if (_lostPower) - { - return; - } + SoundSystem.Play(Filter.Pvs(Owner), _startCookingSound.GetSound(), Owner, AudioParams.Default); + Owner.SpawnTimer((int) (_currentCookTimerTime * _cookTimeMultiplier), (Action) (() => + { + if (_lostPower) + { + return; + } - if(failState == MicrowaveSuccessState.UnwantedForeignObject) - { - VaporizeReagents(); - EjectSolids(); - } - else - { - if (recipeToCook != null) - { - SubtractContents(recipeToCook); - Owner.EntityManager.SpawnEntity(recipeToCook.Result, Owner.Transform.Coordinates); - } - else - { - VaporizeReagents(); - VaporizeSolids(); - Owner.EntityManager.SpawnEntity(_badRecipeName, Owner.Transform.Coordinates); - } - } + if (failState == MicrowaveSuccessState.UnwantedForeignObject) + { + VaporizeReagents(); + EjectSolids(); + } + else + { + if (recipeToCook != null) + { + SubtractContents(recipeToCook); + Owner.EntityManager.SpawnEntity(recipeToCook.Result, Owner.Transform.Coordinates); + } + else + { + VaporizeReagents(); + VaporizeSolids(); + Owner.EntityManager.SpawnEntity(_badRecipeName, Owner.Transform.Coordinates); + } + } - if(_cookingCompleteSound.TryGetSound(out var cookingCompleteSound)) - SoundSystem.Play(Filter.Pvs(Owner), cookingCompleteSound, Owner, AudioParams.Default.WithVolume(-1f)); + SoundSystem.Play(Filter.Pvs(Owner), _cookingCompleteSound.GetSound(), Owner, AudioParams.Default.WithVolume(-1f)); - SetAppearance(MicrowaveVisualState.Idle); - _busy = false; + SetAppearance(MicrowaveVisualState.Idle); + _busy = false; - _uiDirty = true; - })); + _uiDirty = true; + })); _lostPower = false; _uiDirty = true; } @@ -396,7 +394,7 @@ namespace Content.Server.Kitchen.Components private void VaporizeSolids() { - for(var i = _storage.ContainedEntities.Count-1; i>=0; i--) + for (var i = _storage.ContainedEntities.Count - 1; i >= 0; i--) { var item = _storage.ContainedEntities.ElementAt(i); _storage.Remove(item); @@ -407,7 +405,7 @@ namespace Content.Server.Kitchen.Components private void EjectSolids() { - for(var i = _storage.ContainedEntities.Count-1; i>=0; i--) + for (var i = _storage.ContainedEntities.Count - 1; i >= 0; i--) { _storage.Remove(_storage.ContainedEntities.ElementAt(i)); } @@ -429,7 +427,7 @@ namespace Content.Server.Kitchen.Components return; } - foreach(var recipeReagent in recipe.IngredientsReagents) + foreach (var recipeReagent in recipe.IngredientsReagents) { solution?.TryRemoveReagent(recipeReagent.Key, ReagentUnit.New(recipeReagent.Value)); } @@ -457,7 +455,7 @@ namespace Content.Server.Kitchen.Components } - private MicrowaveSuccessState CanSatisfyRecipe(FoodRecipePrototype recipe, Dictionary solids) + private MicrowaveSuccessState CanSatisfyRecipe(FoodRecipePrototype recipe, Dictionary solids) { if (_currentCookTimerTime != (uint) recipe.CookTime) { @@ -500,8 +498,7 @@ namespace Content.Server.Kitchen.Components private void ClickSound() { - if(_clickSound.TryGetSound(out var clickSound)) - SoundSystem.Play(Filter.Pvs(Owner), clickSound, Owner,AudioParams.Default.WithVolume(-2f)); + SoundSystem.Play(Filter.Pvs(Owner), _clickSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f)); } SuicideKind ISuicideAct.Suicide(IEntity victim, IChatManager chat) @@ -537,7 +534,7 @@ namespace Content.Server.Kitchen.Components var othersMessage = headCount > 1 ? Loc.GetString("microwave-component-suicide-multi-head-others-message", ("victim", victim)) - : Loc.GetString("microwave-component-suicide-others-message",("victim", victim)); + : Loc.GetString("microwave-component-suicide-others-message", ("victim", victim)); victim.PopupMessageOtherClients(othersMessage); diff --git a/Content.Server/Kitchen/Components/ReagentGrinderComponent.cs b/Content.Server/Kitchen/Components/ReagentGrinderComponent.cs index 5507978b53..51cc7b0b1d 100644 --- a/Content.Server/Kitchen/Components/ReagentGrinderComponent.cs +++ b/Content.Server/Kitchen/Components/ReagentGrinderComponent.cs @@ -39,8 +39,8 @@ namespace Content.Server.Kitchen.Components //YAML serialization vars [ViewVariables(VVAccess.ReadWrite)] [DataField("chamberCapacity")] public int StorageCap = 16; [ViewVariables(VVAccess.ReadWrite)] [DataField("workTime")] public int WorkTime = 3500; //3.5 seconds, completely arbitrary for now. - [DataField("clickSound")] private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg"); - [DataField("grindSound")] private SoundSpecifier _grindSound = new SoundPathSpecifier("/Audio/Machines/blender.ogg"); - [DataField("juiceSound")] private SoundSpecifier _juiceSound = new SoundPathSpecifier("/Audio/Machines/juicer.ogg"); + [DataField("clickSound")] public SoundSpecifier ClickSound { get; set; } = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg"); + [DataField("grindSound")] public SoundSpecifier GrindSound { get; set; } = new SoundPathSpecifier("/Audio/Machines/blender.ogg"); + [DataField("juiceSound")] public SoundSpecifier JuiceSound { get; set; } = new SoundPathSpecifier("/Audio/Machines/juicer.ogg"); } } diff --git a/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs b/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs index 2b110578c1..74a128539c 100644 --- a/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs +++ b/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using Content.Server.Chemistry.Components; @@ -270,7 +270,7 @@ namespace Content.Server.Kitchen.EntitySystems switch (program) { case SharedReagentGrinderComponent.GrinderProgram.Grind: - SoundSystem.Play(Filter.Pvs(component.Owner), "/Audio/Machines/blender.ogg", component.Owner, AudioParams.Default); + SoundSystem.Play(Filter.Pvs(component.Owner), component.GrindSound.GetSound(), component.Owner, AudioParams.Default); //Get each item inside the chamber and get the reagents it contains. Transfer those reagents to the beaker, given we have one in. component.Owner.SpawnTimer(component.WorkTime, (Action) (() => { @@ -291,7 +291,7 @@ namespace Content.Server.Kitchen.EntitySystems break; case SharedReagentGrinderComponent.GrinderProgram.Juice: - SoundSystem.Play(Filter.Pvs(component.Owner), "/Audio/Machines/juicer.ogg", component.Owner, AudioParams.Default); + SoundSystem.Play(Filter.Pvs(component.Owner), component.JuiceSound.GetSound(), component.Owner, AudioParams.Default); component.Owner.SpawnTimer(component.WorkTime, (Action) (() => { foreach (var item in component.Chamber.ContainedEntities.ToList()) @@ -311,7 +311,7 @@ namespace Content.Server.Kitchen.EntitySystems private void ClickSound(ReagentGrinderComponent component) { - SoundSystem.Play(Filter.Pvs(component.Owner), "/Audio/Machines/machine_switch.ogg", component.Owner, AudioParams.Default.WithVolume(-2f)); + SoundSystem.Play(Filter.Pvs(component.Owner), component.ClickSound.GetSound(), component.Owner, AudioParams.Default.WithVolume(-2f)); } } } diff --git a/Content.Server/Light/Components/ExpendableLightComponent.cs b/Content.Server/Light/Components/ExpendableLightComponent.cs index 87a098f66d..b60bf0f8b2 100644 --- a/Content.Server/Light/Components/ExpendableLightComponent.cs +++ b/Content.Server/Light/Components/ExpendableLightComponent.cs @@ -100,11 +100,8 @@ namespace Content.Server.Light.Components switch (CurrentState) { case ExpendableLightState.Lit: - if (LitSound.TryGetSound(out var litSound)) - { - SoundSystem.Play(Filter.Pvs(Owner), litSound, Owner); - } - + SoundSystem.Play(Filter.Pvs(Owner), LitSound.GetSound(), Owner); + if (IconStateLit != string.Empty) { sprite.LayerSetState(2, IconStateLit); @@ -119,11 +116,7 @@ namespace Content.Server.Light.Components default: case ExpendableLightState.Dead: - - if (DieSound.TryGetSound(out var dieSound)) - { - SoundSystem.Play(Filter.Pvs(Owner), dieSound, Owner); - } + SoundSystem.Play(Filter.Pvs(Owner), DieSound.GetSound(), Owner); sprite.LayerSetState(0, IconStateSpent); sprite.LayerSetShader(0, "shaded"); diff --git a/Content.Server/Light/Components/HandheldLightComponent.cs b/Content.Server/Light/Components/HandheldLightComponent.cs index 35f5e43eee..2db579e71c 100644 --- a/Content.Server/Light/Components/HandheldLightComponent.cs +++ b/Content.Server/Light/Components/HandheldLightComponent.cs @@ -120,9 +120,9 @@ namespace Content.Server.Light.Components UpdateLightAction(); Owner.EntityManager.EventBus.QueueEvent(EventSource.Local, new DeactivateHandheldLightMessage(this)); - if (makeNoise && TurnOffSound.TryGetSound(out var turnOffSound)) + if (makeNoise) { - SoundSystem.Play(Filter.Pvs(Owner), turnOffSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), TurnOffSound.GetSound(), Owner); } return true; @@ -137,8 +137,7 @@ namespace Content.Server.Light.Components if (Cell == null) { - if (TurnOnFailSound.TryGetSound(out var turnOnFailSound)) - SoundSystem.Play(Filter.Pvs(Owner), turnOnFailSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), TurnOnFailSound.GetSound(), Owner); Owner.PopupMessage(user, Loc.GetString("handheld-light-component-cell-missing-message")); UpdateLightAction(); return false; @@ -149,8 +148,7 @@ namespace Content.Server.Light.Components // Simple enough. if (Wattage > Cell.CurrentCharge) { - if (TurnOnFailSound.TryGetSound(out var turnOnFailSound)) - SoundSystem.Play(Filter.Pvs(Owner), turnOnFailSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), TurnOnFailSound.GetSound(), Owner); Owner.PopupMessage(user, Loc.GetString("handheld-light-component-cell-dead-message")); UpdateLightAction(); return false; @@ -161,8 +159,7 @@ namespace Content.Server.Light.Components SetState(true); Owner.EntityManager.EventBus.QueueEvent(EventSource.Local, new ActivateHandheldLightMessage(this)); - if (TurnOnSound.TryGetSound(out var turnOnSound)) - SoundSystem.Play(Filter.Pvs(Owner), turnOnSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), TurnOnSound.GetSound(), Owner); return true; } diff --git a/Content.Server/Light/Components/LightBulbComponent.cs b/Content.Server/Light/Components/LightBulbComponent.cs index 6cc8253324..342dc41303 100644 --- a/Content.Server/Light/Components/LightBulbComponent.cs +++ b/Content.Server/Light/Components/LightBulbComponent.cs @@ -47,7 +47,8 @@ namespace Content.Server.Light.Components [DataField("color")] private Color _color = Color.White; - [ViewVariables(VVAccess.ReadWrite)] public Color Color + [ViewVariables(VVAccess.ReadWrite)] + public Color Color { get { return _color; } set @@ -78,7 +79,8 @@ namespace Content.Server.Light.Components /// The current state of the light bulb. Invokes the OnLightBulbStateChange event when set. /// It also updates the bulb's sprite accordingly. /// - [ViewVariables(VVAccess.ReadWrite)] public LightBulbState State + [ViewVariables(VVAccess.ReadWrite)] + public LightBulbState State { get { return _state; } set @@ -132,8 +134,7 @@ namespace Content.Server.Light.Components public void PlayBreakSound() { - if(_breakSound.TryGetSound(out var breakSound)) - SoundSystem.Play(Filter.Pvs(Owner), breakSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), _breakSound.GetSound(), Owner); } } } diff --git a/Content.Server/Light/Components/MatchstickComponent.cs b/Content.Server/Light/Components/MatchstickComponent.cs index 3cba208db5..864ed2ae1a 100644 --- a/Content.Server/Light/Components/MatchstickComponent.cs +++ b/Content.Server/Light/Components/MatchstickComponent.cs @@ -24,13 +24,14 @@ namespace Content.Server.Light.Components /// /// How long will matchstick last in seconds. /// - [ViewVariables(VVAccess.ReadOnly)] [DataField("duration")] + [ViewVariables(VVAccess.ReadOnly)] + [DataField("duration")] private int _duration = 10; /// /// Sound played when you ignite the matchstick. /// - [DataField("igniteSound")] private SoundSpecifier _igniteSound = default!; + [DataField("igniteSound", required: true)] private SoundSpecifier _igniteSound = default!; /// /// Point light component. Gives matches a glow in dark effect. @@ -69,11 +70,9 @@ namespace Content.Server.Light.Components public void Ignite(IEntity user) { // Play Sound - if (_igniteSound.TryGetSound(out var igniteSound)) - { - SoundSystem.Play(Filter.Pvs(Owner), igniteSound, Owner, - AudioHelpers.WithVariation(0.125f).WithVolume(-0.125f)); - } + SoundSystem.Play( + Filter.Pvs(Owner), _igniteSound.GetSound(), Owner, + AudioHelpers.WithVariation(0.125f).WithVolume(-0.125f)); // Change state CurrentState = SharedBurningStates.Lit; diff --git a/Content.Server/Light/Components/PoweredLightComponent.cs b/Content.Server/Light/Components/PoweredLightComponent.cs index d63f34c093..5f38eda681 100644 --- a/Content.Server/Light/Components/PoweredLightComponent.cs +++ b/Content.Server/Light/Components/PoweredLightComponent.cs @@ -58,7 +58,8 @@ namespace Content.Server.Light.Components [DataField("hasLampOnSpawn")] private bool _hasLampOnSpawn = true; - [ViewVariables] [DataField("on")] + [ViewVariables] + [DataField("on")] private bool _on = true; [ViewVariables] @@ -67,7 +68,8 @@ namespace Content.Server.Light.Components [ViewVariables] private bool _isBlinking; - [ViewVariables] [DataField("ignoreGhostsBoo")] + [ViewVariables] + [DataField("ignoreGhostsBoo")] private bool _ignoreGhostsBoo; [DataField("bulb")] private LightBulbType _bulbType = LightBulbType.Tube; @@ -102,9 +104,9 @@ namespace Content.Server.Light.Components Eject(); return false; } - if(eventArgs.User.TryGetComponent(out HeatResistanceComponent? heatResistanceComponent)) + if (eventArgs.User.TryGetComponent(out HeatResistanceComponent? heatResistanceComponent)) { - if(CanBurn(heatResistanceComponent.GetHeatResistance())) + if (CanBurn(heatResistanceComponent.GetHeatResistance())) { Burn(); return true; @@ -125,8 +127,7 @@ namespace Content.Server.Light.Components { Owner.PopupMessage(eventArgs.User, Loc.GetString("powered-light-component-burn-hand")); damageableComponent.ChangeDamage(DamageType.Heat, 20, false, Owner); - if(_burnHandSound.TryGetSound(out var burnHandSound)) - SoundSystem.Play(Filter.Pvs(Owner), burnHandSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), _burnHandSound.GetSound(), Owner); } void Eject() @@ -228,8 +229,7 @@ namespace Content.Server.Light.Components if (time > _lastThunk + _thunkDelay) { _lastThunk = time; - if(_turnOnSound.TryGetSound(out var turnOnSound)) - SoundSystem.Play(Filter.Pvs(Owner), turnOnSound, Owner, AudioParams.Default.WithVolume(-10f)); + SoundSystem.Play(Filter.Pvs(Owner), _turnOnSound.GetSound(), Owner, AudioParams.Default.WithVolume(-10f)); } } else @@ -338,7 +338,8 @@ namespace Content.Server.Light.Components _lastGhostBlink = time; ToggleBlinkingLight(true); - Owner.SpawnTimer(ghostBlinkingTime, () => { + Owner.SpawnTimer(ghostBlinkingTime, () => + { ToggleBlinkingLight(false); }); diff --git a/Content.Server/Lock/LockComponent.cs b/Content.Server/Lock/LockComponent.cs index 966548e607..ad9f25afe8 100644 --- a/Content.Server/Lock/LockComponent.cs +++ b/Content.Server/Lock/LockComponent.cs @@ -20,8 +20,8 @@ namespace Content.Server.Storage.Components public override string Name => "Lock"; [ViewVariables(VVAccess.ReadWrite)] [DataField("locked")] public bool Locked { get; set; } = true; - [ViewVariables(VVAccess.ReadWrite)] [DataField("unlockingSound")] public SoundSpecifier? UnlockSound { get; set; } = new SoundPathSpecifier("/Audio/Machines/door_lock_off.ogg"); - [ViewVariables(VVAccess.ReadWrite)] [DataField("lockingSound")] public SoundSpecifier? LockSound { get; set; } = new SoundPathSpecifier("/Audio/Machines/door_lock_off.ogg"); + [ViewVariables(VVAccess.ReadWrite)] [DataField("unlockingSound")] public SoundSpecifier UnlockSound { get; set; } = new SoundPathSpecifier("/Audio/Machines/door_lock_off.ogg"); + [ViewVariables(VVAccess.ReadWrite)] [DataField("lockingSound")] public SoundSpecifier LockSound { get; set; } = new SoundPathSpecifier("/Audio/Machines/door_lock_off.ogg"); [Verb] private sealed class ToggleLockVerb : Verb diff --git a/Content.Server/Mining/Components/AsteroidRockComponent.cs b/Content.Server/Mining/Components/AsteroidRockComponent.cs index 246f49ceee..4de41b4275 100644 --- a/Content.Server/Mining/Components/AsteroidRockComponent.cs +++ b/Content.Server/Mining/Components/AsteroidRockComponent.cs @@ -42,10 +42,7 @@ namespace Content.Server.Mining.Components if (!item.TryGetComponent(out PickaxeComponent? pickaxeComponent)) return true; - if (pickaxeComponent.MiningSound.TryGetSound(out var miningSound)) - { - SoundSystem.Play(Filter.Pvs(Owner), miningSound, Owner, AudioParams.Default); - } + SoundSystem.Play(Filter.Pvs(Owner), pickaxeComponent.MiningSound.GetSound(), Owner, AudioParams.Default); return true; } } diff --git a/Content.Server/Morgue/Components/CrematoriumEntityStorageComponent.cs b/Content.Server/Morgue/Components/CrematoriumEntityStorageComponent.cs index 0366a29034..11f8b81b44 100644 --- a/Content.Server/Morgue/Components/CrematoriumEntityStorageComponent.cs +++ b/Content.Server/Morgue/Components/CrematoriumEntityStorageComponent.cs @@ -120,8 +120,7 @@ namespace Content.Server.Morgue.Components TryOpenStorage(Owner); - if (_cremateFinishSound.TryGetSound(out var cremateFinishSound)) - SoundSystem.Play(Filter.Pvs(Owner), cremateFinishSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), _cremateFinishSound.GetSound(), Owner); }, _cremateCancelToken.Token); } diff --git a/Content.Server/Morgue/Components/MorgueEntityStorageComponent.cs b/Content.Server/Morgue/Components/MorgueEntityStorageComponent.cs index b03ef06737..d61e8683bb 100644 --- a/Content.Server/Morgue/Components/MorgueEntityStorageComponent.cs +++ b/Content.Server/Morgue/Components/MorgueEntityStorageComponent.cs @@ -146,10 +146,9 @@ namespace Content.Server.Morgue.Components { CheckContents(); - if (DoSoulBeep && Appearance != null && Appearance.TryGetData(MorgueVisuals.HasSoul, out bool hasSoul) && hasSoul && - _occupantHasSoulAlarmSound.TryGetSound(out var occupantHasSoulAlarmSound)) + if (DoSoulBeep && Appearance != null && Appearance.TryGetData(MorgueVisuals.HasSoul, out bool hasSoul) && hasSoul) { - SoundSystem.Play(Filter.Pvs(Owner), occupantHasSoulAlarmSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), _occupantHasSoulAlarmSound.GetSound(), Owner); } } diff --git a/Content.Server/Movement/Components/FootstepModifierComponent.cs b/Content.Server/Movement/Components/FootstepModifierComponent.cs index c61ec76cc3..9384c7d730 100644 --- a/Content.Server/Movement/Components/FootstepModifierComponent.cs +++ b/Content.Server/Movement/Components/FootstepModifierComponent.cs @@ -15,13 +15,12 @@ namespace Content.Server.Movement.Components /// public override string Name => "FootstepModifier"; - [DataField("footstepSoundCollection")] - public SoundSpecifier _soundCollection = default!; + [DataField("footstepSoundCollection", required: true)] + public SoundSpecifier SoundCollection = default!; public void PlayFootstep() { - if (_soundCollection.TryGetSound(out var footstepSound)) - SoundSystem.Play(Filter.Pvs(Owner), footstepSound, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2f)); + SoundSystem.Play(Filter.Pvs(Owner), SoundCollection.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2f)); } } } diff --git a/Content.Server/Nutrition/Components/CreamPieComponent.cs b/Content.Server/Nutrition/Components/CreamPieComponent.cs index e59a084fe5..97b46fd83a 100644 --- a/Content.Server/Nutrition/Components/CreamPieComponent.cs +++ b/Content.Server/Nutrition/Components/CreamPieComponent.cs @@ -25,8 +25,7 @@ namespace Content.Server.Nutrition.Components public void PlaySound() { - if(_sound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioHelpers.WithVariation(0.125f)); + SoundSystem.Play(Filter.Pvs(Owner), _sound.GetSound(), Owner, AudioHelpers.WithVariation(0.125f)); } void IThrowCollide.DoHit(ThrowCollideEventArgs eventArgs) diff --git a/Content.Server/Nutrition/Components/DrinkComponent.cs b/Content.Server/Nutrition/Components/DrinkComponent.cs index 40f783d299..0a1a9fc39c 100644 --- a/Content.Server/Nutrition/Components/DrinkComponent.cs +++ b/Content.Server/Nutrition/Components/DrinkComponent.cs @@ -127,8 +127,7 @@ namespace Content.Server.Nutrition.Components if (!Opened) { //Do the opening stuff like playing the sounds. - if(_openSounds.TryGetSound(out var openSound)) - SoundSystem.Play(Filter.Pvs(args.User), openSound, args.User, AudioParams.Default); + SoundSystem.Play(Filter.Pvs(args.User), _openSounds.GetSound(), args.User, AudioParams.Default); Opened = true; return false; @@ -137,7 +136,7 @@ namespace Content.Server.Nutrition.Components if (!Owner.TryGetComponent(out ISolutionInteractionsComponent? contents) || contents.DrainAvailable <= 0) { - args.User.PopupMessage(Loc.GetString("drink-component-on-use-is-empty",("owner", Owner))); + args.User.PopupMessage(Loc.GetString("drink-component-on-use-is-empty", ("owner", Owner))); return true; } @@ -163,14 +162,14 @@ namespace Content.Server.Nutrition.Components } var color = Empty ? "gray" : "yellow"; var openedText = Loc.GetString(Empty ? "drink-component-on-examine-is-empty" : "drink-component-on-examine-is-opened"); - message.AddMarkup(Loc.GetString("drink-component-on-examine-details-text",("colorName", color),("text", openedText))); + message.AddMarkup(Loc.GetString("drink-component-on-examine-details-text", ("colorName", color), ("text", openedText))); } private bool TryUseDrink(IEntity user, IEntity target, bool forced = false) { if (!Opened) { - target.PopupMessage(Loc.GetString("drink-component-try-use-drink-not-open",("owner", Owner))); + target.PopupMessage(Loc.GetString("drink-component-try-use-drink-not-open", ("owner", Owner))); return false; } @@ -180,7 +179,7 @@ namespace Content.Server.Nutrition.Components { if (!forced) { - target.PopupMessage(Loc.GetString("drink-component-try-use-drink-is-empty", ("entity",Owner))); + target.PopupMessage(Loc.GetString("drink-component-try-use-drink-is-empty", ("entity", Owner))); } return false; @@ -189,7 +188,7 @@ namespace Content.Server.Nutrition.Components if (!target.TryGetComponent(out SharedBodyComponent? body) || !body.TryGetMechanismBehaviors(out var stomachs)) { - target.PopupMessage(Loc.GetString("drink-component-try-use-drink-cannot-drink",("owner", Owner))); + target.PopupMessage(Loc.GetString("drink-component-try-use-drink-cannot-drink", ("owner", Owner))); return false; } @@ -207,7 +206,7 @@ namespace Content.Server.Nutrition.Components // All stomach are full or can't handle whatever solution we have. if (firstStomach == null) { - target.PopupMessage(Loc.GetString("drink-component-try-use-drink-had-enough",("owner", Owner))); + target.PopupMessage(Loc.GetString("drink-component-try-use-drink-had-enough", ("owner", Owner))); if (!interactions.CanRefill) { @@ -219,10 +218,7 @@ namespace Content.Server.Nutrition.Components return false; } - if (_useSound.TryGetSound(out var useSound)) - { - SoundSystem.Play(Filter.Pvs(target), useSound, target, AudioParams.Default.WithVolume(-2f)); - } + SoundSystem.Play(Filter.Pvs(target), _useSound.GetSound(), target, AudioParams.Default.WithVolume(-2f)); target.PopupMessage(Loc.GetString("drink-component-try-use-drink-success-slurp")); UpdateAppearance(); @@ -253,8 +249,7 @@ namespace Content.Server.Nutrition.Components var solution = interactions.Drain(interactions.DrainAvailable); solution.SpillAt(Owner, "PuddleSmear"); - if(_burstSound.TryGetSound(out var burstSound)) - SoundSystem.Play(Filter.Pvs(Owner), burstSound, Owner, AudioParams.Default.WithVolume(-4)); + SoundSystem.Play(Filter.Pvs(Owner), _burstSound.GetSound(), Owner, AudioParams.Default.WithVolume(-4)); } } } diff --git a/Content.Server/Nutrition/Components/FoodComponent.cs b/Content.Server/Nutrition/Components/FoodComponent.cs index 8a6afa4ffc..08c9cdbad6 100644 --- a/Content.Server/Nutrition/Components/FoodComponent.cs +++ b/Content.Server/Nutrition/Components/FoodComponent.cs @@ -50,7 +50,7 @@ namespace Content.Server.Nutrition.Components return solution.CurrentVolume == 0 ? 0 - : Math.Max(1, (int)Math.Ceiling((solution.CurrentVolume / TransferAmount).Float())); + : Math.Max(1, (int) Math.Ceiling((solution.CurrentVolume / TransferAmount).Float())); } } @@ -110,7 +110,7 @@ namespace Content.Server.Nutrition.Components } var utensils = utensilUsed != null - ? new List {utensilUsed} + ? new List { utensilUsed } : null; if (_utensilsNeeded != UtensilType.None) @@ -160,10 +160,7 @@ namespace Content.Server.Nutrition.Components firstStomach.TryTransferSolution(split); - if (UseSound.TryGetSound(out var useSound)) - { - SoundSystem.Play(Filter.Pvs(trueTarget), useSound, trueTarget, AudioParams.Default.WithVolume(-1f)); - } + SoundSystem.Play(Filter.Pvs(trueTarget), UseSound.GetSound(), trueTarget, AudioParams.Default.WithVolume(-1f)); trueTarget.PopupMessage(user, Loc.GetString("food-nom")); diff --git a/Content.Server/Nutrition/Components/SliceableFoodComponent.cs b/Content.Server/Nutrition/Components/SliceableFoodComponent.cs index cc1f4502e2..6f707b3daa 100644 --- a/Content.Server/Nutrition/Components/SliceableFoodComponent.cs +++ b/Content.Server/Nutrition/Components/SliceableFoodComponent.cs @@ -24,13 +24,16 @@ namespace Content.Server.Nutrition.Components int IInteractUsing.Priority => 1; // take priority over eating with utensils - [DataField("slice")] [ViewVariables(VVAccess.ReadWrite)] + [DataField("slice")] + [ViewVariables(VVAccess.ReadWrite)] private string _slice = string.Empty; - [DataField("sound")] [ViewVariables(VVAccess.ReadWrite)] + [DataField("sound")] + [ViewVariables(VVAccess.ReadWrite)] private SoundSpecifier _sound = new SoundPathSpecifier("/Audio/Items/Culinary/chop.ogg"); - [DataField("count")] [ViewVariables(VVAccess.ReadWrite)] + [DataField("count")] + [ViewVariables(VVAccess.ReadWrite)] private ushort _totalCount = 5; [ViewVariables(VVAccess.ReadWrite)] public ushort Count; @@ -67,9 +70,8 @@ namespace Content.Server.Nutrition.Components } } - if(_sound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, - AudioParams.Default.WithVolume(-2)); + SoundSystem.Play(Filter.Pvs(Owner), _sound.GetSound(), Owner.Transform.Coordinates, + AudioParams.Default.WithVolume(-2)); Count--; if (Count < 1) diff --git a/Content.Server/Nutrition/Components/UtensilComponent.cs b/Content.Server/Nutrition/Components/UtensilComponent.cs index c31599d193..5275a313ed 100644 --- a/Content.Server/Nutrition/Components/UtensilComponent.cs +++ b/Content.Server/Nutrition/Components/UtensilComponent.cs @@ -71,9 +71,9 @@ namespace Content.Server.Nutrition.Components internal void TryBreak(IEntity user) { - if (_breakSound.TryGetSound(out var breakSound) && IoCManager.Resolve().Prob(_breakChance)) + if (IoCManager.Resolve().Prob(_breakChance)) { - SoundSystem.Play(Filter.Pvs(user), breakSound, user, AudioParams.Default.WithVolume(-2f)); + SoundSystem.Play(Filter.Pvs(user), _breakSound.GetSound(), user, AudioParams.Default.WithVolume(-2f)); Owner.Delete(); } } diff --git a/Content.Server/PDA/PDAComponent.cs b/Content.Server/PDA/PDAComponent.cs index 2c392f91a0..a2ffba3a95 100644 --- a/Content.Server/PDA/PDAComponent.cs +++ b/Content.Server/PDA/PDAComponent.cs @@ -104,49 +104,49 @@ namespace Content.Server.PDA switch (message.Message) { case PDARequestUpdateInterfaceMessage _: - { - UpdatePDAUserInterface(); - break; - } - case PDAToggleFlashlightMessage _: - { - ToggleLight(); - break; - } - - case PDAEjectIDMessage _: - { - HandleIDEjection(message.Session.AttachedEntity!); - break; - } - - case PDAEjectPenMessage _: - { - HandlePenEjection(message.Session.AttachedEntity!); - break; - } - - case PDAUplinkBuyListingMessage buyMsg: - { - var player = message.Session.AttachedEntity; - if (player == null) - break; - - if (!_uplinkManager.TryPurchaseItem(_syndicateUplinkAccount, buyMsg.ItemId, - player.Transform.Coordinates, out var entity)) { - SendNetworkMessage(new PDAUplinkInsufficientFundsMessage(), message.Session.ConnectedClient); + UpdatePDAUserInterface(); + break; + } + case PDAToggleFlashlightMessage _: + { + ToggleLight(); break; } - if (!player.TryGetComponent(out HandsComponent? hands) || !entity.TryGetComponent(out ItemComponent? item)) + case PDAEjectIDMessage _: + { + HandleIDEjection(message.Session.AttachedEntity!); break; + } - hands.PutInHandOrDrop(item); + case PDAEjectPenMessage _: + { + HandlePenEjection(message.Session.AttachedEntity!); + break; + } - SendNetworkMessage(new PDAUplinkBuySuccessMessage(), message.Session.ConnectedClient); - break; - } + case PDAUplinkBuyListingMessage buyMsg: + { + var player = message.Session.AttachedEntity; + if (player == null) + break; + + if (!_uplinkManager.TryPurchaseItem(_syndicateUplinkAccount, buyMsg.ItemId, + player.Transform.Coordinates, out var entity)) + { + SendNetworkMessage(new PDAUplinkInsufficientFundsMessage(), message.Session.ConnectedClient); + break; + } + + if (!player.TryGetComponent(out HandsComponent? hands) || !entity.TryGetComponent(out ItemComponent? item)) + break; + + hands.PutInHandOrDrop(item); + + SendNetworkMessage(new PDAUplinkBuySuccessMessage(), message.Session.ConnectedClient); + break; + } } } @@ -305,8 +305,7 @@ namespace Content.Server.PDA { _idSlot.Insert(card.Owner); ContainedID = card; - if(_insertIdSound.TryGetSound(out var insertIdSound)) - SoundSystem.Play(Filter.Pvs(Owner), insertIdSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), _insertIdSound.GetSound(), Owner); } /// @@ -335,8 +334,7 @@ namespace Content.Server.PDA _lightOn = !_lightOn; light.Enabled = _lightOn; - if(_toggleFlashlightSound.TryGetSound(out var toggleFlashlightSound)) - SoundSystem.Play(Filter.Pvs(Owner), toggleFlashlightSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), _toggleFlashlightSound.GetSound(), Owner); UpdatePDAUserInterface(); } @@ -355,8 +353,7 @@ namespace Content.Server.PDA hands.PutInHandOrDrop(cardItemComponent); ContainedID = null; - if(_ejectIdSound.TryGetSound(out var ejectIdSound)) - SoundSystem.Play(Filter.Pvs(Owner), ejectIdSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), _ejectIdSound.GetSound(), Owner); UpdatePDAUserInterface(); } diff --git a/Content.Server/Physics/Controllers/MoverController.cs b/Content.Server/Physics/Controllers/MoverController.cs index 5c97878c3e..386a79af1f 100644 --- a/Content.Server/Physics/Controllers/MoverController.cs +++ b/Content.Server/Physics/Controllers/MoverController.cs @@ -214,10 +214,9 @@ namespace Content.Server.Physics.Controllers string? soundToPlay = null; foreach (var maybeFootstep in grid.GetAnchoredEntities(tile.GridIndices)) { - if (EntityManager.ComponentManager.TryGetComponent(maybeFootstep, out FootstepModifierComponent? footstep) && - footstep._soundCollection.TryGetSound(out var footstepSound)) + if (EntityManager.ComponentManager.TryGetComponent(maybeFootstep, out FootstepModifierComponent? footstep)) { - soundToPlay = footstepSound; + soundToPlay = footstep.SoundCollection.GetSound(); break; } } @@ -226,11 +225,8 @@ namespace Content.Server.Physics.Controllers { // Walking on a tile. var def = (ContentTileDefinition) _tileDefinitionManager[tile.Tile.TypeId]; - if (def.FootstepSounds.TryGetSound(out var footstepSound)) - { - soundToPlay = footstepSound; - return; - } + soundToPlay = def.FootstepSounds.GetSound(); + return; } if (string.IsNullOrWhiteSpace(soundToPlay)) diff --git a/Content.Server/Plants/Components/PottedPlantHideComponent.cs b/Content.Server/Plants/Components/PottedPlantHideComponent.cs index 2a64e494c4..ecab584ba2 100644 --- a/Content.Server/Plants/Components/PottedPlantHideComponent.cs +++ b/Content.Server/Plants/Components/PottedPlantHideComponent.cs @@ -49,8 +49,7 @@ namespace Content.Server.Plants.Components private void Rustle() { - if(_rustleSound.TryGetSound(out var rustleSound)) - SoundSystem.Play(Filter.Pvs(Owner), rustleSound, Owner, AudioHelpers.WithVariation(0.25f)); + SoundSystem.Play(Filter.Pvs(Owner), _rustleSound.GetSound(), Owner, AudioHelpers.WithVariation(0.25f)); } } } diff --git a/Content.Server/Pointing/Components/RoguePointingArrowComponent.cs b/Content.Server/Pointing/Components/RoguePointingArrowComponent.cs index da3014d516..f800134a8a 100644 --- a/Content.Server/Pointing/Components/RoguePointingArrowComponent.cs +++ b/Content.Server/Pointing/Components/RoguePointingArrowComponent.cs @@ -123,8 +123,7 @@ namespace Content.Server.Pointing.Components } Owner.SpawnExplosion(0, 2, 1, 1); - if(_explosionSound.TryGetSound(out var explosionSound)) - SoundSystem.Play(Filter.Pvs(Owner), explosionSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), _explosionSound.GetSound(), Owner); Owner.Delete(); } diff --git a/Content.Server/Power/Components/ApcComponent.cs b/Content.Server/Power/Components/ApcComponent.cs index 442cdb8756..987dd2c16d 100644 --- a/Content.Server/Power/Components/ApcComponent.cs +++ b/Content.Server/Power/Components/ApcComponent.cs @@ -85,7 +85,7 @@ namespace Content.Server.Power.Components if (serverMsg.Message is ApcToggleMainBreakerMessage) { var user = serverMsg.Session.AttachedEntity; - if(user == null) return; + if (user == null) return; if (_accessReader == null || _accessReader.IsAllowed(user)) { @@ -93,8 +93,7 @@ namespace Content.Server.Power.Components Owner.GetComponent().CanDischarge = MainBreakerEnabled; _uiDirty = true; - if(_onReceiveMessageSound.TryGetSound(out var onReceiveMessageSound)) - SoundSystem.Play(Filter.Pvs(Owner), onReceiveMessageSound, Owner, AudioParams.Default.WithVolume(-2f)); + SoundSystem.Play(Filter.Pvs(Owner), _onReceiveMessageSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f)); } else { diff --git a/Content.Server/PowerCell/Components/PowerCellSlotComponent.cs b/Content.Server/PowerCell/Components/PowerCellSlotComponent.cs index bf8f694779..97decb4d4f 100644 --- a/Content.Server/PowerCell/Components/PowerCellSlotComponent.cs +++ b/Content.Server/PowerCell/Components/PowerCellSlotComponent.cs @@ -144,9 +144,9 @@ namespace Content.Server.PowerCell.Components cell.Owner.Transform.Coordinates = Owner.Transform.Coordinates; } - if (playSound && CellRemoveSound.TryGetSound(out var cellRemoveSound)) + if (playSound) { - SoundSystem.Play(Filter.Pvs(Owner), cellRemoveSound, Owner, AudioHelpers.WithVariation(0.125f)); + SoundSystem.Play(Filter.Pvs(Owner), CellRemoveSound.GetSound(), Owner, AudioHelpers.WithVariation(0.125f)); } Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new PowerCellChangedEvent(true), false); @@ -167,9 +167,9 @@ namespace Content.Server.PowerCell.Components if (cellComponent.CellSize != SlotSize) return false; if (!_cellContainer.Insert(cell)) return false; //Dirty(); - if (playSound && CellInsertSound.TryGetSound(out var cellInsertSound)) + if (playSound) { - SoundSystem.Play(Filter.Pvs(Owner), cellInsertSound, Owner, AudioHelpers.WithVariation(0.125f)); + SoundSystem.Play(Filter.Pvs(Owner), CellInsertSound.GetSound(), Owner, AudioHelpers.WithVariation(0.125f)); } Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new PowerCellChangedEvent(false), false); diff --git a/Content.Server/Projectiles/Components/HitscanComponent.cs b/Content.Server/Projectiles/Components/HitscanComponent.cs index 073ed091e6..721aac12ab 100644 --- a/Content.Server/Projectiles/Components/HitscanComponent.cs +++ b/Content.Server/Projectiles/Components/HitscanComponent.cs @@ -86,8 +86,7 @@ namespace Content.Server.Projectiles.Components // TODO: No wall component so ? var offset = angle.ToVec().Normalized / 2; var coordinates = user.Transform.Coordinates.Offset(offset); - if(_soundHitWall.TryGetSound(out var soundHitWall)) - SoundSystem.Play(Filter.Pvs(coordinates), soundHitWall, coordinates); + SoundSystem.Play(Filter.Pvs(coordinates), _soundHitWall.GetSound(), coordinates); } Owner.SpawnTimer((int) _deathTime.TotalMilliseconds, () => diff --git a/Content.Server/Projectiles/Components/ProjectileComponent.cs b/Content.Server/Projectiles/Components/ProjectileComponent.cs index 64a56ef03a..c22f5038a0 100644 --- a/Content.Server/Projectiles/Components/ProjectileComponent.cs +++ b/Content.Server/Projectiles/Components/ProjectileComponent.cs @@ -26,8 +26,8 @@ namespace Content.Server.Projectiles.Components public bool DeleteOnCollide { get; } = true; // Get that juicy FPS hit sound - [DataField("soundHit")] public SoundSpecifier SoundHit = default!; - [DataField("soundHitSpecies")] public SoundSpecifier SoundHitSpecies = default!; + [DataField("soundHit", required: true)] public SoundSpecifier SoundHit = default!; + [DataField("soundHitSpecies", required: true)] public SoundSpecifier SoundHitSpecies = default!; public bool DamagedEntity; diff --git a/Content.Server/Projectiles/ProjectileSystem.cs b/Content.Server/Projectiles/ProjectileSystem.cs index 76b1b7c32a..d5bf5173a1 100644 --- a/Content.Server/Projectiles/ProjectileSystem.cs +++ b/Content.Server/Projectiles/ProjectileSystem.cs @@ -32,14 +32,13 @@ namespace Content.Server.Projectiles var coordinates = args.OtherFixture.Body.Owner.Transform.Coordinates; var playerFilter = Filter.Pvs(coordinates); - if (!otherEntity.Deleted && - otherEntity.HasComponent() && component.SoundHitSpecies.TryGetSound(out var soundHitSpecies)) + if (!otherEntity.Deleted && otherEntity.HasComponent()) { - SoundSystem.Play(playerFilter, soundHitSpecies, coordinates); + SoundSystem.Play(playerFilter, component.SoundHitSpecies.GetSound(), coordinates); } - else if (component.SoundHit.TryGetSound(out var soundHit)) + else { - SoundSystem.Play(playerFilter, soundHit, coordinates); + SoundSystem.Play(playerFilter, component.SoundHit.GetSound(), coordinates); } if (!otherEntity.Deleted && otherEntity.TryGetComponent(out IDamageableComponent? damage)) diff --git a/Content.Server/RCD/Components/RCDComponent.cs b/Content.Server/RCD/Components/RCDComponent.cs index bde50fec51..3479d667b0 100644 --- a/Content.Server/RCD/Components/RCDComponent.cs +++ b/Content.Server/RCD/Components/RCDComponent.cs @@ -33,7 +33,7 @@ namespace Content.Server.RCD.Components public override string Name => "RCD"; private RcdMode _mode = 0; //What mode are we on? Can be floors, walls, deconstruct. - private readonly RcdMode[] _modes = (RcdMode[]) Enum.GetValues(typeof(RcdMode)); + private readonly RcdMode[] _modes = (RcdMode[]) Enum.GetValues(typeof(RcdMode)); [ViewVariables(VVAccess.ReadWrite)] [DataField("maxAmmo")] public int MaxAmmo = 5; public int _ammo; //How much "ammo" we have left. You can refill this with RCD ammo. [ViewVariables(VVAccess.ReadWrite)] [DataField("delay")] private float _delay = 2f; @@ -77,8 +77,7 @@ namespace Content.Server.RCD.Components public void SwapMode(UseEntityEventArgs eventArgs) { - if(_swapModeSound.TryGetSound(out var swapModeSound)) - SoundSystem.Play(Filter.Pvs(Owner), swapModeSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), _swapModeSound.GetSound(), 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. @@ -104,7 +103,7 @@ namespace Content.Server.RCD.Components } } - async Task IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs) + async Task IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs) { // FIXME: Make this work properly. Right now it relies on the click location being on a grid, which is bad. if (!eventArgs.ClickLocation.IsValid(Owner.EntityManager) || !eventArgs.ClickLocation.GetGridId(Owner.EntityManager).IsValid()) @@ -163,8 +162,7 @@ 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! } - if(_successSound.TryGetSound(out var successSound)) - SoundSystem.Play(Filter.Pvs(Owner), successSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), _successSound.GetSound(), Owner); _ammo--; return true; } diff --git a/Content.Server/Radiation/RadiationPulseComponent.cs b/Content.Server/Radiation/RadiationPulseComponent.cs index e5851f600e..143b5bf87d 100644 --- a/Content.Server/Radiation/RadiationPulseComponent.cs +++ b/Content.Server/Radiation/RadiationPulseComponent.cs @@ -93,8 +93,7 @@ namespace Content.Server.Radiation _endTime = currentTime + TimeSpan.FromSeconds(_duration); } - if(Sound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates); + SoundSystem.Play(Filter.Pvs(Owner), Sound.GetSound(), Owner.Transform.Coordinates); Dirty(); } @@ -109,7 +108,7 @@ namespace Content.Server.Radiation if (!Decay || Owner.Deleted) return; - if(_duration <= 0f) + if (_duration <= 0f) Owner.QueueDelete(); _duration -= frameTime; diff --git a/Content.Server/Research/Components/ResearchConsoleComponent.cs b/Content.Server/Research/Components/ResearchConsoleComponent.cs index 3a94d9a311..7615259fcd 100644 --- a/Content.Server/Research/Components/ResearchConsoleComponent.cs +++ b/Content.Server/Research/Components/ResearchConsoleComponent.cs @@ -125,8 +125,7 @@ namespace Content.Server.Research.Components private void PlayKeyboardSound() { - if (_soundCollectionName.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default); + SoundSystem.Play(Filter.Pvs(Owner), _soundCollectionName.GetSound(), Owner, AudioParams.Default); } } } diff --git a/Content.Server/Singularity/Components/ServerSingularityComponent.cs b/Content.Server/Singularity/Components/ServerSingularityComponent.cs index 9874b82030..9a75e0673a 100644 --- a/Content.Server/Singularity/Components/ServerSingularityComponent.cs +++ b/Content.Server/Singularity/Components/ServerSingularityComponent.cs @@ -89,9 +89,8 @@ namespace Content.Server.Singularity.Components audioParams.Loop = true; audioParams.MaxDistance = 20f; audioParams.Volume = 5; - if(_singularityFormingSound.TryGetSound(out var singuloFormingSound)) - SoundSystem.Play(Filter.Pvs(Owner), singuloFormingSound, Owner); - Timer.Spawn(5200,() => _playingSound = SoundSystem.Play(Filter.Pvs(Owner), _singularitySound.GetSound(), Owner, audioParams)); + SoundSystem.Play(Filter.Pvs(Owner), _singularityFormingSound.GetSound(), Owner); + Timer.Spawn(5200, () => _playingSound = SoundSystem.Play(Filter.Pvs(Owner), _singularitySound.GetSound(), Owner, audioParams)); _singularitySystem.ChangeSingularityLevel(this, 1); } @@ -104,8 +103,7 @@ namespace Content.Server.Singularity.Components protected override void OnRemove() { _playingSound?.Stop(); - if(_singularityCollapsingSound.TryGetSound(out var singuloCollapseSound)) - SoundSystem.Play(Filter.Pvs(Owner), singuloCollapseSound, Owner.Transform.Coordinates); + SoundSystem.Play(Filter.Pvs(Owner), _singularityCollapsingSound.GetSound(), Owner.Transform.Coordinates); base.OnRemove(); } } diff --git a/Content.Server/Slippery/SlipperySystem.cs b/Content.Server/Slippery/SlipperySystem.cs index 278ffc6d10..31fe94ebe5 100644 --- a/Content.Server/Slippery/SlipperySystem.cs +++ b/Content.Server/Slippery/SlipperySystem.cs @@ -9,10 +9,7 @@ namespace Content.Server.Slippery { protected override void PlaySound(SlipperyComponent component) { - if (component.SlipSound.TryGetSound(out var slipSound)) - { - SoundSystem.Play(Filter.Pvs(component.Owner), slipSound, component.Owner, AudioHelpers.WithVariation(0.2f)); - } + SoundSystem.Play(Filter.Pvs(component.Owner), component.SlipSound.GetSound(), component.Owner, AudioHelpers.WithVariation(0.2f)); } } } diff --git a/Content.Server/Sound/Components/BaseEmitSoundComponent.cs b/Content.Server/Sound/Components/BaseEmitSoundComponent.cs index 6b9ee8ff75..ec2e85800c 100644 --- a/Content.Server/Sound/Components/BaseEmitSoundComponent.cs +++ b/Content.Server/Sound/Components/BaseEmitSoundComponent.cs @@ -12,7 +12,7 @@ namespace Content.Server.Sound.Components public abstract class BaseEmitSoundComponent : Component { [ViewVariables(VVAccess.ReadWrite)] - [DataField("sound")] + [DataField("sound", required: true)] public SoundSpecifier Sound { get; set; } = default!; [ViewVariables(VVAccess.ReadWrite)] diff --git a/Content.Server/Sound/EmitSoundSystem.cs b/Content.Server/Sound/EmitSoundSystem.cs index e397d51d01..46b8b9bc8b 100644 --- a/Content.Server/Sound/EmitSoundSystem.cs +++ b/Content.Server/Sound/EmitSoundSystem.cs @@ -7,7 +7,6 @@ using Content.Shared.Throwing; using JetBrains.Annotations; using Robust.Shared.Audio; using Robust.Shared.GameObjects; -using Robust.Shared.Log; using Robust.Shared.Player; namespace Content.Server.Sound @@ -50,14 +49,7 @@ namespace Content.Server.Sound private static void TryEmitSound(BaseEmitSoundComponent component) { - if (component.Sound.TryGetSound(out var sound)) - { - SoundSystem.Play(Filter.Pvs(component.Owner), sound, component.Owner, AudioHelpers.WithVariation(component.PitchVariation).WithVolume(-2f)); - } - else - { - Logger.Warning($"{nameof(component)} Uid:{component.Owner.Uid} has no {nameof(component.Sound)} to play."); - } + SoundSystem.Play(Filter.Pvs(component.Owner), component.Sound.GetSound(), component.Owner, AudioHelpers.WithVariation(component.PitchVariation).WithVolume(-2f)); } } } diff --git a/Content.Server/Storage/Components/CursedEntityStorageComponent.cs b/Content.Server/Storage/Components/CursedEntityStorageComponent.cs index 5b943e5f77..9606dddcd9 100644 --- a/Content.Server/Storage/Components/CursedEntityStorageComponent.cs +++ b/Content.Server/Storage/Components/CursedEntityStorageComponent.cs @@ -17,7 +17,7 @@ namespace Content.Server.Storage.Components [RegisterComponent] public class CursedEntityStorageComponent : EntityStorageComponent { - [Dependency] private readonly IRobustRandom _robustRandom = default!; + [Dependency] private readonly IRobustRandom _robustRandom = default!; public override string Name => "CursedEntityStorage"; @@ -42,7 +42,7 @@ namespace Content.Server.Storage.Components var locker = lockerEnt.GetComponent(); - if(locker.Open) + if (locker.Open) locker.TryCloseStorage(Owner); foreach (var entity in Contents.ContainedEntities.ToArray()) @@ -51,10 +51,8 @@ namespace Content.Server.Storage.Components locker.Insert(entity); } - 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)); + SoundSystem.Play(Filter.Pvs(Owner), _cursedSound.GetSound(), Owner, AudioHelpers.WithVariation(0.125f)); + SoundSystem.Play(Filter.Pvs(lockerEnt), _cursedLockerSound.GetSound(), lockerEnt, AudioHelpers.WithVariation(0.125f)); } } } diff --git a/Content.Server/Storage/Components/EntityStorageComponent.cs b/Content.Server/Storage/Components/EntityStorageComponent.cs index f8b63b6bbd..451d189d59 100644 --- a/Content.Server/Storage/Components/EntityStorageComponent.cs +++ b/Content.Server/Storage/Components/EntityStorageComponent.cs @@ -226,8 +226,7 @@ namespace Content.Server.Storage.Components } ModifyComponents(); - if(_closeSound.TryGetSound(out var closeSound)) - SoundSystem.Play(Filter.Pvs(Owner), closeSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), _closeSound.GetSound(), Owner); _lastInternalOpenAttempt = default; } @@ -236,8 +235,7 @@ namespace Content.Server.Storage.Components Open = true; EmptyContents(); ModifyComponents(); - if(_openSound.TryGetSound(out var openSound)) - SoundSystem.Play(Filter.Pvs(Owner), openSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), _openSound.GetSound(), Owner); } private void UpdateAppearance() diff --git a/Content.Server/Storage/Components/ServerStorageComponent.cs b/Content.Server/Storage/Components/ServerStorageComponent.cs index f96da5ced6..86a4ff89f3 100644 --- a/Content.Server/Storage/Components/ServerStorageComponent.cs +++ b/Content.Server/Storage/Components/ServerStorageComponent.cs @@ -1,18 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; using Content.Server.DoAfter; using Content.Server.Hands.Components; using Content.Server.Items; using Content.Server.Placeable; using Content.Shared.Acts; -using Content.Shared.Audio; using Content.Shared.Interaction; 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; @@ -31,6 +24,11 @@ using Robust.Shared.Player; using Robust.Shared.Players; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; namespace Content.Server.Storage.Components { @@ -66,7 +64,7 @@ namespace Content.Server.Storage.Components public readonly HashSet SubscribedSessions = new(); [DataField("storageSoundCollection")] - public SoundSpecifier StorageSoundCollection { get; set; } = default!; + public SoundSpecifier StorageSoundCollection { get; set; } = new SoundCollectionSpecifier("storageRustle"); [ViewVariables] public override IReadOnlyList? StoredEntities => _storage?.ContainedEntities; @@ -389,79 +387,79 @@ namespace Content.Server.Storage.Components switch (message) { case RemoveEntityMessage remove: - { - EnsureInitialCalculated(); - - var player = session.AttachedEntity; - - if (player == null) { + EnsureInitialCalculated(); + + var player = session.AttachedEntity; + + if (player == null) + { + break; + } + + var ownerTransform = Owner.Transform; + var playerTransform = player.Transform; + + if (!playerTransform.Coordinates.InRange(Owner.EntityManager, ownerTransform.Coordinates, 2) || + !ownerTransform.IsMapTransform && + !playerTransform.ContainsEntity(ownerTransform)) + { + break; + } + + var entity = Owner.EntityManager.GetEntity(remove.EntityUid); + + if (entity == null || _storage?.Contains(entity) == false) + { + break; + } + + var item = entity.GetComponent(); + if (item == null || + !player.TryGetComponent(out HandsComponent? hands)) + { + break; + } + + if (!hands.CanPutInHand(item)) + { + break; + } + + hands.PutInHand(item); + break; } - - var ownerTransform = Owner.Transform; - var playerTransform = player.Transform; - - if (!playerTransform.Coordinates.InRange(Owner.EntityManager, ownerTransform.Coordinates, 2) || - !ownerTransform.IsMapTransform && - !playerTransform.ContainsEntity(ownerTransform)) - { - break; - } - - var entity = Owner.EntityManager.GetEntity(remove.EntityUid); - - if (entity == null || _storage?.Contains(entity) == false) - { - break; - } - - var item = entity.GetComponent(); - if (item == null || - !player.TryGetComponent(out HandsComponent? hands)) - { - break; - } - - if (!hands.CanPutInHand(item)) - { - break; - } - - hands.PutInHand(item); - - break; - } case InsertEntityMessage _: - { - EnsureInitialCalculated(); - - var player = session.AttachedEntity; - - if (player == null) { + EnsureInitialCalculated(); + + var player = session.AttachedEntity; + + if (player == null) + { + break; + } + + if (!player.InRangeUnobstructed(Owner, popup: true)) + { + break; + } + + PlayerInsertHeldEntity(player); + break; } - - if (!player.InRangeUnobstructed(Owner, popup: true)) - { - break; - } - - PlayerInsertHeldEntity(player); - - break; - } case CloseStorageUIMessage _: - { - if (session is not IPlayerSession playerSession) { + if (session is not IPlayerSession playerSession) + { + break; + } + + UnsubscribeSession(playerSession); break; } - - UnsubscribeSession(playerSession); - break; - } } } @@ -511,7 +509,7 @@ namespace Content.Server.Storage.Components // Pick up all entities in a radius around the clicked location. // The last half of the if is because carpets exist and this is terrible - if(_areaInsert && (eventArgs.Target == null || !eventArgs.Target.HasComponent())) + if (_areaInsert && (eventArgs.Target == null || !eventArgs.Target.HasComponent())) { var validStorables = new List(); foreach (var entity in IoCManager.Resolve().GetEntitiesInRange(eventArgs.ClickLocation, 1)) @@ -556,7 +554,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) + if (successfullyInserted.Count > 0) { PlaySoundCollection(); SendNetworkMessage( @@ -569,7 +567,7 @@ namespace Content.Server.Storage.Components return true; } // Pick up the clicked entity - else if(_quickInsert) + else if (_quickInsert) { if (eventArgs.Target == null || !eventArgs.Target.Transform.IsMapTransform @@ -577,7 +575,7 @@ namespace Content.Server.Storage.Components || !eventArgs.Target.HasComponent()) return false; var position = eventArgs.Target.Transform.Coordinates; - if(PlayerInsertEntityInWorld(eventArgs.User, eventArgs.Target)) + if (PlayerInsertEntityInWorld(eventArgs.User, eventArgs.Target)) { SendNetworkMessage(new AnimateInsertingEntitiesMessage( new List() { eventArgs.Target.Uid }, @@ -631,9 +629,7 @@ namespace Content.Server.Storage.Components private void PlaySoundCollection() { - // TODO this doesn't compile or work - if(StorageSoundCollection?.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default); + SoundSystem.Play(Filter.Pvs(Owner), StorageSoundCollection.GetSound(), Owner, AudioParams.Default); } } } diff --git a/Content.Server/Storage/Components/SpawnItemsOnUseComponent.cs b/Content.Server/Storage/Components/SpawnItemsOnUseComponent.cs index 0956e8a5f3..fcf203137d 100644 --- a/Content.Server/Storage/Components/SpawnItemsOnUseComponent.cs +++ b/Content.Server/Storage/Components/SpawnItemsOnUseComponent.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Content.Shared.Sound; using Robust.Shared.GameObjects; using Robust.Shared.Serialization.Manager.Attributes; @@ -23,7 +23,7 @@ namespace Content.Server.Storage.Components /// /// A sound to play when the items are spawned. For example, gift boxes being unwrapped. /// - [DataField("sound")] + [DataField("sound", required: true)] public SoundSpecifier? Sound = null; /// diff --git a/Content.Server/Stunnable/Components/StunnableComponent.cs b/Content.Server/Stunnable/Components/StunnableComponent.cs index b799f267bf..da72ca145b 100644 --- a/Content.Server/Stunnable/Components/StunnableComponent.cs +++ b/Content.Server/Stunnable/Components/StunnableComponent.cs @@ -29,7 +29,7 @@ namespace Content.Server.Stunnable.Components protected override void OnKnockdownEnd() { - if(Owner.TryGetComponent(out IMobStateComponent? mobState) && !mobState.IsIncapacitated()) + if (Owner.TryGetComponent(out IMobStateComponent? mobState) && !mobState.IsIncapacitated()) EntitySystem.Get().Stand(Owner); } @@ -57,8 +57,7 @@ namespace Content.Server.Stunnable.Components protected override void OnInteractHand() { - if(_stunAttemptSound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioHelpers.WithVariation(0.05f)); + SoundSystem.Play(Filter.Pvs(Owner), _stunAttemptSound.GetSound(), Owner, AudioHelpers.WithVariation(0.05f)); } bool IDisarmedAct.Disarmed(DisarmedActEventArgs eventArgs) @@ -73,12 +72,11 @@ namespace Content.Server.Stunnable.Components if (source != null) { - if (_stunAttemptSound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(source), sound, source, AudioHelpers.WithVariation(0.025f)); + SoundSystem.Play(Filter.Pvs(source), _stunAttemptSound.GetSound(), source, AudioHelpers.WithVariation(0.025f)); if (target != null) { - source.PopupMessageOtherClients(Loc.GetString("stunnable-component-disarm-success-others", ("source", source.Name),("target", target.Name))); - source.PopupMessageCursor(Loc.GetString("stunnable-component-disarm-success",("target", target.Name))); + source.PopupMessageOtherClients(Loc.GetString("stunnable-component-disarm-success-others", ("source", source.Name), ("target", target.Name))); + source.PopupMessageCursor(Loc.GetString("stunnable-component-disarm-success", ("target", target.Name))); } } diff --git a/Content.Server/Stunnable/StunbatonSystem.cs b/Content.Server/Stunnable/StunbatonSystem.cs index fc705d77a0..61f690b31b 100644 --- a/Content.Server/Stunnable/StunbatonSystem.cs +++ b/Content.Server/Stunnable/StunbatonSystem.cs @@ -119,18 +119,17 @@ namespace Content.Server.Stunnable { if (!entity.TryGetComponent(out StunnableComponent? stunnable) || !comp.Activated) return; - if(comp.StunSound.TryGetSound(out var stunSound)) - SoundSystem.Play(Filter.Pvs(comp.Owner), stunSound, comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); - if(!stunnable.SlowedDown) + SoundSystem.Play(Filter.Pvs(comp.Owner), comp.StunSound.GetSound(), comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); + if (!stunnable.SlowedDown) { - if(_robustRandom.Prob(comp.ParalyzeChanceNoSlowdown)) + if (_robustRandom.Prob(comp.ParalyzeChanceNoSlowdown)) stunnable.Paralyze(comp.ParalyzeTime); else stunnable.Slowdown(comp.SlowdownTime); } else { - if(_robustRandom.Prob(comp.ParalyzeChanceWithSlowdown)) + if (_robustRandom.Prob(comp.ParalyzeChanceWithSlowdown)) stunnable.Paralyze(comp.ParalyzeTime); else stunnable.Slowdown(comp.SlowdownTime); @@ -140,8 +139,7 @@ namespace Content.Server.Stunnable if (!comp.Owner.TryGetComponent(out var slot) || slot.Cell == null || !(slot.Cell.CurrentCharge < comp.EnergyPerUse)) return; - if(comp.SparksSound.TryGetSound(out var sparksSound)) - SoundSystem.Play(Filter.Pvs(comp.Owner), sparksSound, comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); + SoundSystem.Play(Filter.Pvs(comp.Owner), comp.SparksSound.GetSound(), comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); TurnOff(comp); } @@ -155,8 +153,7 @@ namespace Content.Server.Stunnable if (!comp.Owner.TryGetComponent(out var sprite) || !comp.Owner.TryGetComponent(out var item)) return; - if(comp.SparksSound.TryGetSound(out var sparksSound)) - SoundSystem.Play(Filter.Pvs(comp.Owner), sparksSound, comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); + SoundSystem.Play(Filter.Pvs(comp.Owner), comp.SparksSound.GetSound(), comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); item.EquippedPrefix = "off"; // TODO stunbaton visualizer sprite.LayerSetState(0, "stunbaton_off"); @@ -180,22 +177,19 @@ namespace Content.Server.Stunnable if (slot.Cell == null) { - if(comp.TurnOnFailSound.TryGetSound(out var turnOnFailSound)) - SoundSystem.Play(playerFilter, turnOnFailSound, comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); + SoundSystem.Play(playerFilter, comp.TurnOnFailSound.GetSound(), comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); user.PopupMessage(Loc.GetString("comp-stunbaton-activated-missing-cell")); return; } if (slot.Cell != null && slot.Cell.CurrentCharge < comp.EnergyPerUse) { - if(comp.TurnOnFailSound.TryGetSound(out var turnOnFailSound)) - SoundSystem.Play(playerFilter, turnOnFailSound, comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); + SoundSystem.Play(playerFilter, comp.TurnOnFailSound.GetSound(), comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); user.PopupMessage(Loc.GetString("comp-stunbaton-activated-dead-cell")); return; } - if(comp.SparksSound.TryGetSound(out var sparksSound)) - SoundSystem.Play(playerFilter, sparksSound, comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); + SoundSystem.Play(playerFilter, comp.SparksSound.GetSound(), comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); item.EquippedPrefix = "on"; sprite.LayerSetState(0, "stunbaton_on"); diff --git a/Content.Server/Tiles/FloorTileItemComponent.cs b/Content.Server/Tiles/FloorTileItemComponent.cs index 6399fadc63..4cb9b5de34 100644 --- a/Content.Server/Tiles/FloorTileItemComponent.cs +++ b/Content.Server/Tiles/FloorTileItemComponent.cs @@ -23,7 +23,7 @@ namespace Content.Server.Tiles [Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!; public override string Name => "FloorTile"; - [DataField("outputs", customTypeSerializer:typeof(PrototypeIdListSerializer))] + [DataField("outputs", customTypeSerializer: typeof(PrototypeIdListSerializer))] private List? _outputTiles; [DataField("placeTileSound")] SoundSpecifier _placeTileSound = new SoundPathSpecifier("/Audio/Items/genhit.ogg"); @@ -50,8 +50,7 @@ namespace Content.Server.Tiles private void PlaceAt(IMapGrid mapGrid, EntityCoordinates location, ushort tileId, float offset = 0) { mapGrid.SetTile(location.Offset(new Vector2(offset, offset)), new Tile(tileId)); - if(_placeTileSound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(location), sound, location, AudioHelpers.WithVariation(0.125f)); + SoundSystem.Play(Filter.Pvs(location), _placeTileSound.GetSound(), location, AudioHelpers.WithVariation(0.125f)); } async Task IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs) diff --git a/Content.Server/Toilet/ToiletComponent.cs b/Content.Server/Toilet/ToiletComponent.cs index 2d9e3a069c..f010ced8e9 100644 --- a/Content.Server/Toilet/ToiletComponent.cs +++ b/Content.Server/Toilet/ToiletComponent.cs @@ -130,8 +130,7 @@ namespace Content.Server.Toilet public void ToggleToiletSeat() { IsSeatUp = !IsSeatUp; - if(_toggleSound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioHelpers.WithVariation(0.05f)); + SoundSystem.Play(Filter.Pvs(Owner), _toggleSound.GetSound(), Owner, AudioHelpers.WithVariation(0.05f)); UpdateSprite(); } diff --git a/Content.Server/Tools/Components/MultitoolComponent.cs b/Content.Server/Tools/Components/MultitoolComponent.cs index 1fedb20e80..ecc6289ff4 100644 --- a/Content.Server/Tools/Components/MultitoolComponent.cs +++ b/Content.Server/Tools/Components/MultitoolComponent.cs @@ -33,10 +33,10 @@ namespace Content.Server.Tools.Components [DataField("sprite")] public string Sprite { get; } = string.Empty; - [DataField("useSound")] + [DataField("useSound", required: true)] public SoundSpecifier Sound { get; } = default!; - [DataField("changeSound")] + [DataField("changeSound", required: true)] public SoundSpecifier ChangeSound { get; } = default!; } @@ -60,8 +60,7 @@ namespace Content.Server.Tools.Components _currentTool = (_currentTool + 1) % _tools.Count; SetTool(); var current = _tools[_currentTool]; - if(current.ChangeSound.TryGetSound(out var changeSound)) - SoundSystem.Play(Filter.Pvs(Owner), changeSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), current.ChangeSound.GetSound(), Owner); } private void SetTool() diff --git a/Content.Server/Tools/Components/ToolComponent.cs b/Content.Server/Tools/Components/ToolComponent.cs index 9213c1877c..be65dd3ff4 100644 --- a/Content.Server/Tools/Components/ToolComponent.cs +++ b/Content.Server/Tools/Components/ToolComponent.cs @@ -44,7 +44,7 @@ namespace Content.Server.Tools.Components [DataField("speed")] public float SpeedModifier { get; set; } = 1; - [DataField("useSound")] + [DataField("useSound", required: true)] public SoundSpecifier UseSound { get; set; } = default!; public void AddQuality(ToolQuality quality) @@ -96,8 +96,7 @@ namespace Content.Server.Tools.Components public void PlayUseSound(float volume = -5f) { - if(UseSound.TryGetSound(out var useSound)) - SoundSystem.Play(Filter.Pvs(Owner), useSound, Owner, AudioHelpers.WithVariation(0.15f).WithVolume(volume)); + SoundSystem.Play(Filter.Pvs(Owner), UseSound.GetSound(), Owner, AudioHelpers.WithVariation(0.15f).WithVolume(volume)); } } } diff --git a/Content.Server/Tools/Components/WelderComponent.cs b/Content.Server/Tools/Components/WelderComponent.cs index ad8cc9cc0f..2faf2a0d96 100644 --- a/Content.Server/Tools/Components/WelderComponent.cs +++ b/Content.Server/Tools/Components/WelderComponent.cs @@ -60,7 +60,7 @@ namespace Content.Server.Tools.Components private SolutionContainerComponent? _solutionComponent; private PointLightComponent? _pointLightComponent; - [DataField("weldSounds")] + [DataField("weldSounds", required: true)] private SoundSpecifier WeldSounds { get; set; } = default!; [DataField("welderOffSounds")] @@ -171,9 +171,9 @@ namespace Content.Server.Tools.Components var succeeded = _solutionComponent.TryRemoveReagent("WeldingFuel", ReagentUnit.New(value)); - if (succeeded && !silent && WeldSounds.TryGetSound(out var weldSounds)) + if (succeeded && !silent) { - PlaySound(weldSounds); + PlaySound(WeldSounds); } return succeeded; } @@ -204,8 +204,7 @@ namespace Content.Server.Tools.Components if (_pointLightComponent != null) _pointLightComponent.Enabled = false; - if(WelderOffSounds.TryGetSound(out var welderOffSOunds)) - PlaySound(welderOffSOunds, -5); + PlaySound(WelderOffSounds, -5); _welderSystem.Unsubscribe(this); return true; } @@ -222,8 +221,7 @@ namespace Content.Server.Tools.Components if (_pointLightComponent != null) _pointLightComponent.Enabled = true; - if (WelderOnSounds.TryGetSound(out var welderOnSOunds)) - PlaySound(welderOnSOunds, -5); + PlaySound(WelderOnSounds, -5); _welderSystem.Subscribe(this); EntitySystem.Get().HotspotExpose(Owner.Transform.Coordinates, 700, 50, true); @@ -283,8 +281,7 @@ namespace Content.Server.Tools.Components if (TryWeld(5, victim, silent: true)) { - if(WeldSounds.TryGetSound(out var weldSound)) - PlaySound(weldSound); + PlaySound(WeldSounds); othersMessage = Loc.GetString("welder-component-suicide-lit-others-message", @@ -337,8 +334,7 @@ namespace Content.Server.Tools.Components { var drained = targetSolution.Drain(trans); _solutionComponent.TryAddSolution(drained); - if(WelderRefill.TryGetSound(out var welderRefillSound)) - SoundSystem.Play(Filter.Pvs(Owner), welderRefillSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), WelderRefill.GetSound(), Owner); eventArgs.Target.PopupMessage(eventArgs.User, Loc.GetString("welder-component-after-interact-refueled-message")); } } @@ -346,9 +342,9 @@ namespace Content.Server.Tools.Components return true; } - private void PlaySound(string soundName, float volume = -5f) + private void PlaySound(SoundSpecifier sound, float volume = -5f) { - SoundSystem.Play(Filter.Pvs(Owner), soundName, Owner, AudioHelpers.WithVariation(0.15f).WithVolume(volume)); + SoundSystem.Play(Filter.Pvs(Owner), sound.GetSound(), Owner, AudioHelpers.WithVariation(0.15f).WithVolume(volume)); } } } diff --git a/Content.Server/VendingMachines/VendingMachineComponent.cs b/Content.Server/VendingMachines/VendingMachineComponent.cs index 6914978eb7..d021cc5018 100644 --- a/Content.Server/VendingMachines/VendingMachineComponent.cs +++ b/Content.Server/VendingMachines/VendingMachineComponent.cs @@ -202,8 +202,7 @@ namespace Content.Server.VendingMachines Owner.EntityManager.SpawnEntity(id, Owner.Transform.Coordinates); }); - if(_soundVend.TryGetSound(out var soundVend)) - SoundSystem.Play(Filter.Pvs(Owner), soundVend, Owner, AudioParams.Default.WithVolume(-2f)); + SoundSystem.Play(Filter.Pvs(Owner), _soundVend.GetSound(), Owner, AudioParams.Default.WithVolume(-2f)); } private void TryEject(string id, IEntity? sender) @@ -222,8 +221,7 @@ namespace Content.Server.VendingMachines private void Deny() { - if(_soundDeny.TryGetSound(out var soundDeny)) - SoundSystem.Play(Filter.Pvs(Owner), soundDeny, Owner, AudioParams.Default.WithVolume(-2f)); + SoundSystem.Play(Filter.Pvs(Owner), _soundDeny.GetSound(), Owner, AudioParams.Default.WithVolume(-2f)); // Play the Deny animation TrySetVisualState(VendingMachineVisualState.Deny); diff --git a/Content.Server/Weapon/Melee/MeleeWeaponSystem.cs b/Content.Server/Weapon/Melee/MeleeWeaponSystem.cs index a4de423800..73b26b878a 100644 --- a/Content.Server/Weapon/Melee/MeleeWeaponSystem.cs +++ b/Content.Server/Weapon/Melee/MeleeWeaponSystem.cs @@ -78,12 +78,12 @@ namespace Content.Server.Weapon.Melee if (target != null) { // Raise event before doing damage so we can cancel damage if the event is handled - var hitEvent = new MeleeHitEvent(new List() {target}, args.User); + var hitEvent = new MeleeHitEvent(new List() { target }, args.User); RaiseLocalEvent(uid, hitEvent, false); if (!hitEvent.Handled) { - var targets = new[] {target}; + var targets = new[] { target }; SendAnimation(comp.ClickArc, angle, args.User, owner, targets, comp.ClickAttackEffect, false); if (target.TryGetComponent(out IDamageableComponent? damageableComponent)) @@ -91,14 +91,12 @@ namespace Content.Server.Weapon.Melee damageableComponent.ChangeDamage(comp.DamageType, comp.Damage, false, owner); } - if(comp.HitSound.TryGetSound(out var hitSound)) - SoundSystem.Play(Filter.Pvs(owner), hitSound, target); + SoundSystem.Play(Filter.Pvs(owner), comp.HitSound.GetSound(), target); } } else { - if(comp.MissSound.TryGetSound(out var missSound)) - SoundSystem.Play(Filter.Pvs(owner), missSound, args.User); + SoundSystem.Play(Filter.Pvs(owner), comp.MissSound.GetSound(), args.User); return; } @@ -148,13 +146,11 @@ namespace Content.Server.Weapon.Melee { if (entities.Count != 0) { - if(comp.HitSound.TryGetSound(out var hitSound)) - SoundSystem.Play(Filter.Pvs(owner), hitSound, entities.First().Transform.Coordinates); + SoundSystem.Play(Filter.Pvs(owner), comp.HitSound.GetSound(), entities.First().Transform.Coordinates); } else { - if(comp.MissSound.TryGetSound(out var missSound)) - SoundSystem.Play(Filter.Pvs(owner), missSound, args.User.Transform.Coordinates); + SoundSystem.Play(Filter.Pvs(owner), comp.MissSound.GetSound(), args.User.Transform.Coordinates); } foreach (var entity in hitEntities) diff --git a/Content.Server/Weapon/Ranged/Barrels/Components/BoltActionBarrelComponent.cs b/Content.Server/Weapon/Ranged/Barrels/Components/BoltActionBarrelComponent.cs index 34369505b7..cd0c089371 100644 --- a/Content.Server/Weapon/Ranged/Barrels/Components/BoltActionBarrelComponent.cs +++ b/Content.Server/Weapon/Ranged/Barrels/Components/BoltActionBarrelComponent.cs @@ -75,18 +75,12 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components if (value) { TryEjectChamber(); - if (_soundBoltOpen.TryGetSound(out var soundBoltOpen)) - { - SoundSystem.Play(Filter.Pvs(Owner), soundBoltOpen, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundBoltOpen.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } else { TryFeedChamber(); - if (_soundBoltClosed.TryGetSound(out var soundBoltClosed)) - { - SoundSystem.Play(Filter.Pvs(Owner), soundBoltClosed, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundBoltClosed.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } _boltOpen = value; @@ -102,7 +96,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components // Sounds [DataField("soundCycle")] - private SoundSpecifier _soundCycle = new SoundPathSpecifier( "/Audio/Weapons/Guns/Cock/sf_rifle_cock.ogg"); + private SoundSpecifier _soundCycle = new SoundPathSpecifier("/Audio/Weapons/Guns/Cock/sf_rifle_cock.ogg"); [DataField("soundBoltOpen")] private SoundSpecifier _soundBoltOpen = new SoundPathSpecifier("/Audio/Weapons/Guns/Bolt/rifle_bolt_open.ogg"); [DataField("soundBoltClosed")] @@ -225,10 +219,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components } else { - if (_soundCycle.TryGetSound(out var soundCycle)) - { - SoundSystem.Play(Filter.Pvs(Owner), soundCycle, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundCycle.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } Dirty(); @@ -257,10 +248,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components if (_chamberContainer.ContainedEntity == null) { _chamberContainer.Insert(ammo); - if (_soundInsert.TryGetSound(out var soundInsert)) - { - SoundSystem.Play(Filter.Pvs(Owner), soundInsert, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundInsert.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); Dirty(); UpdateAppearance(); return true; @@ -270,10 +258,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components { _ammoContainer.Insert(ammo); _spawnedAmmo.Push(ammo); - if (_soundInsert.TryGetSound(out var soundInsert)) - { - SoundSystem.Play(Filter.Pvs(Owner), soundInsert, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundInsert.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); Dirty(); UpdateAppearance(); return true; @@ -347,7 +332,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components { base.Examine(message, inDetailsRange); - message.AddMarkup("\n" + Loc.GetString("bolt-action-barrel-component-on-examine", ("caliber",_caliber))); + message.AddMarkup("\n" + Loc.GetString("bolt-action-barrel-component-on-examine", ("caliber", _caliber))); } [Verb] diff --git a/Content.Server/Weapon/Ranged/Barrels/Components/PumpBarrelComponent.cs b/Content.Server/Weapon/Ranged/Barrels/Components/PumpBarrelComponent.cs index 348db086db..41e12042d4 100644 --- a/Content.Server/Weapon/Ranged/Barrels/Components/PumpBarrelComponent.cs +++ b/Content.Server/Weapon/Ranged/Barrels/Components/PumpBarrelComponent.cs @@ -46,7 +46,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components // Even a point having a chamber? I guess it makes some of the below code cleaner private ContainerSlot _chamberContainer = default!; - private Stack _spawnedAmmo = new (DefaultCapacity-1); + private Stack _spawnedAmmo = new(DefaultCapacity - 1); private Container _ammoContainer = default!; [ViewVariables] @@ -190,10 +190,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components if (manual) { - if (_soundCycle.TryGetSound(out var sound)) - { - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundCycle.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } Dirty(); @@ -219,10 +216,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components _spawnedAmmo.Push(eventArgs.Using); Dirty(); UpdateAppearance(); - if (_soundInsert.TryGetSound(out var soundInsert)) - { - SoundSystem.Play(Filter.Pvs(Owner), soundInsert, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundInsert.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); return true; } @@ -246,7 +240,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components { base.Examine(message, inDetailsRange); - message.AddMarkup("\n" + Loc.GetString("pump-barrel-component-on-examine",("caliber", _caliber))); + message.AddMarkup("\n" + Loc.GetString("pump-barrel-component-on-examine", ("caliber", _caliber))); } } } diff --git a/Content.Server/Weapon/Ranged/Barrels/Components/RevolverBarrelComponent.cs b/Content.Server/Weapon/Ranged/Barrels/Components/RevolverBarrelComponent.cs index ed38699ee1..d02f8d6f97 100644 --- a/Content.Server/Weapon/Ranged/Barrels/Components/RevolverBarrelComponent.cs +++ b/Content.Server/Weapon/Ranged/Barrels/Components/RevolverBarrelComponent.cs @@ -165,10 +165,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components _currentSlot = i; _ammoSlots[i] = entity; _ammoContainer.Insert(entity); - if (_soundInsert.TryGetSound(out var sound)) - { - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundInsert.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); Dirty(); UpdateAppearance(); @@ -195,10 +192,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components { var random = _random.Next(_ammoSlots.Length - 1); _currentSlot = random; - if (_soundSpin.TryGetSound(out var sound)) - { - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundSpin.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); Dirty(); } @@ -249,10 +243,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components if (_ammoContainer.ContainedEntities.Count > 0) { - if (_soundEject.TryGetSound(out var sound)) - { - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-1)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundEject.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-1)); } // May as well point back at the end? diff --git a/Content.Server/Weapon/Ranged/Barrels/Components/ServerBatteryBarrelComponent.cs b/Content.Server/Weapon/Ranged/Barrels/Components/ServerBatteryBarrelComponent.cs index 5104100622..1b17844992 100644 --- a/Content.Server/Weapon/Ranged/Barrels/Components/ServerBatteryBarrelComponent.cs +++ b/Content.Server/Weapon/Ranged/Barrels/Components/ServerBatteryBarrelComponent.cs @@ -83,9 +83,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components private AppearanceComponent? _appearanceComponent; // Sounds - [DataField("soundPowerCellInsert")] + [DataField("soundPowerCellInsert", required: true)] private SoundSpecifier _soundPowerCellInsert = default!; - [DataField("soundPowerCellEject")] + [DataField("soundPowerCellEject", required: true)] private SoundSpecifier _soundPowerCellEject = default!; public override ComponentState GetComponentState(ICommonSession player) @@ -223,10 +223,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components return false; } - if (_soundPowerCellInsert.TryGetSound(out var sound)) - { - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundPowerCellInsert.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); _powerCellContainer.Insert(entity); @@ -276,10 +273,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components cell.Owner.Transform.Coordinates = user.Transform.Coordinates; } - if (_soundPowerCellEject.TryGetSound(out var sound)) - { - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundPowerCellEject.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); return true; } diff --git a/Content.Server/Weapon/Ranged/Barrels/Components/ServerMagazineBarrelComponent.cs b/Content.Server/Weapon/Ranged/Barrels/Components/ServerMagazineBarrelComponent.cs index 429c5d5b65..fbc6d4fed7 100644 --- a/Content.Server/Weapon/Ranged/Barrels/Components/ServerMagazineBarrelComponent.cs +++ b/Content.Server/Weapon/Ranged/Barrels/Components/ServerMagazineBarrelComponent.cs @@ -98,18 +98,12 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components if (value) { TryEjectChamber(); - if (_soundBoltOpen.TryGetSound(out var soundBoltOpen)) - { - SoundSystem.Play(Filter.Pvs(Owner), soundBoltOpen, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundBoltOpen.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } else { TryFeedChamber(); - if (_soundBoltClosed.TryGetSound(out var soundBoltClosed)) - { - SoundSystem.Play(Filter.Pvs(Owner), soundBoltClosed, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundBoltClosed.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } _boltOpen = value; @@ -129,17 +123,17 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components private AppearanceComponent? _appearanceComponent; // Sounds - [DataField("soundBoltOpen")] + [DataField("soundBoltOpen", required: true)] private SoundSpecifier _soundBoltOpen = default!; - [DataField("soundBoltClosed")] + [DataField("soundBoltClosed", required: true)] private SoundSpecifier _soundBoltClosed = default!; - [DataField("soundRack")] + [DataField("soundRack", required: true)] private SoundSpecifier _soundRack = default!; - [DataField("soundMagInsert")] + [DataField("soundMagInsert", required: true)] private SoundSpecifier _soundMagInsert = default!; - [DataField("soundMagEject")] + [DataField("soundMagEject", required: true)] private SoundSpecifier _soundMagEject = default!; - [DataField("soundAutoEject")] + [DataField("soundAutoEject", required: true)] private SoundSpecifier _soundAutoEject = new SoundPathSpecifier("/Audio/Weapons/Guns/EmptyAlarm/smg_empty_alarm.ogg"); private List GetMagazineTypes() @@ -229,10 +223,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components if (_chamberContainer.ContainedEntity == null && !BoltOpen) { - if (_soundBoltOpen.TryGetSound(out var soundBoltOpen)) - { - SoundSystem.Play(Filter.Pvs(Owner), soundBoltOpen, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-5)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundBoltOpen.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-5)); if (Owner.TryGetContainer(out var container)) { @@ -244,10 +235,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components if (manual) { - if (_soundRack.TryGetSound(out var soundRack)) - { - SoundSystem.Play(Filter.Pvs(Owner), soundRack, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundRack.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } Dirty(); @@ -272,10 +260,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components if (BoltOpen) { - if (_soundBoltClosed.TryGetSound(out var soundBoltClosed)) - { - SoundSystem.Play(Filter.Pvs(Owner), soundBoltClosed, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-5)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundBoltClosed.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-5)); Owner.PopupMessage(eventArgs.User, Loc.GetString("server-magazine-barrel-component-use-entity-bolt-closed")); BoltOpen = false; return true; @@ -326,10 +311,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components if (_autoEjectMag && magazine != null && magazine.GetComponent().ShotsLeft == 0) { - if (_soundAutoEject.TryGetSound(out var soundAutoEject)) - { - SoundSystem.Play(Filter.Pvs(Owner), soundAutoEject, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundAutoEject.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); _magazineContainer.Remove(magazine); SendNetworkMessage(new MagazineAutoEjectMessage()); @@ -353,10 +335,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components } _magazineContainer.Remove(mag); - if (_soundMagEject.TryGetSound(out var soundMagEject)) - { - SoundSystem.Play(Filter.Pvs(Owner), soundMagEject, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundMagEject.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); if (user.TryGetComponent(out HandsComponent? handsComponent)) { @@ -392,10 +371,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components if (_magazineContainer.ContainedEntity == null) { - if (_soundMagInsert.TryGetSound(out var soundMagInsert)) - { - SoundSystem.Play(Filter.Pvs(Owner), soundMagInsert, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundMagInsert.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); Owner.PopupMessage(eventArgs.User, Loc.GetString("server-magazine-barrel-component-interact-using-success")); _magazineContainer.Insert(eventArgs.Using); Dirty(); @@ -442,11 +418,11 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components { base.Examine(message, inDetailsRange); - message.AddMarkup("\n" + Loc.GetString("server-magazine-barrel-component-on-examine", ("caliber",Caliber))); + message.AddMarkup("\n" + Loc.GetString("server-magazine-barrel-component-on-examine", ("caliber", Caliber))); foreach (var magazineType in GetMagazineTypes()) { - message.AddMarkup("\n" + Loc.GetString("server-magazine-barrel-component-on-examine-magazine-type",("magazineType", magazineType))); + message.AddMarkup("\n" + Loc.GetString("server-magazine-barrel-component-on-examine-magazine-type", ("magazineType", magazineType))); } } diff --git a/Content.Server/Weapon/Ranged/Barrels/Components/ServerRangedBarrelComponent.cs b/Content.Server/Weapon/Ranged/Barrels/Components/ServerRangedBarrelComponent.cs index 4ab245d7d9..0a588126b6 100644 --- a/Content.Server/Weapon/Ranged/Barrels/Components/ServerRangedBarrelComponent.cs +++ b/Content.Server/Weapon/Ranged/Barrels/Components/ServerRangedBarrelComponent.cs @@ -97,7 +97,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components public bool CanMuzzleFlash { get; } = true; // Sounds - [DataField("soundGunshot")] + [DataField("soundGunshot", required: true)] public SoundSpecifier SoundGunshot { get; set; } = default!; [DataField("soundEmpty")] @@ -197,10 +197,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components { if (ShotsLeft == 0) { - if (SoundEmpty.TryGetSound(out var sound)) - { - SoundSystem.Play(Filter.Broadcast(), sound, Owner.Transform.Coordinates); - } + SoundSystem.Play(Filter.Broadcast(), SoundEmpty.GetSound(), Owner.Transform.Coordinates); return; } @@ -208,8 +205,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components var projectile = TakeProjectile(shooter.Transform.Coordinates); if (projectile == null) { - if(SoundEmpty.TryGetSound(out var soundEmpty)) - SoundSystem.Play(Filter.Broadcast(), soundEmpty, Owner.Transform.Coordinates); + SoundSystem.Play(Filter.Broadcast(), SoundEmpty.GetSound(), Owner.Transform.Coordinates); return; } @@ -249,10 +245,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components throw new InvalidOperationException(); } - if (SoundGunshot.TryGetSound(out var soundGunshot)) - { - SoundSystem.Play(Filter.Broadcast(), soundGunshot, Owner.Transform.Coordinates); - } + SoundSystem.Play(Filter.Broadcast(), SoundGunshot.GetSound(), Owner.Transform.Coordinates); _lastFire = _gameTiming.CurTime; } @@ -283,10 +276,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components entity.Transform.Coordinates = entity.Transform.Coordinates.Offset(offsetPos); entity.Transform.LocalRotation = robustRandom.Pick(ejectDirections).ToAngle(); - if (ammo.SoundCollectionEject.TryGetSound(out var ejectSounds) && playSound) - { - SoundSystem.Play(Filter.Broadcast(), ejectSounds, entity.Transform.Coordinates, AudioParams.Default.WithVolume(-1)); - } + SoundSystem.Play(Filter.Broadcast(), ammo.SoundCollectionEject.GetSound(), entity.Transform.Coordinates, AudioParams.Default.WithVolume(-1)); } /// diff --git a/Content.Server/Weapon/Ranged/ServerRangedWeaponComponent.cs b/Content.Server/Weapon/Ranged/ServerRangedWeaponComponent.cs index 345a69e33e..8a6fdeaccf 100644 --- a/Content.Server/Weapon/Ranged/ServerRangedWeaponComponent.cs +++ b/Content.Server/Weapon/Ranged/ServerRangedWeaponComponent.cs @@ -147,7 +147,8 @@ namespace Content.Server.Weapon.Ranged return; } - if(!user.TryGetComponent(out CombatModeComponent? combat) || !combat.IsInCombatMode) { + if (!user.TryGetComponent(out CombatModeComponent? combat) || !combat.IsInCombatMode) + { return; } @@ -167,13 +168,13 @@ namespace Content.Server.Weapon.Ranged if (ClumsyCheck && ClumsyComponent.TryRollClumsy(user, ClumsyExplodeChance)) { - if(_clumsyWeaponHandlingSound.TryGetSound(out var clumsyWeaponHandlingSound)) - SoundSystem.Play(Filter.Pvs(Owner), clumsyWeaponHandlingSound, - Owner.Transform.Coordinates, AudioParams.Default.WithMaxDistance(5)); + SoundSystem.Play( + Filter.Pvs(Owner), _clumsyWeaponHandlingSound.GetSound(), + Owner.Transform.Coordinates, AudioParams.Default.WithMaxDistance(5)); - if(_clumsyWeaponShotSound.TryGetSound(out var clumsyWeaponShotSound)) - SoundSystem.Play(Filter.Pvs(Owner), clumsyWeaponShotSound, - Owner.Transform.Coordinates, AudioParams.Default.WithMaxDistance(5)); + SoundSystem.Play( + Filter.Pvs(Owner), _clumsyWeaponShotSound.GetSound(), + Owner.Transform.Coordinates, AudioParams.Default.WithMaxDistance(5)); if (user.TryGetComponent(out IDamageableComponent? health)) { diff --git a/Content.Server/Window/WindowComponent.cs b/Content.Server/Window/WindowComponent.cs index b9d38a3f3a..fb83630d11 100644 --- a/Content.Server/Window/WindowComponent.cs +++ b/Content.Server/Window/WindowComponent.cs @@ -31,7 +31,8 @@ namespace Content.Server.Window [ViewVariables(VVAccess.ReadWrite)] private TimeSpan _lastKnockTime; - [DataField("knockDelay")] [ViewVariables(VVAccess.ReadWrite)] + [DataField("knockDelay")] + [ViewVariables(VVAccess.ReadWrite)] private TimeSpan _knockDelay = TimeSpan.FromSeconds(0.5); [DataField("rateLimitedKnocking")] @@ -47,11 +48,11 @@ namespace Content.Server.Window switch (message) { case DamageChangedMessage msg: - { - var current = msg.Damageable.TotalDamage; - UpdateVisuals(current); - break; - } + { + var current = msg.Damageable.TotalDamage; + UpdateVisuals(current); + break; + } } } @@ -133,9 +134,9 @@ namespace Content.Server.Window return false; } - if(_knockSound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(eventArgs.Target), sound, - eventArgs.Target.Transform.Coordinates, AudioHelpers.WithVariation(0.05f)); + SoundSystem.Play( + Filter.Pvs(eventArgs.Target), _knockSound.GetSound(), + eventArgs.Target.Transform.Coordinates, AudioHelpers.WithVariation(0.05f)); eventArgs.Target.PopupMessageEveryone(Loc.GetString("comp-window-knock")); _lastKnockTime = _gameTiming.CurTime; diff --git a/Content.Server/WireHacking/WiresComponent.cs b/Content.Server/WireHacking/WiresComponent.cs index c6d16b8d58..ffa9def798 100644 --- a/Content.Server/WireHacking/WiresComponent.cs +++ b/Content.Server/WireHacking/WiresComponent.cs @@ -456,8 +456,7 @@ namespace Content.Server.WireHacking return; } - if(_pulseSound.TryGetSound(out var pulseSound)) - SoundSystem.Play(Filter.Pvs(Owner), pulseSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), _pulseSound.GetSound(), Owner); break; } @@ -509,17 +508,11 @@ namespace Content.Server.WireHacking IsPanelOpen = !IsPanelOpen; if (IsPanelOpen) { - if(_screwdriverOpenSound.TryGetSound(out var openSound)) - { - SoundSystem.Play(Filter.Pvs(Owner), openSound, Owner); - } + SoundSystem.Play(Filter.Pvs(Owner), _screwdriverOpenSound.GetSound(), Owner); } else { - if (_screwdriverCloseSound.TryGetSound(out var closeSound)) - { - SoundSystem.Play(Filter.Pvs(Owner), closeSound, Owner); - } + SoundSystem.Play(Filter.Pvs(Owner), _screwdriverCloseSound.GetSound(), Owner); } return true; diff --git a/Content.Shared/Light/Component/SharedExpendableLightComponent.cs b/Content.Shared/Light/Component/SharedExpendableLightComponent.cs index 1ee1cd35c9..000cb5a37b 100644 --- a/Content.Shared/Light/Component/SharedExpendableLightComponent.cs +++ b/Content.Shared/Light/Component/SharedExpendableLightComponent.cs @@ -69,11 +69,11 @@ namespace Content.Shared.Light.Component protected string IconStateLit { get; set; } = string.Empty; [ViewVariables] - [DataField("litSound")] + [DataField("litSound", required: true)] protected SoundSpecifier LitSound { get; set; } = default!; [ViewVariables] - [DataField("loopedSound")] + [DataField("loopedSound", required: true)] public string LoopedSound { get; set; } = string.Empty; [ViewVariables] diff --git a/Content.Shared/Maps/ContentTileDefinition.cs b/Content.Shared/Maps/ContentTileDefinition.cs index cc7f5961e0..6f82ad0768 100644 --- a/Content.Shared/Maps/ContentTileDefinition.cs +++ b/Content.Shared/Maps/ContentTileDefinition.cs @@ -32,7 +32,7 @@ namespace Content.Shared.Maps [DataField("can_crowbar")] public bool CanCrowbar { get; private set; } - [DataField("footstep_sounds")] public SoundSpecifier FootstepSounds { get; } = default!; + [DataField("footstep_sounds", required: true)] public SoundSpecifier FootstepSounds { get; } = default!; [DataField("friction")] public float Friction { get; set; } diff --git a/Content.Shared/Sound/SoundSpecifier.cs b/Content.Shared/Sound/SoundSpecifier.cs index a911c5db81..35b38e823d 100644 --- a/Content.Shared/Sound/SoundSpecifier.cs +++ b/Content.Shared/Sound/SoundSpecifier.cs @@ -3,7 +3,6 @@ using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.TypeSerializers.Implementations; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; using Robust.Shared.Utility; -using System.Diagnostics.CodeAnalysis; namespace Content.Shared.Sound { @@ -11,8 +10,6 @@ namespace Content.Shared.Sound public abstract class SoundSpecifier { public abstract string GetSound(); - - public abstract bool TryGetSound([NotNullWhen(true)] out string? sound); } public sealed class SoundPathSpecifier : SoundSpecifier @@ -40,12 +37,6 @@ namespace Content.Shared.Sound { return Path == null ? string.Empty : Path.ToString(); } - - public override bool TryGetSound([NotNullWhen(true)] out string? sound) - { - sound = GetSound(); - return !string.IsNullOrWhiteSpace(sound); - } } public sealed class SoundCollectionSpecifier : SoundSpecifier @@ -68,11 +59,5 @@ namespace Content.Shared.Sound { return Collection == null ? string.Empty : AudioHelpers.GetRandomFileFromSoundCollection(Collection); } - - public override bool TryGetSound([NotNullWhen(true)] out string? sound) - { - sound = GetSound(); - return !string.IsNullOrWhiteSpace(sound); - } } } diff --git a/Content.Shared/Standing/StandingStateSystem.cs b/Content.Shared/Standing/StandingStateSystem.cs index 7f96cc3bf8..6898ca2c02 100644 --- a/Content.Shared/Standing/StandingStateSystem.cs +++ b/Content.Shared/Standing/StandingStateSystem.cs @@ -61,9 +61,9 @@ namespace Content.Shared.Standing } // Currently shit is only downed by server but when it's predicted we can probably only play this on server / client - if (playSound && component.DownSoundCollection.TryGetSound(out var sound)) + if (playSound) { - SoundSystem.Play(Filter.Pvs(entity), sound, entity, AudioHelpers.WithVariation(0.25f)); + SoundSystem.Play(Filter.Pvs(entity), component.DownSoundCollection.GetSound(), entity, AudioHelpers.WithVariation(0.25f)); } } From 10baebae7988aeebbc60ca0b4bd60f5d31c33ed4 Mon Sep 17 00:00:00 2001 From: Galactic Chimp Date: Sat, 31 Jul 2021 20:00:03 +0200 Subject: [PATCH 13/18] changed some prototypes' sound paths --- Resources/Prototypes/Entities/Objects/Fun/toys.yml | 4 ++-- .../Entities/Objects/Weapons/Guns/Projectiles/projectiles.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Resources/Prototypes/Entities/Objects/Fun/toys.yml b/Resources/Prototypes/Entities/Objects/Fun/toys.yml index a626670610..83b23cacab 100644 --- a/Resources/Prototypes/Entities/Objects/Fun/toys.yml +++ b/Resources/Prototypes/Entities/Objects/Fun/toys.yml @@ -481,9 +481,9 @@ soundEmpty: path: /Audio/Weapons/Guns/Empty/empty.ogg soundGunshot: - path: /Audio/Weapons/Guns/Gunshots/click.ogg + path: /Audio/Weapons/click.ogg soundInsert: - path: /Audio/Weapons/Guns/MagIn/drawbow2.ogg + path: /Audio/Weapons/drawbow2.ogg - type: entity parent: BaseItem diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/projectiles.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/projectiles.yml index 8e39dd3c38..bdc3457810 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/projectiles.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/projectiles.yml @@ -272,7 +272,7 @@ - type: Projectile deleteOnCollide: true soundHit: - path: /Audio/Guns/Hits/snap.ogg + path: /Audio/Weapons/Guns/Hits/snap.ogg damages: Blunt: 2 From aa7606cf42092d4b418c03360036e985cb3309f5 Mon Sep 17 00:00:00 2001 From: Galactic Chimp Date: Sat, 31 Jul 2021 21:01:03 +0200 Subject: [PATCH 14/18] test fixes --- .../Tests/Destructible/DestructibleTestPrototypes.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Content.IntegrationTests/Tests/Destructible/DestructibleTestPrototypes.cs b/Content.IntegrationTests/Tests/Destructible/DestructibleTestPrototypes.cs index 27e72e74b0..31e9021f50 100644 --- a/Content.IntegrationTests/Tests/Destructible/DestructibleTestPrototypes.cs +++ b/Content.IntegrationTests/Tests/Destructible/DestructibleTestPrototypes.cs @@ -1,4 +1,4 @@ -namespace Content.IntegrationTests.Tests.Destructible +namespace Content.IntegrationTests.Tests.Destructible { public static class DestructibleTestPrototypes { @@ -30,7 +30,8 @@ triggersOnce: false behaviors: - !type:PlaySoundBehavior - sound: /Audio/Effects/woodhit.ogg + sound: + path: /Audio/Effects/woodhit.ogg - !type:SpawnEntitiesBehavior spawn: {SpawnedEntityId}: @@ -52,7 +53,8 @@ damage: 50 behaviors: - !type:PlaySoundBehavior - sound: /Audio/Effects/woodhit.ogg + sound: + path: /Audio/Effects/woodhit.ogg - !type:SpawnEntitiesBehavior spawn: {SpawnedEntityId}: From e9f358f56bd99fa96f49290410e62422b186b2f5 Mon Sep 17 00:00:00 2001 From: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com> Date: Tue, 10 Aug 2021 15:39:24 -0700 Subject: [PATCH 15/18] Fix indentation --- .../Kitchen/Components/MicrowaveComponent.cs | 59 ++++++++++--------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/Content.Server/Kitchen/Components/MicrowaveComponent.cs b/Content.Server/Kitchen/Components/MicrowaveComponent.cs index a0786f7fe0..38ea0f9fe6 100644 --- a/Content.Server/Kitchen/Components/MicrowaveComponent.cs +++ b/Content.Server/Kitchen/Components/MicrowaveComponent.cs @@ -339,39 +339,40 @@ namespace Content.Server.Kitchen.Components SetAppearance(MicrowaveVisualState.Cooking); SoundSystem.Play(Filter.Pvs(Owner), _startCookingSound.GetSound(), Owner, AudioParams.Default); Owner.SpawnTimer((int) (_currentCookTimerTime * _cookTimeMultiplier), (Action) (() => - { - if (_lostPower) - { - return; - } + { + if (_lostPower) + { + return; + } - if (failState == MicrowaveSuccessState.UnwantedForeignObject) - { - VaporizeReagents(); - EjectSolids(); - } - else - { - if (recipeToCook != null) - { - SubtractContents(recipeToCook); - Owner.EntityManager.SpawnEntity(recipeToCook.Result, Owner.Transform.Coordinates); - } - else - { - VaporizeReagents(); - VaporizeSolids(); - Owner.EntityManager.SpawnEntity(_badRecipeName, Owner.Transform.Coordinates); - } - } + if (failState == MicrowaveSuccessState.UnwantedForeignObject) + { + VaporizeReagents(); + EjectSolids(); + } + else + { + if (recipeToCook != null) + { + SubtractContents(recipeToCook); + Owner.EntityManager.SpawnEntity(recipeToCook.Result, Owner.Transform.Coordinates); + } + else + { + VaporizeReagents(); + VaporizeSolids(); + Owner.EntityManager.SpawnEntity(_badRecipeName, Owner.Transform.Coordinates); + } + } - SoundSystem.Play(Filter.Pvs(Owner), _cookingCompleteSound.GetSound(), Owner, AudioParams.Default.WithVolume(-1f)); + SoundSystem.Play(Filter.Pvs(Owner), _cookingCompleteSound.GetSound(), Owner, + AudioParams.Default.WithVolume(-1f)); - SetAppearance(MicrowaveVisualState.Idle); - _busy = false; + SetAppearance(MicrowaveVisualState.Idle); + _busy = false; - _uiDirty = true; - })); + _uiDirty = true; + })); _lostPower = false; _uiDirty = true; } From 0c09d4d7e2da487a95c16fdc58cb4e3b2d1fad96 Mon Sep 17 00:00:00 2001 From: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com> Date: Tue, 10 Aug 2021 16:18:57 -0700 Subject: [PATCH 16/18] Fix stuff --- .../Cuffs/Components/HandcuffComponent.cs | 3 +- .../Components/SoundOnTriggerComponent.cs | 2 +- .../Nutrition/Components/CreamPieComponent.cs | 2 +- Content.Server/PDA/PDAComponent.cs | 66 ++++----- .../Physics/Controllers/MoverController.cs | 3 +- .../Components/EmitterComponent.cs | 2 +- .../EntitySystems/EmitterSystem.cs | 2 +- .../StationEvents/Events/GasLeak.cs | 1 - .../Components/ServerStorageComponent.cs | 132 +++++++++--------- Content.Server/Window/WindowComponent.cs | 10 +- 10 files changed, 111 insertions(+), 112 deletions(-) diff --git a/Content.Server/Cuffs/Components/HandcuffComponent.cs b/Content.Server/Cuffs/Components/HandcuffComponent.cs index c652e00e2e..24cedb9a26 100644 --- a/Content.Server/Cuffs/Components/HandcuffComponent.cs +++ b/Content.Server/Cuffs/Components/HandcuffComponent.cs @@ -116,7 +116,8 @@ namespace Content.Server.Cuffs.Components [DataField("startCuffSound")] public SoundSpecifier StartCuffSound { get; set; } = new SoundPathSpecifier("/Audio/Items/Handcuffs/cuff_start.ogg"); - [DataField("endCuffSound")] public SoundSpecifier EndCuffSound { get; set; } = new SoundPathSpecifier("/Audio/Items/Handcuffs/cuff_end.ogg"); + [DataField("endCuffSound")] + public SoundSpecifier EndCuffSound { get; set; } = new SoundPathSpecifier("/Audio/Items/Handcuffs/cuff_end.ogg"); [DataField("startBreakoutSound")] public SoundSpecifier StartBreakoutSound { get; set; } = new SoundPathSpecifier("/Audio/Items/Handcuffs/cuff_breakout_start.ogg"); diff --git a/Content.Server/Explosion/Components/SoundOnTriggerComponent.cs b/Content.Server/Explosion/Components/SoundOnTriggerComponent.cs index 83ea9bca05..ac25afb8e9 100644 --- a/Content.Server/Explosion/Components/SoundOnTriggerComponent.cs +++ b/Content.Server/Explosion/Components/SoundOnTriggerComponent.cs @@ -15,6 +15,6 @@ namespace Content.Server.Explosion.Components [ViewVariables(VVAccess.ReadWrite)] [DataField("sound", required: true)] - public SoundSpecifier? Sound { get; set; } = null; + public SoundSpecifier Sound { get; set; } = default!; } } diff --git a/Content.Server/Nutrition/Components/CreamPieComponent.cs b/Content.Server/Nutrition/Components/CreamPieComponent.cs index 97b46fd83a..2cf0349582 100644 --- a/Content.Server/Nutrition/Components/CreamPieComponent.cs +++ b/Content.Server/Nutrition/Components/CreamPieComponent.cs @@ -21,7 +21,7 @@ namespace Content.Server.Nutrition.Components public float ParalyzeTime { get; set; } = 1f; [DataField("sound")] - private SoundSpecifier _sound = new SoundCollectionSpecifier("desacration"); + private SoundSpecifier _sound = new SoundCollectionSpecifier("desecration"); public void PlaySound() { diff --git a/Content.Server/PDA/PDAComponent.cs b/Content.Server/PDA/PDAComponent.cs index a2ffba3a95..6f528af652 100644 --- a/Content.Server/PDA/PDAComponent.cs +++ b/Content.Server/PDA/PDAComponent.cs @@ -104,49 +104,49 @@ namespace Content.Server.PDA switch (message.Message) { case PDARequestUpdateInterfaceMessage _: - { - UpdatePDAUserInterface(); - break; - } + { + UpdatePDAUserInterface(); + break; + } case PDAToggleFlashlightMessage _: - { - ToggleLight(); - break; - } + { + ToggleLight(); + break; + } case PDAEjectIDMessage _: - { - HandleIDEjection(message.Session.AttachedEntity!); - break; - } + { + HandleIDEjection(message.Session.AttachedEntity!); + break; + } case PDAEjectPenMessage _: - { - HandlePenEjection(message.Session.AttachedEntity!); - break; - } + { + HandlePenEjection(message.Session.AttachedEntity!); + break; + } case PDAUplinkBuyListingMessage buyMsg: + { + var player = message.Session.AttachedEntity; + if (player == null) break; + + if (!_uplinkManager.TryPurchaseItem(_syndicateUplinkAccount, buyMsg.ItemId, + player.Transform.Coordinates, out var entity)) { - var player = message.Session.AttachedEntity; - if (player == null) - break; - - if (!_uplinkManager.TryPurchaseItem(_syndicateUplinkAccount, buyMsg.ItemId, - player.Transform.Coordinates, out var entity)) - { - SendNetworkMessage(new PDAUplinkInsufficientFundsMessage(), message.Session.ConnectedClient); - break; - } - - if (!player.TryGetComponent(out HandsComponent? hands) || !entity.TryGetComponent(out ItemComponent? item)) - break; - - hands.PutInHandOrDrop(item); - - SendNetworkMessage(new PDAUplinkBuySuccessMessage(), message.Session.ConnectedClient); + SendNetworkMessage(new PDAUplinkInsufficientFundsMessage(), message.Session.ConnectedClient); break; } + + if (!player.TryGetComponent(out HandsComponent? hands) || + !entity.TryGetComponent(out ItemComponent? item)) + break; + + hands.PutInHandOrDrop(item); + + SendNetworkMessage(new PDAUplinkBuySuccessMessage(), message.Session.ConnectedClient); + break; + } } } diff --git a/Content.Server/Physics/Controllers/MoverController.cs b/Content.Server/Physics/Controllers/MoverController.cs index 386a79af1f..e01b80327f 100644 --- a/Content.Server/Physics/Controllers/MoverController.cs +++ b/Content.Server/Physics/Controllers/MoverController.cs @@ -226,7 +226,8 @@ namespace Content.Server.Physics.Controllers // Walking on a tile. var def = (ContentTileDefinition) _tileDefinitionManager[tile.Tile.TypeId]; soundToPlay = def.FootstepSounds.GetSound(); - return; + if (string.IsNullOrEmpty(soundToPlay)) + return; } if (string.IsNullOrWhiteSpace(soundToPlay)) diff --git a/Content.Server/Singularity/Components/EmitterComponent.cs b/Content.Server/Singularity/Components/EmitterComponent.cs index 5b2b27191f..27748e96b0 100644 --- a/Content.Server/Singularity/Components/EmitterComponent.cs +++ b/Content.Server/Singularity/Components/EmitterComponent.cs @@ -35,7 +35,7 @@ namespace Content.Server.Singularity.Components [ViewVariables] public int FireShotCounter; - [ViewVariables] [DataField("fireSound")] public string FireSound = "/Audio/Weapons/emitter.ogg"; + [ViewVariables] [DataField("fireSound")] public SoundSpecifier FireSound = new SoundPathSpecifier("/Audio/Weapons/emitter.ogg"); [ViewVariables] [DataField("boltType")] public string BoltType = "EmitterBolt"; [ViewVariables] [DataField("powerUseActive")] public int PowerUseActive = 500; [ViewVariables] [DataField("fireBurstSize")] public int FireBurstSize = 3; diff --git a/Content.Server/Singularity/EntitySystems/EmitterSystem.cs b/Content.Server/Singularity/EntitySystems/EmitterSystem.cs index fd5d157a11..75950f6866 100644 --- a/Content.Server/Singularity/EntitySystems/EmitterSystem.cs +++ b/Content.Server/Singularity/EntitySystems/EmitterSystem.cs @@ -222,7 +222,7 @@ namespace Content.Server.Singularity.EntitySystems // TODO: Move to projectile's code. Timer.Spawn(3000, () => projectile.Delete()); - SoundSystem.Play(Filter.Pvs(component.Owner), component.FireSound, component.Owner, + SoundSystem.Play(Filter.Pvs(component.Owner), component.FireSound.GetSound(), component.Owner, AudioHelpers.WithVariation(EmitterComponent.Variation).WithVolume(EmitterComponent.Volume).WithMaxDistance(EmitterComponent.Distance)); } diff --git a/Content.Server/StationEvents/Events/GasLeak.cs b/Content.Server/StationEvents/Events/GasLeak.cs index f41e9b398b..b1108edcae 100644 --- a/Content.Server/StationEvents/Events/GasLeak.cs +++ b/Content.Server/StationEvents/Events/GasLeak.cs @@ -2,7 +2,6 @@ using Content.Server.Atmos.Components; using Content.Server.Atmos.EntitySystems; using Content.Server.GameTicking; using Content.Shared.Atmos; -using Content.Shared.Sound; using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.IoC; diff --git a/Content.Server/Storage/Components/ServerStorageComponent.cs b/Content.Server/Storage/Components/ServerStorageComponent.cs index 86a4ff89f3..25df3277c6 100644 --- a/Content.Server/Storage/Components/ServerStorageComponent.cs +++ b/Content.Server/Storage/Components/ServerStorageComponent.cs @@ -1,3 +1,8 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; using Content.Server.DoAfter; using Content.Server.Hands.Components; using Content.Server.Items; @@ -24,11 +29,6 @@ using Robust.Shared.Player; using Robust.Shared.Players; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; namespace Content.Server.Storage.Components { @@ -387,79 +387,77 @@ namespace Content.Server.Storage.Components switch (message) { case RemoveEntityMessage remove: + { + EnsureInitialCalculated(); + + var player = session.AttachedEntity; + + if (player == null) { - EnsureInitialCalculated(); - - var player = session.AttachedEntity; - - if (player == null) - { - break; - } - - var ownerTransform = Owner.Transform; - var playerTransform = player.Transform; - - if (!playerTransform.Coordinates.InRange(Owner.EntityManager, ownerTransform.Coordinates, 2) || - !ownerTransform.IsMapTransform && - !playerTransform.ContainsEntity(ownerTransform)) - { - break; - } - - var entity = Owner.EntityManager.GetEntity(remove.EntityUid); - - if (entity == null || _storage?.Contains(entity) == false) - { - break; - } - - var item = entity.GetComponent(); - if (item == null || - !player.TryGetComponent(out HandsComponent? hands)) - { - break; - } - - if (!hands.CanPutInHand(item)) - { - break; - } - - hands.PutInHand(item); - break; } + + var ownerTransform = Owner.Transform; + var playerTransform = player.Transform; + + if (!playerTransform.Coordinates.InRange(Owner.EntityManager, ownerTransform.Coordinates, 2) || + !ownerTransform.IsMapTransform && !playerTransform.ContainsEntity(ownerTransform)) + { + break; + } + + var entity = Owner.EntityManager.GetEntity(remove.EntityUid); + + if (entity == null || _storage?.Contains(entity) == false) + { + break; + } + + var item = entity.GetComponent(); + if (item == null || !player.TryGetComponent(out HandsComponent? hands)) + { + break; + } + + if (!hands.CanPutInHand(item)) + { + break; + } + + hands.PutInHand(item); + + break; + } case InsertEntityMessage _: + { + EnsureInitialCalculated(); + + var player = session.AttachedEntity; + + if (player == null) { - EnsureInitialCalculated(); - - var player = session.AttachedEntity; - - if (player == null) - { - break; - } - - if (!player.InRangeUnobstructed(Owner, popup: true)) - { - break; - } - - PlayerInsertHeldEntity(player); - break; } + + if (!player.InRangeUnobstructed(Owner, popup: true)) + { + break; + } + + PlayerInsertHeldEntity(player); + + break; + } case CloseStorageUIMessage _: + { + if (session is not IPlayerSession playerSession) { - if (session is not IPlayerSession playerSession) - { - break; - } - - UnsubscribeSession(playerSession); break; } + + UnsubscribeSession(playerSession); + break; + } } } diff --git a/Content.Server/Window/WindowComponent.cs b/Content.Server/Window/WindowComponent.cs index fb83630d11..9eeca09d67 100644 --- a/Content.Server/Window/WindowComponent.cs +++ b/Content.Server/Window/WindowComponent.cs @@ -48,11 +48,11 @@ namespace Content.Server.Window switch (message) { case DamageChangedMessage msg: - { - var current = msg.Damageable.TotalDamage; - UpdateVisuals(current); - break; - } + { + var current = msg.Damageable.TotalDamage; + UpdateVisuals(current); + break; + } } } From 26ebcb4cb8f6d1bd79e551cd60203318115bbf82 Mon Sep 17 00:00:00 2001 From: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com> Date: Tue, 10 Aug 2021 16:55:12 -0700 Subject: [PATCH 17/18] Fix gas canister --- Content.Server/Singularity/Components/EmitterComponent.cs | 1 - .../Entities/Structures/Storage/Canisters/gas_canisters.yml | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Content.Server/Singularity/Components/EmitterComponent.cs b/Content.Server/Singularity/Components/EmitterComponent.cs index 27748e96b0..64cf772c77 100644 --- a/Content.Server/Singularity/Components/EmitterComponent.cs +++ b/Content.Server/Singularity/Components/EmitterComponent.cs @@ -42,6 +42,5 @@ namespace Content.Server.Singularity.Components [ViewVariables] [DataField("fireInterval")] public TimeSpan FireInterval = TimeSpan.FromSeconds(2); [ViewVariables] [DataField("fireBurstDelayMin")] public TimeSpan FireBurstDelayMin = TimeSpan.FromSeconds(2); [ViewVariables] [DataField("fireBurstDelayMax")] public TimeSpan FireBurstDelayMax = TimeSpan.FromSeconds(10); - } } diff --git a/Resources/Prototypes/Entities/Structures/Storage/Canisters/gas_canisters.yml b/Resources/Prototypes/Entities/Structures/Storage/Canisters/gas_canisters.yml index 37eda3fc53..c9f06362eb 100644 --- a/Resources/Prototypes/Entities/Structures/Storage/Canisters/gas_canisters.yml +++ b/Resources/Prototypes/Entities/Structures/Storage/Canisters/gas_canisters.yml @@ -1,7 +1,7 @@ - type: entity - abstract: true id: GasCanister name: gas canister + abstract: true description: A canister that can contain any type of gas. It can be attached to connector ports using a wrench. parent: BaseStructureDynamic components: @@ -32,7 +32,8 @@ damage: 300 behaviors: - !type:PlaySoundBehavior - sound: /Audio/Effects/metalbreak.ogg + sound: + path: /Audio/Effects/metalbreak.ogg - !type:SpawnEntitiesBehavior spawn: GasCanisterBrokenBase: From 5ba86d16f8841e02baedf9fb4cfe9f2dd55bcd1a Mon Sep 17 00:00:00 2001 From: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com> Date: Tue, 10 Aug 2021 17:38:50 -0700 Subject: [PATCH 18/18] Organize gas canister prototype --- .../Entities/Structures/Storage/Canisters/gas_canisters.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Resources/Prototypes/Entities/Structures/Storage/Canisters/gas_canisters.yml b/Resources/Prototypes/Entities/Structures/Storage/Canisters/gas_canisters.yml index c9f06362eb..dc4cfee857 100644 --- a/Resources/Prototypes/Entities/Structures/Storage/Canisters/gas_canisters.yml +++ b/Resources/Prototypes/Entities/Structures/Storage/Canisters/gas_canisters.yml @@ -1,9 +1,9 @@ - type: entity + abstract: true + parent: BaseStructureDynamic id: GasCanister name: gas canister - abstract: true description: A canister that can contain any type of gas. It can be attached to connector ports using a wrench. - parent: BaseStructureDynamic components: - type: InteractionOutline - type: Sprite