mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-20 22:54:46 +00:00
* Starlight Polish (Space is blue!) (#72886) <!-- Write **BELOW** The Headers and **ABOVE** The comments else it may not be viewable. --> <!-- You can view Contributing.MD for a detailed description of the pull request process. --> ## About The Pull Request Adds support to underlays to realize_overlays Ensures decals properly handle plane offsets Fixes space lighting double applying if it's changeturf'd into. this will be important later Makes solar vis_contents block emissives as expected Moves transit tube overlays to update_overlays, adds emissive blockers to them #### Adds render steps An expansion on render_target based emissive blockers. They allow us to hijack an object's appearance and draw it somewhere else, or even modify it, THEN draw it somewhere else. They chain quite nicely Fixes shuttles deleting z holder objects #### Makes space emissive, makes walls and floors block emissives The core idea here goes like this: We make space glow, and give its overlays some color This way, the tile and space parallax remain fullbright, along with anything that doesn't block emissives, but anything that does block emissives will instead get shaded the color of starlight This requires a bit of extra work, see later This is done automatically with render relays, which now support specifiying layer and color (Need to make an editor for these one of these days) The emissive blocking floor stuff requires making a second render plate to prevent double scaling Also adds some new layering defines for lighting, and ensures all turf lights have a layer. We'll get to this soon #### Makes things in space blue We color them the same as starlight, by taking advantage of space being emissive This means that things in space that block emissive will block it correctly and be colored blue by the light overlay, but space itself will remain fullbright This does require redefining what always_lit means, but nothing but cordons use that so it's fineee #### Makes glass above space glow, and some other stuff Glass tiles that sit above space will now shine light with matching color to the glasses color. This includes mat tiles. Glass tiles (not mat because they have no alpha) also only partially block emissives. Adds a new proc that uses render steps to acomplish this, essentially we're cutting out bits below X alpha and drawing what remains as an emissive. #### Modifies partial space showing to support glow Essentially, alongside displaying space as an underlay, we also display a light overlay colored like starlight. That starlight overlay gets masked to only be visible in bits that do not contain any alpha. We also mask the turf lighting to not go into bits that have no alpha, to ensure we get the effect we want. This is done with that lighting layer thing I mentioned earlier. #### Makes appearance realization's list output ordered I want it output in order of overlay, sub overlay suboverlay, next overlay Need to use insert for that ## Why It's Good For The Game Pretty! Also having space be emissive is a very very good way to test for fucked emissive blockers (If it's broken why are we even drawing the overlay) I know for a fact mob blockers on lizards and socks are kinda yorked, I think there's more <details> <summary> Old </summary>    </details> <details> <summary> New </summary>    </details> ## Changelog <!-- If your PR modifies aspects of the game that can be concretely observed by players or admins you should add a changelog. If your change does NOT meet this description, remove this section. Be sure to properly mark your PRs to prevent unnecessary GBP loss. You can read up on GBP and it's effects on PRs in the tgstation guides for contributors. Please note that maintainers freely reserve the right to remove and add tags should they deem it appropriate. You can attempt to finagle the system all you want, but it's best to shoot for clear communication right off the bat. --> 🆑 add: Space now makes things in it starlight faintly blue fix: Glass floors that display space now properly let space shine through them, rather then hiding it in the dark add: Glass floors above space now glow faintly depending on their glass type /🆑 <!-- Both 🆑's are required for the changelog to work! You can put your name to the right of the first 🆑 if you want to overwrite your GitHub username as author ingame. --> <!-- You can use multiple of the same prefix (they're only used for the icon ingame) and delete the unneeded ones. Despite some of the tags, changelogs should generally represent how a player might be affected by the changes rather than a summary of the PR's contents. --> --------- Co-authored-by: Zephyr <12817816+ZephyrTFA@users.noreply.github.com> * update modular * Update _decal.dm * Update _decal.dm --------- Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Co-authored-by: Zephyr <12817816+ZephyrTFA@users.noreply.github.com> Co-authored-by: Tom <8881105+tf-4@users.noreply.github.com> Co-authored-by: lessthanthree <83487515+lessthnthree@users.noreply.github.com>
231 lines
7.5 KiB
Plaintext
231 lines
7.5 KiB
Plaintext
SUBSYSTEM_DEF(overlays)
|
|
name = "Overlay"
|
|
flags = SS_NO_FIRE|SS_NO_INIT
|
|
var/list/stats
|
|
|
|
/datum/controller/subsystem/overlays/PreInit()
|
|
stats = list()
|
|
|
|
/datum/controller/subsystem/overlays/Shutdown()
|
|
text2file(render_stats(stats), "[GLOB.log_directory]/overlay.log")
|
|
|
|
/datum/controller/subsystem/overlays/Recover()
|
|
stats = SSoverlays.stats
|
|
|
|
/// Converts an overlay list into text for debug printing
|
|
/// Of note: overlays aren't actually mutable appearances, they're just appearances
|
|
/// Don't have access to that type tho, so this is the best you're gonna get
|
|
/proc/overlays2text(list/overlays)
|
|
var/list/unique_overlays = list()
|
|
// As anything because we're basically doing type coerrsion, rather then actually filtering for mutable apperances
|
|
for(var/mutable_appearance/overlay as anything in overlays)
|
|
var/key = "[overlay.icon]-[overlay.icon_state]-[overlay.dir]"
|
|
unique_overlays[key] += 1
|
|
var/list/output_text = list()
|
|
for(var/key in unique_overlays)
|
|
output_text += "([key]) = [unique_overlays[key]]"
|
|
return output_text.Join("\n")
|
|
|
|
/proc/iconstate2appearance(icon, iconstate)
|
|
var/static/image/stringbro = new()
|
|
stringbro.icon = icon
|
|
stringbro.icon_state = iconstate
|
|
return stringbro.appearance
|
|
|
|
/proc/icon2appearance(icon)
|
|
var/static/image/iconbro = new()
|
|
iconbro.icon = icon
|
|
return iconbro.appearance
|
|
|
|
/atom/proc/build_appearance_list(list/build_overlays)
|
|
if (!islist(build_overlays))
|
|
build_overlays = list(build_overlays)
|
|
for (var/overlay in build_overlays)
|
|
if(!overlay)
|
|
build_overlays -= overlay
|
|
continue
|
|
if (istext(overlay))
|
|
// This is too expensive to run normally but running it during CI is a good test
|
|
if (PERFORM_ALL_TESTS(focus_only/invalid_overlays))
|
|
var/list/icon_states_available = icon_states(icon)
|
|
if(!(overlay in icon_states_available))
|
|
var/icon_file = "[icon]" || "Unknown Generated Icon"
|
|
stack_trace("Invalid overlay: Icon object '[icon_file]' [REF(icon)] used in '[src]' [type] is missing icon state [overlay].")
|
|
continue
|
|
|
|
var/index = build_overlays.Find(overlay)
|
|
build_overlays[index] = iconstate2appearance(icon, overlay)
|
|
else if(isicon(overlay))
|
|
var/index = build_overlays.Find(overlay)
|
|
build_overlays[index] = icon2appearance(overlay)
|
|
return build_overlays
|
|
|
|
/atom/proc/cut_overlays()
|
|
STAT_START_STOPWATCH
|
|
overlays = null
|
|
POST_OVERLAY_CHANGE(src)
|
|
STAT_STOP_STOPWATCH
|
|
STAT_LOG_ENTRY(SSoverlays.stats, type)
|
|
|
|
/atom/proc/cut_overlay(list/remove_overlays)
|
|
if(!overlays)
|
|
return
|
|
STAT_START_STOPWATCH
|
|
overlays -= build_appearance_list(remove_overlays)
|
|
POST_OVERLAY_CHANGE(src)
|
|
STAT_STOP_STOPWATCH
|
|
STAT_LOG_ENTRY(SSoverlays.stats, type)
|
|
|
|
/atom/proc/add_overlay(list/add_overlays)
|
|
if(!overlays)
|
|
return
|
|
STAT_START_STOPWATCH
|
|
overlays += build_appearance_list(add_overlays)
|
|
POST_OVERLAY_CHANGE(src)
|
|
STAT_STOP_STOPWATCH
|
|
STAT_LOG_ENTRY(SSoverlays.stats, type)
|
|
|
|
/atom/proc/copy_overlays(atom/other, cut_old) //copys our_overlays from another atom
|
|
if(!other)
|
|
if(cut_old)
|
|
cut_overlays()
|
|
return
|
|
|
|
STAT_START_STOPWATCH
|
|
var/list/cached_other = other.overlays.Copy()
|
|
if(cut_old)
|
|
if(cached_other)
|
|
overlays = cached_other
|
|
else
|
|
overlays = null
|
|
POST_OVERLAY_CHANGE(src)
|
|
STAT_STOP_STOPWATCH
|
|
STAT_LOG_ENTRY(SSoverlays.stats, type)
|
|
else if(cached_other)
|
|
overlays += cached_other
|
|
POST_OVERLAY_CHANGE(src)
|
|
STAT_STOP_STOPWATCH
|
|
STAT_LOG_ENTRY(SSoverlays.stats, type)
|
|
|
|
//TODO: Better solution for these?
|
|
/image/proc/add_overlay(x)
|
|
overlays |= x
|
|
|
|
/image/proc/cut_overlay(x)
|
|
overlays -= x
|
|
|
|
/image/proc/cut_overlays(x)
|
|
overlays.Cut()
|
|
|
|
/image/proc/copy_overlays(atom/other, cut_old)
|
|
if(!other)
|
|
if(cut_old)
|
|
cut_overlays()
|
|
return
|
|
|
|
var/list/cached_other = other.overlays.Copy()
|
|
if(cached_other)
|
|
if(cut_old || !overlays.len)
|
|
overlays = cached_other
|
|
else
|
|
overlays |= cached_other
|
|
else if(cut_old)
|
|
cut_overlays()
|
|
|
|
// Debug procs
|
|
|
|
/atom
|
|
/// List of overlay "keys" (info about the appearance) -> mutable versions of static appearances
|
|
/// Drawn from the overlays list
|
|
var/list/realized_overlays
|
|
/// List of underlay "keys" (info about the appearance) -> mutable versions of static appearances
|
|
/// Drawn from the underlays list
|
|
var/list/realized_underlays
|
|
|
|
/image
|
|
/// List of overlay "keys" (info about the appearance) -> mutable versions of static appearances
|
|
/// Drawn from the overlays list
|
|
var/list/realized_overlays
|
|
/// List of underlay "keys" (info about the appearance) -> mutable versions of static appearances
|
|
/// Drawn from the underlays list
|
|
var/list/realized_underlays
|
|
|
|
/// Takes the atoms's existing overlays and underlays, and makes them mutable so they can be properly vv'd in the realized_overlays/underlays list
|
|
/atom/proc/realize_overlays()
|
|
realized_overlays = realize_appearance_queue(overlays)
|
|
realized_underlays = realize_appearance_queue(underlays)
|
|
|
|
/// Takes the image's existing overlays, and makes them mutable so they can be properly vv'd in the realized_overlays list
|
|
/image/proc/realize_overlays()
|
|
realized_overlays = realize_appearance_queue(overlays)
|
|
realized_underlays = realize_appearance_queue(underlays)
|
|
|
|
/// Takes a list of appearnces, makes them mutable so they can be properly vv'd and inspected
|
|
/proc/realize_appearance_queue(list/appearances)
|
|
var/list/real_appearances = list()
|
|
var/list/queue = appearances.Copy()
|
|
var/queue_index = 0
|
|
while(queue_index < length(queue))
|
|
queue_index++
|
|
// If it's not a command, we assert that it's an appearance
|
|
var/mutable_appearance/appearance = queue[queue_index]
|
|
if(!appearance) // Who fucking adds nulls to their sublists god you people are the worst
|
|
continue
|
|
|
|
var/mutable_appearance/new_appearance = new /mutable_appearance()
|
|
new_appearance.appearance = appearance
|
|
var/key = "[appearance.icon]-[appearance.icon_state]-[appearance.plane]-[appearance.layer]-[appearance.dir]-[appearance.color]"
|
|
var/tmp_key = key
|
|
var/appearance_indx = 1
|
|
while(real_appearances[tmp_key])
|
|
tmp_key = "[key]-[appearance_indx]"
|
|
appearance_indx++
|
|
|
|
real_appearances[tmp_key] = new_appearance
|
|
var/add_index = queue_index
|
|
// Now check its children
|
|
for(var/mutable_appearance/child_appearance as anything in appearance.overlays)
|
|
add_index++
|
|
queue.Insert(add_index, child_appearance)
|
|
for(var/mutable_appearance/child_appearance as anything in appearance.underlays)
|
|
add_index++
|
|
queue.Insert(add_index, child_appearance)
|
|
return real_appearances
|
|
|
|
/// Takes two appearances as args, prints out, logs, and returns a text representation of their differences
|
|
/// Including suboverlays
|
|
/proc/diff_appearances(mutable_appearance/first, mutable_appearance/second, iter = 0)
|
|
var/list/diffs = list()
|
|
var/list/firstdeet = first.vars
|
|
var/list/seconddeet = second.vars
|
|
var/diff_found = FALSE
|
|
for(var/name in first.vars)
|
|
var/firstv = firstdeet[name]
|
|
var/secondv = seconddeet[name]
|
|
if(firstv ~= secondv)
|
|
continue
|
|
if((islist(firstv) || islist(secondv)) && length(firstv) == 0 && length(secondv) == 0)
|
|
continue
|
|
if(name == "vars") // Go away
|
|
continue
|
|
if(name == "comp_lookup") // This is just gonna happen with marked datums, don't care
|
|
continue
|
|
if(name == "overlays")
|
|
first.realize_overlays()
|
|
second.realize_overlays()
|
|
var/overlays_differ = FALSE
|
|
for(var/i in 1 to length(first.realized_overlays))
|
|
if(diff_appearances(first.realized_overlays[i], second.realized_overlays[i], iter + 1))
|
|
overlays_differ = TRUE
|
|
|
|
if(!overlays_differ)
|
|
continue
|
|
|
|
diff_found = TRUE
|
|
diffs += "Diffs detected at [name]: First ([firstv]), Second ([secondv])"
|
|
|
|
var/text = "Depth of: [iter]\n\t[diffs.Join("\n\t")]"
|
|
message_admins(text)
|
|
log_world(text)
|
|
return diff_found
|