Add RequiresGrid component (#23394)
* saving working code * add checks for deletion
This commit is contained in:
29
Content.Server/RequiresGrid/RequiresGridSystem.cs
Normal file
29
Content.Server/RequiresGrid/RequiresGridSystem.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user