BurnBodyBehavior.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. using Content.Shared.Body.Components;
  2. using Content.Shared.Inventory;
  3. using Content.Shared.Popups;
  4. using JetBrains.Annotations;
  5. using Robust.Server.GameObjects;
  6. namespace Content.Server.Destructible.Thresholds.Behaviors;
  7. [UsedImplicitly]
  8. [DataDefinition]
  9. public sealed partial class BurnBodyBehavior : IThresholdBehavior
  10. {
  11. public void Execute(EntityUid bodyId, DestructibleSystem system, EntityUid? cause = null)
  12. {
  13. var transformSystem = system.EntityManager.System<TransformSystem>();
  14. var inventorySystem = system.EntityManager.System<InventorySystem>();
  15. var sharedPopupSystem = system.EntityManager.System<SharedPopupSystem>();
  16. if (system.EntityManager.TryGetComponent<InventoryComponent>(bodyId, out var comp))
  17. {
  18. foreach (var item in inventorySystem.GetHandOrInventoryEntities(bodyId))
  19. {
  20. transformSystem.DropNextTo(item, bodyId);
  21. }
  22. }
  23. sharedPopupSystem.PopupCoordinates(Loc.GetString("bodyburn-text-others", ("name", bodyId)), transformSystem.GetMoverCoordinates(bodyId), PopupType.LargeCaution);
  24. system.EntityManager.QueueDeleteEntity(bodyId);
  25. }
  26. }