/* Research and Development (R&D) Console This is the main work horse of the R&D system. It contains the menus/controls for the Destructive Analyzer, Protolathe, and Circuit imprinter. It also contains the /datum/research holder with all the known/possible technology paths and device designs. Basic use: When it first is created, it will attempt to link up to related devices within 3 squares. It'll only link up if they aren't already linked to another console. Any consoles it cannot link up with (either because all of a certain type are already linked or there aren't any in range), you'll just not have access to that menu. In the settings menu, there are menu options that allow a player to attempt to re-sync with nearby consoles. You can also force it to disconnect from a specific console. The imprinting and construction menus do NOT require toxins access to access but all the other menus do. However, if you leave it on a menu, nothing is to stop the person from using the options on that menu (although they won't be able to change to a different one). You can also lock the console on the settings menu if you're feeling paranoid and you don't want anyone messing with it who doesn't have toxins access. When a R&D console is destroyed or even partially disassembled, you lose all research data on it. However, there are two ways around this dire fate: - The easiest way is to go to the settings menu and select "Sync Database with Network." That causes it to upload (but not download) it's data to every other device in the game. Each console has a "disconnect from network" option that'll will cause data base sync operations to skip that console. This is useful if you want to make a "public" R&D console or, for example, give the engineers a circuit imprinter with certain designs on it and don't want it accidentally updating. The downside of this method is that you have to have physical access to the other console to send data back. Note: An R&D console is on CentCom so if a random griffan happens to cause a ton of data to be lost, an admin can go send it back. - The second method is with Technology Disks and Design Disks. Each of these disks can hold a single technology or design datum in it's entirety. You can then take the disk to any R&D console and upload it's data to it. This method is a lot more secure (since it won't update every console in existence) but it's more of a hassle to do. Also, the disks can be stolen. */ /obj/machinery/computer/rdconsole name = "R&D control console" icon_screen = "rdcomp" icon_keyboard = "purple_key" light_color = LIGHT_COLOR_PURPLE circuit = /obj/item/circuitboard/rdconsole var/datum/research/files //Stores all the collected research data. var/obj/item/disk/tech_disk/t_disk = null //Stores the technology disk. var/obj/item/disk/design_disk/d_disk = null //Stores the design disk. var/obj/machinery/r_n_d/destructive_analyzer/linked_destroy = null //Linked Destructive Analyzer var/obj/machinery/r_n_d/protolathe/linked_lathe = null //Linked Protolathe var/obj/machinery/r_n_d/circuit_imprinter/linked_imprinter = null //Linked Circuit Imprinter var/allow_analyzer = TRUE var/allow_lathe = TRUE var/allow_imprinter = TRUE var/screen = 1.0 //Which screen is currently showing. var/id = 0 //ID of the computer (for server restrictions). var/sync = 1 //If sync = 0, it doesn't show up on Server Control Console var/protolathe_category = "All" var/imprinter_category = "All" req_access = list(access_tox) //Data and setting manipulation requires scientist access. /obj/machinery/computer/rdconsole/proc/CallMaterialName(var/ID) var/return_name = ID switch(return_name) if("metal") return_name = "Metal" if("glass") return_name = "Glass" if("gold") return_name = "Gold" if("silver") return_name = "Silver" if("phoron") return_name = "Solid Phoron" if("uranium") return_name = "Uranium" if("diamond") return_name = "Diamond" if("plasteel") return_name = "Plasteel" return return_name /obj/machinery/computer/rdconsole/proc/CallReagentName(ID) var/singleton/reagent/R = GET_SINGLETON(ID) return R ? R.name : "(none)" /obj/machinery/computer/rdconsole/proc/SyncRDevices() //Makes sure it is properly sync'ed up with the devices attached to it (if any). for(var/obj/machinery/r_n_d/D in range(3, src)) if(D.linked_console != null || D.panel_open) continue if(istype(D, /obj/machinery/r_n_d/destructive_analyzer) && allow_analyzer) if(linked_destroy == null) linked_destroy = D D.linked_console = src else if(istype(D, /obj/machinery/r_n_d/protolathe) && allow_lathe) if(linked_lathe == null) linked_lathe = D D.linked_console = src else if(istype(D, /obj/machinery/r_n_d/circuit_imprinter) && allow_imprinter) if(linked_imprinter == null) linked_imprinter = D D.linked_console = src return /obj/machinery/computer/rdconsole/proc/SyncTechs() for(var/obj/machinery/r_n_d/server/S in SSmachinery.machinery) var/server_processed = 0 if((id in S.id_with_upload) || istype(S, /obj/machinery/r_n_d/server/centcom)) for(var/tech_id in files.known_tech) var/datum/tech/T = files.known_tech[tech_id] S.files.AddTech2Known(T) S.files.RefreshResearch() server_processed = 1 files.known_tech = S.files.known_tech.Copy() if(!istype(S, /obj/machinery/r_n_d/server/centcom) && server_processed) S.produce_heat() screen = 1.6 updateUsrDialog() /obj/machinery/computer/rdconsole/proc/griefProtection() //Have it automatically push research to the centcomm server so wild griffins can't fuck up R&D's work for(var/obj/machinery/r_n_d/server/centcom/C in SSmachinery.machinery) for(var/tech_id in files.known_tech) var/datum/tech/T = files.known_tech[tech_id] C.files.AddTech2Known(files.known_tech[T]) C.files.RefreshResearch() /obj/machinery/computer/rdconsole/Initialize() ..() files = new /datum/research(src) //Setup the research data holder. if(!id) for(var/obj/machinery/r_n_d/server/centcom/S in SSmachinery.machinery) S.setup() break SyncRDevices() return INITIALIZE_HINT_LATELOAD /obj/machinery/computer/rdconsole/LateInitialize() SyncTechs() screen = 1.0 /obj/machinery/computer/rdconsole/Destroy() if(linked_destroy != null) linked_destroy.linked_console = null if(linked_lathe != null) linked_lathe.linked_console = null if(linked_imprinter != null) linked_imprinter.linked_console = null return ..() /obj/machinery/computer/rdconsole/attackby(var/obj/item/D as obj, var/mob/user as mob) //Loading a disk into it. if(istype(D, /obj/item/disk)) if(t_disk || d_disk) to_chat(user, "A disk is already loaded into the machine.") return if(istype(D, /obj/item/disk/tech_disk)) t_disk = D else if (istype(D, /obj/item/disk/design_disk)) d_disk = D else to_chat(user, "Machine cannot accept disks in that format.") return user.drop_from_inventory(D,src) to_chat(user, "You add \the [D] to the machine.") else //The construction/deconstruction of the console code. ..() src.updateUsrDialog() return /obj/machinery/computer/rdconsole/emp_act(var/remaining_charges, var/mob/user) if(!emagged) playsound(src.loc, 'sound/effects/sparks4.ogg', 75, 1) emagged = 1 to_chat(user, "You you disable the security protocols.") return 1 /obj/machinery/computer/rdconsole/Topic(href, href_list) if(..()) return 1 add_fingerprint(usr) usr.set_machine(src) if(href_list["menu"]) //Switches menu screens. Converts a sent text string into a number. Saves a LOT of code. var/temp_screen = text2num(href_list["menu"]) if(temp_screen <= 1.1 || (3 <= temp_screen && 4.9 >= temp_screen) || allowed(usr) || emagged) //Unless you are making something, you need access. screen = temp_screen else to_chat(usr, "Unauthorized Access.") else if(href_list["updt_tech"]) //Update the research holder with information from the technology disk. screen = 0.0 spawn(50) screen = 1.2 files.AddTech2Known(t_disk.stored) updateUsrDialog() griefProtection() //Update centcomm too else if(href_list["clear_tech"]) //Erase data on the technology disk. t_disk.stored = null else if(href_list["eject_tech"]) //Eject the technology disk. t_disk.forceMove(loc) usr.put_in_hands(t_disk) t_disk = null screen = 1.0 else if(href_list["copy_tech"]) //Copys some technology data from the research holder to the disk. var/datum/tech/T = files.known_tech[href_list["copy_tech_sent"]] t_disk.stored = T screen = 1.2 else if(href_list["updt_design"]) //Updates the research holder with design data from the design disk. screen = 0.0 spawn(50) screen = 1.4 files.AddDesign2Known(d_disk.blueprint) updateUsrDialog() griefProtection() //Update centcomm too else if(href_list["clear_design"]) //Erases data on the design disk. d_disk.blueprint = null else if(href_list["eject_design"]) //Eject the design disk. d_disk.forceMove(loc) usr.put_in_hands(d_disk) d_disk = null screen = 1.0 else if(href_list["copy_design"]) //Copy design data from the research holder to the design disk. var/path = text2path(href_list["copy_design_sent"]) var/datum/design/D = files.known_designs[path] d_disk.blueprint = D screen = 1.4 else if(href_list["eject_item"]) //Eject the item inside the destructive analyzer. if(linked_destroy) if(linked_destroy.busy) to_chat(usr, "The destructive analyzer is busy at the moment.") else if(linked_destroy.loaded_item) linked_destroy.loaded_item.forceMove(linked_destroy.loc) if(linked_destroy.Adjacent(usr)) usr.put_in_hands(linked_destroy.loaded_item) linked_destroy.loaded_item = null linked_destroy.icon_state = "d_analyzer" screen = 2.1 else if(href_list["deconstruct"]) //Deconstruct the item in the destructive analyzer and update the research holder. if(linked_destroy) if(linked_destroy.busy) to_chat(usr, "The destructive analyzer is busy at the moment.") else if(alert("Proceeding will destroy loaded item. Continue?", "Destructive analyzer confirmation", "Yes", "No") == "No" || !linked_destroy) return linked_destroy.busy = 1 screen = 0.1 updateUsrDialog() flick("d_analyzer_process", linked_destroy) spawn(24) if(linked_destroy) linked_destroy.busy = 0 if(!linked_destroy.loaded_item) to_chat(usr, "The destructive analyzer appears to be empty.") screen = 1.0 return for(var/T in linked_destroy.loaded_item.origin_tech) files.UpdateTech(T, linked_destroy.loaded_item.origin_tech[T]) if(linked_lathe && linked_destroy.loaded_item.matter) // Also sends salvaged materials to a linked protolathe, if any. for(var/t in linked_destroy.loaded_item.matter) if(t in linked_lathe.materials) linked_lathe.materials[t] += min(linked_lathe.max_material_storage - linked_lathe.TotalMaterials(), linked_destroy.loaded_item.matter[t] * linked_destroy.decon_mod) linked_destroy.loaded_item = null for(var/obj/I in linked_destroy.contents) for(var/mob/M in I.contents) M.death() qdel(M) if(istype(I,/obj/item/stack/material))//Only deconsturcts one sheet at a time instead of the entire stack var/obj/item/stack/material/S = I if(S.get_amount() > 1) S.use(1) linked_destroy.loaded_item = S else qdel(S) linked_destroy.icon_state = "d_analyzer" else if(!(I in linked_destroy.component_parts)) qdel(I) linked_destroy.icon_state = "d_analyzer" use_power_oneoff(linked_destroy.active_power_usage) screen = 1.0 updateUsrDialog() else if(href_list["lock"]) //Lock the console from use by anyone without tox access. if(allowed(usr)) screen = text2num(href_list["lock"]) else to_chat(usr, "Unauthorized Access.") else if(href_list["sync"]) //Sync the research holder with all the R&D consoles in the game that aren't sync protected. screen = 0.0 if(!sync) to_chat(usr, "You must connect to the network first.") else griefProtection() //Putting this here because I dont trust the sync process addtimer(CALLBACK(src, PROC_REF(SyncTechs)), 30) else if(href_list["togglesync"]) //Prevents the console from being synced by other consoles. Can still send data. sync = !sync else if(href_list["protolathe_category"]) var/choice = tgui_input_list(usr, "Which category do you wish to display?", "Protolathe Categories", designs_protolathe_categories+"All") if(!choice) return protolathe_category = choice updateUsrDialog() else if(href_list["imprinter_category"]) var/choice = tgui_input_list(usr, "Which category do you wish to display?", "Printer Categories", designs_imprinter_categories+"All") if(!choice) return imprinter_category = choice updateUsrDialog() else if(href_list["build"]) //Causes the Protolathe to build something. if(linked_lathe) var/path = text2path(href_list["build"]) var/datum/design/D = files.known_designs[path] linked_lathe.addToQueue(D) screen = 3.1 updateUsrDialog() else if(href_list["imprint"]) //Causes the Circuit Imprinter to build something. if(linked_imprinter) var/path = text2path(href_list["imprint"]) var/datum/design/D = files.known_designs[path] linked_imprinter.addToQueue(D) screen = 4.1 updateUsrDialog() else if(href_list["disposeI"] && linked_imprinter) //Causes the circuit imprinter to dispose of a single reagent (all of it) linked_imprinter.reagents.del_reagent(href_list["dispose"]) else if(href_list["disposeallI"] && linked_imprinter) //Causes the circuit imprinter to dispose of all it's reagents. linked_imprinter.reagents.clear_reagents() else if(href_list["removeI"] && linked_lathe) linked_imprinter.removeFromQueue(text2num(href_list["removeI"])) else if(href_list["disposeP"] && linked_lathe) //Causes the protolathe to dispose of a single reagent (all of it) linked_lathe.reagents.del_reagent(href_list["dispose"]) else if(href_list["disposeallP"] && linked_lathe) //Causes the protolathe to dispose of all it's reagents. linked_lathe.reagents.clear_reagents() else if(href_list["removeP"] && linked_lathe) linked_lathe.removeFromQueue(text2num(href_list["removeP"])) else if(href_list["lathe_ejectsheet"] && linked_lathe) //Causes the protolathe to eject a sheet of material var/num_sheets = min(text2num(href_list["amount"]), round(linked_lathe.materials[href_list["lathe_ejectsheet"]] / SHEET_MATERIAL_AMOUNT)) if(num_sheets < 1) return var/mattype = linked_lathe.getMaterialType(href_list["lathe_ejectsheet"]) var/obj/item/stack/material/M = new mattype(linked_lathe.loc) M.amount = num_sheets linked_lathe.materials[href_list["lathe_ejectsheet"]] -= num_sheets * SHEET_MATERIAL_AMOUNT else if(href_list["imprinter_ejectsheet"] && linked_imprinter) //Causes the protolathe to eject a sheet of material var/num_sheets = min(text2num(href_list["amount"]), round(linked_imprinter.materials[href_list["imprinter_ejectsheet"]] / SHEET_MATERIAL_AMOUNT)) if(num_sheets < 1) return var/mattype = linked_imprinter.getMaterialType(href_list["imprinter_ejectsheet"]) var/obj/item/stack/material/M = new mattype(linked_imprinter.loc) M.amount = num_sheets linked_imprinter.materials[href_list["imprinter_ejectsheet"]] -= num_sheets * SHEET_MATERIAL_AMOUNT else if(href_list["find_device"]) //The R&D console looks for devices nearby to link up with. screen = 0.0 spawn(10) SyncRDevices() screen = 1.7 updateUsrDialog() else if(href_list["disconnect"]) //The R&D console disconnects with a specific device. switch(href_list["disconnect"]) if("destroy") linked_destroy.linked_console = null linked_destroy = null if("lathe") linked_lathe.linked_console = null linked_lathe = null if("imprinter") linked_imprinter.linked_console = null linked_imprinter = null else if(href_list["reset"]) //Reset the R&D console's database. griefProtection() var/choice = alert("R&D Console Database Reset", "Are you sure you want to reset the R&D console's database? Data lost cannot be recovered.", "Continue", "Cancel") if(choice == "Continue") screen = 0.0 qdel(files) files = new /datum/research(src) spawn(20) screen = 1.6 updateUsrDialog() else if (href_list["print"]) //Print research information screen = 0.5 spawn(20) var/obj/item/paper/PR = new/obj/item/paper var/pname = "list of researched technologies" var/info = "
[station_name()] Science Laboratories" info += "

