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