Add basic handheld GPS (#6896)
Co-authored-by: fishfish458 <fishfish458>
This commit is contained in:
65
Content.Client/GPS/HandheldGPSComponent.cs
Normal file
65
Content.Client/GPS/HandheldGPSComponent.cs
Normal file
@@ -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<IEntityManager>();
|
||||||
|
_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<TransformComponent>(_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)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,6 +17,7 @@ namespace Content.Server.Entry
|
|||||||
"ClientEntitySpawner",
|
"ClientEntitySpawner",
|
||||||
"CharacterInfo",
|
"CharacterInfo",
|
||||||
"ItemCabinetVisuals",
|
"ItemCabinetVisuals",
|
||||||
|
"HandheldGPS"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
namespace Content.Shared.GPS
|
||||||
|
{
|
||||||
|
public abstract class SharedHandheldGPSComponent : Component
|
||||||
|
{
|
||||||
|
[DataField("updateRate")]
|
||||||
|
public float UpdateRate = 1.5f;
|
||||||
|
}
|
||||||
|
}
|
||||||
1
Resources/Locale/en-US/GPS/handheld-gps.ftl
Normal file
1
Resources/Locale/en-US/GPS/handheld-gps.ftl
Normal file
@@ -0,0 +1 @@
|
|||||||
|
handheld-gps-coordinates-title = Coords: {$coordinates}
|
||||||
16
Resources/Prototypes/Entities/Objects/Tools/gps.yml
Normal file
16
Resources/Prototypes/Entities/Objects/Tools/gps.yml
Normal file
@@ -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
|
||||||
@@ -64,6 +64,7 @@
|
|||||||
- Shovel
|
- Shovel
|
||||||
- Spade
|
- Spade
|
||||||
- CableStack
|
- CableStack
|
||||||
|
- HandheldGPSBasic
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
visuals:
|
visuals:
|
||||||
- type: AutolatheVisualizer
|
- type: AutolatheVisualizer
|
||||||
|
|||||||
@@ -134,3 +134,12 @@
|
|||||||
materials:
|
materials:
|
||||||
Steel: 500
|
Steel: 500
|
||||||
Plastic: 250
|
Plastic: 250
|
||||||
|
|
||||||
|
- type: latheRecipe
|
||||||
|
id: HandheldGPSBasic
|
||||||
|
icon: Objects/Devices/gps.rsi/icon.png
|
||||||
|
result: HandheldGPSBasic
|
||||||
|
completetime: 2000
|
||||||
|
materials:
|
||||||
|
Steel: 800
|
||||||
|
Glass: 300
|
||||||
|
|||||||
BIN
Resources/Textures/Objects/Devices/gps.rsi/active.png
Normal file
BIN
Resources/Textures/Objects/Devices/gps.rsi/active.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 385 B |
BIN
Resources/Textures/Objects/Devices/gps.rsi/icon.png
Normal file
BIN
Resources/Textures/Objects/Devices/gps.rsi/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 351 B |
33
Resources/Textures/Objects/Devices/gps.rsi/meta.json
Normal file
33
Resources/Textures/Objects/Devices/gps.rsi/meta.json
Normal file
@@ -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
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user