diff --git a/Content.Client/Decals/DecalPlacementSystem.cs b/Content.Client/Decals/DecalPlacementSystem.cs index 6b592fd98a..022ad21667 100644 --- a/Content.Client/Decals/DecalPlacementSystem.cs +++ b/Content.Client/Decals/DecalPlacementSystem.cs @@ -100,26 +100,24 @@ public sealed class DecalPlacementSystem : EntitySystem if (args.Handled) return; - if (!_mapMan.TryFindGridAt(args.Target, out var grid)) + if (args.Target.GetGridUid(EntityManager) == null) return; args.Handled = true; - var coords = EntityCoordinates.FromMap(grid.GridEntityId, args.Target, EntityManager); - if (args.Snap) { var newPos = new Vector2( - (float) (MathF.Round(coords.X - 0.5f, MidpointRounding.AwayFromZero) + 0.5), - (float) (MathF.Round(coords.Y - 0.5f, MidpointRounding.AwayFromZero) + 0.5) + (float) (MathF.Round(args.Target.X - 0.5f, MidpointRounding.AwayFromZero) + 0.5), + (float) (MathF.Round(args.Target.Y - 0.5f, MidpointRounding.AwayFromZero) + 0.5) ); - coords = coords.WithPosition(newPos); + args.Target = args.Target.WithPosition(newPos); } - coords = coords.Offset(new Vector2(-0.5f, -0.5f)); + args.Target = args.Target.Offset(new Vector2(-0.5f, -0.5f)); - var decal = new Decal(coords.Position, args.DecalId, args.Color, Angle.FromDegrees(args.Rotation), args.ZIndex, args.Cleanable); - RaiseNetworkEvent(new RequestDecalPlacementEvent(decal, coords)); + var decal = new Decal(args.Target.Position, args.DecalId, args.Color, Angle.FromDegrees(args.Rotation), args.ZIndex, args.Cleanable); + RaiseNetworkEvent(new RequestDecalPlacementEvent(decal, args.Target)); } private void OnFillSlot(FillActionSlotEvent ev) diff --git a/Content.Client/UserInterface/Systems/Actions/ActionUIController.cs b/Content.Client/UserInterface/Systems/Actions/ActionUIController.cs index 1b59568554..ac6e0510d2 100644 --- a/Content.Client/UserInterface/Systems/Actions/ActionUIController.cs +++ b/Content.Client/UserInterface/Systems/Actions/ActionUIController.cs @@ -205,7 +205,7 @@ public sealed class ActionUIController : UIController, IOnStateChanged /// The list of Entities to spawn in - /// Map Coordinates where the entities will spawn + /// Map Coordinates where the entities will spawn /// Check to see if the entities should self delete /// A Vector2 offset that the entities will spawn in - private void SpawnSpellHelper(List entityEntries, MapCoordinates mapCoords, float? lifetime, Vector2 offsetVector2) + private void SpawnSpellHelper(List entityEntries, EntityCoordinates entityCoords, float? lifetime, Vector2 offsetVector2) { var getProtos = EntitySpawnCollection.GetSpawns(entityEntries, _random); - var offsetCoords = mapCoords; + var offsetCoords = entityCoords; foreach (var proto in getProtos) { // TODO: Share this code with instant because they're both doing similar things for positioning. diff --git a/Content.Shared/Actions/ActionEvents.cs b/Content.Shared/Actions/ActionEvents.cs index bd316e6ae2..4c6b6719d0 100644 --- a/Content.Shared/Actions/ActionEvents.cs +++ b/Content.Shared/Actions/ActionEvents.cs @@ -44,7 +44,7 @@ public sealed class RequestPerformActionEvent : EntityEventArgs { public readonly ActionType Action; public readonly EntityUid? EntityTarget; - public readonly MapCoordinates? MapTarget; + public readonly EntityCoordinates? EntityCoordinatesTarget; public RequestPerformActionEvent(InstantAction action) { @@ -57,10 +57,10 @@ public sealed class RequestPerformActionEvent : EntityEventArgs EntityTarget = entityTarget; } - public RequestPerformActionEvent(WorldTargetAction action, MapCoordinates mapTarget) + public RequestPerformActionEvent(WorldTargetAction action, EntityCoordinates entityCoordinatesTarget) { Action = action; - MapTarget = mapTarget; + EntityCoordinatesTarget = entityCoordinatesTarget; } } @@ -102,7 +102,7 @@ public abstract class WorldTargetActionEvent : BaseActionEvent /// /// The coordinates of the location that the user targeted. /// - public MapCoordinates Target; + public EntityCoordinates Target; } /// diff --git a/Content.Shared/Actions/SharedActionsSystem.cs b/Content.Shared/Actions/SharedActionsSystem.cs index 98e9a57adc..5a8a92072c 100644 --- a/Content.Shared/Actions/SharedActionsSystem.cs +++ b/Content.Shared/Actions/SharedActionsSystem.cs @@ -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);