[MIRROR] Rotation component refactor and improvements [MDB IGNORE] (#11304)

* Rotation component refactor and improvements

* Update code/modules/power/singularity/emitter.dm

* e

Co-authored-by: Tim <timothymtorres@gmail.com>
Co-authored-by: Tom <8881105+tf-4@users.noreply.github.com>
Co-authored-by: Gandalf <9026500+Gandalf2k15@users.noreply.github.com>
This commit is contained in:
SkyratBot
2022-02-08 01:38:20 +00:00
committed by GitHub
co-authored by Tim Tom Gandalf
parent e73aa07ddd
commit d682fbfbc8
33 changed files with 203 additions and 393 deletions
@@ -28,25 +28,11 @@
addtimer(CALLBACK(src, .proc/RemoveFromLatejoin), 0)
if(prob(0.2))
name = "tactical [name]"
MakeRotate()
/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.canUseTopic(src, BE_CLOSE, NO_DEXTERITY, FALSE, !iscyborg(user)))
return FALSE
else
return TRUE
else if(isobserver(user) && CONFIG_GET(flag/ghost_interaction))
return TRUE
return FALSE
///This proc adds the rotate component, overwrite this if you for some reason want to change some specific args.
/obj/structure/chair/proc/MakeRotate()
AddComponent(/datum/component/simple_rotation, ROTATION_IGNORE_ANCHORED|ROTATION_GHOSTS_ALLOWED)
/obj/structure/chair/Destroy()
RemoveFromLatejoin()
@@ -9,6 +9,10 @@
buildstackamount = 3
item_chair = null
///This proc adds the rotate component, overwrite this if you for some reason want to change some specific args.
/obj/structure/chair/pew/MakeRotate()
AddComponent(/datum/component/simple_rotation, ROTATION_REQUIRE_WRENCH|ROTATION_IGNORE_ANCHORED)
/obj/structure/chair/pew/left
name = "left wooden pew end"
icon_state = "pewend_left"
@@ -70,16 +74,3 @@
/obj/structure/chair/pew/right/post_unbuckle_mob()
. = ..()
update_rightpewarmrest()
/obj/structure/chair/pew/can_user_rotate(mob/user)
. = ..()
if(!.)
return
var/mob/living/living_user = user
if(!istype(living_user))
return
var/obj/item/tool = living_user.get_active_held_item()
if(!tool || tool.tool_behaviour != TOOL_WRENCH)
balloon_alert(user, "you need a wrench!")
return FALSE
+1 -16
View File
@@ -32,7 +32,7 @@
)
AddElement(/datum/element/connect_loc, loc_connections)
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))
AddComponent(/datum/component/simple_rotation, ROTATION_NEEDS_ROOM)
/obj/structure/railing/attackby(obj/item/I, mob/living/user, params)
..()
@@ -111,21 +111,6 @@
leaving.Bump(src)
return COMPONENT_ATOM_BLOCK_EXIT
/obj/structure/railing/proc/can_be_rotated(mob/user,rotation_type)
if(anchored)
to_chat(user, span_warning("[src] cannot be rotated while it is fastened to the floor!"))
return FALSE
var/target_dir = turn(dir, rotation_type == ROTATION_CLOCKWISE ? -90 : 90)
if(!valid_window_location(loc, target_dir, is_fulltile = FALSE)) //Expanded to include rails, as well!
to_chat(user, span_warning("[src] cannot be rotated in that direction!"))
return FALSE
return TRUE
/obj/structure/railing/proc/check_anchored(checked_anchored)
if(anchored == checked_anchored)
return TRUE
/obj/structure/railing/proc/after_rotation(mob/user,rotation_type)
add_fingerprint(user)
+1 -6
View File
@@ -211,12 +211,7 @@
/obj/structure/showerframe/Initialize(mapload)
. = ..()
AddComponent(/datum/component/simple_rotation, ROTATION_ALTCLICK | ROTATION_CLOCKWISE | ROTATION_COUNTERCLOCKWISE | ROTATION_VERBS, null, CALLBACK(src, .proc/can_be_rotated))
/obj/structure/showerframe/proc/can_be_rotated(mob/user, rotation_type)
if(anchored)
to_chat(user, span_warning("It is fastened to the floor!"))
return !anchored
AddComponent(/datum/component/simple_rotation)
/obj/effect/mist
name = "mist"
@@ -14,6 +14,10 @@
var/flipped_build_type
var/base_icon
/obj/structure/c_transit_tube/Initialize(mapload)
. = ..()
AddComponent(/datum/component/simple_rotation, AfterRotation = CALLBACK(src, .proc/AfterRotation))
/obj/structure/c_transit_tube/proc/can_wrench_in_loc(mob/user)
var/turf/source_turf = get_turf(loc)
var/existing_tubes = 0
@@ -24,13 +28,9 @@
return FALSE
return TRUE
/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/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
/obj/structure/c_transit_tube/proc/AfterRotation(mob/user, degrees)
if(flipped_build_type && degrees == ROTATION_FLIP)
setDir(turn(dir, degrees)) //Turn back we don't actually flip
flipped = !flipped
var/cur_flip = initial(flipped) ? !flipped : flipped
if(cur_flip)
+2 -7
View File
@@ -456,14 +456,9 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/urinal, 32)
anchored = FALSE
material_flags = MATERIAL_EFFECTS | MATERIAL_ADD_PREFIX | MATERIAL_COLOR | MATERIAL_AFFECT_STATISTICS
/obj/structure/sinkframe/ComponentInitialize()
/obj/structure/sinkframe/Initialize(mapload)
. = ..()
AddComponent(/datum/component/simple_rotation, ROTATION_ALTCLICK | ROTATION_CLOCKWISE | ROTATION_COUNTERCLOCKWISE | ROTATION_VERBS, null, CALLBACK(src, .proc/can_be_rotated))
/obj/structure/sinkframe/proc/can_be_rotated(mob/user, rotation_type)
if(anchored)
to_chat(user, span_warning("It is fastened to the floor!"))
return !anchored
AddComponent(/datum/component/simple_rotation)
/obj/structure/sinkframe/attackby(obj/item/I, mob/living/user, params)
if(istype(I, /obj/item/stock_parts/water_recycler))
@@ -40,6 +40,7 @@
)
AddElement(/datum/element/connect_loc, loc_connections)
AddComponent(/datum/component/simple_rotation, ROTATION_NEEDS_ROOM)
/obj/structure/windoor_assembly/Destroy()
set_density(FALSE)
@@ -321,27 +322,6 @@
//Update to reflect changes(if applicable)
update_appearance()
/obj/structure/windoor_assembly/ComponentInitialize()
. = ..()
var/static/rotation_flags = ROTATION_ALTCLICK | ROTATION_CLOCKWISE | ROTATION_COUNTERCLOCKWISE | ROTATION_VERBS
AddComponent(/datum/component/simple_rotation, rotation_flags, can_be_rotated=CALLBACK(src, .proc/can_be_rotated), after_rotation=CALLBACK(src,.proc/after_rotation))
/obj/structure/windoor_assembly/proc/can_be_rotated(mob/user,rotation_type)
if(anchored)
to_chat(user, span_warning("[src] cannot be rotated while it is fastened to the floor!"))
return FALSE
var/target_dir = turn(dir, rotation_type == ROTATION_CLOCKWISE ? -90 : 90)
if(!valid_window_location(loc, target_dir, is_fulltile = FALSE))
to_chat(user, span_warning("[src] cannot be rotated in that direction!"))
return FALSE
return TRUE
/obj/structure/windoor_assembly/proc/after_rotation(mob/user)
update_appearance()
//Flips the windoor assembly, determines whather the door opens to the left or the right
/obj/structure/windoor_assembly/verb/flip()
set name = "Flip Windoor Assembly"
+2 -18
View File
@@ -70,6 +70,7 @@
flags_1 |= ALLOW_DARK_PAINTS_1
RegisterSignal(src, COMSIG_OBJ_PAINTED, .proc/on_painted)
AddElement(/datum/element/atmos_sensitive, mapload)
AddComponent(/datum/component/simple_rotation, ROTATION_NEEDS_ROOM, AfterRotation = CALLBACK(src,.proc/AfterRotation))
var/static/list/loc_connections = list(
COMSIG_ATOM_EXIT = .proc/on_exit,
@@ -78,10 +79,6 @@
if (flags_1 & ON_BORDER_1)
AddElement(/datum/element/connect_loc, loc_connections)
/obj/structure/window/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/window/rcd_vals(mob/user, obj/item/construction/rcd/the_rcd)
switch(the_rcd.mode)
if(RCD_DECONSTRUCT)
@@ -295,21 +292,8 @@
if (fulltile)
. += new /obj/item/shard(location)
/obj/structure/window/proc/can_be_rotated(mob/user,rotation_type)
if(anchored)
to_chat(user, span_warning("[src] cannot be rotated while it is fastened to the floor!"))
return FALSE
var/target_dir = turn(dir, rotation_type == ROTATION_CLOCKWISE ? -90 : 90)
if(!valid_window_location(loc, target_dir, is_fulltile = fulltile))
to_chat(user, span_warning("[src] cannot be rotated in that direction!"))
return FALSE
return TRUE
/obj/structure/window/proc/after_rotation(mob/user,rotation_type)
/obj/structure/window/proc/AfterRotation(mob/user, degrees)
air_update_turf(TRUE, FALSE)
add_fingerprint(user)
/obj/structure/window/proc/on_painted(obj/structure/window/source, is_dark_color)
SIGNAL_HANDLER