From: āda Date: Thu, 27 Feb 2025 11:33:39 +0000 (-0600) Subject: Multiple categories for lathe recipes (#34315) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=3127f73c4806273e2509342636734bbd0cb07a9e;p=space-station-14.git Multiple categories for lathe recipes (#34315) * first * lint * changes * change null comparison * linq * indent * fix indent --------- Co-authored-by: Milon --- diff --git a/Content.Client/Lathe/UI/LatheMenu.xaml.cs b/Content.Client/Lathe/UI/LatheMenu.xaml.cs index fa99a9dd8e..2b18ce28de 100644 --- a/Content.Client/Lathe/UI/LatheMenu.xaml.cs +++ b/Content.Client/Lathe/UI/LatheMenu.xaml.cs @@ -94,8 +94,17 @@ public sealed partial class LatheMenu : DefaultWindow if (!_prototypeManager.TryIndex(recipe, out var proto)) continue; - if (CurrentCategory != null && proto.Category != CurrentCategory) - continue; + // Category filtering + if (CurrentCategory != null) + { + if (proto.Categories.Count <= 0) + continue; + + var validRecipe = proto.Categories.Any(category => category == CurrentCategory); + + if (!validRecipe) + continue; + } if (SearchBar.Text.Trim().Length != 0) { @@ -179,18 +188,22 @@ public sealed partial class LatheMenu : DefaultWindow public void UpdateCategories() { + // Get categories from recipes var currentCategories = new List>(); foreach (var recipeId in Recipes) { var recipe = _prototypeManager.Index(recipeId); - if (recipe.Category == null) + if (recipe.Categories.Count <= 0) continue; - if (currentCategories.Contains(recipe.Category.Value)) - continue; + foreach (var category in recipe.Categories) + { + if (currentCategories.Contains(category)) + continue; - currentCategories.Add(recipe.Category.Value); + currentCategories.Add(category); + } } if (Categories != null && (Categories.Count == currentCategories.Count || !Categories.All(currentCategories.Contains))) diff --git a/Content.Shared/Research/Prototypes/LatheRecipePrototype.cs b/Content.Shared/Research/Prototypes/LatheRecipePrototype.cs index 79525575a6..7d26971b11 100644 --- a/Content.Shared/Research/Prototypes/LatheRecipePrototype.cs +++ b/Content.Shared/Research/Prototypes/LatheRecipePrototype.cs @@ -66,9 +66,9 @@ namespace Content.Shared.Research.Prototypes public bool ApplyMaterialDiscount = true; /// - /// A category used for visually sorting lathe recipes in the UI. + /// List of categories used for visually sorting lathe recipes in the UI. /// [DataField] - public ProtoId? Category; + public List> Categories = new(); } } diff --git a/Resources/Prototypes/Recipes/Lathes/Parts.yml b/Resources/Prototypes/Recipes/Lathes/Parts.yml index 0202919cb9..b870683a44 100644 --- a/Resources/Prototypes/Recipes/Lathes/Parts.yml +++ b/Resources/Prototypes/Recipes/Lathes/Parts.yml @@ -2,7 +2,8 @@ - type: latheRecipe abstract: true id: BasePartRecipe - category: Parts + categories: + - Parts completetime: 2 materials: Steel: 300 diff --git a/Resources/Prototypes/Recipes/Lathes/biogen.yml b/Resources/Prototypes/Recipes/Lathes/biogen.yml index 4f8887a130..a22a535caa 100644 --- a/Resources/Prototypes/Recipes/Lathes/biogen.yml +++ b/Resources/Prototypes/Recipes/Lathes/biogen.yml @@ -1,7 +1,8 @@ - type: latheRecipe id: BioGenMonkeyCube result: MonkeyCube - category: Food + categories: + - Food completetime: 3 materials: Biomass: 70 @@ -9,7 +10,8 @@ - type: latheRecipe id: BioGenKoboldCube result: KoboldCube - category: Food + categories: + - Food completetime: 3 materials: Biomass: 70 @@ -17,7 +19,8 @@ - type: latheRecipe id: BioGenMaterialCloth1 result: MaterialCloth1 - category: Materials + categories: + - Materials icon: sprite: Objects/Materials/materials.rsi state: cloth @@ -28,7 +31,8 @@ - type: latheRecipe id: BioGenMaterialCardboard1 result: MaterialCardboard1 - category: Materials + categories: + - Materials icon: sprite: Objects/Materials/materials.rsi state: cardboard @@ -39,7 +43,8 @@ - type: latheRecipe id: BioGenPaper result: Paper - category: Materials + categories: + - Materials completetime: 1 materials: Biomass: 2 @@ -47,7 +52,8 @@ - type: latheRecipe id: BioGenPaperRolling1 result: PaperRolling1 - category: Materials + categories: + - Materials completetime: 1 materials: Biomass: 1 @@ -55,7 +61,8 @@ - type: latheRecipe id: BioGenCandle result: Candle - category: Materials + categories: + - Materials completetime: 3 materials: Biomass: 3 @@ -64,7 +71,8 @@ id: BioGenPlantBGone resultReagents: PlantBGone: 10 - category: Chemicals + categories: + - Chemicals icon: sprite: Objects/Tools/Hydroponics/sprays.rsi state: plantbgone @@ -76,7 +84,8 @@ id: BioGenWeedKiller resultReagents: WeedKiller: 10 - category: Chemicals + categories: + - Chemicals icon: sprite: Objects/Tools/Hydroponics/sprays.rsi state: weedspray @@ -88,7 +97,8 @@ id: BioGenPestKiller resultReagents: PestKiller: 10 - category: Chemicals + categories: + - Chemicals icon: sprite: Objects/Tools/Hydroponics/sprays.rsi state: weedspray @@ -100,7 +110,8 @@ id: BioGenLeft4Zed resultReagents: Left4Zed: 10 - category: Chemicals + categories: + - Chemicals icon: sprite: Objects/Specific/Chemistry/bottle.rsi state: bottle-1 @@ -112,7 +123,8 @@ id: BioGenEZNutrient resultReagents: EZNutrient: 10 - category: Chemicals + categories: + - Chemicals icon: sprite: Objects/Specific/Chemistry/bottle.rsi state: bottle-1 @@ -124,7 +136,8 @@ id: BioGenRobustHarvest resultReagents: RobustHarvest: 10 - category: Chemicals + categories: + - Chemicals icon: sprite: Objects/Specific/Chemistry/bottle.rsi state: bottle-1 @@ -136,7 +149,8 @@ id: BioGenMilk resultReagents: Milk: 10 - category: Food + categories: + - Food icon: sprite: Objects/Consumable/Drinks/milk.rsi state: icon @@ -148,7 +162,8 @@ id: BioGenMilkSoy resultReagents: MilkSoy: 10 - category: Food + categories: + - Food icon: sprite: Objects/Consumable/Drinks/soymilk.rsi state: icon @@ -160,7 +175,8 @@ id: BioGenEthanol resultReagents: Ethanol: 10 - category: Food + categories: + - Food icon: sprite: Objects/Consumable/Drinks/glass_clear.rsi state: icon @@ -172,7 +188,8 @@ id: BioGenCream resultReagents: Cream: 10 - category: Food + categories: + - Food icon: sprite: Objects/Consumable/Drinks/cream.rsi state: icon @@ -184,7 +201,8 @@ id: BioGenBlackpepper resultReagents: Blackpepper: 10 - category: Food + categories: + - Food icon: sprite: Objects/Consumable/Food/condiments.rsi state: packet-pepper @@ -196,7 +214,8 @@ id: BioGenEnzyme resultReagents: Enzyme: 10 - category: Food + categories: + - Food icon: sprite: Objects/Consumable/Food/condiments.rsi state: bottle-empty @@ -208,7 +227,8 @@ id: BioGenFlour resultReagents: Flour: 10 - category: Food + categories: + - Food icon: sprite: Objects/Consumable/Food/ingredients.rsi state: flour-big @@ -220,7 +240,8 @@ id: BioGenSugar resultReagents: Sugar: 10 - category: Food + categories: + - Food icon: sprite: Objects/Consumable/Food/ingredients.rsi state: sugar-big diff --git a/Resources/Prototypes/Recipes/Lathes/devices.yml b/Resources/Prototypes/Recipes/Lathes/devices.yml index 5d7c649cde..21ec6773ef 100644 --- a/Resources/Prototypes/Recipes/Lathes/devices.yml +++ b/Resources/Prototypes/Recipes/Lathes/devices.yml @@ -43,7 +43,8 @@ - type: latheRecipe id: ExplosivePayload result: ExplosivePayload - category: Weapons + categories: + - Weapons completetime: 4 materials: Steel: 100 @@ -73,7 +74,8 @@ - type: latheRecipe id: AnomalyLocator result: AnomalyLocatorEmpty - category: Tools + categories: + - Tools completetime: 3 materials: Steel: 400 @@ -82,7 +84,8 @@ - type: latheRecipe id: AnomalyLocatorWide result: AnomalyLocatorWideEmpty - category: Tools + categories: + - Tools completetime: 3 materials: Steel: 400 @@ -99,7 +102,8 @@ - type: latheRecipe id: WeaponPistolCHIMP result: WeaponPistolCHIMP - category: Tools + categories: + - Tools completetime: 5 materials: Steel: 500 @@ -108,7 +112,8 @@ - type: latheRecipe id: WeaponGauntletGorilla result: WeaponGauntletGorilla - category: Tools + categories: + - Tools completetime: 5 materials: Steel: 1500 @@ -153,7 +158,8 @@ - type: latheRecipe id: WeaponForceGun result: WeaponForceGun - category: Tools + categories: + - Tools completetime: 5 materials: Steel: 500 @@ -172,7 +178,8 @@ - type: latheRecipe id: WeaponProtoKineticAccelerator result: WeaponProtoKineticAccelerator - category: Weapons + categories: + - Weapons completetime: 5 materials: Steel: 1000 @@ -182,7 +189,8 @@ - type: latheRecipe id: WeaponTetherGun result: WeaponTetherGun - category: Tools + categories: + - Tools completetime: 5 materials: Steel: 500 @@ -192,7 +200,8 @@ - type: latheRecipe id: WeaponGrapplingGun result: WeaponGrapplingGun - category: Tools + categories: + - Tools completetime: 5 materials: Steel: 500 diff --git a/Resources/Prototypes/Recipes/Lathes/electronics.yml b/Resources/Prototypes/Recipes/Lathes/electronics.yml index 5e51dec195..f6f56ab282 100644 --- a/Resources/Prototypes/Recipes/Lathes/electronics.yml +++ b/Resources/Prototypes/Recipes/Lathes/electronics.yml @@ -3,7 +3,8 @@ - type: latheRecipe abstract: true id: BaseElectronicsRecipe - category: Circuitry + categories: + - Circuitry completetime: 2 materials: Steel: 100 diff --git a/Resources/Prototypes/Recipes/Lathes/mech_parts.yml b/Resources/Prototypes/Recipes/Lathes/mech_parts.yml index db7443256c..52d68e7c39 100644 --- a/Resources/Prototypes/Recipes/Lathes/mech_parts.yml +++ b/Resources/Prototypes/Recipes/Lathes/mech_parts.yml @@ -3,7 +3,8 @@ - type: latheRecipe abstract: true id: BaseMechPartRecipe - category: Mech + categories: + - Mech completetime: 10 # Recipes diff --git a/Resources/Prototypes/Recipes/Lathes/medical.yml b/Resources/Prototypes/Recipes/Lathes/medical.yml index 08250290ec..f09babc770 100644 --- a/Resources/Prototypes/Recipes/Lathes/medical.yml +++ b/Resources/Prototypes/Recipes/Lathes/medical.yml @@ -75,7 +75,8 @@ - type: latheRecipe id: HandheldHealthAnalyzer result: HandheldHealthAnalyzerEmpty - category: Tools + categories: + - Tools completetime: 4 materials: Glass: 500 diff --git a/Resources/Prototypes/Recipes/Lathes/misc.yml b/Resources/Prototypes/Recipes/Lathes/misc.yml index b1e8cee32d..d0a9b586c0 100644 --- a/Resources/Prototypes/Recipes/Lathes/misc.yml +++ b/Resources/Prototypes/Recipes/Lathes/misc.yml @@ -3,7 +3,8 @@ - type: latheRecipe abstract: true id: BaseLightRecipe - category: Lights + categories: + - Lights completetime: 2 materials: Steel: 50 diff --git a/Resources/Prototypes/Recipes/Lathes/powercells.yml b/Resources/Prototypes/Recipes/Lathes/powercells.yml index 82c7b96aff..3b9270201d 100644 --- a/Resources/Prototypes/Recipes/Lathes/powercells.yml +++ b/Resources/Prototypes/Recipes/Lathes/powercells.yml @@ -1,7 +1,8 @@ - type: latheRecipe id: PowerCellSmall result: PowerCellSmallPrinted - category: Parts + categories: + - Parts completetime: 1 materials: Steel: 100 @@ -10,7 +11,8 @@ - type: latheRecipe id: PowerCellMedium result: PowerCellMediumPrinted - category: Parts + categories: + - Parts completetime: 6 materials: Steel: 300 @@ -21,7 +23,8 @@ - type: latheRecipe id: PowerCellHigh result: PowerCellHighPrinted - category: Parts + categories: + - Parts completetime: 10 materials: Steel: 300 @@ -32,7 +35,8 @@ - type: latheRecipe id: PowerCellMicroreactor result: PowerCellMicroreactorPrinted - category: Parts + categories: + - Parts completetime: 10 materials: Steel: 500 diff --git a/Resources/Prototypes/Recipes/Lathes/robotics.yml b/Resources/Prototypes/Recipes/Lathes/robotics.yml index a4413e01eb..60b762c1f1 100644 --- a/Resources/Prototypes/Recipes/Lathes/robotics.yml +++ b/Resources/Prototypes/Recipes/Lathes/robotics.yml @@ -3,7 +3,8 @@ - type: latheRecipe abstract: true id: BaseRoboticsRecipe - category: Robotics + categories: + - Robotics completetime: 2 - type: latheRecipe diff --git a/Resources/Prototypes/Recipes/Lathes/salvage.yml b/Resources/Prototypes/Recipes/Lathes/salvage.yml index 4cf9b9073c..02eeb4bafb 100644 --- a/Resources/Prototypes/Recipes/Lathes/salvage.yml +++ b/Resources/Prototypes/Recipes/Lathes/salvage.yml @@ -21,7 +21,8 @@ - type: latheRecipe id: Fulton result: Fulton1 - category: Tools + categories: + - Tools completetime: 1 materials: Steel: 200 @@ -30,7 +31,8 @@ - type: latheRecipe id: FultonBeacon result: FultonBeacon - category: Tools + categories: + - Tools completetime: 5 materials: Steel: 1000 @@ -40,7 +42,8 @@ - type: latheRecipe id: SeismicCharge result: SeismicCharge - category: Tools + categories: + - Tools completetime: 1 materials: Plastic: 1500 diff --git a/Resources/Prototypes/Recipes/Lathes/security.yml b/Resources/Prototypes/Recipes/Lathes/security.yml index c72701711b..725b785dd7 100644 --- a/Resources/Prototypes/Recipes/Lathes/security.yml +++ b/Resources/Prototypes/Recipes/Lathes/security.yml @@ -3,7 +3,8 @@ - type: latheRecipe abstract: true id: BaseWeaponRecipe - category: Weapons + categories: + - Weapons completetime: 2 materials: Steel: 300 @@ -18,7 +19,8 @@ - type: latheRecipe abstract: true id: BaseAmmoRecipe - category: Ammo + categories: + - Ammo completetime: 5 - type: latheRecipe diff --git a/Resources/Prototypes/Recipes/Lathes/tools.yml b/Resources/Prototypes/Recipes/Lathes/tools.yml index fc35153317..8a8c88d1e6 100644 --- a/Resources/Prototypes/Recipes/Lathes/tools.yml +++ b/Resources/Prototypes/Recipes/Lathes/tools.yml @@ -3,7 +3,8 @@ - type: latheRecipe abstract: true id: BaseToolRecipe - category: Tools + categories: + - Tools completetime: 2 materials: Steel: 200 @@ -52,7 +53,8 @@ - type: latheRecipe id: CableStack result: CableApcStack1 - category: Parts + categories: + - Parts completetime: 0.1 materials: Steel: 30