Fix nearest beacon messages reporting the opposite direction (#28869)
* Fix nearest beacon messages reporting the opposite direction * Lets document that method, shall we?
This commit is contained in:
@@ -431,6 +431,10 @@ public sealed partial class NavMapSystem : SharedNavMapSystem
|
|||||||
return beacon != null;
|
return beacon != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a string describing the rough distance and direction
|
||||||
|
/// to the position of <paramref name="ent"/> from the nearest beacon.
|
||||||
|
/// </summary>
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
public string GetNearestBeaconString(Entity<TransformComponent?> ent)
|
public string GetNearestBeaconString(Entity<TransformComponent?> ent)
|
||||||
{
|
{
|
||||||
@@ -440,6 +444,11 @@ public sealed partial class NavMapSystem : SharedNavMapSystem
|
|||||||
return GetNearestBeaconString(_transformSystem.GetMapCoordinates(ent, ent.Comp));
|
return GetNearestBeaconString(_transformSystem.GetMapCoordinates(ent, ent.Comp));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a string describing the rough distance and direction
|
||||||
|
/// to <paramref name="coordinates"/> from the nearest beacon.
|
||||||
|
/// </summary>
|
||||||
|
|
||||||
public string GetNearestBeaconString(MapCoordinates coordinates)
|
public string GetNearestBeaconString(MapCoordinates coordinates)
|
||||||
{
|
{
|
||||||
if (!TryGetNearestBeacon(coordinates, out var beacon, out var pos))
|
if (!TryGetNearestBeacon(coordinates, out var beacon, out var pos))
|
||||||
@@ -451,10 +460,11 @@ public sealed partial class NavMapSystem : SharedNavMapSystem
|
|||||||
|
|
||||||
// get the angle between the two positions, adjusted for the grid rotation so that
|
// get the angle between the two positions, adjusted for the grid rotation so that
|
||||||
// we properly preserve north in relation to the grid.
|
// we properly preserve north in relation to the grid.
|
||||||
var dir = (pos.Value.Position - coordinates.Position).ToWorldAngle();
|
var offset = coordinates.Position - pos.Value.Position;
|
||||||
|
var dir = offset.ToWorldAngle();
|
||||||
var adjustedDir = (dir - gridOffset).GetDir();
|
var adjustedDir = (dir - gridOffset).GetDir();
|
||||||
|
|
||||||
var length = (pos.Value.Position - coordinates.Position).Length();
|
var length = offset.Length();
|
||||||
if (length < CloseDistance)
|
if (length < CloseDistance)
|
||||||
{
|
{
|
||||||
return Loc.GetString("nav-beacon-pos-format",
|
return Loc.GetString("nav-beacon-pos-format",
|
||||||
|
|||||||
Reference in New Issue
Block a user