fix: fix non-access checking EntityTargetActions (#38731)
This commit is contained in:
@@ -334,7 +334,12 @@ namespace Content.Client.Actions
|
|||||||
|
|
||||||
private void OnEntityTargetAttempt(Entity<EntityTargetActionComponent> ent, ref ActionTargetAttemptEvent args)
|
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;
|
return;
|
||||||
|
|
||||||
// let world target component handle it
|
// let world target component handle it
|
||||||
@@ -345,8 +350,6 @@ namespace Content.Client.Actions
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
args.Handled = true;
|
|
||||||
|
|
||||||
var action = args.Action;
|
var action = args.Action;
|
||||||
var user = args.User;
|
var user = args.User;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using Content.Shared.Actions;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Physics;
|
||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
namespace Content.Shared.Actions.Components;
|
namespace Content.Shared.Actions.Components;
|
||||||
@@ -37,6 +37,16 @@ public sealed partial class TargetActionComponent : Component
|
|||||||
[DataField]
|
[DataField]
|
||||||
public bool CheckCanAccess = true;
|
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]
|
[DataField]
|
||||||
public float Range = SharedInteractionSystem.InteractionRange;
|
public float Range = SharedInteractionSystem.InteractionRange;
|
||||||
|
|
||||||
|
|||||||
@@ -417,13 +417,18 @@ public abstract class SharedActionsSystem : EntitySystem
|
|||||||
return comp.CanTargetSelf;
|
return comp.CanTargetSelf;
|
||||||
|
|
||||||
var targetAction = Comp<TargetActionComponent>(uid);
|
var targetAction = Comp<TargetActionComponent>(uid);
|
||||||
|
|
||||||
// not using the ValidateBaseTarget logic since its raycast fails if the target is e.g. a wall
|
// not using the ValidateBaseTarget logic since its raycast fails if the target is e.g. a wall
|
||||||
if (targetAction.CheckCanAccess)
|
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
|
// Just check normal in range, allowing <= 0 range to mean infinite range.
|
||||||
// if it's out of range it probably isn't stored anyway...
|
if (targetAction.Range > 0
|
||||||
return _interaction.CanAccessViaStorage(user, target);
|
&& !_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<WorldTargetActionComponent> ent)
|
public bool ValidateWorldTarget(EntityUid user, EntityCoordinates target, Entity<WorldTargetActionComponent> ent)
|
||||||
|
|||||||
@@ -86,7 +86,11 @@ namespace Content.Shared.Interaction
|
|||||||
private EntityQuery<UseDelayComponent> _delayQuery;
|
private EntityQuery<UseDelayComponent> _delayQuery;
|
||||||
private EntityQuery<ActivatableUIComponent> _uiQuery;
|
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 InteractionRange = 1.5f;
|
||||||
public const float InteractionRangeSquared = InteractionRange * InteractionRange;
|
public const float InteractionRangeSquared = InteractionRange * InteractionRange;
|
||||||
|
|||||||
@@ -35,7 +35,8 @@
|
|||||||
sprite: Objects/Magic/Eldritch/eldritch_actions.rsi
|
sprite: Objects/Magic/Eldritch/eldritch_actions.rsi
|
||||||
state: voidblink
|
state: voidblink
|
||||||
- type: TargetAction
|
- type: TargetAction
|
||||||
checkCanAccess: false
|
accessMask:
|
||||||
|
- Opaque
|
||||||
repeat: false
|
repeat: false
|
||||||
range: 16
|
range: 16
|
||||||
- type: EntityTargetAction
|
- type: EntityTargetAction
|
||||||
|
|||||||
Reference in New Issue
Block a user