Skip to content

Commit 1529048

Browse files
Fix: Plushies no longer delete items when recycled (space-wizards#32838)
fix
1 parent 7fc27a1 commit 1529048

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

‎Content.Shared/Storage/EntitySystems/SecretStashSystem.cs‎

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
using Content.Shared.IdentityManagement;
1515
using Content.Shared.Tools.EntitySystems;
1616
using Content.Shared.Whitelist;
17+
using Content.Shared.Materials;
18+
using Robust.Shared.Map;
1719

1820
namespace Content.Shared.Storage.EntitySystems;
1921

@@ -35,6 +37,7 @@ public override void Initialize()
3537
base.Initialize();
3638
SubscribeLocalEvent<SecretStashComponent, ComponentInit>(OnInit);
3739
SubscribeLocalEvent<SecretStashComponent, DestructionEventArgs>(OnDestroyed);
40+
SubscribeLocalEvent<SecretStashComponent, GotReclaimedEvent>(OnReclaimed);
3841
SubscribeLocalEvent<SecretStashComponent, InteractUsingEvent>(OnInteractUsing, after: new[] { typeof(ToolOpenableSystem) });
3942
SubscribeLocalEvent<SecretStashComponent, InteractHandEvent>(OnInteractHand);
4043
SubscribeLocalEvent<SecretStashComponent, GetVerbsEvent<InteractionVerb>>(OnGetVerb);
@@ -47,12 +50,12 @@ private void OnInit(Entity<SecretStashComponent> entity, ref ComponentInit args)
4750

4851
private void OnDestroyed(Entity<SecretStashComponent> entity, ref DestructionEventArgs args)
4952
{
50-
var storedInside = _containerSystem.EmptyContainer(entity.Comp.ItemContainer);
51-
if (storedInside != null && storedInside.Count >= 1)
52-
{
53-
var popup = Loc.GetString("comp-secret-stash-on-destroyed-popup", ("stashname", GetStashName(entity)));
54-
_popupSystem.PopupEntity(popup, storedInside[0], PopupType.MediumCaution);
55-
}
53+
DropContentsAndAlert(entity);
54+
}
55+
56+
private void OnReclaimed(Entity<SecretStashComponent> entity, ref GotReclaimedEvent args)
57+
{
58+
DropContentsAndAlert(entity, args.ReclaimerCoordinates);
5659
}
5760

5861
private void OnInteractUsing(Entity<SecretStashComponent> entity, ref InteractUsingEvent args)
@@ -211,5 +214,18 @@ private bool HasItemInside(Entity<SecretStashComponent> entity)
211214
return entity.Comp.ItemContainer.ContainedEntity != null;
212215
}
213216

217+
/// <summary>
218+
/// Drop the item stored in the stash and alert all nearby players with a popup.
219+
/// </summary>
220+
private void DropContentsAndAlert(Entity<SecretStashComponent> entity, EntityCoordinates? cords = null)
221+
{
222+
var storedInside = _containerSystem.EmptyContainer(entity.Comp.ItemContainer, true, cords);
223+
if (storedInside != null && storedInside.Count >= 1)
224+
{
225+
var popup = Loc.GetString("comp-secret-stash-on-destroyed-popup", ("stashname", GetStashName(entity)));
226+
_popupSystem.PopupPredicted(popup, storedInside[0], null, PopupType.MediumCaution);
227+
}
228+
}
229+
214230
#endregion
215231
}

0 commit comments

Comments
 (0)