Replaces Subsystems (mostly) with internal computing device (#7798)

This is for robots.
This commit is contained in:
Karolis
2020-01-04 13:36:03 +02:00
committed by Matt Atlas
parent 7dc0fdded5
commit b820f601fa
18 changed files with 151 additions and 129 deletions
@@ -31,7 +31,7 @@
else
idle_threads.Remove(P)
working = hard_drive && processor_unit && damage < broken_damage && (apc_power(0) || battery_power(0))
working = hard_drive && processor_unit && damage < broken_damage && computer_use_power()
check_update_ui_need()
if (working && enabled && world.time > ambience_last_played + 30 SECONDS && prob(3))
@@ -125,7 +125,7 @@
else
to_chat(user, "You press the power button, but the computer fails to boot up, displaying variety of errors before shutting down again.")
return
if(processor_unit && (apc_power(0) || battery_power(0))) // Battery-run and charged or non-battery but powered by APC.
if(processor_unit && computer_use_power()) // Battery-run and charged or non-battery but powered by APC.
if(issynth)
to_chat(user, "You send an activation signal to \the [src], turning it on")
else
@@ -38,6 +38,16 @@
A.use_power(power_usage, EQUIP)
return TRUE
// Tries to use power in general (Abstraction)
/obj/item/modular_computer/proc/computer_use_power(var/power_usage = 0)
// First tries to charge from an APC, if APC is unavailable switches to battery power. If neither works the computer fails.
if(apc_power(power_usage))
return TRUE
if(battery_power(power_usage))
return TRUE
return FALSE
// Handles power-related things, such as battery interaction, recharging, shutdown when it's discharged
/obj/item/modular_computer/proc/handle_power()
var/power_usage = screen_on ? base_active_power_usage : base_idle_power_usage
@@ -47,13 +57,8 @@
power_usage += H.power_usage
last_power_usage = power_usage
// First tries to charge from an APC, if APC is unavailable switches to battery power. If neither works the computer fails.
if(apc_power(power_usage))
if (power_has_failed)
power_has_failed = FALSE
update_icon()
return
if(battery_power(power_usage))
if(computer_use_power(power_usage))
if (power_has_failed)
power_has_failed = FALSE
update_icon()
@@ -5,7 +5,7 @@
if(ui)
ui.close()
return
if(!apc_power(0) && !battery_power(0))
if(!computer_use_power())
if(ui)
ui.close()
return