Skip to content

Commit

Permalink
Tent code changes (#4796)
Browse files Browse the repository at this point in the history
# 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:
  • Loading branch information
BeagleGaming1 committed Nov 6, 2023
1 parent bdecde4 commit 8cc8778
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 27 deletions.
11 changes: 10 additions & 1 deletion code/controllers/subsystem/mapping.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -201,6 +204,7 @@ SUBSYSTEM_DEF(mapping)
map_templates[T.name] = T

preloadShuttleTemplates()
preload_tent_templates()

/proc/generateMapList(filename)
. = list()
Expand Down Expand Up @@ -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
Expand Down
59 changes: 33 additions & 26 deletions code/modules/tents/folded_tents.dm
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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'
Expand Down
Binary file modified icons/obj/structures/tents_folded.dmi
Binary file not shown.

0 comments on commit 8cc8778

Please sign in to comment.