mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2025-12-19 14:51:27 +00:00
* 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>
63 lines
2.4 KiB
Plaintext
63 lines
2.4 KiB
Plaintext
SUBSYSTEM_DEF(nightshift)
|
|
name = "Night Shift"
|
|
init_order = INIT_ORDER_NIGHTSHIFT
|
|
priority = FIRE_PRIORITY_NIGHTSHIFT
|
|
wait = 600
|
|
flags = SS_NO_TICK_CHECK
|
|
offline_implications = "The game will no longer shift between day and night lighting. No immediate action is needed."
|
|
cpu_display = SS_CPUDISPLAY_LOW
|
|
|
|
var/nightshift_active = FALSE
|
|
var/nightshift_start_time = 702000 //7:30 PM, station time
|
|
var/nightshift_end_time = 270000 //7:30 AM, station time
|
|
var/nightshift_first_check = 30 SECONDS
|
|
|
|
var/high_security_mode = FALSE
|
|
|
|
/datum/controller/subsystem/nightshift/Initialize()
|
|
if(!GLOB.configuration.general.enable_night_shifts)
|
|
flags |= SS_NO_FIRE
|
|
if(GLOB.configuration.general.randomise_shift_time)
|
|
GLOB.gametime_offset = rand(0, 23) HOURS
|
|
|
|
/datum/controller/subsystem/nightshift/fire(resumed = FALSE)
|
|
if(world.time - SSticker.round_start_time < nightshift_first_check)
|
|
return
|
|
check_nightshift()
|
|
|
|
/datum/controller/subsystem/nightshift/proc/announce(message)
|
|
GLOB.minor_announcement.Announce(message, new_sound = 'sound/misc/notice2.ogg', new_title = "Automated Lighting System Announcement")
|
|
|
|
/datum/controller/subsystem/nightshift/proc/check_nightshift(check_canfire=FALSE)
|
|
if(check_canfire && !can_fire)
|
|
return
|
|
var/emergency = SSsecurity_level.get_current_level_as_number() >= SEC_LEVEL_RED
|
|
var/announcing = TRUE
|
|
var/time = station_time()
|
|
var/night_time = (time < nightshift_end_time) || (time > nightshift_start_time)
|
|
if(high_security_mode != emergency)
|
|
high_security_mode = emergency
|
|
if(night_time)
|
|
announcing = FALSE
|
|
if(!emergency)
|
|
announce("Restoring night lighting configuration to normal operation.")
|
|
else
|
|
announce("Disabling night lighting: Station is in a state of emergency.")
|
|
if(emergency)
|
|
night_time = FALSE
|
|
if(nightshift_active != night_time)
|
|
update_nightshift(night_time, announcing)
|
|
|
|
/datum/controller/subsystem/nightshift/proc/update_nightshift(active, announce = TRUE)
|
|
nightshift_active = active
|
|
if(announce)
|
|
if(active)
|
|
announce("Good evening, crew. To reduce power consumption and stimulate the circadian rhythms of some species, all of the lights aboard the station have been dimmed for the night.")
|
|
else
|
|
announce("Good morning, crew. As it is now day time, all of the lights aboard the station have been restored to their former brightness.")
|
|
for(var/A in GLOB.apcs)
|
|
var/obj/machinery/power/apc/APC = A
|
|
if(is_station_level(APC.z))
|
|
APC.set_nightshift(active)
|
|
CHECK_TICK
|