[ (text2num(href_list["print"]) == 2) ? "Detailed" : null] Research Progress Report

" info += "report prepared at [worldtime2text()] station time

" if(text2num(href_list["print"]) == 2) info += GetResearchListInfo() else info += GetResearchLevelsInfo() PR.set_content_unsafe(pname, info) print(PR, user = usr) spawn(10) screen = ((text2num(href_list["print"]) == 2) ? 5.0 : 1.1) updateUsrDialog() updateUsrDialog() return /obj/machinery/computer/rdconsole/proc/GetResearchLevelsInfo() var/dat dat += "" if(1.2) //Technology Disk Menu dat += "Main Menu
" dat += "Disk Contents: (Technology Data Disk)

" dat += "" if(1.3) //Technology Disk submenu dat += "
Main Menu || " dat += "Return to Disk Operations
" dat += "" if(1.4) //Design Disk menu. dat += "Main Menu
" dat += "" if(1.5) //Technology disk submenu dat += "Main Menu || " dat += "Return to Disk Operations
" dat += "" if(1.6) //R&D console settings dat += "Main Menu
" dat += "R&D Console Setting:
" dat += "" if(1.7) //R&D device linkage dat += "Main Menu || " dat += "Settings Menu
" dat += "R&D Console Device Linkage Menu:
" dat += "" ////////////////////DESTRUCTIVE ANALYZER SCREENS//////////////////////////// if(2.0) dat += "Main Menu
" dat += "NO DESTRUCTIVE ANALYZER LINKED TO CONSOLE

