From 524ce4e2c4efc6d90c37eeab0e2b24bb42823a7f Mon Sep 17 00:00:00 2001 From: Aronai Sieyes Date: Fri, 27 Mar 2020 14:33:06 -0400 Subject: [PATCH] Move overmap wrapping onto edge turfs Allows there to be several overmaps --- code/modules/overmap/ships/ship.dm | 27 --------------------------- code/modules/overmap/turfs.dm | 30 ++++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/code/modules/overmap/ships/ship.dm b/code/modules/overmap/ships/ship.dm index 44a2d8e45e..4dcecc5d6e 100644 --- a/code/modules/overmap/ships/ship.dm +++ b/code/modules/overmap/ships/ship.dm @@ -146,7 +146,6 @@ var/turf/newloc = locate(x + deltas[1], y + deltas[2], z) if(newloc) Move(newloc) - handle_wraparound() update_icon() /obj/effect/overmap/visitable/ship/update_icon() @@ -181,27 +180,6 @@ . = min(last_movement[i] - world.time + 1/abs(speed[i]), .) . = max(.,0) -/obj/effect/overmap/visitable/ship/proc/handle_wraparound() - var/nx = x - var/ny = y - var/low_edge = 1 - var/high_edge = global.using_map.overmap_size - 1 - - if((dir & WEST) && x == low_edge) - nx = high_edge - else if((dir & EAST) && x == high_edge) - nx = low_edge - if((dir & SOUTH) && y == low_edge) - ny = high_edge - else if((dir & NORTH) && y == high_edge) - ny = low_edge - if((x == nx) && (y == ny)) - return //we're not flying off anywhere - - var/turf/T = locate(nx,ny,z) - if(T) - forceMove(T) - /obj/effect/overmap/visitable/ship/proc/halt() adjust_speed(-speed[1], -speed[2]) halted = 1 @@ -210,11 +188,6 @@ if(!SSshuttles.overmap_halted) halted = 0 -/obj/effect/overmap/visitable/ship/Bump(var/atom/A) - if(istype(A,/turf/unsimulated/map/edge)) - handle_wraparound() - ..() - /obj/effect/overmap/visitable/ship/proc/get_helm_skill()//delete this mover operator skill to overmap obj return operator_skill diff --git a/code/modules/overmap/turfs.dm b/code/modules/overmap/turfs.dm index 952865878e..3508203a6e 100644 --- a/code/modules/overmap/turfs.dm +++ b/code/modules/overmap/turfs.dm @@ -15,6 +15,36 @@ var/global/list/map_sectors = list() /turf/unsimulated/map/edge opacity = 1 density = 1 + var/map_is_to_my + var/turf/unsimulated/map/edge/wrap_buddy + +/turf/unsimulated/map/edge/Initialize() + . = ..() + //This could be done by using the using_map.overmap_size much faster, HOWEVER, doing it programatically to 'find' + // the edges this way allows for 'sub overmaps' elsewhere and whatnot. + for(var/side in alldirs) //The order of this list is relevant: It should definitely break on finding a cardinal FIRST. + var/turf/T = get_step(src, side) + if(T?.type == /turf/unsimulated/map) //Not a wall, not something else, EXACTLY a flat map turf. + map_is_to_my = side + break + + if(map_is_to_my) + var/turf/T = get_step(src, map_is_to_my) //Should be a normal map turf + while(istype(T, /turf/unsimulated/map)) + T = get_step(T, map_is_to_my) //Could be a wall if the map is only 1 turf big + if(istype(T, /turf/unsimulated/map/edge)) + wrap_buddy = T + break + +/turf/unsimulated/map/edge/Destroy() + wrap_buddy = null + return ..() + +/turf/unsimulated/map/edge/Bumped(var/atom/movable/AM) + if(wrap_buddy?.map_is_to_my) + AM.forceMove(get_step(wrap_buddy, wrap_buddy.map_is_to_my)) + else + . = ..() /turf/unsimulated/map/Initialize() . = ..()