Examining now shows Coords on Handheld GPS, Coord readout update frequency increased (#31814)

* initial commit

* fixed LoadSaveTicksSaveBagel failure

* fixes issues raised in beck's review, yay!

* remove redundant variable

* removed delay on coordinate update, removed system update loop

* changed delay from 0.2s to 0.5s as travelling at high speeds would make it kinda illegible

* 0.35s seems to be the sweet-spot

* fixes merge conflicts

* remove unused dependencies

* review

---------

Co-authored-by: archrbx <punk.gear5260@fastmail.com>
Co-authored-by: Milon <milonpl.git@proton.me>
This commit is contained in:
ArchRBX
2025-04-13 16:29:13 +01:00
committed by GitHub
parent 7d1ab10da4
commit d2bfa2fdda

View File

@@ -0,0 +1,37 @@
using Content.Shared.GPS.Components;
using Content.Shared.Examine;
using Robust.Shared.Map;
namespace Content.Shared.GPS.Systems;
public sealed class HandheldGpsSystem : EntitySystem
{
[Dependency] private readonly SharedTransformSystem _transform = default!;
/// <inheritdoc/>
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<HandheldGPSComponent, ExaminedEvent>(OnExamine);
}
/// <summary>
/// Handles showing the coordinates when a GPS is examined.
/// </summary>
private void OnExamine(Entity<HandheldGPSComponent> ent, ref ExaminedEvent args)
{
var posText = "Error";
var pos = _transform.GetMapCoordinates(ent);
if (pos.MapId != MapId.Nullspace)
{
var x = (int) pos.Position.X;
var y = (int) pos.Position.Y;
posText = $"({x}, {y})";
}
args.PushMarkup(Loc.GetString("handheld-gps-coordinates-title", ("coordinates", posText)));
}
}