Revert "#3935 implemented suggestions from PR"
This reverts commit a9b1c7b96333ca570067d6a9df1954481005892a.
This commit is contained in:
@@ -6,10 +6,12 @@ namespace Content.Server.Sound
|
|||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Base sound emitter which defines most of the data fields.
|
/// 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.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class BaseEmitSoundComponent : Component
|
public abstract class BaseEmitSoundComponent : Component
|
||||||
{
|
{
|
||||||
[ViewVariables(VVAccess.ReadWrite)] [DataField("variation")] public float PitchVariation { get; set; } = 0.0f;
|
[ViewVariables(VVAccess.ReadWrite)] [DataField("variation")] public float PitchVariation { get; set; }
|
||||||
[ViewVariables(VVAccess.ReadWrite)] [DataField("soundCollection", required: true)] public string SoundCollectionName { get; set; } = default!;
|
[ViewVariables(VVAccess.ReadWrite)] [DataField("soundCollection")] public string? SoundCollectionName { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#nullable enable
|
||||||
using Content.Shared.Audio;
|
using Content.Shared.Audio;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Throwing;
|
using Content.Shared.Throwing;
|
||||||
@@ -10,6 +11,7 @@ using Robust.Shared.IoC;
|
|||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
|
using Robust.Shared.Log;
|
||||||
|
|
||||||
namespace Content.Server.Sound
|
namespace Content.Server.Sound
|
||||||
{
|
{
|
||||||
@@ -31,7 +33,14 @@ namespace Content.Server.Sound
|
|||||||
|
|
||||||
private void PlaySound(BaseEmitSoundComponent component)
|
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)
|
private void PlayRandomSoundFromCollection(BaseEmitSoundComponent component)
|
||||||
@@ -48,8 +57,16 @@ namespace Content.Server.Sound
|
|||||||
|
|
||||||
private static void PlaySingleSound(string soundName, BaseEmitSoundComponent component)
|
private static void PlaySingleSound(string soundName, BaseEmitSoundComponent component)
|
||||||
{
|
{
|
||||||
SoundSystem.Play(Filter.Pvs(component.Owner), soundName, component.Owner,
|
if (component.PitchVariation > 0.0)
|
||||||
AudioHelpers.WithVariation(component.PitchVariation).WithVolume(-2f));
|
{
|
||||||
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user