From a527e07b2b3b63bfd7b518efd8f9efa081afce46 Mon Sep 17 00:00:00 2001 From: Alex Evgrashin Date: Tue, 3 May 2022 01:50:11 +0300 Subject: [PATCH] Fixed C4 unstick verb checks (#7870) --- Content.Server/Sticky/Systems/StickySystem.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Content.Server/Sticky/Systems/StickySystem.cs b/Content.Server/Sticky/Systems/StickySystem.cs index 8e4b533141..6f6376e991 100644 --- a/Content.Server/Sticky/Systems/StickySystem.cs +++ b/Content.Server/Sticky/Systems/StickySystem.cs @@ -17,6 +17,7 @@ public sealed class StickySystem : EntitySystem [Dependency] private readonly PopupSystem _popupSystem = default!; [Dependency] private readonly SharedContainerSystem _containerSystem = default!; [Dependency] private readonly SharedHandsSystem _handsSystem = default!; + [Dependency] private readonly SharedInteractionSystem _interactionSystem = default!; private const string StickerSlotId = "stickers_container"; @@ -40,7 +41,14 @@ public sealed class StickySystem : EntitySystem private void AddUnstickVerb(EntityUid uid, StickyComponent component, GetVerbsEvent args) { - if (component.StuckTo == null || !component.CanUnstick) + if (component.StuckTo == null || !component.CanUnstick || !args.CanInteract) + return; + + // we can't use args.CanAccess, because it stuck in another container + // we also need to ignore entity that it stuck to + var inRange = _interactionSystem.InRangeUnobstructed(uid, args.User, + predicate: entity => component.StuckTo == entity); + if (!inRange) return; args.Verbs.Add(new Verb @@ -131,8 +139,6 @@ public sealed class StickySystem : EntitySystem // if delay is zero - unstick entity immediately UnstickFromEntity(uid, user, component); } - - return; } private void OnUnstickSuccessful(UnstickSuccessfulEvent ev)