Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple categories for lathe recipes #34315

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions Content.Client/Lathe/UI/LatheMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,23 @@ public void PopulateRecipes()
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;

bool validRecipe = false;
foreach (var category in proto.Categories)
if (category == CurrentCategory)
{
validRecipe = true;
break;
}

if (!validRecipe)
continue;
}

if (SearchBar.Text.Trim().Length != 0)
{
Expand Down Expand Up @@ -179,18 +194,22 @@ private string GenerateTooltipText(LatheRecipePrototype prototype)

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)))
Expand Down
4 changes: 2 additions & 2 deletions Content.Shared/Research/Prototypes/LatheRecipePrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ public sealed partial class LatheRecipePrototype : IPrototype, IInheritingProtot
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();
}
}
3 changes: 2 additions & 1 deletion Resources/Prototypes/Recipes/Lathes/Parts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
- type: latheRecipe
abstract: true
id: BasePartRecipe
category: Parts
categories:
- Parts
completetime: 2
materials:
Steel: 300
Expand Down
63 changes: 42 additions & 21 deletions Resources/Prototypes/Recipes/Lathes/biogen.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
- type: latheRecipe
id: BioGenMonkeyCube
result: MonkeyCube
category: Food
categories:
- Food
completetime: 3
materials:
Biomass: 70

- type: latheRecipe
id: BioGenKoboldCube
result: KoboldCube
category: Food
categories:
- Food
completetime: 3
materials:
Biomass: 70

- type: latheRecipe
id: BioGenMaterialCloth1
result: MaterialCloth1
category: Materials
categories:
- Materials
icon:
sprite: Objects/Materials/materials.rsi
state: cloth
Expand All @@ -28,7 +31,8 @@
- type: latheRecipe
id: BioGenMaterialCardboard1
result: MaterialCardboard1
category: Materials
categories:
- Materials
icon:
sprite: Objects/Materials/materials.rsi
state: cardboard
Expand All @@ -39,23 +43,26 @@
- type: latheRecipe
id: BioGenPaper
result: Paper
category: Materials
categories:
- Materials
completetime: 1
materials:
Biomass: 2

- type: latheRecipe
id: BioGenPaperRolling1
result: PaperRolling1
category: Materials
categories:
- Materials
completetime: 1
materials:
Biomass: 1

