|
1 | 1 | // This folder contains code that was originally ported from Apollo Station and then refactored/optimized/changed.
|
2 | 2 |
|
3 | 3 | // Tracks precooked food to stop deep fried baked grilled grilled grilled diona nymph cereal.
|
4 |
| -/obj/item/weapon/reagent_containers/food/snacks/var/list/cooked = list() |
| 4 | +/obj/item/weapon/reagent_containers/food/snacks |
| 5 | + var/tmp/list/cooked = list() |
5 | 6 |
|
6 | 7 | // Root type for cooking machines. See following files for specific implementations.
|
7 | 8 | /obj/machinery/appliance
|
|
16 | 17 | idle_power_usage = 5 // Power used when turned on, but not processing anything
|
17 | 18 | active_power_usage = 1000 // Power used when turned on and actively cooking something
|
18 | 19 |
|
19 |
| - |
20 | 20 | var/cooking_power = 1
|
21 | 21 | var/max_contents = 1 // Maximum number of things this appliance can simultaneously cook
|
22 | 22 | var/on_icon // Icon state used when cooking.
|
|
34 | 34 | // If the machine has multiple output modes, define them here.
|
35 | 35 | var/selected_option
|
36 | 36 | var/list/output_options = list()
|
37 |
| - var/list/datum/recipe/available_recipes // List of the recipes this appliance could possibly make |
38 | 37 |
|
39 | 38 | var/container_type = null
|
40 | 39 |
|
|
45 | 44 | if(output_options.len)
|
46 | 45 | verbs += /obj/machinery/appliance/proc/choose_output
|
47 | 46 |
|
48 |
| - if (!available_recipes) |
49 |
| - available_recipes = new |
50 |
| - |
51 |
| - for (var/type in subtypesof(/datum/recipe)) |
52 |
| - var/datum/recipe/test = new type |
53 |
| - if ((appliancetype & test.appliance)) |
54 |
| - available_recipes += test |
55 |
| - else |
56 |
| - qdel(test) |
57 |
| - |
58 | 47 | /obj/machinery/appliance/Destroy()
|
59 | 48 | for (var/a in cooking_objs)
|
60 | 49 | var/datum/cooking_item/CI = a
|
|
111 | 100 |
|
112 | 101 | /obj/machinery/appliance/verb/toggle_power()
|
113 | 102 | set name = "Toggle Power"
|
114 |
| - set category = null |
115 |
| - set src in view() //So that AI can operate it remotely |
| 103 | + set category = "Object" |
| 104 | + set src in view() |
116 | 105 |
|
117 |
| - if (!isliving(usr)) |
118 |
| - usr << "Ghosts aren't allowed to toggle power switches" |
| 106 | + attempt_toggle_power(usr) |
| 107 | + |
| 108 | +/obj/machinery/appliance/proc/attempt_toggle_power(mob/user) |
| 109 | + if (!isliving(user)) |
119 | 110 | return
|
120 | 111 |
|
121 |
| - if (isanimal(usr)) |
122 |
| - usr << "You lack the dexterity to do that!" |
| 112 | + if (!user.IsAdvancedToolUser()) |
| 113 | + user << "You lack the dexterity to do that!" |
123 | 114 | return
|
124 | 115 |
|
125 |
| - if (usr.stat || usr.restrained() || usr.incapacitated()) |
| 116 | + if (user.stat || user.restrained() || user.incapacitated()) |
126 | 117 | return
|
127 | 118 |
|
128 |
| - if (!Adjacent(usr)) |
129 |
| - if (!issilicon(usr)) |
130 |
| - usr << "You can't reach the power switch from there, get closer!" |
131 |
| - return |
| 119 | + if (!Adjacent(user) && !issilicon(user)) |
| 120 | + user << "You can't reach [src] from here." |
| 121 | + return |
132 | 122 |
|
133 | 123 | if (stat & POWEROFF)//Its turned off
|
134 | 124 | stat &= ~POWEROFF
|
135 | 125 | use_power = 1
|
136 |
| - if (usr) |
137 |
| - usr.visible_message("[usr] turns the [src] on", "You turn on the [src]") |
| 126 | + user.visible_message("[user] turns [src] on.", "You turn on [src].") |
| 127 | + |
138 | 128 | else //Its on, turn it off
|
139 | 129 | stat |= POWEROFF
|
140 | 130 | use_power = 0
|
141 |
| - if (usr) |
142 |
| - usr.visible_message("[usr] turns the [src] off", "You turn off the [src]") |
| 131 | + user.visible_message("[user] turns [src] off.", "You turn off [src].") |
143 | 132 |
|
144 | 133 | playsound(src, 'sound/machines/click.ogg', 40, 1)
|
145 | 134 | update_icon()
|
146 | 135 |
|
147 |
| -/obj/machinery/appliance/AICtrlClick() |
148 |
| - toggle_power() |
| 136 | +/obj/machinery/appliance/AICtrlClick(mob/user) |
| 137 | + attempt_toggle_power(user) |
149 | 138 |
|
150 | 139 | /obj/machinery/appliance/proc/choose_output()
|
151 | 140 | set src in view()
|
152 | 141 | set name = "Choose output"
|
153 |
| - set category = null |
| 142 | + set category = "Object" |
154 | 143 |
|
155 | 144 | if (!isliving(usr))
|
156 |
| - usr << "Ghosts aren't allowed to mess with cooking machines!" |
157 | 145 | return
|
158 | 146 |
|
159 |
| - if (isanimal(usr)) |
| 147 | + if (!usr.IsAdvancedToolUser()) |
160 | 148 | usr << "You lack the dexterity to do that!"
|
161 | 149 | return
|
162 | 150 |
|
163 | 151 | if (usr.stat || usr.restrained() || usr.incapacitated())
|
164 | 152 | return
|
165 | 153 |
|
166 |
| - if (!Adjacent(usr)) |
167 |
| - if (!issilicon(usr)) |
168 |
| - usr << "You can't adjust the [src] from this distance, get closer!" |
169 |
| - return |
| 154 | + if (!Adjacent(usr) && !issilicon(usr)) |
| 155 | + usr << "You can't adjust the [src] from this distance, get closer!" |
| 156 | + return |
170 | 157 |
|
171 | 158 | if(output_options.len)
|
172 |
| - |
173 | 159 | var/choice = input("What specific food do you wish to make with \the [src]?") as null|anything in output_options+"Default"
|
174 | 160 | if(!choice)
|
175 | 161 | return
|
|
217 | 203 | user << "<span class='warning'>That would probably break [src].</span>"
|
218 | 204 | return 0
|
219 | 205 | else if(istype(check, /obj/item/weapon/disk/nuclear))
|
220 |
| - user << "Central Command would kill you if you [cook_type] that." |
| 206 | + user << "<span class='warning'>You can't cook that.</span>" |
221 | 207 | return 0
|
222 | 208 | else if(!istype(check) && !istype(check, /obj/item/weapon/holder))
|
223 | 209 | user << "<span class='warning'>That's not edible.</span>"
|
|
238 | 224 | user << "<span class='warning'>\The [src] is not working.</span>"
|
239 | 225 | return
|
240 | 226 |
|
241 |
| - |
242 |
| - |
243 | 227 | var/result = can_insert(I, user)
|
244 | 228 | if (!result)
|
245 | 229 | return
|
|
250 | 234 | cook_mob(G.affecting, user)
|
251 | 235 | return
|
252 | 236 |
|
253 |
| - |
254 | 237 | //From here we can start cooking food
|
255 | 238 | add_content(I, user)
|
256 |
| - |
257 |
| - |
258 | 239 | update_icon()
|
259 | 240 |
|
260 |
| - |
261 |
| - |
262 |
| - |
263 |
| - |
264 |
| - |
265 | 241 | //Override for container mechanics
|
266 | 242 | /obj/machinery/appliance/proc/add_content(var/obj/item/I, var/mob/user)
|
267 | 243 | if(!user.unEquip(I))
|
|
286 | 262 | if (selected_option)
|
287 | 263 | CI.combine_target = selected_option
|
288 | 264 |
|
289 |
| - |
290 | 265 | // We can actually start cooking now.
|
291 | 266 | user.visible_message("<span class='notice'>\The [user] puts \the [I] into \the [src].</span>")
|
292 | 267 |
|
|
348 | 323 |
|
349 | 324 | CI.max_cookwork += work
|
350 | 325 |
|
351 |
| - |
352 | 326 | //Called every tick while we're cooking something
|
353 | 327 | /obj/machinery/appliance/proc/do_cooking_tick(var/datum/cooking_item/CI)
|
354 | 328 | if (!CI.max_cookwork)
|
|
381 | 355 | do_cooking_tick(i)
|
382 | 356 |
|
383 | 357 |
|
384 |
| - |
385 | 358 | /obj/machinery/appliance/proc/finish_cooking(var/datum/cooking_item/CI)
|
386 | 359 |
|
387 | 360 | src.visible_message("<span class='notice'>\The [src] pings!</span>")
|
|
394 | 367 | C = CI.container
|
395 | 368 | else
|
396 | 369 | C = src
|
397 |
| - recipe = select_recipe(available_recipes,C) |
| 370 | + recipe = select_recipe(RECIPE_LIST(appliancetype), C) |
398 | 371 |
|
399 | 372 | if (recipe)
|
400 | 373 | CI.result_type = 4//Recipe type, a specific recipe will transform the ingredients into a new food
|
|
406 | 379 | AM.loc = temp
|
407 | 380 |
|
408 | 381 | //making multiple copies of a recipe from one container. For example, tons of fries
|
409 |
| - while (select_recipe(available_recipes,C) == recipe) |
| 382 | + while (select_recipe(RECIPE_LIST(appliancetype), C) == recipe) |
410 | 383 | var/list/TR = list()
|
411 |
| - TR.Add(recipe.make_food(C)) |
| 384 | + TR += recipe.make_food(C) |
412 | 385 | for (var/atom/movable/AM in TR) //Move results to buffer
|
413 | 386 | AM.loc = temp
|
414 |
| - results.Add(TR) |
| 387 | + results += TR |
415 | 388 |
|
416 | 389 |
|
417 | 390 | for (var/r in results)
|
418 | 391 | var/obj/item/weapon/reagent_containers/food/snacks/R = r
|
419 | 392 | R.loc = C //Move everything from the buffer back to the container
|
420 |
| - R.cooked |= cook_type. |
| 393 | + R.cooked |= cook_type |
421 | 394 |
|
422 |
| - qdel(temp) //delete buffer object |
423 |
| - temp = null |
424 |
| - .=1 //None of the rest of this function is relevant for recipe cooking |
| 395 | + QDEL_NULL(temp) //delete buffer object |
| 396 | + . = 1 //None of the rest of this function is relevant for recipe cooking |
425 | 397 |
|
426 | 398 | else if(CI.combine_target)
|
427 | 399 | CI.result_type = 3//Combination type. We're making something out of our ingredients
|
428 |
| - .=combination_cook(CI) |
| 400 | + . = combination_cook(CI) |
429 | 401 |
|
430 | 402 |
|
431 | 403 | else
|
|
461 | 433 | words |= dd_text2List(S.name," ")
|
462 | 434 | cooktypes |= S.cooked
|
463 | 435 |
|
464 |
| - |
465 |
| - |
466 | 436 | if (S.reagents && S.reagents.total_volume > 0)
|
467 | 437 | if (S.filling_color)
|
468 | 438 | if (!totalcolour || !buffer.total_volume)
|
|
493 | 463 | result.filling_color = totalcolour
|
494 | 464 |
|
495 | 465 | //Set the name.
|
496 |
| - words.Remove(list("and", "the", "in", "is", "bar", "raw", "sticks", "boiled", "fried", "deep", "-o-", "warm", "two", "flavored")) |
| 466 | + words -= list("and", "the", "in", "is", "bar", "raw", "sticks", "boiled", "fried", "deep", "-o-", "warm", "two", "flavored") |
497 | 467 | //Remove common connecting words and unsuitable ones from the list. Unsuitable words include those describing
|
498 | 468 | //the shape, cooked-ness/temperature or other state of an ingredient which doesn't apply to the finished product
|
499 | 469 | words.Remove(result.name)
|
|
524 | 494 | if (!result)
|
525 | 495 | return
|
526 | 496 |
|
527 |
| - result.cooked |= cook_type. |
| 497 | + result.cooked |= cook_type |
528 | 498 |
|
529 | 499 | // Set icon and appearance.
|
530 | 500 | change_product_appearance(result, CI)
|
|
600 | 570 |
|
601 | 571 | /obj/machinery/appliance/proc/change_product_strings(var/obj/item/weapon/reagent_containers/food/snacks/product, var/datum/cooking_item/CI)
|
602 | 572 | product.name = "[cook_type] [product.name]"
|
603 |
| - product.desc = "[product.desc] It has been [cook_type]." |
| 573 | + product.desc = "[product.desc]\nIt has been [cook_type]." |
604 | 574 |
|
605 | 575 |
|
606 | 576 | /obj/machinery/appliance/proc/change_product_appearance(var/obj/item/weapon/reagent_containers/food/snacks/product, var/datum/cooking_item/CI)
|
607 | 577 | if (!product.coating) //Coatings change colour through a new sprite
|
608 | 578 | product.color = food_color
|
609 | 579 | product.filling_color = food_color
|
610 | 580 |
|
611 |
| - |
612 |
| - |
613 |
| - |
614 | 581 | //This function creates a food item which represents a dead mob
|
615 | 582 | /obj/machinery/appliance/proc/create_mob_food(var/obj/item/weapon/holder/H, var/datum/cooking_item/CI)
|
616 | 583 | if (!istype(H) || !H.contained)
|
|
649 | 616 |
|
650 | 617 | return result
|
651 | 618 |
|
652 |
| - |
653 | 619 | /datum/cooking_item
|
654 |
| - //var/obj/object |
655 | 620 | var/max_cookwork
|
656 | 621 | var/cookwork
|
657 | 622 | var/overcook_mult = 3
|
|
674 | 639 | /datum/cooking_item/New(var/obj/item/I)
|
675 | 640 | container = I
|
676 | 641 |
|
677 |
| - |
678 | 642 | //This is called for containers whose contents are ejected without removing the container
|
679 | 643 | /datum/cooking_item/proc/reset()
|
680 |
| - //object = null |
681 | 644 | max_cookwork = 0
|
682 | 645 | cookwork = 0
|
683 | 646 | result_type = 0
|
|
0 commit comments