Files
Matt Atlas 94d92803b4 Replaces our lighting system with CM's. (#21465)
Depends on #21458.

Ports https://github.com/cmss13-devs/cmss13/pull/4229, with the original
authors as:

- https://github.com/tgstation/TerraGov-Marine-Corps/pull/1964 for the
lighting controller (A-lexa)
- https://github.com/tgstation/TerraGov-Marine-Corps/pull/4747 and
https://github.com/tgstation/TerraGov-Marine-Corps/pull/7263 for the
lighting (TiviPlus)
- https://github.com/tgstation/tgstation/pull/54520 for the dir lighting
component
- https://github.com/tgstation/tgstation/pull/75018 for the out of
bounds fix in lighting
- https://github.com/tgstation/TerraGov-Marine-Corps/pull/6678 for the
emissives (TiviPlus)

The main driving reason behind this is that current lighting consumes
way too much processing power, especially for things like odysseys/away
sites where a billion light sources are processing/moving at once and
the game slows down to a crawl. Hopefully this improves the situation by
a good margin, but we will need some testmerging to confirm that.
<img width="1349" height="1349" alt="image"
src="https://github.com/user-attachments/assets/1059ba2b-c0c5-495a-9c76-2d75d0c42bf2"
/>
<img width="1349" height="1349" alt="image"
src="https://github.com/user-attachments/assets/9704b0f6-4cf6-4dfd-a6cb-5702ad07d677"
/>


- [x] Resolve todos
- [x] Look into open space fuckery (border objects)

---------

Co-authored-by: Matt Atlas <liermattia@gmail.com>
Co-authored-by: JohnWildkins <john.wildkins@gmail.com>
2025-11-04 21:27:42 +00:00

60 lines
1.8 KiB
Plaintext

/area
luminosity = 1
///The mutable appearance we underlay to show light
var/mutable_appearance/lighting_effect = null
///Whether this area has a currently active base lighting, bool
var/area_has_base_lighting = FALSE
///alpha 0-255 of lighting_effect and thus baselighting intensity
var/base_lighting_alpha = 0
///The colour of the light acting on this area
var/base_lighting_color = COLOR_WHITE
/area/proc/set_base_lighting(new_base_lighting_color = -1, new_alpha = -1)
if(base_lighting_alpha == new_alpha && base_lighting_color == new_base_lighting_color)
return FALSE
if(new_alpha != -1)
base_lighting_alpha = new_alpha
if(new_base_lighting_color != -1)
base_lighting_color = new_base_lighting_color
update_base_lighting()
return TRUE
/area/vv_edit_var(var_name, var_value)
switch(var_name)
if("base_lighting_color")
set_base_lighting(new_base_lighting_color = var_value)
return TRUE
if("base_lighting_alpha")
set_base_lighting(new_alpha = var_value)
return TRUE
return ..()
/area/proc/update_base_lighting()
if(!area_has_base_lighting && (!base_lighting_alpha || !base_lighting_color))
return
if(!area_has_base_lighting)
add_base_lighting()
return
remove_base_lighting()
if(base_lighting_alpha && base_lighting_color)
add_base_lighting()
/area/proc/remove_base_lighting()
for(var/turf/T in src)
T.overlays -= lighting_effect
QDEL_NULL(lighting_effect)
area_has_base_lighting = FALSE
/area/proc/add_base_lighting()
lighting_effect = mutable_appearance('icons/effects/alphacolors.dmi', "white")
lighting_effect.plane = LIGHTING_PLANE
lighting_effect.layer = LIGHTING_PRIMARY_LAYER
lighting_effect.blend_mode = BLEND_ADD
lighting_effect.alpha = base_lighting_alpha
lighting_effect.color = base_lighting_color
for(var/turf/T in src)
T.overlays += lighting_effect
T.luminosity = 1
area_has_base_lighting = TRUE