Use ECS prototype-reload events (#22613)

* Use ECS prototype-reload events

* better constructors

* Maybe this fixes tests?
This commit is contained in:
Leon Friedrich
2023-12-22 09:13:45 -05:00
committed by GitHub
parent 053c1e877f
commit b6bd82caa6
23 changed files with 135 additions and 242 deletions

View File

@@ -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)