Delta-v/Content.Server/GameObjects/Components/Destructible/Thresholds/Behaviors/EmptyAllContainersBehaviour.cs

27 lines
859 B
C#

#nullable enable
using Content.Server.GameObjects.EntitySystems;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.GameObjects.Components.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);
}
}
}
}