]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add CanAttack check if target is in a container (#27689)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Thu, 9 May 2024 06:00:16 +0000 (16:00 +1000)
committerGitHub <noreply@github.com>
Thu, 9 May 2024 06:00:16 +0000 (23:00 -0700)
Content.Shared/ActionBlocker/ActionBlockerSystem.cs

index f5ed2df227c491ac7277397fbd1e5281ab08c563..47b3997806d32fd5cb0bccc9028792b3a25a2111 100644 (file)
@@ -169,8 +169,16 @@ namespace Content.Shared.ActionBlocker
 
         public bool CanAttack(EntityUid uid, EntityUid? target = null, Entity<MeleeWeaponComponent>? 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);