mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 13:37:47 +03:00
* saving working code * add checks for deletion (cherry picked from commit 487dd113b05aa54a8683f6be980a60f3e431d226)
30 lines
749 B
C#
30 lines
749 B
C#
using Content.Server.Destructible;
|
|
|
|
namespace Content.Server.RequiresGrid;
|
|
|
|
public sealed class RequiresGridSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly DestructibleSystem _destructible = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<RequiresGridComponent, EntParentChangedMessage>(OnEntParentChanged);
|
|
}
|
|
|
|
private void OnEntParentChanged(EntityUid owner, RequiresGridComponent component, EntParentChangedMessage args)
|
|
{
|
|
if (args.OldParent == null)
|
|
return;
|
|
|
|
if (args.Transform.GridUid != null)
|
|
return;
|
|
|
|
if (TerminatingOrDeleted(owner))
|
|
return;
|
|
|
|
_destructible.DestroyEntity(owner);
|
|
}
|
|
}
|