Genericises rotate() on objects. (#8430)

This commit is contained in:
Matt Atlas
2020-03-17 17:17:42 +01:00
committed by GitHub
parent d68a92f48b
commit 72c968eba6
24 changed files with 373 additions and 665 deletions
@@ -13,6 +13,7 @@ obj/structure/windoor_assembly
name = "windoor assembly"
icon = 'icons/obj/doors/windoor.dmi'
icon_state = "l_windoor_assembly01"
obj_flags = OBJ_FLAG_ROTATABLE
anchored = 0
density = 0
dir = NORTH
@@ -26,7 +27,7 @@ obj/structure/windoor_assembly
var/secure = "" //Whether or not this creates a secure windoor
var/state = "01" //How far the door assembly has progressed in terms of sprites
obj/structure/windoor_assembly/New(Loc, start_dir=NORTH, constructed=0)
/obj/structure/windoor_assembly/New(Loc, start_dir=NORTH, constructed=0)
..()
if(constructed)
state = "01"
@@ -261,62 +262,27 @@ obj/structure/windoor_assembly/Destroy()
//Update to reflect changes(if applicable)
update_icon()
/obj/structure/windoor_assembly/rotate(var/mob/user)
if(use_check_and_message(user))
return
//Rotates the windoor assembly clockwise
//These directions are fucked up, apparently dm rotates anticlockwise by default
/obj/structure/windoor_assembly/verb/rotate()
set name = "Rotate Windoor Clockwise"
set category = "Object"
set src in oview(1)
var/targetdir = turn(src.dir, 270)
if(anchored)
to_chat(user, SPAN_WARNING("\The [src] is bolted to the floor!"))
return FALSE
var/targetdir = turn(dir, 270)
for(var/obj/obstacle in get_turf(src))
if (obstacle == src)
continue
if((obstacle.flags & ON_BORDER) && obstacle.dir == targetdir)
to_chat(usr, span("danger", "You can't turn the windoor assembly that way, there's already something there!"))
to_chat(usr, SPAN_WARNING("You can't turn the windoor assembly that way, there's already something there!"))
return
if (src.anchored)
to_chat(usr, "It is fastened to the floor; therefore, you can't rotate it!")
return 0
if(src.state != "01")
update_nearby_tiles(need_rebuild=1) //Compel updates before
src.set_dir(targetdir)
if(src.state != "01")
update_nearby_tiles(need_rebuild=1)
update_icon()
return
//Rotates the windoor assembly anticlockwise
/obj/structure/windoor_assembly/verb/revrotate()
set name = "Rotate Windoor Anticlockwise"
set category = "Object"
set src in oview(1)
var/targetdir = turn(src.dir, 90)
for(var/obj/obstacle in get_turf(src))
if (obstacle == src)
continue
if((obstacle.flags & ON_BORDER) && obstacle.dir == targetdir)
to_chat(usr, span("danger", "You can't turn the windoor assembly that way, there's already something there!"))
return
if (src.anchored)
to_chat(usr, "It is fastened to the floor; therefore, you can't rotate it!")
return 0
if(src.state != "01")
update_nearby_tiles(need_rebuild=1) //Compel updates before
src.set_dir(targetdir)
set_dir(targetdir)
if(src.state != "01")
update_nearby_tiles(need_rebuild=1)