mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-06-05 13:34:25 +01:00
f4bf017921
* Unit Test rework & Master/Ticker update * Fixes and working unit testing * Fixes * Test fixes and FA update * Fixed runtimes * Radio subsystem * move that glob wherever later * ident * CIBUILDING compile option * Fixed runtimes * Some changes to the workflow * CI Split * More split * Pathing * Linters and Annotators * ci dir fix * Missing undef fixed * Enable grep checks * More test conversions * More split * Correct file * Removes unneeded inputs * oop * More dependency changes * More conversions * Conversion fixes * Fixes * Some assert fixes * Corrects start gate * Converted some README.dms to README.mds * Removes duplicate proc * Removes unused defines * Example configs * fix dll access viol by double calling * Post-rebase fixes * Cleans up names global list * Undef restart counter * More code/game/ cleanup * Statpanel update * Skybox * add * Fix ticker * Roundend fix * Persistence dependency update * Reordering * Reordering * Reordering * Initstage fix * . * . * Reorder * Reorder * Circle * Mobs * Air * Test fix * CI Script Fix * Configs * More ticker stuff * This is now in 'reboot world' * Restart world announcements * no glob in PreInit * to define * Update * Removed old include * Make this file normal again * moved * test * shared unit testing objects * Updates batched_spritesheets and universal_icon * . * job data debug * rm that * init order * show us * . * i wonder * . * . * urg * do we not have a job ID? * . * rm sleep for now * updated rust-g linux binaries * binaries update 2 * binaries update 3 * testing something * change that * test something * . * . * . * locavar * test * move that * . * debug * don't run this test * strack trace it * cleaner * . * . * cras again * also comment this out * return to official rust g * Update robot_icons.dm * monitor the generation * . --------- Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
140 lines
4.5 KiB
Plaintext
140 lines
4.5 KiB
Plaintext
/turf
|
|
///Lumcount added by sources other than lighting datum objects, such as the overlay lighting component.
|
|
var/dynamic_lumcount = 0
|
|
|
|
var/dynamic_lighting = TRUE
|
|
|
|
var/tmp/lighting_corners_initialised = FALSE
|
|
|
|
var/tmp/outdoors_adjacent = FALSE
|
|
///Our lighting object.
|
|
var/tmp/datum/lighting_object/lighting_object
|
|
///Lighting Corner datums.
|
|
var/tmp/datum/lighting_corner/lighting_corner_NE
|
|
var/tmp/datum/lighting_corner/lighting_corner_SE
|
|
var/tmp/datum/lighting_corner/lighting_corner_SW
|
|
var/tmp/datum/lighting_corner/lighting_corner_NW
|
|
|
|
///Which directions does this turf block the vision of, taking into account both the turf's opacity and the movable opacity_sources.
|
|
var/directional_opacity = NONE
|
|
///Lazylist of movable atoms providing opacity sources.
|
|
var/list/atom/movable/opacity_sources
|
|
|
|
// Causes any affecting light sources to be queued for a visibility update, for example a door got opened.
|
|
/turf/proc/reconsider_lights()
|
|
lighting_corner_NE?.vis_update()
|
|
lighting_corner_SE?.vis_update()
|
|
lighting_corner_SW?.vis_update()
|
|
lighting_corner_NW?.vis_update()
|
|
|
|
/turf/proc/lighting_clear_overlay()
|
|
if(lighting_object)
|
|
qdel(lighting_object, force=TRUE)
|
|
|
|
// Builds a lighting object for us, but only if our area is dynamic.
|
|
/turf/proc/lighting_build_overlay()
|
|
if(!has_dynamic_lighting())
|
|
return
|
|
|
|
lighting_clear_overlay()
|
|
new/datum/lighting_object(src)
|
|
|
|
// Used to get a scaled lumcount.
|
|
/turf/proc/get_lumcount(minlum = 0, maxlum = 1)
|
|
if (!lighting_object)
|
|
return 1
|
|
|
|
var/totallums = 0
|
|
var/datum/lighting_corner/L
|
|
L = lighting_corner_NE
|
|
if (L)
|
|
totallums += L.lum_r + L.lum_b + L.lum_g
|
|
L = lighting_corner_SE
|
|
if (L)
|
|
totallums += L.lum_r + L.lum_b + L.lum_g
|
|
L = lighting_corner_SW
|
|
if (L)
|
|
totallums += L.lum_r + L.lum_b + L.lum_g
|
|
L = lighting_corner_NW
|
|
if (L)
|
|
totallums += L.lum_r + L.lum_b + L.lum_g
|
|
|
|
|
|
totallums /= 12 // 4 corners, each with 3 channels, get the average.
|
|
|
|
totallums = (totallums - minlum) / (maxlum - minlum)
|
|
|
|
totallums += dynamic_lumcount
|
|
|
|
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 !(luminosity || dynamic_lumcount)
|
|
|
|
|
|
///Proc to add movable sources of opacity on the turf and let it handle lighting code.
|
|
/turf/proc/add_opacity_source(atom/movable/new_source)
|
|
LAZYADD(opacity_sources, new_source)
|
|
if(opacity)
|
|
return
|
|
recalculate_directional_opacity()
|
|
|
|
|
|
///Proc to remove movable sources of opacity on the turf and let it handle lighting code.
|
|
/turf/proc/remove_opacity_source(atom/movable/old_source)
|
|
LAZYREMOVE(opacity_sources, old_source)
|
|
if(opacity) //Still opaque, no need to worry on updating.
|
|
return
|
|
recalculate_directional_opacity()
|
|
|
|
///Setter for the byond luminosity var
|
|
/turf/proc/set_luminosity(new_luminosity, force)
|
|
if(((is_outdoors() && !force) || outdoors_adjacent) && (z in fake_sunlight_zs)) //Special exception for fakesun lit tiles
|
|
return
|
|
|
|
luminosity = new_luminosity
|
|
|
|
///Checks planets and fake_suns to see if our turf should be handled by either
|
|
/turf/proc/check_for_sun()
|
|
if((SSplanets && SSplanets.z_to_planet.len >= z && SSplanets.z_to_planet[z]) || (z in fake_sunlight_zs))
|
|
return TRUE
|
|
return FALSE
|
|
|
|
///Calculate on which directions this turfs block view.
|
|
/turf/proc/recalculate_directional_opacity()
|
|
. = directional_opacity
|
|
if(opacity)
|
|
directional_opacity = ALL_CARDINALS
|
|
if(. != directional_opacity)
|
|
reconsider_lights()
|
|
return
|
|
directional_opacity = NONE
|
|
for(var/atom/movable/opacity_source as anything in opacity_sources)
|
|
if(opacity_source && opacity_source.flags & ON_BORDER)
|
|
directional_opacity |= opacity_source.dir
|
|
else //If fulltile and opaque, then the whole tile blocks view, no need to continue checking.
|
|
directional_opacity = ALL_CARDINALS
|
|
break
|
|
if(. != directional_opacity && (. == ALL_CARDINALS || directional_opacity == ALL_CARDINALS))
|
|
reconsider_lights() //The lighting system only cares whether the tile is fully concealed from all directions or not.
|
|
|
|
|
|
/turf/proc/change_area(area/old_area, area/new_area)
|
|
if(SSlighting.initialized)
|
|
if (new_area.dynamic_lighting != old_area.dynamic_lighting)
|
|
if (new_area.dynamic_lighting)
|
|
lighting_build_overlay()
|
|
else
|
|
lighting_clear_overlay()
|
|
|
|
/turf/proc/has_dynamic_lighting()
|
|
var/area/A = loc
|
|
return (IS_DYNAMIC_LIGHTING(src) && IS_DYNAMIC_LIGHTING(A))
|