diff --git a/code/modules/integrated_electronics/core/printer.dm b/code/modules/integrated_electronics/core/printer.dm index 6378ae146a..e1ec172710 100644 --- a/code/modules/integrated_electronics/core/printer.dm +++ b/code/modules/integrated_electronics/core/printer.dm @@ -1,13 +1,18 @@ +#define MAX_CIRCUIT_CLONE_TIME 3 MINUTES //circuit slow-clones can only take up this amount of time to complete + /obj/item/device/integrated_circuit_printer name = "integrated circuit printer" desc = "A portable(ish) machine made to print tiny modular circuitry out of metal." icon = 'icons/obj/assemblies/electronic_tools.dmi' icon_state = "circuit_printer" w_class = WEIGHT_CLASS_BULKY - var/upgraded = FALSE // When hit with an upgrade disk, will turn true, allowing it to print the higher tier circuits. - var/can_clone = FALSE // Same for above, but will allow the printer to duplicate a specific assembly. + var/upgraded = FALSE // When hit with an upgrade disk, will turn true, allowing it to print the higher tier circuits. + var/can_clone = TRUE // Allows the printer to clone circuits, either instantly or over time depending on upgrade. Set to FALSE to disable entirely. + var/fast_clone = FALSE // If this is false, then cloning will take an amount of deciseconds equal to the metal cost divided by 100. var/debug = FALSE // If it's upgraded and can clone, even without config settings. var/current_category = null + var/cloning = FALSE // If the printer is currently creating a circuit + var/clone_countdown = 0 // This counts down when cloning is in progress, and clones the circuit when it's ready var/recycling = FALSE // If an assembly is being emptied into this printer var/list/program // Currently loaded save, in form of list @@ -17,6 +22,7 @@ /obj/item/device/integrated_circuit_printer/upgraded upgraded = TRUE can_clone = TRUE + fast_clone = TRUE /obj/item/device/integrated_circuit_printer/debug //translation: "integrated_circuit_printer/local_server" name = "debug circuit printer" @@ -27,23 +33,39 @@ . = ..() AddComponent(/datum/component/material_container, list(MAT_METAL), MINERAL_MATERIAL_AMOUNT * 25, TRUE, list(/obj/item/stack, /obj/item/integrated_circuit, /obj/item/device/electronic_assembly)) +/obj/item/device/integrated_circuit_printer/Destroy() + STOP_PROCESSING(SSprocessing, src) + return ..() + +/obj/item/device/integrated_circuit_printer/process() + if(!cloning) + STOP_PROCESSING(SSprocessing, src) + clone_countdown-- + if(!clone_countdown || fast_clone) + var/turf/T = get_turf(src) + T.visible_message("[src] has finished printing its assembly!") + playsound(get_turf(T), 'sound/items/poster_being_created.ogg', 50, TRUE) + SScircuit.load_electronic_assembly(T, program) + cloning = FALSE + STOP_PROCESSING(SSprocessing, src) + /obj/item/device/integrated_circuit_printer/attackby(obj/item/O, mob/user) if(istype(O, /obj/item/disk/integrated_circuit/upgrade/advanced)) if(upgraded) - to_chat(user, "\The [src] already has this upgrade. ") + to_chat(user, "[src] already has this upgrade. ") return TRUE - to_chat(user, "You install \the [O] into \the [src]. ") + to_chat(user, "You install [O] into [src]. ") upgraded = TRUE qdel(O) interact(user) return TRUE if(istype(O, /obj/item/disk/integrated_circuit/upgrade/clone)) - if(can_clone) - to_chat(user, "\The [src] already has this upgrade. ") + if(fast_clone) + to_chat(user, "[src] already has this upgrade. ") return TRUE - to_chat(user, "You install \the [O] into \the [src]. ") - can_clone = TRUE + to_chat(user, "You install [O] into [src]. Circuit cloning will now be instant. ") + fast_clone = TRUE qdel(O) interact(user) return TRUE @@ -103,8 +125,8 @@ else HTML += "Metal: [materials.total_amount]/[materials.max_amount].

" - if(CONFIG_GET(flag/ic_printing) && !debug) - HTML += "Assembly cloning: [can_clone ? "Available": "Unavailable"].
" + if(CONFIG_GET(flag/ic_printing) || debug) + HTML += "Assembly cloning: [can_clone ? (fast_clone ? "Instant" : "Available") : "Unavailable"].
" HTML += "Circuits available: [upgraded || debug ? "Advanced":"Regular"]." if(!upgraded) @@ -113,11 +135,16 @@ HTML += "
" if((can_clone && CONFIG_GET(flag/ic_printing)) || debug) HTML += "Here you can load script for your assembly.
" - HTML += " {Load Program} " - if(!program) - HTML += " {Print Assembly}" + if(!cloning) + HTML += " {Load Program} " else - HTML += " {Print Assembly}" + HTML += " {Load Program}" + if(!program) + HTML += " {[fast_clone ? "Print" : "Begin Printing"] Assembly}" + else if(cloning) + HTML += " {Cancel Print} - [clone_countdown] second(s) remaining until completion" + else + HTML += " {[fast_clone ? "Print" : "Begin Printing"] Assembly}" HTML += "

