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";
}
}