mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-30 08:29:57 +01:00
Collapse dmms (#19698)
Collapsed all the multi-z dmm maps into single-file dmms Moved some of the map geometry into traits
This commit is contained in:
@@ -3,7 +3,20 @@
|
||||
var/id = null // All maps that should be loadable during runtime need an id
|
||||
var/width = 0
|
||||
var/height = 0
|
||||
var/list/mappaths = null
|
||||
var/mappath = null
|
||||
|
||||
/**
|
||||
* A list of traits for the zlevels of the map
|
||||
*
|
||||
* Each element is one zlevel, starting from the bottom one up
|
||||
*
|
||||
* Works the same as the variable in `/datum/map`
|
||||
*/
|
||||
var/list/traits = list(
|
||||
//Z1 (The define is a list), this is set as default because most templates only have a single zlevel
|
||||
ZTRAITS_AWAY
|
||||
)
|
||||
|
||||
var/loaded = 0 // Times loaded this round
|
||||
var/static/dmm_suite/maploader = new
|
||||
var/list/shuttles_to_initialise = list()
|
||||
@@ -16,28 +29,25 @@
|
||||
///ONLY IF IT'S THE LONGEST RUNNING CI POD AND THEY ARE ALREADY BALANCED
|
||||
var/list/unit_test_groups = list()
|
||||
|
||||
/datum/map_template/New(var/list/paths = null, rename = null)
|
||||
if(paths && !islist(paths))
|
||||
crash_with("Non-list paths passed into map template constructor.")
|
||||
if(paths)
|
||||
mappaths = paths
|
||||
if(mappaths)
|
||||
preload_size(mappaths)
|
||||
/datum/map_template/New(path = null, rename = null, cache = FALSE)
|
||||
SHOULD_CALL_PARENT(TRUE)
|
||||
. = ..()
|
||||
if(path)
|
||||
mappath = path
|
||||
if(mappath)
|
||||
preload_size(mappath, cache)
|
||||
if(rename)
|
||||
name = rename
|
||||
|
||||
..()
|
||||
|
||||
/datum/map_template/proc/preload_size(paths)
|
||||
/datum/map_template/proc/preload_size(path)
|
||||
var/list/bounds = list(1.#INF, 1.#INF, 1.#INF, -1.#INF, -1.#INF, -1.#INF)
|
||||
var/z_offset = 1 // needed to calculate z-bounds correctly
|
||||
for(var/mappath in mappaths)
|
||||
var/datum/map_load_metadata/M = maploader.load_map(file(mappath), 1, 1, z_offset, cropMap=FALSE, measureOnly=TRUE)
|
||||
if(M)
|
||||
bounds = extend_bounds_if_needed(bounds, M.bounds)
|
||||
z_offset++
|
||||
else
|
||||
return FALSE
|
||||
|
||||
var/datum/map_load_metadata/M = maploader.load_map(file(mappath), 1, 1, cropMap=FALSE, measureOnly=TRUE)
|
||||
if(M)
|
||||
bounds = extend_bounds_if_needed(bounds, M.bounds)
|
||||
else
|
||||
return FALSE
|
||||
|
||||
width = bounds[MAP_MAXX] - bounds[MAP_MINX] + 1
|
||||
height = bounds[MAP_MAXY] - bounds[MAP_MINX] + 1
|
||||
return bounds
|
||||
@@ -58,41 +68,20 @@
|
||||
|
||||
//Since SSicon_smooth.add_to_queue() manually wakes the subsystem, we have to use enable/disable.
|
||||
SSicon_smooth.can_fire = FALSE
|
||||
var/is_first = TRUE
|
||||
|
||||
for(var/i in 1 to length(mappaths))
|
||||
var/mappath = mappaths[i]
|
||||
var/datum/space_level/base_level = null
|
||||
for(var/traits_for_level in traits)
|
||||
var/level = SSmapping.add_new_zlevel(name, traits_for_level, contain_turfs = FALSE)
|
||||
if(!base_level)
|
||||
base_level = level
|
||||
|
||||
var/list/trait = ZTRAITS_AWAY
|
||||
|
||||
//Second or subsequent map file
|
||||
if(!is_first)
|
||||
//Last map file in a multi level map, can only go down
|
||||
if(i == length(mappaths))
|
||||
trait += list(ZTRAIT_UP = FALSE, ZTRAIT_DOWN = TRUE)
|
||||
//Intermediate map file, can go up and down
|
||||
else
|
||||
trait += list(ZTRAIT_UP = TRUE, ZTRAIT_DOWN = TRUE)
|
||||
|
||||
//First map file
|
||||
else
|
||||
//Multi-level map
|
||||
if(length(mappaths) >= 2)
|
||||
trait += list(ZTRAIT_UP = TRUE, ZTRAIT_DOWN = FALSE)
|
||||
//Single-level map
|
||||
else
|
||||
trait += list(ZTRAIT_UP = FALSE, ZTRAIT_DOWN = FALSE)
|
||||
|
||||
var/datum/space_level/level = SSmapping.add_new_zlevel(name, trait, contain_turfs = FALSE)
|
||||
var/datum/map_load_metadata/M = maploader.load_map(file(mappath), x, y, level.z_value, no_changeturf = no_changeturf)
|
||||
if (M)
|
||||
bounds = extend_bounds_if_needed(bounds, M.bounds)
|
||||
atoms_to_initialise += M.atoms_to_initialise
|
||||
else
|
||||
SSicon_smooth.can_fire = TRUE
|
||||
return FALSE
|
||||
|
||||
is_first = FALSE
|
||||
var/datum/map_load_metadata/M = maploader.load_map(file(mappath), x, y, base_level.z_value, no_changeturf = no_changeturf)
|
||||
if(M)
|
||||
bounds = extend_bounds_if_needed(bounds, M.bounds)
|
||||
atoms_to_initialise += M.atoms_to_initialise
|
||||
else
|
||||
SSicon_smooth.can_fire = TRUE
|
||||
return FALSE
|
||||
|
||||
for (var/z_index = bounds[MAP_MINZ]; z_index <= bounds[MAP_MAXZ]; z_index++)
|
||||
if (accessibility_weight)
|
||||
@@ -204,13 +193,13 @@
|
||||
|
||||
//Since SSicon_smooth.add_to_queue() manually wakes the subsystem, we have to use enable/disable.
|
||||
SSicon_smooth.can_fire = FALSE
|
||||
for (var/mappath in mappaths)
|
||||
var/datum/map_load_metadata/M = maploader.load_map(file(mappath), T.x, T.y, T.z, cropMap=TRUE)
|
||||
if (M)
|
||||
atoms_to_initialise += M.atoms_to_initialise
|
||||
else
|
||||
SSicon_smooth.can_fire = TRUE
|
||||
return FALSE
|
||||
|
||||
var/datum/map_load_metadata/M = maploader.load_map(file(mappath), T.x, T.y, T.z, cropMap=TRUE)
|
||||
if(M)
|
||||
atoms_to_initialise += M.atoms_to_initialise
|
||||
else
|
||||
SSicon_smooth.can_fire = TRUE
|
||||
return FALSE
|
||||
|
||||
//initialize things that are normally initialized after map load
|
||||
init_atoms(atoms_to_initialise)
|
||||
|
||||
@@ -14,3 +14,42 @@
|
||||
stack_trace("Unmanaged z-level [z]! maxz = [world.maxz], default.len = [default.len]")
|
||||
return list()
|
||||
return default[z][DL_TRAITS][trait]
|
||||
|
||||
/// Check if levels[z] has any of the specified traits
|
||||
/datum/controller/subsystem/mapping/proc/level_has_any_trait(z, list/traits)
|
||||
var/datum/space_level/level_to_check = z_list[z]
|
||||
if (length(level_to_check.traits & traits))
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
/// Check if levels[z] has all of the specified traits
|
||||
/datum/controller/subsystem/mapping/proc/level_has_all_traits(z, list/traits)
|
||||
var/datum/space_level/level_to_check = z_list[z]
|
||||
if (length(level_to_check.traits & traits) == length(traits))
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
/// Get a list of all z which have the specified trait
|
||||
/datum/controller/subsystem/mapping/proc/levels_by_trait(trait)
|
||||
return z_trait_levels[trait] || list()
|
||||
|
||||
/// Get a list of all z which have any of the specified traits
|
||||
/datum/controller/subsystem/mapping/proc/levels_by_any_trait(list/traits)
|
||||
var/list/final_return = list()
|
||||
for (var/trait in traits)
|
||||
if (z_trait_levels[trait])
|
||||
final_return |= z_trait_levels[trait]
|
||||
return final_return
|
||||
|
||||
/// Get a list of all z which have all of the specified traits
|
||||
/datum/controller/subsystem/mapping/proc/levels_by_all_traits(list/traits)
|
||||
var/list/final_return = list()
|
||||
for(var/datum/space_level/level as anything in z_list)
|
||||
if(level_has_all_traits(level.z_value, traits))
|
||||
final_return += level.z_value
|
||||
return final_return
|
||||
|
||||
/// Prefer not to use this one too often
|
||||
/datum/controller/subsystem/mapping/proc/get_station_center()
|
||||
var/station_z = levels_by_trait(ZTRAIT_STATION)[1]
|
||||
return locate(round(world.maxx * 0.5, 1), round(world.maxy * 0.5, 1), station_z)
|
||||
|
||||
Reference in New Issue
Block a user