Dispose storage windows on state change (#20095)

This commit is contained in:
metalgearsloth
2023-09-14 08:03:44 +10:00
committed by GitHub
parent dea266ea8b
commit 91444083cf

View File

@@ -1,10 +1,11 @@
using Content.Client.Gameplay;
using Content.Client.Storage.Systems;
using Content.Shared.Storage;
using Robust.Client.UserInterface.Controllers;
namespace Content.Client.Storage.UI;
public sealed class StorageUIController : UIController, IOnSystemChanged<StorageSystem>
public sealed class StorageUIController : UIController, IOnSystemChanged<StorageSystem>, IOnStateExited<GameplayState>
{
// This is mainly to keep legacy functionality for now.
private readonly Dictionary<EntityUid, StorageWindow> _storageWindows = new();
@@ -57,4 +58,14 @@ public sealed class StorageUIController : UIController, IOnSystemChanged<Storage
{
system.StorageUpdated -= OnStorageUpdate;
}
public void OnStateExited(GameplayState state)
{
foreach (var window in _storageWindows.Values)
{
window.Dispose();
}
_storageWindows.Clear();
}
}