diff --git a/Content.Client/Shuttles/BUI/RadarConsoleBoundUserInterface.cs b/Content.Client/Shuttles/BUI/RadarConsoleBoundUserInterface.cs index 57971bd072b4..75d542501fcb 100644 --- a/Content.Client/Shuttles/BUI/RadarConsoleBoundUserInterface.cs +++ b/Content.Client/Shuttles/BUI/RadarConsoleBoundUserInterface.cs @@ -16,7 +16,8 @@ protected override void Open() { base.Open(); _window = new RadarConsoleWindow(); - _window?.OpenCentered(); + _window.OnClose += Close; + _window.OpenCentered(); } protected override void Dispose(bool disposing) diff --git a/Content.Client/Shuttles/UI/RadarControl.cs b/Content.Client/Shuttles/UI/RadarControl.cs index db7a79d97fcc..6d69fd809a2a 100644 --- a/Content.Client/Shuttles/UI/RadarControl.cs +++ b/Content.Client/Shuttles/UI/RadarControl.cs @@ -145,33 +145,30 @@ protected override void Draw(DrawingHandleScreen handle) var mapPosition = _coordinates.Value.ToMap(_entManager); - if (mapPosition.MapId == MapId.Nullspace) + if (mapPosition.MapId == MapId.Nullspace || !xformQuery.TryGetComponent(_coordinates.Value.EntityId, out var xform)) { Clear(); return; } var offset = _coordinates.Value.Position; - Matrix3 matrix; + var offsetMatrix = Matrix3.CreateInverseTransform( + mapPosition.Position, + xform.WorldRotation - _rotation.Value); // Draw our grid in detail var ourGridId = _coordinates.Value.GetGridUid(_entManager); if (ourGridId != null) { - var offsetMatrix = Matrix3.CreateInverseTransform(offset.X, offset.Y, (float) _rotation.Value.Theta); + var ourGridMatrix = xformQuery.GetComponent(ourGridId.Value).WorldMatrix; var ourGridFixtures = fixturesQuery.GetComponent(ourGridId.Value); - // Draw our grid; use non-filled boxes so it doesn't look awful. - DrawGrid(handle, offsetMatrix, ourGridFixtures, Color.Yellow); - DrawDocks(handle, ourGridId.Value, offsetMatrix); + Matrix3.Multiply(in ourGridMatrix, in offsetMatrix, out var matrix); - var ourGridMatrix = xformQuery.GetComponent(ourGridId.Value).InvWorldMatrix; + // Draw our grid; use non-filled boxes so it doesn't look awful. + DrawGrid(handle, matrix, ourGridFixtures, Color.Yellow); - Matrix3.Multiply(in ourGridMatrix, in offsetMatrix, out matrix); - } - else - { - matrix = Matrix3.CreateTranslation(-offset); + DrawDocks(handle, ourGridId.Value, matrix); } var invertedPosition = _coordinates.Value.Position - offset; @@ -205,7 +202,7 @@ protected override void Draw(DrawingHandleScreen handle) var gridXform = xformQuery.GetComponent(grid.GridEntityId); var gridFixtures = fixturesQuery.GetComponent(grid.GridEntityId); var gridMatrix = gridXform.WorldMatrix; - Matrix3.Multiply(in gridMatrix, in matrix, out var matty); + Matrix3.Multiply(in gridMatrix, in offsetMatrix, out var matty); if (ShowIFF) { diff --git a/Content.Server/Shuttles/Systems/RadarConsoleSystem.cs b/Content.Server/Shuttles/Systems/RadarConsoleSystem.cs index eac8d07ff629..961539262cd6 100644 --- a/Content.Server/Shuttles/Systems/RadarConsoleSystem.cs +++ b/Content.Server/Shuttles/Systems/RadarConsoleSystem.cs @@ -1,3 +1,4 @@ +using Content.Server.UserInterface; using Content.Shared.Shuttles.BUIStates; using Content.Shared.Shuttles.Components; using Content.Shared.Shuttles.Systems; @@ -24,13 +25,28 @@ private void OnRadarStartup(EntityUid uid, RadarConsoleComponent component, Comp protected override void UpdateState(RadarConsoleComponent component) { var xform = Transform(component.Owner); - var onGrid = xform.ParentUid == xform.GridUid; + EntityCoordinates? coordinates = onGrid ? xform.Coordinates : null; + Angle? angle = onGrid ? xform.LocalRotation : null; + + // Use ourself I guess. + if (TryComp(component.Owner, out var intrinsic)) + { + foreach (var uiKey in intrinsic.UIs) + { + if (uiKey.Key?.Equals(RadarConsoleUiKey.Key) == true) + { + coordinates = new EntityCoordinates(component.Owner, Vector2.Zero); + angle = Angle.Zero; + break; + } + } + } var radarState = new RadarConsoleBoundInterfaceState( component.MaxRange, - onGrid ? xform.Coordinates : null, - onGrid ? xform.LocalRotation : null, + coordinates, + angle, new List()); _uiSystem.GetUiOrNull(component.Owner, RadarConsoleUiKey.Key)?.SetState(radarState);