Modular Cmp Updates

This commit is contained in:
Letter N
2021-02-12 18:29:00 +08:00
parent 5db87b9065
commit 5b0a1077f4
46 changed files with 1311 additions and 318 deletions

View File

@@ -24,8 +24,8 @@
/obj/item/computer_hardware/New(obj/L)
..()
pixel_x = rand(-8, 8)
pixel_y = rand(-8, 8)
pixel_x = base_pixel_x + rand(-8, 8)
pixel_y = base_pixel_y + rand(-8, 8)
/obj/item/computer_hardware/Destroy()
if(holder)
@@ -94,12 +94,20 @@
// Called when component is removed from PC.
/obj/item/computer_hardware/proc/on_remove(obj/item/modular_computer/M, mob/living/user = null)
try_eject(forced = 1)
try_eject(forced = TRUE)
// Called when someone tries to insert something in it - paper in printer, card in card reader, etc.
/obj/item/computer_hardware/proc/try_insert(obj/item/I, mob/living/user = null)
return FALSE
// Called when someone tries to eject something from it - card from card reader, etc.
/obj/item/computer_hardware/proc/try_eject(slot=0, mob/living/user = null, forced = 0)
/**
* Implement this when your hardware contains an object that the user can eject.
*
* Examples include ejecting cells from battery modules, ejecting an ID card from a card reader
* or ejecting an Intellicard from an AI card slot.
* Arguments:
* * user - The mob requesting the eject.
* * forced - Whether this action should be forced in some way.
*/
/obj/item/computer_hardware/proc/try_eject(mob/living/user = null, forced = FALSE)
return FALSE

View File

@@ -12,7 +12,7 @@
/obj/item/computer_hardware/ai_slot/handle_atom_del(atom/A)
if(A == stored_card)
try_eject(0, null, TRUE)
try_eject(forced = TRUE)
. = ..()
/obj/item/computer_hardware/ai_slot/examine(mob/user)
@@ -39,7 +39,7 @@
return TRUE
/obj/item/computer_hardware/ai_slot/try_eject(mob/living/user = null,forced = FALSE)
/obj/item/computer_hardware/ai_slot/try_eject(mob/living/user = null, forced = FALSE)
if(!stored_card)
to_chat(user, "<span class='warning'>There is no card in \the [src].</span>")
return FALSE
@@ -65,5 +65,5 @@
return
if(I.tool_behaviour == TOOL_SCREWDRIVER)
to_chat(user, "<span class='notice'>You press down on the manual eject button with \the [I].</span>")
try_eject(,user,1)
try_eject(user, TRUE)
return

View File

@@ -1,5 +1,5 @@
/obj/item/computer_hardware/card_slot
name = "identification card authentication module" // \improper breaks the find_hardware_by_name proc
name = "primary RFID card module" // \improper breaks the find_hardware_by_name proc
desc = "A module allowing this computer to read or write data on ID cards. Necessary for some programs to run properly."
power_usage = 10 //W
icon_state = "card_mini"
@@ -14,7 +14,7 @@
. = ..()
/obj/item/computer_hardware/card_slot/Destroy()
try_eject()
try_eject(forced = TRUE)
return ..()
/obj/item/computer_hardware/card_slot/GetAccess()
@@ -100,14 +100,16 @@
to_chat(user, "<span class='notice'>You adjust the connecter to fit into [expansion_hw ? "an expansion bay" : "the primary ID bay"].</span>")
/**
*Swaps the card_slot hardware between using the dedicated card slot bay on a computer, and using an expansion bay.
*Swaps the card_slot hardware between using the dedicated card slot bay on a computer, and using an expansion bay.
*/
/obj/item/computer_hardware/card_slot/proc/swap_slot()
expansion_hw = !expansion_hw
if(expansion_hw)
device_type = MC_CARD2
name = "secondary RFID card module"
else
device_type = MC_CARD
name = "primary RFID card module"
/obj/item/computer_hardware/card_slot/examine(mob/user)
. = ..()
@@ -116,5 +118,6 @@
. += "There appears to be something loaded in the card slots."
/obj/item/computer_hardware/card_slot/secondary
name = "secondary RFID card module"
device_type = MC_CARD2
expansion_hw = TRUE

View File

