mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-24 05:23:22 +01:00
A Multi-Z Away Site: The Blue River (#15634)
This commit is contained in:
@@ -1,44 +1,52 @@
|
||||
// If you add a more comprehensive system, just untick this file.
|
||||
// WARNING: Only works for up to 17 z-levels!
|
||||
// Because this shit before was, for some reason, a bitfield.
|
||||
var/global/list/z_levels = list()
|
||||
var/list/list/connected_z_cache = list()
|
||||
|
||||
// If the height is more than 1, we mark all contained levels as connected.
|
||||
/obj/effect/landmark/map_data/New()
|
||||
SSatlas.height_markers += src
|
||||
/obj/effect/landmark/map_data/New(turf/loc, _height)
|
||||
..()
|
||||
if(!istype(loc)) // Using loc.z is safer when using the maploader and New.
|
||||
return
|
||||
if(_height)
|
||||
height = _height
|
||||
for(var/i = (loc.z - height + 1) to (loc.z-1))
|
||||
if (z_levels.len <i)
|
||||
z_levels.len = i
|
||||
z_levels[i] = TRUE
|
||||
|
||||
/obj/effect/landmark/map_data/proc/setup()
|
||||
ASSERT(height <= z)
|
||||
// Due to the offsets of how connections are stored v.s. how z-levels are indexed, some magic number silliness happened.
|
||||
for(var/i = (z - height) to (z - 2))
|
||||
SSatlas.z_levels |= (1 << i)
|
||||
qdel(src)
|
||||
/obj/effect/landmark/map_data/Initialize()
|
||||
..()
|
||||
return INITIALIZE_HINT_QDEL
|
||||
|
||||
/obj/effect/landmark/map_data/Destroy()
|
||||
SSatlas.height_markers -= src
|
||||
return ..()
|
||||
|
||||
// Legacy shims.
|
||||
/proc/HasAbove(var/z)
|
||||
return HAS_ABOVE(z)
|
||||
if(z >= world.maxz || z < 1 || z > z_levels.len)
|
||||
return 0
|
||||
return z_levels[z]
|
||||
|
||||
/proc/HasBelow(var/z)
|
||||
return HAS_BELOW(z)
|
||||
if(z > world.maxz || z < 2 || (z-1) > z_levels.len)
|
||||
return 0
|
||||
return z_levels[z-1]
|
||||
|
||||
// Thankfully, no bitwise magic is needed here.
|
||||
/proc/GetAbove(atom/A)
|
||||
if (!A.z)
|
||||
A = get_turf(A)
|
||||
return A ? GET_ABOVE(A) : null
|
||||
/proc/GetAbove(var/atom/atom)
|
||||
var/turf/turf = get_turf(atom)
|
||||
if(!turf)
|
||||
return null
|
||||
return HasAbove(turf.z) ? get_step(turf, UP) : null
|
||||
|
||||
/proc/GetBelow(atom/A)
|
||||
if (!A.z)
|
||||
A = get_turf(A)
|
||||
return A ? GET_BELOW(A) : null
|
||||
/proc/GetBelow(var/atom/atom)
|
||||
var/turf/turf = get_turf(atom)
|
||||
if(!turf)
|
||||
return null
|
||||
return HasBelow(turf.z) ? get_step(turf, DOWN) : null
|
||||
|
||||
/proc/GetConnectedZlevels(z)
|
||||
. = list(z)
|
||||
for(var/level = z, HAS_BELOW(level), level--)
|
||||
for(var/level = z, HasBelow(level), level--)
|
||||
. |= level-1
|
||||
for(var/level = z, HAS_ABOVE(level), level++)
|
||||
for(var/level = z, HasAbove(level), level++)
|
||||
. |= level+1
|
||||
|
||||
/proc/AreConnectedZLevels(var/zA, var/zB)
|
||||
@@ -48,20 +56,20 @@
|
||||
if(zA == 0 || zB == 0)
|
||||
return FALSE
|
||||
|
||||
if (SSatlas.connected_z_cache.len >= zA && SSatlas.connected_z_cache[zA])
|
||||
return (SSatlas.connected_z_cache[zA].len >= zB && SSatlas.connected_z_cache[zA][zB])
|
||||
if (connected_z_cache.len >= zA && connected_z_cache[zA])
|
||||
return (connected_z_cache[zA].len >= zB && connected_z_cache[zA][zB])
|
||||
|
||||
var/list/levels = GetConnectedZlevels(zA)
|
||||
var/list/new_entry = new(max(levels))
|
||||
for (var/entry in levels)
|
||||
new_entry[entry] = TRUE
|
||||
|
||||
if (SSatlas.connected_z_cache.len < zA)
|
||||
SSatlas.connected_z_cache.len = zA
|
||||
if (connected_z_cache.len < zA)
|
||||
connected_z_cache.len = zA
|
||||
|
||||
SSatlas.connected_z_cache[zA] = new_entry
|
||||
connected_z_cache[zA] = new_entry
|
||||
|
||||
return (SSatlas.connected_z_cache[zA].len >= zB && SSatlas.connected_z_cache[zA][zB])
|
||||
return (connected_z_cache[zA].len >= zB && connected_z_cache[zA][zB])
|
||||
|
||||
/proc/get_zstep(atom/ref, dir)
|
||||
if (!isloc(ref))
|
||||
|
||||
Reference in New Issue
Block a user