Bleeding edgy refresh (#303)
* not code stuff * other things * global vars, defines, helpers * onclick hud stuff, orphans, world.dm * controllers and datums * game folder * everything not client/mobs in modules * client folder * stage 1 mob stuff * simple animal things * silicons * carbon things * ayylmaos and monkeys * hyoomahn * icons n shit * sprite fixes * compile fixes * some fixes I cherrypicked. * qdel fixes * forgot brain refractors
This commit is contained in:
@@ -1,63 +1,67 @@
|
||||
/turf
|
||||
var/dynamic_lighting = DYNAMIC_LIGHTING_ENABLED
|
||||
var/dynamic_lighting = TRUE
|
||||
luminosity = 1
|
||||
|
||||
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.
|
||||
|
||||
/turf/New()
|
||||
. = ..()
|
||||
|
||||
if (opacity)
|
||||
has_opaque_atom = TRUE
|
||||
|
||||
// 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()
|
||||
if (lighting_overlay)
|
||||
qdel(lighting_overlay, TRUE)
|
||||
lighting_overlay = null
|
||||
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()
|
||||
|
||||
for(var/turf/open/space/S in RANGE_TURFS(1,src)) //RANGE_TURFS is in code\__HELPERS\game.dm
|
||||
S.update_starlight()
|
||||
|
||||
// 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
|
||||
|
||||
PoolOrNew(/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/L in C.affecting)
|
||||
var/datum/light_source/S = L
|
||||
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)
|
||||
return 0.5
|
||||
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.
|
||||
@@ -66,12 +70,24 @@
|
||||
|
||||
return CLAMP01(totallums)
|
||||
|
||||
// Returns a boolean whether the turf is on soft lighting.
|
||||
// Soft lighting being the threshold at which point the overlay considers
|
||||
// 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_object)
|
||||
return FALSE
|
||||
|
||||
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)
|
||||
@@ -88,9 +104,9 @@
|
||||
recalc_atom_opacity() // Make sure to do this before reconsider_lights(), incase we're on instant updates.
|
||||
reconsider_lights()
|
||||
|
||||
/turf/change_area(var/area/old_area, var/area/new_area)
|
||||
if (IS_DYNAMIC_LIGHTING(new_area) != IS_DYNAMIC_LIGHTING(old_area))
|
||||
if (IS_DYNAMIC_LIGHTING(new_area))
|
||||
/turf/proc/change_area(var/area/old_area, var/area/new_area)
|
||||
if (new_area.dynamic_lighting != old_area.dynamic_lighting)
|
||||
if (new_area.dynamic_lighting)
|
||||
lighting_build_overlay()
|
||||
|
||||
else
|
||||
@@ -113,41 +129,31 @@
|
||||
|
||||
corners[i] = new/datum/lighting_corner(src, LIGHTING_CORNER_DIAGONAL[i])
|
||||
|
||||
|
||||
/turf/ChangeTurf(path)
|
||||
if(!path || (!use_preloader && path == type)) //Sucks this is here but it would cause problems otherwise.
|
||||
if (!path || (!use_preloader && path == type) || !SSlighting.initialized)
|
||||
return ..()
|
||||
|
||||
if (!lighting_corners_initialised)
|
||||
if (!corners)
|
||||
corners = list(null, null, null, null)
|
||||
|
||||
for (var/i = 1 to 4)
|
||||
if (corners[i]) // Already have a corner on this direction.
|
||||
continue
|
||||
|
||||
corners[i] = new/datum/lighting_corner(src, LIGHTING_CORNER_DIAGONAL[i])
|
||||
|
||||
|
||||
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
|
||||
|
||||
for(var/obj/effect/decal/cleanable/decal in src.contents)
|
||||
qdel(decal)
|
||||
|
||||
. = ..() //At this point the turf has changed
|
||||
|
||||
lighting_corners_initialised = TRUE
|
||||
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))
|
||||
if (old_opacity != opacity || dynamic_lighting != old_dynamic_lighting)
|
||||
reconsider_lights()
|
||||
if(dynamic_lighting != old_dynamic_lighting)
|
||||
if(IS_DYNAMIC_LIGHTING(src))
|
||||
|
||||
if (dynamic_lighting != old_dynamic_lighting)
|
||||
if (IS_DYNAMIC_LIGHTING(src))
|
||||
lighting_build_overlay()
|
||||
else
|
||||
lighting_clear_overlay()
|
||||
|
||||
for(var/turf/open/space/S in RANGE_TURFS(1, src)) //RANGE_TURFS is in code\__HELPERS\game.dm
|
||||
S.update_starlight()
|
||||
Reference in New Issue
Block a user