Merge pull request #8907 from Bram961/Window-placement

Window placement revert
This commit is contained in:
tigercat2000
2018-04-29 19:40:32 -07:00
committed by GitHub
+32 -50
View File
@@ -146,6 +146,7 @@
return ..()
/obj/structure/grille/proc/build_window(obj/item/stack/sheet/S, mob/user)
var/dir_to_set = NORTH
if(!istype(S) || !user)
return
if(broken)
@@ -160,59 +161,40 @@
if(!getRelativeDirection(src, user) && (user.loc != loc)) //essentially a cardinal direction adjacent or sharing same loc check
to_chat(user, "<span class='warning'>You can't reach.</span>")
return
if(/obj/structure/window/full in loc) //check for a full window already present (blocks the whole tile)
to_chat(user, "<span class='warning'>There is already a full window there.</span>")
return
var/selection = alert(user, "What type of window would you like to place?", "Window Construction", "One Direction", "Full", "Cancel")
if(selection == "Cancel")
return
if(selection == "Full")
if(S.get_amount() < 2)
to_chat(user, "<span class='warning'>You need at least two sheets of glass for that!</span>")
if(loc == user.loc)
dir_to_set = user.dir
else
if(x == user.x)
if(y > user.y)
dir_to_set = SOUTH
else
dir_to_set = NORTH
else if(y == user.y)
if(x > user.x)
dir_to_set = WEST
else
dir_to_set = EAST
for(var/obj/structure/window/WINDOW in loc)
if(WINDOW.dir == dir_to_set)
to_chat(user, "<span class='notice'>There is already a window facing this way there.</span>")
return
if(do_after(user, 20, target = src)) //glass doesn't have a toolspeed, so no multiplier
if(broken || !anchored || !src) //make sure the grille is still intact, anchored, and exists!
return
if(S.get_amount() < 2) //make sure we still have enough for this!
return
if(!getRelativeDirection(src, user) && (user.loc != loc)) //make sure we can still do this from our location
return
var/obj/structure/window/W = new S.full_window(get_turf(src))
S.use(2)
W.anchored = 0
W.state = 0
to_chat(user, "<span class='notice'>You place [W] on [src].</span>")
W.update_icon()
return
if(selection == "One Direction")
var/dir_selection = input("Which direction will this window face?", "Direction") as null|anything in list("north", "east", "south", "west")
if(!dir_selection)
to_chat(user, "<span class='notice'>You start placing the window...</span>")
if(do_after(user, 20, target = src))
if(!loc || !anchored) //Grille destroyed or unanchored while waiting
return
var/temp_dir = text2dir(dir_selection)
for(var/obj/structure/window/W in loc)
if(istype(W, /obj/structure/window/full)) //double checking in case a full window was created while selecting direction
to_chat(user, "<span class='warning'>There is already a full window there.</span>")
for(var/obj/structure/window/WINDOW in loc)
if(WINDOW.dir == dir_to_set)//checking this for a 2nd time to check if a window was made while we were waiting.
to_chat(user, "<span class='notice'>There is already a window facing this way there.</span>")
return
if(W.dir == temp_dir) //to avoid building a window on top of an existing window
to_chat(user, "<span class='warning'>There is already a window facing this direction there.</span>")
return
if(do_after(user, 20, target = src))
if(broken || !anchored || !src) //make sure the grille is still intact, anchored, and exists!
return
if(S.get_amount() < 1) //make sure we still have enough fir this!
to_chat(user, "<span class='warning'>You need at least one sheet of glass for that!</span>")
return
if(!getRelativeDirection(src, user) && (user.loc != loc)) //make sure we can still do this from our location
return
var/obj/structure/window/W = new S.created_window(get_turf(src))
S.use(1)
W.setDir(temp_dir)
W.ini_dir = temp_dir
W.anchored = 0
W.state = 0
to_chat(user, "<span class='notice'>You place [W] on [src].</span>")
W.update_icon()
return
var/obj/structure/window/W = new S.created_window(get_turf(src))
S.use(1)
W.setDir(dir_to_set)
W.ini_dir = dir_to_set
W.anchored = 0
W.state = 0
to_chat(user, "<span class='notice'>You place the [W] on [src].</span>")
W.update_icon()
return
/obj/structure/grille/attacked_by(obj/item/I, mob/living/user)
user.changeNext_move(CLICK_CD_MELEE)