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
This commit is contained in:
DrSmugleaf
2024-06-26 07:11:51 -07:00
committed by GitHub
parent 063011ec8d
commit 58efe4fdd1
2 changed files with 8 additions and 2 deletions

View File

@@ -1,4 +1,4 @@
using System.Linq; using System.Linq;
using System.Numerics; using System.Numerics;
using Content.Client.Animations; using Content.Client.Animations;
using Content.Shared.Hands; using Content.Shared.Hands;
@@ -69,7 +69,7 @@ public sealed class StorageSystem : SharedStorageSystem
public void CloseStorageWindow(Entity<StorageComponent?> entity) public void CloseStorageWindow(Entity<StorageComponent?> entity)
{ {
if (!Resolve(entity, ref entity.Comp)) if (!Resolve(entity, ref entity.Comp, false))
return; return;
if (!_openStorages.Contains((entity, entity.Comp))) if (!_openStorages.Contains((entity, entity.Comp)))

View File

@@ -96,6 +96,7 @@ public abstract class SharedStorageSystem : EntitySystem
subs.Event<BoundUIClosedEvent>(OnBoundUIClosed); subs.Event<BoundUIClosedEvent>(OnBoundUIClosed);
}); });
SubscribeLocalEvent<StorageComponent, ComponentRemove>(OnRemove);
SubscribeLocalEvent<StorageComponent, MapInitEvent>(OnMapInit); SubscribeLocalEvent<StorageComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<StorageComponent, GetVerbsEvent<ActivationVerb>>(AddUiVerb); SubscribeLocalEvent<StorageComponent, GetVerbsEvent<ActivationVerb>>(AddUiVerb);
SubscribeLocalEvent<StorageComponent, ComponentGetState>(OnStorageGetState); SubscribeLocalEvent<StorageComponent, ComponentGetState>(OnStorageGetState);
@@ -133,6 +134,11 @@ public abstract class SharedStorageSystem : EntitySystem
UpdatePrototypeCache(); UpdatePrototypeCache();
} }
private void OnRemove(Entity<StorageComponent> entity, ref ComponentRemove args)
{
_ui.CloseUi(entity.Owner, StorageComponent.StorageUiKey.Key);
}
private void OnMapInit(Entity<StorageComponent> entity, ref MapInitEvent args) private void OnMapInit(Entity<StorageComponent> entity, ref MapInitEvent args)
{ {
UseDelay.SetLength(entity.Owner, entity.Comp.QuickInsertCooldown, QuickInsertUseDelayID); UseDelay.SetLength(entity.Owner, entity.Comp.QuickInsertCooldown, QuickInsertUseDelayID);