From 2e0fcbab5a4f077279fec3d30b041a50d0e9cd58 Mon Sep 17 00:00:00 2001 From: 20kdc Date: Wed, 4 May 2022 03:51:25 +0100 Subject: [PATCH] Remove GalacticMarket component (#7914) --- .../Cargo/CargoConsoleBoundUserInterface.cs | 15 +-- .../Components/GalacticMarketComponent.cs | 36 ------ .../Cargo/UI/CargoConsoleMenu.xaml.cs | 30 +++-- .../Cargo/Components/CargoConsoleComponent.cs | 1 - .../Components/GalacticMarketComponent.cs | 15 --- .../SharedGalacticMarketComponent.cs | 106 ------------------ .../Catalog/Cargo/cargo_atmospherics.yml | 66 +++++------ .../Entities/Mobs/Player/admin_ghost.yml | 63 ----------- .../Machines/Computers/computers.yml | 68 ----------- 9 files changed, 47 insertions(+), 353 deletions(-) delete mode 100644 Content.Client/Cargo/Components/GalacticMarketComponent.cs delete mode 100644 Content.Server/Cargo/Components/GalacticMarketComponent.cs delete mode 100644 Content.Shared/Cargo/Components/SharedGalacticMarketComponent.cs diff --git a/Content.Client/Cargo/CargoConsoleBoundUserInterface.cs b/Content.Client/Cargo/CargoConsoleBoundUserInterface.cs index 944c133ecb..ac03a59fe9 100644 --- a/Content.Client/Cargo/CargoConsoleBoundUserInterface.cs +++ b/Content.Client/Cargo/CargoConsoleBoundUserInterface.cs @@ -19,9 +19,6 @@ namespace Content.Client.Cargo [ViewVariables] private CargoConsoleOrderMenu? _orderMenu; - [ViewVariables] - public GalacticMarketComponent? Market { get; private set; } - [ViewVariables] public CargoOrderDatabaseComponent? Orders { get; private set; } @@ -51,10 +48,8 @@ namespace Content.Client.Cargo base.Open(); var entMan = IoCManager.Resolve(); - if (!entMan.TryGetComponent(Owner.Owner, out GalacticMarketComponent? market) || - !entMan.TryGetComponent(Owner.Owner, out CargoOrderDatabaseComponent? orders)) return; + if (!entMan.TryGetComponent(Owner.Owner, out CargoOrderDatabaseComponent? orders)) return; - Market = market; Orders = orders; _menu = new CargoConsoleMenu(this); @@ -64,8 +59,6 @@ namespace Content.Client.Cargo _menu.Populate(); - Market.OnDatabaseUpdated += _menu.PopulateProducts; - Market.OnDatabaseUpdated += _menu.PopulateCategories; Orders.OnDatabaseUpdated += _menu.PopulateOrders; _menu.CallShuttleButton.OnPressed += (_) => @@ -121,12 +114,6 @@ namespace Content.Client.Cargo if (!disposing) return; - if (Market != null && _menu != null) - { - Market.OnDatabaseUpdated -= _menu.PopulateProducts; - Market.OnDatabaseUpdated -= _menu.PopulateCategories; - } - if (Orders != null && _menu != null) { Orders.OnDatabaseUpdated -= _menu.PopulateOrders; diff --git a/Content.Client/Cargo/Components/GalacticMarketComponent.cs b/Content.Client/Cargo/Components/GalacticMarketComponent.cs deleted file mode 100644 index b26ee0b1f4..0000000000 --- a/Content.Client/Cargo/Components/GalacticMarketComponent.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using Content.Shared.Cargo; -using Content.Shared.Cargo.Components; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using Robust.Shared.Prototypes; - -namespace Content.Client.Cargo.Components -{ - [RegisterComponent] - public sealed class GalacticMarketComponent : SharedGalacticMarketComponent - { - [Dependency] private readonly IPrototypeManager _prototypeManager = default!; - - /// - /// Event called when the database is updated. - /// - public event Action? OnDatabaseUpdated; - - public override void HandleComponentState(ComponentState? curState, ComponentState? nextState) - { - base.HandleComponentState(curState, nextState); - if (curState is not GalacticMarketState state) - return; - _productIds.Clear(); - foreach (var productId in state.Products) - { - if (!_prototypeManager.TryIndex(productId, out CargoProductPrototype? product)) - continue; - _products.Add(product); - } - - OnDatabaseUpdated?.Invoke(); - } - } -} diff --git a/Content.Client/Cargo/UI/CargoConsoleMenu.xaml.cs b/Content.Client/Cargo/UI/CargoConsoleMenu.xaml.cs index 126bf1d3e3..dac0b70d86 100644 --- a/Content.Client/Cargo/UI/CargoConsoleMenu.xaml.cs +++ b/Content.Client/Cargo/UI/CargoConsoleMenu.xaml.cs @@ -9,6 +9,7 @@ using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.XAML; using Robust.Client.Utility; using Robust.Shared.IoC; +using Robust.Shared.Prototypes; using Robust.Shared.Localization; using Robust.Shared.Log; using Robust.Shared.Maths; @@ -21,6 +22,9 @@ namespace Content.Client.Cargo.UI [GenerateTypedNameReferences] public sealed partial class CargoConsoleMenu : DefaultWindow { + [Dependency] + private IPrototypeManager _prototypeManager = default!; + public CargoConsoleBoundUserInterface Owner { get; private set; } public event Action? OnItemSelected; @@ -66,6 +70,8 @@ namespace Content.Client.Cargo.UI Categories.SelectId(id); } + public IEnumerable ProductPrototypes => _prototypeManager.EnumeratePrototypes(); + /// /// Populates the list of products that will actually be shown, using the current filters. /// @@ -73,13 +79,8 @@ namespace Content.Client.Cargo.UI { Products.RemoveAllChildren(); - if (Owner.Market == null) - { - return; - } - var search = SearchBar.Text.Trim().ToLowerInvariant(); - foreach (var prototype in Owner.Market.Products) + foreach (var prototype in ProductPrototypes) { // if no search or category // else if search @@ -112,14 +113,9 @@ namespace Content.Client.Cargo.UI _categoryStrings.Clear(); Categories.Clear(); - if (Owner.Market == null) - { - return; - } - _categoryStrings.Add(Loc.GetString("cargo-console-menu-populate-categories-all-text")); - foreach (var prototype in Owner.Market.Products) + foreach (var prototype in ProductPrototypes) { if (!_categoryStrings.Contains(prototype.Category)) { @@ -141,26 +137,26 @@ namespace Content.Client.Cargo.UI Orders.RemoveAllChildren(); Requests.RemoveAllChildren(); - if (Owner.Orders == null || Owner.Market == null) + if (Owner.Orders == null) { return; } foreach (var order in Owner.Orders.Orders) { - var productName = Owner.Market.GetProduct(order.ProductId)?.Name; - - if (productName == null) + if (!_prototypeManager.TryIndex(order.ProductId, out CargoProductPrototype? product)) { DebugTools.Assert(false); Logger.ErrorS("cargo", $"Unable to find product name for {order.ProductId}"); continue; } + var productName = product.Name; + var row = new CargoOrderRow { Order = order, - Icon = { Texture = Owner.Market.GetProduct(order.ProductId)?.Icon.Frame0() }, + Icon = { Texture = product.Icon.Frame0() }, ProductName = { Text = Loc.GetString( diff --git a/Content.Server/Cargo/Components/CargoConsoleComponent.cs b/Content.Server/Cargo/Components/CargoConsoleComponent.cs index 1d74b681ec..5c13a5170c 100644 --- a/Content.Server/Cargo/Components/CargoConsoleComponent.cs +++ b/Content.Server/Cargo/Components/CargoConsoleComponent.cs @@ -68,7 +68,6 @@ namespace Content.Server.Cargo.Components { base.Initialize(); - Owner.EnsureComponentWarn(out GalacticMarketComponent _); Owner.EnsureComponentWarn(out CargoOrderDatabaseComponent _); if (UserInterface != null) diff --git a/Content.Server/Cargo/Components/GalacticMarketComponent.cs b/Content.Server/Cargo/Components/GalacticMarketComponent.cs deleted file mode 100644 index d374cc0090..0000000000 --- a/Content.Server/Cargo/Components/GalacticMarketComponent.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Content.Shared.Cargo.Components; -using Robust.Shared.GameObjects; -using Robust.Shared.Players; - -namespace Content.Server.Cargo.Components -{ - [RegisterComponent] - public sealed class GalacticMarketComponent : SharedGalacticMarketComponent - { - public override ComponentState GetComponentState() - { - return new GalacticMarketState(GetProductIdList()); - } - } -} diff --git a/Content.Shared/Cargo/Components/SharedGalacticMarketComponent.cs b/Content.Shared/Cargo/Components/SharedGalacticMarketComponent.cs deleted file mode 100644 index 5806b50dfe..0000000000 --- a/Content.Shared/Cargo/Components/SharedGalacticMarketComponent.cs +++ /dev/null @@ -1,106 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using Robust.Shared.GameObjects; -using Robust.Shared.GameStates; -using Robust.Shared.IoC; -using Robust.Shared.Log; -using Robust.Shared.Prototypes; -using Robust.Shared.Serialization; -using Robust.Shared.Serialization.Manager.Attributes; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List; - -namespace Content.Shared.Cargo.Components -{ - [NetworkedComponent()] - public abstract class SharedGalacticMarketComponent : Component, IEnumerable, ISerializationHooks - { - [DataField("products", customTypeSerializer: typeof(PrototypeIdListSerializer))] - protected List _productIds = new(); - - protected readonly List _products = new(); - - /// - /// A read-only list of products. - /// - public IReadOnlyList Products => _products; - - void ISerializationHooks.AfterDeserialization() - { - var prototypeManager = IoCManager.Resolve(); - - _products.Clear(); - - foreach (var id in _productIds) - { - if (!prototypeManager.TryIndex(id, out CargoProductPrototype? product)) - { - Logger.ErrorS("cargo", $"Unable to find {nameof(CargoProductPrototype)} for {id}"); - continue; - } - - _products.Add(product); - } - } - - void ISerializationHooks.BeforeSerialization() - { - _productIds.Clear(); - - foreach (var product in _products) - { - _productIds.Add(product.ID); - } - } - - public IEnumerator GetEnumerator() - { - return _products.GetEnumerator(); - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - - /// - /// Returns a product from the string id; - /// - /// Product - public CargoProductPrototype? GetProduct(string productId) - { - var prototypeManager = IoCManager.Resolve(); - if (!prototypeManager.TryIndex(productId, out CargoProductPrototype? product) || !_products.Contains(product)) - { - return null; - } - return product; - } - - /// - /// Returns a list with the IDs of all products. - /// - /// A list of product IDs - public List GetProductIdList() - { - var productIds = new List(); - - foreach (var product in _products) - { - productIds.Add(product.ID); - } - - return productIds; - } - } - - [Serializable, NetSerializable] - public sealed class GalacticMarketState : ComponentState - { - public List Products; - public GalacticMarketState(List technologies) - { - Products = technologies; - } - } -} diff --git a/Resources/Prototypes/Catalog/Cargo/cargo_atmospherics.yml b/Resources/Prototypes/Catalog/Cargo/cargo_atmospherics.yml index 1c33d1da13..aaa65e9348 100644 --- a/Resources/Prototypes/Catalog/Cargo/cargo_atmospherics.yml +++ b/Resources/Prototypes/Catalog/Cargo/cargo_atmospherics.yml @@ -46,38 +46,38 @@ category: Atmospherics group: market -- type: cargoProduct - name: "water vapor canister" - id: AtmosphericsWaterVapor - description: "Water vapor canister" - icon: - sprite: Structures/Storage/canister.rsi - state: water_vapor - product: WaterVaporCanister - cost: 1000 - category: Atmospherics - group: market +#- type: cargoProduct +# name: "water vapor canister" +# id: AtmosphericsWaterVapor +# description: "Water vapor canister" +# icon: +# sprite: Structures/Storage/canister.rsi +# state: water_vapor +# product: WaterVaporCanister +# cost: 1000 +# category: Atmospherics +# group: market -- type: cargoProduct - name: "plasma canister" - id: AtmosphericsPlasma - description: "Plasma canister" - icon: - sprite: Structures/Storage/canister.rsi - state: orange - product: PlasmaCanister - cost: 2000 - category: Atmospherics - group: market +#- type: cargoProduct +# name: "plasma canister" +# id: AtmosphericsPlasma +# description: "Plasma canister" +# icon: +# sprite: Structures/Storage/canister.rsi +# state: orange +# product: PlasmaCanister +# cost: 2000 +# category: Atmospherics +# group: market -- type: cargoProduct - name: "tritium canister" - id: AtmosphericsTritium - description: "Tritium canister" - icon: - sprite: Structures/Storage/canister.rsi - state: green - product: TritiumCanister - cost: 2000 - category: Atmospherics - group: market +#- type: cargoProduct +# name: "tritium canister" +# id: AtmosphericsTritium +# description: "Tritium canister" +# icon: +# sprite: Structures/Storage/canister.rsi +# state: green +# product: TritiumCanister +# cost: 2000 +# category: Atmospherics +# group: market diff --git a/Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml b/Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml index d250376306..990b62b765 100644 --- a/Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml +++ b/Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml @@ -100,69 +100,6 @@ - type: RadarConsole - type: CargoConsole - type: CargoOrderDatabase - - type: GalacticMarket # wow this kinda sucks. - products: - - MedicalSupplies - - MedicalChemistrySupplies - - EmergencyExplosive - - EmergencyFire - - EmergencyInternals - - EmergencyRadiation - - EmergencyInflatablewall - - ArmorySmg - - ArmoryShotgun - - SecurityArmor - - SecurityRiot - - SecurityLaser - - SecurityHelmet - - SecuritySupplies - - SecurityNonLethal - - SecurityRestraints - - HydroponicsTools - - HydroponicsSeeds - - HydroponicsSeedsExotic - - LivestockMonkeyCube - - LivestockCow - - LivestockChicken - - LivestockDuck - - LivestockGoat - - FoodPizza - - ServiceJanitorial - - ServiceLightsReplacement - - ServiceSmokeables - - ServiceCustomSmokable - - ServiceBureaucracy - - ServicePersonnel - - EngineeringCableLv - - EngineeringCableMv - - EngineeringCableHv - - EngineeringCableBulk - - EngineAmeShielding - - EngineAmeJar - - EngineAmeControl - - EngineSolar - - FunPlushies - - FunArtSupplies - - FunInstruments - - FunBoardGames - - FunATV - - MaterialSteel - - MaterialGlass - - MaterialPlastic - - MaterialPlasteel - - MaterialPlasma - - EngineSingularityEmitter - - EngineSingularityCollector - - EngineSingularityGenerator - - EngineSingularityContainment - - EngineParticleAccelerator - - ShuttleThruster - - ShuttleGyroscope - - AtmosphericsAir - - AtmosphericsOxygen - - AtmosphericsNitrogen - - AtmosphericsCarbonDioxide - - ArtifactContainer - type: CrewMonitoringConsole snap: false precision: 3 diff --git a/Resources/Prototypes/Entities/Structures/Machines/Computers/computers.yml b/Resources/Prototypes/Entities/Structures/Machines/Computers/computers.yml index d41a3a6531..44108cf513 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/Computers/computers.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/Computers/computers.yml @@ -349,74 +349,6 @@ screen: supply - type: CargoConsole - type: CargoOrderDatabase - - type: GalacticMarket - products: - - MedicalSupplies - - MedicalChemistrySupplies - - EmergencyExplosive - - EmergencyFire - - EmergencyInternals - - EmergencyRadiation - - EmergencyInflatablewall - - ArmorySmg - - ArmoryShotgun - - SecurityArmor - - SecurityRiot - - SecurityLaser - - SecurityHelmet - - SecuritySupplies - - SecurityNonLethal - - SecurityRestraints - - HydroponicsTools - - HydroponicsSeeds - - HydroponicsSeedsExotic - - LivestockMonkeyCube - - LivestockCow - - LivestockChicken - - LivestockDuck - - LivestockGoat - - FoodPizza - - FoodMRE - - ServiceJanitorial - - ServiceLightsReplacement - - ServiceSmokeables - - ServiceCustomSmokable - - ServiceBureaucracy - - ServicePersonnel - - EngineeringCableLv - - EngineeringCableMv - - EngineeringCableHv - - EngineeringCableBulk - - EngineAmeShielding - - EngineAmeJar - - EngineAmeControl - - EngineSolar - - FunPlushies - - FunArtSupplies - - FunInstruments - - FunBrass - - FunBoardGames - - FunATV - - MaterialSteel - - MaterialGlass - - MaterialPlastic - - MaterialPlasteel - - MaterialPlasma - - EngineSingularityEmitter - - EngineSingularityCollector - - EngineSingularityGenerator - - EngineSingularityContainment - - EngineParticleAccelerator - - ShuttleThruster - - ShuttleGyroscope - - AtmosphericsAir - - AtmosphericsOxygen - - AtmosphericsNitrogen - - AtmosphericsCarbonDioxide - - ArtifactContainer -# - AtmosphericsWaterVapor -# - AtmosphericsPlasma -# - AtmosphericsTritium - type: ActivatableUI key: enum.CargoConsoleUiKey.Key - type: ActivatableUIRequiresPower