" if(2.1) dat += "Main Menu
" dat += "No Item Loaded. Standing-by...

" if(2.2) dat += "Main Menu
" dat += "Deconstruction Menu
" dat += "Name: [linked_destroy.loaded_item.name]
" dat += "Origin Tech:" dat += "" if(!istype(linked_destroy.loaded_item, /obj/item/stack)) dat += "
Deconstruct Item || " else dat += "
Deconstruct One In Stack || " dat += "Eject Item" /////////////////////PROTOLATHE SCREENS///////////////////////// if(3.0) dat += "Main Menu
" dat += "NO PROTOLATHE LINKED TO CONSOLE

" if(3.1) dat += "Main Menu || " dat += "View Queue || " dat += "Material Storage || " dat += "Chemical Storage
" dat += "Protolathe Menu:
" dat += "Material Amount: [linked_lathe.TotalMaterials()] cm3 (MAX: [linked_lathe.max_material_storage])
" dat += "Chemical Volume: [linked_lathe.reagents.total_volume] (MAX: [linked_lathe.reagents.maximum_volume])
" dat += "Category: [protolathe_category]
" dat += "
" dat += "" dat += "
" if(3.2) //Protolathe Material Storage Sub-menu dat += "Main Menu || " dat += "Protolathe Menu
" dat += "Material Storage

