From 58efe4fdd140525a0f2c3cd2d953a1d297614288 Mon Sep 17 00:00:00 2001 From: DrSmugleaf <10968691+DrSmugleaf@users.noreply.github.com> Date: Wed, 26 Jun 2024 07:11:51 -0700 Subject: [PATCH] Fix storages bugging out if an open storage has its component removed (#29485) * Fix storages bugging out if an open storage has its component removed * Fix error on close --- Content.Client/Storage/Systems/StorageSystem.cs | 4 ++-- Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Content.Client/Storage/Systems/StorageSystem.cs b/Content.Client/Storage/Systems/StorageSystem.cs index b80a855f98..a74a118cd0 100644 --- a/Content.Client/Storage/Systems/StorageSystem.cs +++ b/Content.Client/Storage/Systems/StorageSystem.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; using System.Numerics; using Content.Client.Animations; using Content.Shared.Hands; @@ -69,7 +69,7 @@ public sealed class StorageSystem : SharedStorageSystem public void CloseStorageWindow(Entity entity) { - if (!Resolve(entity, ref entity.Comp)) + if (!Resolve(entity, ref entity.Comp, false)) return; if (!_openStorages.Contains((entity, entity.Comp))) diff --git a/Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs b/Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs index 2b434befe5..5c2e0080a6 100644 --- a/Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs +++ b/Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs @@ -96,6 +96,7 @@ public abstract class SharedStorageSystem : EntitySystem subs.Event(OnBoundUIClosed); }); + SubscribeLocalEvent(OnRemove); SubscribeLocalEvent(OnMapInit); SubscribeLocalEvent>(AddUiVerb); SubscribeLocalEvent(OnStorageGetState); @@ -133,6 +134,11 @@ public abstract class SharedStorageSystem : EntitySystem UpdatePrototypeCache(); } + private void OnRemove(Entity entity, ref ComponentRemove args) + { + _ui.CloseUi(entity.Owner, StorageComponent.StorageUiKey.Key); + } + private void OnMapInit(Entity entity, ref MapInitEvent args) { UseDelay.SetLength(entity.Owner, entity.Comp.QuickInsertCooldown, QuickInsertUseDelayID); -- 2.51.2