From 8cc8778dc20e394d56f876081d97d93ce84a1ff7 Mon Sep 17 00:00:00 2001 From: BeagleGaming1 <56142455+BeagleGaming1@users.noreply.github.com> Date: Sun, 5 Nov 2023 21:57:51 -0500 Subject: [PATCH] Tent code changes (#4796) # About the pull request Using the tents map template datum directly makes it easier to edit # Explain why it's good for the game Makes it possible to vv edit it # Changelog :cl: code: Tents now hold the datum directly, instead of the typepath admin: Added a proc for staff to change tent dmm's /:cl: --- code/controllers/subsystem/mapping.dm | 11 ++++- code/modules/tents/folded_tents.dm | 59 ++++++++++++++------------ icons/obj/structures/tents_folded.dmi | Bin 560 -> 1181 bytes 3 files changed, 43 insertions(+), 27 deletions(-) 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 e9f4555ae6a12a2c8aef0901dd5a273027a96759..e93702d7b2f9c6a01885f643496432e1943240c9 100644 GIT binary patch delta 1090 zcmdnMGM7`eGr-TCmrII^fq{Y7)59eQNGAZX0|y(Bd}>m}2c+sICgs#mSTJkSl|4c+ zT~kD3{>B{G$HJiT)lo@^XO=Ys1M@9U7srr_Id5nCW(Yfq99ORsyqL6h!j%S&Z$cZU zDSdh1c*4>4g`g=49*186u$Lagocl!`xe2g8Qqo zhS1;jdp6uW^G0p==HJ`C{Z%-_SFdRO{_Ov=Z_YgPT^6IK-Pm7xhiy%%3qu-KWcH)B zGW$!8?WwccQ_uTZn*Gxe{w5b==90TT*1AWTf$hutx52G*twp?kZHad0+_fz)Ncph4 zv*qDb=PPB_8C3Q=hCu*>Q>S#{+@kpZk0Oe?Xk}H#tjZjcvsddRk%9@DSW#4^TET`)vu1fk6%@= z$-K}y=khfz4rPXVr3aIba9n82e17I{;BzTeU+2|x9T)}PPVJw3&ZdpuWkGgLM&IXa ztFNZMKK4km<%Ii87Pb3UYkz-jeJ^5SYMOm_r9pr|!@ti*mnkq5OjvjKtA^u*Dev7F zpFI~3-FRd5s`z~?=e><~x-0Yjfbjfz{}LZ?FiG!w{ch#!?rEtSYguyY8`$n{+0E0+ zyR+u{{gr7)vjkXlopXP^J9o41P z!OyY$z3s^Z6D&hB|5)&JJTM6OUC83NJJNK)?nYGo~D3`w~1Z*w=u zyYs!@RAjc`)5Gel|Dl(;CR};QVt?W1i57#@y{uOQ7sWnd{`xlX>z1wypO)J^J>Fh= zC)(Ze@1wnjhF;(GI_j z`mg9aKR$8NU-($6hD_zpsu!h=> zi`@R%qLMkQX_DQX2ke~!OJl#E@P56zV_G^xXTs)*8!Ueb99$-wd8EQcGt>E+*2?=G jf8Td7oIyi>7)8oF*O@dBEW5>gTe~DWM4fbTkDA delta 463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