Fix misc virtual item issues (#5980)
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using Content.Server.Hands.Components;
|
||||
using Content.Shared.Hands;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -13,16 +12,6 @@ namespace Content.Server.Hands.Systems
|
||||
{
|
||||
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<HandVirtualItemComponent, DroppedEvent>(HandleItemDropped);
|
||||
SubscribeLocalEvent<HandVirtualItemComponent, UnequippedHandEvent>(HandleItemUnequipped);
|
||||
|
||||
SubscribeLocalEvent<HandVirtualItemComponent, BeforeInteractEvent>(HandleBeforeInteract);
|
||||
}
|
||||
|
||||
public bool TrySpawnVirtualItemInHand(EntityUid blockingEnt, EntityUid user)
|
||||
{
|
||||
if (EntityManager.TryGetComponent<HandsComponent>(user, out var hands))
|
||||
@@ -45,39 +34,6 @@ namespace Content.Server.Hands.Systems
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void HandleBeforeInteract(
|
||||
EntityUid uid,
|
||||
HandVirtualItemComponent component,
|
||||
BeforeInteractEvent args)
|
||||
{
|
||||
// No interactions with a virtual item, please.
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
// If the virtual item gets removed from the hands for any reason, cancel the pull and delete it.
|
||||
private void HandleItemUnequipped(EntityUid uid, HandVirtualItemComponent component, UnequippedHandEvent args)
|
||||
{
|
||||
Delete(component, args.User);
|
||||
}
|
||||
|
||||
private void HandleItemDropped(EntityUid uid, HandVirtualItemComponent component, DroppedEvent args)
|
||||
{
|
||||
Delete(component, args.UserUid);
|
||||
}
|
||||
|
||||
/// <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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes all virtual items in a user's hands with
|
||||
/// the specified blocked entity.
|
||||
|
||||
Reference in New Issue
Block a user