]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Multiple categories for lathe recipes (#34315)
authorāda <ss.adasts@gmail.com>
Thu, 27 Feb 2025 11:33:39 +0000 (05:33 -0600)
committerGitHub <noreply@github.com>
Thu, 27 Feb 2025 11:33:39 +0000 (12:33 +0100)
* first

* lint

* changes

* change null comparison

* linq

* indent

* fix indent

---------

Co-authored-by: Milon <milonpl.git@proton.me>
14 files changed:
Content.Client/Lathe/UI/LatheMenu.xaml.cs
Content.Shared/Research/Prototypes/LatheRecipePrototype.cs
Resources/Prototypes/Recipes/Lathes/Parts.yml
Resources/Prototypes/Recipes/Lathes/biogen.yml
Resources/Prototypes/Recipes/Lathes/devices.yml
Resources/Prototypes/Recipes/Lathes/electronics.yml
Resources/Prototypes/Recipes/Lathes/mech_parts.yml
Resources/Prototypes/Recipes/Lathes/medical.yml
Resources/Prototypes/Recipes/Lathes/misc.yml
Resources/Prototypes/Recipes/Lathes/powercells.yml
Resources/Prototypes/Recipes/Lathes/robotics.yml
Resources/Prototypes/Recipes/Lathes/salvage.yml
Resources/Prototypes/Recipes/Lathes/security.yml
Resources/Prototypes/Recipes/Lathes/tools.yml

index fa99a9dd8ebf20dc0db045eb0669391f0531a5c3..2b18ce28de957f77943f19f645eb77474374a974 100644 (file)
@@ -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<ProtoId<LatheCategoryPrototype>>();
         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)))
index 79525575a6426a87a8cca9255d2739a6e2ce1945..7d26971b1136e7ff3bc1b6315f5984728ff581ae 100644 (file)
@@ -66,9 +66,9 @@ namespace Content.Shared.Research.Prototypes
         public bool ApplyMaterialDiscount = true;
 
         /// <summary>
-        /// A category used for visually sorting lathe recipes in the UI.
+        /// List of categories used for visually sorting lathe recipes in the UI.
         /// </summary>
         [DataField]
-        public ProtoId<LatheCategoryPrototype>? Category;
+        public List<ProtoId<LatheCategoryPrototype>> Categories = new();
     }
 }
index 0202919cb9a794161a2602569b5023f7b726ac09..b870683a4474fd4dce328bdbd06b36653aca78fb 100644 (file)
@@ -2,7 +2,8 @@
 - type: latheRecipe
   abstract: true
   id: BasePartRecipe
-  category: Parts
+  categories:
+  - Parts
   completetime: 2
   materials:
     Steel: 300
index 4f8887a130d00798be889f47e56b353e2edb02a2..a22a535caa6b9de3db5864cb185572340aa941d1 100644 (file)
@@ -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
   id: BioGenLeft4Zed
   resultReagents:
     Left4Zed: 10
-  category: Chemicals
+  categories:
+  - Chemicals
   icon:
     sprite: Objects/Specific/Chemistry/bottle.rsi
     state: bottle-1
   id: BioGenEZNutrient
   resultReagents:
     EZNutrient: 10
-  category: Chemicals
+  categories:
+  - Chemicals
   icon:
     sprite: Objects/Specific/Chemistry/bottle.rsi
     state: bottle-1
   id: BioGenRobustHarvest
   resultReagents:
     RobustHarvest: 10
-  category: Chemicals
+  categories:
+  - Chemicals
   icon:
     sprite: Objects/Specific/Chemistry/bottle.rsi
     state: bottle-1
   id: BioGenMilk
   resultReagents:
     Milk: 10
-  category: Food
+  categories:
+  - Food
   icon:
     sprite: Objects/Consumable/Drinks/milk.rsi
     state: icon
   id: BioGenMilkSoy
   resultReagents:
     MilkSoy: 10
-  category: Food
+  categories:
+  - Food
   icon:
     sprite: Objects/Consumable/Drinks/soymilk.rsi
     state: icon
   id: BioGenEthanol
   resultReagents:
     Ethanol: 10
-  category: Food
+  categories:
+  - Food
   icon:
     sprite: Objects/Consumable/Drinks/glass_clear.rsi
     state: icon
   id: BioGenCream
   resultReagents:
     Cream: 10
-  category: Food
+  categories:
+  - Food
   icon:
     sprite: Objects/Consumable/Drinks/cream.rsi
     state: icon
   id: BioGenBlackpepper
   resultReagents:
     Blackpepper: 10
-  category: Food
+  categories:
+  - Food
   icon:
     sprite: Objects/Consumable/Food/condiments.rsi
     state: packet-pepper
   id: BioGenEnzyme
   resultReagents:
     Enzyme: 10
