]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add ability to put spesos into cargo console (#24263)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Fri, 19 Jan 2024 07:23:07 +0000 (18:23 +1100)
committerGitHub <noreply@github.com>
Fri, 19 Jan 2024 07:23:07 +0000 (18:23 +1100)
I thought we had it already but maybe it was an unfinished pr or something.

Content.Server/Cargo/Systems/CargoSystem.Orders.cs
Content.Shared/Cargo/Components/CashComponent.cs [new file with mode: 0644]
Resources/Prototypes/Entities/Objects/Misc/space_cash.yml

index 4a150c3c1a8b26d37a162f73d34bb69c50842508..c0d598a5d002463c9a2d1423b73cffee183c6e1b 100644 (file)
@@ -5,9 +5,11 @@ using Content.Server.Paper;
 using Content.Server.Station.Components;
 using Content.Shared.Cargo;
 using Content.Shared.Cargo.BUI;
+using Content.Shared.Cargo.Components;
 using Content.Shared.Cargo.Events;
 using Content.Shared.Cargo.Prototypes;
 using Content.Shared.Database;
+using Content.Shared.Interaction;
 using Robust.Shared.Map;
 using Robust.Shared.Player;
 using Robust.Shared.Prototypes;
@@ -35,9 +37,30 @@ namespace Content.Server.Cargo.Systems
             SubscribeLocalEvent<CargoOrderConsoleComponent, CargoConsoleApproveOrderMessage>(OnApproveOrderMessage);
             SubscribeLocalEvent<CargoOrderConsoleComponent, BoundUIOpenedEvent>(OnOrderUIOpened);
             SubscribeLocalEvent<CargoOrderConsoleComponent, ComponentInit>(OnInit);
+            SubscribeLocalEvent<CargoOrderConsoleComponent, InteractUsingEvent>(OnInteractUsing);
             Reset();
         }
 
+        private void OnInteractUsing(EntityUid uid, CargoOrderConsoleComponent component, ref InteractUsingEvent args)
+        {
+            if (!HasComp<CashComponent>(args.Used))
+                return;
+
+            var price = _pricing.GetPrice(args.Used);
+
+            if (price == 0)
+                return;
+
+            var stationUid = _station.GetOwningStation(args.Used);
+
+            if (!TryComp(stationUid, out StationBankAccountComponent? bank))
+                return;
+
+            _audio.PlayPvs(component.ConfirmSound, uid);
+            UpdateBankAccount(stationUid.Value, bank, (int) price);
+            QueueDel(args.Used);
+        }
+
         private void OnInit(EntityUid uid, CargoOrderConsoleComponent orderConsole, ComponentInit args)
         {
             var station = _station.GetOwningStation(uid);
diff --git a/Content.Shared/Cargo/Components/CashComponent.cs b/Content.Shared/Cargo/Components/CashComponent.cs
new file mode 100644 (file)
index 0000000..10a47ff
--- /dev/null
@@ -0,0 +1,12 @@
+using Robust.Shared.GameStates;
+
+namespace Content.Shared.Cargo.Components;
+
+/// <summary>
+/// Can be inserted into a <see cref="Content.Server.Cargo.Components.CargoOrderConsoleComponent"/> to increase the station's bank account.
+/// </summary>
+[RegisterComponent, NetworkedComponent]
+public sealed partial class CashComponent : Component
+{
+
+}
index 27e19bc3bd9468efc32341cbfe9c3a5c52596494..f402c1abefe0961e0e3f209a71bd9f8eeb49a710 100644 (file)
@@ -4,6 +4,7 @@
   name: spesos
   description: You gotta have money.
   components:
+  - type: Cash
   - type: Item
     shape:
     - 0,0,1,0