Files
Bubberstation/code/modules/lighting/lighting_area.dm
SkyratBot 17a7b8f2fb [MIRROR] Starlight Control (Aurora works now, space gas doesn't touch starlight, narsie ending effects) [MDB IGNORE] (#24406)
* Starlight Control (Aurora works now, space gas doesn't touch starlight, narsie ending effects) (#78877)

## About The Pull Request

[Implements a setter for starlight
variables](af34f06b41)

I want to start to modify starlight more, and that means I need a way to
hook into everything that uses it and update it, so we can modify it on
the fly.

This does that, alongside removing space overlays from nearspace (too
many false positives) and making the aurora modify all turfs projecting
starlight, rather then all turfs in an area.

Do still need to figure out handling for the starlight color usage in
turf underlays tho (I gave up, we just keep it static. I'll fix it
someday but the render_relay strategy just doesn't work with its masking
setup)

[Reworks how starlight overlays
work](9da4bc38e2)

Instead of setting color on the overlays directly, we instead store an
object with our current settings in every mob's screen, and
render_target it down onto our overlays.

This lets us update overlay colors VERY trivially. Just need to set
color on the overlay var. Makes modifying starlight a lot cheaper.

It doesn't work on area overlays, because suffering, and it MIGHT induce
extra cost on clients. if it does we can do something about that, we'll
play it by ear

[Removes parallax starlight
coloring.](5f701a1b13)

I'm sorta iffy on the color, the effect can be real oppressive in some
cases, and I'd like to use starlight color for more events in world, and
having it vary can make that looking nice hard.

[Adds some visual effects to narsie being
summoned](a423cfcb2b)

As the rune drawing progresses space (starlight and parallax) go from
normal to greyscale. Then, right about when narsie shows up, starlight
becomes vibrant red.

It's a nice effect. I wanna do more shit like this, I think it'll
improve vibes significantly.
## Why It's Good For The Game

Can't embed it because of github's upload limit, can show a
[link](https://cdn.discordapp.com/attachments/458452245256601615/1160821856358645860/2023-10-08_22-31-22.mp4?ex=65360e99&is=65239999&hm=680e33e4e0026b89e132afc50c04a648a24f869eb662f274a381a5de5c5a36f2&)
for the narsie stuff

Here's
[one](https://cdn.discordapp.com/attachments/326831214667235328/1160813747196141568/2023-10-08_22-34-10.mp4?ex=6536070c&is=6523920c&hm=f8d571d1013da89887f49f3fec99f632251eeeac83085aa7dde97009aee3922f&)
for the aurora too.

This gives us more pretty starlight shit, and the ABILITY to do more
pretty starlight shit. I'm pretty jazzed, and I hope people use this
proc more (keeping in mind that it's pretty hard on the lighting system,
and needs significant delay between changes)
## Changelog

🆑
add: Narsie summoning has had some effects added to space and starlight
del: Removes the link between spacegas color and starlight. It was a
slight bit too vibrant and I think impacted the vibe too wildly to be
incidental.
fix: The aurora event actually... works now. Space lights up and all
that
/🆑

* Starlight Control (Aurora works now, space gas doesn't touch starlight, narsie ending effects)

* Update space.dm

* Update shuttles.dm

---------

Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com>
Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com>
2023-10-18 01:23:18 -04:00

126 lines
4.9 KiB
Plaintext

/area
luminosity = 1
///List of mutable appearances we underlay to show light
///In the form plane offset + 1 -> appearance to use
var/list/mutable_appearance/lighting_effects = 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(NAMEOF(src, base_lighting_color))
set_base_lighting(new_base_lighting_color = var_value)
return TRUE
if(NAMEOF(src, base_lighting_alpha))
set_base_lighting(new_alpha = var_value)
return TRUE
if(NAMEOF(src, static_lighting))
if(!static_lighting)
create_area_lighting_objects()
else
remove_area_lighting_objects()
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()
UnregisterSignal(SSdcs, COMSIG_STARLIGHT_COLOR_CHANGED)
var/list/z_offsets = SSmapping.z_level_to_plane_offset
if(length(lighting_effects) > 1)
for(var/turf/T as anything in get_contained_turfs())
if(z_offsets[T.z])
T.cut_overlay(lighting_effects[z_offsets[T.z] + 1])
cut_overlay(lighting_effects[1])
lighting_effects = null
area_has_base_lighting = FALSE
/area/proc/add_base_lighting()
lighting_effects = list()
for(var/offset in 0 to SSmapping.max_plane_offset)
var/mutable_appearance/light
if(base_lighting_color == COLOR_STARLIGHT)
light = new(GLOB.starlight_overlays[offset + 1])
else
light = mutable_appearance('icons/effects/alphacolors.dmi', "white")
light.color = base_lighting_color
light.layer = LIGHTING_PRIMARY_LAYER
light.blend_mode = BLEND_ADD
light.appearance_flags = RESET_TRANSFORM | RESET_ALPHA | RESET_COLOR
light.alpha = base_lighting_alpha
SET_PLANE_W_SCALAR(light, LIGHTING_PLANE, offset)
lighting_effects += light
if(base_lighting_color == COLOR_STARLIGHT)
// Ok this is gonna be dumb
// We rely on render_source working, and it DOES NOT APPEAR TO in area rendering
// So we're gonna have to update the area's overlay manually. everything else can be automatic tho
// Fortunately the first overlay is only ever used by the area, soooo
var/mutable_appearance/light = mutable_appearance('icons/effects/alphacolors.dmi', "white")
light.layer = LIGHTING_PRIMARY_LAYER
light.blend_mode = BLEND_ADD
light.appearance_flags = RESET_TRANSFORM | RESET_ALPHA | RESET_COLOR
light.color = GLOB.starlight_color
light.alpha = base_lighting_alpha
SET_PLANE_W_SCALAR(light, LIGHTING_PLANE, 0)
lighting_effects[1] = light
RegisterSignal(SSdcs, COMSIG_STARLIGHT_COLOR_CHANGED, PROC_REF(starlight_changed))
add_overlay(lighting_effects[1])
var/list/z_offsets = SSmapping.z_level_to_plane_offset
if(length(lighting_effects) > 1)
// This inside loop is EXTREMELY hot because it's run by space tiles. Don't want no part in that
for(var/turf/T as anything in get_contained_turfs())
T.luminosity = 1
// We will only add overlays to turfs not on the first z layer, because that's a significantly lesser portion
// And we need to do them separate, or lighting will go fuckey
if(z_offsets[T.z])
T.add_overlay(lighting_effects[z_offsets[T.z] + 1])
else
for(var/turf/T as anything in get_contained_turfs())
T.luminosity = 1
area_has_base_lighting = TRUE
/area/proc/starlight_changed(datum/source, old_star, new_star)
var/mutable_appearance/old_star_effect = mutable_appearance('icons/effects/alphacolors.dmi', "white")
old_star_effect.layer = LIGHTING_PRIMARY_LAYER
old_star_effect.blend_mode = BLEND_ADD
old_star_effect.appearance_flags = RESET_TRANSFORM | RESET_ALPHA | RESET_COLOR
old_star_effect.color = old_star
old_star_effect.alpha = base_lighting_alpha
SET_PLANE_W_SCALAR(old_star_effect, LIGHTING_PLANE, 0)
cut_overlay(old_star_effect)
var/mutable_appearance/new_star_effect = mutable_appearance('icons/effects/alphacolors.dmi', "white")
new_star_effect.layer = LIGHTING_PRIMARY_LAYER
new_star_effect.blend_mode = BLEND_ADD
new_star_effect.appearance_flags = RESET_TRANSFORM | RESET_ALPHA | RESET_COLOR
new_star_effect.color = new_star
new_star_effect.alpha = base_lighting_alpha
SET_PLANE_W_SCALAR(new_star_effect, LIGHTING_PLANE, 0)
add_overlay(new_star_effect)
lighting_effects[1] = new_star_effect