mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2025-12-26 02:02:39 +00:00
gotta go fast!
This commit is contained in:
@@ -116,11 +116,7 @@
|
||||
|
||||
/datum/light_source/proc/falloff(atom/movable/lighting_overlay/O)
|
||||
#if LIGHTING_FALLOFF == 1 // circular
|
||||
#if LIGHTING_RESOLUTION == 1
|
||||
. = (O.x - source_turf.x)**2 + (O.y - source_turf.y)**2 + LIGHTING_HEIGHT
|
||||
#else
|
||||
. = (O.x - source_turf.x + O.xoffset)**2 + (O.y - source_turf.y + O.yoffset)**2 + LIGHTING_HEIGHT
|
||||
#endif
|
||||
|
||||
#if LIGHTING_LAMBERTIAN == 1
|
||||
. = CLAMP01((1 - CLAMP01(sqrt(.) / max(1,light_range))) * (1 / (sqrt(. + 1))))
|
||||
@@ -129,11 +125,7 @@
|
||||
#endif
|
||||
|
||||
#elif LIGHTING_FALLOFF == 2 // square
|
||||
#if LIGHTING_RESOLUTION == 1
|
||||
. = abs(O.x - source_turf.x) + abs(O.y - source_turf.y) + LIGHTING_HEIGHT
|
||||
#else
|
||||
. = abs(O.x - source_turf.x + O.xoffset) + abs(O.y - source_turf.y + O.yoffset) + LIGHTING_HEIGHT
|
||||
#endif
|
||||
|
||||
#if LIGHTING_LAMBERTIAN == 1
|
||||
. = CLAMP01((1 - CLAMP01(. / max(1,light_range))) * (1 / (sqrt(.)**2 + )))
|
||||
@@ -145,16 +137,15 @@
|
||||
/datum/light_source/proc/apply_lum()
|
||||
applied = 1
|
||||
if(istype(source_turf))
|
||||
#if LIGHTING_RESOLUTION == 1
|
||||
for(var/turf/T in dview(light_range, source_turf, INVISIBILITY_LIGHTING))
|
||||
if(T.lighting_overlay)
|
||||
var/strength = light_power * falloff(T.lighting_overlay)
|
||||
if(!strength) //Don't add turfs that aren't affected to the affected turfs.
|
||||
continue
|
||||
|
||||
effect_r[T.lighting_overlay] = round(lum_r * strength, LIGHTING_ROUND_VALUE)
|
||||
effect_g[T.lighting_overlay] = round(lum_g * strength, LIGHTING_ROUND_VALUE)
|
||||
effect_b[T.lighting_overlay] = round(lum_b * strength, LIGHTING_ROUND_VALUE)
|
||||
effect_r += round(lum_r * strength, LIGHTING_ROUND_VALUE)
|
||||
effect_g += round(lum_g * strength, LIGHTING_ROUND_VALUE)
|
||||
effect_b += round(lum_b * strength, LIGHTING_ROUND_VALUE)
|
||||
|
||||
T.lighting_overlay.update_lumcount(
|
||||
round(lum_r * strength, LIGHTING_ROUND_VALUE),
|
||||
@@ -162,48 +153,28 @@
|
||||
round(lum_b * strength, LIGHTING_ROUND_VALUE)
|
||||
)
|
||||
|
||||
if(!T.affecting_lights)
|
||||
T.affecting_lights = list()
|
||||
|
||||
T.affecting_lights += src
|
||||
effect_turf += T
|
||||
|
||||
#else
|
||||
for(var/turf/T in dview(light_range, source_turf, INVISIBILITY_LIGHTING))
|
||||
for(var/atom/movable/lighting_overlay/L in T.lighting_overlays)
|
||||
var/strength = light_power * falloff(L)
|
||||
|
||||
effect_r[L] = round(lum_r * strength, LIGHTING_ROUND_VALUE)
|
||||
effect_g[L] = round(lum_g * strength, LIGHTING_ROUND_VALUE)
|
||||
effect_b[L] = round(lum_b * strength, LIGHTING_ROUND_VALUE)
|
||||
|
||||
L.update_lumcount(
|
||||
round(lum_r * strength, LIGHTING_ROUND_VALUE),
|
||||
round(lum_g * strength, LIGHTING_ROUND_VALUE),
|
||||
round(lum_b * strength, LIGHTING_ROUND_VALUE)
|
||||
)
|
||||
else
|
||||
effect_r += 0
|
||||
effect_g += 0
|
||||
effect_b += 0
|
||||
|
||||
if(!T.affecting_lights)
|
||||
T.affecting_lights = list()
|
||||
|
||||
T.affecting_lights += src
|
||||
effect_turf += T
|
||||
#endif
|
||||
|
||||
/datum/light_source/proc/remove_lum()
|
||||
applied = 0
|
||||
var/i = 1
|
||||
for(var/turf/T in effect_turf)
|
||||
if(T.affecting_lights)
|
||||
T.affecting_lights -= src
|
||||
|
||||
#if LIGHTING_RESOLUTION == 1
|
||||
if(T.lighting_overlay)
|
||||
T.lighting_overlay.update_lumcount(-effect_r[T.lighting_overlay], -effect_g[T.lighting_overlay], -effect_b[T.lighting_overlay])
|
||||
#else
|
||||
for(var/atom/movable/lighting_overlay/L in T.lighting_overlays)
|
||||
L.lighting_overlay.update_lumcount(-effect_r[L], -effect_g[L], -effect_b[L])
|
||||
#endif
|
||||
T.lighting_overlay.update_lumcount(-effect_r[i], -effect_g[i], -effect_b[i])
|
||||
|
||||
i++
|
||||
|
||||
effect_r.Cut()
|
||||
effect_g.Cut()
|
||||
|
||||
Reference in New Issue
Block a user