//All devices that link into the R&D console fall into thise type for easy identification and some shared procs.
/obj/machinery/r_n_d
name = "R&D Device"
icon = 'icons/obj/machines/research.dmi'
density = TRUE
anchored = TRUE
var/busy = FALSE
var/obj/machinery/computer/rdconsole/linked_console
var/obj/item/loaded_item = null
var/datum/component/material_container/materials //Store for hyper speed!
var/efficiency_coeff = 1
var/list/categories = list()
/obj/machinery/r_n_d/Initialize(mapload)
. = ..()
materials = AddComponent(/datum/component/material_container, list(MAT_METAL, MAT_GLASS, MAT_SILVER, MAT_GOLD, MAT_DIAMOND, MAT_PLASMA, MAT_URANIUM, MAT_BANANIUM, MAT_TRANQUILLITE, MAT_TITANIUM, MAT_BLUESPACE, MAT_PLASTIC), 0, TRUE, /obj/item/stack, CALLBACK(src, PROC_REF(is_insertion_ready)), CALLBACK(src, PROC_REF(AfterMaterialInsert)))
materials.precise_insertion = TRUE
/obj/machinery/r_n_d/Destroy()
if(loaded_item)
loaded_item.forceMove(get_turf(src))
loaded_item = null
linked_console = null
materials = null
return ..()
//whether the machine can have an item inserted in its current state.
/obj/machinery/r_n_d/proc/is_insertion_ready(mob/user)
if(panel_open)
to_chat(user, "You can't load [src] while it's opened!")
return FALSE
if(!linked_console)
to_chat(user, "[src] must be linked to an R&D console first!")
return FALSE
if(busy)
to_chat(user, "[src] is busy right now.")
return FALSE
if(stat & BROKEN)
to_chat(user, "[src] is broken.")
return FALSE
if(stat & NOPOWER)
to_chat(user, "[src] has no power.")
return FALSE
if(loaded_item)
to_chat(user, "[src] is already loaded.")
return FALSE
return TRUE
/obj/machinery/r_n_d/proc/AfterMaterialInsert(type_inserted, id_inserted, amount_inserted)
var/stack_name
if(ispath(type_inserted, /obj/item/stack/ore/bluespace_crystal))
stack_name = "bluespace"
use_power(MINERAL_MATERIAL_AMOUNT / 10)
else
var/obj/item/stack/S = type_inserted
stack_name = initial(S.name)
use_power(min(1000, (amount_inserted / 100)))
add_overlay("protolathe_[stack_name]")
addtimer(CALLBACK(src, TYPE_PROC_REF(/atom, cut_overlay), "protolathe_[stack_name]"), 10)
/obj/machinery/r_n_d/proc/check_mat(datum/design/being_built, M)
return 0 // number of copies of design beign_built you can make with material M