// a switchgear for cogwerks
// blatant ripoff of the power monitor computer's code, allows you to turn on and off supply to APCs on the powernet.
// its kind of a hack, right now it works by setting a flag on the APC. when the circuit is disabled the APC just sees no available power
// this is a problem, if the switchgear gets destroyed there's no other way to reset that flag. should do it differently but not sure how
// TODO: finish this thing, make it use a terminal to separate powernets then
// have switchgears control power to apcs in a small region. when its in the map
// it will separate powernets into high power (engine -> smes), mid power (smes ->
// switchgear) and low power (switchgear -> apc). would work with possible future
// tiered cables (same code just different sprites and max power before faults and
// build/repair steps and materials) to make power repair work a little more varied
// and separate the crew from the more dangerous wires to go with making higher power
// more dangerous
/obj/machinery/power/switchgear
name = "High Voltage Switchgear"
desc = "It looks like a giant cabinet full of switches and shiny metal parts. Why not start messing with it, what's the worst that could happen?"
icon = 'icons/obj/computer.dmi'
icon_state = "power"
density = 1
anchored = 1
var/locked = 1
var/open = 0
var/mainsupply = 1
/obj/machinery/power/switchgear/attack_ai(mob/user)
add_fingerprint(user)
if(status & (BROKEN|NOPOWER))
return
interact(user)
/obj/machinery/power/switchgear/attack_hand(mob/user)
add_fingerprint(user)
if(status & (BROKEN|NOPOWER))
return
if (open)
interact(user)
else
if (locked)
boutput(user, "The access panel is locked.")
else
boutput(user, "You open the access panel.")
// todo: update icon to open state
open = 1
icon_state = initial(icon_state)
/obj/machinery/power/switchgear/attackby(obj/item/W, mob/user)
if(istype(W, /obj/item/card/id))
if (src.allowed(user))
if (src.open)
boutput(user, "You need to close the panel first.")
return
src.locked = !src.locked
boutput(user, "You [src.locked ? "lock" : "unlock"] the switchgear access panel.")
else
boutput(user, "Access denied.")
else
return ..(W, user)
/obj/machinery/power/switchgear/proc/interact(mob/user)
if ( (get_dist(src, user) > 1 ) || (status & (BROKEN|NOPOWER)) )
if (!issilicon(user))
user.machine = null
user.Browse(null, "window=switchgear")
return
user.machine = src
var/t = "Switchgear Control Close Panel"
if(!powernet)
t += "No connection"
else
var/list/L = list()
for(var/obj/machinery/power/terminal/term in powernet.nodes)
if(istype(term.master, /obj/machinery/power/apc))
var/obj/machinery/power/apc/A = term.master
L += A
t += "