Skip to content

Commit

Permalink
AstroNav GPS Cartridge (#32194)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
ArchRBX and archrbx authored Sep 24, 2024
1 parent f3e185c commit 241be37
Show file tree
Hide file tree
Showing 14 changed files with 99 additions and 28 deletions.
9 changes: 0 additions & 9 deletions Content.Client/GPS/Components/HandheldGPSComponent.cs

This file was deleted.

2 changes: 1 addition & 1 deletion Content.Client/GPS/Systems/HandheldGpsSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Client.GPS.Components;
using Content.Shared.GPS.Components;
using Content.Client.GPS.UI;
using Content.Client.Items;

Expand Down
15 changes: 11 additions & 4 deletions Content.Client/GPS/UI/HandheldGpsStatusControl.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -30,6 +30,13 @@ protected override void FrameUpdate(FrameEventArgs args)
{
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;
Expand All @@ -44,9 +51,9 @@ private void UpdateGpsDetails()
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)));
Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
1 change: 0 additions & 1 deletion Content.Server/Entry/IgnoredComponents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public static class IgnoredComponents
"GuideHelp",
"Clickable",
"Icon",
"HandheldGPS",
"CableVisualizer",
"SolutionItemStatus",
"UIFragment",
Expand Down
10 changes: 10 additions & 0 deletions Content.Shared/GPS/Components/HandheldGPSComponent.cs
Original file line number Diff line number Diff line change
@@ -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;
}
9 changes: 0 additions & 9 deletions Content.Shared/Tools/Components/SharedHandheldGPSComponent.cs

This file was deleted.

2 changes: 2 additions & 0 deletions Resources/Locale/en-US/cartridge-loader/cartridges.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Catalog/Fills/Lockers/heads.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- id: RubberStampApproved
- id: RubberStampDenied
- id: RubberStampQm
- id: AstroNavCartridge

- type: entity
id: LockerQuarterMasterFilled
Expand Down
19 changes: 19 additions & 0 deletions Resources/Prototypes/Entities/Objects/Devices/cartridges.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions Resources/Prototypes/Entities/Objects/Devices/pda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 7 additions & 4 deletions Resources/Textures/Objects/Devices/cartridge.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -58,6 +58,9 @@
{
"name": "cart-mi"
},
{
"name": "cart-nav"
},
{
"name": "cart-ord"
},
Expand All @@ -70,6 +73,9 @@
{
"name": "cart-s"
},
{
"name": "cart-sec"
},
{
"name": "cart-tear"
},
Expand All @@ -79,9 +85,6 @@
{
"name": "cart-y"
},
{
"name": "cart-sec"
},
{
"name": "insert_overlay"
}
Expand Down

0 comments on commit 241be37

Please sign in to comment.