Files
CHOMPStation2/code/modules/research/rdconsole.dm
CHOMPStation2 ab154b48b2 [MIRROR] refactors most spans (#9139)
Co-authored-by: Heroman3003 <31296024+Heroman3003@users.noreply.github.com>
Co-authored-by: Kashargul <KashL@t-online.de>
2024-10-04 15:00:17 +02:00

232 lines
8.6 KiB
Plaintext
Executable File

/*
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"
desc = "Science, in a computer! Experiment results not guaranteed."
icon_keyboard = "rd_key"
icon_screen = "rdcomp"
light_color = "#a97faa"
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/list/LockedLatheDesigns = list() //CHOMPADDITION: FOR VR mainly.
var/list/LockedPrinterDesigns = list() //CHOMPADDITION: FOR VR mainly.
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/is_public = FALSE //Above mentions the option for public consoles. But for that, we need to remove the sync tab from the console entirely
req_access = list(access_research) //Data and setting manipulation requires scientist access.
var/protofilter //String to filter protolathe designs by
var/circuitfilter //String to filter circuit designs by
/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"
return return_name
/obj/machinery/computer/rdconsole/proc/CallReagentName(var/ID)
var/return_name = ID
for(var/datum/reagent/R in SSchemistry.chemical_reagents)
if(R.id == ID)
return_name = R.name
break
return return_name
/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))
if(linked_destroy == null)
linked_destroy = D
D.linked_console = src
else if(istype(D, /obj/machinery/r_n_d/protolathe))
if(linked_lathe == null)
linked_lathe = D
D.linked_console = src
linked_lathe.LockedDesigns.Cut()
linked_lathe.LockedDesigns = LockedLatheDesigns.Copy();
else if(istype(D, /obj/machinery/r_n_d/circuit_imprinter))
if(linked_imprinter == null)
linked_imprinter = D
D.linked_console = src
linked_imprinter.LockedDesigns.Cut()
linked_imprinter.LockedDesigns = LockedPrinterDesigns.Copy();
return
/obj/machinery/computer/rdconsole/proc/griefProtection() //Have it automatically push research to the CentCom server so wild griffins can't fuck up R&D's work
for(var/obj/machinery/r_n_d/server/centcom/C in machines)
for(var/datum/tech/T in files.known_tech)
C.files.AddTech2Known(T)
for(var/datum/design/D in files.known_designs)
C.files.AddDesign2Known(D)
C.files.RefreshResearch()
/obj/machinery/computer/rdconsole/New()
..()
files = new /datum/research(src) //Setup the research data holder.
if(!id)
for(var/obj/machinery/r_n_d/server/centcom/S in machines)
S.update_connections()
break
/obj/machinery/computer/rdconsole/Initialize()
SyncRDevices()
. = ..()
/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, span_filter_notice("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, span_notice("Machine cannot accept disks in that format."))
return
user.drop_item()
D.loc = src
to_chat(user, span_notice("You add \the [D] to the machine."))
else
//The construction/deconstruction of the console code.
..()
SStgui.update_uis(src)
return
/obj/machinery/computer/rdconsole/dismantle()
if(linked_destroy)
linked_destroy.linked_console = null
if(linked_lathe)
linked_lathe.linked_console = null
if(linked_imprinter)
linked_imprinter.linked_console = null
..()
/obj/machinery/computer/rdconsole/emp_act(var/remaining_charges, var/mob/user)
if(!emagged)
playsound(src, 'sound/effects/sparks4.ogg', 75, 1)
emagged = 1
to_chat(user, span_notice("You disable the security protocols."))
return 1
/obj/machinery/computer/rdconsole/proc/GetResearchLevelsInfo()
var/list/dat = list()
dat += "<UL>"
for(var/datum/tech/T in files.known_tech)
if(T.level < 1)
continue
dat += "<LI>"
dat += "[T.name]"
dat += "<UL>"
dat += "<LI>Level: [T.level]"
dat += "<LI>Summary: [T.desc]"
dat += "</UL>"
return dat.Join()
/obj/machinery/computer/rdconsole/proc/GetResearchListInfo()
var/list/dat = list()
dat += "<UL>"
for(var/datum/design/D in files.known_designs)
if(D.build_path)
dat += "<LI><B>[D.name]</B>: [D.desc]"
dat += "</UL>"
return dat.Join()
/obj/machinery/computer/rdconsole/attack_hand(mob/user as mob)
if(stat & (BROKEN|NOPOWER))
return
tgui_interact(user) // TODO: remove the other UI
/obj/machinery/computer/rdconsole/robotics
name = "Robotics R&D Console"
id = 2
req_access = list(access_robotics)
/obj/machinery/computer/rdconsole/core
name = "Core R&D Console"
id = 1
// CHOMPAdd Start - Departmental lathes
/obj/machinery/computer/rdconsole/engineering
name = "Engineering Protolathe Console"
id = 3
req_access = list(access_engine)
/obj/machinery/computer/rdconsole/medical
name = "Medical Protolathe Console"
id = 4
req_access = list(access_medical)
/obj/machinery/computer/rdconsole/cargo
name = "Cargo Protolathe Console"
id = 5
req_access = list(access_cargo)
/obj/machinery/computer/rdconsole/service
name = "Service Protolathe Console"
id = 6
req_access = list(access_bar, access_janitor, access_library)
/obj/machinery/computer/rdconsole/security
name = "Security Protolathe Console"
id = 7
req_access = list(access_security)
// CHOMPEnd