Let objects register to be informed when shuttles have been setup.

* Switch /obj/shuttle_connector to use it instead of the icky process hack.
This commit is contained in:
Leshana
2018-02-03 20:54:41 -05:00
parent df21594485
commit ca64667773
2 changed files with 17 additions and 9 deletions
+15
View File
@@ -16,10 +16,17 @@ SUBSYSTEM_DEF(shuttles)
var/list/shuttles = list() // Maps shuttle tags to shuttle datums, so that they can be looked up.
var/list/process_shuttles = list() // Simple list of shuttles, for processing
var/list/current_run = list() // Shuttles remaining to process this fire() tick
var/list/docks_init_callbacks // List of callbacks to run when we finish setting up shuttle docks.
var/docks_initialized = FALSE
/datum/controller/subsystem/shuttles/Initialize(timeofday)
global.shuttle_controller = src
setup_shuttle_docks()
for(var/I in docks_init_callbacks)
var/datum/callback/cb = I
cb.InvokeAsync()
LAZYCLEARLIST(docks_init_callbacks)
docks_init_callbacks = null
return ..()
/datum/controller/subsystem/shuttles/fire(resumed = 0)
@@ -66,3 +73,11 @@ SUBSYSTEM_DEF(shuttles)
for(var/obj/machinery/embedded_controller/C in machines)
if(istype(C.program, /datum/computer/file/embedded_program/docking))
C.program.tag = null //clear the tags, 'cause we don't need 'em anymore
docks_initialized = TRUE
// Register a callback that will be invoked once the shuttles have been initialized
/datum/controller/subsystem/shuttles/proc/OnDocksInitialized(datum/callback/cb)
if(!docks_initialized)
LAZYADD(docks_init_callbacks, cb)
else
cb.InvokeAsync()
+2 -9
View File
@@ -428,18 +428,13 @@
/obj/shuttle_connector
name = "shuttle connector"
var/shuttle_name //Text name of the shuttle to connect to
var/start_time = 60 SECONDS //After round start (needs to be some time, to let other destinations set up)
var/list/destinations //Make sure this STARTS with a destination that builds a route to one that always exists as an anchor.
/obj/shuttle_connector/initialize()
. = ..()
SSshuttles.OnDocksInitialized(CALLBACK(src, .proc/setup_routes))
processing_objects += src
/obj/shuttle_connector/process()
if(world.time < start_time)
return
/obj/shuttle_connector/proc/setup_routes()
if(destinations && shuttle_name)
var/datum/shuttle/web_shuttle/ES = shuttle_controller.shuttles[shuttle_name]
var/datum/shuttle_web_master/WM = ES.web_master
@@ -452,6 +447,4 @@
var/travel_delay = D.routes_to_make[type_to_link]
D.link_destinations(WM.get_destination_by_type(type_to_link), D.preferred_interim_area, travel_delay)
processing_objects -= src
qdel(src)