-  category: Food
+  categories:
+  - Food
   icon:
     sprite: Objects/Consumable/Food/condiments.rsi
     state: bottle-empty
   id: BioGenFlour
   resultReagents:
     Flour: 10
-  category: Food
+  categories:
+  - Food
   icon:
     sprite: Objects/Consumable/Food/ingredients.rsi
     state: flour-big
   id: BioGenSugar
   resultReagents:
     Sugar: 10
-  category: Food
+  categories:
+  - Food
   icon:
     sprite: Objects/Consumable/Food/ingredients.rsi
     state: sugar-big
index 5d7c649cdebadd23b8786691abd4d3f168e6c61e..21ec6773efe2d82208ec32e3e7a1c04174016945 100644 (file)
@@ -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
 - type: latheRecipe
   id: WeaponPistolCHIMP
   result: WeaponPistolCHIMP
-  category: Tools
+  categories:
+  - Tools
   completetime: 5
   materials:
     Steel: 500
 - type: latheRecipe
   id: WeaponGauntletGorilla
   result: WeaponGauntletGorilla
-  category: Tools
+  categories:
+  - Tools
   completetime: 5
   materials:
     Steel: 1500
 - type: latheRecipe
   id: WeaponForceGun
   result: WeaponForceGun
-  category: Tools
+  categories:
+  - Tools
   completetime: 5
   materials:
     Steel: 500
 - type: latheRecipe
   id: WeaponProtoKineticAccelerator
   result: WeaponProtoKineticAccelerator
-  category: Weapons
+  categories:
+  - Weapons
   completetime: 5
   materials:
     Steel: 1000
 - type: latheRecipe
   id: WeaponTetherGun
   result: WeaponTetherGun
-  category: Tools
+  categories:
+  - Tools
   completetime: 5
   materials:
     Steel: 500
 - type: latheRecipe
   id: WeaponGrapplingGun
   result: WeaponGrapplingGun
-  category: Tools
+  categories:
+  - Tools
   completetime: 5
   materials:
     Steel: 500
index 5e51dec195aa437a4f856d0fddb2fd59ee6ef700..f6f56ab282dfe431a88d5a169afdd1521668928f 100644 (file)
@@ -3,7 +3,8 @@
 - type: latheRecipe
   abstract: true
   id: BaseElectronicsRecipe
-  category: Circuitry
+  categories:
+  - Circuitry
   completetime: 2
   materials:
     Steel: 100
index db7443256cd3c1c69bd48ddf515ac49f37cfe257..52d68e7c391bc5ef6d792c9e47d2040bdb454eaf 100644 (file)
@@ -3,7 +3,8 @@
 - type: latheRecipe
   abstract: true
   id: BaseMechPartRecipe
-  category: Mech
+  categories:
+  - Mech
   completetime: 10
 
 # Recipes
index 08250290ec780c09327f9db7993684003fb9eca3..f09babc770beaa898f824f0658af9d05273af4c1 100644 (file)
@@ -75,7 +75,8 @@
 - type: latheRecipe
   id: HandheldHealthAnalyzer
   result: HandheldHealthAnalyzerEmpty
-  category: Tools
+  categories:
+  - Tools
   completetime: 4
   materials:
     Glass: 500
index b1e8cee32ded7303c86708524b798385334abb71..d0a9b586c058f4694d2790a58396f9b025bbebdd 100644 (file)
@@ -3,7 +3,8 @@
 - type: latheRecipe
   abstract: true
   id: BaseLightRecipe
-  category: Lights
+  categories:
+  - Lights
   completetime: 2
   materials:
     Steel: 50
index 82c7b96affa97202dee8e66ebd2f1389c36f7537..3b9270201db842b44139d3fb5d926526cd0b1591 100644 (file)
@@ -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
index a4413e01ebee1173986771d5475eafae0bb0ea4c..60b762c1f1adc0dc6fbb822df0f59d14f55758da 100644 (file)
@@ -3,7 +3,8 @@
 - type: latheRecipe
   abstract: true
   id: BaseRoboticsRecipe
-  category: Robotics
+  categories:
+  - Robotics
   completetime: 2
 
 - type: latheRecipe
index 4cf9b9073ce23a8eb576ffef6f45c9435f47ba1b..02eeb4bafb851ef77c7d86f2d2a37ab10cb2cb0e 100644 (file)
@@ -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
index c72701711b70881322c04b20d5607e8ecff25265..725b785dd78c781dd2632cccef9e26a4d5979665 100644 (file)
@@ -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
index fc35153317e7b1a58cbed351b5a09c5caedeb61e..8a8c88d1e6c82355ce4d8ba76dea153490f71756 100644 (file)
@@ -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