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
+9 -22
View File
@@ -1,6 +1,6 @@
/obj/machinery/power/emitter
name = "emitter"
desc = "A heavy-duty industrial laser, often used in containment fields and power generation.\n<span class='notice'>Alt-click to rotate it clockwise.</span>"
desc = "A heavy-duty industrial laser, often used in containment fields and power generation."
icon = 'icons/obj/singularity.dmi'
icon_state = "emitter"
@@ -75,28 +75,15 @@
power_usage -= 50 * M.rating
active_power_usage = power_usage
/obj/machinery/power/emitter/verb/rotate()
set name = "Rotate"
set category = "Object"
set src in oview(1)
/obj/machinery/power/emitter/ComponentInitialize()
. = ..()
AddComponent(/datum/component/simple_rotation,ROTATION_ALTCLICK | ROTATION_FLIP ,null,CALLBACK(src, .proc/can_be_rotated))
if(usr.stat || !usr.canmove || usr.restrained())
return
if (src.anchored)
to_chat(usr, "<span class='warning'>It is fastened to the floor!</span>")
return 0
src.setDir(turn(src.dir, 270))
return 1
/obj/machinery/power/emitter/AltClick(mob/user)
..()
if(user.incapacitated())
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
return
if(!in_range(src, user))
return
else
rotate()
/obj/machinery/power/emitter/proc/can_be_rotated(mob/user,rotation_type)
if (anchored)
to_chat(user, "<span class='warning'>It is fastened to the floor!</span>")
return FALSE
return TRUE
/obj/machinery/power/emitter/Destroy()
if(SSticker.IsRoundInProgress())
@@ -46,8 +46,6 @@
if(PA_CONSTRUCTION_PANEL_OPEN)
to_chat(user, "The panel is open.")
to_chat(user, "<span class='notice'>Alt-click to rotate it clockwise.</span>")
/obj/structure/particle_accelerator/Destroy()
construction_state = PA_CONSTRUCTION_UNSECURED
if(master)
@@ -56,41 +54,10 @@
master = null
return ..()
/obj/structure/particle_accelerator/verb/rotate()
set name = "Rotate Clockwise"
set category = "Object"
set src in oview(1)
/obj/structure/particle_accelerator/ComponentInitialize()
. = ..()
AddComponent(/datum/component/simple_rotation,ROTATION_ALTCLICK | ROTATION_CLOCKWISE | ROTATION_COUNTERCLOCKWISE | ROTATION_VERBS )
if(usr.stat || !usr.canmove || usr.restrained())
return
if (anchored)
to_chat(usr, "It is fastened to the floor!")
return 0
setDir(turn(dir, -90))
return 1
/obj/structure/particle_accelerator/AltClick(mob/user)
..()
if(user.incapacitated())
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
return
if(!in_range(src, user))
return
else
rotate()
/obj/structure/particle_accelerator/verb/rotateccw()
set name = "Rotate Counter Clockwise"
set category = "Object"
set src in oview(1)
if(usr.stat || !usr.canmove || usr.restrained())
return
if (anchored)
to_chat(usr, "It is fastened to the floor!")
return 0
setDir(turn(dir, -90))
return 1
/obj/structure/particle_accelerator/attackby(obj/item/W, mob/user, params)
var/did_something = FALSE