From fd728fdd08cbbd566ef4edd163b1ccae2f2761df Mon Sep 17 00:00:00 2001 From: pathetic meowmeow Date: Wed, 16 Apr 2025 18:05:13 -0400 Subject: [PATCH] Early cherrypick of Departmental Economy (#36445) (#3458) * Departmental Economy (#36445) * Cargo Accounts, Request Consoles, and lock boxes * Funding Allocation Computer * final changes * test fix * remove dumb code * ScarKy0 review * first cour * second cour * Update machines.yml * review --------- Co-authored-by: ScarKy0 <106310278+ScarKy0@users.noreply.github.com> Co-authored-by: Milon (cherry picked from commit 12b75beeab27f8905d6d3f07b7bbda2cfd859b5e) * Fix station income instantly accumulating roundstart (#36572) Fix station money accumulating roundstart (cherry picked from commit ed3e4c7d4ea82f000ef963e393d01f73484417a9) * DeltaV departmental economy --------- Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> --- .../CargoOrderConsoleBoundUserInterface.cs | 33 ++- ...dingAllocationConsoleBoundUserInterface.cs | 35 +++ Content.Client/Cargo/UI/CargoConsoleMenu.xaml | 117 ++++---- .../Cargo/UI/CargoConsoleMenu.xaml.cs | 139 +++++++-- Content.Client/Cargo/UI/CargoOrderRow.xaml | 8 +- Content.Client/Cargo/UI/CargoProductRow.xaml | 6 +- .../Cargo/UI/FundingAllocationMenu.xaml | 29 ++ .../Cargo/UI/FundingAllocationMenu.xaml.cs | 169 +++++++++++ .../Cargo/Components/CargoPalletComponent.cs | 2 - .../Components/CargoPalletConsoleComponent.cs | 6 +- .../Components/StationBankAccountComponent.cs | 19 -- .../StationCargoOrderDatabaseComponent.cs | 12 +- .../Cargo/Systems/CargoSystem.Bounty.cs | 17 +- .../Cargo/Systems/CargoSystem.Funds.cs | 144 +++++++++ .../Cargo/Systems/CargoSystem.Orders.cs | 159 +++++----- .../Cargo/Systems/CargoSystem.Shuttle.cs | 108 ++++--- .../Cargo/Systems/CargoSystem.Telepad.cs | 36 ++- Content.Server/Cargo/Systems/CargoSystem.cs | 43 +-- Content.Server/Delivery/DeliverySystem.cs | 0 Content.Server/Stack/StackSystem.cs | 2 +- .../Station/Systems/StationSystem.cs | 4 +- .../Components/CargoGiftsRuleComponent.cs | 6 + .../StationEvents/Events/CargoGiftsRule.cs | 3 +- .../StationLogisticStatsDatabaseComponent.cs | 3 +- .../_DV/Cargo/Systems/LogisticStatsSystem.cs | 2 +- .../_DV/Cargo/Systems/StockMarketSystem.cs | 5 +- .../Cartridges/StockTradingCartridgeSystem.cs | 6 +- .../_DV/Mail/EntitySystems/MailSystem.cs | 11 +- .../_DV/Shipyard/ShipyardConsoleSystem.cs | 22 +- .../Components/IdCardConsoleComponent.cs | 1 + .../Cargo/BUI/CargoConsoleInterfaceState.cs | 8 +- .../Cargo/Components/BankClientComponent.cs | 25 -- .../Components/CargoOrderConsoleComponent.cs | 100 ++++++- .../FundingAllocationConsoleComponent.cs | 49 ++++ .../Cargo/Components/OverrideSellComponent.cs | 17 ++ .../Components/StationBankAccountComponent.cs | 79 +++++ .../Cargo/Prototypes/CargoAccountPrototype.cs | 39 +++ Content.Shared/Cargo/SharedCargoSystem.cs | 65 ++++- .../Locale/en-US/_DV/cargo/cargo-accounts.ftl | 8 + .../_DV/cargo/cargo-console-component.ftl | 1 + .../Locale/en-US/_DV/cargo/overrides.ftl | 10 + .../catalog/cargo/cargoproduct-categories.ftl | 1 + .../Locale/en-US/cargo/cargo-accounts.ftl | 17 ++ .../en-US/cargo/cargo-console-component.ftl | 49 +++- .../en-US/prototypes/access/accesses.ftl | 2 + Resources/Prototypes/Access/cargo.yml | 4 + Resources/Prototypes/Access/misc.yml | 1 + .../Catalog/Cargo/cargo_lockbox.yml | 49 ++++ .../Catalog/Fills/Lockers/heads.yml | 6 + .../Prototypes/Catalog/cargo_accounts.yml | 42 +++ .../Entities/Mobs/Player/admin_ghost.yml | 1 - .../Devices/Circuitboards/computer.yml | 78 +++++ .../Entities/Objects/Misc/paper.yml | 2 +- .../Prototypes/Entities/Stations/base.yml | 8 + .../Machines/Computers/computers.yml | 206 ++++++++++++- .../Structures/Storage/Crates/crates.yml | 188 ++++++++++++ .../Prototypes/SoundCollections/machines.yml | 14 + .../_DV/Catalog/Cargo/cargo_lockbox.yml | 9 + .../Catalog/Fills/Lockers/chiefjustice.yml | 1 + .../_DV/Catalog/Fills/Lockers/heads.yml | 1 + .../Prototypes/_DV/Catalog/cargo_accounts.yml | 6 + .../Devices/CircuitBoards/computer.yml | 14 + .../Entities/Objects/Devices/cartridges.yml | 1 - .../Structures/Machines/computers.yml | 34 ++- .../Structures/Storage/Crates/crates.yml | 30 ++ .../Machines/computers.rsi/allocate.png | Bin 0 -> 971 bytes .../Machines/computers.rsi/meta.json | 276 +++++++++++++++++- .../Machines/computers.rsi/request-eng.png | Bin 0 -> 1502 bytes .../Machines/computers.rsi/request-med.png | Bin 0 -> 1448 bytes .../Machines/computers.rsi/request-sci.png | Bin 0 -> 1371 bytes .../Machines/computers.rsi/request-sec.png | Bin 0 -> 1417 bytes .../Machines/computers.rsi/request-srv.png | Bin 0 -> 1511 bytes .../Machines/computers.rsi/transfer.png | Bin 0 -> 1776 bytes .../Storage/Crates/lockbox.rsi/base.png | Bin 0 -> 361 bytes .../Storage/Crates/lockbox.rsi/closed.png | Bin 0 -> 187 bytes .../Storage/Crates/lockbox.rsi/icon.png | Bin 0 -> 370 bytes .../Storage/Crates/lockbox.rsi/locked.png | Bin 0 -> 144 bytes .../Storage/Crates/lockbox.rsi/meta.json | 51 ++++ .../Storage/Crates/lockbox.rsi/open.png | Bin 0 -> 240 bytes .../Crates/lockbox.rsi/overlay-closed.png | Bin 0 -> 155 bytes .../Storage/Crates/lockbox.rsi/overlay.png | Bin 0 -> 144 bytes .../Storage/Crates/lockbox.rsi/sparking.png | Bin 0 -> 221 bytes .../Storage/Crates/lockbox.rsi/unlocked.png | Bin 0 -> 139 bytes .../Storage/Crates/lockbox.rsi/welded.png | Bin 0 -> 274 bytes .../Objects/Misc/module.rsi/cpu_justice.png | Bin 0 -> 269 bytes .../_DV/Objects/Misc/module.rsi/meta.json | 14 + .../Machines/computers.rsi/meta.json | 49 ++++ .../Machines/computers.rsi/request-jst.png | Bin 0 -> 723 bytes 88 files changed, 2344 insertions(+), 358 deletions(-) create mode 100644 Content.Client/Cargo/BUI/FundingAllocationConsoleBoundUserInterface.cs create mode 100644 Content.Client/Cargo/UI/FundingAllocationMenu.xaml create mode 100644 Content.Client/Cargo/UI/FundingAllocationMenu.xaml.cs delete mode 100644 Content.Server/Cargo/Components/StationBankAccountComponent.cs create mode 100644 Content.Server/Cargo/Systems/CargoSystem.Funds.cs create mode 100644 Content.Server/Delivery/DeliverySystem.cs delete mode 100644 Content.Shared/Cargo/Components/BankClientComponent.cs create mode 100644 Content.Shared/Cargo/Components/FundingAllocationConsoleComponent.cs create mode 100644 Content.Shared/Cargo/Components/OverrideSellComponent.cs create mode 100644 Content.Shared/Cargo/Components/StationBankAccountComponent.cs create mode 100644 Content.Shared/Cargo/Prototypes/CargoAccountPrototype.cs create mode 100644 Resources/Locale/en-US/_DV/cargo/cargo-accounts.ftl create mode 100644 Resources/Locale/en-US/_DV/cargo/cargo-console-component.ftl create mode 100644 Resources/Locale/en-US/_DV/cargo/overrides.ftl create mode 100644 Resources/Locale/en-US/_DV/prototypes/catalog/cargo/cargoproduct-categories.ftl create mode 100644 Resources/Locale/en-US/cargo/cargo-accounts.ftl create mode 100644 Resources/Prototypes/Catalog/Cargo/cargo_lockbox.yml create mode 100644 Resources/Prototypes/Catalog/cargo_accounts.yml create mode 100644 Resources/Prototypes/SoundCollections/machines.yml create mode 100644 Resources/Prototypes/_DV/Catalog/Cargo/cargo_lockbox.yml create mode 100644 Resources/Prototypes/_DV/Catalog/cargo_accounts.yml create mode 100644 Resources/Textures/Structures/Machines/computers.rsi/allocate.png create mode 100644 Resources/Textures/Structures/Machines/computers.rsi/request-eng.png create mode 100644 Resources/Textures/Structures/Machines/computers.rsi/request-med.png create mode 100644 Resources/Textures/Structures/Machines/computers.rsi/request-sci.png create mode 100644 Resources/Textures/Structures/Machines/computers.rsi/request-sec.png create mode 100644 Resources/Textures/Structures/Machines/computers.rsi/request-srv.png create mode 100644 Resources/Textures/Structures/Machines/computers.rsi/transfer.png create mode 100644 Resources/Textures/Structures/Storage/Crates/lockbox.rsi/base.png create mode 100644 Resources/Textures/Structures/Storage/Crates/lockbox.rsi/closed.png create mode 100644 Resources/Textures/Structures/Storage/Crates/lockbox.rsi/icon.png create mode 100644 Resources/Textures/Structures/Storage/Crates/lockbox.rsi/locked.png create mode 100644 Resources/Textures/Structures/Storage/Crates/lockbox.rsi/meta.json create mode 100644 Resources/Textures/Structures/Storage/Crates/lockbox.rsi/open.png create mode 100644 Resources/Textures/Structures/Storage/Crates/lockbox.rsi/overlay-closed.png create mode 100644 Resources/Textures/Structures/Storage/Crates/lockbox.rsi/overlay.png create mode 100644 Resources/Textures/Structures/Storage/Crates/lockbox.rsi/sparking.png create mode 100644 Resources/Textures/Structures/Storage/Crates/lockbox.rsi/unlocked.png create mode 100644 Resources/Textures/Structures/Storage/Crates/lockbox.rsi/welded.png create mode 100644 Resources/Textures/_DV/Objects/Misc/module.rsi/cpu_justice.png create mode 100644 Resources/Textures/_DV/Objects/Misc/module.rsi/meta.json create mode 100644 Resources/Textures/_DV/Structures/Machines/computers.rsi/meta.json create mode 100644 Resources/Textures/_DV/Structures/Machines/computers.rsi/request-jst.png diff --git a/Content.Client/Cargo/BUI/CargoOrderConsoleBoundUserInterface.cs b/Content.Client/Cargo/BUI/CargoOrderConsoleBoundUserInterface.cs index 0be3ebd97f8..52846cefdb9 100644 --- a/Content.Client/Cargo/BUI/CargoOrderConsoleBoundUserInterface.cs +++ b/Content.Client/Cargo/BUI/CargoOrderConsoleBoundUserInterface.cs @@ -1,6 +1,7 @@ using Content.Shared.Cargo; using Content.Client.Cargo.UI; using Content.Shared.Cargo.BUI; +using Content.Shared.Cargo.Components; using Content.Shared.Cargo.Events; using Content.Shared.Cargo.Prototypes; using Content.Shared.IdentityManagement; @@ -14,6 +15,8 @@ namespace Content.Client.Cargo.BUI { public sealed class CargoOrderConsoleBoundUserInterface : BoundUserInterface { + private readonly SharedCargoSystem _cargoSystem; + [ViewVariables] private CargoConsoleMenu? _menu; @@ -43,6 +46,7 @@ namespace Content.Client.Cargo.BUI public CargoOrderConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) { + _cargoSystem = EntMan.System(); } protected override void Open() @@ -57,7 +61,7 @@ namespace Content.Client.Cargo.BUI string orderRequester; - if (EntMan.TryGetComponent(localPlayer, out var metadata)) + if (EntMan.EntityExists(localPlayer)) orderRequester = Identity.Name(localPlayer.Value, EntMan); else orderRequester = string.Empty; @@ -96,41 +100,54 @@ namespace Content.Client.Cargo.BUI } }; + _menu.OnAccountAction += (account, amount) => + { + SendMessage(new CargoConsoleWithdrawFundsMessage(account, amount)); + }; + + _menu.OnToggleUnboundedLimit += _ => + { + SendMessage(new CargoConsoleToggleLimitMessage()); + }; + _menu.OpenCentered(); } private void Populate(List orders) { - if (_menu == null) return; + if (_menu == null) + return; _menu.PopulateProducts(); _menu.PopulateCategories(); _menu.PopulateOrders(orders); + _menu.PopulateAccountActions(); } protected override void UpdateState(BoundUserInterfaceState state) { base.UpdateState(state); - if (state is not CargoConsoleInterfaceState cState) + if (state is not CargoConsoleInterfaceState cState || !EntMan.TryGetComponent(Owner, out var orderConsole)) return; + var station = EntMan.GetEntity(cState.Station); OrderCapacity = cState.Capacity; OrderCount = cState.Count; - BankBalance = cState.Balance; + BankBalance = _cargoSystem.GetBalanceFromAccount(station, orderConsole.Account); AccountName = cState.Name; + _menu?.UpdateStation(station); Populate(cState.Orders); - _menu?.UpdateCargoCapacity(OrderCount, OrderCapacity); - _menu?.UpdateBankData(AccountName, BankBalance); } protected override void Dispose(bool disposing) { base.Dispose(disposing); - if (!disposing) return; + if (!disposing) + return; _menu?.Dispose(); _orderMenu?.Dispose(); @@ -170,8 +187,6 @@ namespace Content.Client.Cargo.BUI return; SendMessage(new CargoConsoleApproveOrderMessage(row.Order.OrderId)); - // Most of the UI isn't predicted anyway so. - // _menu?.UpdateCargoCapacity(OrderCount + row.Order.Amount, OrderCapacity); } } } diff --git a/Content.Client/Cargo/BUI/FundingAllocationConsoleBoundUserInterface.cs b/Content.Client/Cargo/BUI/FundingAllocationConsoleBoundUserInterface.cs new file mode 100644 index 00000000000..eb65be40d37 --- /dev/null +++ b/Content.Client/Cargo/BUI/FundingAllocationConsoleBoundUserInterface.cs @@ -0,0 +1,35 @@ +using Content.Client.Cargo.UI; +using Content.Shared.Cargo.Components; +using JetBrains.Annotations; +using Robust.Client.UserInterface; + +namespace Content.Client.Cargo.BUI; + +[UsedImplicitly] +public sealed class FundingAllocationConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : BoundUserInterface(owner, uiKey) +{ + [ViewVariables] + private FundingAllocationMenu? _menu; + + protected override void Open() + { + base.Open(); + + _menu = this.CreateWindow(); + + _menu.OnSavePressed += d => + { + SendMessage(new SetFundingAllocationBuiMessage(d)); + }; + } + + protected override void UpdateState(BoundUserInterfaceState message) + { + base.UpdateState(message); + + if (message is not FundingAllocationConsoleBuiState state) + return; + + _menu?.Update(state); + } +} diff --git a/Content.Client/Cargo/UI/CargoConsoleMenu.xaml b/Content.Client/Cargo/UI/CargoConsoleMenu.xaml index dd7a9f110ca..72d8cf7daf0 100644 --- a/Content.Client/Cargo/UI/CargoConsoleMenu.xaml +++ b/Content.Client/Cargo/UI/CargoConsoleMenu.xaml @@ -3,66 +3,83 @@ xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls" SetSize="600 600" MinSize="600 600"> - + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +