Merge pull request #14178 from Poojawa/fancy-AFGs

Fixes #14118
This commit is contained in:
Heroman3003
2022-12-10 10:22:16 +10:00
committed by CHOMPStation2
parent 7566c3306c
commit 6f890fbe98

View File

@@ -14,11 +14,11 @@
var/isactive = FALSE var/isactive = FALSE
var/wasactive = FALSE //controls automatic reboot after power-loss var/wasactive = FALSE //controls automatic reboot after power-loss
var/alwaysactive = FALSE //for a special subtype var/alwaysactive = FALSE //for a special subtype
//how long it takes us to reboot if we're shut down by an EMP //how long it takes us to reboot if we're shut down by an EMP
var/reboot_delay_min = 50 var/reboot_delay_min = 50
var/reboot_delay_max = 75 var/reboot_delay_max = 75
var/hatch_open = FALSE var/hatch_open = FALSE
var/wires_intact = TRUE var/wires_intact = TRUE
var/list/areas_added var/list/areas_added
@@ -98,26 +98,30 @@
/obj/machinery/atmospheric_field_generator/power_change() /obj/machinery/atmospheric_field_generator/power_change()
var/oldstat var/oldstat
..() ..()
if(!(stat & NOPOWER)) if(!(stat & (BROKEN|NOPOWER|EMPED)))
ispowered = 1 ispowered = TRUE
update_icon() update_icon()
if(alwaysactive || wasactive) //reboot our field if we were on or are supposed to be always-on if(alwaysactive || wasactive) //reboot our field if we were on or are supposed to be always-on
generate_field() generate_field()
if(stat != oldstat && isactive && (stat & NOPOWER)) if(stat != oldstat && isactive && (stat & (BROKEN|NOPOWER|EMPED)))
ispowered = 0 ispowered = FALSE
disable_field() disable_field()
update_icon() update_icon()
/obj/machinery/atmospheric_field_generator/emp_act() /obj/machinery/atmospheric_field_generator/emp_act()
. = ..() if(!(stat & EMPED))
disable_field() //shutting dowwwwwwn stat |= EMPED
if(alwaysactive || wasactive) //reboot after a short delay if we were online before disable_field() //shutting dowwwwwwn
spawn(rand(reboot_delay_min,reboot_delay_max)) spawn(rand(reboot_delay_min,reboot_delay_max))
generate_field() stat &= ~EMPED
if(alwaysactive || wasactive) //reboot after a short delay if we were online before
generate_field()
..()
/obj/machinery/atmospheric_field_generator/ex_act(severity) /obj/machinery/atmospheric_field_generator/ex_act(severity)
switch(severity) switch(severity)
if(1) if(1)
stat |= BROKEN //ensures that always on generators are set as broken prior to being deleted, thus, off.
disable_field() disable_field()
qdel(src) qdel(src)
return return
@@ -134,23 +138,26 @@
if(!ispowered || hatch_open || !wires_intact || isactive) //if it's not powered, the hatch is open, the wires are busted, or it's already on, don't do anything if(!ispowered || hatch_open || !wires_intact || isactive) //if it's not powered, the hatch is open, the wires are busted, or it's already on, don't do anything
return return
else else
isactive = 1 isactive = TRUE
icon_state = "arfg_on" icon_state = "arfg_on"
new field_type (src.loc) new field_type (src.loc)
src.visible_message("<span class='warning'>The ARF-G crackles to life!</span>","<span class='warning'>You hear an ARF-G coming online!</span>") src.visible_message("<span class='warning'>The ARF-G crackles to life!</span>","<span class='warning'>You hear an ARF-G coming online!</span>")
update_use_power(USE_POWER_ACTIVE) update_use_power(USE_POWER_ACTIVE)
return return
/obj/machinery/atmospheric_field_generator/proc/disable_field() /obj/machinery/atmospheric_field_generator/proc/disable_field()
if(isactive) if(isactive)
icon_state = "arfg_off" if(alwaysactive == TRUE && !(stat & (BROKEN|NOPOWER|EMPED))) //If we're not damaged, don't turn off if we're always on.
for(var/obj/structure/atmospheric_retention_field/F in loc) return
qdel(F) else
src.visible_message("The ARF-G shuts down with a low hum.","You hear an ARF-G powering down.") icon_state = "arfg_off"
update_use_power(USE_POWER_IDLE) for(var/obj/structure/atmospheric_retention_field/F in loc)
isactive = 0 qdel(F)
src.visible_message("The ARF-G shuts down with a low hum.","You hear an ARF-G powering down.")
update_use_power(USE_POWER_IDLE)
isactive = FALSE
return return
/obj/machinery/atmospheric_field_generator/Initialize() /obj/machinery/atmospheric_field_generator/Initialize()
. = ..() . = ..()
//Delete ourselves if we find extra mapped in arfgs //Delete ourselves if we find extra mapped in arfgs
@@ -158,7 +165,7 @@
if(F != src) if(F != src)
log_debug("Duplicate ARFGS at [x],[y],[z]") log_debug("Duplicate ARFGS at [x],[y],[z]")
return INITIALIZE_HINT_QDEL return INITIALIZE_HINT_QDEL
var/area/A = get_area(src) var/area/A = get_area(src)
ASSERT(istype(A)) ASSERT(istype(A))
@@ -202,11 +209,11 @@
for(var/i = 1 to 4) for(var/i = 1 to 4)
var/image/I = image(icon, "[basestate][connections[i]]", dir = 1<<(i-1)) var/image/I = image(icon, "[basestate][connections[i]]", dir = 1<<(i-1))
add_overlay(I) add_overlay(I)
return return
/obj/structure/atmospheric_retention_field/Initialize() /obj/structure/atmospheric_retention_field/Initialize()
. = ..() . = ..()
update_nearby_tiles() //Force ZAS update update_nearby_tiles() //Force ZAS update
update_connections(1) update_connections(1)
update_icon() update_icon()