mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2025-12-22 08:01:06 +00:00
Rewrites the area movement code used by shuttles & elevators in an effort to make it faster, more extensible, and generally easier to read. Also fixes some bugs relating to lighting & moving areas, such as lighting overlays suddenly being teleported into space for absolutely no reason. Fixes #2161. Fixes #2166.
157 lines
4.6 KiB
Plaintext
157 lines
4.6 KiB
Plaintext
/atom/movable/lighting_overlay
|
|
name = ""
|
|
anchored = TRUE
|
|
icon = LIGHTING_ICON
|
|
icon_state = LIGHTING_BASE_ICON_STATE
|
|
color = LIGHTING_BASE_MATRIX
|
|
mouse_opacity = 0
|
|
layer = LIGHTING_LAYER
|
|
invisibility = INVISIBILITY_LIGHTING
|
|
simulated = 0
|
|
blend_mode = BLEND_MULTIPLY
|
|
|
|
var/needs_update = FALSE
|
|
|
|
#if WORLD_ICON_SIZE != 32
|
|
transform = matrix(WORLD_ICON_SIZE / 32, 0, (WORLD_ICON_SIZE - 32) / 2, 0, WORLD_ICON_SIZE / 32, (WORLD_ICON_SIZE - 32) / 2)
|
|
#endif
|
|
|
|
/atom/movable/lighting_overlay/New(atom/loc, no_update = FALSE)
|
|
. = ..()
|
|
verbs.Cut()
|
|
SSlighting.lighting_overlays += src
|
|
|
|
var/turf/T = loc // If this runtimes atleast we'll know what's creating overlays in things that aren't turfs.
|
|
T.lighting_overlay = src
|
|
T.luminosity = 0
|
|
|
|
if (no_update)
|
|
return
|
|
|
|
update_overlay()
|
|
|
|
/atom/movable/lighting_overlay/Destroy(force = FALSE)
|
|
if (!force)
|
|
return QDEL_HINT_LETMELIVE // STOP DELETING ME
|
|
|
|
L_PROF(loc, "overlay_destroy")
|
|
SSlighting.lighting_overlays -= src
|
|
SSlighting.overlay_queue -= src
|
|
|
|
var/turf/T = loc
|
|
if (istype(T))
|
|
T.lighting_overlay = null
|
|
T.luminosity = 1
|
|
|
|
return ..()
|
|
|
|
/atom/movable/lighting_overlay/proc/update_overlay()
|
|
if (QDELING(src)) // This shouldn't happen.
|
|
return
|
|
|
|
var/turf/T = loc
|
|
if (!istype(T)) // Erm...
|
|
if (loc)
|
|
warning("A lighting overlay realised its loc was NOT a turf (actual loc: [loc], [loc.type]) in update_overlay() and got deleted!")
|
|
|
|
else
|
|
warning("A lighting overlay realised it was in nullspace in update_overlay() and got deleted!")
|
|
|
|
qdel(src, TRUE)
|
|
return
|
|
|
|
// To the future coder who sees this and thinks
|
|
// "Why didn't he just use a loop?"
|
|
// Well my man, it's because the loop performed like shit.
|
|
// And there's no way to improve it because
|
|
// without a loop you can make the list all at once which is the fastest you're gonna get.
|
|
// Oh it's also shorter line wise.
|
|
// Including with these comments.
|
|
|
|
// See LIGHTING_CORNER_DIAGONAL in lighting_corner.dm for why these values are what they are.
|
|
// No I seriously cannot think of a more efficient method, fuck off Comic.
|
|
var/datum/lighting_corner/cr = T.corners[3] || dummy_lighting_corner
|
|
var/datum/lighting_corner/cg = T.corners[2] || dummy_lighting_corner
|
|
var/datum/lighting_corner/cb = T.corners[4] || dummy_lighting_corner
|
|
var/datum/lighting_corner/ca = T.corners[1] || dummy_lighting_corner
|
|
|
|
var/max = max(cr.cache_mx, cg.cache_mx, cb.cache_mx, ca.cache_mx)
|
|
luminosity = max > LIGHTING_SOFT_THRESHOLD
|
|
|
|
// The RNG introduced by LIGHTING_USE_MEMORY_HACK makes this shortcut ineffective.
|
|
#ifndef LIGHTING_USE_MEMORY_HACK
|
|
var/rr = cr.cache_r
|
|
var/rg = cr.cache_g
|
|
var/rb = cr.cache_b
|
|
|
|
var/gr = cg.cache_r
|
|
var/gg = cg.cache_g
|
|
var/gb = cg.cache_b
|
|
|
|
var/br = cb.cache_r
|
|
var/bg = cb.cache_g
|
|
var/bb = cb.cache_b
|
|
|
|
var/ar = ca.cache_r
|
|
var/ag = ca.cache_g
|
|
var/ab = ca.cache_b
|
|
|
|
// Check for a common value first so we can skip expensive color matrixes if possible.
|
|
var/all_equal = ((rr == gr && gr == br && br == ar) && (rg == gg && gg == bg && bg == ag) && (rb == gb && gb == bb && bb == ab))
|
|
|
|
if (!luminosity)
|
|
icon_state = LIGHTING_DARKNESS_ICON_STATE
|
|
color = null
|
|
else if (all_equal && rr == LIGHTING_DEFAULT_TUBE_R && rg == LIGHTING_DEFAULT_TUBE_G && rb == LIGHTING_DEFAULT_TUBE_B)
|
|
icon_state = LIGHTING_STATION_ICON_STATE
|
|
color = null
|
|
else
|
|
icon_state = LIGHTING_BASE_ICON_STATE
|
|
color = list(
|
|
rr, rg, rb, 0,
|
|
gr, gg, gb, 0,
|
|
br, bg, bb, 0,
|
|
ar, ag, ab, 0,
|
|
0, 0, 0, 1
|
|
)
|
|
#else
|
|
color = list(
|
|
cr.cache_r, cr.cache_g, cr.cache_b, 0,
|
|
cg.cache_r, cg.cache_g, cg.cache_b, 0,
|
|
cb.cache_r, cb.cache_g, cb.cache_b, 0,
|
|
ca.cache_r, ca.cache_g, ca.cache_b, 0,
|
|
0, 0, 0, 1
|
|
)
|
|
#endif
|
|
|
|
// Variety of overrides so the overlays don't get affected by weird things.
|
|
|
|
/atom/movable/lighting_overlay/ex_act(severity)
|
|
return 0
|
|
|
|
/atom/movable/lighting_overlay/singularity_act()
|
|
return
|
|
|
|
/atom/movable/lighting_overlay/singularity_pull()
|
|
return
|
|
|
|
/atom/movable/lighting_overlay/singuloCanEat()
|
|
return FALSE
|
|
|
|
/atom/movable/lighting_overlay/can_fall()
|
|
return FALSE
|
|
|
|
// Override here to prevent things accidentally moving around overlays.
|
|
/atom/movable/lighting_overlay/forceMove(atom/destination, no_tp = FALSE, harderforce = FALSE)
|
|
if(harderforce)
|
|
L_PROF(loc, "overlay_forcemove")
|
|
. = ..()
|
|
|
|
/atom/movable/lighting_overlay/resetVariables(...)
|
|
color = LIGHTING_BASE_MATRIX
|
|
|
|
return ..("color")
|
|
|
|
/atom/movable/lighting_overlay/shuttle_move(turf/loc)
|
|
return
|