1414using Content . Shared . IdentityManagement ;
1515using Content . Shared . Tools . EntitySystems ;
1616using Content . Shared . Whitelist ;
17+ using Content . Shared . Materials ;
18+ using Robust . Shared . Map ;
1719
1820namespace 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