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

@@ -1,4 +1,3 @@
using Content.Client.GameTicking.Managers;
using Content.Shared.CrewManifest;
using Content.Shared.Roles;
using Robust.Shared.Prototypes;
@@ -19,12 +18,7 @@ public sealed class CrewManifestSystem : EntitySystem
base.Initialize();
BuildDepartmentLookup();
_prototypeManager.PrototypesReloaded += OnPrototypesReload;
}
public override void Shutdown()
{
_prototypeManager.PrototypesReloaded -= OnPrototypesReload;
SubscribeLocalEvent<PrototypesReloadedEventArgs>(OnPrototypesReload);
}
/// <summary>
@@ -36,16 +30,16 @@ public sealed class CrewManifestSystem : EntitySystem
RaiseNetworkEvent(new RequestCrewManifestMessage(netEntity));
}
private void OnPrototypesReload(PrototypesReloadedEventArgs _)
private void OnPrototypesReload(PrototypesReloadedEventArgs args)
{
_jobDepartmentLookup.Clear();
_departments.Clear();
BuildDepartmentLookup();
if (args.WasModified<DepartmentPrototype>())
BuildDepartmentLookup();
}
private void BuildDepartmentLookup()
{
_jobDepartmentLookup.Clear();
_departments.Clear();
foreach (var department in _prototypeManager.EnumeratePrototypes<DepartmentPrototype>())
{
_departments.Add(department.ID);