diff --git a/code/game/turfs/space/space.dm b/code/game/turfs/space/space.dm index edee66fc97..cf5d512cf5 100644 --- a/code/game/turfs/space/space.dm +++ b/code/game/turfs/space/space.dm @@ -11,8 +11,12 @@ var/keep_sprite = FALSE // heat_capacity = 700000 No. var/static/list/dust_cache + var/static/list/speedspace_cache + var/static/list/phase_shift_by_x + var/static/list/phase_shift_by_y /turf/space/proc/build_dust_cache() + //Static LAZYINITLIST(dust_cache) for (var/i in 0 to 25) var/image/im = image('icons/turf/space_dust.dmi', "[i]") @@ -20,6 +24,19 @@ im.alpha = 128 //80 im.blend_mode = BLEND_ADD dust_cache["[i]"] = im + //Moving + LAZYINITLIST(speedspace_cache) + for (var/i in 0 to 14) + // NORTH/SOUTH + 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 + // EAST/WEST + 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 /turf/space/Initialize() . = ..() @@ -28,7 +45,45 @@ update_starlight() if (!dust_cache) build_dust_cache() - add_overlay(dust_cache["[((x + y) ^ ~(x * y) + z) % 25]"]) + toggle_transit() //add static dust + +/turf/space/proc/toggle_transit(var/direction) + cut_overlays() + + if(!direction) + add_overlay(dust_cache["[((x + y) ^ ~(x * y) + z) % 25]"]) + return + + if(direction & (NORTH|SOUTH)) + if(!phase_shift_by_x) + phase_shift_by_x = get_cross_shift_list(15) + var/x_shift = phase_shift_by_x[src.x % (phase_shift_by_x.len - 1) + 1] + var/transit_state = ((direction & SOUTH ? world.maxy - src.y : src.y) + x_shift)%15 + add_overlay(speedspace_cache["NS_[transit_state]"]) + else if(direction & (EAST|WEST)) + if(!phase_shift_by_y) + phase_shift_by_y = get_cross_shift_list(15) + var/y_shift = phase_shift_by_y[src.y % (phase_shift_by_y.len - 1) + 1] + var/transit_state = ((direction & WEST ? world.maxx - src.x : src.x) + y_shift)%15 + add_overlay(speedspace_cache["EW_[transit_state]"]) + + for(var/atom/movable/AM in src) + if (AM.simulated && !AM.anchored) + AM.throw_at(get_step(src,reverse_direction(direction)), 5, 1) + +//generates a list used to randomize transit animations so they aren't in lockstep +/turf/space/proc/get_cross_shift_list(var/size) + var/list/result = list() + + result += rand(0, 14) + for(var/i in 2 to size) + var/shifts = list(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14) + shifts -= result[i - 1] //consecutive shifts should not be equal + if(i == size) + shifts -= result[1] //because shift list is a ring buffer + result += pick(shifts) + + return result /turf/space/is_space() return 1 diff --git a/code/game/turfs/space/transit.dm b/code/game/turfs/space/transit.dm index 0bfcb4e0f6..8b9c7b2d35 100644 --- a/code/game/turfs/space/transit.dm +++ b/code/game/turfs/space/transit.dm @@ -7,26 +7,11 @@ /turf/space/transit/attackby(obj/O as obj, mob/user as mob) return -//generates a list used to randomize transit animations so they aren't in lockstep -/turf/space/transit/proc/get_cross_shift_list(var/size) - var/list/result = list() - - result += rand(0, 14) - for(var/i in 2 to size) - var/shifts = list(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14) - shifts -= result[i - 1] //consecutive shifts should not be equal - if(i == size) - shifts -= result[1] //because shift list is a ring buffer - result += pick(shifts) - - return result - //------------------------ /turf/space/transit/north // moving to the north icon_state = "arrow-north" pushdirection = SOUTH // south because the space tile is scrolling south - var/static/list/phase_shift_by_x /turf/space/transit/north/New() ..() @@ -42,7 +27,6 @@ /turf/space/transit/south // moving to the south icon_state = "arrow-south" pushdirection = SOUTH // south because the space tile is scrolling south - var/static/list/phase_shift_by_x /turf/space/transit/south/New() ..() @@ -60,7 +44,6 @@ /turf/space/transit/east // moving to the east icon_state = "arrow-east" pushdirection = WEST - var/static/list/phase_shift_by_y /turf/space/transit/east/New() ..() @@ -76,7 +59,6 @@ /turf/space/transit/west // moving to the west icon_state = "arrow-west" pushdirection = WEST - var/static/list/phase_shift_by_y /turf/space/transit/west/New() ..() diff --git a/code/modules/overmap/_defines.dm b/code/modules/overmap/_defines.dm index 46fcaad7df..bf967eb3b9 100644 --- a/code/modules/overmap/_defines.dm +++ b/code/modules/overmap/_defines.dm @@ -70,27 +70,12 @@ proc/toggle_move_stars(zlevel, direction) if(!zlevel) return - var/gen_dir = null - if(direction & (NORTH|SOUTH)) - gen_dir += "ns" - else if(direction & (EAST|WEST)) - gen_dir += "ew" - if(!direction) - gen_dir = null - - if (moving_levels["[zlevel]"] != gen_dir) - moving_levels["[zlevel]"] = gen_dir + if (moving_levels["[zlevel]"] != direction) + moving_levels["[zlevel]"] = direction var/list/spaceturfs = block(locate(1, 1, zlevel), locate(world.maxx, world.maxy, zlevel)) for(var/turf/space/T in spaceturfs) - if(!gen_dir) - T.icon_state = initial(T.icon_state) - else - T.icon_state = "speedspace_[gen_dir]_[rand(1,15)]" - for(var/atom/movable/AM in T) - if (AM.simulated && !AM.anchored) - AM.throw_at(get_step(T,reverse_direction(direction)), 5, 1) - CHECK_TICK + T.toggle_transit(direction) CHECK_TICK /* //list used to cache empty zlevels to avoid nedless map bloat diff --git a/icons/turf/space.dmi b/icons/turf/space.dmi index 5c5d6fd747..1d799dbc3f 100644 Binary files a/icons/turf/space.dmi and b/icons/turf/space.dmi differ diff --git a/icons/turf/space_dust_transit.dmi b/icons/turf/space_dust_transit.dmi new file mode 100644 index 0000000000..db36a50efb Binary files /dev/null and b/icons/turf/space_dust_transit.dmi differ