Simple rotation component. (#34476)

I'm going to port other rotations to it when i don't feel lazy.
Closes #34064
This commit is contained in:
AnturK
2018-01-23 09:09:15 +01:00
committed by CitadelStationBot
parent 5e1ff26276
commit eb7974df7d
12 changed files with 225 additions and 315 deletions
+18 -49
View File
@@ -14,13 +14,8 @@
var/obj/pipe_type = /obj/structure/disposalpipe/segment
var/pipename
/obj/structure/disposalconstruct/examine(mob/user)
..()
to_chat(user, "<span class='notice'>Alt-click to rotate it clockwise.</span>")
/obj/structure/disposalconstruct/New(loc, _pipe_type, _dir = SOUTH, flip = FALSE, obj/make_from)
..()
/obj/structure/disposalconstruct/Initialize(loc, _pipe_type, _dir = SOUTH, flip = FALSE, obj/make_from)
. = ..()
if(make_from)
pipe_type = make_from.type
setDir(make_from.dir)
@@ -34,7 +29,8 @@
pipename = initial(pipe_type.name)
if(flip)
flip()
GET_COMPONENT(rotcomp,/datum/component/simple_rotation)
rotcomp.BaseRot(null,ROTATION_FLIP)
update_icon()
@@ -91,51 +87,24 @@
dpdir |= turn(dir, 180)
return dpdir
// flip and rotate verbs
/obj/structure/disposalconstruct/verb/rotate()
set name = "Rotate Pipe"
set category = "Object"
set src in view(1)
/obj/structure/disposalconstruct/ComponentInitialize()
. = ..()
AddComponent(/datum/component/simple_rotation,ROTATION_ALTCLICK | ROTATION_CLOCKWISE | ROTATION_FLIP | ROTATION_VERBS ,null,CALLBACK(src, .proc/can_be_rotated), CALLBACK(src, .proc/after_rot))
if(usr.incapacitated())
return
if(anchored)
to_chat(usr, "<span class='warning'>You must unfasten the pipe before rotating it!</span>")
return
setDir(turn(dir, -90))
/obj/structure/disposalconstruct/proc/after_rot(mob/user,rotation_type)
if(rotation_type == ROTATION_FLIP)
var/obj/structure/disposalpipe/temp = pipe_type
if(initial(temp.flip_type))
if(dir in GLOB.diagonals) // Fix RPD-induced diagonal turning
setDir(turn(dir, 45))
pipe_type = initial(temp.flip_type)
update_icon()
/obj/structure/disposalconstruct/AltClick(mob/user)
..()
if(!in_range(src, user))
return
else
rotate()
/obj/structure/disposalconstruct/verb/flip()
set name = "Flip Pipe"
set category = "Object"
set src in view(1)
if(usr.incapacitated())
return
/obj/structure/disposalconstruct/proc/can_be_rotated(mob/user,rotation_type)
if(anchored)
to_chat(usr, "<span class='warning'>You must unfasten the pipe before flipping it!</span>")
return
setDir(turn(dir, 180))
var/obj/structure/disposalpipe/temp = pipe_type
if(initial(temp.flip_type))
if(dir in GLOB.diagonals) // Fix RPD-induced diagonal turning
setDir(turn(dir, 45))
pipe_type = initial(temp.flip_type)
update_icon()
to_chat(user, "<span class='warning'>You must unfasten the pipe before rotating it!</span>")
return FALSE
return TRUE
// attackby item
// wrench: (un)anchor