diff --git a/baystation12.dme b/baystation12.dme index 2c4359af655..0fa4e4553dc 100644 --- a/baystation12.dme +++ b/baystation12.dme @@ -1124,6 +1124,7 @@ #include "code\modules\paperwork\stamps.dm" #include "code\modules\power\apc.dm" #include "code\modules\power\batteryrack.dm" +#include "code\modules\power\breaker_box.dm" #include "code\modules\power\cable.dm" #include "code\modules\power\cable_heavyduty.dm" #include "code\modules\power\cable_logic.dm" @@ -1139,7 +1140,6 @@ #include "code\modules\power\profiling.dm" #include "code\modules\power\smes.dm" #include "code\modules\power\solar.dm" -#include "code\modules\power\switch.dm" #include "code\modules\power\terminal.dm" #include "code\modules\power\tracker.dm" #include "code\modules\power\turbine.dm" diff --git a/code/modules/power/breaker_box.dm b/code/modules/power/breaker_box.dm new file mode 100644 index 00000000000..e47d6f17f3a --- /dev/null +++ b/code/modules/power/breaker_box.dm @@ -0,0 +1,90 @@ +// Updated version of old powerswitch by Atlantis +// Has better texture, and is now considered electronic device +// AI has ability to toggle it in 5 seconds +// Humans need 30 seconds (AI is faster when it comes to complex electronics) +// Used for advanced grid control (read: Substations) + +/obj/structure/breakerbox + name = "Breaker Box" + desc = "Large panel with breakers used to control connected power circuits." + icon = 'icons/obj/power.dmi' + icon_state = "bbox_off" + var/icon_state_on = "bbox_on" + var/icon_state_off = "bbox_off" + flags = FPRINT + density = 1 + anchored = 1 + var/on = 0 + var/busy = 0 + +/obj/structure/breakerbox/examine() + ..() + usr << "Large machine with heavy duty switching circuits used for advanced grid control" + if(on) + usr << "\green It seems to be online." + else + usr << "\red It seems to be offline" + +/obj/structure/breakerbox/attack_ai(mob/user) + if(busy) + user << "\red System is busy. Please wait until current operation is finished before changing power settings." + return + + ..() + + busy = 1 + user << "\green Updating power settings.." + if(do_after(user, 50)) //5s for AI as AIs can manipulate electronics much faster. + set_state(!on) + user << "\green Update Completed. New setting:[on ? "on": "off"]" + busy = 0 + + +/obj/structure/breakerbox/attack_hand(mob/user) + + if(busy) + user << "\red System is busy. Please wait until current operation is finished before changing power settings." + return + + ..() + + busy = 1 + for(var/mob/O in viewers(user)) + O.show_message(text("\red [user] started reprogramming [src]!"), 1) + + if(do_after(user, 300)) // 30s for non-AIs as humans have to manually reprogram it and rapid switching may cause some lag / powernet updates flood. If AIs spam it they can be easily traced. + set_state(!on) + for(var/mob/O in viewers(user)) + O.show_message(text("\red [user] finished reprogramming the [src]!"), 1) + busy = 0 + +/obj/structure/breakerbox/proc/set_state(var/state) + on = state + if(on) + icon_state = icon_state_on + var/list/connection_dirs = list() + for(var/direction in list(1,2,4,8,5,6,9,10)) + for(var/obj/structure/cable/C in get_step(src,direction)) + if(C.d1 == turn(direction, 180) || C.d2 == turn(direction, 180)) + connection_dirs += direction + break + + for(var/direction in connection_dirs) + var/obj/structure/cable/C = new/obj/structure/cable(src.loc) + C.d1 = 0 + C.d2 = direction + C.icon_state = "[C.d1]-[C.d2]" + C.breaker_box = src + + var/datum/powernet/PN = new() + PN.number = powernets.len + 1 + powernets += PN + PN.cables += C + + C.mergeConnectedNetworks(C.d2) + C.mergeConnectedNetworksOnTurf() + + else + icon_state = icon_state_off + for(var/obj/structure/cable/C in src.loc) + del(C) diff --git a/code/modules/power/cable.dm b/code/modules/power/cable.dm index 229d82eec58..34698cb7351 100644 --- a/code/modules/power/cable.dm +++ b/code/modules/power/cable.dm @@ -36,7 +36,7 @@ var/d2 = 1 layer = 2.44 //Just below unary stuff, which is at 2.45 and above pipes, which are at 2.4 color = COLOR_RED - var/obj/structure/powerswitch/power_switch + var/obj/structure/breakerbox/breaker_box /obj/structure/cable/yellow color = COLOR_YELLOW @@ -117,9 +117,9 @@ return ///// Z-Level Stuff -// if(power_switch) -// user << "\red This piece of cable is tied to a power switch. Flip the switch to remove it." -// return + if(breaker_box) + user << "\red This cable is connected to nearby breaker box. Use breaker box to interact with it." + return if (shock(user, 50)) return diff --git a/code/modules/power/switch.dm b/code/modules/power/switch.dm deleted file mode 100644 index 05683bd9c57..00000000000 --- a/code/modules/power/switch.dm +++ /dev/null @@ -1,85 +0,0 @@ -//This is a power switch. When turned on it looks at the cables around the tile that it's on and notes which cables are trying to connect to it. -//After it knows this it creates the number of cables from the center to each of the cables attempting to conenct. These cables cannot be removed -//with wirecutters. When the switch is turned off it removes all the cables on the tile it's on. -//The switch uses a 5s delay to prevent powernet change spamming. -/* -/obj/structure/powerswitch - name = "power switch" - desc = "A switch that controls power." - icon = 'icons/obj/power.dmi' - icon_state = "switch-dbl-up" - var/icon_state_on = "switch-dbl-down" - var/icon_state_off = "switch-dbl-up" - flags = FPRINT - density = 0 - anchored = 1 - var/on = 0 //up is off, down is on - var/busy = 0 //set to 1 when you start pulling - -/obj/structure/powerswitch/simple - icon_state = "switch-up" - icon_state_on = "switch-down" - icon_state_off = "switch-up" - - -/obj/structure/powerswitch/examine() - ..() - if(on) - usr << "The switch is in the on position" - else - usr << "The switch is in the off position" - -/obj/structure/powerswitch/attack_ai(mob/user) - user << "\red You're an AI. This is a manual switch. It's not going to work." - return - -/obj/structure/powerswitch/attack_hand(mob/user) - - if(busy) - user << "\red This switch is already being toggled." - return - - ..() - - busy = 1 - for(var/mob/O in viewers(user)) - O.show_message(text("\red [user] started pulling the [src]."), 1) - - if(do_after(user, 50)) - set_state(!on) - for(var/mob/O in viewers(user)) - O.show_message(text("\red [user] flipped the [src] into the [on ? "on": "off"] position."), 1) - busy = 0 - -/obj/structure/powerswitch/proc/set_state(var/state) - on = state - if(on) - icon_state = icon_state_on - var/list/connection_dirs = list() - for(var/direction in list(1,2,4,8,5,6,9,10)) - for(var/obj/structure/cable/C in get_step(src,direction)) - if(C.d1 == turn(direction, 180) || C.d2 == turn(direction, 180)) - connection_dirs += direction - break - - for(var/direction in connection_dirs) - var/obj/structure/cable/C = new/obj/structure/cable(src.loc) - C.d1 = 0 - C.d2 = direction - C.icon_state = "[C.d1]-[C.d2]" - C.power_switch = src - - var/datum/powernet/PN = new() - PN.number = powernets.len + 1 - powernets += PN - C.netnum = PN.number - PN.cables += C - - C.mergeConnectedNetworks(C.d2) - C.mergeConnectedNetworksOnTurf() - - else - icon_state = icon_state_off - for(var/obj/structure/cable/C in src.loc) - del(C) -*/ \ No newline at end of file diff --git a/icons/obj/power.dmi b/icons/obj/power.dmi index 90b06c38bf1..ef05d86e647 100644 Binary files a/icons/obj/power.dmi and b/icons/obj/power.dmi differ