diff --git a/code/controllers/subsystem/mapping.dm b/code/controllers/subsystem/mapping.dm index 6f0f060305b2..913e5dcd50d3 100644 --- a/code/controllers/subsystem/mapping.dm +++ b/code/controllers/subsystem/mapping.dm @@ -6,10 +6,13 @@ SUBSYSTEM_DEF(mapping) var/list/datum/map_config/configs var/list/datum/map_config/next_map_configs + ///Name of all maps var/list/map_templates = list() - + ///Name of all shuttles var/list/shuttle_templates = list() var/list/all_shuttle_templates = list() + ///map_id of all tents + var/list/tent_type_templates = list() var/list/areas_in_z = list() @@ -201,6 +204,7 @@ SUBSYSTEM_DEF(mapping) map_templates[T.name] = T preloadShuttleTemplates() + preload_tent_templates() /proc/generateMapList(filename) . = list() @@ -242,6 +246,11 @@ SUBSYSTEM_DEF(mapping) all_shuttle_templates[item] = S map_templates[S.shuttle_id] = S +/datum/controller/subsystem/mapping/proc/preload_tent_templates() + for(var/template in subtypesof(/datum/map_template/tent)) + var/datum/map_template/tent/new_tent = new template() + tent_type_templates[new_tent.map_id] = new_tent + /datum/controller/subsystem/mapping/proc/RequestBlockReservation(width, height, z, type = /datum/turf_reservation, turf_type_override) UNTIL(initialized && !clearing_reserved_turfs) var/datum/turf_reservation/reserve = new type diff --git a/code/modules/tents/folded_tents.dm b/code/modules/tents/folded_tents.dm index 08b8142ab358..2bed879a0a99 100644 --- a/code/modules/tents/folded_tents.dm +++ b/code/modules/tents/folded_tents.dm @@ -1,20 +1,34 @@ /obj/item/folded_tent name = "Folded Abstract Tent" icon = 'icons/obj/structures/tents_folded.dmi' + icon_state = "tent" w_class = SIZE_LARGE /// Required cleared area along X axis var/dim_x = 1 /// Required cleared area along Y axis var/dim_y = 1 - /// Deployment X offset - var/off_x = 0 - /// Deployment Y offset - var/off_y = 0 - /// Map Template to use for the tent - var/template + /// Tents map template typepath + var/template_preset = "abstract" + ///Map template datum used for tent + var/datum/map_template/template /// If this tent can be deployed anywhere var/unrestricted_deployment = FALSE +/obj/item/folded_tent/Initialize(mapload, ...) + . = ..() + if(template_preset == "abstract") //So spawning an abstract tent wont fail create and destroy + return + set_template(SSmapping.tent_type_templates[template_preset]) + if(!template) + CRASH("[src] initialized with template preset, \"[template_preset]\", that does not exist.") + +/obj/item/folded_tent/proc/set_template(datum/map_template/new_template) + if(!istype(new_template)) + return + template = new_template + dim_x = template.width + dim_y = template.height + /// Check an area is clear for deployment of the tent /obj/item/folded_tent/proc/check_area(turf/ref_turf, mob/message_receiver, display_error = FALSE) SHOULD_NOT_SLEEP(TRUE) @@ -47,9 +61,11 @@ return FALSE return TRUE -/obj/item/folded_tent/proc/unfold(turf/ref_turf) - var/datum/map_template/template_instance = new template() - template_instance.load(ref_turf, FALSE, FALSE) +/obj/item/folded_tent/proc/unfold(mob/user, turf/ref_turf) + if(!istype(template)) + to_chat(user, SPAN_BOLDWARNING("[src] does not contain a tent! It is broken!")) + CRASH("[src] attempted to unfold \"[template]\" as a tent.") + template.load(ref_turf, FALSE, FALSE) /obj/item/folded_tent/proc/get_deployment_area(turf/ref_turf) RETURN_TYPE(/list/turf) @@ -58,11 +74,13 @@ /obj/item/folded_tent/attack_self(mob/living/user) . = ..() + var/off_x = -(tgui_input_number(user, "If facing North or South", "Set X Offset", 0, dim_x, 0, 30 SECONDS, TRUE)) + var/off_y = -(tgui_input_number(user, "If facing East or West", "Set Y Offset", 0, dim_y, 0, 30 SECONDS, TRUE)) var/turf/deploy_turf = user.loc if(!istype(deploy_turf)) return // In a locker or something. Get lost you already have a home. - switch(user.dir) // Fix up offset deploy location so tent is better centered + can be deployed under all angles + switch(user.dir) //Handles offsets when deploying if(NORTH) deploy_turf = locate(deploy_turf.x + off_x, deploy_turf.y + 1, deploy_turf.z) if(SOUTH) @@ -103,7 +121,7 @@ QDEL_IN(gfx, 1.5 SECONDS) return - unfold(deploy_turf) + unfold(user, deploy_turf) user.visible_message(SPAN_INFO("[user] finishes deploying the [src]!"), SPAN_INFO("You finish deploying the [src]!")) for(var/gfx in turf_overlay) qdel(gfx) @@ -113,36 +131,25 @@ name = "folded USCM Command Tent" icon_state = "cmd" desc = "A standard USCM Command Tent. This one comes equipped with a self-powered Overwatch Console and a Telephone. Unfold in a suitable location to maximize usefulness. Staff Officer not included. ENTRANCE TO THE SOUTH." - dim_x = 2 - dim_y = 4 - off_x = -1 - template = /datum/map_template/tent/cmd + template_preset = "tent_cmd" /obj/item/folded_tent/med name = "folded USCM Medical Tent" icon_state = "med" desc = "A standard USCM Medical Tent. This one comes equipped with advanced field surgery facilities. Unfold in a suitable location to maximize health gains. Surgical Tray not included. ENTRANCE TO THE SOUTH." - dim_x = 2 - dim_y = 4 - template = /datum/map_template/tent/med + template_preset = "tent_med" /obj/item/folded_tent/reqs name = "folded USCM Requisitions Tent" icon_state = "req" desc = "A standard USCM Requisitions Tent. Now, you can enjoy req line anywhere you go! Unfold in a suitable location to maximize resource distribution. ASRS not included. ENTRANCE TO THE SOUTH." - dim_x = 4 - dim_y = 4 - off_x = -2 - template = /datum/map_template/tent/reqs + template_preset = "tent_reqs" /obj/item/folded_tent/big name = "folded USCM Big Tent" icon_state = "big" desc = "A standard USCM Tent. This one is just a bigger, general purpose version. Unfold in a suitable location for maximum FOB vibes. Mess Tech not included. ENTRANCE TO THE SOUTH." - dim_x = 3 - dim_y = 4 - off_x = -2 - template = /datum/map_template/tent/big + template_preset = "tent_big" /obj/effect/overlay/temp/tent_deployment_error icon = 'icons/effects/effects.dmi' diff --git a/icons/obj/structures/tents_folded.dmi b/icons/obj/structures/tents_folded.dmi index e9f4555ae6a1..e93702d7b2f9 100644 Binary files a/icons/obj/structures/tents_folded.dmi and b/icons/obj/structures/tents_folded.dmi differ