diff --git a/Content.Shared/Clothing/EntitySystems/ClothingSystem.cs b/Content.Shared/Clothing/EntitySystems/ClothingSystem.cs index add47be5411..087e2ecedab 100644 --- a/Content.Shared/Clothing/EntitySystems/ClothingSystem.cs +++ b/Content.Shared/Clothing/EntitySystems/ClothingSystem.cs @@ -9,6 +9,7 @@ using Content.Shared.Tag; using Robust.Shared.GameStates; using System.Linq; +using Robust.Shared.Containers; namespace Content.Shared.Clothing.EntitySystems; @@ -19,6 +20,7 @@ public abstract class ClothingSystem : EntitySystem [Dependency] private readonly TagSystem _tagSystem = default!; [Dependency] private readonly InventorySystem _invSystem = default!; [Dependency] private readonly SharedHandsSystem _handsSystem = default!; + [Dependency] private readonly SharedContainerSystem _containerSys = default!; [ValidatePrototypeId] private const string HairTag = "HidesHair"; @@ -36,6 +38,7 @@ public override void Initialize() SubscribeLocalEvent(OnGotEquipped); SubscribeLocalEvent(OnGotUnequipped); SubscribeLocalEvent(OnMaskToggled); + SubscribeLocalEvent(OnPickedUp); SubscribeLocalEvent(OnEquipDoAfter); SubscribeLocalEvent(OnUnequipDoAfter); @@ -165,6 +168,18 @@ private void OnMaskToggled(Entity ent, ref ItemMaskToggledEve ToggleVisualLayer(args.Wearer, HumanoidVisualLayers.Snout, NoseTag); } + private void OnPickedUp(Entity ent, ref GettingPickedUpAttemptEvent args) + { + // If this clothing is equipped by the performer of this action, and the clothing has an unequip delay, stop the attempt + if (ent.Comp.UnequipDelay <= TimeSpan.Zero + || !_invSystem.TryGetContainingSlot(ent.Owner, out var slot) + || !_containerSys.TryGetContainingContainer(ent, out var container) + || container.Owner != args.User) + return; + + args.Cancel(); + } + private void OnEquipDoAfter(Entity ent, ref ClothingEquipDoAfterEvent args) { if (args.Handled || args.Cancelled || args.Target is not { } target)