Moves lists off cooking machines

Moves the lists for recipes, reagents, and ingredients off of the
individual machines to a shared global list.
This commit is contained in:
FalseIncarnate
2018-03-18 00:42:47 -04:00
parent 6b66eb4794
commit d7f89ed25f
8 changed files with 47 additions and 34 deletions
+5
View File
@@ -5,3 +5,8 @@
#define CAT_FOOD "Food"
#define CAT_MISC "Misc"
#define CAT_PRIMAL "Tribal"
#define RECIPE_MICROWAVE "Microwave"
#define RECIPE_OVEN "Oven"
#define RECIPE_GRILL "Grill"
#define RECIPE_CANDY "Candy"
+10
View File
@@ -30,3 +30,13 @@ var/list/round_end_sounds = list( // Maps available round end sounds to their du
'sound/goonstation/misc/newround1.ogg' = 6.9 SECONDS,
'sound/goonstation/misc/newround2.ogg' = 14.8 SECONDS
)
var/list/cooking_recipe_types = list(
RECIPE_MICROWAVE = /datum/recipe/microwave,
RECIPE_OVEN = /datum/recipe/oven,
RECIPE_GRILL = /datum/recipe/grill,
RECIPE_CANDY = /datum/recipe/candy
)
var/list/cooking_recipes = list(RECIPE_MICROWAVE = list(), RECIPE_OVEN = list(), RECIPE_GRILL = list(), RECIPE_CANDY = list())
var/list/cooking_ingredients = list(RECIPE_MICROWAVE = list(), RECIPE_OVEN = list(), RECIPE_GRILL = list(), RECIPE_CANDY = list())
var/list/cooking_reagents = list(RECIPE_MICROWAVE = list(), RECIPE_OVEN = list(), RECIPE_GRILL = list(), RECIPE_CANDY = list())
+6 -6
View File
@@ -95,16 +95,16 @@
container.reagents.clear_reagents()
return result_obj
/proc/select_recipe(list/datum/recipe/avaiable_recipes, obj/obj, exact = 1 as num)
/proc/select_recipe(list/datum/recipe/available_recipes, obj/obj, exact = 1 as num)
if(!exact)
exact = -1
var/list/datum/recipe/possible_recipes = new
for(var/datum/recipe/recipe in avaiable_recipes)
if(recipe.check_reagents(obj.reagents)==exact && recipe.check_items(obj)==exact)
possible_recipes+=recipe
if(possible_recipes.len==0)
for(var/datum/recipe/recipe in available_recipes)
if(recipe.check_reagents(obj.reagents) == exact && recipe.check_items(obj) == exact)
possible_recipes += recipe
if(possible_recipes.len == 0)
return null
else if(possible_recipes.len==1)
else if(possible_recipes.len == 1)
return possible_recipes[1]
else //okay, let's select the most complicated recipe
var/r_count = 0
@@ -5,7 +5,7 @@
icon = 'icons/obj/cooking_machines.dmi'
icon_state = "candymaker_off"
cook_verbs = list("Wonderizing", "Scrumpdiddlyumptiousification", "Miracle-coating", "Flavorifaction")
recipe_type = /datum/recipe/candy
recipe_type = RECIPE_CANDY
off_icon = "candymaker_off"
on_icon = "candymaker_on"
broken_icon = "candymaker_broke"
@@ -5,7 +5,7 @@
icon = 'icons/obj/cooking_machines.dmi'
icon_state = "grill_off"
cook_verbs = list("Grilling", "Searing", "Frying")
recipe_type = /datum/recipe/grill
recipe_type = RECIPE_GRILL
off_icon = "grill_off"
on_icon = "grill_on"
broken_icon = "grill_broke"
@@ -16,10 +16,7 @@
var/list/cook_verbs = list("Cooking")
//Recipe & Item vars
var/recipe_type //Make sure to set this on the machine definition, or else you're gonna runtime on New()
var/list/datum/recipe/available_recipes // List of the recipes you can use
var/list/acceptable_items // List of the items you can put in
var/list/acceptable_reagents // List of the reagents you can put in
var/max_n_of_items = 0
var/max_n_of_items = 25
//Icon states
var/off_icon
var/on_icon
@@ -34,23 +31,24 @@
/obj/machinery/kitchen_machine/New()
create_reagents(100)
reagents.set_reacting(FALSE)
if(!available_recipes)
available_recipes = new
acceptable_items = new
acceptable_reagents = new
for(var/type in subtypesof(recipe_type))
var/datum/recipe/recipe = new type
if(recipe.result) // Ignore recipe subtypes that lack a result
available_recipes += recipe
for(var/item in recipe.items)
acceptable_items |= item
for(var/reagent in recipe.reagents)
acceptable_reagents |= reagent
if(recipe.items)
max_n_of_items = max(max_n_of_items,recipe.count_n_items())
else
qdel(recipe)
acceptable_items |= /obj/item/weapon/reagent_containers/food/snacks/grown
if(!cooking_recipes[recipe_type])
cooking_recipes[recipe_type] = list()
cooking_ingredients[recipe_type] = list()
cooking_reagents[recipe_type] = list()
for(var/type in subtypesof(cooking_recipe_types[recipe_type]))
var/datum/recipe/recipe = new type
if(recipe in cooking_recipes[recipe_type])
qdel(recipe)
continue
if(recipe.result) // Ignore recipe subtypes that lack a result
cooking_recipes[recipe_type] += recipe
for(var/item in recipe.items)
cooking_ingredients[recipe_type] |= item
for(var/reagent in recipe.reagents)
cooking_reagents[recipe_type] |= reagent
else
qdel(recipe)
cooking_ingredients[recipe_type] |= /obj/item/weapon/reagent_containers/food/snacks/grown
/*******************
* Item Adding
@@ -124,7 +122,7 @@
else //Otherwise bad luck!!
to_chat(user, "<span class='alert'>It's dirty!</span>")
return 1
else if(is_type_in_list(O,acceptable_items))
else if(is_type_in_list(O, cooking_ingredients[recipe_type]))
if(contents.len>=max_n_of_items)
to_chat(user, "<span class='alert'>This [src] is full of ingredients, you cannot put more.</span>")
return 1
@@ -150,7 +148,7 @@
if(!O.reagents)
return 1
for(var/datum/reagent/R in O.reagents.reagent_list)
if(!(R.id in acceptable_reagents))
if(!(R.id in cooking_reagents[recipe_type]))
to_chat(user, "<span class='alert'>Your [O] contains components unsuitable for cookery.</span>")
return 1
//G.reagents.trans_to(src,G.amount_per_transfer_from_this)
@@ -259,7 +257,7 @@
stop()
return
var/datum/recipe/recipe = select_recipe(available_recipes,src)
var/datum/recipe/recipe = select_recipe(cooking_recipes[recipe_type], src)
var/obj/cooked
var/obj/byproduct
if(!recipe)
@@ -5,7 +5,7 @@
icon = 'icons/obj/kitchen.dmi'
icon_state = "mw"
cook_verbs = list("Microwaving", "Reheating", "Heating")
recipe_type = /datum/recipe/microwave
recipe_type = RECIPE_MICROWAVE
off_icon = "mw"
on_icon = "mw1"
broken_icon = "mwb"
@@ -5,7 +5,7 @@
icon = 'icons/obj/cooking_machines.dmi'
icon_state = "oven_off"
cook_verbs = list("Baking", "Roasting", "Broiling")
recipe_type = /datum/recipe/oven
recipe_type = RECIPE_OVEN
off_icon = "oven_off"
on_icon = "oven_on"
broken_icon = "oven_broke"