mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-01 20:42:08 +00:00
* Removes recharger tablet parts Removes 'advanced' tablet subtypes that we used before PDAs were added, in some jobs. Replaces Roboticist's advanced tablet mail with a laptop Moves the notepad's note var from the tablet, to the note app Moves modular computer's defines into their own file Machine computers now directly use power from the machine they're in, while the rest uses power cells. Silicon tablets don't use power at all. Co-authored-by: san7890 <the@san7890.com> Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
64 lines
2.2 KiB
Plaintext
64 lines
2.2 KiB
Plaintext
// Tries to draw power from charger or, if no operational charger is present, from power cell.
|
|
/obj/item/modular_computer/proc/use_power(amount = 0)
|
|
if(check_power_override())
|
|
return TRUE
|
|
|
|
if(ismachinery(loc))
|
|
var/obj/machinery/machine_holder = loc
|
|
if(machine_holder.powered())
|
|
machine_holder.use_power(amount)
|
|
return TRUE
|
|
|
|
var/obj/item/computer_hardware/battery/battery_module = all_components[MC_CELL]
|
|
if(battery_module && battery_module.battery && battery_module.battery.charge)
|
|
var/obj/item/stock_parts/cell/cell = battery_module.battery
|
|
if(cell.use(amount JOULES))
|
|
return TRUE
|
|
else // Discharge the cell anyway.
|
|
cell.use(min(amount JOULES, cell.charge))
|
|
return FALSE
|
|
return FALSE
|
|
|
|
/obj/item/modular_computer/proc/give_power(amount)
|
|
var/obj/item/computer_hardware/battery/battery_module = all_components[MC_CELL]
|
|
if(battery_module?.battery)
|
|
return battery_module.battery.give(amount)
|
|
return 0
|
|
|
|
/obj/item/modular_computer/get_cell()
|
|
var/obj/item/computer_hardware/battery/battery_module = all_components[MC_CELL]
|
|
return battery_module?.get_cell()
|
|
|
|
// Used in following function to reduce copypaste
|
|
/obj/item/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/modular_computer/proc/handle_power(delta_time)
|
|
var/power_usage = screen_on ? base_active_power_usage : base_idle_power_usage
|
|
|
|
for(var/obj/item/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 subtypes for special cases for power usage, returns TRUE if it should stop the use_power chain.
|
|
/obj/item/modular_computer/proc/check_power_override()
|
|
return FALSE
|
|
|
|
//Integrated (Silicon) tablets don't drain power, because the tablet is required to state laws, so it being disabled WILL cause problems.
|
|
/obj/item/modular_computer/tablet/integrated/check_power_override()
|
|
return TRUE
|