]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
fix: fix non-access checking EntityTargetActions (#38731)
authorPerry Fraser <perryprog@users.noreply.github.com>
Tue, 22 Jul 2025 19:34:39 +0000 (15:34 -0400)
committerGitHub <noreply@github.com>
Tue, 22 Jul 2025 19:34:39 +0000 (21:34 +0200)
Content.Client/Actions/ActionsSystem.cs
Content.Shared/Actions/Components/TargetActionComponent.cs
Content.Shared/Actions/SharedActionsSystem.cs
Content.Shared/Interaction/SharedInteractionSystem.cs
Resources/Prototypes/Magic/teleport_spells.yml

index 3bfacb5bc6e8f3f55f5e3fa04730ba565e1de21d..8efe0b2367f8d32feb2b789da7bb00de9de6fc9e 100644 (file)
@@ -334,7 +334,12 @@ namespace Content.Client.Actions
 
         private void OnEntityTargetAttempt(Entity<EntityTargetActionComponent> ent, ref ActionTargetAttemptEvent args)
         {
-            if (args.Handled || args.Input.EntityUid is not { Valid: true } entity)
+            if (args.Handled)
+                return;
+
+            args.Handled = true;
+
+            if (args.Input.EntityUid is not { Valid: true } entity)
                 return;
 
             // let world target component handle it
@@ -345,8 +350,6 @@ namespace Content.Client.Actions
                 return;
             }
 
-            args.Handled = true;
-
             var action = args.Action;
             var user = args.User;
 
index 0cb9de49468a8d243fd35fb8ea91787bdc2dd744..8d3e7640324dc0b1657cd6820a87c905010ccaf6 100644 (file)
@@ -1,6 +1,6 @@
-using Content.Shared.Actions;
-using Content.Shared.Interaction;
-using Robust.Shared.GameStates;
+using Content.Shared.Interaction;
+using Content.Shared.Physics;
+using Robust.Shared.GameStates;
 using Robust.Shared.Prototypes;
 
 namespace Content.Shared.Actions.Components;
@@ -37,6 +37,16 @@ public sealed partial class TargetActionComponent : Component
     [DataField]
     public bool CheckCanAccess = true;
 
+    /// <summary>
+    ///     The collision group to use to check for accessibility if <see cref="CheckCanAccess" /> is true.
+    /// </summary>
+    [DataField]
+    public CollisionGroup AccessMask = SharedInteractionSystem.InRangeUnobstructedMask;
+
+    /// <summary>
+    ///     The allowed range for a target to be. If zero or negative, the range check is skipped,
+    ///     unless <see cref="CheckCanAccess"/> is true.
+    /// </summary>
     [DataField]
     public float Range = SharedInteractionSystem.InteractionRange;
 
index 333d87157d04c14bde1be9b057eba8b652318c88..69b15235c4cea2dec31fe7c14015b426043e6a15 100644 (file)
@@ -417,13 +417,18 @@ public abstract class SharedActionsSystem : EntitySystem
             return comp.CanTargetSelf;
 
         var targetAction = Comp<TargetActionComponent>(uid);
+
         // not using the ValidateBaseTarget logic since its raycast fails if the target is e.g. a wall
         if (targetAction.CheckCanAccess)
-            return _interaction.InRangeAndAccessible(user, target, range: targetAction.Range);
+            return _interaction.InRangeAndAccessible(user, target, targetAction.Range, targetAction.AccessMask);
+
+        // Just check normal in range, allowing <= 0 range to mean infinite range.
+        if (targetAction.Range > 0
+            && !_transform.InRange(user, target, targetAction.Range))
+            return false;
 
-        // if not just checking pure range, let stored entities be targeted by actions
-        // if it's out of range it probably isn't stored anyway...
-        return _interaction.CanAccessViaStorage(user, target);
+        // If checkCanAccess isn't set, we allow targeting things in containers
+        return _interaction.IsAccessible(user, target);
     }
 
     public bool ValidateWorldTarget(EntityUid user, EntityCoordinates target, Entity<WorldTargetActionComponent> ent)
index b91f56a8360ed28552454c684050419d84099092..68e9d8a6717da2a8c096da2777bd3910d6b31d35 100644 (file)
@@ -86,7 +86,11 @@ namespace Content.Shared.Interaction
         private EntityQuery<UseDelayComponent> _delayQuery;
         private EntityQuery<ActivatableUIComponent> _uiQuery;
 
-        private const CollisionGroup InRangeUnobstructedMask = CollisionGroup.Impassable | CollisionGroup.InteractImpassable;
+        /// <summary>
+        /// The collision mask used by default for
+        /// <see cref="InRangeUnobstructed(MapCoordinates,MapCoordinates,float,CollisionGroup,Ignored?,bool)" />
+        /// </summary>
+        public const CollisionGroup InRangeUnobstructedMask = CollisionGroup.Impassable | CollisionGroup.InteractImpassable;
 
         public const float InteractionRange = 1.5f;
         public const float InteractionRangeSquared = InteractionRange * InteractionRange;
index ab79a2f5d0cab8014a95434b7807647abd52a0b2..fc166e8c4bc7ca5f304f696360b3c5fd42c0c5f7 100644 (file)
@@ -35,7 +35,8 @@
       sprite: Objects/Magic/Eldritch/eldritch_actions.rsi
       state: voidblink
   - type: TargetAction
-    checkCanAccess: false
+    accessMask:
+    - Opaque
     repeat: false
     range: 16
   - type: EntityTargetAction