Merge pull request #7310 from VOREStation/vplk-lazy-landables

Lazy ship/landable Overmap Levels
This commit is contained in:
Aronai Sieyes
2020-04-17 14:13:04 -04:00
committed by GitHub
6 changed files with 57 additions and 15 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -29,14 +29,16 @@ var/list/cached_space = list()
return 1
proc/get_deepspace(x,y)
var/obj/effect/overmap/visitable/sector/temporary/res = locate(x,y,global.using_map.overmap_z)
var/turf/unsimulated/map/overmap_turf = locate(x,y,global.using_map.overmap_z)
if(!istype(overmap_turf))
CRASH("Attempt to get deepspace at ([x],[y]) which is not on overmap: [overmap_turf]")
var/obj/effect/overmap/visitable/sector/temporary/res = locate() in overmap_turf
if(istype(res))
return res
else if(cached_space.len)
res = cached_space[cached_space.len]
cached_space -= res
res.x = x
res.y = y
res.forceMove(overmap_turf)
return res
else
return new /obj/effect/overmap/visitable/sector/temporary(x, y, global.using_map.get_empty_zlevel())
@@ -110,5 +112,5 @@ proc/overmap_spacetravel(var/turf/space/T, var/atom/movable/A)
var/obj/effect/overmap/visitable/sector/temporary/source = M
if (source.can_die())
testing("Caching [M] for future use")
source.loc = null
source.moveToNullspace()
cached_space += source

View File

@@ -44,7 +44,6 @@
else
base_area = locate(base_area || world.area)
name = (name + " ([x],[y])")
SSshuttles.register_landmark(landmark_tag, src)
/obj/effect/shuttle_landmark/LateInitialize()
@@ -124,14 +123,16 @@
name = "Navpoint"
landmark_tag = "navpoint"
flags = SLANDMARK_FLAG_AUTOSET
var/original_name = null // Save our mapped-in name so we can rebuild our name when moving sectors.
/obj/effect/shuttle_landmark/automatic/Initialize()
original_name = name
landmark_tag += "-[x]-[y]-[z]-[random_id("landmarks",1,9999)]"
return ..()
/obj/effect/shuttle_landmark/automatic/sector_set(var/obj/effect/overmap/visitable/O)
..()
name = ("[O.name] - [initial(name)] ([x],[y])")
name = ("[O.name] - [original_name] ([x],[y])")
//Subtype that calls explosion on init to clear space for shuttles
/obj/effect/shuttle_landmark/automatic/clearing

View File

@@ -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)

View File

@@ -2906,6 +2906,7 @@
#include "code\modules\organs\subtypes\vox_vr.dm"
#include "code\modules\organs\subtypes\xenos.dm"
#include "code\modules\overmap\bluespace_rift_vr.dm"
#include "code\modules\overmap\champagne.dm"
#include "code\modules\overmap\helpers.dm"
#include "code\modules\overmap\overmap_object.dm"
#include "code\modules\overmap\overmap_shuttle.dm"