@@ -14,6 +14,8 @@ using Content.Shared.Verbs;
|
|||||||
using Content.Shared.IdentityManagement;
|
using Content.Shared.IdentityManagement;
|
||||||
using Content.Shared.Tools.EntitySystems;
|
using Content.Shared.Tools.EntitySystems;
|
||||||
using Content.Shared.Whitelist;
|
using Content.Shared.Whitelist;
|
||||||
|
using Content.Shared.Materials;
|
||||||
|
using Robust.Shared.Map;
|
||||||
|
|
||||||
namespace Content.Shared.Storage.EntitySystems;
|
namespace Content.Shared.Storage.EntitySystems;
|
||||||
|
|
||||||
@@ -35,6 +37,7 @@ public sealed class SecretStashSystem : EntitySystem
|
|||||||
base.Initialize();
|
base.Initialize();
|
||||||
SubscribeLocalEvent<SecretStashComponent, ComponentInit>(OnInit);
|
SubscribeLocalEvent<SecretStashComponent, ComponentInit>(OnInit);
|
||||||
SubscribeLocalEvent<SecretStashComponent, DestructionEventArgs>(OnDestroyed);
|
SubscribeLocalEvent<SecretStashComponent, DestructionEventArgs>(OnDestroyed);
|
||||||
|
SubscribeLocalEvent<SecretStashComponent, GotReclaimedEvent>(OnReclaimed);
|
||||||
SubscribeLocalEvent<SecretStashComponent, InteractUsingEvent>(OnInteractUsing, after: new[] { typeof(ToolOpenableSystem) });
|
SubscribeLocalEvent<SecretStashComponent, InteractUsingEvent>(OnInteractUsing, after: new[] { typeof(ToolOpenableSystem) });
|
||||||
SubscribeLocalEvent<SecretStashComponent, InteractHandEvent>(OnInteractHand);
|
SubscribeLocalEvent<SecretStashComponent, InteractHandEvent>(OnInteractHand);
|
||||||
SubscribeLocalEvent<SecretStashComponent, GetVerbsEvent<InteractionVerb>>(OnGetVerb);
|
SubscribeLocalEvent<SecretStashComponent, GetVerbsEvent<InteractionVerb>>(OnGetVerb);
|
||||||
@@ -47,12 +50,12 @@ public sealed class SecretStashSystem : EntitySystem
|
|||||||
|
|
||||||
private void OnDestroyed(Entity<SecretStashComponent> entity, ref DestructionEventArgs args)
|
private void OnDestroyed(Entity<SecretStashComponent> entity, ref DestructionEventArgs args)
|
||||||
{
|
{
|
||||||
var storedInside = _containerSystem.EmptyContainer(entity.Comp.ItemContainer);
|
DropContentsAndAlert(entity);
|
||||||
if (storedInside != null && storedInside.Count >= 1)
|
}
|
||||||
{
|
|
||||||
var popup = Loc.GetString("comp-secret-stash-on-destroyed-popup", ("stashname", GetStashName(entity)));
|
private void OnReclaimed(Entity<SecretStashComponent> entity, ref GotReclaimedEvent args)
|
||||||
_popupSystem.PopupEntity(popup, storedInside[0], PopupType.MediumCaution);
|
{
|
||||||
}
|
DropContentsAndAlert(entity, args.ReclaimerCoordinates);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnInteractUsing(Entity<SecretStashComponent> entity, ref InteractUsingEvent args)
|
private void OnInteractUsing(Entity<SecretStashComponent> entity, ref InteractUsingEvent args)
|
||||||
@@ -211,5 +214,18 @@ public sealed class SecretStashSystem : EntitySystem
|
|||||||
return entity.Comp.ItemContainer.ContainedEntity != null;
|
return entity.Comp.ItemContainer.ContainedEntity != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Drop the item stored in the stash and alert all nearby players with a popup.
|
||||||
|
/// </summary>
|
||||||
|
private void DropContentsAndAlert(Entity<SecretStashComponent> 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
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user