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

View File

@@ -0,0 +1,126 @@
#define ROTATION_ALTCLICK 1
#define ROTATION_WRENCH 2
#define ROTATION_VERBS 4
#define ROTATION_COUNTERCLOCKWISE 8
#define ROTATION_CLOCKWISE 16
#define ROTATION_FLIP 32
/datum/component/simple_rotation
var/datum/callback/can_user_rotate //Checks if user can rotate
var/datum/callback/can_be_rotated //Check if object can be rotated at all
var/datum/callback/after_rotation //Additional stuff to do after rotation
var/rotation_flags = NONE
var/default_rotation_direction = ROTATION_CLOCKWISE
/datum/component/simple_rotation/Initialize(rotation_flags = NONE ,can_user_rotate,can_be_rotated,after_rotation)
if(!ismovableatom(parent))
return COMPONENT_INCOMPATIBLE
//throw if no rotation direction is specificed ?
src.rotation_flags = rotation_flags
if(can_user_rotate)
src.can_user_rotate = can_user_rotate
else
src.can_user_rotate = CALLBACK(src,.proc/default_can_user_rotate)
if(can_be_rotated)
src.can_be_rotated = can_be_rotated
else
src.can_be_rotated = CALLBACK(src,.proc/default_can_be_rotated)
if(after_rotation)
src.after_rotation = after_rotation
else
src.after_rotation = CALLBACK(src,.proc/default_after_rotation)
//Try Clockwise,counter,flip in order
if(src.rotation_flags & ROTATION_FLIP)
default_rotation_direction = ROTATION_FLIP
if(src.rotation_flags & ROTATION_COUNTERCLOCKWISE)
default_rotation_direction = ROTATION_COUNTERCLOCKWISE
if(src.rotation_flags & ROTATION_CLOCKWISE)
default_rotation_direction = ROTATION_CLOCKWISE
if(src.rotation_flags & ROTATION_ALTCLICK)
RegisterSignal(COMSIG_CLICK_ALT, .proc/HandRot)
RegisterSignal(COMSIG_PARENT_EXAMINE, .proc/ExamineMessage)
if(src.rotation_flags & ROTATION_WRENCH)
RegisterSignal(COMSIG_PARENT_ATTACKBY, .proc/WrenchRot)
if(src.rotation_flags & ROTATION_VERBS)
var/atom/movable/AM = parent
if(src.rotation_flags & ROTATION_FLIP)
AM.verbs += /atom/movable/proc/simple_rotate_flip
if(src.rotation_flags & ROTATION_CLOCKWISE)
AM.verbs += /atom/movable/proc/simple_rotate_clockwise
if(src.rotation_flags & ROTATION_COUNTERCLOCKWISE)
AM.verbs += /atom/movable/proc/simple_rotate_counterclockwise
/datum/component/simple_rotation/proc/ExamineMessage(mob/user)
if(rotation_flags & ROTATION_ALTCLICK)
to_chat(user, "<span class='notice'>Alt-click to rotate it clockwise.</span>")
/datum/component/simple_rotation/proc/HandRot(mob/user, rotation)
if(!can_be_rotated.Invoke(user,default_rotation_direction) || !can_user_rotate.Invoke(user,default_rotation_direction))
return
BaseRot(user,default_rotation_direction)
/datum/component/simple_rotation/proc/WrenchRot(obj/item/I, mob/living/user)
if(!can_be_rotated.Invoke(user,default_rotation_direction) || !can_user_rotate.Invoke(user,default_rotation_direction))
return
if(istype(I,/obj/item/wrench))
BaseRot(user,default_rotation_direction)
return COMPONENT_NO_AFTERATTACK
/datum/component/simple_rotation/proc/BaseRot(mob/user,rotation_type)
var/atom/movable/AM = parent
var/rot_degree
switch(rotation_type)
if(ROTATION_CLOCKWISE)
rot_degree = -90
if(ROTATION_COUNTERCLOCKWISE)
rot_degree = 90
if(ROTATION_FLIP)
rot_degree = 180
AM.setDir(turn(AM.dir,rot_degree))
after_rotation.Invoke(user,rotation_type)
/datum/component/simple_rotation/proc/default_can_user_rotate(mob/living/user, rotation_type)
if(!istype(user) || !user.Adjacent(parent) || user.incapacitated())
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
return FALSE
return TRUE
/datum/component/simple_rotation/proc/default_can_be_rotated(mob/user, rotation_type)
var/atom/movable/AM = parent
return !AM.anchored
/datum/component/simple_rotation/proc/default_after_rotation(mob/user, rotation_type)
to_chat(user,"<span class='notice'>You [rotation_type == ROTATION_FLIP ? "flip" : "rotate"] [parent].</span>")
/atom/movable/proc/simple_rotate_clockwise()
set name = "Rotate Clockwise"
set category = "Object"
set src in oview(1)
GET_COMPONENT(rotcomp,/datum/component/simple_rotation)
if(rotcomp)
rotcomp.HandRot(usr,ROTATION_CLOCKWISE)
/atom/movable/proc/simple_rotate_counterclockwise()
set name = "Rotate Counter-Clockwise"
set category = "Object"
set src in oview(1)
GET_COMPONENT(rotcomp,/datum/component/simple_rotation)
if(rotcomp)
rotcomp.HandRot(usr,ROTATION_COUNTERCLOCKWISE)
/atom/movable/proc/simple_rotate_flip()
set name = "Flip"
set category = "Object"
set src in oview(1)
GET_COMPONENT(rotcomp,/datum/component/simple_rotation)
if(rotcomp)
rotcomp.HandRot(usr,ROTATION_FLIP)

