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:
Leshana
2018-01-26 20:35:13 -05:00
parent f116625c7b
commit 44dc4b7286
18 changed files with 309 additions and 78 deletions
+3 -3
View File
@@ -27,7 +27,7 @@
use_power = 1
idle_power_usage = 100
var/initialized = 0 // Map-placed ones break if seeds are loaded right at the start of the round, so we do it on the first interaction
var/seeds_initialized = 0 // Map-placed ones break if seeds are loaded right at the start of the round, so we do it on the first interaction
var/list/datum/seed_pile/piles = list()
var/list/starting_seeds = list()
var/list/scanner = list() // What properties we can view
@@ -135,7 +135,7 @@
if (..())
return
if (!initialized)
if (!seeds_initialized)
for(var/typepath in starting_seeds)
var/amount = starting_seeds[typepath]
if(isnull(amount)) amount = 1
@@ -143,7 +143,7 @@
for (var/i = 1 to amount)
var/O = new typepath
add(O)
initialized = 1
seeds_initialized = 1
var/dat = "<center><h1>Seed storage contents</h1></center>"
if (piles.len == 0)
+6 -1
View File
@@ -10,7 +10,7 @@
//invisibility = INVISIBILITY_LIGHTING
color = LIGHTING_BASE_MATRIX
icon_state = "light1"
auto_init = 0 // doesn't need special init
//auto_init = 0 // doesn't need special init
blend_mode = BLEND_OVERLAY
var/lum_r = 0
@@ -19,6 +19,11 @@
var/needs_update = FALSE
/atom/movable/lighting_overlay/initialize()
// doesn't need special init
initialized = TRUE
return INITIALIZE_HINT_NORMAL
/atom/movable/lighting_overlay/New(var/atom/loc, var/no_update = FALSE)
. = ..()
verbs.Cut()
+23 -45
View File
@@ -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)
+4 -4
View File
@@ -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
+1 -1
View File
@@ -10,7 +10,7 @@
unacidable = 1
density = 0
opacity = 0 // Don't trigger lighting recalcs gah! TODO - consider multi-z lighting.
auto_init = FALSE // We do not need to be initialize()d
//auto_init = FALSE // We do not need to be initialize()d
var/mob/owner = null // What we are a shadow of.
/mob/zshadow/can_fall()