mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-23 13:10:02 +01:00
Merge pull request #19810 from KorPhaeron/blueprint_fix
Refactors area creation
This commit is contained in:
@@ -1,3 +1,18 @@
|
||||
#define AREA_ERRNONE 0
|
||||
#define AREA_STATION 1
|
||||
#define AREA_SPACE 2
|
||||
#define AREA_SPECIAL 3
|
||||
|
||||
#define BORDER_ERROR 0
|
||||
#define BORDER_NONE 1
|
||||
#define BORDER_BETWEEN 2
|
||||
#define BORDER_2NDTILE 3
|
||||
#define BORDER_SPACE 4
|
||||
|
||||
#define ROOM_ERR_LOLWAT 0
|
||||
#define ROOM_ERR_SPACE 1
|
||||
#define ROOM_ERR_TOOLARGE 2
|
||||
|
||||
/obj/item/areaeditor
|
||||
name = "area modification item"
|
||||
icon = 'icons/obj/items.dmi'
|
||||
@@ -5,22 +20,6 @@
|
||||
attack_verb = list("attacked", "bapped", "hit")
|
||||
var/fluffnotice = "Nobody's gonna read this stuff!"
|
||||
|
||||
var/const/AREA_ERRNONE = 0
|
||||
var/const/AREA_STATION = 1
|
||||
var/const/AREA_SPACE = 2
|
||||
var/const/AREA_SPECIAL = 3
|
||||
|
||||
var/const/BORDER_ERROR = 0
|
||||
var/const/BORDER_NONE = 1
|
||||
var/const/BORDER_BETWEEN = 2
|
||||
var/const/BORDER_2NDTILE = 3
|
||||
var/const/BORDER_SPACE = 4
|
||||
|
||||
var/const/ROOM_ERR_LOLWAT = 0
|
||||
var/const/ROOM_ERR_SPACE = -1
|
||||
var/const/ROOM_ERR_TOOLARGE = -2
|
||||
|
||||
|
||||
/obj/item/areaeditor/attack_self(mob/user)
|
||||
add_fingerprint(user)
|
||||
var/text = "<BODY><HTML><head><title>[src]</title></head> \
|
||||
@@ -43,37 +42,9 @@
|
||||
return
|
||||
if(href_list["create_area"])
|
||||
if(get_area_type()==AREA_SPACE)
|
||||
create_area()
|
||||
create_area(usr)
|
||||
updateUsrDialog()
|
||||
|
||||
|
||||
//One-use area creation permits.
|
||||
/obj/item/areaeditor/permit
|
||||
name = "construction permit"
|
||||
icon_state = "permit"
|
||||
desc = "This is a one-use permit that allows the user to offically declare a built room as new addition to the station."
|
||||
fluffnotice = "Nanotrasen Engineering requires all on-station construction projects to be approved by a head of staff, as detailed in Nanotrasen Company Regulation 512-C (Mid-Shift Modifications to Company Property). \
|
||||
By submitting this form, you accept any fines, fees, or personal injury/death that may occur during construction."
|
||||
w_class = 1
|
||||
|
||||
|
||||
/obj/item/areaeditor/permit/attack_self(mob/user)
|
||||
. = ..()
|
||||
var/area/A = get_area()
|
||||
if(get_area_type() == AREA_STATION)
|
||||
. += "<p>According to \the [src], you are now in <b>\"[html_encode(A.name)]\"</b>.</p>"
|
||||
var/datum/browser/popup = new(user, "blueprints", "[src]", 700, 500)
|
||||
popup.set_content(.)
|
||||
popup.open()
|
||||
onclose(usr, "blueprints")
|
||||
|
||||
|
||||
/obj/item/areaeditor/permit/create_area()
|
||||
var/success = ..()
|
||||
if(success)
|
||||
qdel(src)
|
||||
|
||||
|
||||
//Station blueprints!!!
|
||||
/obj/item/areaeditor/blueprints
|
||||
name = "station blueprints"
|
||||
@@ -87,7 +58,6 @@
|
||||
|
||||
/obj/item/areaeditor/blueprints/Destroy()
|
||||
clear_viewer()
|
||||
|
||||
return ..()
|
||||
|
||||
|
||||
@@ -179,29 +149,28 @@
|
||||
return AREA_SPECIAL
|
||||
return AREA_STATION
|
||||
|
||||
|
||||
/obj/item/areaeditor/proc/create_area()
|
||||
var/res = detect_room(get_turf(usr))
|
||||
/proc/create_area(mob/living/creator)
|
||||
var/res = detect_room(get_turf(creator))
|
||||
if(!istype(res,/list))
|
||||
switch(res)
|
||||
if(ROOM_ERR_SPACE)
|
||||
usr << "<span class='warning'>The new area must be completely airtight.</span>"
|
||||
creator << "<span class='warning'>The new area must be completely airtight.</span>"
|
||||
return
|
||||
if(ROOM_ERR_TOOLARGE)
|
||||
usr << "<span class='warning'>The new area is too large.</span>"
|
||||
creator << "<span class='warning'>The new area is too large.</span>"
|
||||
return
|
||||
else
|
||||
usr << "<span class='warning'>Error! Please notify administration.</span>"
|
||||
creator << "<span class='warning'>Error! Please notify administration.</span>"
|
||||
return
|
||||
|
||||
var/list/turfs = res
|
||||
var/str = trim(stripped_input(usr,"New area name:", "Blueprint Editing", "", MAX_NAME_LEN))
|
||||
var/str = trim(stripped_input(creator,"New area name:", "Blueprint Editing", "", MAX_NAME_LEN))
|
||||
if(!str || !length(str)) //cancel
|
||||
return
|
||||
if(length(str) > 50)
|
||||
usr << "<span class='warning'>The given name is too long. The area remains undefined.</span>"
|
||||
creator << "<span class='warning'>The given name is too long. The area remains undefined.</span>"
|
||||
return
|
||||
var/area/old = get_area(get_turf(src))
|
||||
var/area/old = get_area(get_turf(creator))
|
||||
var/old_gravity = old.has_gravity
|
||||
|
||||
var/area/A
|
||||
@@ -220,14 +189,14 @@
|
||||
A.contents += turfs
|
||||
A.SetDynamicLighting()
|
||||
A.has_gravity = old_gravity
|
||||
interact()
|
||||
creator << "<span class='notice'>You have created a new area, named [str]. It is now weather proof, and constructing an APC will allow it to be powered.</span>"
|
||||
return 1
|
||||
|
||||
|
||||
/obj/item/areaeditor/proc/edit_area()
|
||||
var/area/A = get_area()
|
||||
var/prevname = "[A.name]"
|
||||
var/str = trim(stripped_input(usr,"New area name:", "Blueprint Editing", "", MAX_NAME_LEN))
|
||||
var/str = trim(stripped_input(usr,"New area name:", "Area Creation", "", MAX_NAME_LEN))
|
||||
if(!str || !length(str) || str==prevname) //cancel
|
||||
return
|
||||
if(length(str) > 50)
|
||||
@@ -258,33 +227,26 @@
|
||||
//TODO: much much more. Unnamed airlocks, cameras, etc.
|
||||
|
||||
|
||||
/obj/item/areaeditor/proc/check_tile_is_border(turf/T2,dir)
|
||||
if (istype(T2, /turf/open/space))
|
||||
return BORDER_SPACE //omg hull breach we all going to die here
|
||||
if (get_area_type(T2.loc)!=AREA_SPACE)
|
||||
return BORDER_BETWEEN
|
||||
if (istype(T2, /turf/closed/wall))
|
||||
return BORDER_2NDTILE
|
||||
if (!istype(T2, /turf))
|
||||
return BORDER_BETWEEN
|
||||
/turf/proc/check_tile_is_border()
|
||||
return BORDER_NONE
|
||||
|
||||
for (var/obj/structure/window/W in T2)
|
||||
if(turn(dir,180) == W.dir)
|
||||
return BORDER_BETWEEN
|
||||
if (W.dir in list(NORTHEAST,SOUTHEAST,NORTHWEST,SOUTHWEST))
|
||||
/turf/open/space/check_tile_is_border()
|
||||
return BORDER_SPACE
|
||||
|
||||
/turf/closed/check_tile_is_border()
|
||||
return BORDER_2NDTILE
|
||||
|
||||
/turf/open/check_tile_is_border()
|
||||
for(var/atom/movable/AM in src)
|
||||
if(!AM.CanAtmosPass(src))
|
||||
return BORDER_2NDTILE
|
||||
for(var/obj/machinery/door/window/D in T2)
|
||||
if(turn(dir,180) == D.dir)
|
||||
return BORDER_BETWEEN
|
||||
if (locate(/obj/machinery/door) in T2)
|
||||
return BORDER_2NDTILE
|
||||
if (locate(/obj/structure/falsewall) in T2)
|
||||
return BORDER_2NDTILE
|
||||
|
||||
return BORDER_NONE
|
||||
|
||||
/turf/closed/mineral/check_tile_is_border()
|
||||
return BORDER_NONE
|
||||
|
||||
/obj/item/areaeditor/proc/detect_room(turf/first)
|
||||
/proc/detect_room(turf/first)
|
||||
var/list/turf/found = new
|
||||
var/list/turf/pending = list(first)
|
||||
var/list/border = list()
|
||||
@@ -312,7 +274,7 @@
|
||||
if (!isturf(NT) || (NT in found) || (NT in pending))
|
||||
continue
|
||||
|
||||
switch(check_tile_is_border(NT,dir))
|
||||
switch(NT.check_tile_is_border())
|
||||
if(BORDER_NONE)
|
||||
pending+=NT
|
||||
if(BORDER_BETWEEN)
|
||||
@@ -333,7 +295,7 @@
|
||||
var/turf/U = get_step(F, direction)
|
||||
if((U in border) || (U in found))
|
||||
continue
|
||||
if(check_tile_is_border(U, direction) == BORDER_2NDTILE)
|
||||
if(U.check_tile_is_border() == BORDER_2NDTILE)
|
||||
found += U
|
||||
found |= F
|
||||
return found
|
||||
@@ -347,4 +309,4 @@
|
||||
desc = "A digital copy of the station blueprints stored in your memory."
|
||||
icon = 'icons/obj/items.dmi'
|
||||
icon_state = "blueprints"
|
||||
fluffnotice = "Intellectual Property of Nanotrasen. For use in engineering cyborgs only. Wipe from memory upon departure from the station."
|
||||
fluffnotice = "Intellectual Property of Nanotrasen. For use in engineering cyborgs only. Wipe from memory upon departure from the station."
|
||||
|
||||
@@ -343,18 +343,6 @@
|
||||
for(var/i = 1; i <= 5; i++)
|
||||
new /obj/item/weapon/reagent_containers/food/snacks/monkeycube(src)
|
||||
|
||||
|
||||
/obj/item/weapon/storage/box/permits
|
||||
name = "box of construction permits"
|
||||
desc = "A box for containing construction permits, used to officially declare built rooms as additions to the station."
|
||||
icon_state = "id"
|
||||
|
||||
/obj/item/weapon/storage/box/permits/New() //There's only a few, so blueprints are still useful beyond setting every room's name to PRIMARY FART STORAGE
|
||||
..()
|
||||
for(var/i in 1 to 3)
|
||||
new /obj/item/areaeditor/permit(src)
|
||||
|
||||
|
||||
/obj/item/weapon/storage/box/ids
|
||||
name = "box of spare IDs"
|
||||
desc = "Has so many empty IDs."
|
||||
|
||||
Reference in New Issue
Block a user