From: ArchRBX <5040911+ArchRBX@users.noreply.github.com> Date: Sun, 13 Apr 2025 15:29:13 +0000 (+0100) Subject: Examining now shows Coords on Handheld GPS, Coord readout update frequency increased... X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=d2bfa2fddaad0b9d1f376ba00e7cceee12fdd1ce;p=space-station-14.git 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 Co-authored-by: Milon --- diff --git a/Content.Shared/GPS/Systems/HandheldGpsSystem.cs b/Content.Shared/GPS/Systems/HandheldGpsSystem.cs new file mode 100644 index 0000000000..6a8e4c08db --- /dev/null +++ b/Content.Shared/GPS/Systems/HandheldGpsSystem.cs @@ -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!; + + /// + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnExamine); + } + + /// + /// Handles showing the coordinates when a GPS is examined. + /// + private void OnExamine(Entity 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))); + } +}