Files
Bubberstation/code/modules/mapping/modular_map_loader/modular_map_loader.dm
YesterdaysPromise 71a1fee2f1 Explodes device.dmi (#80025)
## About The Pull Request

I woke up today and thought 'what would be easy thing to do today so I
can say I've done something?'. Then I remembered I saw several gangtool
usages the time I split radio up, and I could remedy those. 7 hours
later, device.dmi is split in a folder of its own, and I've also given
unique sprites to door remotes and landing desginators.


## Why It's Good For The Game

The device.dmi was kind of a mess.

## Changelog

🆑
/🆑
2023-12-09 13:31:50 +01:00

78 lines
2.0 KiB
Plaintext

/obj/modular_map_root
invisibility = INVISIBILITY_ABSTRACT
icon = 'icons/obj/devices/tracker.dmi'
icon_state = "pinonclose"
resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF
anchored = TRUE
/// Points to a .toml file storing configuration data about the modules associated with this root
var/config_file = null
/// Key used to look up the appropriate map paths in the associated .toml file
var/key = null
INITIALIZE_IMMEDIATE(/obj/modular_map_root)
/obj/modular_map_root/Initialize(mapload)
. = ..()
INVOKE_ASYNC(src, PROC_REF(load_map))
/// Randonly selects a map file from the TOML config specified in config_file, loads it, then deletes itself.
/obj/modular_map_root/proc/load_map()
var/turf/spawn_area = get_turf(src)
var/datum/map_template/map_module/map = new()
if(!config_file)
return
if(!key)
return
var/config = rustg_read_toml_file(config_file)
var/mapfile = config["directory"] + pick(config["rooms"][key]["modules"])
map.load(spawn_area, FALSE, mapfile)
qdel(src, force=TRUE)
/datum/map_template/map_module
name = "Base Map Module Template"
var/x_offset = 0
var/y_offset = 0
/datum/map_template/map_module/load(turf/T, centered = FALSE, mapfile = null)
if(!mapfile)
return
mappath = mapfile
preload_size(mappath) // We need to run this here as the map path has been null until now
T = locate(T.x - x_offset, T.y - y_offset, T.z)
. = ..()
/datum/map_template/map_module/preload_size(path, cache)
. = ..(path, TRUE) // Done this way because we still want to know if someone actualy wanted to cache the map
if(!cached_map)
return
var/list/offset = discover_offset(/obj/modular_map_connector)
x_offset = offset[1] - 1
y_offset = offset[2] - 1
if(!cache)
cached_map = null
/obj/modular_map_connector
invisibility = INVISIBILITY_ABSTRACT
icon = 'icons/obj/devices/tracker.dmi'
icon_state = "pinonclose"
resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF
anchored = TRUE