diff --git a/code/game/machinery/autolathe.dm b/code/game/machinery/autolathe.dm index ba9667b3e58..a0e2eab029b 100644 --- a/code/game/machinery/autolathe.dm +++ b/code/game/machinery/autolathe.dm @@ -95,10 +95,19 @@ /obj/machinery/autolathe/proc/AfterMaterialInsert(container, obj/item/item_inserted, last_inserted_id, mats_consumed, amount_inserted, atom/context) SIGNAL_HANDLER - flick("autolathe_[item_inserted.has_material_type(/datum/material/glass) ? "r" : "o"]", src) - //we use initial(active_power_usage) because higher tier parts will have higher active usage but we have no benifit from it - directly_use_power(ROUND_UP((amount_inserted / (MAX_STACK_SIZE * SHEET_MATERIAL_AMOUNT)) * 0.01 * initial(active_power_usage))) + if(directly_use_power(ROUND_UP((amount_inserted / (MAX_STACK_SIZE * SHEET_MATERIAL_AMOUNT)) * 0.02 * initial(active_power_usage)))) + flick_overlay_view(mutable_appearance('icons/obj/machines/lathes.dmi', "autolathe_mat"), 1 SECONDS) + + var/datum/material/highest_mat_ref + var/highest_mat = 0 + for(var/datum/material/mat as anything in mats_consumed) + var/present_mat = mats_consumed[mat] + if(present_mat > highest_mat) + highest_mat = present_mat + highest_mat_ref = mat + + flick_overlay_view(material_insertion_animation(highest_mat_ref.greyscale_colors), 1 SECONDS) /obj/machinery/autolathe/ui_interact(mob/user, datum/tgui/ui) if(!is_operational) diff --git a/code/game/objects/effects/material_insert.dm b/code/game/objects/effects/material_insert.dm new file mode 100644 index 00000000000..9ca86226b24 --- /dev/null +++ b/code/game/objects/effects/material_insert.dm @@ -0,0 +1,22 @@ +/** + * Creates a mutable appearance with the material color applied for its insertion animation into an autolathe or techfab + * Arguments + * + * * color - the material color that will be applied + */ +/proc/material_insertion_animation(color) + RETURN_TYPE(/mutable_appearance) + + var/static/list/mutable_appearance/apps = list() + + var/mutable_appearance/cached_app = apps[color] + if(isnull(cached_app)) + var/icon/modified_icon = icon('icons/obj/machines/research.dmi', "material_insertion") + + //assuming most of the icon is white we find what ratio to scale the intensity of each part roughly + var/list/rgb_list = rgb2num(color) + modified_icon.SetIntensity(rgb_list[1] / 255, rgb_list[2] / 255, rgb_list[3] / 255) + cached_app = mutable_appearance(modified_icon, "material_insertion") + + apps[color] = cached_app + return cached_app diff --git a/code/modules/research/machinery/_production.dm b/code/modules/research/machinery/_production.dm index f95145b4b94..673a0dbbac9 100644 --- a/code/modules/research/machinery/_production.dm +++ b/code/modules/research/machinery/_production.dm @@ -28,7 +28,7 @@ /datum/component/remote_materials, \ mapload, \ mat_container_signals = list( \ - COMSIG_MATCONTAINER_ITEM_CONSUMED = TYPE_PROC_REF(/obj/machinery/rnd, local_material_insert) + COMSIG_MATCONTAINER_ITEM_CONSUMED = TYPE_PROC_REF(/obj/machinery/rnd/production, local_material_insert) ) \ ) @@ -49,7 +49,6 @@ cached_designs = null return ..() - // Stuff for the stripe on the department machines /obj/machinery/rnd/production/default_deconstruction_screwdriver(mob/user, icon_state_open, icon_state_closed, obj/item/screwdriver) . = ..() @@ -128,7 +127,7 @@ addtimer(CALLBACK(src, PROC_REF(update_designs)), 2 SECONDS, TIMER_UNIQUE | TIMER_OVERRIDE) ///When materials are instered via silo link -/obj/machinery/rnd/proc/silo_material_insert(obj/machinery/rnd/machine, container, obj/item/item_inserted, last_inserted_id, list/mats_consumed, amount_inserted) +/obj/machinery/rnd/production/proc/silo_material_insert(obj/machinery/rnd/machine, container, obj/item/item_inserted, last_inserted_id, list/mats_consumed, amount_inserted) SIGNAL_HANDLER process_item(item_inserted, mats_consumed, amount_inserted) @@ -141,37 +140,39 @@ * * list/mats_consumed - list of mats consumed * * amount_inserted - amount of material actually processed */ -/obj/machinery/rnd/proc/process_item(obj/item/item_inserted, list/mats_consumed, amount_inserted) +/obj/machinery/rnd/production/proc/process_item(obj/item/item_inserted, list/mats_consumed, amount_inserted) PRIVATE_PROC(TRUE) //we use initial(active_power_usage) because higher tier parts will have higher active usage but we have no benifit from it - if(directly_use_power(ROUND_UP((amount_inserted / (MAX_STACK_SIZE * SHEET_MATERIAL_AMOUNT)) * 0.01 * initial(active_power_usage)))) - var/mat_name = "iron" + if(directly_use_power(ROUND_UP((amount_inserted / (MAX_STACK_SIZE * SHEET_MATERIAL_AMOUNT)) * 0.02 * initial(active_power_usage)))) + var/datum/material/highest_mat_ref var/highest_mat = 0 for(var/datum/material/mat as anything in mats_consumed) var/present_mat = mats_consumed[mat] if(present_mat > highest_mat) - mat_name = initial(mat.name) - if(mat_name == "silver" || mat_name == "titanium" || mat_name == "plastic") //these materials have similar appearances so use an common overlay for them - mat_name = "shiny" highest_mat = present_mat + highest_mat_ref = mat - flick_animation(mat_name) + flick_animation(highest_mat_ref) /** * Plays an visual animation when materials are inserted * Arguments * - * * mat_name - the name of the material we are trying to animate on the machine + * * mat - the material ref we are trying to animate on the machine */ -/obj/machinery/rnd/proc/flick_animation(mat_name) +/obj/machinery/rnd/production/proc/flick_animation(datum/material/mat_ref) PROTECTED_PROC(TRUE) SHOULD_CALL_PARENT(FALSE) - flick_overlay_view(mutable_appearance('icons/obj/machines/research.dmi', "protolathe_[mat_name]"), 1 SECONDS) + //first play the insertion animation + flick_overlay_view(material_insertion_animation(mat_ref.greyscale_colors), 1 SECONDS) + + //now play the progress bar animation + flick_overlay_view(mutable_appearance('icons/obj/machines/research.dmi', "protolathe_progress"), 1 SECONDS) ///When materials are instered into local storage -/obj/machinery/rnd/proc/local_material_insert(container, obj/item/item_inserted, last_inserted_id, list/mats_consumed, amount_inserted, atom/context) +/obj/machinery/rnd/production/proc/local_material_insert(container, obj/item/item_inserted, last_inserted_id, list/mats_consumed, amount_inserted, atom/context) SIGNAL_HANDLER process_item(item_inserted, mats_consumed, amount_inserted) @@ -288,7 +289,7 @@ return //we use initial(active_power_usage) because higher tier parts will have higher active usage but we have no benifit from it - if(!directly_use_power(ROUND_UP((amount / MAX_STACK_SIZE) * 0.01 * initial(active_power_usage)))) + if(!directly_use_power(ROUND_UP((amount / MAX_STACK_SIZE) * 0.02 * initial(active_power_usage)))) say("No power to dispense sheets") return diff --git a/code/modules/research/machinery/circuit_imprinter.dm b/code/modules/research/machinery/circuit_imprinter.dm index 2dcbde23663..c6d50f13307 100644 --- a/code/modules/research/machinery/circuit_imprinter.dm +++ b/code/modules/research/machinery/circuit_imprinter.dm @@ -13,7 +13,7 @@ return 0.5 ** max(rating - 1, 0) // One sheet, half sheet, quarter sheet, eighth sheet. -/obj/machinery/rnd/production/circuit_imprinter/flick_animation(mat_name) +/obj/machinery/rnd/production/circuit_imprinter/flick_animation(datum/material/mat) return //we presently have no animation /obj/machinery/rnd/production/circuit_imprinter/offstation diff --git a/icons/obj/machines/lathes.dmi b/icons/obj/machines/lathes.dmi index 1c4111303eb..f4bb2116b42 100644 Binary files a/icons/obj/machines/lathes.dmi and b/icons/obj/machines/lathes.dmi differ diff --git a/icons/obj/machines/research.dmi b/icons/obj/machines/research.dmi index 544054279e9..baa4cc07225 100644 Binary files a/icons/obj/machines/research.dmi and b/icons/obj/machines/research.dmi differ diff --git a/tgstation.dme b/tgstation.dme index 5b32823d9ed..30caca028dd 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -2205,6 +2205,7 @@ #include "code\game\objects\effects\info.dm" #include "code\game\objects\effects\landmarks.dm" #include "code\game\objects\effects\lighting.dm" +#include "code\game\objects\effects\material_insert.dm" #include "code\game\objects\effects\mines.dm" #include "code\game\objects\effects\misc.dm" #include "code\game\objects\effects\overlays.dm"