// 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 += "" if(L.len > 0) var/side = 0 for(var/obj/machinery/power/apc/A in L) if (side) side = 0 t += "" else side = 1 t += "" if (side) t += "" t += "
Main Supply
[mainsupply ? "On" : "Off"]
[A.circuit_disabled ? "Off" : "On"] - [A.area.name]
[A.area.name] - [A.circuit_disabled ? "Off" : "On"]
" t += "
" user.Browse(t, "window=switchgear;size=500x700") onclose(user, "switchgear") /obj/machinery/power/switchgear/Topic(href, href_list) ..() if ((usr.contents.Find(src) || ((get_dist(src, usr) <= 1) && istype(src.loc, /turf))) || (isAI(usr))) if( href_list["set_main"] ) var/value = text2num(href_list["set_main"]) mainsupply = value src.updateDialog() return if( href_list["set_apc"] ) var/obj/machinery/power/apc/A = locate(href_list["set_apc"]) if (A) A.circuit_disabled = min(max(0, text2num(href_list["circuit_disabled"])), 1) // todo: messing with the APC was a hack, need to have the APCs check the switchgear somehow src.updateDialog() return if( href_list["close"] ) if (isAI(usr)) boutput(usr, "You'd close the panel, if only you had hands.") return usr.Browse(null, "window=switchgear") usr.machine = null src.open = 0 icon_state = "c_unpowered" // update icon to closed state return else usr.Browse(null, "window=switchgear") usr.machine = null /obj/machinery/power/switchgear/process() if(!(status & (NOPOWER|BROKEN)) ) use_power(250) src.updateDialog() /obj/machinery/power/switchgear/power_change() if(status & BROKEN) icon_state = "broken" else if (!open) icon_state = "c_unpowered" else if( powered() ) icon_state = initial(icon_state) status &= ~NOPOWER else SPAWN_DBG(rand(0, 15)) src.icon_state = "c_unpowered" status |= NOPOWER