var entOptions = GetValidActions<EntityTargetActionComponent>(component.ActionEntities, args.CanReach);
for (var i = entOptions.Count - 1; i >= 0; i--)
{
- var action = entOptions[i].Comp;
+ var action = entOptions[i];
if (!_actions.ValidateEntityTarget(args.User, args.Target.Value, action))
entOptions.RemoveAt(i);
}
var options = GetValidActions<WorldTargetActionComponent>(component.ActionEntities, args.CanReach);
for (var i = options.Count - 1; i >= 0; i--)
{
- var action = options[i].Comp;
+ var action = options[i];
if (!_actions.ValidateWorldTarget(args.User, args.ClickLocation, action))
options.RemoveAt(i);
}
using Content.Shared.Interaction;
using Content.Shared.Inventory.Events;
using Content.Shared.Mind;
-using Content.Shared.Mobs.Components;
+using Content.Shared.Rejuvenate;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
using Robust.Shared.Map;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
-using Content.Shared.Rejuvenate;
namespace Content.Shared.Actions;
var targetWorldPos = _transformSystem.GetWorldPosition(entityTarget);
_rotateToFaceSystem.TryFaceCoordinates(user, targetWorldPos);
- if (!ValidateEntityTarget(user, entityTarget, entityAction))
+ if (!ValidateEntityTarget(user, entityTarget, (actionEnt, entityAction)))
return;
_adminLogger.Add(LogType.Action,
var entityCoordinatesTarget = GetCoordinates(netCoordinatesTarget);
_rotateToFaceSystem.TryFaceCoordinates(user, entityCoordinatesTarget.ToMapPos(EntityManager, _transformSystem));
- if (!ValidateWorldTarget(user, entityCoordinatesTarget, worldAction))
+ if (!ValidateWorldTarget(user, entityCoordinatesTarget, (actionEnt, worldAction)))
return;
_adminLogger.Add(LogType.Action,
PerformAction(user, component, actionEnt, action, performEvent, curTime);
}
- public bool ValidateEntityTarget(EntityUid user, EntityUid target, EntityTargetActionComponent action)
+ public bool ValidateEntityTarget(EntityUid user, EntityUid target, Entity<EntityTargetActionComponent> actionEnt)
+ {
+ if (!ValidateEntityTargetBase(user, target, actionEnt))
+ return false;
+
+ var ev = new ValidateActionEntityTargetEvent(user, target);
+ RaiseLocalEvent(actionEnt, ref ev);
+ return !ev.Cancelled;
+ }
+
+ private bool ValidateEntityTargetBase(EntityUid user, EntityUid target, EntityTargetActionComponent action)
{
if (!target.IsValid() || Deleted(target))
return false;
return _interactionSystem.CanAccessViaStorage(user, target);
}
- public bool ValidateWorldTarget(EntityUid user, EntityCoordinates coords, WorldTargetActionComponent action)
+ public bool ValidateWorldTarget(EntityUid user, EntityCoordinates coords, Entity<WorldTargetActionComponent> action)
+ {
+ if (!ValidateWorldTargetBase(user, coords, action))
+ return false;
+
+ var ev = new ValidateActionWorldTargetEvent(user, coords);
+ RaiseLocalEvent(action, ref ev);
+ return !ev.Cancelled;
+ }
+
+ private bool ValidateWorldTargetBase(EntityUid user, EntityCoordinates coords, WorldTargetActionComponent action)
{
if (action.CheckCanInteract && !_actionBlockerSystem.CanInteract(user, null))
return false;