Use ECS prototype-reload events (#22613)
* Use ECS prototype-reload events * better constructors * Maybe this fixes tests?
This commit is contained in:
@@ -3,7 +3,6 @@ using Content.Shared.Audio;
|
||||
using Content.Shared.GameTicking;
|
||||
using Robust.Server.Audio;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Audio.Components;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.Audio;
|
||||
@@ -11,14 +10,13 @@ namespace Content.Server.Audio;
|
||||
public sealed class ContentAudioSystem : SharedContentAudioSystem
|
||||
{
|
||||
[Dependency] private readonly AudioSystem _serverAudio = default!;
|
||||
[Dependency] private readonly IPrototypeManager _protoManager = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRoundCleanup);
|
||||
SubscribeLocalEvent<RoundStartingEvent>(OnRoundStart);
|
||||
_protoManager.PrototypesReloaded += OnProtoReload;
|
||||
SubscribeLocalEvent<PrototypesReloadedEventArgs>(OnProtoReload);
|
||||
}
|
||||
|
||||
private void OnRoundCleanup(RoundRestartCleanupEvent ev)
|
||||
@@ -28,16 +26,8 @@ public sealed class ContentAudioSystem : SharedContentAudioSystem
|
||||
|
||||
private void OnProtoReload(PrototypesReloadedEventArgs obj)
|
||||
{
|
||||
if (!obj.ByType.ContainsKey(typeof(AudioPresetPrototype)))
|
||||
return;
|
||||
|
||||
_serverAudio.ReloadPresets();
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
{
|
||||
base.Shutdown();
|
||||
_protoManager.PrototypesReloaded -= OnProtoReload;
|
||||
if (obj.WasModified<AudioPresetPrototype>())
|
||||
_serverAudio.ReloadPresets();
|
||||
}
|
||||
|
||||
private void OnRoundStart(RoundStartingEvent ev)
|
||||
|
||||
Reference in New Issue
Block a user