@@ -31,43 +31,43 @@
// Use this proc to add file to the drive. Returns 1 on success and 0 on failure. Contains necessary sanity checks.
/obj/item/computer_hardware/hard_drive/proc/store_file(datum/computer_file/F)
if(!F || !istype(F))
return 0
return FALSE
if(!can_store_file(F))
return 0
return FALSE
if(!check_functionality())
return 0
return FALSE
if(!stored_files)
return 0
return FALSE
// This file is already stored. Don't store it again.
if(F in stored_files)
return 0
return FALSE
F.holder = src
stored_files.Add(F)
recalculate_size()
return 1
return TRUE
// Use this proc to remove file from the drive. Returns 1 on success and 0 on failure. Contains necessary sanity checks.
/obj/item/computer_hardware/hard_drive/proc/remove_file(datum/computer_file/F)
if(!F || !istype(F))
return 0
return FALSE
if(!stored_files)
return 0
return FALSE
if(!check_functionality())
return 0
return FALSE
if(F in stored_files)
stored_files -= F
recalculate_size()
return 1
return TRUE
else
return 0
return FALSE
// Loops through all stored files and recalculates used_capacity of this drive
/obj/item/computer_hardware/hard_drive/proc/recalculate_size()
@@ -80,24 +80,24 @@
// Checks whether file can be stored on the hard drive. We can only store unique files, so this checks whether we wouldn't get a duplicity by adding a file.
/obj/item/computer_hardware/hard_drive/proc/can_store_file(datum/computer_file/F)
if(!F || !istype(F))
return 0
return FALSE
if(F in stored_files)
return 0
return FALSE
var/name = F.filename + "." + F.filetype
for(var/datum/computer_file/file in stored_files)
if((file.filename + "." + file.filetype) == name)
return 0
return FALSE
// 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
return FALSE
if((used_capacity + F.size) > max_capacity)
return 0
return FALSE
else
return 1
return TRUE
// Tries to find the file by filename. Returns null on failure
@@ -157,7 +157,14 @@
max_capacity = 64
icon_state = "ssd_mini"
w_class = WEIGHT_CLASS_TINY
custom_price = 150
custom_price = PAYCHECK_MEDIUM * 2
// For borg integrated tablets. No downloader.
/obj/item/computer_hardware/hard_drive/small/integrated/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/filemanager(src)) // File manager, allows text editor functions and basic file manipulation.
store_file(new /datum/computer_file/program/robotact(src))
// Syndicate variant - very slight better
/obj/item/computer_hardware/hard_drive/small/syndicate

View File

@@ -77,3 +77,23 @@
power_usage = 100 // Better range but higher power usage.
icon_state = "net_wired"
w_class = WEIGHT_CLASS_NORMAL
/obj/item/computer_hardware/network_card/integrated //Borg tablet version, only works while the borg has power and is not locked
name = "cyborg data link"
/obj/item/computer_hardware/network_card/integrated/get_signal(specific_action = 0)
var/obj/item/modular_computer/tablet/integrated/modularInterface = holder
if(!modularInterface || !istype(modularInterface))
return FALSE //wrong type of tablet
if(!modularInterface.borgo)
return FALSE //No borg found
if(modularInterface.borgo.lockcharge)
return FALSE //lockdown restricts borg networking
if(!modularInterface.borgo.cell || modularInterface.borgo.cell.charge == 0)
return FALSE //borg cell dying restricts borg networking
return ..()

View File

@@ -4,7 +4,7 @@
power_usage = 10
icon_state = "datadisk6"
w_class = WEIGHT_CLASS_TINY
critical = 0
critical = FALSE
max_capacity = 16
device_type = MC_SDD

View File

@@ -6,8 +6,8 @@
/obj/item/computer_hardware/recharger/proc/use_power(amount, charging=0)
if(charging)
return 1
return 0
return TRUE
return FALSE
/obj/item/computer_hardware/recharger/process()
..()
@@ -23,28 +23,28 @@
holder.give_power(charge_rate * GLOB.CELLRATE)
/obj/item/computer_hardware/recharger/APC
/obj/item/computer_hardware/recharger/apc_recharger
name = "area power connector"
desc = "A device that wirelessly recharges connected device from nearby APC."
icon_state = "charger_APC"
w_class = WEIGHT_CLASS_SMALL // Can't be installed into tablets/PDAs
/obj/item/computer_hardware/recharger/APC/use_power(amount, charging=0)
/obj/item/computer_hardware/recharger/apc_recharger/use_power(amount, charging=0)
if(ismachinery(holder.physical))
var/obj/machinery/M = holder.physical
if(M.powered())
M.use_power(amount)
return 1
return TRUE
else
var/area/A = get_area(src)
if(!istype(A))
return 0
return FALSE
if(A.powered(EQUIP))
A.use_power(amount, EQUIP)
return 1
return 0
return TRUE
return FALSE
/obj/item/computer_hardware/recharger/wired
name = "wired power connector"
@@ -56,27 +56,34 @@
if(ismachinery(M.physical) && M.physical.anchored)
return ..()
to_chat(user, "<span class='warning'>\The [src] is incompatible with portable computers!</span>")
return 0
return FALSE
/obj/item/computer_hardware/recharger/wired/use_power(amount, charging=0)
if(ismachinery(holder.physical) && holder.physical.anchored)
var/obj/machinery/M = holder.physical
var/turf/T = M.loc
if(!T || !istype(T))
return 0
return FALSE
var/obj/structure/cable/C = T.get_cable_node()
if(!C || !C.powernet)
return 0
return FALSE
var/power_in_net = C.powernet.avail-C.powernet.load
if(power_in_net && power_in_net > amount)
C.powernet.load += amount
return 1
return TRUE
return FALSE
return 0
/// This recharger exists only in borg built-in tablets. I would have tied it to the borg's cell but
/// the program that displays laws should always be usable, and the exceptions were starting to pile.
/obj/item/computer_hardware/recharger/cyborg
name = "modular interface power harness"
desc = "A standard connection to power a small computer device from a cyborg's chassis."
/obj/item/computer_hardware/recharger/cyborg/use_power(amount, charging=0)
return TRUE
// This is not intended to be obtainable in-game. Intended for adminbus and debugging purposes.