Fix misc virtual item issues (#5980)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Inventory.Events;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
@@ -11,10 +12,33 @@ public abstract class SharedHandVirtualItemSystem : EntitySystem
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<HandVirtualItemComponent, BeingEquippedAttemptEvent>(OnBeingEquippedAttempt);
|
||||
SubscribeLocalEvent<HandVirtualItemComponent, BeforeInteractEvent>(HandleBeforeInteract);
|
||||
}
|
||||
|
||||
private void OnBeingEquippedAttempt(EntityUid uid, HandVirtualItemComponent component, BeingEquippedAttemptEvent args)
|
||||
{
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
private static void HandleBeforeInteract(
|
||||
EntityUid uid,
|
||||
HandVirtualItemComponent component,
|
||||
BeforeInteractEvent args)
|
||||
{
|
||||
// No interactions with a virtual item, please.
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Queues a deletion for a virtual item and notifies the blocking entity and user.
|
||||
/// </summary>
|
||||
public void Delete(HandVirtualItemComponent comp, EntityUid user)
|
||||
{
|
||||
var userEv = new VirtualItemDeletedEvent(comp.BlockingEntity, user);
|
||||
RaiseLocalEvent(user, userEv, false);
|
||||
var targEv = new VirtualItemDeletedEvent(comp.BlockingEntity, user);
|
||||
RaiseLocalEvent(comp.BlockingEntity, targEv, false);
|
||||
|
||||
EntityManager.QueueDeleteEntity(comp.Owner);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user