diff --git a/Content.Client/Shuttles/Systems/ShuttleSystem.Console.cs b/Content.Client/Shuttles/Systems/ShuttleSystem.Console.cs index c134b7157c4..5fbf9be4422 100644 --- a/Content.Client/Shuttles/Systems/ShuttleSystem.Console.cs +++ b/Content.Client/Shuttles/Systems/ShuttleSystem.Console.cs @@ -30,7 +30,7 @@ public Texture GetTexture(Entity entity) /// /// Gets the map coordinates of a map object. /// - public MapCoordinates GetMapCoordinates(IMapObject mapObj) + public MapCoordinates? GetMapCoordinates(IMapObject mapObj) { switch (mapObj) { @@ -39,7 +39,8 @@ public MapCoordinates GetMapCoordinates(IMapObject mapObj) case ShuttleExclusionObject exclusion: return GetCoordinates(exclusion.Coordinates).ToMap(EntityManager, XformSystem); case GridMapObject grid: - var gridXform = Transform(grid.Entity); + if (!TryComp(grid.Entity, out var gridXform)) + return null; if (HasComp(grid.Entity)) { diff --git a/Content.Client/Shuttles/UI/MapScreen.xaml.cs b/Content.Client/Shuttles/UI/MapScreen.xaml.cs index f3646e7c73d..07e5fbd4c2a 100644 --- a/Content.Client/Shuttles/UI/MapScreen.xaml.cs +++ b/Content.Client/Shuttles/UI/MapScreen.xaml.cs @@ -379,7 +379,16 @@ private void RebuildMapObjects() var yMapPos = _shuttles.GetMapCoordinates(y.mapobj); var xMapPos = _shuttles.GetMapCoordinates(x.mapobj); - return (yMapPos.Position - shuttlePos).Length().CompareTo((xMapPos.Position - shuttlePos).Length()); + if (xMapPos is not null && yMapPos is null) + return 1; + + if (yMapPos is not null && xMapPos is null) + return -1; + + if (xMapPos is null && yMapPos is null) + return 0; + + return (yMapPos!.Value.Position - shuttlePos).Length().CompareTo((xMapPos!.Value.Position - shuttlePos).Length()); }); } @@ -418,8 +427,11 @@ private void OnMapObjectPress(IMapObject mapObject) var coordinates = _shuttles.GetMapCoordinates(mapObject); + if (coordinates is null) + return; + // If it's our map then scroll, otherwise just set position there. - MapRadar.SetMap(coordinates.MapId, coordinates.Position, recentering: true); + MapRadar.SetMap(coordinates.Value.MapId, coordinates.Value.Position, recentering: true); } public void SetMap(MapId mapId, Vector2 position) diff --git a/Content.Client/Shuttles/UI/ShuttleMapControl.xaml.cs b/Content.Client/Shuttles/UI/ShuttleMapControl.xaml.cs index 2f35a8dffd7..60af631c52e 100644 --- a/Content.Client/Shuttles/UI/ShuttleMapControl.xaml.cs +++ b/Content.Client/Shuttles/UI/ShuttleMapControl.xaml.cs @@ -217,7 +217,10 @@ private List GetViewportMapObjects(Matrix3 matty, List m var mapCoords = _shuttles.GetMapCoordinates(mapObj); - var relativePos = matty.Transform(mapCoords.Position); + if (mapCoords is null) + continue; + + var relativePos = matty.Transform(mapCoords.Value.Position); relativePos = relativePos with { Y = -relativePos.Y }; var uiPosition = ScalePosition(relativePos);