"Fix" aghost mass scanner (#9438)
This commit is contained in:
@@ -16,7 +16,8 @@ public sealed class RadarConsoleBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
base.Open();
|
||||
_window = new RadarConsoleWindow();
|
||||
_window?.OpenCentered();
|
||||
_window.OnClose += Close;
|
||||
_window.OpenCentered();
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
|
||||
@@ -145,33 +145,30 @@ public sealed class RadarControl : Control
|
||||
|
||||
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);
|
||||
|
||||
Matrix3.Multiply(in ourGridMatrix, in offsetMatrix, out var matrix);
|
||||
|
||||
// Draw our grid; use non-filled boxes so it doesn't look awful.
|
||||
DrawGrid(handle, offsetMatrix, ourGridFixtures, Color.Yellow);
|
||||
DrawGrid(handle, matrix, ourGridFixtures, Color.Yellow);
|
||||
|
||||
DrawDocks(handle, ourGridId.Value, offsetMatrix);
|
||||
|
||||
var ourGridMatrix = xformQuery.GetComponent(ourGridId.Value).InvWorldMatrix;
|
||||
|
||||
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 @@ public sealed class RadarControl : Control
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -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 @@ public sealed class RadarConsoleSystem : SharedRadarConsoleSystem
|
||||
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<IntrinsicUIComponent>(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<DockingInterfaceState>());
|
||||
|
||||
_uiSystem.GetUiOrNull(component.Owner, RadarConsoleUiKey.Key)?.SetState(radarState);
|
||||
|
||||
Reference in New Issue
Block a user