diff --git a/code/modules/overmap/overmap_shuttle.dm b/code/modules/overmap/overmap_shuttle.dm index b614137db4..d009c53847 100644 --- a/code/modules/overmap/overmap_shuttle.dm +++ b/code/modules/overmap/overmap_shuttle.dm @@ -42,7 +42,7 @@ if(moving_status == SHUTTLE_INTRANSIT) return FALSE //already going somewhere, current_location may be an intransit location instead of in a sector var/our_sector = waypoint_sector(current_location) - if(!our_sector && myship?.landmark && next_location == myship.landmark) + if(myship?.landmark && next_location == myship.landmark) return TRUE //We're not on the overmap yet (admin spawned probably), and we're trying to hook up with our openspace sector return get_dist(our_sector, waypoint_sector(next_location)) <= range diff --git a/code/modules/overmap/ships/landable.dm b/code/modules/overmap/ships/landable.dm index 0a28eefd8d..fed030ba6f 100644 --- a/code/modules/overmap/ships/landable.dm +++ b/code/modules/overmap/ships/landable.dm @@ -11,6 +11,7 @@ moving_state = "shuttle_moving" /obj/effect/overmap/visitable/ship/landable/Destroy() + GLOB.shuttle_pre_move_event.unregister(SSshuttles.shuttles[shuttle], src) GLOB.shuttle_moved_event.unregister(SSshuttles.shuttles[shuttle], src) return ..() @@ -34,13 +35,18 @@ // We autobuild our z levels. /obj/effect/overmap/visitable/ship/landable/find_z_levels() + src.landmark = new(null, shuttle) // Create in nullspace since we lazy-create overmap z + add_landmark(landmark, shuttle) + +/obj/effect/overmap/visitable/ship/landable/proc/setup_overmap_location() + if(LAZYLEN(map_z)) + return // We're already set up! for(var/i = 0 to multiz) world.increment_max_z() map_z += world.maxz var/turf/center_loc = locate(round(world.maxx/2), round(world.maxy/2), world.maxz) - landmark = new (center_loc, shuttle) - add_landmark(landmark, shuttle) + landmark.forceMove(center_loc) var/visitor_dir = fore_dir for(var/landmark_name in list("FORE", "PORT", "AFT", "STARBOARD")) @@ -51,6 +57,8 @@ if(multiz) new /obj/effect/landmark/map_data(center_loc, (multiz + 1)) + register_z_levels() + testing("Setup overmap location for \"[name]\" containing Z [english_list(map_z)]") /obj/effect/overmap/visitable/ship/landable/get_areas() var/datum/shuttle/shuttle_datum = SSshuttles.shuttles[shuttle] @@ -64,13 +72,19 @@ if(istype(shuttle_datum,/datum/shuttle/autodock/overmap)) var/datum/shuttle/autodock/overmap/oms = shuttle_datum oms.myship = src + GLOB.shuttle_pre_move_event.register(shuttle_datum, src, .proc/pre_shuttle_jump) GLOB.shuttle_moved_event.register(shuttle_datum, src, .proc/on_shuttle_jump) on_landing(landmark, shuttle_datum.current_location) // We "land" at round start to properly place ourselves on the overmap. + +// +// Center Landmark +// + /obj/effect/shuttle_landmark/ship name = "Open Space" landmark_tag = "ship" - flags = SLANDMARK_FLAG_AUTOSET | SLANDMARK_FLAG_ZERO_G + flags = SLANDMARK_FLAG_ZERO_G // *Not* AUTOSET, these must be world.turf and world.area for lazy loading to work. var/shuttle_name var/list/visitors // landmark -> visiting shuttle stationed there @@ -78,6 +92,7 @@ landmark_tag += "_[shuttle_name]" src.shuttle_name = shuttle_name . = ..() + base_turf = world.turf /obj/effect/shuttle_landmark/ship/Destroy() var/obj/effect/overmap/visitable/ship/landable/ship = get_overmap_sector(z) @@ -85,10 +100,22 @@ ship.landmark = null . = ..() +/obj/effect/shuttle_landmark/ship/is_valid(datum/shuttle/shuttle) + return (isnull(loc) || ..()) // If it doesn't exist yet, its clear + +/obj/effect/shuttle_landmark/ship/create_warning_effect(var/datum/shuttle/shuttle) + if(isnull(loc)) + return + ..() + /obj/effect/shuttle_landmark/ship/cannot_depart(datum/shuttle/shuttle) if(LAZYLEN(visitors)) return "Grappled by other shuttle; cannot manouver." +// +// Visitor Landmark +// + /obj/effect/shuttle_landmark/visiting_shuttle flags = SLANDMARK_FLAG_AUTOSET | SLANDMARK_FLAG_ZERO_G var/obj/effect/shuttle_landmark/ship/core_landmark @@ -125,6 +152,17 @@ GLOB.shuttle_moved_event.unregister(shuttle, src) LAZYREMOVE(core_landmark.visitors, src) +// +// More ship procs +// + +/obj/effect/overmap/visitable/ship/landable/proc/pre_shuttle_jump(datum/shuttle/given_shuttle, obj/effect/shuttle_landmark/from, obj/effect/shuttle_landmark/into) + if(given_shuttle != SSshuttles.shuttles[shuttle]) + return + if(into == landmark) + setup_overmap_location() // They're coming boys, better actually exist! + GLOB.shuttle_pre_move_event.unregister(SSshuttles.shuttles[shuttle], src) + /obj/effect/overmap/visitable/ship/landable/proc/on_shuttle_jump(datum/shuttle/given_shuttle, obj/effect/shuttle_landmark/from, obj/effect/shuttle_landmark/into) if(given_shuttle != SSshuttles.shuttles[shuttle]) return diff --git a/code/modules/shuttles/shuttle.dm b/code/modules/shuttles/shuttle.dm index 808a1f55e7..dd8e9ec3f3 100644 --- a/code/modules/shuttles/shuttle.dm +++ b/code/modules/shuttles/shuttle.dm @@ -249,16 +249,16 @@ log_shuttle("Shuttle [src] aborting attempt_move() because current_location=[current_location] refuses.") return FALSE + // Observer pattern pre-move + var/old_location = current_location + GLOB.shuttle_pre_move_event.raise_event(src, old_location, destination) + current_location.shuttle_departed(src) + log_shuttle("[src] moving to [destination]. Areas are [english_list(shuttle_area)]") var/list/translation = list() for(var/area/A in shuttle_area) log_shuttle("Translating [A]") translation += get_turf_translation(get_turf(current_location), get_turf(destination), A.contents) - var/old_location = current_location - - // Observer pattern pre-move - GLOB.shuttle_pre_move_event.raise_event(src, old_location, destination) - current_location.shuttle_departed(src) // Actually do it! (This never fails) perform_shuttle_move(destination, translation)