Multiple categories for lathe recipes (#34315)

* first

* lint

* changes

* change null comparison

* linq

* indent

* fix indent

---------

Co-authored-by: Milon <milonpl.git@proton.me>
This commit is contained in:
āda
2025-02-27 05:33:39 -06:00
committed by GitHub
parent 53dc27cb1e
commit 3127f73c48
14 changed files with 115 additions and 55 deletions

View 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)))

View 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();
}
}

View File

@@ -2,7 +2,8 @@
- type: latheRecipe
abstract: true
id: BasePartRecipe
category: Parts
categories:
- Parts
completetime: 2
materials:
Steel: 300

View 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
@@ -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

View 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
@@ -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

View File

@@ -3,7 +3,8 @@
- type: latheRecipe
abstract: true
id: BaseElectronicsRecipe
category: Circuitry
categories:
- Circuitry
completetime: 2
materials:
Steel: 100

View File

@@ -3,7 +3,8 @@
- type: latheRecipe
abstract: true
id: BaseMechPartRecipe
category: Mech
categories:
- Mech
completetime: 10
# Recipes

View File

@@ -75,7 +75,8 @@
- type: latheRecipe
id: HandheldHealthAnalyzer
result: HandheldHealthAnalyzerEmpty
category: Tools
categories:
- Tools
completetime: 4
materials:
Glass: 500

View File

@@ -3,7 +3,8 @@
- type: latheRecipe
abstract: true
id: BaseLightRecipe
category: Lights
categories:
- Lights
completetime: 2
materials:
Steel: 50

View 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

View File

@@ -3,7 +3,8 @@
- type: latheRecipe
abstract: true
id: BaseRoboticsRecipe
category: Robotics
categories:
- Robotics
completetime: 2
- type: latheRecipe

View 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

View 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

View 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