From c0f5cedf41f02226f62bd85c84a6e02523563f92 Mon Sep 17 00:00:00 2001 From: Crazylemon64 Date: Sat, 25 Jun 2016 01:44:08 -0700 Subject: [PATCH] Adds a system to give each ruin a separate area - This means separate APCs and air alarms, while still sharing the same "Space" area, or any other area that isn't a ruin subtype --- code/game/area/areas.dm | 8 ++++- code/modules/awaymissions/maploader/reader.dm | 36 +++++++++++++++++-- code/modules/ruins/ruin_areas.dm | 1 + 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/code/game/area/areas.dm b/code/game/area/areas.dm index bce20cb8172..a42f39cd5cb 100644 --- a/code/game/area/areas.dm +++ b/code/game/area/areas.dm @@ -11,6 +11,12 @@ 'sound/ambience/ambigen10.ogg','sound/ambience/ambigen11.ogg',\ 'sound/ambience/ambigen12.ogg','sound/ambience/ambigen14.ogg') + // This var is used with the maploader (modules/awaymissions/maploader/reader.dm) + // if this is 1, when used in a map snippet, this will instantiate a unique + // area from any other instances already present (meaning you can have + // separate APCs, and so on) + var/there_can_be_many = 0 + /area/New() icon_state = "" @@ -384,4 +390,4 @@ for(var/obj/machinery/door/airlock/temp_airlock in src) temp_airlock.prison_open() for(var/obj/machinery/door/window/temp_windoor in src) - temp_windoor.open() \ No newline at end of file + temp_windoor.open() diff --git a/code/modules/awaymissions/maploader/reader.dm b/code/modules/awaymissions/maploader/reader.dm index 25c930163bf..1581fb5ae04 100644 --- a/code/modules/awaymissions/maploader/reader.dm +++ b/code/modules/awaymissions/maploader/reader.dm @@ -42,6 +42,8 @@ var/global/dmm_suite/preloader/_preloader = new var/list/grid_models = list() var/key_len = 0 + var/dmm_suite/loaded_map/LM = new + dmmRegex.next = 1 while(dmmRegex.Find(tfile, dmmRegex.next)) @@ -121,7 +123,7 @@ var/global/dmm_suite/preloader/_preloader = new var/model_key = copytext(line, tpos, tpos + key_len) if(!grid_models[model_key]) throw EXCEPTION("Undefined model key in DMM.") - parse_grid(grid_models[model_key], xcrd, ycrd, zcrd) + parse_grid(grid_models[model_key], xcrd, ycrd, zcrd, LM) CHECK_TICK maxx = max(maxx, xcrd) @@ -132,6 +134,7 @@ var/global/dmm_suite/preloader/_preloader = new CHECK_TICK + qdel(LM) if(bounds[1] == 1.#INF) // Shouldn't need to check every item return null else @@ -158,7 +161,7 @@ var/global/dmm_suite/preloader/_preloader = new * 4) Instanciates the atom with its variables * */ -/dmm_suite/proc/parse_grid(model as text,xcrd as num,ycrd as num,zcrd as num) +/dmm_suite/proc/parse_grid(model as text,xcrd as num,ycrd as num,zcrd as num, dmm_suite/loaded_map/LM) /*Method parse_grid() - Accepts a text string containing a comma separated list of type paths of the same construction as those contained in a .dmm file, and instantiates them. @@ -224,10 +227,15 @@ var/global/dmm_suite/preloader/_preloader = new //first instance the /area and remove it from the members list index = members.len if(members[index] != /area/template_noop) + // We assume `members[index]` is an area path, as above, yes? I will operate + // on that assumption. + if(!ispath(members[index], /area)) + throw EXCEPTION("Oh no, I thought this was an area!") + var/atom/instance _preloader.setup(members_attributes[index])//preloader for assigning set variables on atom creation + instance = LM.area_path_to_real_area(members[index]) - instance = locate(members[index]) var/turf/crds = locate(xcrd,ycrd,zcrd) if(crds) instance.contents.Add(crds) @@ -274,6 +282,8 @@ var/global/dmm_suite/preloader/_preloader = new if(ispath(path, /turf)) T.ChangeTurf(path, 1) instance = T + else if(ispath(path, /area)) + else instance = new path (T)//first preloader pass @@ -395,6 +405,26 @@ var/global/dmm_suite/preloader/_preloader = new what.vars[attribute] = value use_preloader = FALSE +// A datum for use within the context of loading a single map, +// so that one can have separate "unpowered" areas for ruins or whatever, +// yet have a single area type for use of mapping, instead of creating +// a new area type for each new ruin +/dmm_suite/loaded_map + parent_type = /datum + var/list/area_list = list() + +/dmm_suite/loaded_map/proc/area_path_to_real_area(area/A) + if(!ispath(A, /area)) + throw EXCEPTION("Wrong argument to `area_path_to_real_area`") + + if(!(A in area_list)) + if(initial(A.there_can_be_many)) + area_list[A] = new A + else + area_list[A] = locate(A) + + return area_list[A] + /area/template_noop name = "Area Passthrough" diff --git a/code/modules/ruins/ruin_areas.dm b/code/modules/ruins/ruin_areas.dm index 69fe2fa6376..fc51dcc0155 100644 --- a/code/modules/ruins/ruin_areas.dm +++ b/code/modules/ruins/ruin_areas.dm @@ -4,6 +4,7 @@ name = "\improper Unexplored Location" icon_state = "away" has_gravity = 1 + there_can_be_many = 1 /area/ruin/unpowered