DeleteEntity.cs 795 B

1234567891011121314151617181920212223242526272829
  1. using Content.Shared.Construction;
  2. using JetBrains.Annotations;
  3. namespace Content.Server.Construction.Completions
  4. {
  5. public sealed class ConstructionBeforeDeleteEvent : CancellableEntityEventArgs
  6. {
  7. public EntityUid? User;
  8. public ConstructionBeforeDeleteEvent(EntityUid? user)
  9. {
  10. User = user;
  11. }
  12. }
  13. [UsedImplicitly]
  14. [DataDefinition]
  15. public sealed partial class DeleteEntity : IGraphAction
  16. {
  17. public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager)
  18. {
  19. var ev = new ConstructionBeforeDeleteEvent(userUid);
  20. entityManager.EventBus.RaiseLocalEvent(uid, ev);
  21. if (!ev.Cancelled)
  22. entityManager.DeleteEntity(uid);
  23. }
  24. }
  25. }