2023-08-12 17:39:58 -04:00
|
|
|
using Robust.Server.Containers;
|
|
|
|
|
using Robust.Shared.Containers;
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.Destructible.Thresholds.Behaviors
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Drop all items from specified containers
|
|
|
|
|
/// </summary>
|
|
|
|
|
[DataDefinition]
|
2023-08-22 18:14:33 -07:00
|
|
|
public sealed partial class EmptyContainersBehaviour : IThresholdBehavior
|
2023-08-12 17:39:58 -04:00
|
|
|
{
|
|
|
|
|
[DataField("containers")]
|
|
|
|
|
public List<string> Containers = new();
|
|
|
|
|
|
|
|
|
|
public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
|
|
|
|
|
{
|
|
|
|
|
if (!system.EntityManager.TryGetComponent<ContainerManagerComponent>(owner, out var containerManager))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var containerSys = system.EntityManager.System<ContainerSystem>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var containerId in Containers)
|
|
|
|
|
{
|
|
|
|
|
if (!containerSys.TryGetContainer(owner, containerId, out var container, containerManager))
|
|
|
|
|
continue;
|
|
|
|
|
|
2023-08-14 19:34:23 -04:00
|
|
|
containerSys.EmptyContainer(container, true);
|
2023-08-12 17:39:58 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|