diff --git a/Content.Server/Construction/Completions/DestroyEntity.cs b/Content.Server/Construction/Completions/DestroyEntity.cs new file mode 100644 index 0000000000..ec19d58574 --- /dev/null +++ b/Content.Server/Construction/Completions/DestroyEntity.cs @@ -0,0 +1,23 @@ +#nullable enable +using Content.Server.GameObjects.EntitySystems; +using Content.Shared.Construction; +using JetBrains.Annotations; +using Robust.Shared.GameObjects; +using Robust.Shared.Serialization.Manager.Attributes; +using System.Threading.Tasks; + +namespace Content.Server.Construction.Completions +{ + [UsedImplicitly] + [DataDefinition] + public class DestroyEntity : IGraphAction + { + public async Task PerformAction(IEntity entity, IEntity? user) + { + if (entity.Deleted) return; + + var destructibleSystem = EntitySystem.Get(); + destructibleSystem.ActSystem.HandleDestruction(entity); + } + } +} diff --git a/Content.Server/GameObjects/Components/Strap/StrapComponent.cs b/Content.Server/GameObjects/Components/Strap/StrapComponent.cs index b4402c438c..7909f81a21 100644 --- a/Content.Server/GameObjects/Components/Strap/StrapComponent.cs +++ b/Content.Server/GameObjects/Components/Strap/StrapComponent.cs @@ -1,9 +1,10 @@ -#nullable enable +#nullable enable using System.Collections.Generic; using System.Linq; using Content.Server.GameObjects.Components.Buckle; using Content.Shared.Alert; using Content.Shared.GameObjects.Components.Strap; +using Content.Shared.GameObjects.EntitySystems; using Content.Shared.GameObjects.EntitySystems.ActionBlocker; using Content.Shared.GameObjects.Verbs; using Content.Shared.Interfaces.GameObjects.Components; @@ -20,7 +21,7 @@ namespace Content.Server.GameObjects.Components.Strap { [RegisterComponent] [ComponentReference(typeof(SharedStrapComponent))] - public class StrapComponent : SharedStrapComponent, IInteractHand, ISerializationHooks + public class StrapComponent : SharedStrapComponent, IInteractHand, ISerializationHooks, IDestroyAct { [ComponentDependency] public readonly SpriteComponent? SpriteComponent = null; @@ -134,6 +135,16 @@ namespace Content.Server.GameObjects.Components.Strap { base.OnRemove(); + RemoveAll(); + } + + void IDestroyAct.OnDestroy(DestructionEventArgs eventArgs) + { + RemoveAll(); + } + + private void RemoveAll() + { foreach (var entity in _buckledEntities.ToArray()) { if (entity.TryGetComponent(out var buckle)) diff --git a/Resources/Prototypes/Recipes/Construction/Graphs/seats.yml b/Resources/Prototypes/Recipes/Construction/Graphs/seats.yml index c7cfb34048..3652262ecd 100644 --- a/Resources/Prototypes/Recipes/Construction/Graphs/seats.yml +++ b/Resources/Prototypes/Recipes/Construction/Graphs/seats.yml @@ -4,7 +4,7 @@ graph: - node: start actions: - - !type:DeleteEntity {} + - !type:DestroyEntity {} edges: - to: chair steps: