Makes a lot of entity systems unsubscribe from events on shutdown.

This commit is contained in:
Vera Aguilera Puerto
2021-04-09 16:08:12 +02:00
parent c28f22ebff
commit 03cd390478
15 changed files with 119 additions and 28 deletions

View File

@@ -51,8 +51,12 @@ namespace Content.Client.GameObjects.EntitySystems
/// <inheritdoc />
public override void Shutdown()
{
CommandBinds.Unregister<ConstructionSystem>();
base.Shutdown();
UnsubscribeLocalEvent<PlayerAttachSysMessage>();
UnsubscribeNetworkEvent<AckStructureConstructionMessage>();
CommandBinds.Unregister<ConstructionSystem>();
}
public event EventHandler<CraftingAvailabilityChangedArgs>? CraftingAvailabilityChanged;

View File

@@ -40,6 +40,12 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter
SubscribeLocalEvent<PlayerAttachSysMessage>(HandlePlayerAttached);
}
public override void Shutdown()
{
base.Shutdown();
UnsubscribeLocalEvent<PlayerAttachSysMessage>();
}
private void HandlePlayerAttached(PlayerAttachSysMessage message)
{
_attachedEntity = message.AttachedEntity;

View File

@@ -46,6 +46,13 @@ namespace Content.Client.GameObjects.EntitySystems.HealthOverlay
SubscribeLocalEvent<PlayerAttachSysMessage>(HandlePlayerAttached);
}
public override void Shutdown()
{
base.Shutdown();
UnsubscribeLocalEvent<PlayerAttachSysMessage>();
}
public void Reset()
{
foreach (var gui in _guis.Values)

View File

@@ -24,9 +24,16 @@ namespace Content.Client.GameObjects.EntitySystems
/// <inheritdoc />
public override void Initialize()
{
SubscribeLocalEvent<IconSmoothDirtyEvent>(HandleDirtyEvent);
base.Initialize();
IoCManager.InjectDependencies(this);
SubscribeLocalEvent<IconSmoothDirtyEvent>(HandleDirtyEvent);
}
public override void Shutdown()
{
base.Shutdown();
UnsubscribeLocalEvent<IconSmoothDirtyEvent>();
}
public override void FrameUpdate(float frameTime)

View File

@@ -46,7 +46,6 @@ namespace Content.Client.GameObjects.EntitySystems
public override void Initialize()
{
base.Initialize();
IoCManager.InjectDependencies(this);
SubscribeNetworkEvent<VerbSystemMessages.VerbsResponseMessage>(FillEntityPopup);
SubscribeNetworkEvent<PlayerContainerVisibilityMessage>(HandleContainerVisibilityMessage);
@@ -62,11 +61,14 @@ namespace Content.Client.GameObjects.EntitySystems
public override void Shutdown()
{
base.Shutdown();
UnsubscribeNetworkEvent<VerbSystemMessages.VerbsResponseMessage>();
UnsubscribeNetworkEvent<PlayerContainerVisibilityMessage>();
UnsubscribeLocalEvent<MoveEvent>();
_contextMenuPresenter?.Dispose();
CommandBinds.Unregister<VerbSystem>();
base.Shutdown();
}
public void Reset()

View File

@@ -17,6 +17,13 @@ namespace Content.Client.GameObjects.EntitySystems
SubscribeLocalEvent<WindowSmoothDirtyEvent>(HandleDirtyEvent);
}
public override void Shutdown()
{
base.Shutdown();
UnsubscribeLocalEvent<WindowSmoothDirtyEvent>();
}
private void HandleDirtyEvent(WindowSmoothDirtyEvent ev)
{
if (ev.Sender.HasComponent<WindowComponent>())