Skip to content

Commit

Permalink
Move recipe categories to generic_factory
Browse files Browse the repository at this point in the history
To enable using copy-from to extend recipe subcategories, so mods that
touch the same ones don't overwrite.
  • Loading branch information
anothersimulacrum committed Jun 21, 2024
1 parent 4e4ec04 commit 5ec4c0b
Show file tree
Hide file tree
Showing 18 changed files with 158 additions and 139 deletions.
3 changes: 3 additions & 0 deletions data/json/recipes/recipes.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"type": "recipe_category",
"id": "CC_*",
"//": "This is just a dummy category. No recipes should be added in here.",
"is_wildcard": true,
"recipe_subcategories": [ "CSC_*_FAVORITE", "CSC_*_RECENT", "CSC_*_HIDDEN", "CSC_*_NESTED" ]
},
{
Expand Down Expand Up @@ -125,11 +126,13 @@
"type": "recipe_category",
"id": "CC_BUILDING",
"recipe_subcategories": [ "CSC_ALL", "CSC_BUILDING_BASES", "CSC_BUILDING_EXPANSIONS" ],
"is_building": true,
"is_hidden": true
},
{
"type": "recipe_category",
"id": "CC_PRACTICE",
"is_practice": true,
"recipe_subcategories": [
"CSC_ALL",
"CSC_PRACTICE_SCIENCE",
Expand Down
31 changes: 4 additions & 27 deletions data/mods/Aftershock/recipes/recipes_categories.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,13 @@
{
"type": "recipe_category",
"id": "CC_ELECTRONIC",
"recipe_subcategories": [
"CSC_ALL",
"CSC_ELECTRONIC_CBMS",
"CSC_ELECTRONIC_TOOLS",
"CSC_ELECTRONIC_PARTS",
"CSC_ELECTRONIC_LIGHTING",
"CSC_ELECTRONIC_COMPONENTS",
"CSC_ELECTRONIC_OTHER"
]
"copy-from": "CC_ELECTRONIC",
"extend": { "recipe_subcategories": [ "CSC_ELECTRONIC_CBMS" ] }
},
{
"type": "recipe_category",
"id": "CC_PRACTICE",
"recipe_subcategories": [
"CSC_ALL",
"CSC_PRACTICE_SCIENCE",
"CSC_PRACTICE_ELECTRONICS",
"CSC_PRACTICE_FABRICATION",
"CSC_PRACTICE_FOOD",
"CSC_PRACTICE_SURVIVAL",
"CSC_PRACTICE_TAILORING",
"CSC_PRACTICE_ATHLETICS",
"CSC_PRACTICE_COMPUTERS",
"CSC_PRACTICE_DEVICES",
"CSC_PRACTICE_HEALTH",
"CSC_PRACTICE_MECHANICS",
"CSC_PRACTICE_SOCIAL",
"CSC_PRACTICE_MELEE",
"CSC_PRACTICE_RANGED",
"CSC_PRACTICE_PSI"
]
"copy-from": "CC_PRACTICE",
"extend": { "recipe_subcategories": [ "CSC_PRACTICE_PSI" ] }
}
]
12 changes: 2 additions & 10 deletions data/mods/DinoMod/recipes/recipes.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,7 @@
{
"type": "recipe_category",
"id": "CC_ANIMALS",
"recipe_subcategories": [
"CSC_ALL",
"CSC_ANIMALS_BOVINE ARMOR",
"CSC_ANIMALS_CANINE ARMOR",
"CSC_ANIMALS_EQUINE ARMOR",
"CSC_ANIMALS_ELEPHANT ARMOR",
"CSC_ANIMALS_OSTRICH ARMOR",
"CSC_ANIMALS_BEAR ARMOR",
"CSC_ANIMALS_EQUINE STORAGE"
]
"copy-from": "CC_ANIMALS",
"extend": { "recipe_subcategories": [ "CSC_ANIMALS_ELEPHANT ARMOR", "CSC_ANIMALS_OSTRICH ARMOR", "CSC_ANIMALS_BEAR ARMOR" ] }
}
]
20 changes: 2 additions & 18 deletions data/mods/MindOverMatter/recipes/psionics_practice.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,8 @@
{
"type": "recipe_category",
"id": "CC_PRACTICE",
"recipe_subcategories": [
"CSC_ALL",
"CSC_PRACTICE_SCIENCE",
"CSC_PRACTICE_ELECTRONICS",
"CSC_PRACTICE_FABRICATION",
"CSC_PRACTICE_FOOD",
"CSC_PRACTICE_SURVIVAL",
"CSC_PRACTICE_TAILORING",
"CSC_PRACTICE_ATHLETICS",
"CSC_PRACTICE_COMPUTERS",
"CSC_PRACTICE_DEVICES",
"CSC_PRACTICE_HEALTH",
"CSC_PRACTICE_MECHANICS",
"CSC_PRACTICE_SOCIAL",
"CSC_PRACTICE_MELEE",
"CSC_PRACTICE_RANGED",
"CSC_PRACTICE_METAPHYSICS"
]
"copy-from": "CC_PRACTICE",
"extend": { "recipe_subcategories": [ "CSC_PRACTICE_METAPHYSICS" ] }
},
{
"id": "prac_psionics_begin",
Expand Down
3 changes: 2 additions & 1 deletion src/activity_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "contents_change_handler.h"
#include "coordinates.h"
#include "craft_command.h"
#include "crafting_gui.h"
#include "creature.h"
#include "creature_tracker.h"
#include "debug.h"
Expand Down Expand Up @@ -3768,7 +3769,7 @@ void craft_activity_actor::canceled( player_activity &/*act*/, Character &/*who*
}
const recipe item_recipe = craft->get_making();
// practice recipe items with no components can be safely removed
if( item_recipe.category == "CC_PRACTICE" && craft->components.empty() ) {
if( item_recipe.category->is_practice && craft->components.empty() ) {
craft_item.remove_item();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/crafting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ static bool crafting_allowed( const Character &p, const recipe &rec )
return false;
}

if( rec.category == "CC_BUILDING" ) {
if( rec.category->is_building ) {
add_msg( m_info, _( "Overmap terrain building recipes are not implemented yet!" ) );
return false;
}
Expand Down
Loading

0 comments on commit 5ec4c0b

Please sign in to comment.