" dat += "" if(3.3) //Protolathe Chemical Storage Submenu dat += "Main Menu || " dat += "Protolathe Menu
" dat += "Chemical Storage

" for(var/_R in linked_lathe.reagents.reagent_volumes) var/singleton/reagent/R = GET_SINGLETON(_R) dat += "Name: [R.name] | Units: [linked_lathe.reagents.reagent_volumes[_R]] " dat += "(Purge)
" dat += "Disposal All Chemicals in Storage
" if(3.4) // Protolathe queue dat += "Main Menu || " dat += "Protolathe Menu
" dat += "Queue

" if(!linked_lathe.queue.len) dat += "Empty" else var/tmp = 1 for(var/datum/design/D in linked_lathe.queue) if(tmp == 1) if(linked_lathe.busy) dat += "1: [D.name]
" else dat += "1: [D.name] (Awaiting materials) Remove
" else dat += "[tmp]: [D.name] Remove
" ++tmp ///////////////////CIRCUIT IMPRINTER SCREENS//////////////////// if(4.0) dat += "Main Menu
" dat += "NO CIRCUIT IMPRINTER LINKED TO CONSOLE

" if(4.1) dat += "Main Menu || " dat += "View Queue || " dat += "Material Storage || " dat += "Chemical Storage
" dat += "Circuit Imprinter Menu:

