AstroNav GPS Cartridge (#32194)

* initial commit

* adds astronav cartridge to QM locker

* changes requested in review

* fix merge conflicts

* fixes the statuscontrol disappearing if you eject the cartridge but still have it installed

* fix notificationsenabled on salv pda proto

* fixes lingering statuscontrol on eject while held

---------

Co-authored-by: archrbx <punk.gear5260@fastmail.com>
This commit is contained in:
ArchRBX
2024-09-24 18:02:51 +01:00
committed by GitHub
parent f3e185c063
commit 241be37185
14 changed files with 99 additions and 28 deletions

View File

@@ -1,9 +0,0 @@
using Content.Shared.GPS;
namespace Content.Client.GPS.Components
{
[RegisterComponent]
public sealed partial class HandheldGPSComponent : SharedHandheldGPSComponent
{
}
}

View File

@@ -1,4 +1,4 @@
using Content.Client.GPS.Components;
using Content.Shared.GPS.Components;
using Content.Client.GPS.UI;
using Content.Client.Items;

View File

@@ -1,4 +1,4 @@
using Content.Client.GPS.Components;
using Content.Shared.GPS.Components;
using Content.Client.Message;
using Content.Client.Stylesheets;
using Robust.Client.GameObjects;
@@ -30,6 +30,13 @@ public sealed class HandheldGpsStatusControl : Control
{
base.FrameUpdate(args);
// don't display the label if the gps component is being removed
if (_parent.Comp.LifeStage > ComponentLifeStage.Running)
{
_label.Visible = false;
return;
}
_updateDif += args.DeltaSeconds;
if (_updateDif < _parent.Comp.UpdateRate)
return;
@@ -44,9 +51,9 @@ public sealed class HandheldGpsStatusControl : Control
var posText = "Error";
if (_entMan.TryGetComponent(_parent, out TransformComponent? transComp))
{
var pos = _transform.GetMapCoordinates(_parent.Owner, xform: transComp);
var x = (int) pos.X;
var y = (int) pos.Y;
var pos = _transform.GetMapCoordinates(_parent.Owner, xform: transComp);
var x = (int)pos.X;
var y = (int)pos.Y;
posText = $"({x}, {y})";
}
_label.SetMarkup(Loc.GetString("handheld-gps-coordinates-title", ("coordinates", posText)));

View File

@@ -0,0 +1,9 @@
using Content.Shared.CartridgeLoader.Cartridges;
using Content.Shared.GPS;
namespace Content.Server.CartridgeLoader.Cartridges;
[RegisterComponent]
public sealed partial class AstroNavCartridgeComponent : Component
{
}

View File

@@ -0,0 +1,32 @@
using Content.Shared.CartridgeLoader;
using Content.Shared.CartridgeLoader.Cartridges;
using Content.Shared.GPS.Components;
namespace Content.Server.CartridgeLoader.Cartridges;
public sealed class AstroNavCartridgeSystem : EntitySystem
{
[Dependency] private readonly CartridgeLoaderSystem _cartridgeLoaderSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<AstroNavCartridgeComponent, CartridgeAddedEvent>(OnCartridgeAdded);
SubscribeLocalEvent<AstroNavCartridgeComponent, CartridgeRemovedEvent>(OnCartridgeRemoved);
}
private void OnCartridgeAdded(Entity<AstroNavCartridgeComponent> ent, ref CartridgeAddedEvent args)
{
EnsureComp<HandheldGPSComponent>(args.Loader);
}
private void OnCartridgeRemoved(Entity<AstroNavCartridgeComponent> ent, ref CartridgeRemovedEvent args)
{
// only remove when the program itself is removed
if (!_cartridgeLoaderSystem.HasProgram<AstroNavCartridgeComponent>(args.Loader))
{
RemComp<HandheldGPSComponent>(args.Loader);
}
}
}

View File

@@ -12,7 +12,6 @@ namespace Content.Server.Entry
"GuideHelp",
"Clickable",
"Icon",
"HandheldGPS",
"CableVisualizer",
"SolutionItemStatus",
"UIFragment",

View File

@@ -0,0 +1,10 @@
using Robust.Shared.GameStates;
namespace Content.Shared.GPS.Components;
[RegisterComponent, NetworkedComponent]
public sealed partial class HandheldGPSComponent : Component
{
[DataField]
public float UpdateRate = 1.5f;
}

View File

@@ -1,9 +0,0 @@
namespace Content.Shared.GPS
{
public abstract partial class SharedHandheldGPSComponent : Component
{
[DataField("updateRate")]
public float UpdateRate = 1.5f;
}
}

View File

@@ -20,6 +20,8 @@ log-probe-label-time = Time
log-probe-label-accessor = Accessed by
log-probe-label-number = #
astro-nav-program-name = AstroNav
# Wanted list cartridge
wanted-list-program-name = Wanted list
wanted-list-label-no-records = It's all right, cowboy

View File

@@ -17,6 +17,7 @@
- id: RubberStampApproved
- id: RubberStampDenied
- id: RubberStampQm
- id: AstroNavCartridge
- type: entity
id: LockerQuarterMasterFilled

View File

@@ -116,3 +116,22 @@
- type: WantedListCartridge
- type: StealTarget
stealGroup: WantedListCartridge
- type: entity
parent: BaseItem
id: AstroNavCartridge
name: AstroNav cartridge
description: A program for navigation that provides GPS coordinates.
components:
- type: Sprite
sprite: Objects/Devices/cartridge.rsi
state: cart-nav
- type: Icon
sprite: Objects/Devices/cartridge.rsi
state: cart-nav
- type: Cartridge
programName: astro-nav-program-name
icon:
sprite: Objects/Devices/gps.rsi
state: icon
- type: AstroNavCartridge

View File

@@ -400,6 +400,13 @@
accentVColor: "#8900c9"
- type: Icon
state: pda-miner
- type: CartridgeLoader
uiKey: enum.PdaUiKey.Key
preinstalled:
- CrewManifestCartridge
- NotekeeperCartridge
- NewsReaderCartridge
- AstroNavCartridge
- type: entity
parent: BasePDA

Binary file not shown.

After

Width:  |  Height:  |  Size: 300 B

View File

@@ -1,7 +1,7 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Taken from vgstation at https://github.com/vgstation-coders/vgstation13/commit/1cdfb0230cc96d0ba751fa002d04f8aa2f25ad7d and tgstation at tgstation at https://github.com/tgstation/tgstation/commit/0c15d9dbcf0f2beb230eba5d9d889ef2d1945bb8, cart-log made by Skarletto (github), cart-sec made by dieselmohawk (discord)",
"copyright": "Taken from vgstation at https://github.com/vgstation-coders/vgstation13/commit/1cdfb0230cc96d0ba751fa002d04f8aa2f25ad7d and tgstation at tgstation at https://github.com/tgstation/tgstation/commit/0c15d9dbcf0f2beb230eba5d9d889ef2d1945bb8, cart-log made by Skarletto (github), cart-sec made by dieselmohawk (discord), cart-nav made by ArchRBX (github)",
"size": {
"x": 32,
"y": 32
@@ -58,6 +58,9 @@
{
"name": "cart-mi"
},
{
"name": "cart-nav"
},
{
"name": "cart-ord"
},
@@ -70,6 +73,9 @@
{
"name": "cart-s"
},
{
"name": "cart-sec"
},
{
"name": "cart-tear"
},
@@ -79,9 +85,6 @@
{
"name": "cart-y"
},
{
"name": "cart-sec"
},
{
"name": "insert_overlay"
}