Files
tbd-station-14/Content.Server/Destructible/Thresholds/Behaviors/EmptyAllContainersBehaviour.cs
2023-10-11 20:18:49 +11:00

23 lines
800 B
C#

using Robust.Shared.Containers;
namespace Content.Server.Destructible.Thresholds.Behaviors
{
/// <summary>
/// Drop all items from all containers
/// </summary>
[DataDefinition]
public sealed partial class EmptyAllContainersBehaviour : IThresholdBehavior
{
public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
{
if (!system.EntityManager.TryGetComponent<ContainerManagerComponent>(owner, out var containerManager))
return;
foreach (var container in containerManager.GetAllContainers())
{
system.ContainerSystem.EmptyContainer(container, true, system.EntityManager.GetComponent<TransformComponent>(owner).Coordinates);
}
}
}
}