View File

@@ -2,7 +2,7 @@ GLOBAL_LIST_EMPTY(doppler_arrays)
/obj/machinery/doppler_array
name = "tachyon-doppler array"
desc = "A highly precise directional sensor array which measures the release of quants from decaying tachyons. The doppler shifting of the mirror-image formed by these quants can reveal the size, location and temporal affects of energetic disturbances within a large radius ahead of the array.\n<span class='notice'>Alt-click to rotate it clockwise.</span>"
desc = "A highly precise directional sensor array which measures the release of quants from decaying tachyons. The doppler shifting of the mirror-image formed by these quants can reveal the size, location and temporal affects of energetic disturbances within a large radius ahead of the array.\n"
icon = 'icons/obj/machines/research.dmi'
icon_state = "tdoppler"
density = TRUE
@@ -15,6 +15,9 @@ GLOBAL_LIST_EMPTY(doppler_arrays)
. = ..()
GLOB.doppler_arrays += src
/obj/machinery/doppler_array/ComponentInitialize()
AddComponent(/datum/component/simple_rotation,ROTATION_ALTCLICK | ROTATION_CLOCKWISE,null,null,CALLBACK(src,.proc/rot_message))
/obj/machinery/doppler_array/Destroy()
GLOB.doppler_arrays -= src
return ..()
@@ -40,28 +43,10 @@ GLOBAL_LIST_EMPTY(doppler_arrays)
else
return ..()
/obj/machinery/doppler_array/verb/rotate()
set name = "Rotate Tachyon-doppler Dish"
set category = "Object"
set src in oview(1)
if(!usr || !isturf(usr.loc))
return
if(usr.stat || usr.restrained() || !usr.canmove)
return
setDir(turn(dir, -90))
to_chat(usr, "<span class='notice'>You adjust [src]'s dish to face to the [dir2text(dir)].</span>")
/obj/machinery/doppler_array/proc/rot_message(mob/user)
to_chat(user, "<span class='notice'>You adjust [src]'s dish to face to the [dir2text(dir)].</span>")
playsound(src, 'sound/items/screwdriver2.ogg', 50, 1)
/obj/machinery/doppler_array/AltClick(mob/living/user)
if(!istype(user) || 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/doppler_array/proc/sense_explosion(turf/epicenter,devastation_range,heavy_impact_range,light_impact_range,
took,orig_dev_range,orig_heavy_range,orig_light_range)
if(stat & NOPOWER)

View File

@@ -36,9 +36,9 @@ Buildable meters
/obj/item/pipe/quaternary
RPD_type = PIPE_ONEDIR
/obj/item/pipe/examine(mob/user)
..()
to_chat(user, "<span class='notice'>Alt-click to rotate it clockwise.</span>")
/obj/item/pipe/ComponentInitialize()
//Flipping handled manually due to custom handling for trinary pipes
AddComponent(/datum/component/simple_rotation,ROTATION_ALTCLICK | ROTATION_CLOCKWISE ,null,null, CALLBACK(src, .proc/fixdir))
/obj/item/pipe/Initialize(mapload, _pipe_type, _dir, obj/machinery/atmospherics/make_from)
if(make_from)
@@ -84,19 +84,6 @@ Buildable meters
name = "[initial(fakeA.name)] fitting"
icon_state = initial(fakeA.pipe_state)
// rotate the pipe item clockwise
/obj/item/pipe/verb/rotate()
set category = "Object"
set name = "Rotate Pipe"
set src in view(1)
if ( usr.stat || usr.restrained() || !usr.canmove )
return
setDir(turn(dir, -90))
fixdir()
/obj/item/pipe/verb/flip()
set category = "Object"
set name = "Flip Pipe"
@@ -115,16 +102,6 @@ Buildable meters
setDir(turn(dir, flipped ? 45 : -45))
flipped = !flipped
/obj/item/pipe/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/item/pipe/Move()
var/old_dir = dir
..()
@@ -145,7 +122,8 @@ Buildable meters
setDir(turn(dir, 45))
/obj/item/pipe/attack_self(mob/user)
return rotate()
setDir(turn(dir,-90))
fixdir()
/obj/item/pipe/attackby(obj/item/W, mob/user, params)
if (!istype(W, /obj/item/wrench))

View File

@@ -18,15 +18,33 @@
..()
to_chat(user, "<span class='notice'>It's held together by a couple of <b>bolts</b>.</span>")
if(!has_buckled_mobs())
to_chat(user, "<span class='notice'>Drag your sprite to sit in it. Alt-click to rotate.</span>")
else
to_chat(user, "<span class='notice'>Alt-click to rotate.</span>")
to_chat(user, "<span class='notice'>Drag your sprite to sit in it.</span>")
/obj/structure/chair/Initialize()
. = ..()
if(!anchored) //why would you put these on the shuttle?
addtimer(CALLBACK(src, .proc/RemoveFromLatejoin), 0)
/obj/structure/chair/ComponentInitialize()
. = ..()
AddComponent(/datum/component/simple_rotation,ROTATION_ALTCLICK | ROTATION_CLOCKWISE, CALLBACK(src, .proc/can_user_rotate),CALLBACK(src, .proc/can_be_rotated),null)
/obj/structure/chair/proc/can_be_rotated(mob/user)
return TRUE
/obj/structure/chair/proc/can_user_rotate(mob/user)
var/mob/living/L = user
if(istype(L))
if(!user.Adjacent(src) || user.incapacitated())
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
return FALSE
else
return TRUE
else if(isobserver(user) && CONFIG_GET(flag/ghost_interaction))
return TRUE
return FALSE
/obj/structure/chair/Destroy()
RemoveFromLatejoin()
return ..()
@@ -72,10 +90,10 @@
return ..()
/obj/structure/chair/attack_tk(mob/user)
if(!anchored || has_buckled_mobs())
if(!anchored || has_buckled_mobs() || !isturf(user.loc))
..()
else
rotate()
setDir(turn(dir,-90))
/obj/structure/chair/proc/handle_rotation(direction)
handle_layer()
@@ -98,37 +116,10 @@
. = ..()
handle_layer()
/obj/structure/chair/proc/spin()
setDir(turn(dir, -90))
/obj/structure/chair/setDir(newdir)
..()
handle_rotation(newdir)
/obj/structure/chair/verb/rotate()
set name = "Rotate Chair"
set category = "Object"
set src in oview(1)
if(CONFIG_GET(flag/ghost_interaction))
spin()
else
if(!usr || !isturf(usr.loc))
return
if(usr.stat || usr.restrained())
return
spin()
/obj/structure/chair/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()
// Chair types
/obj/structure/chair/wood
icon_state = "wooden_chair"
@@ -375,7 +366,7 @@
. = ..()
/obj/structure/chair/brass/process()
spin()
setDir(turn(dir,-90))
playsound(src, 'sound/effects/servostep.ogg', 50, FALSE)
/obj/structure/chair/brass/ratvar_act()

View File

@@ -1,6 +1,6 @@
/obj/structure/chair/e_chair
name = "electric chair"
desc = "Looks absolutely SHOCKING!\n<span class='notice'>Alt-click to rotate it clockwise.</span>"
desc = "Looks absolutely SHOCKING!"
icon_state = "echair0"
var/obj/item/assembly/shock_kit/part = null
var/last_time = 1

View File

@@ -14,54 +14,21 @@
var/flipped_build_type
var/base_icon
/obj/structure/c_transit_tube/examine(mob/user)
..()
to_chat(user, "<span class='notice'>Alt-click to rotate it clockwise.</span>")
/obj/structure/c_transit_tube/proc/tube_rotate()
setDir(turn(dir, -90))
/obj/structure/c_transit_tube/ComponentInitialize()
. = ..()
AddComponent(/datum/component/simple_rotation,ROTATION_ALTCLICK | ROTATION_CLOCKWISE | ROTATION_FLIP | ROTATION_VERBS,null,null,CALLBACK(src,.proc/after_rot))
/obj/structure/c_transit_tube/proc/tube_flip()
if(flipped_build_type)
/obj/structure/c_transit_tube/proc/after_rot(mob/user,rotation_type)
if(flipped_build_type && rotation_type == ROTATION_FLIP)
setDir(turn(dir,-180)) //Turn back we don't actually flip
flipped = !flipped
var/cur_flip = initial(flipped) ? !flipped : flipped
if(cur_flip)
build_type = flipped_build_type
else
build_type = initial(build_type)
icon_state = "[base_icon][flipped]"
else
setDir(turn(dir, 180))
// disposals-style flip and rotate verbs
/obj/structure/c_transit_tube/verb/rotate()
set name = "Rotate Tube"
set category = "Object"
set src in view(1)
if(usr.incapacitated())
return
tube_rotate()
/obj/structure/c_transit_tube/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
tube_rotate()
/obj/structure/c_transit_tube/verb/flip()
set name = "Flip"
set category = "Object"
set src in view(1)
if(usr.incapacitated())
return
tube_flip()
icon_state = "[base_icon][flipped]"
/obj/structure/c_transit_tube/attackby(obj/item/I, mob/user, params)
if(istype(I, /obj/item/wrench))

View File

@@ -29,10 +29,6 @@
var/state = "01" //How far the door assembly has progressed
CanAtmosPass = ATMOS_PASS_PROC
/obj/structure/windoor_assembly/examine(mob/user)
..()
to_chat(user, "<span class='notice'>Alt-click to rotate it clockwise.</span>")
/obj/structure/windoor_assembly/New(loc, set_dir)
..()
if(set_dir)
@@ -319,38 +315,25 @@
update_icon()
//Rotates the windoor assembly clockwise
/obj/structure/windoor_assembly/verb/revrotate()
set name = "Rotate Windoor Assembly"
set category = "Object"
set src in oview(1)
if(usr.stat || !usr.canmove || usr.restrained())
return
if(anchored)
to_chat(usr, "<span class='warning'>[src] cannot be rotated while it is fastened to the floor!</span>")
return FALSE
var/target_dir = turn(dir, 270)
/obj/structure/windoor_assembly/ComponentInitialize()
. = ..()
AddComponent(/datum/component/simple_rotation,ROTATION_ALTCLICK | ROTATION_CLOCKWISE | ROTATION_COUNTERCLOCKWISE | ROTATION_VERBS,null,CALLBACK(src, .proc/can_be_rotated),CALLBACK(src,.proc/after_rotation))
/obj/structure/windoor_assembly/proc/can_be_rotated(mob/user,rotation_type)
if(anchored)
to_chat(user, "<span class='warning'>[src] cannot be rotated while it is fastened to the floor!</span>")
return FALSE
var/target_dir = turn(dir, rotation_type == ROTATION_CLOCKWISE ? -90 : 90)
if(!valid_window_location(loc, target_dir))
to_chat(usr, "<span class='warning'>[src] cannot be rotated in that direction!</span>")
to_chat(user, "<span class='warning'>[src] cannot be rotated in that direction!</span>")
return FALSE
setDir(target_dir)
ini_dir = dir
update_icon()
return TRUE
/obj/structure/windoor_assembly/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
revrotate()
/obj/structure/windoor_assembly/proc/after_rotation(mob/user)
ini_dir = dir
update_icon()
//Flips the windoor assembly, determines whather the door opens to the left or the right
/obj/structure/windoor_assembly/verb/flip()

View File

@@ -26,6 +26,7 @@
var/real_explosion_block //ignore this, just use explosion_block
var/breaksound = "shatter"
var/hitsound = 'sound/effects/Glasshit.ogg'
var/rad_insulation = RAD_VERY_LIGHT_INSULATION
/obj/structure/window/examine(mob/user)
..()
@@ -44,9 +45,6 @@
else
to_chat(user, "<span class='notice'>The window is <i>unscrewed</i> from the floor, and could be deconstructed by <b>wrenching</b>.</span>")
if(!anchored)
to_chat(user, "<span class='notice'>Alt-click to rotate it clockwise.</span>")
/obj/structure/window/Initialize(mapload, direct)
. = ..()
if(direct)
@@ -80,7 +78,8 @@
/obj/structure/window/ComponentInitialize()
. = ..()
AddComponent(/datum/component/rad_insulation, RAD_VERY_LIGHT_INSULATION, TRUE, FALSE)
AddComponent(/datum/component/rad_insulation, rad_insulation, TRUE, FALSE)
AddComponent(/datum/component/simple_rotation,ROTATION_ALTCLICK | ROTATION_CLOCKWISE | ROTATION_COUNTERCLOCKWISE | ROTATION_VERBS ,null,CALLBACK(src, .proc/can_be_rotated),CALLBACK(src,.proc/after_rotation))
/obj/structure/window/rcd_vals(mob/user, obj/item/construction/rcd/the_rcd)
switch(the_rcd.mode)
@@ -291,62 +290,23 @@
qdel(src)
update_nearby_icons()
/obj/structure/window/verb/rotate()
set name = "Rotate Window Counter-Clockwise"
set category = "Object"
set src in oview(1)
if(usr.stat || !usr.canmove || usr.restrained())
return
/obj/structure/window/proc/can_be_rotated(mob/user,rotation_type)
if(anchored)
to_chat(usr, "<span class='warning'>[src] cannot be rotated while it is fastened to the floor!</span>")
to_chat(user, "<span class='warning'>[src] cannot be rotated while it is fastened to the floor!</span>")
return FALSE
var/target_dir = turn(dir, 90)
var/target_dir = turn(dir, rotation_type == ROTATION_CLOCKWISE ? -90 : 90)
if(!valid_window_location(loc, target_dir))
to_chat(usr, "<span class='warning'>[src] cannot be rotated in that direction!</span>")
to_chat(user, "<span class='warning'>[src] cannot be rotated in that direction!</span>")
return FALSE
return TRUE
setDir(target_dir)
/obj/structure/window/proc/after_rotation(mob/user,rotation_type)
air_update_turf(1)
ini_dir = dir
add_fingerprint(usr)
return TRUE
/obj/structure/window/verb/revrotate()
set name = "Rotate Window Clockwise"
set category = "Object"
set src in oview(1)
if(usr.stat || !usr.canmove || usr.restrained())
return
if(anchored)
to_chat(usr, "<span class='warning'>[src] cannot be rotated while it is fastened to the floor!</span>")
return FALSE
var/target_dir = turn(dir, 270)
if(!valid_window_location(loc, target_dir))
to_chat(usr, "<span class='warning'>[src] cannot be rotated in that direction!</span>")
return FALSE
setDir(target_dir)
ini_dir = dir
add_fingerprint(usr)
return TRUE
/obj/structure/window/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
revrotate()
add_fingerprint(user)
/obj/structure/window/Destroy()
density = FALSE
@@ -432,9 +392,7 @@
max_integrity = 50
explosion_block = 1
glass_type = /obj/item/stack/sheet/rglass
/obj/structure/window/reinforced/ComponentInitialize()
AddComponent(/datum/component/rad_insulation, RAD_HEAVY_INSULATION, TRUE, FALSE)
rad_insulation = RAD_HEAVY_INSULATION
/obj/structure/window/reinforced/spawner/east
dir = EAST
@@ -458,9 +416,7 @@
max_integrity = 150
explosion_block = 1
glass_type = /obj/item/stack/sheet/plasmaglass
/obj/structure/window/plasma/ComponentInitialize()
AddComponent(/datum/component/rad_insulation, RAD_NO_INSULATION, TRUE, FALSE)
rad_insulation = RAD_NO_INSULATION
/obj/structure/window/plasma/spawner/east
dir = EAST

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())

View File

@@ -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

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

View File

@@ -366,6 +366,7 @@
#include "code\datums\components\rad_insulation.dm"
#include "code\datums\components\radioactive.dm"
#include "code\datums\components\riding.dm"
#include "code\datums\components\rotation.dm"
#include "code\datums\components\signal_redirect.dm"
#include "code\datums\components\slippery.dm"
#include "code\datums\components\spooky.dm"