Files
crystall-punk-14/Content.Server/Destructible/Thresholds/Behaviors/EmptyAllContainersBehaviour.cs
2021-07-16 17:37:09 -07:00

25 lines
771 B
C#

using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Destructible.Thresholds.Behaviors
{
/// <summary>
/// Drop all items from all containers
/// </summary>
[DataDefinition]
public class EmptyAllContainersBehaviour : IThresholdBehavior
{
public void Execute(IEntity owner, DestructibleSystem system)
{
if (owner.Deleted || !owner.TryGetComponent<ContainerManagerComponent>(out var containerManager))
return;
foreach (var container in containerManager.GetAllContainers())
{
container.EmptyContainer(true, owner.Transform.Coordinates);
}
}
}
}