From d2e3e778052b5bd9e80dd514936c9b91c5fa5160 Mon Sep 17 00:00:00 2001 From: kane-f <57303506+kane-f@users.noreply.github.com> Date: Thu, 3 Jun 2021 00:29:38 +0100 Subject: [PATCH] RCD window construction/deconstruction (#29637) * Adding spawner * File itself * Window schematics * Construct window framework * Adding to schematics and deconstructioN * Adding to mech and borg schematics, placeholder icon * Fixing compile errors * Unneeded var * Hopefully better logic * Copypasting fix * Another compile fix * This should make selecting them actually work * No deconstructing plasma glass * Better checks, can_r_wall usage * Less brackets * Overlay implementation testing * More of it * Remove for now so it can compile, come up with better idea later * Workable solution * Now actually works right * Custom dirs Co-authored-by: kanef --- code/_onclick/hud/screen_objects.dm | 2 + code/modules/RCD/RCD.dm | 3 +- code/modules/RCD/engie.dm | 6 +- code/modules/RCD/schematic.dm | 1 + code/modules/RCD/schematics/engi.dm | 271 ++++++++++++++++++ .../RCD/schematics/rcd_window_spawner.dm | 115 ++++++++ vgstation13.dme | 1 + 7 files changed, 396 insertions(+), 3 deletions(-) create mode 100644 code/modules/RCD/schematics/rcd_window_spawner.dm diff --git a/code/_onclick/hud/screen_objects.dm b/code/_onclick/hud/screen_objects.dm index db9687c7793..48bcb7a330c 100644 --- a/code/_onclick/hud/screen_objects.dm +++ b/code/_onclick/hud/screen_objects.dm @@ -46,6 +46,7 @@ icon = ourschematic.icon icon_state = ourschematic.icon_state name = ourschematic.name + overlays += ourschematic.overlays transform = transform*0.8 /obj/abstract/screen/schematics/Click() @@ -54,6 +55,7 @@ /obj/abstract/screen/schematics/Destroy() ourschematic = null + overlays = list() ..() /obj/abstract/screen/inventory diff --git a/code/modules/RCD/RCD.dm b/code/modules/RCD/RCD.dm index 5b9fa881a9b..b5ad0ce08fd 100644 --- a/code/modules/RCD/RCD.dm +++ b/code/modules/RCD/RCD.dm @@ -347,7 +347,8 @@ /datum/rcd_schematic/decon, /datum/rcd_schematic/con_floors, /datum/rcd_schematic/con_walls, - /datum/rcd_schematic/con_airlock + /datum/rcd_schematic/con_airlock, + /datum/rcd_schematic/con_window, ) /obj/item/device/rcd/mech/attack_self(var/mob/living/user) diff --git a/code/modules/RCD/engie.dm b/code/modules/RCD/engie.dm index 6dcdb7528dd..f6923e7eb65 100644 --- a/code/modules/RCD/engie.dm +++ b/code/modules/RCD/engie.dm @@ -3,7 +3,8 @@ /datum/rcd_schematic/decon, /datum/rcd_schematic/con_floors, /datum/rcd_schematic/con_walls, - /datum/rcd_schematic/con_airlock + /datum/rcd_schematic/con_airlock, + /datum/rcd_schematic/con_window, ) @@ -35,7 +36,8 @@ /datum/rcd_schematic/decon, /datum/rcd_schematic/con_floors, /datum/rcd_schematic/con_walls, - /datum/rcd_schematic/con_airlock/borg + /datum/rcd_schematic/con_airlock/borg, + /datum/rcd_schematic/con_window/borg, ) /obj/item/device/rcd/matter/engineering/pre_loaded/admin diff --git a/code/modules/RCD/schematic.dm b/code/modules/RCD/schematic.dm index c4748789c81..ac95480947a 100644 --- a/code/modules/RCD/schematic.dm +++ b/code/modules/RCD/schematic.dm @@ -7,6 +7,7 @@ var/obj/item/device/rcd/master //Okay all of the vars here are obvious... var/icon var/icon_state + var/list/overlays = list() var/obj/abstract/screen/schematics/ourobj var/datum/selection_schematic/selected diff --git a/code/modules/RCD/schematics/engi.dm b/code/modules/RCD/schematics/engi.dm index c20e4a49148..2aa39dbf64b 100644 --- a/code/modules/RCD/schematics/engi.dm +++ b/code/modules/RCD/schematics/engi.dm @@ -45,7 +45,26 @@ playsound(master, 'sound/items/Deconstruct.ogg', 50, 1) qdel(D) return 0 + + else if(istype(A,/obj/structure/window)) + var/obj/structure/window/W = A + if(is_type_in_list(W, list(/obj/structure/window/plasma,/obj/structure/window/reinforced/plasma,/obj/structure/window/full/plasma,/obj/structure/window/full/reinforced/plasma)) && !can_r_wall) + return "it cannot deconstruct plasma glass!" + to_chat(user, "Deconstructing \the [W]...") + if(master.delay(user, W, 5 SECONDS)) + if(master.get_energy(user) < energy_cost) + return 1 + playsound(master, 'sound/items/Deconstruct.ogg', 50, 1) + for(var/obj/structure/grille/G in W.loc) + qdel(G) + for(var/obj/structure/window/WI in W.loc) + if(is_type_in_list(W, list(/obj/structure/window/plasma,/obj/structure/window/reinforced/plasma,/obj/structure/window/full/plasma,/obj/structure/window/full/reinforced/plasma)) && !can_r_wall) + continue + if(WI != W) + qdel(WI) + qdel(W) + return 0 return 1 /datum/rcd_schematic/con_floors @@ -371,11 +390,95 @@ D.req_access = selected_access.Copy() D.autoclose = 1 + +/datum/rcd_schematic/con_window + name = "Build window" + icon = 'icons/obj/window_grille_spawner.dmi' + icon_state = "window_grille" + category = "Construction" + energy_cost = 2 + + var/list/schematics = list() + var/ready + +/datum/rcd_schematic/con_window/borg + energy_cost = 20 + +/datum/rcd_schematic/con_window/show(var/mob/living/user, close = 0) + if(!close) + user.shown_schematics_background = 1 + user.hud_used.toggle_show_schematics_display(schematics,1, master) + else + user.shown_schematics_background = 1 + user.hud_used.toggle_show_schematics_display(master.schematics["Construction"], 1, master) + master.selected = null + return 1 + +/datum/rcd_schematic/con_window/New() + . = ..() + + for(var/path in typesof(/datum/selection_schematic/window_schematic)) + schematics += new path(src) + selected = schematics[1] + +/datum/rcd_schematic/con_window/Destroy() + for(var/datum/selection_schematic/thing in schematics) + qdel(thing) + schematics = null + ..() + +/datum/rcd_schematic/con_window/select(var/mob/user, var/datum/rcd_schematic/old_schematic) + ..() + show(user) +/datum/rcd_schematic/con_window/deselect() + . = ..() + selected = schematics[1] //Reset the selection. + +/*/datum/rcd_schematic/con_window/register_assets() + for(var/datum/selection_schematic/airlock_schematic/C in schematics) + C.register_icon() + +/datum/rcd_schematic/con_window/send_assets(var/client/client) + for(var/datum/selection_schematic/airlock_schematic/C in schematics) + C.send_icon(client) +*/ + +/datum/rcd_schematic/con_window/build_ui() + master.interface.updateLayout("
") + master.update_options_menu() + +/datum/rcd_schematic/con_window/Topic(var/href, var/href_list) + if(href_list["set_selected"]) + var/idx = clamp(text2num(href_list["set_selected"]), 1, schematics.len) + var/datum/selection_schematic/window_schematic/C = schematics[idx] + + selected = C + + master.update_options_menu() + return 1 + +/datum/rcd_schematic/con_window/attack(var/atom/A, var/mob/user) + if(!istype(A, /turf)) + return 1 + + to_chat(user, "Building window...") + + if(!master.delay(user, A, 5 SECONDS)) + return 1 + + if(master.get_energy(user) < energy_cost) + return 1 + + playsound(master, 'sound/items/Deconstruct.ogg', 50, 1) + + new selected.build_type(A) + /datum/selection_schematic var/name = "Selection" var/build_type var/icon_state var/icon + var/list/overlays = list() var/obj/abstract/screen/ourobj var/datum/rcd_schematic/master @@ -518,3 +621,171 @@ name = "\improper Glass Mining Airlock" build_type = /obj/machinery/door/airlock/glass_mining icon = 'icons/obj/doors/Doorminingglass.dmi' + +// ALL THE WINDOW TYPES. +/datum/selection_schematic/window_schematic + name = "window" //Name of the window for the tooltip. + build_type = /obj/effect/spawner/window //Type of the window. + icon = 'icons/obj/structures.dmi' + icon_state = "grille" + var/list/dirs = list(NORTH,EAST,WEST,SOUTH) + +/datum/selection_schematic/window_schematic/New() + for(var/d in dirs) + overlays += image(icon,icon_state="rwindow",dir=d) + ..() + +/datum/selection_schematic/window_schematic/Destroy() + overlays = list() + ..() + +/datum/selection_schematic/window_schematic/clicked(var/mob/user) + master.selected = src + +/datum/selection_schematic/window_schematic/northend + name = "\improper north window" + build_type = /obj/effect/spawner/window/northend + dirs = list(NORTH) + +/datum/selection_schematic/window_schematic/eastend + name = "\improper east window" + build_type = /obj/effect/spawner/window/eastend + dirs = list(EAST) + +/datum/selection_schematic/window_schematic/southend + name = "\improper south window" + build_type = /obj/effect/spawner/window/southend + dirs = list(SOUTH) + +/datum/selection_schematic/window_schematic/westend + name = "\improper west window" + build_type = /obj/effect/spawner/window/westend + dirs = list(WEST) + +/datum/selection_schematic/window_schematic/horizontal + name = "\improper horizontal window" + build_type = /obj/effect/spawner/window/horizontal + dirs = list(NORTH,SOUTH) + +/datum/selection_schematic/window_schematic/vertical + name = "\improper vertical window" + build_type = /obj/effect/spawner/window/vertical + dirs = list(EAST,WEST) + +/datum/selection_schematic/window_schematic/necorner + name = "\improper northeast window" + build_type = /obj/effect/spawner/window/necorner + dirs = list(NORTH,EAST) + +/datum/selection_schematic/window_schematic/secorner + name = "\improper southeast window" + build_type = /obj/effect/spawner/window/secorner + dirs = list(EAST,SOUTH) + +/datum/selection_schematic/window_schematic/swcorner + name = "\improper southwest window" + build_type = /obj/effect/spawner/window/swcorner + dirs = list(WEST,SOUTH) + +/datum/selection_schematic/window_schematic/nwcorner + name = "\improper northwest window" + build_type = /obj/effect/spawner/window/nwcorner + dirs = list(NORTH,WEST) + +/datum/selection_schematic/window_schematic/northcap + name = "\improper north window cap" + build_type = /obj/effect/spawner/window/northcap + dirs = list(NORTH,EAST,WEST) + +/datum/selection_schematic/window_schematic/eastcap + name = "\improper east window cap" + build_type = /obj/effect/spawner/window/eastcap + dirs = list(NORTH,EAST,SOUTH) + +/datum/selection_schematic/window_schematic/southcap + name = "\improper south window cap" + build_type = /obj/effect/spawner/window/southcap + dirs = list(EAST,WEST,SOUTH) + +/datum/selection_schematic/window_schematic/westcap + name = "\improper west window cap" + build_type = /obj/effect/spawner/window/westcap + dirs = list(NORTH,WEST,SOUTH) + +/datum/selection_schematic/window_schematic/full + name = "\improper full window" + build_type = /obj/effect/spawner/window/full + +/datum/selection_schematic/window_schematic/full/New() + overlays += image(icon,icon_state="rwindow0") + ..() + +/datum/selection_schematic/window_schematic/full/northend + name = "\improper full north window" + build_type = /obj/effect/spawner/window/full/northend + dirs = list(NORTH) + +/datum/selection_schematic/window_schematic/full/eastend + name = "\improper full east window" + build_type = /obj/effect/spawner/window/full/eastend + dirs = list(EAST) + +/datum/selection_schematic/window_schematic/full/southend + name = "\improper full south window" + build_type = /obj/effect/spawner/window/full/southend + dirs = list(SOUTH) + +/datum/selection_schematic/window_schematic/full/westend + name = "\improper full west window" + build_type = /obj/effect/spawner/window/full/westend + dirs = list(WEST) + +/datum/selection_schematic/window_schematic/full/horizontal + name = "\improper full horizontal window" + build_type = /obj/effect/spawner/window/full/horizontal + dirs = list(NORTH,SOUTH) + +/datum/selection_schematic/window_schematic/full/vertical + name = "\improper full vertical window" + build_type = /obj/effect/spawner/window/full/vertical + dirs = list(EAST,WEST) + +/datum/selection_schematic/window_schematic/full/necorner + name = "\improper full northeast window" + build_type = /obj/effect/spawner/window/full/necorner + dirs = list(NORTH,EAST) + +/datum/selection_schematic/window_schematic/full/secorner + name = "\improper full southeast window" + build_type = /obj/effect/spawner/window/full/secorner + dirs = list(EAST,SOUTH) + +/datum/selection_schematic/window_schematic/full/swcorner + name = "\improper full southwest window" + build_type = /obj/effect/spawner/window/full/swcorner + dirs = list(WEST,SOUTH) + +/datum/selection_schematic/window_schematic/full/nwcorner + name = "\improper full northwest window" + build_type = /obj/effect/spawner/window/full/nwcorner + dirs = list(NORTH,WEST) + +/datum/selection_schematic/window_schematic/full/northcap + name = "\improper full north window cap" + build_type = /obj/effect/spawner/window/full/northcap + dirs = list(NORTH,EAST,WEST) + +/datum/selection_schematic/window_schematic/full/eastcap + name = "\improper full east window cap" + build_type = /obj/effect/spawner/window/full/eastcap + dirs = list(NORTH,EAST,SOUTH) + +/datum/selection_schematic/window_schematic/full/southcap + name = "\improper full south window cap" + build_type = /obj/effect/spawner/window/full/southcap + dirs = list(EAST,WEST,SOUTH) + +/datum/selection_schematic/window_schematic/full/westcap + name = "\improper full west window cap" + build_type = /obj/effect/spawner/window/full/westcap + dirs = list(NORTH,WEST,SOUTH) \ No newline at end of file diff --git a/code/modules/RCD/schematics/rcd_window_spawner.dm b/code/modules/RCD/schematics/rcd_window_spawner.dm new file mode 100644 index 00000000000..ee5f0ab9bb1 --- /dev/null +++ b/code/modules/RCD/schematics/rcd_window_spawner.dm @@ -0,0 +1,115 @@ +/obj/effect/spawner/window + name = "window spawner" + var/full = FALSE + var/list/dirs = list(NORTH,WEST,SOUTH,EAST) + +/obj/effect/spawner/window/New() + ..() + spawn_window() + +/obj/effect/spawner/window/proc/spawn_window() + var/turf/T = get_turf(src) + if(T && !istype(T,/turf/simulated/wall) && !istype(T,/turf/unsimulated/wall)) + if(!locate(/obj/structure/grille) in loc) + new /obj/structure/grille(T) + for(var/direction in dirs) + var/windowhere = FALSE + for(var/obj/structure/window/reinforced/R in loc) + if(R.dir == direction) + windowhere = TRUE + if(windowhere) + continue + var/obj/structure/window/reinforced/new_window = new /obj/structure/window/reinforced(loc) + new_window.dir = direction + new_window.update_nearby_tiles() + if(full && !locate(/obj/structure/window/full/reinforced) in loc) + var/obj/structure/window/reinforced/new_fullwindow = new /obj/structure/window/full/reinforced(loc) + new_fullwindow.update_nearby_tiles() + qdel(src) + +/obj/effect/spawner/window/northend + dirs = list(NORTH) + +/obj/effect/spawner/window/westend + dirs = list(WEST) + +/obj/effect/spawner/window/southend + dirs = list(SOUTH) + +/obj/effect/spawner/window/eastend + dirs = list(EAST) + +/obj/effect/spawner/window/horizontal + dirs = list(NORTH,SOUTH) + +/obj/effect/spawner/window/vertical + dirs = list(WEST,EAST) + +/obj/effect/spawner/window/nwcorner + dirs = list(NORTH,WEST) + +/obj/effect/spawner/window/swcorner + dirs = list(SOUTH,WEST) + +/obj/effect/spawner/window/secorner + dirs = list(SOUTH,EAST) + +/obj/effect/spawner/window/necorner + dirs = list(NORTH,EAST) + +/obj/effect/spawner/window/northcap + dirs = list(NORTH,EAST,WEST) + +/obj/effect/spawner/window/westcap + dirs = list(WEST,NORTH,SOUTH) + +/obj/effect/spawner/window/southcap + dirs = list(SOUTH,EAST,WEST) + +/obj/effect/spawner/window/eastcap + dirs = list(EAST,NORTH,SOUTH) + +/obj/effect/spawner/window/full + full = TRUE + +/obj/effect/spawner/window/full/northend + dirs = list(NORTH) + +/obj/effect/spawner/window/full/westend + dirs = list(WEST) + +/obj/effect/spawner/window/full/southend + dirs = list(SOUTH) + +/obj/effect/spawner/window/full/eastend + dirs = list(EAST) + +/obj/effect/spawner/window/full/horizontal + dirs = list(NORTH,SOUTH) + +/obj/effect/spawner/window/full/vertical + dirs = list(WEST,EAST) + +/obj/effect/spawner/window/full/nwcorner + dirs = list(NORTH,WEST) + +/obj/effect/spawner/window/full/swcorner + dirs = list(SOUTH,WEST) + +/obj/effect/spawner/window/full/secorner + dirs = list(SOUTH,EAST) + +/obj/effect/spawner/window/full/necorner + dirs = list(NORTH,EAST) + +/obj/effect/spawner/window/full/northcap + dirs = list(NORTH,EAST,WEST) + +/obj/effect/spawner/window/full/westcap + dirs = list(WEST,NORTH,SOUTH) + +/obj/effect/spawner/window/full/southcap + dirs = list(SOUTH,EAST,WEST) + +/obj/effect/spawner/window/full/eastcap + dirs = list(EAST,NORTH,SOUTH) \ No newline at end of file diff --git a/vgstation13.dme b/vgstation13.dme index 0272a9e47f8..1e4ac58f796 100644 --- a/vgstation13.dme +++ b/vgstation13.dme @@ -2267,6 +2267,7 @@ #include "code\modules\RCD\schematics\engi.dm" #include "code\modules\RCD\schematics\pipe.dm" #include "code\modules\RCD\schematics\service.dm" +#include "code\modules\RCD\schematics\rcd_window_spawner.dm" #include "code\modules\RCD\schematics\test.dm" #include "code\modules\RCD\schematics\tile.dm" #include "code\modules\reagents\Chemistry-Colours.dm"