Files
tbd-station-14/Content.Server/Audio/ContentAudioSystem.cs
Leon Friedrich b6bd82caa6 Use ECS prototype-reload events (#22613)
* Use ECS prototype-reload events

* better constructors

* Maybe this fixes tests?
2023-12-23 01:13:45 +11:00

40 lines
1.1 KiB
C#

using Content.Server.GameTicking.Events;
using Content.Shared.Audio;
using Content.Shared.GameTicking;
using Robust.Server.Audio;
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;
namespace Content.Server.Audio;
public sealed class ContentAudioSystem : SharedContentAudioSystem
{
[Dependency] private readonly AudioSystem _serverAudio = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRoundCleanup);
SubscribeLocalEvent<RoundStartingEvent>(OnRoundStart);
SubscribeLocalEvent<PrototypesReloadedEventArgs>(OnProtoReload);
}
private void OnRoundCleanup(RoundRestartCleanupEvent ev)
{
SilenceAudio();
}
private void OnProtoReload(PrototypesReloadedEventArgs obj)
{
if (obj.WasModified<AudioPresetPrototype>())
_serverAudio.ReloadPresets();
}
private void OnRoundStart(RoundStartingEvent ev)
{
// On cleanup all entities get purged so need to ensure audio presets are still loaded
// yeah it's whacky af.
_serverAudio.ReloadPresets();
}
}