- type: latheRecipe
id: BioGenCandle
result: Candle
category: Materials
categories:
- Materials
completetime: 3
materials:
Biomass: 3
Expand All @@ -64,7 +71,8 @@
id: BioGenPlantBGone
resultReagents:
PlantBGone: 10
category: Chemicals
categories:
- Chemicals
icon:
sprite: Objects/Tools/Hydroponics/sprays.rsi
state: plantbgone
Expand All @@ -76,7 +84,8 @@
id: BioGenWeedKiller
resultReagents:
WeedKiller: 10
category: Chemicals
categories:
- Chemicals
icon:
sprite: Objects/Tools/Hydroponics/sprays.rsi
state: weedspray
Expand All @@ -88,7 +97,8 @@
id: BioGenPestKiller
resultReagents:
PestKiller: 10
category: Chemicals
categories:
- Chemicals
icon:
sprite: Objects/Tools/Hydroponics/sprays.rsi
state: weedspray
Expand All @@ -100,7 +110,8 @@
id: BioGenLeft4Zed
resultReagents:
Left4Zed: 10
category: Chemicals
categories:
- Chemicals
icon:
sprite: Objects/Specific/Chemistry/bottle.rsi
state: bottle-1
Expand All @@ -112,7 +123,8 @@
id: BioGenEZNutrient
resultReagents:
EZNutrient: 10
category: Chemicals
categories:
- Chemicals
icon:
sprite: Objects/Specific/Chemistry/bottle.rsi
state: bottle-1
Expand All @@ -124,7 +136,8 @@
id: BioGenRobustHarvest
resultReagents:
RobustHarvest: 10
category: Chemicals
categories:
- Chemicals
icon:
sprite: Objects/Specific/Chemistry/bottle.rsi
state: bottle-1
Expand All @@ -136,7 +149,8 @@
id: BioGenMilk
resultReagents:
Milk: 10
category: Food
categories:
- Food
icon:
sprite: Objects/Consumable/Drinks/milk.rsi
state: icon
Expand All @@ -148,7 +162,8 @@
id: BioGenMilkSoy
resultReagents:
MilkSoy: 10
category: Food
categories:
- Food
icon:
sprite: Objects/Consumable/Drinks/soymilk.rsi
state: icon
Expand All @@ -160,7 +175,8 @@
id: BioGenEthanol
resultReagents:
Ethanol: 10
category: Food
categories:
- Food
icon:
sprite: Objects/Consumable/Drinks/glass_clear.rsi
state: icon
Expand All @@ -172,7 +188,8 @@
id: BioGenCream
resultReagents:
Cream: 10
category: Food
categories:
- Food
icon:
sprite: Objects/Consumable/Drinks/cream.rsi
state: icon
Expand All @@ -184,7 +201,8 @@
id: BioGenBlackpepper
resultReagents:
Blackpepper: 10
category: Food
categories:
- Food
icon:
sprite: Objects/Consumable/Food/condiments.rsi
state: packet-pepper
Expand All @@ -196,7 +214,8 @@
id: BioGenEnzyme
resultReagents:
Enzyme: 10
category: Food
categories:
- Food
icon:
sprite: Objects/Consumable/Food/condiments.rsi
state: bottle-empty
Expand All @@ -208,7 +227,8 @@
id: BioGenFlour
resultReagents:
Flour: 10
category: Food
categories:
- Food
icon:
sprite: Objects/Consumable/Food/ingredients.rsi
state: flour-big
Expand All @@ -220,7 +240,8 @@
id: BioGenSugar
resultReagents:
Sugar: 10
category: Food
categories:
- Food
icon:
sprite: Objects/Consumable/Food/ingredients.rsi
state: sugar-big
Expand Down
27 changes: 18 additions & 9 deletions Resources/Prototypes/Recipes/Lathes/devices.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
- type: latheRecipe
id: ExplosivePayload
result: ExplosivePayload
category: Weapons
categories:
- Weapons
completetime: 4
materials:
Steel: 100
Expand Down Expand Up @@ -73,7 +74,8 @@
- type: latheRecipe
id: AnomalyLocator
result: AnomalyLocatorEmpty
category: Tools
categories:
- Tools
completetime: 3
materials:
Steel: 400
Expand All @@ -82,7 +84,8 @@
- type: latheRecipe
id: AnomalyLocatorWide
result: AnomalyLocatorWideEmpty
category: Tools
categories:
- Tools
completetime: 3
materials:
Steel: 400
Expand All @@ -99,7 +102,8 @@
- type: latheRecipe
id: WeaponPistolCHIMP
result: WeaponPistolCHIMP
category: Tools
categories:
- Tools
completetime: 5
materials:
Steel: 500
Expand All @@ -108,7 +112,8 @@
- type: latheRecipe
id: WeaponGauntletGorilla
result: WeaponGauntletGorilla
category: Tools
categories:
- Tools
completetime: 5
materials:
Steel: 1500
Expand Down Expand Up @@ -153,7 +158,8 @@
- type: latheRecipe
id: WeaponForceGun
result: WeaponForceGun
category: Tools
categories:
- Tools
completetime: 5
materials:
Steel: 500
Expand All @@ -172,7 +178,8 @@
- type: latheRecipe
id: WeaponProtoKineticAccelerator
result: WeaponProtoKineticAccelerator
category: Weapons
categories:
- Weapons
completetime: 5
materials:
Steel: 1000
Expand All @@ -182,7 +189,8 @@
- type: latheRecipe
id: WeaponTetherGun
result: WeaponTetherGun
category: Tools
categories:
- Tools
completetime: 5
materials:
Steel: 500
Expand All @@ -192,7 +200,8 @@
- type: latheRecipe
id: WeaponGrapplingGun
result: WeaponGrapplingGun
category: Tools
categories:
- Tools
completetime: 5
materials:
Steel: 500
Expand Down
3 changes: 2 additions & 1 deletion Resources/Prototypes/Recipes/Lathes/electronics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
- type: latheRecipe
abstract: true
id: BaseElectronicsRecipe
category: Circuitry
categories:
- Circuitry
completetime: 2
materials:
Steel: 100
Expand Down
3 changes: 2 additions & 1 deletion Resources/Prototypes/Recipes/Lathes/mech_parts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
- type: latheRecipe
abstract: true
id: BaseMechPartRecipe
category: Mech
categories:
- Mech
completetime: 10

# Recipes
Expand Down
Loading
Loading