Ports Modular Computers from Baystation

This is just the initial parts. Additional work will probably be necessary.
This commit is contained in:
Unknown
2019-04-02 21:06:37 -04:00
parent f8a5d17597
commit cce3116c3a
94 changed files with 4659 additions and 48 deletions
@@ -0,0 +1,59 @@
// This device is wrapper for actual power cell. I have decided to not use power cells directly as even low-end cells available on station
// have tremendeous capacity in comparsion. Higher tier cells would provide your device with nearly infinite battery life, which is something i want to avoid.
/obj/item/weapon/computer_hardware/battery_module
name = "standard battery"
desc = "A standard power cell, commonly seen in high-end portable microcomputers or low-end laptops. It's rating is 750."
icon_state = "battery_normal"
critical = 1
var/battery_rating = 750
var/obj/item/weapon/cell/battery = null
/obj/item/weapon/computer_hardware/battery_module/advanced
name = "advanced battery"
desc = "An advanced power cell, often used in most laptops. It is too large to be fitted into smaller devices. It's rating is 1100."
icon_state = "battery_advanced"
hardware_size = 2
battery_rating = 1100
/obj/item/weapon/computer_hardware/battery_module/super
name = "super battery"
desc = "A very advanced power cell, often used in high-end devices, or as uninterruptable power supply for important consoles or servers. It's rating is 1500."
icon_state = "battery_super"
hardware_size = 2
battery_rating = 1500
/obj/item/weapon/computer_hardware/battery_module/ultra
name = "ultra battery"
desc = "A very advanced large power cell. It's often used as uninterruptable power supply for critical consoles or servers. It's rating is 2000."
icon_state = "battery_ultra"
hardware_size = 3
battery_rating = 2000
/obj/item/weapon/computer_hardware/battery_module/micro
name = "micro battery"
desc = "A small power cell, commonly seen in most portable microcomputers. It's rating is 500."
icon_state = "battery_micro"
battery_rating = 500
/obj/item/weapon/computer_hardware/battery_module/nano
name = "nano battery"
desc = "A tiny power cell, commonly seen in low-end portable microcomputers. It's rating is 300."
icon_state = "battery_nano"
battery_rating = 300
// This is not intended to be obtainable in-game. Intended for adminbus and debugging purposes.
/obj/item/weapon/computer_hardware/battery_module/lambda
name = "lambda coil"
desc = "A very complex device that creates it's own bluespace dimension. This dimension may be used to store massive amounts of energy."
icon_state = "battery_lambda"
hardware_size = 1
battery_rating = 1000000
/obj/item/weapon/computer_hardware/battery_module/New()
battery = new/obj/item/weapon/cell(src)
battery.maxcharge = battery_rating
battery.charge = battery_rating
..()
@@ -0,0 +1,16 @@
/obj/item/weapon/computer_hardware/card_slot
name = "RFID card slot"
desc = "Slot that allows this computer to write data on RFID cards. Necessary for some programs to run properly."
power_usage = 10 //W
critical = 0
icon_state = "cardreader"
hardware_size = 1
var/obj/item/weapon/card/id/stored_card = null
/obj/item/weapon/computer_hardware/card_slot/Destroy()
if(holder2 && (holder2.card_slot == src))
holder2.card_slot = null
stored_card.loc = get_turf(holder2)
holder2 = null
..()
@@ -0,0 +1,146 @@
/obj/item/weapon/computer_hardware/hard_drive/
name = "basic hard drive"
desc = "A small power efficient solid state drive, with 128GQ of storage capacity for use in basic computers where power efficiency is desired."
power_usage = 25 // SSD or something with low power usage
icon_state = "hdd_normal"
hardware_size = 1
var/max_capacity = 128
var/used_capacity = 0
var/list/stored_files = list() // List of stored files on this drive. DO NOT MODIFY DIRECTLY!
/obj/item/weapon/computer_hardware/hard_drive/advanced
name = "advanced hard drive"
desc = "A small hybrid hard drive with 256GQ of storage capacity for use in higher grade computers where balance between power efficiency and capacity is desired."
max_capacity = 256
power_usage = 50 // Hybrid, medium capacity and medium power storage
icon_state = "hdd_advanced"
hardware_size = 2
/obj/item/weapon/computer_hardware/hard_drive/super
name = "super hard drive"
desc = "A small hard drive with 512GQ of storage capacity for use in cluster storage solutions where capacity is more important than power efficiency."
max_capacity = 512
power_usage = 100 // High-capacity but uses lots of power, shortening battery life. Best used with APC link.
icon_state = "hdd_super"
hardware_size = 2
/obj/item/weapon/computer_hardware/hard_drive/cluster
name = "cluster hard drive"
desc = "A large storage cluster consisting of multiple hard drives for usage in high capacity storage systems. Has capacity of 2048 GQ."
power_usage = 500
max_capacity = 2048
icon_state = "hdd_cluster"
hardware_size = 3
// For tablets, etc. - highly power efficient.
/obj/item/weapon/computer_hardware/hard_drive/small
name = "small hard drive"
desc = "A small highly efficient solid state drive for portable devices."
power_usage = 10
max_capacity = 64
icon_state = "hdd_small"
hardware_size = 1
/obj/item/weapon/computer_hardware/hard_drive/micro
name = "micro hard drive"
desc = "A small micro hard drive for portable devices."
power_usage = 2
max_capacity = 32
icon_state = "hdd_micro"
hardware_size = 1
// Use this proc to add file to the drive. Returns 1 on success and 0 on failure. Contains necessary sanity checks.
/obj/item/weapon/computer_hardware/hard_drive/proc/store_file(var/datum/computer_file/F)
if(!F || !istype(F))
return 0
if(!can_store_file(F.size))
return 0
if(!stored_files)
return 0
// This file is already stored. Don't store it again.
if(F in stored_files)
return 0
F.holder = src
stored_files.Add(F)
recalculate_size()
return 1
// Use this proc to add file to the drive. Returns 1 on success and 0 on failure. Contains necessary sanity checks.
/obj/item/weapon/computer_hardware/hard_drive/proc/install_default_programs()
store_file(new/datum/computer_file/program/computerconfig(src)) // Computer configuration utility, allows hardware control and displays more info than status bar
store_file(new/datum/computer_file/program/ntnetdownload(src)) // NTNet Downloader Utility, allows users to download more software from NTNet repository
store_file(new/datum/computer_file/program/filemanager(src)) // File manager, allows text editor functions and basic file manipulation.
// Use this proc to remove file from the drive. Returns 1 on success and 0 on failure. Contains necessary sanity checks.
/obj/item/weapon/computer_hardware/hard_drive/proc/remove_file(var/datum/computer_file/F)
if(!F || !istype(F))
return 0
if(!stored_files)
return 0
if(F in stored_files)
stored_files -= F
recalculate_size()
return 1
else
return 0
// Loops through all stored files and recalculates used_capacity of this drive
/obj/item/weapon/computer_hardware/hard_drive/proc/recalculate_size()
var/total_size = 0
for(var/datum/computer_file/F in stored_files)
total_size += F.size
used_capacity = total_size
// Checks whether file can be stored on the hard drive.
/obj/item/weapon/computer_hardware/hard_drive/proc/can_store_file(var/size = 1)
// In the unlikely event someone manages to create that many files.
// BYOND is acting weird with numbers above 999 in loops (infinite loop prevention)
if(stored_files.len >= 999)
return 0
if(used_capacity + size > max_capacity)
return 0
else
return 1
// Checks whether we can store the file. We can only store unique files, so this checks whether we wouldn't get a duplicity by adding a file.
/obj/item/weapon/computer_hardware/hard_drive/proc/try_store_file(var/datum/computer_file/F)
if(!F || !istype(F))
return 0
var/name = F.filename + "." + F.filetype
for(var/datum/computer_file/file in stored_files)
if((file.filename + "." + file.filetype) == name)
return 0
return can_store_file(F.size)
// Tries to find the file by filename. Returns null on failure
/obj/item/weapon/computer_hardware/hard_drive/proc/find_file_by_name(var/filename)
if(!filename)
return null
if(!stored_files)
return null
for(var/datum/computer_file/F in stored_files)
if(F.filename == filename)
return F
return null
/obj/item/weapon/computer_hardware/hard_drive/Destroy()
if(holder2 && (holder2.hard_drive == src))
holder2.hard_drive = null
stored_files = null
..()
/obj/item/weapon/computer_hardware/hard_drive/New()
install_default_programs()
..()
@@ -0,0 +1,23 @@
/obj/item/weapon/computer_hardware/
name = "Hardware"
desc = "Unknown Hardware"
icon = 'icons/obj/modular_components.dmi'
var/obj/item/modular_computer/holder2 = null
var/power_usage = 0 // If the hardware uses extra power, change this.
var/enabled = 1 // If the hardware is turned off set this to 0.
var/critical = 1 // Prevent disabling for important component, like the HDD.
var/hardware_size = 1 // Limits which devices can contain this component. 1: Tablets/Laptops/Consoles, 2: Laptops/Consoles, 3: Consoles only
/obj/item/weapon/computer_hardware/New(var/obj/L)
if(istype(L, /obj/machinery/modular_computer))
var/obj/machinery/modular_computer/C = L
if(C.cpu)
holder2 = C.cpu
return
if(istype(L, /obj/item/modular_computer))
holder2 = L
return
/obj/item/weapon/computer_hardware/Destroy()
holder2 = null
..()
@@ -0,0 +1,59 @@
/obj/item/weapon/computer_hardware/nano_printer
name = "nano printer"
desc = "Small integrated printer with scanner and paper recycling module."
power_usage = 50
icon_state = "printer"
hardware_size = 1
var/stored_paper = 5
var/max_paper = 10
var/obj/item/weapon/paper/P = null // Currently stored paper for scanning.
/obj/item/weapon/computer_hardware/nano_printer/proc/print_text(var/text_to_print)
if(!stored_paper)
return 0
// Recycle stored paper
if(P)
stored_paper++
qdel(P)
P = null
P = new/obj/item/weapon/paper(get_turf(holder2))
P.info = text_to_print
P.update_icon()
stored_paper--
P = null
return 1
/obj/item/weapon/computer_hardware/nano_printer/proc/load_paper(var/obj/item/weapon/paper/paper)
if(!paper || !istype(paper))
return 0
// We already have paper loaded, recycle it.
if(P && try_recycle_paper())
P = paper
P.forceMove(holder2)
/obj/item/weapon/computer_hardware/nano_printer/proc/try_recycle_paper()
if(!P)
return 0
if(stored_paper >= max_paper)
return 0
qdel(P)
P = null
return 1
/obj/item/weapon/computer_hardware/nano_printer/Destroy()
if(holder2 && (holder2.nano_printer == src))
holder2.nano_printer = null
if(P)
if(holder2)
P.forceMove(get_turf(holder2))
else
qdel(P)
P = null
holder2 = null
..()
@@ -0,0 +1,73 @@
var/global/ntnet_card_uid = 1
/obj/item/weapon/computer_hardware/network_card/
name = "basic NTNet network card"
desc = "A basic network card for usage with standard NTNet frequencies."
power_usage = 50
critical = 0
icon_state = "netcard_basic"
hardware_size = 1
var/identification_id = null // Identification ID. Technically MAC address of this device. Can't be changed by user.
var/identification_string = "" // Identification string, technically nickname seen in the network. Can be set by user.
var/long_range = 0
var/ethernet = 0 // Hard-wired, therefore always on, ignores NTNet wireless checks.
/obj/item/weapon/computer_hardware/network_card/New(var/l)
..(l)
identification_id = ntnet_card_uid
ntnet_card_uid++
/obj/item/weapon/computer_hardware/network_card/advanced
name = "advanced NTNet network card"
desc = "An advanced network card for usage with standard NTNet frequencies. It's transmitter is strong enough to connect even off-station."
long_range = 1
power_usage = 100 // Better range but higher power usage.
icon_state = "netcard_advanced"
hardware_size = 1
/obj/item/weapon/computer_hardware/network_card/wired
name = "wired NTNet network card"
desc = "An advanced network card for usage with NTNet. This one uses wired connection."
ethernet = 1
power_usage = 100 // Better range but higher power usage.
icon_state = "netcard_ethernet"
hardware_size = 3
/obj/item/weapon/computer_hardware/network_card/Destroy()
if(holder2 && (holder2.network_card == src))
holder2.network_card = null
holder2 = null
..()
// Returns a string identifier of this network card
/obj/item/weapon/computer_hardware/network_card/proc/get_network_tag()
return "[identification_string] (NID [identification_id])"
// 0 - No signal, 1 - Low signal, 2 - High signal. 3 - Wired Connection
/obj/item/weapon/computer_hardware/network_card/proc/get_signal(var/specific_action = 0)
if(!holder2) // Hardware is not installed in anything. No signal. How did this even get called?
return 0
if(!enabled)
return 0
if(ethernet) // Computer is connected via wired connection.
return 3
if(!ntnet_global || !ntnet_global.check_function(specific_action)) // NTNet is down and we are not connected via wired connection. No signal.
return 0
if(holder2)
var/turf/T = get_turf(holder2)
if((T && istype(T)) && T.z in using_map.station_levels)
return 2
if(long_range) // Computer is not on station, but it has upgraded network card. Low signal.
return 1
return 0 // Computer is not on station and does not have upgraded network card. No signal.
/obj/item/weapon/computer_hardware/network_card/Destroy()
if(holder2 && (holder2.network_card == src))
holder2.network_card = null
..()
@@ -0,0 +1,31 @@
// These are basically USB data sticks and may be used to transfer files between devices
/obj/item/weapon/computer_hardware/hard_drive/portable/
name = "basic data crystal"
desc = "Small crystal with imprinted photonic circuits that can be used to store data. It's capacity is 16 GQ"
power_usage = 10
icon_state = "flashdrive_basic"
hardware_size = 1
max_capacity = 16
/obj/item/weapon/computer_hardware/hard_drive/portable/advanced
name = "advanced data crystal"
desc = "Small crystal with imprinted high-density photonic circuits that can be used to store data. It's capacity is 64 GQ"
power_usage = 20
icon_state = "flashdrive_advanced"
hardware_size = 1
max_capacity = 64
/obj/item/weapon/computer_hardware/hard_drive/portable/super
name = "super data crystal"
desc = "Small crystal with imprinted ultra-density photonic circuits that can be used to store data. It's capacity is 256 GQ"
power_usage = 40
icon_state = "flashdrive_super"
hardware_size = 1
max_capacity = 256
/obj/item/weapon/computer_hardware/hard_drive/portable/New()
..()
stored_files = list()
recalculate_size()
@@ -0,0 +1,19 @@
/obj/item/weapon/computer_hardware/tesla_link
name = "tesla link"
desc = "An advanced tesla link that wirelessly recharges connected device from nearby area power controller."
critical = 0
enabled = 0 // Starts turned off
icon_state = "teslalink"
hardware_size = 2 // Can't be installed into tablets
var/obj/machinery/modular_computer/holder
/obj/item/weapon/computer_hardware/tesla_link/New(var/obj/L)
if(istype(L, /obj/machinery/modular_computer))
holder = L
return
..(L)
/obj/item/weapon/computer_hardware/tesla_link/Destroy()
if(holder && (holder.tesla_link == src))
holder.tesla_link = null
..()