Use ECS prototype-reload events (#22613)
* Use ECS prototype-reload events * better constructors * Maybe this fixes tests?
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user