114 lines
3.0 KiB
Plaintext
114 lines
3.0 KiB
Plaintext
/obj/machinery/recharge_station
|
|
name = "cyborg recharging station"
|
|
desc = "This device recharges cyborgs and resupplies them with materials."
|
|
icon = 'icons/obj/objects.dmi'
|
|
icon_state = "borgcharger0"
|
|
density = FALSE
|
|
use_power = IDLE_POWER_USE
|
|
idle_power_usage = 5
|
|
active_power_usage = 1000
|
|
req_access = list(ACCESS_ROBOTICS)
|
|
state_open = TRUE
|
|
circuit = /obj/item/circuitboard/machine/cyborgrecharger
|
|
occupant_typecache = list(/mob/living/silicon/robot)
|
|
var/recharge_speed
|
|
var/repairs
|
|
|
|
/obj/machinery/recharge_station/Initialize()
|
|
. = ..()
|
|
update_icon()
|
|
|
|
/obj/machinery/recharge_station/RefreshParts()
|
|
recharge_speed = 0
|
|
repairs = 0
|
|
for(var/obj/item/stock_parts/capacitor/C in component_parts)
|
|
recharge_speed += C.rating * 100
|
|
for(var/obj/item/stock_parts/manipulator/M in component_parts)
|
|
repairs += M.rating - 1
|
|
for(var/obj/item/stock_parts/cell/C in component_parts)
|
|
recharge_speed *= C.maxcharge / 10000
|
|
|
|
/obj/machinery/recharge_station/process()
|
|
if(!is_operational())
|
|
return
|
|
|
|
if(occupant)
|
|
process_occupant()
|
|
return 1
|
|
|
|
/obj/machinery/recharge_station/relaymove(mob/user)
|
|
if(user.stat)
|
|
return
|
|
open_machine()
|
|
|
|
/obj/machinery/recharge_station/emp_act(severity)
|
|
. = ..()
|
|
if(!(stat & (BROKEN|NOPOWER)))
|
|
if(occupant && !(. & EMP_PROTECT_CONTENTS))
|
|
occupant.emp_act(severity)
|
|
if (!(. & EMP_PROTECT_SELF))
|
|
open_machine()
|
|
|
|
/obj/machinery/recharge_station/attackby(obj/item/P, mob/user, params)
|
|
if(state_open)
|
|
if(default_deconstruction_screwdriver(user, "borgdecon2", "borgcharger0", P))
|
|
return
|
|
|
|
if(default_pry_open(P))
|
|
return
|
|
|
|
if(default_deconstruction_crowbar(P))
|
|
return
|
|
return ..()
|
|
|
|
/obj/machinery/recharge_station/interact(mob/user)
|
|
toggle_open()
|
|
return TRUE
|
|
|
|
/obj/machinery/recharge_station/proc/toggle_open()
|
|
if(state_open)
|
|
close_machine()
|
|
else
|
|
open_machine()
|
|
|
|
/obj/machinery/recharge_station/open_machine()
|
|
. = ..()
|
|
if(iscyborg(occupant))
|
|
use_power = IDLE_POWER_USE
|
|
|
|
/obj/machinery/recharge_station/close_machine()
|
|
. = ..()
|
|
if(occupant)
|
|
if(iscyborg(occupant))
|
|
use_power = ACTIVE_POWER_USE
|
|
add_fingerprint(occupant)
|
|
|
|
/obj/machinery/recharge_station/update_icon()
|
|
if(is_operational())
|
|
if(state_open)
|
|
icon_state = "borgcharger0"
|
|
else
|
|
icon_state = (occupant ? "borgcharger1" : "borgcharger2")
|
|
else
|
|
icon_state = (state_open ? "borgcharger-u0" : "borgcharger-u1")
|
|
|
|
/obj/machinery/recharge_station/power_change()
|
|
..()
|
|
update_icon()
|
|
|
|
/obj/machinery/recharge_station/proc/process_occupant()
|
|
if(occupant && iscyborg(occupant))
|
|
var/mob/living/silicon/robot/R = occupant
|
|
restock_modules()
|
|
if(repairs)
|
|
R.heal_bodypart_damage(repairs, repairs - 1)
|
|
if(R.cell)
|
|
R.cell.charge = min(R.cell.charge + recharge_speed, R.cell.maxcharge)
|
|
|
|
/obj/machinery/recharge_station/proc/restock_modules()
|
|
if(occupant)
|
|
var/mob/living/silicon/robot/R = occupant
|
|
if(R && R.module)
|
|
var/coeff = recharge_speed * 0.005
|
|
R.module.respawn_consumable(R, coeff)
|