diff --git a/Content.Shared/Storage/EntitySystems/SecretStashSystem.cs b/Content.Shared/Storage/EntitySystems/SecretStashSystem.cs index 08a69c345f09..af9b768e98be 100644 --- a/Content.Shared/Storage/EntitySystems/SecretStashSystem.cs +++ b/Content.Shared/Storage/EntitySystems/SecretStashSystem.cs @@ -14,6 +14,8 @@ using Content.Shared.IdentityManagement; using Content.Shared.Tools.EntitySystems; using Content.Shared.Whitelist; +using Content.Shared.Materials; +using Robust.Shared.Map; namespace Content.Shared.Storage.EntitySystems; @@ -35,6 +37,7 @@ public override void Initialize() base.Initialize(); SubscribeLocalEvent(OnInit); SubscribeLocalEvent(OnDestroyed); + SubscribeLocalEvent(OnReclaimed); SubscribeLocalEvent(OnInteractUsing, after: new[] { typeof(ToolOpenableSystem) }); SubscribeLocalEvent(OnInteractHand); SubscribeLocalEvent>(OnGetVerb); @@ -47,12 +50,12 @@ private void OnInit(Entity entity, ref ComponentInit args) private void OnDestroyed(Entity entity, ref DestructionEventArgs args) { - var storedInside = _containerSystem.EmptyContainer(entity.Comp.ItemContainer); - if (storedInside != null && storedInside.Count >= 1) - { - var popup = Loc.GetString("comp-secret-stash-on-destroyed-popup", ("stashname", GetStashName(entity))); - _popupSystem.PopupEntity(popup, storedInside[0], PopupType.MediumCaution); - } + DropContentsAndAlert(entity); + } + + private void OnReclaimed(Entity entity, ref GotReclaimedEvent args) + { + DropContentsAndAlert(entity, args.ReclaimerCoordinates); } private void OnInteractUsing(Entity entity, ref InteractUsingEvent args) @@ -211,5 +214,18 @@ private bool HasItemInside(Entity entity) return entity.Comp.ItemContainer.ContainedEntity != null; } + /// + /// Drop the item stored in the stash and alert all nearby players with a popup. + /// + private void DropContentsAndAlert(Entity entity, EntityCoordinates? cords = null) + { + var storedInside = _containerSystem.EmptyContainer(entity.Comp.ItemContainer, true, cords); + if (storedInside != null && storedInside.Count >= 1) + { + var popup = Loc.GetString("comp-secret-stash-on-destroyed-popup", ("stashname", GetStashName(entity))); + _popupSystem.PopupPredicted(popup, storedInside[0], null, PopupType.MediumCaution); + } + } + #endregion }