From 81c4d7b5aba1bacff48a48ef911e7be2cb329cdd Mon Sep 17 00:00:00 2001 From: Leshana Date: Sat, 4 Mar 2017 22:34:35 -0500 Subject: [PATCH] Made blueprints able to expand station areas into spae * Added expand area capability, it will add connected space area turfs to the current area. * Made the allowed area types vars so they can be more easily configured if needed. --- code/game/objects/items/blueprints.dm | 59 ++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 6 deletions(-) diff --git a/code/game/objects/items/blueprints.dm b/code/game/objects/items/blueprints.dm index 40d2f968c5..ce74cc049f 100644 --- a/code/game/objects/items/blueprints.dm +++ b/code/game/objects/items/blueprints.dm @@ -33,6 +33,12 @@ // For the color overlays var/list/areaColor_turfs = list() + // Easy configuring of what we're allowed to do where or whatnot + var/can_create_areas_in = AREA_SPACE // Must be standing in space to create + var/can_create_areas_into = AREA_SPACE // New areas will only overwrite space area turfs. + var/can_expand_areas_in = AREA_STATION // Must be standing in station to expand + var/can_expand_areas_into = AREA_SPACE // Can expand station areas only into space. + var/can_rename_areas_in = AREA_STATION // Only station areas can be reanamed /obj/item/blueprints/attack_self(mob/M as mob) if (!istype(M,/mob/living/carbon/human)) @@ -49,17 +55,23 @@ return switch(href_list["action"]) if ("create_area") - if (get_area_type()!=AREA_SPACE) + if (!(get_area_type() & can_create_areas_in)) usr << "You can't make a new area here." interact() return create_area() if ("edit_area") - if (get_area_type()!=AREA_STATION) + if (!(get_area_type() & can_rename_areas_in)) usr << "You can't rename this area." interact() return edit_area() + if ("expand_area") + if (!(get_area_type() & can_expand_areas_in)) + usr << "You can't expand this area." + interact() + return + expand_area() /obj/item/blueprints/interact() var/area/A = get_area() @@ -80,9 +92,11 @@ return // Shouldn ever get here, just sanity check // Offer links for what user is allowed to do based on current area - if(curAreaType == AREA_SPACE) + if(curAreaType & can_create_areas_in) text += "

You can Mark this place as new area.

" - if(curAreaType == AREA_STATION) + if(curAreaType & can_expand_areas_in) + text += "

You can expand the area.

" + if(curAreaType & can_rename_areas_in) text += "

You can rename the area.

" text += "" @@ -108,7 +122,7 @@ * Create a new area encompasing the current room. */ /obj/item/blueprints/proc/create_area() - var/res = detect_room_ex(get_turf(usr), AREA_SPACE) + var/res = detect_room_ex(get_turf(usr), can_create_areas_into) if(!istype(res,/list)) switch(res) if(ROOM_ERR_SPACE) @@ -141,6 +155,37 @@ interact() return +/** + * Expand the current area to fill the current room. + */ +/obj/item/blueprints/proc/expand_area() + var/turf/startingTurf = get_turf(usr) + var/res = detect_room_ex(startingTurf, can_expand_areas_into) + if(!istype(res,/list)) + switch(res) + if(ROOM_ERR_SPACE) + usr << "The new area must be completely airtight!" + return + if(ROOM_ERR_TOOLARGE) + usr << "The new area too large!" + return + else + usr << "Error! Please notify administration!" + return + var/list/turf/turfs = res + + var/area/A = get_area(startingTurf) + for(var/turf/T in A.contents) + turfs -= T // Don't add turfs already in A to A + if(turfs.len == 0) + usr << "\The [A] already covers the entire room." + return + + move_turfs_to_area(turfs, A) + usr << "Expanded \the [A] by [turfs.len] turfs" + spawn(5) + interact() + return /obj/item/blueprints/proc/move_turfs_to_area(var/list/turf/turfs, var/area/A) A.contents.Add(turfs) @@ -251,7 +296,9 @@ set category = "Blueprints" set name = "Show Room Colors" - var/res = detect_room_ex(get_turf(usr), AREA_SPACE) + // If standing somewhere we can expand from, use expand perms, otherwise create + var/canOverwrite = (get_area_type() & can_expand_areas_in) ? can_expand_areas_into : can_create_areas_into + var/res = detect_room_ex(get_turf(usr), canOverwrite) if(!istype(res, /list)) switch(res) if(ROOM_ERR_SPACE)