replacing sound (collection) names with SoundSpecifier - part 1

This commit is contained in:
Galactic Chimp
2021-07-10 17:35:33 +02:00
parent 4500b66f28
commit ce3c59e0e6
131 changed files with 934 additions and 587 deletions

View File

@@ -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
/// <summary>
/// Sound played upon destruction.
/// </summary>
[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));
}
}
}
}

View File

@@ -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
{
/// <summary>
/// Sound collection from which to pick a random sound to play.
/// </summary>
[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));
}
}
}