" dat += "Material Amount: [linked_imprinter.TotalMaterials()] cm3
" dat += "Chemical Volume: [linked_imprinter.reagents.total_volume]
" dat += "Category: [imprinter_category]
" dat += "
" dat += "" dat += "
" if(4.2) dat += "Main Menu || " dat += "Imprinter Menu
" dat += "Chemical Storage

" for(var/_R in linked_imprinter.reagents.reagent_volumes) var/singleton/reagent/R = GET_SINGLETON(_R) dat += "Name: [R.name] | Units: [linked_imprinter.reagents.reagent_volumes[_R]] " dat += "(Purge)
" dat += "Disposal All Chemicals in Storage
" if(4.3) dat += "Main Menu || " dat += "Circuit Imprinter Menu
" dat += "Material Storage

" dat += "" if(4.4) dat += "Main Menu || " dat += "Circuit Imprinter Menu
" dat += "Queue

" if(linked_imprinter.queue.len == 0) dat += "Empty" else var/tmp = 1 for(var/datum/design/D in linked_imprinter.queue) if(tmp == 1) dat += "1: [D.name]
" else dat += "[tmp]: [D.name] Remove
" ++tmp ///////////////////Research Information Browser//////////////////// if(5.0) dat += "Main Menu || " dat += "Print This Page
" dat += "List of Researched Technologies and Designs:
" dat += GetResearchListInfo() var/datum/browser/rdconsole = new(user, "rdconsole", "Research and Development Console", 850, 600) rdconsole.add_stylesheet("rdconsole", 'html/browser/rdconsole.css') rdconsole.set_content(dat) rdconsole.open() /obj/machinery/computer/rdconsole/robotics name = "robotics R&D console" id = 1 req_access = list(access_robotics) allow_analyzer = FALSE /obj/machinery/computer/rdconsole/core name = "core R&D console" desc = "A console which is used to operate various research devices. It is the backbone of any megacorporate research division." id = 1