From a2329889aa40ef30ca29c1e508e7460ebc710477 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Thu, 9 May 2024 16:00:16 +1000 Subject: [PATCH] Add CanAttack check if target is in a container (#27689) --- Content.Shared/ActionBlocker/ActionBlockerSystem.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Content.Shared/ActionBlocker/ActionBlockerSystem.cs b/Content.Shared/ActionBlocker/ActionBlockerSystem.cs index f5ed2df227..47b3997806 100644 --- a/Content.Shared/ActionBlocker/ActionBlockerSystem.cs +++ b/Content.Shared/ActionBlocker/ActionBlockerSystem.cs @@ -169,8 +169,16 @@ namespace Content.Shared.ActionBlocker public bool CanAttack(EntityUid uid, EntityUid? target = null, Entity? weapon = null, bool disarm = false) { + // If target is in a container can we attack + if (target != null && _container.IsEntityInContainer(target.Value)) + { + return false; + } + _container.TryGetOuterContainer(uid, Transform(uid), out var outerContainer); - if (target != null && target != outerContainer?.Owner && _container.IsEntityInContainer(uid)) + + // If we're in a container can we attack the target. + if (target != null && target != outerContainer?.Owner && _container.IsEntityInContainer(uid)) { var containerEv = new CanAttackFromContainerEvent(uid, target); RaiseLocalEvent(uid, containerEv); -- 2.52.0