Prevent virtual item storage and popups (#30020)
* Prevent virtual item storage and popups * fix typo * add comment
This commit is contained in:
@@ -62,21 +62,22 @@ public sealed class SmartEquipSystem : EntitySystem
|
|||||||
if (playerSession.AttachedEntity is not { Valid: true } uid || !Exists(uid))
|
if (playerSession.AttachedEntity is not { Valid: true } uid || !Exists(uid))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!_actionBlocker.CanInteract(uid, null))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// early out if we don't have any hands or a valid inventory slot
|
// early out if we don't have any hands or a valid inventory slot
|
||||||
if (!TryComp<HandsComponent>(uid, out var hands) || hands.ActiveHand == null)
|
if (!TryComp<HandsComponent>(uid, out var hands) || hands.ActiveHand == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
var handItem = hands.ActiveHand.HeldEntity;
|
||||||
|
|
||||||
|
// can the user interact, and is the item interactable? e.g. virtual items
|
||||||
|
if (!_actionBlocker.CanInteract(uid, handItem))
|
||||||
|
return;
|
||||||
|
|
||||||
if (!TryComp<InventoryComponent>(uid, out var inventory) || !_inventory.HasSlot(uid, equipmentSlot, inventory))
|
if (!TryComp<InventoryComponent>(uid, out var inventory) || !_inventory.HasSlot(uid, equipmentSlot, inventory))
|
||||||
{
|
{
|
||||||
_popup.PopupClient(Loc.GetString("smart-equip-missing-equipment-slot", ("slotName", equipmentSlot)), uid, uid);
|
_popup.PopupClient(Loc.GetString("smart-equip-missing-equipment-slot", ("slotName", equipmentSlot)), uid, uid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var handItem = hands.ActiveHand.HeldEntity;
|
|
||||||
|
|
||||||
// early out if we have an item and cant drop it at all
|
// early out if we have an item and cant drop it at all
|
||||||
if (handItem != null && !_hands.CanDropHeld(uid, hands.ActiveHand))
|
if (handItem != null && !_hands.CanDropHeld(uid, hands.ActiveHand))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using System.Diagnostics.CodeAnalysis;
|
|||||||
using Content.Shared.Hands;
|
using Content.Shared.Hands;
|
||||||
using Content.Shared.Hands.EntitySystems;
|
using Content.Shared.Hands.EntitySystems;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
|
using Content.Shared.Interaction.Events;
|
||||||
using Content.Shared.Inventory.Events;
|
using Content.Shared.Inventory.Events;
|
||||||
using Content.Shared.Item;
|
using Content.Shared.Item;
|
||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
@@ -43,6 +44,7 @@ public abstract class SharedVirtualItemSystem : EntitySystem
|
|||||||
SubscribeLocalEvent<VirtualItemComponent, BeingUnequippedAttemptEvent>(OnBeingUnequippedAttempt);
|
SubscribeLocalEvent<VirtualItemComponent, BeingUnequippedAttemptEvent>(OnBeingUnequippedAttempt);
|
||||||
|
|
||||||
SubscribeLocalEvent<VirtualItemComponent, BeforeRangedInteractEvent>(OnBeforeRangedInteract);
|
SubscribeLocalEvent<VirtualItemComponent, BeforeRangedInteractEvent>(OnBeforeRangedInteract);
|
||||||
|
SubscribeLocalEvent<VirtualItemComponent, GettingInteractedWithAttemptEvent>(OnGettingInteractedWithAttemptEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -72,6 +74,12 @@ public abstract class SharedVirtualItemSystem : EntitySystem
|
|||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnGettingInteractedWithAttemptEvent(Entity<VirtualItemComponent> ent, ref GettingInteractedWithAttemptEvent args)
|
||||||
|
{
|
||||||
|
// No interactions with a virtual item, please.
|
||||||
|
args.Cancelled = true;
|
||||||
|
}
|
||||||
|
|
||||||
#region Hands
|
#region Hands
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -5,4 +5,5 @@
|
|||||||
noSpawn: true
|
noSpawn: true
|
||||||
components:
|
components:
|
||||||
- type: Item
|
- type: Item
|
||||||
|
size: Ginormous # no storage insertion visuals
|
||||||
- type: VirtualItem
|
- type: VirtualItem
|
||||||
|
|||||||
Reference in New Issue
Block a user