Fix chairs not unbuckling entities when deconstructed or destroyed (#3696)
This commit is contained in:
23
Content.Server/Construction/Completions/DestroyEntity.cs
Normal file
23
Content.Server/Construction/Completions/DestroyEntity.cs
Normal file
@@ -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>();
|
||||||
|
destructibleSystem.ActSystem.HandleDestruction(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Server.GameObjects.Components.Buckle;
|
using Content.Server.GameObjects.Components.Buckle;
|
||||||
using Content.Shared.Alert;
|
using Content.Shared.Alert;
|
||||||
using Content.Shared.GameObjects.Components.Strap;
|
using Content.Shared.GameObjects.Components.Strap;
|
||||||
|
using Content.Shared.GameObjects.EntitySystems;
|
||||||
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
|
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
|
||||||
using Content.Shared.GameObjects.Verbs;
|
using Content.Shared.GameObjects.Verbs;
|
||||||
using Content.Shared.Interfaces.GameObjects.Components;
|
using Content.Shared.Interfaces.GameObjects.Components;
|
||||||
@@ -20,7 +21,7 @@ namespace Content.Server.GameObjects.Components.Strap
|
|||||||
{
|
{
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
[ComponentReference(typeof(SharedStrapComponent))]
|
[ComponentReference(typeof(SharedStrapComponent))]
|
||||||
public class StrapComponent : SharedStrapComponent, IInteractHand, ISerializationHooks
|
public class StrapComponent : SharedStrapComponent, IInteractHand, ISerializationHooks, IDestroyAct
|
||||||
{
|
{
|
||||||
[ComponentDependency] public readonly SpriteComponent? SpriteComponent = null;
|
[ComponentDependency] public readonly SpriteComponent? SpriteComponent = null;
|
||||||
|
|
||||||
@@ -134,6 +135,16 @@ namespace Content.Server.GameObjects.Components.Strap
|
|||||||
{
|
{
|
||||||
base.OnRemove();
|
base.OnRemove();
|
||||||
|
|
||||||
|
RemoveAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
void IDestroyAct.OnDestroy(DestructionEventArgs eventArgs)
|
||||||
|
{
|
||||||
|
RemoveAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RemoveAll()
|
||||||
|
{
|
||||||
foreach (var entity in _buckledEntities.ToArray())
|
foreach (var entity in _buckledEntities.ToArray())
|
||||||
{
|
{
|
||||||
if (entity.TryGetComponent<BuckleComponent>(out var buckle))
|
if (entity.TryGetComponent<BuckleComponent>(out var buckle))
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
graph:
|
graph:
|
||||||
- node: start
|
- node: start
|
||||||
actions:
|
actions:
|
||||||
- !type:DeleteEntity {}
|
- !type:DestroyEntity {}
|
||||||
edges:
|
edges:
|
||||||
- to: chair
|
- to: chair
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
Reference in New Issue
Block a user