Optimize a few things in overlay lighting procs

Credit to Rohesie
This commit is contained in:
Aronai Sieyes
2021-07-19 23:05:16 -04:00
parent 9ab624544b
commit 86fc5c3751
+6 -5
View File
@@ -171,8 +171,7 @@
///Clears the affected_turfs lazylist, removing from its contents the effects of being near the light.
/datum/component/overlay_lighting/proc/clean_old_turfs()
for(var/t in affected_turfs)
var/turf/lit_turf = t
for(var/turf/lit_turf as anything in affected_turfs)
lit_turf.dynamic_lumcount -= lum_power
affected_turfs = null
@@ -182,9 +181,12 @@
if(!current_holder)
return
var/atom/movable/light_source = GET_LIGHT_SOURCE
. = list()
for(var/turf/lit_turf in view(lumcount_range, get_turf(light_source)))
lit_turf.dynamic_lumcount += lum_power
LAZYADD(affected_turfs, lit_turf)
. += lit_turf
if(length(.))
affected_turfs = .
///Clears the old affected turfs and populates the new ones.
@@ -431,8 +433,7 @@
. = lum_power
lum_power = new_lum_power
var/difference = . - lum_power
for(var/t in affected_turfs)
var/turf/lit_turf = t
for(var/turf/lit_turf as anything in affected_turfs)
lit_turf.dynamic_lumcount -= difference
///Moves the light directional_atom that emits our "light" based on our position and our direction