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-07-25 01:50:40 +02:00
committed by null
parent 25098feecb
commit 914f397035
2 changed files with 8 additions and 2 deletions
@@ -97,6 +97,7 @@ public abstract class SharedStorageSystem : EntitySystem
subs.Event<BoundUIClosedEvent>(OnBoundUIClosed);
});
SubscribeLocalEvent<StorageComponent, ComponentRemove>(OnRemove);
SubscribeLocalEvent<StorageComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<StorageComponent, GetVerbsEvent<ActivationVerb>>(AddUiVerb);
SubscribeLocalEvent<StorageComponent, ComponentGetState>(OnStorageGetState);
@@ -134,6 +135,11 @@ public abstract class SharedStorageSystem : EntitySystem
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)
{
UseDelay.SetLength(entity.Owner, entity.Comp.QuickInsertCooldown, QuickInsertUseDelayID);