mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
Implement SSatoms
* Moves proc/initialize() from being on /atom/movable, /are and /turf/simulated to being on /atom - Now turfs can initialize too * Added the SSatoms subsystem which controls initialization of atoms at roundstart and during normal conditions. * Disabled the old auto_init = 0 behavior, ALL atoms should get initialized() called on them now. * Refactored the way initialize() is called during /New() to utilize SSatoms instead of SScreation * Removed SScreation, as it was only a stop-gap until SSatoms could be ported. * Updated the maploader to inform SSatoms when it is loading maps instead of SScreation. * Updated the template map loader to use SSatoms to perform initTemplateBounds * Renamed 'initialized' var in seed_storage to deconflict. * Removed usage of auto_init = 0, replaced with a no-op initialize() proc for atoms that don't need initialization.
This commit is contained in:
@@ -44,62 +44,40 @@ var/list/global/map_templates = list()
|
||||
return bounds
|
||||
|
||||
/datum/map_template/proc/initTemplateBounds(var/list/bounds)
|
||||
var/list/obj/machinery/atmospherics/atmos_machines = list()
|
||||
if (SSatoms.initialized == INITIALIZATION_INSSATOMS)
|
||||
return // let proper initialisation handle it later
|
||||
|
||||
var/list/atom/atoms = list()
|
||||
var/list/area/areas = list()
|
||||
// var/list/turf/turfs = list()
|
||||
|
||||
for(var/L in block(locate(bounds[MAP_MINX], bounds[MAP_MINY], bounds[MAP_MINZ]),
|
||||
locate(bounds[MAP_MAXX], bounds[MAP_MAXY], bounds[MAP_MAXZ])))
|
||||
var/list/obj/structure/cable/cables = list()
|
||||
var/list/obj/machinery/atmospherics/atmos_machines = list()
|
||||
var/list/turf/turfs = block(locate(bounds[MAP_MINX], bounds[MAP_MINY], bounds[MAP_MINZ]),
|
||||
locate(bounds[MAP_MAXX], bounds[MAP_MAXY], bounds[MAP_MAXZ]))
|
||||
for(var/L in turfs)
|
||||
var/turf/B = L
|
||||
atoms += B
|
||||
areas |= B.loc
|
||||
for(var/A in B)
|
||||
atoms += A
|
||||
// turfs += B
|
||||
areas |= get_area(B)
|
||||
if(istype(A, /obj/machinery/atmospherics))
|
||||
if(istype(A, /obj/structure/cable))
|
||||
cables += A
|
||||
else if(istype(A, /obj/machinery/atmospherics))
|
||||
atmos_machines += A
|
||||
atoms |= areas
|
||||
|
||||
var/i = 0
|
||||
|
||||
// Apparently when areas get initialize()'d they initialize their turfs as well.
|
||||
// If this is ever changed, uncomment the block of code below.
|
||||
|
||||
// admin_notice("<span class='danger'>Initializing newly created simulated turfs in submap.</span>", R_DEBUG)
|
||||
// for(var/turf/simulated/T in turfs)
|
||||
// T.initialize()
|
||||
// i++
|
||||
// admin_notice("<span class='danger'>[i] turf\s initialized.</span>", R_DEBUG)
|
||||
// i = 0
|
||||
|
||||
SScreation.initialize_late_atoms()
|
||||
|
||||
admin_notice("<span class='danger'>Initializing newly created area(s) in submap.</span>", R_DEBUG)
|
||||
for(var/area/A in areas)
|
||||
A.initialize()
|
||||
i++
|
||||
admin_notice("<span class='danger'>[i] area\s initialized.</span>", R_DEBUG)
|
||||
i = 0
|
||||
|
||||
admin_notice("<span class='danger'>Initializing newly created atom(s) in submap.</span>", R_DEBUG)
|
||||
SSatoms.InitializeAtoms(atoms)
|
||||
|
||||
admin_notice("<span class='danger'>Initializing atmos pipenets and machinery in submap.</span>", R_DEBUG)
|
||||
for(var/obj/machinery/atmospherics/machine in atmos_machines)
|
||||
machine.atmos_init()
|
||||
i++
|
||||
|
||||
for(var/obj/machinery/atmospherics/machine in atmos_machines)
|
||||
machine.build_network()
|
||||
|
||||
for(var/obj/machinery/atmospherics/unary/U in machines)
|
||||
if(istype(U, /obj/machinery/atmospherics/unary/vent_pump))
|
||||
var/obj/machinery/atmospherics/unary/vent_pump/T = U
|
||||
T.broadcast_status()
|
||||
else if(istype(U, /obj/machinery/atmospherics/unary/vent_scrubber))
|
||||
var/obj/machinery/atmospherics/unary/vent_scrubber/T = U
|
||||
T.broadcast_status()
|
||||
admin_notice("<span class='danger'>[i] pipe\s initialized.</span>", R_DEBUG)
|
||||
SSmachines.setup_atmos_machinery(atmos_machines)
|
||||
|
||||
admin_notice("<span class='danger'>Rebuilding powernets due to submap creation.</span>", R_DEBUG)
|
||||
SSmachines.makepowernets()
|
||||
SSmachines.setup_powernets_for_cables(cables)
|
||||
|
||||
// Ensure all machines in loaded areas get notified of power status
|
||||
for(var/I in areas)
|
||||
var/area/A = I
|
||||
A.power_change()
|
||||
|
||||
admin_notice("<span class='danger'>Submap initializations finished.</span>", R_DEBUG)
|
||||
|
||||
|
||||
@@ -304,7 +304,7 @@ var/global/use_preloader = FALSE
|
||||
first_turf_index++
|
||||
|
||||
//turn off base new Initialization until the whole thing is loaded
|
||||
SScreation.StartLoadingMap()
|
||||
SSatoms.map_loader_begin()
|
||||
//instanciate the first /turf
|
||||
var/turf/T
|
||||
if(members[first_turf_index] != /turf/template_noop)
|
||||
@@ -323,7 +323,7 @@ var/global/use_preloader = FALSE
|
||||
for(index in 1 to first_turf_index-1)
|
||||
instance_atom(members[index],members_attributes[index],crds,no_changeturf)
|
||||
//Restore initialization to the previous value
|
||||
SScreation.StopLoadingMap()
|
||||
SSatoms.map_loader_stop()
|
||||
|
||||
////////////////
|
||||
//Helpers procs
|
||||
@@ -344,9 +344,9 @@ var/global/use_preloader = FALSE
|
||||
|
||||
//custom CHECK_TICK here because we don't want things created while we're sleeping to not initialize
|
||||
if(TICK_CHECK)
|
||||
SScreation.StopLoadingMap()
|
||||
SSatoms.map_loader_stop()
|
||||
stoplag()
|
||||
SScreation.StartLoadingMap()
|
||||
SSatoms.map_loader_begin()
|
||||
|
||||
/dmm_suite/proc/create_atom(path, crds)
|
||||
set waitfor = FALSE
|
||||
|
||||
Reference in New Issue
Block a user