diff --git a/code/game/machinery/kitchen/microwave.dm b/code/game/machinery/kitchen/microwave.dm
index 28d5c5d6164..1ce5253a154 100644
--- a/code/game/machinery/kitchen/microwave.dm
+++ b/code/game/machinery/kitchen/microwave.dm
@@ -1,6 +1,6 @@
-
/obj/machinery/microwave
- name = "Microwave"
+ name = "microwave"
+ desc = "A Getmore-brand microwave. It's seen better days. Below the oven door, a faded label warns to keep non-food items out, and to beware of choking."
icon = 'icons/obj/kitchen.dmi'
icon_state = "mw"
layer = 2.9
@@ -10,22 +10,39 @@
idle_power_usage = 5
active_power_usage = 2000
flags = OPENCONTAINER | NOREACT
- var/operating = 0 // Is it on?
+ var/operating = FALSE // Is it on?
var/dirty = 0 // = {0..100} Does it need cleaning?
var/broken = 0 // ={0,1,2} How broken is it???
var/global/list/acceptable_items // List of the items you can put in
var/global/list/acceptable_reagents // List of the reagents you can put in
var/global/max_n_of_items = 20
+ var/list/acceptable_containers = list(
+ /obj/item/weapon/reagent_containers/glass,
+ /obj/item/weapon/reagent_containers/food/drinks,
+ /obj/item/weapon/reagent_containers/food/condiment
+ )
var/appliancetype = MICROWAVE
var/datum/looping_sound/microwave/soundloop
+ var/datum/recipe/recipe
+
+ // These determine if the current cooking process failed, the vars above determine if the microwave is broken
+ var/cook_break = FALSE
+ var/cook_dirty = FALSE
+ var/abort = FALSE
+ var/failed = FALSE // pretty much exclusively for sending the fail state across to the UI, using recipe elsewhere is preferred
component_types = list(
- /obj/item/weapon/circuitboard/microwave,
+ /obj/item/weapon/circuitboard/microwave = 1,
/obj/item/weapon/stock_parts/capacitor = 3,
- /obj/item/weapon/stock_parts/scanning_module,
+ /obj/item/weapon/stock_parts/micro_laser = 1,
/obj/item/weapon/stock_parts/matter_bin = 2
)
+ var/cook_time = 400
+ var/start_time = 0
+ var/end_time = 0
+ var/cooking_power = 1
+
// see code/modules/food/recipes_microwave.dm for recipes
/*******************
@@ -42,6 +59,20 @@
else
setup_recipes()
+ if(component_parts)
+ component_parts.Cut()
+ else
+ component_parts = list()
+
+ for (var/type in component_types)
+ var/count = component_types[type]
+ for (var/i in 1 to count)
+ var/obj/t = new type
+ component_parts += t
+ t.forceMove(null)
+
+ RefreshParts()
+
/obj/machinery/microwave/proc/setup_recipes()
if (!LAZYLEN(acceptable_items))
acceptable_items = list()
@@ -63,9 +94,16 @@
* Item Adding
********************/
+/obj/machinery/microwave/proc/add_item(var/obj/item/I as obj, var/mob/user as mob)
+ user.drop_from_inventory(I, src)
+ user.visible_message( \
+ "\The [user] has added one of [I] to \the [src].", \
+ "You add one of [I] to \the [src].")
+ SSvueui.check_uis_for_change(src)
+
/obj/machinery/microwave/attackby(var/obj/item/O as obj, var/mob/user as mob)
- if(src.broken > 0)
- if(src.broken == 2 && O.isscrewdriver()) // If it's broken and they're using a screwdriver
+ if(broken > 0)
+ if(broken == 2 && O.isscrewdriver()) // If it's broken and they're using a screwdriver
user.visible_message( \
"\The [user] starts to fix part of the microwave.", \
"You start to fix part of the microwave." \
@@ -75,8 +113,8 @@
"\The [user] fixes part of the microwave.", \
"You have fixed part of the microwave." \
)
- src.broken = 1 // Fix it a bit
- else if(src.broken == 1 && O.iswrench()) // If it's broken and they're doing the wrench
+ broken = 1 // Fix it a bit
+ else if(broken == 1 && O.iswrench()) // If it's broken and they're doing the wrench
user.visible_message( \
"\The [user] starts to fix part of the microwave.", \
"You start to fix part of the microwave." \
@@ -86,15 +124,15 @@
"\The [user] fixes the microwave.", \
"You have fixed the microwave." \
)
- src.icon_state = "mw"
- src.broken = 0 // Fix it!
- src.dirty = 0 // just to be sure
- src.flags = OPENCONTAINER | NOREACT
+ icon_state = "mw"
+ broken = 0 // Fix it!
+ dirty = 0 // just to be sure
+ flags = OPENCONTAINER | NOREACT
else
to_chat(user, "It's broken!")
return 1
- else if(src.dirty==100) // The microwave is all dirty so can't be used!
- if(istype(O, /obj/item/weapon/reagent_containers/spray/cleaner) || istype(O, /obj/item/weapon/soap)) // If they're trying to clean it then let them
+ else if(dirty >= 100) // The microwave is all dirty so can't be used!
+ if(istype(O, /obj/item/weapon/reagent_containers/spray/cleaner) || istype(O, /obj/item/weapon/soap) || istype(O, /obj/item/weapon/reagent_containers/glass/rag)) // If they're trying to clean it then let them
user.visible_message( \
"\The [user] starts to clean the microwave.", \
"You start to clean the microwave." \
@@ -104,43 +142,21 @@
"\The [user] has cleaned the microwave.", \
"You have cleaned the microwave." \
)
- src.dirty = 0 // It's clean!
- src.broken = 0 // just to be sure
- src.icon_state = "mw"
- src.flags = OPENCONTAINER | NOREACT
+ dirty = 0 // It's clean!
+ broken = 0 // just to be sure
+ icon_state = "mw"
+ flags = OPENCONTAINER | NOREACT
else //Otherwise bad luck!!
to_chat(user, "It's dirty!")
return 1
- else if(is_type_in_list(O,acceptable_items))
- if (contents.len>=max_n_of_items)
- to_chat(user, "This [src] is full of ingredients, you cannot put more.")
- return 1
- if(istype(O, /obj/item/stack) && O:get_amount() > 1) // This is bad, but I can't think of how to change it
- var/obj/item/stack/S = O
- new O.type (src)
- S.use(1)
- user.visible_message( \
- "\The [user] has added one of [O] to \the [src].", \
- "You add one of [O] to \the [src].")
- return
- else
- // user.remove_from_mob(O) //This just causes problems so far as I can tell. -Pete
- user.drop_from_inventory(O,src)
- user.visible_message( \
- "\The [user] has added \the [O] to \the [src].", \
- "You add \the [O] to \the [src].")
- return
- else if(istype(O,/obj/item/weapon/reagent_containers/glass) || \
- istype(O,/obj/item/weapon/reagent_containers/food/drinks) || \
- istype(O,/obj/item/weapon/reagent_containers/food/condiment) \
- )
+ else if(is_type_in_list(O, acceptable_containers))
if (!O.reagents)
return 1
for (var/datum/reagent/R in O.reagents.reagent_list)
if (!(R.id in acceptable_reagents))
to_chat(user, "Your [O] contains components unsuitable for cookery.")
return 1
- return
+ return // Note to the future: reagents are added after this in the container's afterattack().
else if(istype(O,/obj/item/weapon/grab))
var/obj/item/weapon/grab/G = O
to_chat(user, "This is ridiculous. You can not fit \the [G.affecting] in this [src].")
@@ -167,10 +183,30 @@
else if(default_part_replacement(user, O))
return
else
-
- to_chat(user, "You have no idea what you can cook with this [O].")
+ if (contents.len>=max_n_of_items)
+ to_chat(user, "This [src] is full of ingredients, you can't fit any more!")
+ return 1
+ if(istype(O, /obj/item/stack))
+ var/obj/item/stack/S = O
+ if(S.get_amount() > 1)
+ new O.type (src)
+ S.use(1)
+ user.visible_message( \
+ "\The [user] has added one of [O] to \the [src].", \
+ "You add one of [O] to \the [src].")
+ SSvueui.check_uis_for_change(src)
+ return
+ else
+ add_item(O, user)
+ else
+ add_item(O, user)
+ return
+ SSvueui.check_uis_for_change(src)
..()
- src.updateUsrDialog()
+
+/obj/machinery/microwave/AltClick()
+ if(!operating)
+ cook()
/obj/machinery/microwave/attack_ai(mob/user as mob)
if(istype(user, /mob/living/silicon/robot) && Adjacent(user))
@@ -178,75 +214,67 @@
/obj/machinery/microwave/attack_hand(mob/user as mob)
user.set_machine(src)
- interact(user)
+ if(broken > 0)
+ to_chat(user, "\The [name] is broken! You'll need to fix it before using it.")
+ else if(dirty >= 100)
+ to_chat(user, "\The [name] is dirty! You'll need to clean it before using it.")
+ else
+ ui_interact(user)
+
+/obj/machinery/microwave/examine(var/mob/user)
+ ..()
+ if(broken > 0)
+ to_chat(user, "It's broken!")
+ else if(dirty >= 100)
+ to_chat(user, "The insides are completely filthy!")
+ else if(dirty > 75)
+ to_chat(user, "It's covered in stains.")
+ else if(dirty > 50)
+ to_chat(user, "It's pretty messy.")
+ else if(dirty > 25)
+ to_chat(user, "It's a bit dirty.")
/*******************
* Microwave Menu
********************/
-/obj/machinery/microwave/interact(mob/user as mob) // The microwave Menu
- var/dat = ""
- if(src.broken > 0)
- dat = {"Bzzzzttttt"}
- else if(src.operating)
- dat = {"Microwaving in progress!
Please wait...!"}
- else if(src.dirty==100)
- dat = {"This microwave is dirty!
Please clean it before use!"}
- else
- var/list/items_counts = new
- var/list/items_measures = new
- var/list/items_measures_p = new
+VUEUI_MONITOR_VARS(/obj/machinery/microwave, microwavemonitor)
+ watch_var("operating", "on", CALLBACK(null, .proc/transform_to_boolean, FALSE))
+ watch_var("failed", "failed")
+ watch_var("cook_time", "cook_time")
+ watch_var("start_time", "start_time")
+
+/obj/machinery/microwave/vueui_data_change(var/list/data, var/mob/user, var/datum/vueui/ui)
+ var/monitordata = ..()
+ if(monitordata)
+ . = data = monitordata
+
+ // init data objects if they aren't already
+ LAZYINITLIST(data["cookingobjs"])
+ LAZYINITLIST(data["cookingreas"])
+
+ // if BYOND lists are smaller than UI, then something (or everything) was removed - wipe the list
+ if(LAZYLEN(contents) < LAZYLEN(data["cookingobjs"]))
+ VUEUI_SET_CHECK(data["cookingobjs"], list(), ., data)
+ if(LAZYLEN(reagents.reagent_list) < LAZYLEN(data["cookingreas"]))
+ VUEUI_SET_CHECK(data["cookingreas"], list(), ., data)
+
+ // build the list of objs and reagents
+ if (LAZYLEN(contents))
+ var/list/cook_count = list()
for (var/obj/O in contents)
- var/display_name = O.name
- if (istype(O,/obj/item/weapon/reagent_containers/food/snacks/egg))
- items_measures[display_name] = "egg"
- items_measures_p[display_name] = "eggs"
- if (istype(O,/obj/item/weapon/reagent_containers/food/snacks/tofu))
- items_measures[display_name] = "tofu chunk"
- items_measures_p[display_name] = "tofu chunks"
- if (istype(O,/obj/item/weapon/reagent_containers/food/snacks/meat)) //any meat
- items_measures[display_name] = "slab of meat"
- items_measures_p[display_name] = "slabs of meat"
- if (istype(O,/obj/item/weapon/reagent_containers/food/snacks/donkpocket))
- display_name = "Turnovers"
- items_measures[display_name] = "turnover"
- items_measures_p[display_name] = "turnovers"
- if (istype(O,/obj/item/weapon/reagent_containers/food/snacks/carpmeat))
- items_measures[display_name] = "fillet of meat"
- items_measures_p[display_name] = "fillets of meat"
- items_counts[display_name]++
- for (var/O in items_counts)
- var/N = items_counts[O]
- if (!(O in items_measures))
- dat += {"[capitalize(O)]: [N] [lowertext(O)]\s
"}
- else
- if (N==1)
- dat += {"[capitalize(O)]: [N] [items_measures[O]]
"}
- else
- dat += {"[capitalize(O)]: [N] [items_measures_p[O]]
"}
-
+ cook_count[O.name]++
+ for (var/C in cook_count)
+ VUEUI_SET_CHECK(data["cookingobjs"][C], cook_count[C], ., data)
+ if (LAZYLEN(reagents.reagent_list))
for (var/datum/reagent/R in reagents.reagent_list)
- var/display_name = R.name
- if (R.id == "capsaicin")
- display_name = "Hotsauce"
- if (R.id == "frostoil")
- display_name = "Coldsauce"
- dat += {"[display_name]: [R.volume] unit\s
"}
-
- if (items_counts.len==0 && reagents.reagent_list.len==0)
- dat = {"The microwave is empty
"}
- else
- dat = {"Ingredients:
[dat]"}
- dat += {"
\
-Turn on!
\
-Eject ingredients!
\
-"}
-
- user << browse("Microwave Controls[dat]", "window=microwave")
- onclose(user, "microwave")
- return
-
+ VUEUI_SET_CHECK(data["cookingreas"][R], R.volume, ., data)
+/obj/machinery/microwave/ui_interact(mob/user)
+ var/datum/vueui/ui = SSvueui.get_open_ui(user, src)
+ if (!ui)
+ ui = new(user, src, "cooking-microwave", 300, 300, capitalize(name))
+ ui.open()
/***********************************
* Microwave Menu Handling/Cooking
@@ -255,102 +283,91 @@
/obj/machinery/microwave/proc/cook()
if(stat & (NOPOWER|BROKEN))
return
- start()
- if (reagents.total_volume==0 && !(locate(/obj) in contents)) //dry run
- if (!wzhzhzh(16))
- abort()
- return
- stop()
+
+ if (!reagents.reagent_list.len && !(locate(/obj) in contents)) //dry run
+ start()
return
- var/datum/recipe/recipe = select_recipe(RECIPE_LIST(appliancetype),src)
- var/obj/cooked
+ recipe = select_recipe(RECIPE_LIST(appliancetype),src)
+
+ if (reagents.reagent_list.len && prob(50)) // 50% chance a liquid recipe gets messy
+ dirty += Ceiling(reagents.total_volume / 10)
+
if (!recipe)
- dirty += 1
- if (prob(max(10,dirty*5)))
- if (!wzhzhzh(16))
- abort()
- return
- muck_start()
- wzhzhzh(16)
- muck_finish()
- cooked = fail()
- cooked.forceMove(src.loc)
- return
+ failed = TRUE
+ cook_time = update_cook_time()
+ dirty += 5
+ if (prob(max(10, dirty*5)))
+ // It's dirty enough to mess up the microwave
+ cook_dirty = TRUE
else if (has_extra_item())
- if (!wzhzhzh(16))
- abort()
- return
- broke()
- cooked = fail()
- cooked.forceMove(src.loc)
- return
- else
- if (!wzhzhzh(40))
- abort()
- return
- stop()
- cooked = fail()
- cooked.forceMove(src.loc)
- return
+ // Something's in the microwave that shouldn't be! Time to break!
+ cook_break = TRUE
else
- var/halftime = round((recipe.time*4)/10/2)
- if (!wzhzhzh(halftime))
- abort()
- return
- if (!wzhzhzh(halftime))
- abort()
- cooked = fail()
- cooked.forceMove(src.loc)
- return
+ failed = FALSE
+ cook_time = update_cook_time(round(recipe.time * 2))
+ start()
- //Making multiple copies of a recipe
- var/result = recipe.result
- var/valid = 1
- var/list/cooked_items = list()
- var/obj/temp = new /obj(src) //To prevent infinite loops, all results will be moved into a temporary location so they're not considered as inputs for other recipes
- while(valid)
- var/list/things = list()
- things.Add(recipe.make_food(src))
- cooked_items += things
- //Move cooked things to the buffer so they're not considered as ingredients
- for (var/atom/movable/AM in things)
- AM.forceMove(temp)
+/obj/machinery/microwave/proc/update_cook_time(var/ct = 200)
+ RefreshParts()
+ return (ct / cooking_power)
- valid = 0
- recipe = select_recipe(RECIPE_LIST(appliancetype),src)
- if (recipe && recipe.result == result)
- sleep(2)
- valid = 1
+/obj/machinery/microwave/proc/finish_cooking()
+ var/result = recipe.result
+ var/valid = TRUE
+ var/list/cooked_items = list()
+ var/obj/temp = new /obj(src) //To prevent infinite loops, all results will be moved into a temporary location so they're not considered as inputs for other recipes
+ while(valid)
+ var/list/things = list()
+ things.Add(recipe.make_food(src))
+ cooked_items += things
+ //Move cooked things to the buffer so they're not considered as ingredients
+ for (var/atom/movable/AM in things)
+ AM.forceMove(temp)
- for (var/r in cooked_items)
- var/atom/movable/R = r
- R.forceMove(src) //Move everything from the buffer back to the container
+ valid = FALSE
+ recipe = select_recipe(RECIPE_LIST(appliancetype),src)
+ if (recipe && recipe.result == result)
+ sleep(2)
+ valid = TRUE
- qdel(temp)//Delete buffer object
- temp = null
+ for (var/r in cooked_items)
+ var/atom/movable/R = r
+ R.forceMove(src) //Move everything from the buffer back to the container
- //Any leftover reagents are divided amongst the foods
- var/total = reagents.total_volume
- for (var/obj/item/weapon/reagent_containers/food/snacks/S in cooked_items)
- reagents.trans_to_holder(S.reagents, total/cooked_items.len)
+ QDEL_NULL(temp)//Delete buffer object
- for (var/obj/item/weapon/reagent_containers/food/snacks/S in contents)
- S.cook()
+ //Any leftover reagents are divided amongst the foods
+ var/total = reagents.total_volume
+ for (var/obj/item/weapon/reagent_containers/food/snacks/S in cooked_items)
+ reagents.trans_to_holder(S.reagents, total/cooked_items.len)
- dispose(0) //clear out anything left
+ for (var/obj/item/weapon/reagent_containers/food/snacks/S in contents)
+ S.cook()
+
+ eject(0) //clear out anything left
+
+ return
+
+/obj/machinery/microwave/process() // What you see here are the remains of proc/wzhzhzh, 2010 - 2019. RIP.
+ if (stat & (NOPOWER|BROKEN))
stop()
-
return
-/obj/machinery/microwave/proc/wzhzhzh(var/seconds as num) // Whoever named this proc is fucking literally Satan. ~ Z
- for (var/i=1 to seconds)
- if (stat & (NOPOWER|BROKEN))
- return 0
- use_power(active_power_usage)
- sleep(10)
- return 1
+ use_power(active_power_usage)
+
+ if(world.time > end_time)
+ stop()
+
+/obj/machinery/microwave/proc/half_time_process()
+ if (stat & (NOPOWER|BROKEN))
+ return
+
+ playsound(src, 'sound/machines/click.ogg', 20, 1)
+
+ if(failed)
+ visible_message(span("warning", "\The [src] begins to leak an acrid smoke..."))
/obj/machinery/microwave/proc/has_extra_item()
for (var/obj/O in contents)
@@ -358,64 +375,57 @@
!istype(O,/obj/item/weapon/reagent_containers/food) && \
!istype(O, /obj/item/weapon/grown) \
)
- return 1
- return 0
+ return TRUE
+ return FALSE
/obj/machinery/microwave/proc/start()
- src.visible_message("The microwave turns on.", "You hear a microwave.")
- src.operating = 1
- src.icon_state = "mw1"
- src.updateUsrDialog()
+ start_time = world.time
+ end_time = cook_time + start_time
+ operating = TRUE
+
+ START_PROCESSING(SSprocessing, src)
+ addtimer(CALLBACK(src, .proc/half_time_process), cook_time / 2)
+ visible_message("The microwave turns on.", "You hear a microwave.")
+
+ if(cook_dirty)
+ playsound(loc, 'sound/effects/splat.ogg', 50, 1) // Play a splat sound
+ icon_state = "mwbloody1" // Make it look dirty!!
+ else
+ icon_state = "mw1"
+
set_light(1.5)
soundloop.start()
-
-/obj/machinery/microwave/proc/abort()
- after_finish_loop()
- src.operating = 0 // Turn it off again aferwards
- src.icon_state = "mw"
- src.updateUsrDialog()
+ SSvueui.check_uis_for_change(src)
/obj/machinery/microwave/proc/stop()
+ STOP_PROCESSING(SSprocessing, src)
after_finish_loop()
- src.operating = 0 // Turn it off again aferwards
- src.icon_state = "mw"
- src.updateUsrDialog()
-/obj/machinery/microwave/proc/dispose(var/message = 1)
- for (var/atom/movable/A in contents)
- A.forceMove(loc)
- if (src.reagents.total_volume)
- src.dirty++
- src.reagents.clear_reagents()
- if (message)
- to_chat(usr, "You dispose of the microwave contents.")
- src.updateUsrDialog()
+ operating = FALSE // Turn it off again aferwards
+ if(cook_dirty || cook_break)
+ flags = null //So you can't add condiments
+ if(cook_dirty)
+ visible_message(span("warning", "The insides of the microwave get covered in muck!"))
+ dirty = 100 // Make it dirty so it can't be used util cleaned
+ icon_state = "mwbloody" // Make it look dirty too
+ else if(cook_break)
+ spark(src, 2, alldirs)
+ icon_state = "mwb" // Make it look all busted up and shit
+ visible_message(span("warning", "The microwave sprays out a shower of sparks - it's broken!")) //Let them know they're stupid
+ broken = 2 // Make it broken so it can't be used util
+ else
+ icon_state = "mw"
-/obj/machinery/microwave/proc/muck_start()
- playsound(src.loc, 'sound/effects/splat.ogg', 50, 1) // Play a splat sound
- src.icon_state = "mwbloody1" // Make it look dirty!!
+ if(failed)
+ fail()
+ failed = FALSE
+ else if(!failed && !abort)
+ finish_cooking()
-/obj/machinery/microwave/proc/muck_finish()
- after_finish_loop()
- src.visible_message("The microwave gets covered in muck!")
- src.dirty = 100 // Make it dirty so it can't be used util cleaned
- src.flags = null //So you can't add condiments
- src.icon_state = "mwbloody" // Make it look dirty too
- src.operating = 0 // Turn it off again aferwards
- src.updateUsrDialog()
-
-/obj/machinery/microwave/proc/broke()
- after_finish_loop()
- spark(src, 2, alldirs)
- src.icon_state = "mwb" // Make it look all busted up and shit
- src.visible_message("The microwave breaks!") //Let them know they're stupid
- src.broken = 2 // Make it broken so it can't be used util fixed
- src.flags = null //So you can't add condiments
- src.operating = 0 // Turn it off again aferwards
- src.updateUsrDialog()
+ abort = FALSE
+ SSvueui.check_uis_for_change(src)
/obj/machinery/microwave/proc/fail()
- after_finish_loop()
var/obj/item/weapon/reagent_containers/food/snacks/badrecipe/ffuu = new(src)
var/amount = 0
for (var/obj/O in contents-ffuu)
@@ -425,45 +435,90 @@
if (id)
amount+=O.reagents.get_reagent_amount(id)
qdel(O)
- src.reagents.clear_reagents()
+ reagents.clear_reagents()
+ SSvueui.check_uis_for_change(src)
ffuu.reagents.add_reagent("carbon", amount)
ffuu.reagents.add_reagent("toxin", amount/10)
+
+ if(!abort)
+ visible_message("\The [src] belches out foul-smelling smoke!")
+ var/datum/effect/effect/system/smoke_spread/bad/smoke = new /datum/effect/effect/system/smoke_spread/bad
+ smoke.attach(src)
+ smoke.set_up(10, 0, get_turf(src), 300)
+ smoke.start()
+
+ ffuu.forceMove(loc)
return ffuu
/obj/machinery/microwave/Topic(href, href_list)
+ SSvueui.check_uis_for_change(src)
if(..())
return
- usr.set_machine(src)
- if(src.operating)
- src.updateUsrDialog()
+ if(dirty >= 100)
+ to_chat(usr, "\The [name] is dirty! You'll need to clean it before using it.")
return
- switch(href_list["action"])
- if ("cook")
- cook()
+ if(broken > 0)
+ to_chat(usr, "\The [name] is broken! You'll need to fix it before using it.")
+ return
+
+ usr.set_machine(src)
+
+ if(operating)
+ if(href_list["abort"])
+ abort = TRUE
+ stop()
+ SSvueui.check_uis_for_change(src)
+ return
+
+ if(href_list["cook"])
+ cook()
+ SSvueui.check_uis_for_change(src)
+ else if(href_list["eject_all"])
+ eject()
+ else if(href_list["eject"])
+ for (var/datum/reagent/R in reagents.reagent_list)
+ if(R.name == href_list["eject"])
+ eject_reagent(R, usr)
+ break
+ for (var/obj/O in contents)
+ if(O.name == href_list["eject"])
+ eject(0, O)
+ break
- if ("dispose")
- dispose()
return
-/obj/machinery/microwave/verb/Eject()
- set src in oview(1)
- set category = "Object"
- set name = "Eject content"
- usr.visible_message(
- "[usr] is trying to open [src] to take out its content." ,
- "You are trying to open [src] to take out its content"
- )
+/obj/machinery/microwave/proc/eject_reagent(datum/reagent/R, mob/user)
+ if(istype(user.l_hand, /obj/item/weapon/reagent_containers) || istype(user.r_hand, /obj/item/weapon/reagent_containers))
+ var/obj/item/weapon/reagent_containers/RC = user.l_hand || user.r_hand
+ var/free_space = RC.reagents.get_free_space()
+ if(free_space > R.volume)
+ to_chat(user, "You empty [R.volume] units of [R.name] into your [RC.name].")
+ RC.reagents.add_reagent(R.id, R.volume)
+ reagents.remove_reagent(R.id, R.volume)
+ else if(free_space <= 0)
+ to_chat(user, "[RC.name] is full!")
+ else
+ to_chat(user, "You empty [free_space] units of [R.name] into your [RC.name].")
+ RC.reagents.add_reagent(R.id, free_space)
+ reagents.remove_reagent(R.id, free_space)
+ SSvueui.check_uis_for_change(src)
+ else
+ to_chat(user, "You need to be holding a valid container to empty [R.name]!")
- if (!do_after(usr, 1 SECONDS, act_target = src))
- return
-
- usr.visible_message(
- "[usr] opened [src] and has taken out [english_list(contents)]." ,
- "You have opened [src] and taken out [english_list(contents)]."
- )
- dispose()
+/obj/machinery/microwave/proc/eject(var/message = 1, var/obj/EJ = null)
+ if (EJ)
+ EJ.forceMove(loc)
+ else
+ for (var/atom/movable/A in contents)
+ A.forceMove(loc)
+ if (reagents.total_volume)
+ dirty += round(reagents.total_volume / 10)
+ reagents.clear_reagents()
+ if (message)
+ to_chat(usr, "You dispose of the microwave contents.")
+ SSvueui.check_uis_for_change(src)
/obj/machinery/microwave/CanPass(atom/movable/mover, turf/target, height=0, air_group=0)
if (!mover)
@@ -476,4 +531,23 @@
/obj/machinery/microwave/proc/after_finish_loop()
set_light(0)
soundloop.stop()
- update_icon()
\ No newline at end of file
+ update_icon()
+
+/obj/machinery/microwave/RefreshParts()
+ ..()
+ var/bin_rating = 0 // 2
+ var/cap_rating = 0 // 3
+ var/las_rating = 0 // 1
+
+ for (var/obj/item/weapon/stock_parts/P in component_parts)
+ if(ismatterbin(P))
+ bin_rating += (P.rating - 1)
+ else if(iscapacitor(P))
+ cap_rating += (P.rating - 1)
+ else if(ismicrolaser(P))
+ las_rating += (P.rating - 1)
+
+ active_power_usage = initial(active_power_usage) - (cap_rating * 25)
+ max_n_of_items = initial(max_n_of_items) + Floor(bin_rating)
+ cooking_power = initial(cooking_power) + (las_rating / 3)
+
diff --git a/code/game/objects/items/weapons/circuitboards/machinery/miscboards.dm b/code/game/objects/items/weapons/circuitboards/machinery/miscboards.dm
index 9054cb4c835..ad05899abb3 100644
--- a/code/game/objects/items/weapons/circuitboards/machinery/miscboards.dm
+++ b/code/game/objects/items/weapons/circuitboards/machinery/miscboards.dm
@@ -117,7 +117,7 @@
board_type = "machine"
req_components = list(
"/obj/item/weapon/stock_parts/capacitor" = 3,
- "/obj/item/weapon/stock_parts/scanning_module" = 1,
+ "/obj/item/weapon/stock_parts/micro_laser" = 1,
"/obj/item/weapon/stock_parts/matter_bin" = 2)
/obj/item/weapon/circuitboard/oven
diff --git a/code/modules/reagents/reagent_containers.dm b/code/modules/reagents/reagent_containers.dm
index f06bca66a27..f45da8a891b 100644
--- a/code/modules/reagents/reagent_containers.dm
+++ b/code/modules/reagents/reagent_containers.dm
@@ -70,6 +70,7 @@
if(standard_splash_mob(user, target))
return
if(standard_pour_into(user, target))
+ SSvueui.check_uis_for_change(target)
return
if(standard_splash_obj(user, target))
return
diff --git a/html/changelogs/johnwildkins-7180.yml b/html/changelogs/johnwildkins-7180.yml
new file mode 100644
index 00000000000..997123b9c0c
--- /dev/null
+++ b/html/changelogs/johnwildkins-7180.yml
@@ -0,0 +1,49 @@
+################################
+# Example Changelog File
+#
+# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb.
+#
+# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.)
+# When it is, any changes listed below will disappear.
+#
+# Valid Prefixes:
+# bugfix
+# wip (For works in progress)
+# tweak
+# soundadd
+# sounddel
+# rscadd (general adding of nice things)
+# rscdel (general deleting of nice things)
+# imageadd
+# imagedel
+# maptweak
+# spellcheck (typo fixes)
+# experiment
+# balance
+# admin
+# backend
+# security
+# refactor
+#################################
+
+# Your name.
+author: JohnWildkins
+
+# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again.
+delete-after: True
+
+# Any changes you've made. See valid prefix list above.
+# INDENT WITH TWO SPACES. NOT TABS. SPACES.
+# SCREW THIS UP AND IT WON'T WORK.
+# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries.
+# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog.
+changes:
+ - refactor: "Microwaves have been reworked from the ground up on the back-end. Microwaves have been moved to a process-based system for cooking, and behave more similarly to other cooking devices."
+ - rscadd: "Microwaves have had their UI rebuilt from scratch in Vue."
+ - rscadd: "You can now eject individual ingredients and reagents from a microwave. To perform the latter, you must be holding a reagent container with enough space in your hands."
+ - rscadd: "You can now start microwaves by alt-clicking on them."
+ - rscadd: "Microwaves can now be upgraded, with matter bins, capacitors, and the micro laser affecting maximum cookable items, power usage, and cook time respectively."
+ - tweak: "Microwaves now display their cook time as a progress bar in the UI. Cook time has been reduced across the board."
+ - tweak: "Eject verb for microwaves removed. All interfacing should now be done via the UI."
+ - bugfix: "Bugs both known and unknown relating to the old UI and general instability of the microwave have been solved, including food duplication."
+ - backend: "Vue UI progress bar element now caps width at 100%."
diff --git a/vueui/src/components/view/cooking/microwave.vue b/vueui/src/components/view/cooking/microwave.vue
new file mode 100644
index 00000000000..e2fd71df4a7
--- /dev/null
+++ b/vueui/src/components/view/cooking/microwave.vue
@@ -0,0 +1,63 @@
+
+
+
+
+ There's nothing inside. Microwave's working, though!
+ Something doesn't look right...
+ It's cooking nicely!
+
+ It's starting to cook...
+
+ Abort!
+
+
+ Ingredients
+
+ - The microwave is empty!
+ -
+ {{ name }} • {{ amt }}
+
+
+ -
+ {{ name }} • {{ amt }} units
+
+
+
+ Eject All
+ Cook!
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/vueui/src/components/vui/progress.vue b/vueui/src/components/vui/progress.vue
index 7c279319db7..8d51d3c8eec 100644
--- a/vueui/src/components/vui/progress.vue
+++ b/vueui/src/components/vui/progress.vue
@@ -23,7 +23,7 @@ export default {
},
computed: {
percentage() {
- return (this.value - this.min) / (this.max - this.min) * 100
+ return (Math.min(this.max, Math.max(this.value, this.min)) - this.min) / (this.max - this.min) * 100;
}
}
}