diff --git a/Content.Client/Actions/ActionsSystem.cs b/Content.Client/Actions/ActionsSystem.cs index 3bfacb5bc6..8efe0b2367 100644 --- a/Content.Client/Actions/ActionsSystem.cs +++ b/Content.Client/Actions/ActionsSystem.cs @@ -334,7 +334,12 @@ namespace Content.Client.Actions private void OnEntityTargetAttempt(Entity 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; diff --git a/Content.Shared/Actions/Components/TargetActionComponent.cs b/Content.Shared/Actions/Components/TargetActionComponent.cs index 0cb9de4946..8d3e764032 100644 --- a/Content.Shared/Actions/Components/TargetActionComponent.cs +++ b/Content.Shared/Actions/Components/TargetActionComponent.cs @@ -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; + /// + /// The collision group to use to check for accessibility if is true. + /// + [DataField] + public CollisionGroup AccessMask = SharedInteractionSystem.InRangeUnobstructedMask; + + /// + /// The allowed range for a target to be. If zero or negative, the range check is skipped, + /// unless is true. + /// [DataField] public float Range = SharedInteractionSystem.InteractionRange; diff --git a/Content.Shared/Actions/SharedActionsSystem.cs b/Content.Shared/Actions/SharedActionsSystem.cs index 333d87157d..69b15235c4 100644 --- a/Content.Shared/Actions/SharedActionsSystem.cs +++ b/Content.Shared/Actions/SharedActionsSystem.cs @@ -417,13 +417,18 @@ public abstract class SharedActionsSystem : EntitySystem return comp.CanTargetSelf; var targetAction = Comp(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); - // 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); + // 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 checkCanAccess isn't set, we allow targeting things in containers + return _interaction.IsAccessible(user, target); } public bool ValidateWorldTarget(EntityUid user, EntityCoordinates target, Entity ent) diff --git a/Content.Shared/Interaction/SharedInteractionSystem.cs b/Content.Shared/Interaction/SharedInteractionSystem.cs index b91f56a836..68e9d8a671 100644 --- a/Content.Shared/Interaction/SharedInteractionSystem.cs +++ b/Content.Shared/Interaction/SharedInteractionSystem.cs @@ -86,7 +86,11 @@ namespace Content.Shared.Interaction private EntityQuery _delayQuery; private EntityQuery _uiQuery; - private const CollisionGroup InRangeUnobstructedMask = CollisionGroup.Impassable | CollisionGroup.InteractImpassable; + /// + /// The collision mask used by default for + /// + /// + public const CollisionGroup InRangeUnobstructedMask = CollisionGroup.Impassable | CollisionGroup.InteractImpassable; public const float InteractionRange = 1.5f; public const float InteractionRangeSquared = InteractionRange * InteractionRange; diff --git a/Resources/Prototypes/Magic/teleport_spells.yml b/Resources/Prototypes/Magic/teleport_spells.yml index ab79a2f5d0..fc166e8c4b 100644 --- a/Resources/Prototypes/Magic/teleport_spells.yml +++ b/Resources/Prototypes/Magic/teleport_spells.yml @@ -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