Files
CHOMPStation2/code/datums/wires/grid_checker.dm
Neerti 337ef499a1 Cleans Up WIP Event System + New Grid Check For It
Separates the 'count and assess everything' stuff to it's own datum, called the metric datum, which I plan to add on to in the future to make counting and metrics easier.
Makes decision process a bit more weight-based, will probably continue tweaking later.
Makes the admin debug UI have links to change settings easily.
Adds replacement for grid check event, which works similar to the old one, but is now based on a physical machine in the game world, that Engineering can hack to make the event end faster, if so desired.  Note that the machine is not mapped in, and won't be mapped in until the event system is ready for launch.
Adds grid_check variables to SMESes and APCs to make them stop doing work without draining the battery.
Grid checks in the new system are caused by a "power spike" which originates from the engine and will cause bad things, should no grid checker machine be connected to the power-net.  These power spikes occur when the GM decides that a grid check is a good event to have.
The grid checker can be built and deconstructed using the standard machine construction methods.
2016-10-05 21:40:07 -04:00

66 lines
2.3 KiB
Plaintext

/datum/wires/grid_checker
holder_type = /obj/machinery/power/grid_checker
wire_count = 8
var/const/GRID_CHECKER_WIRE_REBOOT = 1 // This wire causes the grid-check to end, if pulsed.
var/const/GRID_CHECKER_WIRE_LOCKOUT = 2 // If cut or pulsed, locks the user out for half a minute.
var/const/GRID_CHECKER_WIRE_ALLOW_MANUAL_1 = 4 // Needs to be cut for REBOOT to be possible.
var/const/GRID_CHECKER_WIRE_ALLOW_MANUAL_2 = 8 // Needs to be cut for REBOOT to be possible.
var/const/GRID_CHECKER_WIRE_ALLOW_MANUAL_3 = 16 // Needs to be cut for REBOOT to be possible.
var/const/GRID_CHECKER_WIRE_SHOCK = 32 // Shocks the user if not wearing gloves.
var/const/GRID_CHECKER_WIRE_NOTHING_1 = 64 // Does nothing, but makes it a bit harder.
var/const/GRID_CHECKER_WIRE_NOTHING_2 = 128 // Does nothing, but makes it a bit harder.
/datum/wires/grid_checker/CanUse(var/mob/living/L)
var/obj/machinery/power/grid_checker/G = holder
if(G.opened)
return TRUE
return FALSE
/datum/wires/grid_checker/GetInteractWindow()
var/obj/machinery/power/grid_checker/G = holder
. += ..()
. += "The green light is [G.power_failing ? "off" : "on"].<br>"
. += "The red light is [G.wire_locked_out ? "on" : "off"].<br>"
. += "The blue light is [G.wire_allow_manual_1 && G.wire_allow_manual_2 && G.wire_allow_manual_3 ? "on" : "off"]."
/datum/wires/grid_checker/UpdateCut(var/index, var/mended)
var/obj/machinery/power/grid_checker/G = holder
switch(index)
if(GRID_CHECKER_WIRE_LOCKOUT)
G.wire_locked_out = !mended
if(GRID_CHECKER_WIRE_ALLOW_MANUAL_1)
G.wire_allow_manual_1 = !mended
if(GRID_CHECKER_WIRE_ALLOW_MANUAL_2)
G.wire_allow_manual_2 = !mended
if(GRID_CHECKER_WIRE_ALLOW_MANUAL_3)
G.wire_allow_manual_3 = !mended
if(GRID_CHECKER_WIRE_SHOCK)
if(G.wire_locked_out)
return
G.shock(usr, 70)
/datum/wires/grid_checker/UpdatePulsed(var/index)
var/obj/machinery/power/grid_checker/G = holder
switch(index)
if(GRID_CHECKER_WIRE_REBOOT)
if(G.wire_locked_out)
return
if(G.power_failing && G.wire_allow_manual_1 && G.wire_allow_manual_2 && G.wire_allow_manual_3)
G.end_power_failure(TRUE)
if(GRID_CHECKER_WIRE_LOCKOUT)
if(G.wire_locked_out)
return
G.wire_locked_out = TRUE
spawn(30 SECONDS)
G.wire_locked_out = FALSE
if(GRID_CHECKER_WIRE_SHOCK)
if(G.wire_locked_out)
return
G.shock(usr, 70)