Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
35 changes: 35 additions & 0 deletions Content.Shared/GPS/Systems/HandheldGpsSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Content.Shared.GPS.Components;
using Content.Shared.Examine;
using Robust.Shared.Timing;

namespace Content.Shared.GPS.Systems;

public sealed class HandheldGpsSystem : EntitySystem
{
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly IEntityManager _entMan = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<HandheldGPSComponent, ExaminedEvent>(OnExamine);
}

private void OnExamine(Entity<HandheldGPSComponent> ent, ref ExaminedEvent args)
{
var posText = "Error";
var xform = _entMan.GetComponent<TransformComponent>(ent);

if (xform.GridUid is { } gridUid)
{
var pos = _transform.GetMapCoordinates(ent, xform);
var x = (int)pos.X;
var y = (int)pos.Y;

posText = $"({x}, {y})";
}

args.PushMarkup(Loc.GetString("handheld-gps-coordinates-title", ("coordinates", posText)));
}
}
Loading