Strap bug fixes (#10142)
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using Content.Server.Buckle.Components;
|
using Content.Server.Buckle.Components;
|
||||||
|
using Content.Server.Construction.Completions;
|
||||||
using Content.Server.Interaction;
|
using Content.Server.Interaction;
|
||||||
using Content.Shared.Destructible;
|
using Content.Shared.Destructible;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
@@ -8,7 +9,6 @@ using JetBrains.Annotations;
|
|||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
|
|
||||||
|
|
||||||
namespace Content.Server.Buckle.Systems
|
namespace Content.Server.Buckle.Systems
|
||||||
{
|
{
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
@@ -23,7 +23,19 @@ namespace Content.Server.Buckle.Systems
|
|||||||
SubscribeLocalEvent<StrapComponent, GetVerbsEvent<InteractionVerb>>(AddStrapVerbs);
|
SubscribeLocalEvent<StrapComponent, GetVerbsEvent<InteractionVerb>>(AddStrapVerbs);
|
||||||
SubscribeLocalEvent<StrapComponent, ContainerGettingInsertedAttemptEvent>(OnInsertAttempt);
|
SubscribeLocalEvent<StrapComponent, ContainerGettingInsertedAttemptEvent>(OnInsertAttempt);
|
||||||
SubscribeLocalEvent<StrapComponent, InteractHandEvent>(OnInteractHand);
|
SubscribeLocalEvent<StrapComponent, InteractHandEvent>(OnInteractHand);
|
||||||
SubscribeLocalEvent<StrapComponent, DestructionEventArgs>(OnDestroy);
|
SubscribeLocalEvent<StrapComponent, DestructionEventArgs>((_,c,_) => RemoveAll(c));
|
||||||
|
SubscribeLocalEvent<StrapComponent, BreakageEventArgs>((_, c, _) => RemoveAll(c));
|
||||||
|
SubscribeLocalEvent<StrapComponent, ConstructionBeforeDeleteEvent>((_, c, _) => RemoveAll(c));
|
||||||
|
SubscribeLocalEvent<StrapComponent, ComponentShutdown>(OnShutdown);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnShutdown(EntityUid uid, StrapComponent component, ComponentShutdown args)
|
||||||
|
{
|
||||||
|
if (LifeStage(uid) > EntityLifeStage.MapInitialized)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Component is being removed, but entity is not shutting down.
|
||||||
|
component.RemoveAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnInsertAttempt(EntityUid uid, StrapComponent component, ContainerGettingInsertedAttemptEvent args)
|
private void OnInsertAttempt(EntityUid uid, StrapComponent component, ContainerGettingInsertedAttemptEvent args)
|
||||||
@@ -123,7 +135,7 @@ namespace Content.Server.Buckle.Systems
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDestroy(EntityUid uid, StrapComponent component, DestructionEventArgs args)
|
public void RemoveAll(StrapComponent component)
|
||||||
{
|
{
|
||||||
component.RemoveAll();
|
component.RemoveAll();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,28 @@
|
|||||||
using Content.Shared.Construction;
|
using Content.Shared.Construction;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
|
||||||
namespace Content.Server.Construction.Completions
|
namespace Content.Server.Construction.Completions
|
||||||
{
|
{
|
||||||
|
public sealed class ConstructionBeforeDeleteEvent : CancellableEntityEventArgs
|
||||||
|
{
|
||||||
|
public EntityUid? User;
|
||||||
|
|
||||||
|
public ConstructionBeforeDeleteEvent(EntityUid? user)
|
||||||
|
{
|
||||||
|
User = user;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
[DataDefinition]
|
[DataDefinition]
|
||||||
public sealed class DeleteEntity : IGraphAction
|
public sealed class DeleteEntity : IGraphAction
|
||||||
{
|
{
|
||||||
public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager)
|
public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager)
|
||||||
{
|
{
|
||||||
|
var ev = new ConstructionBeforeDeleteEvent(userUid);
|
||||||
|
entityManager.EventBus.RaiseLocalEvent(uid, ev);
|
||||||
|
|
||||||
|
if (!ev.Cancelled)
|
||||||
entityManager.DeleteEntity(uid);
|
entityManager.DeleteEntity(uid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user