mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-22 04:30:44 +01:00
Merge branch 'master' of https://github.com/tgstation/-tg-station into revert_revert_revert_come_on_revert_please_rever_please_shit_REVERT_JESUS_TAPDANCING_CHRIST_REVERT_YOU_FUCKING_PIECE_OF_GODDAMN_PISS
Conflicts: code/_onclick/hud/plane_master.dm code/modules/lighting/lighting_object.dm
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
|
||||
else
|
||||
for (var/turf/T in area_contents(src))
|
||||
if (T.lighting_overlay)
|
||||
if (T.lighting_object)
|
||||
T.lighting_clear_overlay()
|
||||
|
||||
return TRUE
|
||||
|
||||
@@ -87,24 +87,24 @@
|
||||
|
||||
/atom/movable/Moved(atom/OldLoc, Dir)
|
||||
. = ..()
|
||||
for (var/datum/light_source/L in light_sources) // Cycle through the light sources on this atom and tell them to update.
|
||||
var/datum/light_source/L
|
||||
var/thing
|
||||
for (thing in light_sources) // Cycle through the light sources on this atom and tell them to update.
|
||||
L = thing
|
||||
L.source_atom.update_light()
|
||||
|
||||
/atom/vv_edit_var(var_name, var_value)
|
||||
switch (var_name)
|
||||
if ("light_range")
|
||||
set_light(l_range=var_value)
|
||||
var_edited = TRUE
|
||||
return
|
||||
|
||||
if ("light_power")
|
||||
set_light(l_power=var_value)
|
||||
var_edited = TRUE
|
||||
return
|
||||
|
||||
if ("light_color")
|
||||
set_light(l_color=var_value)
|
||||
var_edited = TRUE
|
||||
return
|
||||
|
||||
return ..()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/var/list/datum/lighting_corner/all_lighting_corners = list()
|
||||
// Because we can control each corner of every lighting overlay.
|
||||
/var/datum/lighting_corner/dummy/dummy_lighting_corner = new
|
||||
// Because we can control each corner of every lighting object.
|
||||
// And corners get shared between multiple turfs (unless you're on the corners of the map, then 1 corner doesn't).
|
||||
// For the record: these should never ever ever be deleted, even if the turf doesn't have dynamic lighting.
|
||||
|
||||
@@ -7,8 +8,8 @@
|
||||
/var/list/LIGHTING_CORNER_DIAGONAL = list(NORTHEAST, SOUTHEAST, SOUTHWEST, NORTHWEST)
|
||||
|
||||
/datum/lighting_corner
|
||||
var/list/turf/masters
|
||||
var/list/datum/light_source/affecting// Light sources affecting us.
|
||||
var/list/turf/masters = list()
|
||||
var/list/datum/light_source/affecting = list() // Light sources affecting us.
|
||||
var/active = FALSE // TRUE if one of our masters has dynamic lighting.
|
||||
|
||||
var/x = 0
|
||||
@@ -29,8 +30,8 @@
|
||||
var/update_gen = 0
|
||||
|
||||
/datum/lighting_corner/New(var/turf/new_turf, var/diagonal)
|
||||
masters = list()
|
||||
affecting = list()
|
||||
. = ..()
|
||||
|
||||
all_lighting_corners += src
|
||||
|
||||
masters[new_turf] = turn(diagonal, 180)
|
||||
@@ -50,49 +51,44 @@
|
||||
|
||||
// Diagonal one is easy.
|
||||
T = get_step(new_turf, diagonal)
|
||||
var/corners
|
||||
if (T) // In case we're on the map's border.
|
||||
corners = T.corners
|
||||
if (!corners)
|
||||
corners = list(null, null, null, null)
|
||||
T.corners = corners
|
||||
if (T) // In case we're on the map's border.
|
||||
if (!T.corners)
|
||||
T.corners = list(null, null, null, null)
|
||||
|
||||
masters[T] = diagonal
|
||||
i = LIGHTING_CORNER_DIAGONAL.Find(turn(diagonal, 180))
|
||||
corners[i] = src
|
||||
T.corners[i] = src
|
||||
|
||||
// Now the horizontal one.
|
||||
T = get_step(new_turf, horizontal)
|
||||
if (T) // Ditto.
|
||||
corners = T.corners
|
||||
if (!T.corners)
|
||||
corners = list(null, null, null, null)
|
||||
T.corners = corners
|
||||
T.corners = list(null, null, null, null)
|
||||
|
||||
masters[T] = ((T.x > x) ? EAST : WEST) | ((T.y > y) ? NORTH : SOUTH) // Get the dir based on coordinates.
|
||||
i = LIGHTING_CORNER_DIAGONAL.Find(turn(masters[T], 180))
|
||||
corners[i] = src
|
||||
T.corners[i] = src
|
||||
|
||||
// And finally the vertical one.
|
||||
T = get_step(new_turf, vertical)
|
||||
if (T)
|
||||
corners = T.corners
|
||||
if (!T.corners)
|
||||
corners = list(null, null, null, null)
|
||||
T.corners = corners
|
||||
T.corners = list(null, null, null, null)
|
||||
|
||||
masters[T] = ((T.x > x) ? EAST : WEST) | ((T.y > y) ? NORTH : SOUTH) // Get the dir based on coordinates.
|
||||
i = LIGHTING_CORNER_DIAGONAL.Find(turn(masters[T], 180))
|
||||
corners[i] = src
|
||||
T.corners[i] = src
|
||||
|
||||
update_active()
|
||||
|
||||
/datum/lighting_corner/proc/update_active()
|
||||
active = FALSE
|
||||
for (var/turf/T in masters)
|
||||
if (T.lighting_overlay)
|
||||
var/turf/T
|
||||
var/thing
|
||||
for (thing in masters)
|
||||
T = thing
|
||||
if (T.lighting_object)
|
||||
active = TRUE
|
||||
break
|
||||
|
||||
// God that was a mess, now to do the rest of the corner code! Hooray!
|
||||
/datum/lighting_corner/proc/update_lumcount(var/delta_r, var/delta_g, var/delta_b)
|
||||
@@ -104,8 +100,8 @@
|
||||
needs_update = TRUE
|
||||
lighting_update_corners += src
|
||||
|
||||
/datum/lighting_corner/proc/update_overlays()
|
||||
// Cache these values a head of time so 4 individual lighting overlays don't all calculate them individually.
|
||||
/datum/lighting_corner/proc/update_objects()
|
||||
// Cache these values a head of time so 4 individual lighting objects don't all calculate them individually.
|
||||
var/mx = max(lum_r, lum_g, lum_b) // Scale it so one of them is the strongest lum, if it is above 1.
|
||||
. = 1 // factor
|
||||
if (mx > 1)
|
||||
@@ -115,22 +111,22 @@
|
||||
else if (mx < LIGHTING_SOFT_THRESHOLD)
|
||||
. = 0 // 0 means soft lighting.
|
||||
|
||||
cache_r = lum_r * . + (rand(1,999)/100000) || LIGHTING_SOFT_THRESHOLD
|
||||
cache_g = lum_g * . + (rand(1,999)/100000) || LIGHTING_SOFT_THRESHOLD
|
||||
cache_b = lum_b * . + (rand(1,999)/100000) || LIGHTING_SOFT_THRESHOLD
|
||||
cache_r = lum_r * . || LIGHTING_SOFT_THRESHOLD
|
||||
cache_g = lum_g * . || LIGHTING_SOFT_THRESHOLD
|
||||
cache_b = lum_b * . || LIGHTING_SOFT_THRESHOLD
|
||||
#else
|
||||
cache_r = lum_r * . + (rand(1,999)/100000)
|
||||
cache_g = lum_g * . + (rand(1,999)/100000)
|
||||
cache_b = lum_b * . + (rand(1,999)/100000)
|
||||
cache_r = lum_r * .
|
||||
cache_g = lum_g * .
|
||||
cache_b = lum_b * .
|
||||
#endif
|
||||
cache_mx = mx
|
||||
|
||||
for (var/TT in masters)
|
||||
var/turf/T = TT
|
||||
var/atom/movable/lighting_overlay/lo = T.lighting_overlay
|
||||
if (lo && !lo.needs_update)
|
||||
lo.needs_update = TRUE
|
||||
lighting_update_overlays += lo
|
||||
if (T.lighting_object)
|
||||
if (!T.lighting_object.needs_update)
|
||||
T.lighting_object.needs_update = TRUE
|
||||
lighting_update_objects += T.lighting_object
|
||||
|
||||
|
||||
/datum/lighting_corner/dummy/New()
|
||||
@@ -138,6 +134,9 @@
|
||||
|
||||
|
||||
/datum/lighting_corner/Destroy(var/force)
|
||||
stack_trace("Ok, Look, TG, I need you to find whatever fucker decided to call qdel on a fucking lighting overlay, then tell him very nicely and politely that he is 100% retarded and needs his head checked. Thanks. Send them my regards by the way.")
|
||||
if (!force)
|
||||
return QDEL_HINT_LETMELIVE
|
||||
|
||||
stack_trace("Ok, Look, TG, I need you to find whatever fucker decided to call qdel on a fucking lighting corner, then tell him very nicely and politely that he is 100% retarded and needs his head checked. Thanks. Send them my regards by the way.")
|
||||
// Yeah fuck you anyways.
|
||||
return QDEL_HINT_LETMELIVE
|
||||
|
||||
+23
-26
@@ -1,6 +1,6 @@
|
||||
/var/list/all_lighting_overlays = list() // Global list of lighting overlays.
|
||||
/var/list/all_lighting_objects = list() // Global list of lighting objects.
|
||||
|
||||
/atom/movable/lighting_overlay
|
||||
/atom/movable/lighting_object
|
||||
name = ""
|
||||
|
||||
anchored = TRUE
|
||||
@@ -16,13 +16,13 @@
|
||||
|
||||
var/needs_update = FALSE
|
||||
|
||||
/atom/movable/lighting_overlay/Initialize(mapload, var/no_update = FALSE)
|
||||
/atom/movable/lighting_object/Initialize(mapload, var/no_update = FALSE)
|
||||
. = ..()
|
||||
verbs.Cut()
|
||||
global.all_lighting_overlays += src
|
||||
global.all_lighting_objects += src
|
||||
|
||||
var/turf/T = loc // If this runtimes atleast we'll know what's creating overlays in things that aren't turfs.
|
||||
T.lighting_overlay = src
|
||||
T.lighting_object = src
|
||||
T.luminosity = 0
|
||||
|
||||
for(var/turf/open/space/S in RANGE_TURFS(1, src)) //RANGE_TURFS is in code\__HELPERS\game.dm
|
||||
@@ -31,30 +31,30 @@
|
||||
if (no_update)
|
||||
return
|
||||
|
||||
update_overlay()
|
||||
update()
|
||||
|
||||
/atom/movable/lighting_overlay/Destroy(var/force)
|
||||
/atom/movable/lighting_object/Destroy(var/force)
|
||||
if (force)
|
||||
global.all_lighting_overlays -= src
|
||||
global.lighting_update_overlays -= src
|
||||
global.all_lighting_objects -= src
|
||||
global.lighting_update_objects -= src
|
||||
|
||||
var/turf/T = loc
|
||||
if (istype(T))
|
||||
T.lighting_overlay = null
|
||||
T.lighting_object = null
|
||||
T.luminosity = 1
|
||||
|
||||
return ..()
|
||||
else
|
||||
return QDEL_HINT_LETMELIVE
|
||||
|
||||
/atom/movable/lighting_overlay/proc/update_overlay()
|
||||
/atom/movable/lighting_object/proc/update()
|
||||
var/turf/T = loc
|
||||
if (!istype(T)) // Erm...
|
||||
if (loc)
|
||||
WARNING("A lighting overlay realised its loc was NOT a turf (actual loc: [loc], [loc.type]) in update_overlay()!")
|
||||
warning("A lighting object realised its loc was NOT a turf (actual loc: [loc], [loc.type]) in update()!")
|
||||
|
||||
else
|
||||
WARNING("A lighting overlay realised it was in nullspace in update_overlay()!")
|
||||
warning("A lighting object realised it was in nullspace in update()!")
|
||||
|
||||
qdel(src, TRUE)
|
||||
return
|
||||
@@ -68,13 +68,10 @@
|
||||
// Including with these comments.
|
||||
|
||||
// See LIGHTING_CORNER_DIAGONAL in lighting_corner.dm for why these values are what they are.
|
||||
// No I seriously cannot think of a more efficient method, fuck off Comic.
|
||||
var/list/corners = T.corners
|
||||
var/static/datum/lighting_corner/dummy/dummy_lighting_corner = new
|
||||
var/datum/lighting_corner/cr = corners[3] || dummy_lighting_corner
|
||||
var/datum/lighting_corner/cg = corners[2] || dummy_lighting_corner
|
||||
var/datum/lighting_corner/cb = corners[4] || dummy_lighting_corner
|
||||
var/datum/lighting_corner/ca = corners[1] || dummy_lighting_corner
|
||||
var/datum/lighting_corner/cr = T.corners[3] || dummy_lighting_corner
|
||||
var/datum/lighting_corner/cg = T.corners[2] || dummy_lighting_corner
|
||||
var/datum/lighting_corner/cb = T.corners[4] || dummy_lighting_corner
|
||||
var/datum/lighting_corner/ca = T.corners[1] || dummy_lighting_corner
|
||||
|
||||
var/max = max(cr.cache_mx, cg.cache_mx, cb.cache_mx, ca.cache_mx)
|
||||
|
||||
@@ -95,23 +92,23 @@
|
||||
|
||||
// Variety of overrides so the overlays don't get affected by weird things.
|
||||
|
||||
/atom/movable/lighting_overlay/ex_act(severity)
|
||||
/atom/movable/lighting_object/ex_act(severity)
|
||||
return 0
|
||||
|
||||
/atom/movable/lighting_overlay/singularity_act()
|
||||
/atom/movable/lighting_object/singularity_act()
|
||||
return
|
||||
|
||||
/atom/movable/lighting_overlay/singularity_pull()
|
||||
/atom/movable/lighting_object/singularity_pull()
|
||||
return
|
||||
|
||||
/atom/movable/lighting_overlay/blob_act()
|
||||
/atom/movable/lighting_object/blob_act()
|
||||
return
|
||||
|
||||
// Nope nope nope!
|
||||
/atom/movable/lighting_overlay/onShuttleMove(turf/T1, rotation)
|
||||
/atom/movable/lighting_object/onShuttleMove(turf/T1, rotation)
|
||||
return FALSE
|
||||
|
||||
// Override here to prevent things accidentally moving around overlays.
|
||||
/atom/movable/lighting_overlay/forceMove(atom/destination, var/no_tp=FALSE, var/harderforce = FALSE)
|
||||
/atom/movable/lighting_object/forceMove(atom/destination, var/no_tp=FALSE, var/harderforce = FALSE)
|
||||
if(harderforce)
|
||||
. = ..()
|
||||
@@ -1,11 +1,13 @@
|
||||
/proc/create_all_lighting_overlays()
|
||||
/proc/create_all_lighting_objects()
|
||||
for (var/zlevel = 1 to world.maxz)
|
||||
create_lighting_overlays_zlevel(zlevel)
|
||||
create_lighting_objects_zlevel(zlevel)
|
||||
|
||||
/proc/create_lighting_overlays_zlevel(var/zlevel)
|
||||
/proc/create_lighting_objects_zlevel(zlevel)
|
||||
ASSERT(zlevel)
|
||||
|
||||
for (var/turf/T in block(locate(1, 1, zlevel), locate(world.maxx, world.maxy, zlevel)))
|
||||
var/turf/T
|
||||
var/thing
|
||||
for (thing in block(locate(1, 1, zlevel), locate(world.maxx, world.maxy, zlevel)))
|
||||
T = thing
|
||||
if (!IS_DYNAMIC_LIGHTING(T))
|
||||
continue
|
||||
|
||||
@@ -13,5 +15,5 @@
|
||||
if (!IS_DYNAMIC_LIGHTING(A))
|
||||
continue
|
||||
|
||||
new/atom/movable/lighting_overlay(T, TRUE)
|
||||
new/atom/movable/lighting_object(T, TRUE)
|
||||
CHECK_TICK
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
var/atom/source_atom // The atom that we belong to.
|
||||
|
||||
var/turf/source_turf // The turf under the above.
|
||||
var/turf/pixel_turf // The turf the top_atom appears to over.
|
||||
var/light_power // Intensity of the emitter light.
|
||||
var/light_range // The range of the emitted light.
|
||||
var/light_color // The colour of the light, string, decomposed by parse_light_color()
|
||||
@@ -44,6 +45,8 @@
|
||||
top_atom.light_sources += src
|
||||
|
||||
source_turf = top_atom
|
||||
pixel_turf = get_turf_pixel(top_atom) || source_turf
|
||||
|
||||
light_power = source_atom.light_power
|
||||
light_range = source_atom.light_range
|
||||
light_color = source_atom.light_color
|
||||
@@ -121,10 +124,17 @@
|
||||
if (isturf(top_atom))
|
||||
if (source_turf != top_atom)
|
||||
source_turf = top_atom
|
||||
pixel_turf = source_turf
|
||||
. = 1
|
||||
else if (top_atom.loc != source_turf)
|
||||
source_turf = top_atom.loc
|
||||
pixel_turf = get_turf_pixel(top_atom)
|
||||
. = 1
|
||||
else
|
||||
var/P = get_turf_pixel(top_atom)
|
||||
if (P != pixel_turf)
|
||||
. = 1
|
||||
pixel_turf = get_turf_pixel(top_atom)
|
||||
|
||||
if (source_atom.light_power != light_power)
|
||||
light_power = source_atom.light_power
|
||||
@@ -158,9 +168,9 @@
|
||||
// If you're wondering what's with the backslashes, the backslashes cause BYOND to not automatically end the line.
|
||||
// As such this all gets counted as a single line.
|
||||
// The braces and semicolons are there to be able to do this on a single line.
|
||||
|
||||
#define LUM_FALLOFF(C, T) (1 - CLAMP01(sqrt((C.x - T.x) ** 2 + (C.y - T.y) ** 2 + LIGHTING_HEIGHT) / max(1, light_range)))
|
||||
#define APPLY_CORNER(C) \
|
||||
. = LUM_FALLOFF(C, source_turf); \
|
||||
. = LUM_FALLOFF(C, pixel_turf); \
|
||||
\
|
||||
. *= light_power; \
|
||||
\
|
||||
@@ -184,7 +194,7 @@
|
||||
);
|
||||
|
||||
// This is the define used to calculate falloff.
|
||||
#define LUM_FALLOFF(C, T) (1 - CLAMP01(sqrt((C.x - T.x) ** 2 + (C.y - T.y) ** 2 + LIGHTING_HEIGHT) / max(1, light_range)))
|
||||
|
||||
|
||||
/datum/light_source/proc/apply_lum()
|
||||
var/static/update_gen = 1
|
||||
@@ -194,17 +204,19 @@
|
||||
applied_lum_r = lum_r
|
||||
applied_lum_g = lum_g
|
||||
applied_lum_b = lum_b
|
||||
|
||||
FOR_DVIEW(var/turf/T, light_range, source_turf, INVISIBILITY_LIGHTING)
|
||||
var/thing
|
||||
var/datum/lighting_corner/C
|
||||
FOR_DVIEW(var/turf/T, light_range+1, source_turf, INVISIBILITY_LIGHTING)
|
||||
if (!T.lighting_corners_initialised)
|
||||
T.generate_missing_corners()
|
||||
|
||||
for (var/datum/lighting_corner/C in T.get_corners())
|
||||
for (thing in T.get_corners())
|
||||
C = thing
|
||||
if (C.update_gen == update_gen)
|
||||
continue
|
||||
|
||||
C.update_gen = update_gen
|
||||
C.affecting += src
|
||||
LAZYADD(C.affecting,src)
|
||||
|
||||
if (!C.active)
|
||||
effect_str[C] = 0
|
||||
@@ -212,29 +224,26 @@
|
||||
|
||||
APPLY_CORNER(C)
|
||||
|
||||
if (!T.affecting_lights)
|
||||
T.affecting_lights = list()
|
||||
|
||||
T.affecting_lights += src
|
||||
LAZYADD(T.affecting_lights, src)
|
||||
affecting_turfs += T
|
||||
|
||||
update_gen++
|
||||
|
||||
/datum/light_source/proc/remove_lum()
|
||||
applied = FALSE
|
||||
|
||||
for (var/turf/T in affecting_turfs)
|
||||
if (!T.affecting_lights)
|
||||
T.affecting_lights = list()
|
||||
else
|
||||
T.affecting_lights -= src
|
||||
var/thing
|
||||
for (thing in affecting_turfs)
|
||||
var/turf/T = thing
|
||||
LAZYREMOVE(T.affecting_lights, src)
|
||||
|
||||
affecting_turfs.Cut()
|
||||
|
||||
for (var/datum/lighting_corner/C in effect_str)
|
||||
var/datum/lighting_corner/C
|
||||
for (thing in effect_str)
|
||||
C = thing
|
||||
REMOVE_CORNER(C)
|
||||
|
||||
C.affecting -= src
|
||||
LAZYREMOVE(C.affecting, src)
|
||||
|
||||
effect_str.Cut()
|
||||
|
||||
@@ -247,39 +256,48 @@
|
||||
/datum/light_source/proc/smart_vis_update()
|
||||
var/list/datum/lighting_corner/corners = list()
|
||||
var/list/turf/turfs = list()
|
||||
FOR_DVIEW(var/turf/T, light_range, source_turf, 0)
|
||||
var/thing
|
||||
var/datum/lighting_corner/C
|
||||
var/turf/T
|
||||
|
||||
FOR_DVIEW(T, light_range+1, source_turf, 0)
|
||||
if (!T.lighting_corners_initialised)
|
||||
T.generate_missing_corners()
|
||||
corners |= T.get_corners()
|
||||
turfs += T
|
||||
for (thing in T.get_corners(source_turf))
|
||||
C = thing
|
||||
corners[C] = 0
|
||||
turfs += T
|
||||
|
||||
var/list/L = turfs - affecting_turfs // New turfs, add us to the affecting lights of them.
|
||||
affecting_turfs += L
|
||||
for (var/turf/T in L)
|
||||
if (!T.affecting_lights)
|
||||
T.affecting_lights = list(src)
|
||||
else
|
||||
T.affecting_lights += src
|
||||
for (thing in L)
|
||||
T = thing
|
||||
LAZYADD(T.affecting_lights, src)
|
||||
|
||||
L = affecting_turfs - turfs // Now-gone turfs, remove us from the affecting lights.
|
||||
affecting_turfs -= L
|
||||
for (var/turf/T in L)
|
||||
T.affecting_lights -= src
|
||||
for (thing in L)
|
||||
T = thing
|
||||
LAZYREMOVE(T.affecting_lights, src)
|
||||
|
||||
for (var/datum/lighting_corner/C in corners - effect_str) // New corners
|
||||
C.affecting += src
|
||||
|
||||
|
||||
for (thing in corners - effect_str) // New corners
|
||||
C = thing
|
||||
LAZYADD(C.affecting, src)
|
||||
if (!C.active)
|
||||
effect_str[C] = 0
|
||||
continue
|
||||
|
||||
APPLY_CORNER(C)
|
||||
|
||||
for (var/datum/lighting_corner/C in effect_str - corners) // Old, now gone, corners.
|
||||
for (thing in effect_str - corners) // Old, now gone, corners.
|
||||
C = thing
|
||||
REMOVE_CORNER(C)
|
||||
C.affecting -= src
|
||||
LAZYREMOVE(C.affecting, src)
|
||||
effect_str -= C
|
||||
|
||||
#undef effect_update
|
||||
#undef EFFECT_UPDATE
|
||||
#undef LUM_FALLOFF
|
||||
#undef REMOVE_CORNER
|
||||
#undef APPLY_CORNER
|
||||
|
||||
@@ -5,49 +5,63 @@
|
||||
var/tmp/lighting_corners_initialised = FALSE
|
||||
|
||||
var/tmp/list/datum/light_source/affecting_lights // List of light sources affecting this turf.
|
||||
var/tmp/atom/movable/lighting_overlay/lighting_overlay // Our lighting overlay.
|
||||
var/tmp/atom/movable/lighting_object/lighting_object // Our lighting object.
|
||||
var/tmp/list/datum/lighting_corner/corners
|
||||
var/tmp/has_opaque_atom = FALSE // Not to be confused with opacity, this will be TRUE if there's any opaque atom on the tile.
|
||||
|
||||
// Causes any affecting light sources to be queued for a visibility update, for example a door got opened.
|
||||
/turf/proc/reconsider_lights()
|
||||
for (var/datum/light_source/L in affecting_lights)
|
||||
var/datum/light_source/L
|
||||
var/thing
|
||||
for (thing in affecting_lights)
|
||||
L = thing
|
||||
L.vis_update()
|
||||
|
||||
/turf/proc/lighting_clear_overlay()
|
||||
var/lo = lighting_overlay
|
||||
if (lo)
|
||||
qdel(lo, TRUE)
|
||||
if (lighting_object)
|
||||
qdel(lighting_object, TRUE)
|
||||
|
||||
for (var/datum/lighting_corner/C in corners)
|
||||
var/datum/lighting_corner/C
|
||||
var/thing
|
||||
for (thing in corners)
|
||||
C = thing
|
||||
C.update_active()
|
||||
|
||||
// Builds a lighting overlay for us, but only if our area is dynamic.
|
||||
// Builds a lighting object for us, but only if our area is dynamic.
|
||||
/turf/proc/lighting_build_overlay()
|
||||
if (lighting_overlay)
|
||||
if (lighting_object)
|
||||
return
|
||||
|
||||
var/area/A = loc
|
||||
if (IS_DYNAMIC_LIGHTING(A))
|
||||
if (!lighting_corners_initialised)
|
||||
generate_missing_corners()
|
||||
if (!IS_DYNAMIC_LIGHTING(A))
|
||||
return
|
||||
|
||||
new/atom/movable/lighting_overlay(src)
|
||||
if (!lighting_corners_initialised)
|
||||
generate_missing_corners()
|
||||
|
||||
for (var/datum/lighting_corner/C in corners)
|
||||
if (!C.active) // We would activate the corner, calculate the lighting for it.
|
||||
for (var/datum/light_source/S in C.affecting)
|
||||
S.recalc_corner(C)
|
||||
new/atom/movable/lighting_object(src)
|
||||
|
||||
C.active = TRUE
|
||||
var/thing
|
||||
var/datum/lighting_corner/C
|
||||
var/datum/light_source/S
|
||||
for (thing in corners)
|
||||
C = thing
|
||||
if (!C.active) // We would activate the corner, calculate the lighting for it.
|
||||
for (thing in C.affecting)
|
||||
S = thing
|
||||
S.recalc_corner(C)
|
||||
C.active = TRUE
|
||||
|
||||
// Used to get a scaled lumcount.
|
||||
/turf/proc/get_lumcount(var/minlum = 0, var/maxlum = 1)
|
||||
if (!lighting_overlay)
|
||||
if (!lighting_object)
|
||||
return 1
|
||||
|
||||
var/totallums = 0
|
||||
for (var/datum/lighting_corner/L in corners)
|
||||
var/thing
|
||||
var/datum/lighting_corner/L
|
||||
for (thing in corners)
|
||||
L = thing
|
||||
totallums += L.lum_r + L.lum_b + L.lum_g
|
||||
|
||||
totallums /= 12 // 4 corners, each with 3 channels, get the average.
|
||||
@@ -61,17 +75,19 @@
|
||||
// itself as too dark to allow sight and see_in_dark becomes useful.
|
||||
// So basically if this returns true the tile is unlit black.
|
||||
/turf/proc/is_softly_lit()
|
||||
if (!lighting_overlay)
|
||||
if (!lighting_object)
|
||||
return FALSE
|
||||
|
||||
return !lighting_overlay.luminosity
|
||||
return !lighting_object.luminosity
|
||||
|
||||
// Can't think of a good name, this proc will recalculate the has_opaque_atom variable.
|
||||
/turf/proc/recalc_atom_opacity()
|
||||
has_opaque_atom = FALSE
|
||||
for (var/atom/A in src.contents + src) // Loop through every movable atom on our tile PLUS ourselves (we matter too...)
|
||||
if (A.opacity)
|
||||
has_opaque_atom = TRUE
|
||||
has_opaque_atom = opacity
|
||||
if (!has_opaque_atom)
|
||||
for (var/atom/A in src.contents) // Loop through every movable atom on our tile PLUS ourselves (we matter too...)
|
||||
if (A.opacity)
|
||||
has_opaque_atom = TRUE
|
||||
break
|
||||
|
||||
// If an opaque movable atom moves around we need to potentially update visibility.
|
||||
/turf/Entered(var/atom/movable/Obj, var/atom/OldLoc)
|
||||
@@ -89,9 +105,8 @@
|
||||
reconsider_lights()
|
||||
|
||||
/turf/proc/change_area(var/area/old_area, var/area/new_area)
|
||||
var/nadl = new_area.dynamic_lighting
|
||||
if (nadl != old_area.dynamic_lighting)
|
||||
if (nadl)
|
||||
if (new_area.dynamic_lighting != old_area.dynamic_lighting)
|
||||
if (new_area.dynamic_lighting)
|
||||
lighting_build_overlay()
|
||||
|
||||
else
|
||||
@@ -105,16 +120,14 @@
|
||||
|
||||
/turf/proc/generate_missing_corners()
|
||||
lighting_corners_initialised = TRUE
|
||||
var/ccorners = corners
|
||||
if (!ccorners)
|
||||
ccorners = list(null, null, null, null)
|
||||
corners = ccorners
|
||||
if (!corners)
|
||||
corners = list(null, null, null, null)
|
||||
|
||||
for (var/i = 1 to 4)
|
||||
if (ccorners[i]) // Already have a corner on this direction.
|
||||
if (corners[i]) // Already have a corner on this direction.
|
||||
continue
|
||||
|
||||
ccorners[i] = new/datum/lighting_corner(src, LIGHTING_CORNER_DIAGONAL[i])
|
||||
corners[i] = new/datum/lighting_corner(src, LIGHTING_CORNER_DIAGONAL[i])
|
||||
|
||||
|
||||
/turf/ChangeTurf(path)
|
||||
@@ -124,13 +137,13 @@
|
||||
var/old_opacity = opacity
|
||||
var/old_dynamic_lighting = dynamic_lighting
|
||||
var/old_affecting_lights = affecting_lights
|
||||
var/old_lighting_overlay = lighting_overlay
|
||||
var/old_lighting_object = lighting_object
|
||||
var/old_corners = corners
|
||||
|
||||
. = ..() //At this point the turf has changed
|
||||
|
||||
recalc_atom_opacity()
|
||||
lighting_overlay = old_lighting_overlay
|
||||
lighting_object = old_lighting_object
|
||||
affecting_lights = old_affecting_lights
|
||||
corners = old_corners
|
||||
if (old_opacity != opacity || dynamic_lighting != old_dynamic_lighting)
|
||||
|
||||
Reference in New Issue
Block a user