mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-22 20:48:56 +01:00
Converts most spans into span procs. Mostly used regex for this and sorted out any compile time errors afterwards so there could be some bugs. Was initially going to do defines, but ninja said to make it into a proc, and if there's any overhead, they can easily be changed to defines. Makes it easier to control the formatting and prevents typos when creating spans as it'll runtime if you misspell instead of silently failing. Reduces the code you need to write when writing spans, as you don't need to close the span as that's automatically handled by the proc. (Note from Lemon: This should be converted to defines once we update the minimum version to 514. Didn't do it now because byond pain and such)
100 lines
3.1 KiB
Plaintext
100 lines
3.1 KiB
Plaintext
/obj/item/computer_hardware/recharger
|
|
critical = 1
|
|
enabled = 1
|
|
var/charge_rate = 100
|
|
device_type = MC_CHARGE
|
|
|
|
/obj/item/computer_hardware/recharger/proc/use_power(amount, charging=0)
|
|
if(charging)
|
|
return TRUE
|
|
return FALSE
|
|
|
|
/obj/item/computer_hardware/recharger/process()
|
|
..()
|
|
var/obj/item/computer_hardware/battery/battery_module = holder.all_components[MC_CELL]
|
|
if(!holder || !battery_module || !battery_module.battery)
|
|
return
|
|
|
|
var/obj/item/stock_parts/cell/cell = battery_module.battery
|
|
if(cell.charge >= cell.maxcharge)
|
|
return
|
|
|
|
if(use_power(charge_rate, charging=1))
|
|
holder.give_power(charge_rate * GLOB.CELLRATE)
|
|
|
|
|
|
/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_recharger/use_power(amount, charging=0)
|
|
if(ismachinery(holder.physical))
|
|
var/obj/machinery/M = holder.physical
|
|
if(M.powered())
|
|
M.use_power(amount)
|
|
return TRUE
|
|
|
|
else
|
|
var/area/A = get_area(src)
|
|
if(!istype(A))
|
|
return FALSE
|
|
|
|
if(A.powered(AREA_USAGE_EQUIP))
|
|
A.use_power(amount, AREA_USAGE_EQUIP)
|
|
return TRUE
|
|
return FALSE
|
|
|
|
/obj/item/computer_hardware/recharger/wired
|
|
name = "wired power connector"
|
|
desc = "A power connector that recharges connected device from nearby power wire. Incompatible with portable computers."
|
|
icon_state = "charger_wire"
|
|
w_class = WEIGHT_CLASS_NORMAL
|
|
|
|
/obj/item/computer_hardware/recharger/wired/can_install(obj/item/modular_computer/M, mob/living/user = null)
|
|
if(ismachinery(M.physical) && M.physical.anchored)
|
|
return ..()
|
|
to_chat(user, span_warning("\The [src] is incompatible with portable computers!"))
|
|
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 FALSE
|
|
|
|
var/obj/structure/cable/C = T.get_cable_node()
|
|
if(!C || !C.powernet)
|
|
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 TRUE
|
|
return FALSE
|
|
|
|
/// 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.
|
|
/obj/item/computer_hardware/recharger/lambda
|
|
name = "lambda coil"
|
|
desc = "A very complex device that draws power from its own bluespace dimension."
|
|
icon_state = "charger_lambda"
|
|
w_class = WEIGHT_CLASS_TINY
|
|
charge_rate = 100000
|
|
|
|
/obj/item/computer_hardware/recharger/lambda/use_power(amount, charging=0)
|
|
return 1
|
|
|