mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-27 15:17:01 +01:00
Optimizes grid check event a bit (+minor fixes) (#96075)
This commit is contained in:
@@ -100,7 +100,7 @@
|
||||
var/long_term_power = 10
|
||||
///Automatically name the APC after the area is in
|
||||
var/auto_name = FALSE
|
||||
///Time to allow the APC to regain some power and to turn the channels back online
|
||||
///Time to allow the APC to regain some power and to turn the channels back online in seconds
|
||||
var/failure_timer = 0
|
||||
///Forces an update on the power use to ensure that the apc has enough power
|
||||
var/force_update = FALSE
|
||||
@@ -282,8 +282,8 @@
|
||||
|
||||
/obj/machinery/power/apc/on_saboteur(datum/source, disrupt_duration)
|
||||
. = ..()
|
||||
disrupt_duration *= 0.1 // so, turns out, failure timer is in seconds, not deciseconds; without this, disruptions last 10 times as long as they probably should
|
||||
energy_fail(disrupt_duration)
|
||||
// failure timer is in seconds, not deciseconds, so we need to convert
|
||||
energy_fail(disrupt_duration * 0.1)
|
||||
return TRUE
|
||||
|
||||
/obj/machinery/power/apc/on_set_is_operational(old_value)
|
||||
@@ -589,7 +589,7 @@
|
||||
if(!area?.requires_power)
|
||||
return
|
||||
if(failure_timer)
|
||||
failure_timer--
|
||||
failure_timer = max(0, failure_timer - seconds_per_tick)
|
||||
force_update = TRUE
|
||||
return
|
||||
|
||||
|
||||
@@ -127,16 +127,15 @@
|
||||
terminal.master = null
|
||||
terminal = null
|
||||
|
||||
/**
|
||||
* Temporarily disables all power to the room for a set duration
|
||||
*
|
||||
* Some rooms are immune to this effect due to having important machines
|
||||
*
|
||||
* * duration - the duration of the power failure in seconds (not deciseconds)
|
||||
*/
|
||||
/obj/machinery/power/apc/proc/energy_fail(duration)
|
||||
for(var/obj/machinery/failing_machine in area.contents)
|
||||
if(failing_machine.critical_machine)
|
||||
return
|
||||
|
||||
for(var/mob/living/silicon/ai as anything in GLOB.ai_list)
|
||||
if(get_area(ai) == area)
|
||||
return
|
||||
|
||||
failure_timer = max(failure_timer, round(duration))
|
||||
failure_timer = max(failure_timer, round(duration, SSMACHINES_DT))
|
||||
update()
|
||||
queue_icon_update()
|
||||
|
||||
@@ -147,10 +146,9 @@
|
||||
if(nightshift_lights == on)
|
||||
return //no change
|
||||
nightshift_lights = on
|
||||
for (var/list/zlevel_turfs as anything in area.get_zlevel_turf_lists())
|
||||
for(var/turf/area_turf as anything in zlevel_turfs)
|
||||
for(var/obj/machinery/light/night_light in area_turf)
|
||||
if(night_light.nightshift_allowed)
|
||||
night_light.nightshift_enabled = nightshift_lights
|
||||
night_light.update(FALSE)
|
||||
CHECK_TICK
|
||||
for(var/turf/area_turf as anything in area.get_turfs_from_all_zlevels())
|
||||
for(var/obj/machinery/light/night_light in area_turf)
|
||||
if(night_light.nightshift_allowed)
|
||||
night_light.nightshift_enabled = nightshift_lights
|
||||
night_light.update(FALSE)
|
||||
CHECK_TICK
|
||||
|
||||
Reference in New Issue
Block a user