Files
tbd-station-14/Content.Server/Destructible/Thresholds/Behaviors/EmptyAllContainersBehaviour.cs
Javier Guardia Fernández 42aaba9a5d Remove most IEntity usages from explosions (#5240)
* Remove most IEntity usages from Destructible and Explosions

* Perform a minute amount of cleanup

* Fix build
2021-11-09 21:24:35 +01:00

25 lines
823 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(EntityUid owner, DestructibleSystem system)
{
if (!system.EntityManager.TryGetComponent<ContainerManagerComponent>(owner, out var containerManager))
return;
foreach (var container in containerManager.GetAllContainers())
{
container.EmptyContainer(true, system.EntityManager.GetComponent<TransformComponent>(owner).Coordinates);
}
}
}
}