" HTML += "Categories:" @@ -229,11 +256,11 @@ if(!program) return - if(program["requires_upgrades"] && !upgraded) + if(program["requires_upgrades"] && !upgraded && !debug) to_chat(usr, "This program uses unknown component designs. Printer upgrade is required to proceed.") - if(program["unsupported_circuit"]) + if(program["unsupported_circuit"] && !debug) to_chat(usr, "This program uses components not supported by the specified assembly. Please change the assembly type in the save file to a supported one.") - else + else if(fast_clone || debug) var/datum/component/material_container/materials = GetComponent(/datum/component/material_container) if(debug || materials.use_amount_type(program["metal_cost"], MAT_METAL)) var/obj/item/assembly = SScircuit.load_electronic_assembly(get_turf(src), program) @@ -241,6 +268,30 @@ playsound(src, 'sound/items/poster_being_created.ogg', 50, TRUE) else to_chat(usr, "You need [program["metal_cost"]] metal to build that!") + else + var/datum/component/material_container/materials = GetComponent(/datum/component/material_container) + if(!materials.use_amount_type(program["metal_cost"], MAT_METAL)) + to_chat(usr, "You need [program["metal_cost"]] metal to build that!") + return + var/cloning_time = program["metal_cost"] / 150 + cloning_time = min(cloning_time, MAX_CIRCUIT_CLONE_TIME) + cloning = TRUE + clone_countdown = cloning_time + to_chat(usr, "You begin printing a custom assembly. This will take approximately [round(cloning_time / 60, 0.1)] minute(s). You can still print \ + off normal parts during this time.") + playsound(src, 'sound/items/poster_being_created.ogg', 50, TRUE) + START_PROCESSING(SSprocessing, src) + + if("cancel") + if(!cloning || !program) + return + + to_chat(usr, "Cloning has been canceled. Metal cost has been refunded.") + cloning = FALSE + clone_countdown = FALSE + var/datum/component/material_container/materials = GetComponent(/datum/component/material_container) + materials.use_amount_type(-program["metal_cost"], MAT_METAL) //use negative amount to regain the cost + interact(usr) @@ -258,8 +309,7 @@ name = "integrated circuit printer upgrade disk - advanced designs" desc = "Install this into your integrated circuit printer to enhance it. This one adds new, advanced designs to the printer." -// To be implemented later. /obj/item/disk/integrated_circuit/upgrade/clone - name = "integrated circuit printer upgrade disk - circuit cloner" - desc = "Install this into your integrated circuit printer to enhance it. This one allows the printer to duplicate assemblies." + name = "integrated circuit printer upgrade disk - instant cloner" + desc = "Install this into your integrated circuit printer to enhance it. This one allows the printer to duplicate assemblies instantaneously." icon_state = "upgrade_disk_clone" diff --git a/code/modules/research/designs/electronics_designs.dm b/code/modules/research/designs/electronics_designs.dm index bbc8e18c63..8ab66627f0 100644 --- a/code/modules/research/designs/electronics_designs.dm +++ b/code/modules/research/designs/electronics_designs.dm @@ -57,17 +57,17 @@ departmental_flags = DEPARTMENTAL_FLAG_SCIENCE /datum/design/integrated_printer - name = "Integrated circuits printer" + name = "Integrated circuit printer" desc = "This machine provides all neccesary things for circuitry." id = "icprinter" build_type = PROTOLATHE - materials = list(MAT_GLASS = 5000, MAT_METAL = 5000) + materials = list(MAT_GLASS = 5000, MAT_METAL = 10000) build_path = /obj/item/device/integrated_circuit_printer category = list("Electronics") departmental_flags = DEPARTMENTAL_FLAG_SCIENCE /datum/design/IC_printer_upgrade_advanced - name = "Integrated Circuits printer upgrade: Advanced Designs" + name = "Integrated circuit printer upgrade: Advanced Designs" desc = "This disk allows for integrated circuit printers to print advanced circuitry designs." id = "icupgadv" build_type = PROTOLATHE @@ -77,8 +77,8 @@ departmental_flags = DEPARTMENTAL_FLAG_SCIENCE /datum/design/IC_printer_upgrade_clone - name = "Integrated Circuits printer upgrade: Clone Ability" - desc = "This disk allows for integrated circuit printers to clone designs." + name = "Integrated circuit printer upgrade: Instant Cloning" + desc = "This disk allows for integrated circuit printers to clone designs instantaneously." id = "icupgclo" build_type = PROTOLATHE materials = list(MAT_GLASS = 10000, MAT_METAL = 10000)