}
}
- public void ShowSensors(List<SuitSensorStatus> stSensors, Vector2 localPosition, bool snap, float precision)
+ public void ShowSensors(List<SuitSensorStatus> stSensors, EntityCoordinates? monitorCoords, bool snap, float precision)
{
ClearAllSensors();
+ var monitorCoordsInStationSpace = _stationUid != null ? monitorCoords?.WithEntityId(_stationUid.Value, _entManager).Position : null;
+
// TODO scroll container
// TODO filter by name & occupation
// TODO make each row a xaml-control. Get rid of some of this c# control creation.
// add users positions
// format: (x, y)
- var box = GetPositionBox(sensor.Coordinates, localPosition, snap, precision);
+ var box = GetPositionBox(sensor.Coordinates, monitorCoordsInStationSpace ?? Vector2.Zero, snap, precision);
SensorsTable.AddChild(box);
_rowsContent.Add(box);
};
}
}
+ // For debugging.
+ //if (monitorCoords != null)
+ // NavMap.TrackedCoordinates.Add(monitorCoords.Value, (true, Color.FromHex("#FF00FF")));
}
- private BoxContainer GetPositionBox(EntityCoordinates? coordinates, Vector2 sensorPosition, bool snap, float precision)
+ private BoxContainer GetPositionBox(EntityCoordinates? coordinates, Vector2 monitorCoordsInStationSpace, bool snap, float precision)
{
var box = new BoxContainer() { Orientation = LayoutOrientation.Horizontal };
- if (coordinates == null || !_entManager.TryGetComponent<TransformComponent>(_stationUid, out var xform))
+ if (coordinates == null || _stationUid == null)
{
var dirIcon = new DirectionIcon()
{
}
else
{
- var position = coordinates.Value.ToMapPos(_entManager);
- var local = xform.InvWorldMatrix.Transform(position);
+ var local = coordinates.Value.WithEntityId(_stationUid.Value, _entManager).Position;
var displayPos = local.Floored();
var dirIcon = new DirectionIcon(snap, precision)
};
box.AddChild(dirIcon);
box.AddChild(new Label() { Text = displayPos.ToString() });
- _directionIcons.Add((dirIcon, local - sensorPosition));
+ _directionIcons.Add((dirIcon, local - monitorCoordsInStationSpace));
}
return box;
{
// the window is separate from any specific viewport, so there is no real way to get an eye-rotation without
// using IEyeManager. Eventually this will have to be reworked for a station AI with multi-viewports.
+ // (From the future: Or alternatively, just disable the angular offset for station AIs?)
+
+ // An offsetAngle of zero here perfectly aligns directions to the station map.
+ // Note that the "relative angle" does this weird inverse-inverse thing.
+ // Could recalculate it all in world coordinates and then pass in eye directly... or do this.
+ var offsetAngle = Angle.Zero;
+ if (_entManager.TryGetComponent<TransformComponent>(_stationUid, out var xform))
+ {
+ // Apply the offset relative to the eye.
+ // For a station at 45 degrees rotation, the current eye rotation is -45 degrees.
+ // TODO: This feels sketchy. Is there something underlying wrong with eye rotation?
+ offsetAngle = -(_eye.CurrentEye.Rotation + xform.WorldRotation);
+ }
foreach (var (icon, pos) in _directionIcons)
{
- icon.UpdateDirection(pos, -_eye.CurrentEye.Rotation);
+ icon.UpdateDirection(pos, offsetAngle);
}
}
}
_rowsContent.Clear();
+ _directionIcons.Clear();
NavMap.TrackedCoordinates.Clear();
}
}