Swap overlay cache for appearance cache in SSskybox

This commit is contained in:
Aronai Sieyes
2020-04-15 18:37:13 -04:00
parent c3d406a47c
commit 8512c48b3d
3 changed files with 82 additions and 56 deletions

View File

@@ -6,6 +6,7 @@ SUBSYSTEM_DEF(skybox)
flags = SS_NO_FIRE
var/static/list/skybox_cache = list()
var/static/mutable_appearance/normal_space
var/static/list/dust_cache = list()
var/static/list/speedspace_cache = list()
var/static/list/mapedge_cache = list()
@@ -13,52 +14,75 @@ SUBSYSTEM_DEF(skybox)
var/static/list/phase_shift_by_y = list()
/datum/controller/subsystem/skybox/PreInit()
//Shuffle some lists
phase_shift_by_x = get_cross_shift_list(15)
phase_shift_by_y = get_cross_shift_list(15)
//Create our 'normal' space appearance
normal_space = new()
normal_space.name = "\proper space"
normal_space.desc = "Space!"
normal_space.mouse_opacity = 2 //Always fully opaque. It's SPACE there can't be things BEHIND IT.
normal_space.appearance_flags = TILE_BOUND|PIXEL_SCALE|KEEP_TOGETHER
normal_space.plane = SPACE_PLANE
normal_space.layer = TURF_LAYER
normal_space.icon = 'icons/turf/space.dmi'
normal_space.icon_state = "white"
//Static
for (var/i in 0 to 25)
var/mutable_appearance/MA = new(normal_space)
var/image/im = image('icons/turf/space_dust.dmi', "[i]")
im.plane = DUST_PLANE
im.alpha = 128 //80
im.blend_mode = BLEND_ADD
dust_cache["[i]"] = im
MA.overlays = list(im)
dust_cache["[i]"] = MA
//Moving
for (var/i in 0 to 14)
// NORTH/SOUTH
var/mutable_appearance/MA = new(normal_space)
var/image/im = image('icons/turf/space_dust_transit.dmi', "speedspace_ns_[i]")
im.plane = DUST_PLANE
im.blend_mode = BLEND_ADD
speedspace_cache["NS_[i]"] = im
MA.overlays = list(im)
speedspace_cache["NS_[i]"] = MA
// EAST/WEST
MA = new(normal_space)
im = image('icons/turf/space_dust_transit.dmi', "speedspace_ew_[i]")
im.plane = DUST_PLANE
im.blend_mode = BLEND_ADD
speedspace_cache["EW_[i]"] = im
MA.overlays = list(im)
speedspace_cache["EW_[i]"] = MA
//Over-the-edge images
for (var/dir in alldirs)
var/image/I = image('icons/turf/space.dmi', "white")
var/mutable_appearance/MA = new(normal_space)
var/matrix/M = matrix()
var/horizontal = (dir & (WEST|EAST))
var/vertical = (dir & (NORTH|SOUTH))
M.Scale(horizontal ? 8 : 1, vertical ? 8 : 1)
I.transform = M
I.appearance_flags = KEEP_APART | TILE_BOUND
I.plane = SPACE_PLANE
I.layer = 0
MA.transform = M
MA.appearance_flags = KEEP_APART | TILE_BOUND
MA.plane = SPACE_PLANE
MA.layer = 0
if(dir & NORTH)
I.pixel_y = 112
MA.pixel_y = 112
else if(dir & SOUTH)
I.pixel_y = -112
MA.pixel_y = -112
if(dir & EAST)
I.pixel_x = 112
MA.pixel_x = 112
else if(dir & WEST)
I.pixel_x = -112
MA.pixel_x = -112
mapedge_cache["[dir]"] = I
//Shuffle some lists
phase_shift_by_x = get_cross_shift_list(15)
phase_shift_by_y = get_cross_shift_list(15)
mapedge_cache["[dir]"] = MA
. = ..()

View File

