Refactor: refactor security levels (#21899)

* refactor: datumize security levels

* refactor: implement `SSsecurity_level` for handling security level related stuff

* feat: returns back old `delta_alarm` sound

* refactor: adjust existing code to use `SSsecurity_level`

* fix: remove redundunt new init order

* fix: fix type in var

* refactor: apply reviewer changes

* fix: replace `can_fire=FALSE` with `ss_flags = SS_NO_FIRE`, as subsystem will never fire

* fix: use `flags` instead of `ss_flags` for subsystem

Co-authored-by: SteelSlayer <42044220+SteelSlayer@users.noreply.github.com>

* fix: replace old security level interactions

* feat: implement `Recover` proc for `SSsecurity_level`

* refactor: add clearer doc for `security_level_set_timer_id`  propery of `SSsecurirt_level`

* refactor: swap `security_level` datum properties to make it clearer to read

* refactor: move initialization code from `New` to `Initialize` for `/obj/machinery/firealarm`

* fix: revert back `delta_alarm` annoing sound, use `delta_claxon` on change to delta security level

---------

Co-authored-by: SteelSlayer <42044220+SteelSlayer@users.noreply.github.com>
This commit is contained in:
Gaxeer
2023-10-14 21:46:49 +02:00
committed by GitHub
co-authored by SteelSlayer
parent 6a2704a3ad
commit eda2102bdc
29 changed files with 450 additions and 321 deletions
+2 -2
View File
@@ -49,7 +49,7 @@
var/datum/action/innate/ai/return_to_core/R = new
R.Grant(occupier)
occupier.cancel_camera()
if((seclevel2num(get_security_level()) == SEC_LEVEL_DELTA) && malf.nuking)
if((SSsecurity_level.get_current_level_as_number() == SEC_LEVEL_DELTA) && malf.nuking)
for(var/obj/item/pinpointer/point in GLOB.pinpointer_list)
point.the_disk = src //the pinpointer will detect the shunted AI
@@ -62,7 +62,7 @@
occupier.parent.adjustOxyLoss(occupier.getOxyLoss())
occupier.parent.cancel_camera()
qdel(occupier)
if(seclevel2num(get_security_level()) == SEC_LEVEL_DELTA)
if(SSsecurity_level.get_current_level_as_number() == SEC_LEVEL_DELTA)
for(var/obj/item/pinpointer/point in GLOB.pinpointer_list)
for(var/mob/living/silicon/ai/A in GLOB.ai_list)
if((A.stat != DEAD) && A.nuking)
+34 -1
View File
@@ -256,6 +256,11 @@
// create a new lighting fixture
/obj/machinery/light/Initialize(mapload)
. = ..()
if(is_station_level(z))
RegisterSignal(SSsecurity_level, COMSIG_SECURITY_LEVEL_CHANGE_PLANNED, PROC_REF(on_security_level_change_planned))
RegisterSignal(SSsecurity_level, COMSIG_SECURITY_LEVEL_CHANGED, PROC_REF(on_security_level_update))
var/area/A = get_area(src)
if(A && !A.requires_power)
on = TRUE
@@ -272,11 +277,39 @@
break_light_tube(TRUE)
update(FALSE, TRUE, FALSE)
/obj/machinery/light/proc/on_security_level_change_planned(datum/source, previous_level_number, new_level_number)
SIGNAL_HANDLER
if(status != LIGHT_OK)
return
if(new_level_number == SEC_LEVEL_EPSILON)
fire_mode = FALSE
emergency_mode = TRUE
on = FALSE
INVOKE_ASYNC(src, PROC_REF(update), FALSE)
/obj/machinery/light/proc/on_security_level_update(datum/source, previous_level_number, new_level_number)
SIGNAL_HANDLER
if(status != LIGHT_OK)
return
if(new_level_number >= SEC_LEVEL_EPSILON)
fire_mode = TRUE
emergency_mode = TRUE
on = FALSE
else
fire_mode = FALSE
emergency_mode = FALSE
on = TRUE
INVOKE_ASYNC(src, PROC_REF(update), FALSE)
/obj/machinery/light/Destroy()
var/area/A = get_area(src)
if(A)
on = FALSE
// A.update_lights()
return ..()
/obj/machinery/light/update_icon_state()