1
0

RequiresGridSystem.cs 749 B

1234567891011121314151617181920212223242526272829
  1. using Content.Server.Destructible;
  2. namespace Content.Server.RequiresGrid;
  3. public sealed class RequiresGridSystem : EntitySystem
  4. {
  5. [Dependency] private readonly DestructibleSystem _destructible = default!;
  6. public override void Initialize()
  7. {
  8. base.Initialize();
  9. SubscribeLocalEvent<RequiresGridComponent, EntParentChangedMessage>(OnEntParentChanged);
  10. }
  11. private void OnEntParentChanged(EntityUid owner, RequiresGridComponent component, EntParentChangedMessage args)
  12. {
  13. if (args.OldParent == null)
  14. return;
  15. if (args.Transform.GridUid != null)
  16. return;
  17. if (TerminatingOrDeleted(owner))
  18. return;
  19. _destructible.DestroyEntity(owner);
  20. }
  21. }