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,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()
@@ -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
@@ -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))
@@ -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()
+12 -56
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