World target action uses entity coordinates (#12484)
This commit is contained in:
@@ -156,27 +156,27 @@ public abstract class SharedActionsSystem : EntitySystem
|
||||
|
||||
case WorldTargetAction worldAction:
|
||||
|
||||
if (ev.MapTarget is not MapCoordinates mapTarget)
|
||||
if (ev.EntityCoordinatesTarget is not EntityCoordinates entityCoordinatesTarget)
|
||||
{
|
||||
Logger.Error($"Attempted to perform a map-targeted action without a target! Action: {worldAction.DisplayName}");
|
||||
Logger.Error($"Attempted to perform a world-targeted action without a target! Action: {worldAction.DisplayName}");
|
||||
return;
|
||||
}
|
||||
|
||||
_rotateToFaceSystem.TryFaceCoordinates(user, mapTarget.Position);
|
||||
_rotateToFaceSystem.TryFaceCoordinates(user, entityCoordinatesTarget.Position);
|
||||
|
||||
if (!ValidateWorldTarget(user, mapTarget, worldAction))
|
||||
if (!ValidateWorldTarget(user, entityCoordinatesTarget, worldAction))
|
||||
return;
|
||||
|
||||
if (act.Provider == null)
|
||||
_adminLogger.Add(LogType.Action,
|
||||
$"{ToPrettyString(user):user} is performing the {name:action} action targeted at {mapTarget:target}.");
|
||||
$"{ToPrettyString(user):user} is performing the {name:action} action targeted at {entityCoordinatesTarget:target}.");
|
||||
else
|
||||
_adminLogger.Add(LogType.Action,
|
||||
$"{ToPrettyString(user):user} is performing the {name:action} action (provided by {ToPrettyString(act.Provider.Value):provider}) targeted at {mapTarget:target}.");
|
||||
$"{ToPrettyString(user):user} is performing the {name:action} action (provided by {ToPrettyString(act.Provider.Value):provider}) targeted at {entityCoordinatesTarget:target}.");
|
||||
|
||||
if (worldAction.Event != null)
|
||||
{
|
||||
worldAction.Event.Target = mapTarget;
|
||||
worldAction.Event.Target = entityCoordinatesTarget;
|
||||
performEvent = worldAction.Event;
|
||||
}
|
||||
|
||||
@@ -243,11 +243,8 @@ public abstract class SharedActionsSystem : EntitySystem
|
||||
return _interactionSystem.CanAccessViaStorage(user, target);
|
||||
}
|
||||
|
||||
public bool ValidateWorldTarget(EntityUid user, MapCoordinates coords, WorldTargetAction action)
|
||||
public bool ValidateWorldTarget(EntityUid user, EntityCoordinates coords, WorldTargetAction action)
|
||||
{
|
||||
if (coords == MapCoordinates.Nullspace)
|
||||
return false;
|
||||
|
||||
if (action.CheckCanInteract && !_actionBlockerSystem.CanInteract(user, null))
|
||||
return false;
|
||||
|
||||
@@ -256,13 +253,13 @@ public abstract class SharedActionsSystem : EntitySystem
|
||||
// even if we don't check for obstructions, we may still need to check the range.
|
||||
var xform = Transform(user);
|
||||
|
||||
if (xform.MapID != coords.MapId)
|
||||
if (xform.MapID != coords.GetMapId(EntityManager))
|
||||
return false;
|
||||
|
||||
if (action.Range <= 0)
|
||||
return true;
|
||||
|
||||
return (xform.WorldPosition - coords.Position).Length <= action.Range;
|
||||
return coords.InRange(EntityManager, Transform(user).Coordinates, action.Range);
|
||||
}
|
||||
|
||||
return _interactionSystem.InRangeUnobstructed(user, coords, range: action.Range);
|
||||
|
||||
Reference in New Issue
Block a user