mirror of
https://github.com/SPLURT-Station/S.P.L.U.R.T-Station-13.git
synced 2025-12-11 18:33:36 +00:00
* sync (#3) * shuttle auto call * Merge /vore into /master (#39) * progress * Compile errors fixed No idea if it's test worthy tho as conflicts with race overhaul and narky removal. * Update admins.txt * efforts continue Fuck grab code, seriously * grab code is cancer * Execute the Narkism Do not hesitate. Show no mercy. * holy shit grab code is awful * have I bitched about grab code My bitching, let me show you it * código de agarre es una mierda No really it is * yeah I don't even know anymore. * Lolnope. Fuck grab code * I'm not even sure what to fix anymore * Self eating is not an acceptable fate * Taste the void, son. * My code doesn't pass it's own sanity check. Maybe it's a sign of things to come. * uncommented and notes * It Works and I Don't Know Why (#38) * shuttle auto call * it works and I don't know why * Subsystem 12/21 Most Recent TG subsystem folder * globalvars 12/21 Tossed out the flavor_misc and parallax files * Onclick 12/21 as well as .dme updates * _defines 12/21 ommited old _MC.dm * _HELPERS 12/21 Preserved snowflake placement of furry sprites * _defeines/genetics reapplied narkism holdover for snowflake races. * Oops forgot mutant colors * modules porting 12/21 + Sounds/icons Admin, Client and most of mob life files ommitted * enviroment file * Admin optimizations ahelp log system kept * Mob ports 12/21 Flavor text preserved * datums ported 12/21 * Game ported 12/21 * batch of duplicate fixes/dogborg work Dogborgs need to be modernized to refractored borg standards. * moar fixes * Maps and futher compile fixes
62 lines
2.1 KiB
Plaintext
62 lines
2.1 KiB
Plaintext
// Tries to draw power from charger or, if no operational charger is present, from power cell.
|
|
/obj/item/device/modular_computer/proc/use_power(amount = 0)
|
|
if(check_power_override())
|
|
return TRUE
|
|
|
|
var/obj/item/weapon/computer_hardware/recharger/recharger = all_components[MC_CHARGE]
|
|
|
|
if(recharger && recharger.check_functionality())
|
|
if(recharger.use_power(amount))
|
|
return TRUE
|
|
|
|
var/obj/item/weapon/computer_hardware/battery/battery_module = all_components[MC_CELL]
|
|
|
|
if(battery_module && battery_module.battery && battery_module.battery.charge)
|
|
var/obj/item/weapon/stock_parts/cell/cell = battery_module.battery
|
|
if(cell.use(amount * CELLRATE))
|
|
return TRUE
|
|
else // Discharge the cell anyway.
|
|
cell.use(min(amount*CELLRATE, cell.charge))
|
|
return FALSE
|
|
return FALSE
|
|
|
|
/obj/item/device/modular_computer/proc/give_power(amount)
|
|
var/obj/item/weapon/computer_hardware/battery/battery_module = all_components[MC_CELL]
|
|
if(battery_module && battery_module.battery)
|
|
return battery_module.battery.give(amount)
|
|
return 0
|
|
|
|
|
|
// Used in following function to reduce copypaste
|
|
/obj/item/device/modular_computer/proc/power_failure()
|
|
if(enabled) // Shut down the computer
|
|
if(active_program)
|
|
active_program.event_powerfailure(0)
|
|
for(var/I in idle_threads)
|
|
var/datum/computer_file/program/PRG = I
|
|
PRG.event_powerfailure(1)
|
|
shutdown_computer(0)
|
|
|
|
// Handles power-related things, such as battery interaction, recharging, shutdown when it's discharged
|
|
/obj/item/device/modular_computer/proc/handle_power()
|
|
var/obj/item/weapon/computer_hardware/recharger/recharger = all_components[MC_CHARGE]
|
|
if(recharger)
|
|
recharger.process()
|
|
|
|
var/power_usage = screen_on ? base_active_power_usage : base_idle_power_usage
|
|
|
|
for(var/obj/item/weapon/computer_hardware/H in all_components)
|
|
if(H.enabled)
|
|
power_usage += H.power_usage
|
|
|
|
if(use_power(power_usage))
|
|
last_power_usage = power_usage
|
|
return TRUE
|
|
else
|
|
power_failure()
|
|
return FALSE
|
|
|
|
// Used by child types if they have other power source than battery or recharger
|
|
/obj/item/device/modular_computer/proc/check_power_override()
|
|
return FALSE
|