@@ -9,46 +9,20 @@
thermal_conductivity = OPEN_HEAT_TRANSFER_COEFFICIENT
can_build_into_floor = TRUE
var/keep_sprite = FALSE
var/edge = 0
var/edge = 0 //If we're an edge
var/forced_dirs = 0 //Force this one to pretend it's an overedge turf
/turf/space/Initialize()
. = ..()
if(!keep_sprite)
icon_state = "white"
if(config.starlight)
update_starlight()
build_overedge() //Spread out over the edge of the map if we're an edge
toggle_transit() //Add static dust (not passing a dir)
//Sprite stuff only beyond here
if(keep_sprite)
return .
/turf/space/proc/toggle_transit(var/direction)
cut_overlays()
if(!direction)
add_overlay(SSskybox.dust_cache["[((x + y) ^ ~(x * y) + z) % 25]"])
return
if(direction & (NORTH|SOUTH))
var/x_shift = SSskybox.phase_shift_by_x[src.x % (SSskybox.phase_shift_by_x.len - 1) + 1]
var/transit_state = ((direction & SOUTH ? world.maxy - src.y : src.y) + x_shift)%15
add_overlay(SSskybox.speedspace_cache["NS_[transit_state]"])
else if(direction & (EAST|WEST))
var/y_shift = SSskybox.phase_shift_by_y[src.y % (SSskybox.phase_shift_by_y.len - 1) + 1]
var/transit_state = ((direction & WEST ? world.maxx - src.x : src.x) + y_shift)%15
add_overlay(SSskybox.speedspace_cache["EW_[transit_state]"])
for(var/atom/movable/AM in src)
if (!AM.simulated)
continue
if(!AM.anchored)
AM.throw_at(get_step(src,reverse_direction(direction)), 5, 1)
else if (istype(AM, /obj/effect/decal))
qdel(AM) //No more space blood coming with the shuttle
/turf/space/proc/build_overedge(var/forced_dirs)
//We might be an edge
if(y == world.maxy || forced_dirs & NORTH)
edge |= NORTH
else if(y == 1 || forced_dirs & SOUTH)
@@ -59,10 +33,34 @@
else if(x == world.maxx || forced_dirs & EAST)
edge |= EAST
if(!edge)
if(edge) //Magic edges
appearance = SSskybox.mapedge_cache["[edge]"]
else //Dust
appearance = SSskybox.dust_cache["[((x + y) ^ ~(x * y) + z) % 25]"]
/turf/space/proc/toggle_transit(var/direction)
if(edge) //Not a great way to do this yet. Maybe we'll come up with one. We could pre-make sprites... or tile the overlay over it?
return
add_overlay(SSskybox.mapedge_cache["[edge]"], TRUE)
if(!direction) //Stopping our transit
appearance = SSskybox.dust_cache["[((x + y) ^ ~(x * y) + z) % 25]"]
else if(direction & (NORTH|SOUTH)) //Starting transit vertically
var/x_shift = SSskybox.phase_shift_by_x[src.x % (SSskybox.phase_shift_by_x.len - 1) + 1]
var/transit_state = ((direction & SOUTH ? world.maxy - src.y : src.y) + x_shift)%15
appearance = SSskybox.speedspace_cache["NS_[transit_state]"]
else if(direction & (EAST|WEST)) //Starting transit horizontally
var/y_shift = SSskybox.phase_shift_by_y[src.y % (SSskybox.phase_shift_by_y.len - 1) + 1]
var/transit_state = ((direction & WEST ? world.maxx - src.x : src.x) + y_shift)%15
appearance = SSskybox.speedspace_cache["EW_[transit_state]"]
for(var/atom/movable/AM in src)
if (!AM.simulated)
continue
if(!AM.anchored)
AM.throw_at(get_step(src,reverse_direction(direction)), 5, 1)
else if (istype(AM, /obj/effect/decal))
qdel(AM) //No more space blood coming with the shuttle
/turf/space/is_space()
return 1

View File

@@ -5,26 +5,30 @@
opacity = 1
blocks_air = TRUE
/turf/space/internal_edge/Initialize()
. = ..()
build_overedge(dir)
/turf/space/internal_edge/top
dir = NORTH
forced_dirs = NORTH
/turf/space/internal_edge/bottom
dir = SOUTH
forced_dirs = SOUTH
/turf/space/internal_edge/left
dir = WEST
forced_dirs = WEST
/turf/space/internal_edge/right
dir = EAST
forced_dirs = EAST
/turf/space/internal_edge/topleft
dir = NORTHWEST
forced_dirs = NORTHWEST
/turf/space/internal_edge/topright
dir = NORTHEAST
forced_dirs = NORTHEAST
/turf/space/internal_edge/bottomleft
dir = SOUTHWEST
forced_dirs = SOUTHWEST
/turf/space/internal_edge/bottomright
dir = SOUTHEAST
forced_dirs = SOUTHEAST
//These are fake stairs, that when you try to go up them, they shove you to
// their 'connected' friend! Try to use the appropriate top/bottom ones for good looks.