diff --git a/Content.Client/GPS/HandheldGPSComponent.cs b/Content.Client/GPS/HandheldGPSComponent.cs new file mode 100644 index 0000000000..3d216d4d4c --- /dev/null +++ b/Content.Client/GPS/HandheldGPSComponent.cs @@ -0,0 +1,65 @@ +using Content.Client.Items.Components; +using Content.Client.Message; +using Content.Client.Stylesheets; +using Robust.Client.UserInterface; +using Robust.Client.UserInterface.Controls; +using Robust.Shared.Timing; +using Content.Shared.GPS; + +namespace Content.Client.GPS +{ + [RegisterComponent] + internal sealed class HandheldGPSComponent : SharedHandheldGPSComponent, IItemStatus + { + Control IItemStatus.MakeControl() + { + return new StatusControl(this); + } + + private sealed class StatusControl : Control + { + private readonly HandheldGPSComponent _parent; + private readonly RichTextLabel _label; + private float UpdateDif; + private readonly IEntityManager _entMan = default!; + + public StatusControl(HandheldGPSComponent parent) + { + _parent = parent; + _entMan = IoCManager.Resolve(); + _label = new RichTextLabel { StyleClasses = { StyleNano.StyleClassItemStatus } }; + AddChild(_label); + UpdateGPSDetails(); + } + + protected override void FrameUpdate(FrameEventArgs args) + { + base.FrameUpdate(args); + + UpdateDif += args.DeltaSeconds; + if (UpdateDif < _parent.UpdateRate) + return; + + UpdateDif -= _parent.UpdateRate; + + UpdateGPSDetails(); + } + + public void UpdateGPSDetails() + { + string posText = "Error"; + if (_entMan.TryGetComponent(_parent.Owner, out TransformComponent? transComp)) + { + if (transComp.Coordinates != null) + { + var pos = transComp.MapPosition; + var x = (int) pos.X; + var y = (int) pos.Y; + posText = $"({x}, {y})"; + } + } + _label.SetMarkup(Loc.GetString("handheld-gps-coordinates-title", ("coordinates", posText))); + } + } + } +} diff --git a/Content.Server/Entry/IgnoredComponents.cs b/Content.Server/Entry/IgnoredComponents.cs index 1b5280cc6c..16c1ebbcbd 100644 --- a/Content.Server/Entry/IgnoredComponents.cs +++ b/Content.Server/Entry/IgnoredComponents.cs @@ -17,6 +17,7 @@ namespace Content.Server.Entry "ClientEntitySpawner", "CharacterInfo", "ItemCabinetVisuals", + "HandheldGPS" }; } } diff --git a/Content.Shared/Tools/Components/SharedHandheldGPSComponent.cs b/Content.Shared/Tools/Components/SharedHandheldGPSComponent.cs new file mode 100644 index 0000000000..0535201792 --- /dev/null +++ b/Content.Shared/Tools/Components/SharedHandheldGPSComponent.cs @@ -0,0 +1,9 @@ + +namespace Content.Shared.GPS +{ + public abstract class SharedHandheldGPSComponent : Component + { + [DataField("updateRate")] + public float UpdateRate = 1.5f; + } +} diff --git a/Resources/Locale/en-US/GPS/handheld-gps.ftl b/Resources/Locale/en-US/GPS/handheld-gps.ftl new file mode 100644 index 0000000000..e852f80832 --- /dev/null +++ b/Resources/Locale/en-US/GPS/handheld-gps.ftl @@ -0,0 +1 @@ +handheld-gps-coordinates-title = Coords: {$coordinates} diff --git a/Resources/Prototypes/Entities/Objects/Tools/gps.yml b/Resources/Prototypes/Entities/Objects/Tools/gps.yml new file mode 100644 index 0000000000..ee84fa3e5a --- /dev/null +++ b/Resources/Prototypes/Entities/Objects/Tools/gps.yml @@ -0,0 +1,16 @@ +- type: entity + name: global positioning system + parent: BaseItem + id: HandheldGPSBasic + description: Helping lost spacemen find their way through the planets since 2016. + components: + - type: Sprite + sprite: Objects/Devices/gps.rsi + netsync: false + layers: + - state: icon + - state: active + - type: Item + sprite: Objects/Devices/gps.rsi + state: icon + - type: HandheldGPS diff --git a/Resources/Prototypes/Entities/Structures/Machines/lathe.yml b/Resources/Prototypes/Entities/Structures/Machines/lathe.yml index 80c0025d0b..8fe43b7940 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/lathe.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/lathe.yml @@ -64,6 +64,7 @@ - Shovel - Spade - CableStack + - HandheldGPSBasic - type: Appearance visuals: - type: AutolatheVisualizer diff --git a/Resources/Prototypes/Recipes/Lathes/tools.yml b/Resources/Prototypes/Recipes/Lathes/tools.yml index efe10304c6..9a7e4b1866 100644 --- a/Resources/Prototypes/Recipes/Lathes/tools.yml +++ b/Resources/Prototypes/Recipes/Lathes/tools.yml @@ -134,3 +134,12 @@ materials: Steel: 500 Plastic: 250 + +- type: latheRecipe + id: HandheldGPSBasic + icon: Objects/Devices/gps.rsi/icon.png + result: HandheldGPSBasic + completetime: 2000 + materials: + Steel: 800 + Glass: 300 diff --git a/Resources/Textures/Objects/Devices/gps.rsi/active.png b/Resources/Textures/Objects/Devices/gps.rsi/active.png new file mode 100644 index 0000000000..1dfcedc6c7 Binary files /dev/null and b/Resources/Textures/Objects/Devices/gps.rsi/active.png differ diff --git a/Resources/Textures/Objects/Devices/gps.rsi/icon.png b/Resources/Textures/Objects/Devices/gps.rsi/icon.png new file mode 100644 index 0000000000..a8796cd6fe Binary files /dev/null and b/Resources/Textures/Objects/Devices/gps.rsi/icon.png differ diff --git a/Resources/Textures/Objects/Devices/gps.rsi/meta.json b/Resources/Textures/Objects/Devices/gps.rsi/meta.json new file mode 100644 index 0000000000..a59c0b0012 --- /dev/null +++ b/Resources/Textures/Objects/Devices/gps.rsi/meta.json @@ -0,0 +1,33 @@ +{ + "version": 1, + "license": "CC-BY-SA-3.0", + "copyright": "tgstation at 3ddd840268e33bbcf316f242e6a972b84e6b773c", + "size": { + "x": 32, + "y": 32 + }, + "states": [ + { + "name": "icon" + }, + { + "name": "active", + "delays": [ + [ + 0.1, + 0.1, + 0.1, + 0.1, + 0.1, + 0.1, + 0.1, + 0.1, + 0.1, + 0.1, + 0.1, + 0.1 + ] + ] + } + ] +}