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

@@ -24,14 +24,13 @@ public sealed class ParallaxSystem : SharedParallaxSystem
{
base.Initialize();
_overlay.AddOverlay(new ParallaxOverlay());
_protoManager.PrototypesReloaded += OnReload;
SubscribeLocalEvent<PrototypesReloadedEventArgs>(OnReload);
SubscribeLocalEvent<ParallaxComponent, AfterAutoHandleStateEvent>(OnAfterAutoHandleState);
}
private void OnReload(PrototypesReloadedEventArgs obj)
{
if (!obj.ByType.ContainsKey(typeof(ParallaxPrototype)))
if (!obj.WasModified<ParallaxPrototype>())
return;
_parallax.UnloadParallax(Fallback);
@@ -48,7 +47,6 @@ public sealed class ParallaxSystem : SharedParallaxSystem
{
base.Shutdown();
_overlay.RemoveOverlay<ParallaxOverlay>();
_protoManager.PrototypesReloaded -= OnReload;
}
private void OnAfterAutoHandleState(EntityUid uid, ParallaxComponent component, ref AfterAutoHandleStateEvent args)