EmptyAllContainersBehaviour.cs 800 B

12345678910111213141516171819202122
  1. using Robust.Shared.Containers;
  2. namespace Content.Server.Destructible.Thresholds.Behaviors
  3. {
  4. /// <summary>
  5. /// Drop all items from all containers
  6. /// </summary>
  7. [DataDefinition]
  8. public sealed partial class EmptyAllContainersBehaviour : IThresholdBehavior
  9. {
  10. public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
  11. {
  12. if (!system.EntityManager.TryGetComponent<ContainerManagerComponent>(owner, out var containerManager))
  13. return;
  14. foreach (var container in containerManager.GetAllContainers())
  15. {
  16. system.ContainerSystem.EmptyContainer(container, true, system.EntityManager.GetComponent<TransformComponent>(owner).Coordinates);
  17. }
  18. }
  19. }
  20. }