diff --git a/code/datums/components/rotation.dm b/code/datums/components/rotation.dm deleted file mode 100644 index e57d23ffe50..00000000000 --- a/code/datums/components/rotation.dm +++ /dev/null @@ -1,146 +0,0 @@ -/datum/component/simple_rotation - /// Additional stuff to do after rotation - var/datum/callback/post_rotation - /// Rotation flags for special behavior - var/rotation_flags = NONE - -/** - * Adds the ability to rotate an object by Alt-click or using Right-click verbs. - * - * args: - * * rotation_flags (optional) Bitflags that determine behavior for rotation (defined at the top of this file) - * * post_rotation (optional) Callback proc that is used after the object is rotated (sound effects, balloon alerts, etc.) - **/ -/datum/component/simple_rotation/Initialize(rotation_flags = NONE, post_rotation) - if(!ismovable(parent)) - return COMPONENT_INCOMPATIBLE - - var/atom/movable/source = parent - source.flags_1 |= HAS_CONTEXTUAL_SCREENTIPS_1 - - src.rotation_flags = rotation_flags - src.post_rotation = post_rotation || CALLBACK(src, PROC_REF(default_post_rotation)) - -/datum/component/simple_rotation/RegisterWithParent() - RegisterSignal(parent, COMSIG_CLICK_ALT, PROC_REF(rotate_left)) - RegisterSignal(parent, COMSIG_CLICK_ALT_SECONDARY, PROC_REF(rotate_right)) - RegisterSignal(parent, COMSIG_ATOM_EXAMINE, PROC_REF(ExamineMessage)) - RegisterSignal(parent, COMSIG_ATOM_REQUESTING_CONTEXT_FROM_ITEM, PROC_REF(on_requesting_context_from_item)) - return ..() - -/datum/component/simple_rotation/PostTransfer(datum/new_parent) - //Because of the callbacks which we don't track cleanly we can't transfer this - //item cleanly, better to let the new of the new item create a new rotation datum - //instead (there's no real state worth transferring) - return COMPONENT_NOTRANSFER - -/datum/component/simple_rotation/UnregisterFromParent() - UnregisterSignal(parent, list( - COMSIG_CLICK_ALT, - COMSIG_CLICK_ALT_SECONDARY, - COMSIG_ATOM_EXAMINE, - COMSIG_ATOM_REQUESTING_CONTEXT_FROM_ITEM, - )) - return ..() - -/datum/component/simple_rotation/Destroy() - post_rotation = null - return ..() - -/datum/component/simple_rotation/proc/ExamineMessage(datum/source, mob/user, list/examine_list) - SIGNAL_HANDLER - if(rotation_flags & ROTATION_REQUIRE_WRENCH) - examine_list += span_notice("This requires a wrench to be rotated.") - -/datum/component/simple_rotation/proc/rotate_right(datum/source, mob/user) - SIGNAL_HANDLER - rotate(user, ROTATION_CLOCKWISE) - return CLICK_ACTION_SUCCESS - -/datum/component/simple_rotation/proc/rotate_left(datum/source, mob/user) - SIGNAL_HANDLER - rotate(user, ROTATION_COUNTERCLOCKWISE) - return CLICK_ACTION_SUCCESS - -/datum/component/simple_rotation/proc/rotate(mob/user, degrees) - if(QDELETED(user)) - CRASH("[src] is being rotated [user ? "with a qdeleting" : "without a"] user") - if(!istype(user)) - CRASH("[src] is being rotated without a user of the wrong type: [user.type]") - if(!isnum(degrees)) - CRASH("[src] is being rotated without providing the amount of degrees needed") - - if(!can_be_rotated(user, degrees) || !can_user_rotate(user, degrees)) - return - - var/obj/rotated_obj = parent - rotated_obj.setDir(turn(rotated_obj.dir, degrees)) - if(rotation_flags & ROTATION_REQUIRE_WRENCH) - playsound(rotated_obj, 'sound/items/tools/ratchet.ogg', 50, TRUE) - - post_rotation.Invoke(user, degrees) - -/datum/component/simple_rotation/proc/can_user_rotate(mob/user, degrees) - if(isliving(user) && user.can_perform_action(parent, NEED_DEXTERITY)) - return TRUE - if((rotation_flags & ROTATION_GHOSTS_ALLOWED) && isobserver(user) && CONFIG_GET(flag/ghost_interaction)) - return TRUE - return FALSE - -/datum/component/simple_rotation/proc/can_be_rotated(mob/user, degrees, silent=FALSE) - var/obj/rotated_obj = parent - if(!rotated_obj.Adjacent(user)) - silent = TRUE - - if(rotation_flags & ROTATION_REQUIRE_WRENCH) - if(!isliving(user)) - return FALSE - var/obj/item/tool = user.get_active_held_item() - if(!tool || tool.tool_behaviour != TOOL_WRENCH) - if(!silent) - rotated_obj.balloon_alert(user, "need a wrench!") - return FALSE - if(!(rotation_flags & ROTATION_IGNORE_ANCHORED) && rotated_obj.anchored) - if(istype(rotated_obj, /obj/structure/window) && !silent) - rotated_obj.balloon_alert(user, "need to unscrew!") - else if(!silent) - rotated_obj.balloon_alert(user, "need to unwrench!") - return FALSE - - if(rotation_flags & ROTATION_NEEDS_ROOM) - var/target_dir = turn(rotated_obj.dir, degrees) - var/obj/structure/window/rotated_window = rotated_obj - var/fulltile = istype(rotated_window) ? rotated_window.fulltile : FALSE - if(!valid_build_direction(rotated_obj.loc, target_dir, is_fulltile = fulltile)) - if(!silent) - rotated_obj.balloon_alert(user, "can't rotate in that direction!") - return FALSE - - if(rotation_flags & ROTATION_NEEDS_UNBLOCKED) - var/turf/rotate_turf = get_turf(rotated_obj) - if(rotate_turf.is_blocked_turf(source_atom = rotated_obj)) - if(!silent) - rotated_obj.balloon_alert(user, "rotation is blocked!") - return FALSE - return TRUE - -/datum/component/simple_rotation/proc/default_post_rotation(mob/user, degrees) - return - -// maybe we don't need the item context proc but instead the hand one? since we don't need to check held_item -/datum/component/simple_rotation/proc/on_requesting_context_from_item(atom/source, list/context, obj/item/held_item, mob/user) - SIGNAL_HANDLER - - var/rotation_screentip = FALSE - - if(can_be_rotated(user, ROTATION_CLOCKWISE, silent=TRUE)) - context[SCREENTIP_CONTEXT_ALT_LMB] = "Rotate left" - rotation_screentip = TRUE - if(can_be_rotated(user, ROTATION_COUNTERCLOCKWISE, silent=TRUE)) - context[SCREENTIP_CONTEXT_ALT_RMB] = "Rotate right" - rotation_screentip = TRUE - - if(rotation_screentip) - return CONTEXTUAL_SCREENTIP_SET - - return NONE diff --git a/code/datums/elements/rotation.dm b/code/datums/elements/rotation.dm new file mode 100644 index 00000000000..6d444165945 --- /dev/null +++ b/code/datums/elements/rotation.dm @@ -0,0 +1,136 @@ +/datum/element/simple_rotation + element_flags = ELEMENT_BESPOKE + argument_hash_start_idx = 2 + /// Rotation flags for special behavior + var/rotation_flags + +/** + * Adds the ability to rotate an object by Alt-click or using Right-click verbs. + * + * args: + * * rotation_flags (optional) Bitflags that determine behavior for rotation (defined at the top of this file) + * * post_rotation (optional) Callback proc that is used after the object is rotated (sound effects, balloon alerts, etc.) + **/ +/datum/element/simple_rotation/Attach(datum/target, rotation_flags = NONE) + . = ..() + if(!ismovable(target)) + return ELEMENT_INCOMPATIBLE + + var/atom/movable/source = target + source.flags_1 |= HAS_CONTEXTUAL_SCREENTIPS_1 + + src.rotation_flags = rotation_flags + + RegisterSignal(target, COMSIG_CLICK_ALT, PROC_REF(rotate_left)) + RegisterSignal(target, COMSIG_CLICK_ALT_SECONDARY, PROC_REF(rotate_right)) + RegisterSignal(target, COMSIG_ATOM_EXAMINE, PROC_REF(ExamineMessage)) + RegisterSignal(target, COMSIG_ATOM_REQUESTING_CONTEXT_FROM_ITEM, PROC_REF(on_requesting_context_from_item)) + +/datum/element/simple_rotation/Detach(datum/source, ...) + . = ..() + UnregisterSignal(source, list( + COMSIG_CLICK_ALT, + COMSIG_CLICK_ALT_SECONDARY, + COMSIG_ATOM_EXAMINE, + COMSIG_ATOM_REQUESTING_CONTEXT_FROM_ITEM, + )) + return ..() + +/datum/element/simple_rotation/proc/ExamineMessage(datum/source, mob/user, list/examine_list) + SIGNAL_HANDLER + if(rotation_flags & ROTATION_REQUIRE_WRENCH) + examine_list += span_notice("This requires a wrench to be rotated.") + +/datum/element/simple_rotation/proc/rotate_right(datum/source, mob/user) + SIGNAL_HANDLER + rotate(user, source, ROTATION_CLOCKWISE) + return CLICK_ACTION_SUCCESS + +/datum/element/simple_rotation/proc/rotate_left(datum/source, mob/user) + SIGNAL_HANDLER + rotate(user, source, ROTATION_COUNTERCLOCKWISE) + return CLICK_ACTION_SUCCESS + +/datum/element/simple_rotation/proc/rotate(mob/user, obj/object_to_rotate, degrees) + if(QDELETED(user)) + CRASH("[src] is being rotated [user ? "with a qdeleting" : "without a"] user") + if(!istype(user)) + CRASH("[src] is being rotated without a user of the wrong type: [user.type]") + if(!isnum(degrees)) + CRASH("[src] is being rotated without providing the amount of degrees needed") + + if(!can_be_rotated(user, object_to_rotate, degrees) || !can_user_rotate(user, object_to_rotate, degrees)) + return + + object_to_rotate.setDir(turn(object_to_rotate.dir, degrees)) + if(rotation_flags & ROTATION_REQUIRE_WRENCH) + playsound(object_to_rotate, 'sound/items/tools/ratchet.ogg', 50, TRUE) + + object_to_rotate.post_rotation(user, degrees) + +/datum/element/simple_rotation/proc/can_user_rotate(mob/user, obj/object_to_rotate, degrees) + if(isliving(user) && user.can_perform_action(object_to_rotate, NEED_DEXTERITY)) + return TRUE + if((rotation_flags & ROTATION_GHOSTS_ALLOWED) && isobserver(user) && CONFIG_GET(flag/ghost_interaction)) + return TRUE + return FALSE + +/datum/element/simple_rotation/proc/can_be_rotated(mob/user, obj/object_to_rotate, degrees, silent = FALSE) + if(!object_to_rotate.Adjacent(user)) + silent = TRUE + + if(rotation_flags & ROTATION_REQUIRE_WRENCH) + if(!isliving(user)) + return FALSE + var/obj/item/tool = user.get_active_held_item() + if(!tool || tool.tool_behaviour != TOOL_WRENCH) + if(!silent) + object_to_rotate.balloon_alert(user, "need a wrench!") + return FALSE + + if(!(rotation_flags & ROTATION_IGNORE_ANCHORED) && object_to_rotate.anchored) + if(istype(object_to_rotate, /obj/structure/window) && !silent) + object_to_rotate.balloon_alert(user, "need to unscrew!") + else if(!silent) + object_to_rotate.balloon_alert(user, "need to unwrench!") + return FALSE + + if(rotation_flags & ROTATION_NEEDS_ROOM) + var/target_dir = turn(object_to_rotate.dir, degrees) + var/obj/structure/window/window_to_rotate = object_to_rotate + var/fulltile = istype(window_to_rotate) ? window_to_rotate.fulltile : FALSE + if(!valid_build_direction(object_to_rotate.loc, target_dir, is_fulltile = fulltile)) + if(!silent) + object_to_rotate.balloon_alert(user, "can't rotate in that direction!") + return FALSE + + if(rotation_flags & ROTATION_NEEDS_UNBLOCKED) + var/turf/rotate_turf = get_turf(object_to_rotate) + if(rotate_turf.is_blocked_turf(source_atom = object_to_rotate)) + if(!silent) + object_to_rotate.balloon_alert(user, "rotation is blocked!") + return FALSE + + return TRUE + +// maybe we don't need the item context proc but instead the hand one? since we don't need to check held_item +/datum/element/simple_rotation/proc/on_requesting_context_from_item(atom/source, list/context, obj/item/held_item, mob/user) + SIGNAL_HANDLER + + var/rotation_screentip = FALSE + + if(can_be_rotated(user, source, ROTATION_CLOCKWISE, silent=TRUE)) + context[SCREENTIP_CONTEXT_ALT_LMB] = "Rotate left" + rotation_screentip = TRUE + if(can_be_rotated(user, source, ROTATION_COUNTERCLOCKWISE, silent=TRUE)) + context[SCREENTIP_CONTEXT_ALT_RMB] = "Rotate right" + rotation_screentip = TRUE + + if(rotation_screentip) + return CONTEXTUAL_SCREENTIP_SET + + return NONE + +/// Calld on the atom after it has been successfully rotated +/atom/movable/proc/post_rotation(mob/user, degrees) + return diff --git a/code/game/machinery/atmos_field_gen.dm b/code/game/machinery/atmos_field_gen.dm index 72a0c4a9d05..004728d3914 100644 --- a/code/game/machinery/atmos_field_gen.dm +++ b/code/game/machinery/atmos_field_gen.dm @@ -39,7 +39,7 @@ /obj/machinery/atmos_shield_gen/Initialize(mapload) . = ..() register_context() - AddComponent(/datum/component/simple_rotation) + AddElement(/datum/element/simple_rotation) set_wires(new /datum/wires/atmosshieldgen(src)) SSmachines.processing_early += src if(on) diff --git a/code/game/machinery/computer/buildandrepair.dm b/code/game/machinery/computer/buildandrepair.dm index 64a6495e3a1..d5f6b821006 100644 --- a/code/game/machinery/computer/buildandrepair.dm +++ b/code/game/machinery/computer/buildandrepair.dm @@ -8,7 +8,7 @@ /obj/structure/frame/computer/Initialize(mapload) . = ..() - AddComponent(/datum/component/simple_rotation) + AddElement(/datum/element/simple_rotation) register_context() /obj/structure/frame/computer/atom_deconstruct(disassembled = TRUE) diff --git a/code/game/machinery/doors/firedoor.dm b/code/game/machinery/doors/firedoor.dm index ede3166f261..b14a54f2977 100644 --- a/code/game/machinery/doors/firedoor.dm +++ b/code/game/machinery/doors/firedoor.dm @@ -980,7 +980,7 @@ /obj/structure/firelock_frame/border_only/Initialize(mapload) . = ..() - AddComponent(/datum/component/simple_rotation, ROTATION_NEEDS_ROOM) + AddElement(/datum/element/simple_rotation, ROTATION_NEEDS_ROOM) var/static/list/loc_connections = list( COMSIG_ATOM_EXIT = PROC_REF(on_exit), diff --git a/code/game/machinery/limbgrower.dm b/code/game/machinery/limbgrower.dm index f3d8e236c73..39564a41609 100644 --- a/code/game/machinery/limbgrower.dm +++ b/code/game/machinery/limbgrower.dm @@ -33,7 +33,7 @@ stored_research = GLOB.autounlock_techwebs[/datum/techweb/autounlocking/limbgrower] . = ..() AddComponent(/datum/component/plumbing/simple_demand) - AddComponent(/datum/component/simple_rotation) + AddElement(/datum/element/simple_rotation) register_context() /obj/machinery/limbgrower/add_context(atom/source, list/context, obj/item/held_item, mob/user) diff --git a/code/game/machinery/medipen_refiller.dm b/code/game/machinery/medipen_refiller.dm index 3f365ff3b1d..336554771f5 100644 --- a/code/game/machinery/medipen_refiller.dm +++ b/code/game/machinery/medipen_refiller.dm @@ -24,7 +24,7 @@ /obj/machinery/medipen_refiller/Initialize(mapload) . = ..() AddComponent(/datum/component/plumbing/simple_demand) - AddComponent(/datum/component/simple_rotation) + AddElement(/datum/element/simple_rotation) register_context() /obj/machinery/medipen_refiller/add_context(atom/source, list/context, obj/item/held_item, mob/user) diff --git a/code/game/machinery/pipe/construction.dm b/code/game/machinery/pipe/construction.dm index 010f374b8c4..172fbe8daa1 100644 --- a/code/game/machinery/pipe/construction.dm +++ b/code/game/machinery/pipe/construction.dm @@ -166,7 +166,7 @@ Buildable meters pixel_y += rand(-5, 5) //Flipping handled manually due to custom handling for trinary pipes - AddComponent(/datum/component/simple_rotation, ROTATION_NO_FLIPPING) + AddElement(/datum/element/simple_rotation, ROTATION_NO_FLIPPING) // Only 'normal' pipes if(type != /obj/item/pipe/quaternary) diff --git a/code/game/machinery/recycler.dm b/code/game/machinery/recycler.dm index fc17fbf1740..9ce642b513f 100644 --- a/code/game/machinery/recycler.dm +++ b/code/game/machinery/recycler.dm @@ -25,7 +25,7 @@ INFINITY, \ MATCONTAINER_NO_INSERT \ ) - AddComponent(/datum/component/simple_rotation) + AddElement(/datum/element/simple_rotation) AddComponent( /datum/component/butchering/recycler, \ speed = 0.1 SECONDS, \ diff --git a/code/game/machinery/scanner_gate.dm b/code/game/machinery/scanner_gate.dm index 49475d53f95..27271f3c4b1 100644 --- a/code/game/machinery/scanner_gate.dm +++ b/code/game/machinery/scanner_gate.dm @@ -87,7 +87,7 @@ COMSIG_ATOM_ENTERED = PROC_REF(on_entered), ) AddElement(/datum/element/connect_loc, loc_connections) - AddComponent(/datum/component/simple_rotation, ROTATION_IGNORE_ANCHORED|ROTATION_REQUIRE_WRENCH|ROTATION_NEEDS_UNBLOCKED) + AddElement(/datum/element/simple_rotation, ROTATION_IGNORE_ANCHORED|ROTATION_REQUIRE_WRENCH|ROTATION_NEEDS_UNBLOCKED) register_context() /obj/machinery/scanner_gate/Destroy(force) diff --git a/code/game/machinery/status_display.dm b/code/game/machinery/status_display.dm index 7c08a9cccb9..69a8555f3e1 100644 --- a/code/game/machinery/status_display.dm +++ b/code/game/machinery/status_display.dm @@ -1029,7 +1029,7 @@ GLOBAL_LIST_EMPTY_TYPED(greenscreen_displays, /obj/effect/abstract/greenscreen_d /obj/machinery/greenscreen_camera/Initialize(mapload) . = ..() - AddComponent(/datum/component/simple_rotation, ROTATION_IGNORE_ANCHORED) + AddElement(/datum/element/simple_rotation, ROTATION_IGNORE_ANCHORED) update_appearance(UPDATE_OVERLAYS) /obj/machinery/greenscreen_camera/Destroy() diff --git a/code/game/objects/structures/beds_chairs/chair.dm b/code/game/objects/structures/beds_chairs/chair.dm index 25cf1e0d8cd..637910ce9e4 100644 --- a/code/game/objects/structures/beds_chairs/chair.dm +++ b/code/game/objects/structures/beds_chairs/chair.dm @@ -71,7 +71,7 @@ ///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) + AddElement(/datum/element/simple_rotation, ROTATION_IGNORE_ANCHORED|ROTATION_GHOSTS_ALLOWED) /obj/structure/chair/Destroy() SSjob.latejoin_trackers -= src //These may be here due to the arrivals shuttle diff --git a/code/game/objects/structures/beds_chairs/pew.dm b/code/game/objects/structures/beds_chairs/pew.dm index f39be619852..22faec36e70 100644 --- a/code/game/objects/structures/beds_chairs/pew.dm +++ b/code/game/objects/structures/beds_chairs/pew.dm @@ -12,7 +12,7 @@ ///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) + AddElement(/datum/element/simple_rotation, ROTATION_REQUIRE_WRENCH|ROTATION_IGNORE_ANCHORED) /obj/structure/chair/pew/left name = "left wooden pew end" diff --git a/code/game/objects/structures/cannons/cannon.dm b/code/game/objects/structures/cannons/cannon.dm index a552ba1a392..383e3517209 100644 --- a/code/game/objects/structures/cannons/cannon.dm +++ b/code/game/objects/structures/cannons/cannon.dm @@ -22,7 +22,7 @@ /obj/structure/cannon/Initialize(mapload) . = ..() create_reagents(charge_size) - AddComponent(/datum/component/simple_rotation) + AddElement(/datum/element/simple_rotation) /obj/structure/cannon/examine(mob/user) . = ..() diff --git a/code/game/objects/structures/mannequin.dm b/code/game/objects/structures/mannequin.dm index bb45333cf5b..8fedeebb114 100644 --- a/code/game/objects/structures/mannequin.dm +++ b/code/game/objects/structures/mannequin.dm @@ -63,7 +63,7 @@ material = pick(MANNEQUIN_WOOD, MANNEQUIN_PLASTIC) icon_state = "mannequin_[material]_[body_type == FEMALE ? "female" : "male"]" AddElement(/datum/element/strippable, GLOB.strippable_mannequin_items) - AddComponent(/datum/component/simple_rotation, ROTATION_IGNORE_ANCHORED) + AddElement(/datum/element/simple_rotation, ROTATION_IGNORE_ANCHORED) AddComponent(/datum/component/marionette) update_appearance() diff --git a/code/game/objects/structures/railings.dm b/code/game/objects/structures/railings.dm index c32cd8221c9..7fa9a6ccb18 100644 --- a/code/game/objects/structures/railings.dm +++ b/code/game/objects/structures/railings.dm @@ -73,7 +73,7 @@ ) AddElement(/datum/element/contextual_screentip_tools, tool_behaviors) - AddComponent(/datum/component/simple_rotation, ROTATION_NEEDS_ROOM) + AddElement(/datum/element/simple_rotation, ROTATION_NEEDS_ROOM) /obj/structure/railing/examine(mob/user) . = ..() diff --git a/code/game/objects/structures/shower.dm b/code/game/objects/structures/shower.dm index 6c4d323744a..f3f33a99512 100644 --- a/code/game/objects/structures/shower.dm +++ b/code/game/objects/structures/shower.dm @@ -388,7 +388,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/shower, (-16)) /obj/structure/showerframe/Initialize(mapload) . = ..() - AddComponent(/datum/component/simple_rotation) + AddElement(/datum/element/simple_rotation) /obj/structure/showerframe/attackby(obj/item/tool, mob/living/user, list/modifiers, list/attack_modifiers) if(istype(tool, /obj/item/stock_parts/water_recycler)) diff --git a/code/game/objects/structures/stairs.dm b/code/game/objects/structures/stairs.dm index cddff131c84..8d7e1fc84e1 100644 --- a/code/game/objects/structures/stairs.dm +++ b/code/game/objects/structures/stairs.dm @@ -340,7 +340,7 @@ /obj/structure/stairs_frame/Initialize(mapload) . = ..() - AddComponent(/datum/component/simple_rotation) + AddElement(/datum/element/simple_rotation) /obj/structure/stairs_frame/examine(mob/living/carbon/human/user) . = ..() diff --git a/code/game/objects/structures/steps.dm b/code/game/objects/structures/steps.dm index 9163e57083a..70eee9cb3d7 100644 --- a/code/game/objects/structures/steps.dm +++ b/code/game/objects/structures/steps.dm @@ -17,7 +17,7 @@ AddElement(/datum/element/connect_loc, loc_connections) AddComponent(/datum/component/climb_walkable) - AddComponent(/datum/component/simple_rotation) + AddElement(/datum/element/simple_rotation) register_context() /obj/structure/steps/add_context(atom/source, list/context, obj/item/held_item, mob/user) diff --git a/code/game/objects/structures/toiletbong.dm b/code/game/objects/structures/toiletbong.dm index 269ec6a90d6..664cf9a0010 100644 --- a/code/game/objects/structures/toiletbong.dm +++ b/code/game/objects/structures/toiletbong.dm @@ -12,7 +12,7 @@ /obj/structure/toiletbong/Initialize(mapload) . = ..() - AddComponent(/datum/component/simple_rotation, post_rotation = CALLBACK(src, PROC_REF(post_rotation))) + AddElement(/datum/element/simple_rotation) create_storage(storage_type = /datum/storage/toiletbong) weed_overlay = mutable_appearance('icons/obj/watercloset.dmi', "[base_icon_state]_overlay") @@ -83,7 +83,7 @@ return ITEM_INTERACT_SUCCESS ///Called in the simple rotation's post_rotation callback, playing a sound cue to players. -/obj/structure/toiletbong/proc/post_rotation(mob/user, degrees) +/obj/structure/toiletbong/post_rotation(mob/user, degrees) playsound(src, 'sound/items/deconstruct.ogg', 50) /obj/structure/toiletbong/crowbar_act(mob/living/user, obj/item/tool) diff --git a/code/game/objects/structures/transit_tubes/transit_tube_construction.dm b/code/game/objects/structures/transit_tubes/transit_tube_construction.dm index 420e39f627d..199345a5d6c 100644 --- a/code/game/objects/structures/transit_tubes/transit_tube_construction.dm +++ b/code/game/objects/structures/transit_tubes/transit_tube_construction.dm @@ -15,7 +15,7 @@ /obj/structure/c_transit_tube/Initialize(mapload) . = ..() - AddComponent(/datum/component/simple_rotation, post_rotation = CALLBACK(src, PROC_REF(post_rotation))) + AddElement(/datum/element/simple_rotation) /obj/structure/c_transit_tube/proc/can_wrench_in_loc(mob/user) var/turf/source_turf = get_turf(loc) @@ -27,7 +27,7 @@ return FALSE return TRUE -/obj/structure/c_transit_tube/proc/post_rotation(mob/user, degrees) +/obj/structure/c_transit_tube/post_rotation(mob/user, degrees) if(flipped_build_type && degrees == ROTATION_FLIP) setDir(turn(dir, degrees)) //Turn back we don't actually flip flipped = !flipped diff --git a/code/game/objects/structures/water_structures/sink.dm b/code/game/objects/structures/water_structures/sink.dm index bb79846bb22..6504a8d547f 100644 --- a/code/game/objects/structures/water_structures/sink.dm +++ b/code/game/objects/structures/water_structures/sink.dm @@ -256,7 +256,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/sink/kitchen, (-16)) /obj/structure/sinkframe/Initialize(mapload) . = ..() - AddComponent(/datum/component/simple_rotation) + AddElement(/datum/element/simple_rotation) /obj/structure/sinkframe/attackby(obj/item/tool, mob/living/user, list/modifiers, list/attack_modifiers) if(istype(tool, /obj/item/stock_parts/water_recycler)) diff --git a/code/game/objects/structures/windoor_assembly.dm b/code/game/objects/structures/windoor_assembly.dm index 9842e29a7ac..9107d6180c0 100644 --- a/code/game/objects/structures/windoor_assembly.dm +++ b/code/game/objects/structures/windoor_assembly.dm @@ -47,7 +47,7 @@ ) AddElement(/datum/element/connect_loc, loc_connections) - AddComponent(/datum/component/simple_rotation, ROTATION_NEEDS_ROOM) + AddElement(/datum/element/simple_rotation, ROTATION_NEEDS_ROOM) /obj/structure/windoor_assembly/Destroy() set_density(FALSE) diff --git a/code/game/objects/structures/window.dm b/code/game/objects/structures/window.dm index eaff88d518a..5cff79f59c3 100644 --- a/code/game/objects/structures/window.dm +++ b/code/game/objects/structures/window.dm @@ -69,7 +69,7 @@ flags_1 |= ALLOW_DARK_PAINTS_1 RegisterSignal(src, COMSIG_OBJ_PAINTED, PROC_REF(on_painted)) AddElement(/datum/element/atmos_sensitive, mapload) - AddComponent(/datum/component/simple_rotation, ROTATION_NEEDS_ROOM, post_rotation = CALLBACK(src, PROC_REF(post_rotation))) + AddElement(/datum/element/simple_rotation, ROTATION_NEEDS_ROOM) var/static/list/loc_connections = list( COMSIG_ATOM_EXIT = PROC_REF(on_exit), @@ -360,7 +360,7 @@ dropped_debris += new /obj/item/stack/rods(location, (fulltile ? 2 : 1)) return dropped_debris -/obj/structure/window/proc/post_rotation(mob/user, degrees) +/obj/structure/window/post_rotation(mob/user, degrees) air_update_turf(TRUE, FALSE) /obj/structure/window/proc/on_painted(obj/structure/window/source, mob/user, obj/item/toy/crayon/spraycan/spraycan, is_dark_color) diff --git a/code/game/shuttle_engines.dm b/code/game/shuttle_engines.dm index feb8f6c3dce..d8af0f533fb 100644 --- a/code/game/shuttle_engines.dm +++ b/code/game/shuttle_engines.dm @@ -37,7 +37,7 @@ /obj/machinery/power/shuttle_engine/Initialize(mapload) . = ..() - AddComponent(/datum/component/simple_rotation) + AddElement(/datum/element/simple_rotation) register_context() if(!mapload) engine_state = ENGINE_UNWRENCHED diff --git a/code/modules/art/statues.dm b/code/modules/art/statues.dm index 7cfb01d1da2..7e4174ebcfb 100644 --- a/code/modules/art/statues.dm +++ b/code/modules/art/statues.dm @@ -27,7 +27,7 @@ . = ..() AddElement(art_type, impressiveness) AddElement(/datum/element/beauty, impressiveness * 75) - AddComponent(/datum/component/simple_rotation) + AddElement(/datum/element/simple_rotation) AddComponent(/datum/component/marionette) /obj/structure/statue/wrench_act(mob/living/user, obj/item/tool) diff --git a/code/modules/assembly/holder.dm b/code/modules/assembly/holder.dm index f4ee56221c1..74f2f748f1b 100644 --- a/code/modules/assembly/holder.dm +++ b/code/modules/assembly/holder.dm @@ -15,7 +15,7 @@ /obj/item/assembly_holder/Initialize(mapload) . = ..() - AddComponent(/datum/component/simple_rotation) + AddElement(/datum/element/simple_rotation) /obj/item/assembly_holder/Destroy() QDEL_LAZYLIST(assemblies) diff --git a/code/modules/assembly/infrared.dm b/code/modules/assembly/infrared.dm index f0e9b5136ee..e48ae62b576 100644 --- a/code/modules/assembly/infrared.dm +++ b/code/modules/assembly/infrared.dm @@ -28,7 +28,7 @@ /obj/item/assembly/infra/Initialize(mapload) . = ..() - AddComponent(/datum/component/simple_rotation) + AddElement(/datum/element/simple_rotation) /obj/item/assembly/infra/Destroy() QDEL_NULL(active_beam) diff --git a/code/modules/atmospherics/machinery/components/binary_devices/circulator.dm b/code/modules/atmospherics/machinery/components/binary_devices/circulator.dm index eb966f318b6..546d2818ebc 100644 --- a/code/modules/atmospherics/machinery/components/binary_devices/circulator.dm +++ b/code/modules/atmospherics/machinery/components/binary_devices/circulator.dm @@ -20,7 +20,7 @@ /obj/machinery/atmospherics/components/binary/circulator/Initialize(mapload) . = ..() - AddComponent(/datum/component/simple_rotation) + AddElement(/datum/element/simple_rotation) //default cold circ for mappers /obj/machinery/atmospherics/components/binary/circulator/cold diff --git a/code/modules/basketball/hoop.dm b/code/modules/basketball/hoop.dm index 0017ffdf741..b1963a050b2 100644 --- a/code/modules/basketball/hoop.dm +++ b/code/modules/basketball/hoop.dm @@ -26,7 +26,7 @@ /obj/structure/hoop/Initialize(mapload) . = ..() - AddComponent(/datum/component/simple_rotation, ROTATION_REQUIRE_WRENCH|ROTATION_IGNORE_ANCHORED, post_rotation = CALLBACK(src, PROC_REF(reset_appearance))) + AddElement(/datum/element/simple_rotation, ROTATION_REQUIRE_WRENCH|ROTATION_IGNORE_ANCHORED) update_appearance() register_context() @@ -34,7 +34,7 @@ context[SCREENTIP_CONTEXT_CTRL_LMB] = "Reset score" return CONTEXTUAL_SCREENTIP_SET -/obj/structure/hoop/proc/reset_appearance() +/obj/structure/hoop/post_rotation(mob/user, degrees) update_appearance() /obj/structure/hoop/proc/score(obj/item/toy/basketball/ball, mob/living/baller, points) diff --git a/code/modules/hydroponics/hydroponics.dm b/code/modules/hydroponics/hydroponics.dm index 5ff742ba4a4..d42419fa727 100644 --- a/code/modules/hydroponics/hydroponics.dm +++ b/code/modules/hydroponics/hydroponics.dm @@ -174,7 +174,7 @@ /obj/machinery/hydroponics/constructable/Initialize(mapload) . = ..() - AddComponent(/datum/component/simple_rotation) + AddElement(/datum/element/simple_rotation) AddComponent(/datum/component/plumbing/hydroponics) AddComponent(/datum/component/usb_port, typecacheof(list(/obj/item/circuit_component/hydroponics), only_root_path = TRUE)) AddComponent(/datum/component/fishing_spot, /datum/fish_source/hydro_tray) diff --git a/code/modules/manufactorio/_manufacturing.dm b/code/modules/manufactorio/_manufacturing.dm index 5bf3093a92c..3f5fb1919f4 100644 --- a/code/modules/manufactorio/_manufacturing.dm +++ b/code/modules/manufactorio/_manufacturing.dm @@ -16,7 +16,7 @@ /obj/machinery/power/manufacturing/Initialize(mapload) . = ..() if(may_be_moved) - AddComponent(/datum/component/simple_rotation) + AddElement(/datum/element/simple_rotation) if(anchored) connect_to_network() diff --git a/code/modules/plumbing/plumbers/_plumb_machinery.dm b/code/modules/plumbing/plumbers/_plumb_machinery.dm index 84e51918dc8..ffb7c0fedcd 100644 --- a/code/modules/plumbing/plumbers/_plumb_machinery.dm +++ b/code/modules/plumbing/plumbers/_plumb_machinery.dm @@ -23,7 +23,7 @@ . = ..() set_anchored(bolt) create_reagents(buffer, reagent_flags) - AddComponent(/datum/component/simple_rotation) + AddElement(/datum/element/simple_rotation) register_context() /obj/machinery/plumbing/create_reagents(max_vol, flags) diff --git a/code/modules/plumbing/plumbers/iv_drip.dm b/code/modules/plumbing/plumbers/iv_drip.dm index a12d78cb4e9..d735b49e56a 100644 --- a/code/modules/plumbing/plumbers/iv_drip.dm +++ b/code/modules/plumbing/plumbers/iv_drip.dm @@ -11,7 +11,7 @@ /obj/machinery/iv_drip/plumbing/Initialize(mapload, bolt, layer) . = ..() AddComponent(/datum/component/plumbing/automated_iv, bolt, layer, distinct_reagent_cap = 3) - AddComponent(/datum/component/simple_rotation) + AddElement(/datum/element/simple_rotation) /obj/machinery/iv_drip/plumbing/quick_toggle(mob/living/user) return FALSE diff --git a/code/modules/power/singularity/emitter.dm b/code/modules/power/singularity/emitter.dm index ef7a95a22c1..1c1c45fe59a 100644 --- a/code/modules/power/singularity/emitter.dm +++ b/code/modules/power/singularity/emitter.dm @@ -77,7 +77,7 @@ sparks = new sparks.attach(src) sparks.set_up(5, TRUE, src) - AddComponent(/datum/component/simple_rotation) + AddElement(/datum/element/simple_rotation) AddElement(/datum/element/empprotection, EMP_PROTECT_SELF | EMP_PROTECT_WIRES) /obj/machinery/power/emitter/welded/Initialize(mapload) diff --git a/code/modules/power/thermoelectric_generator.dm b/code/modules/power/thermoelectric_generator.dm index bded1482825..9d5fd1d3850 100644 --- a/code/modules/power/thermoelectric_generator.dm +++ b/code/modules/power/thermoelectric_generator.dm @@ -31,7 +31,7 @@ /obj/machinery/power/thermoelectric_generator/Initialize(mapload) . = ..() - AddComponent(/datum/component/simple_rotation) + AddElement(/datum/element/simple_rotation) find_circulators() connect_to_network() SSair.start_processing_machine(src) diff --git a/code/modules/reagents/chemistry/machinery/chem_dispenser.dm b/code/modules/reagents/chemistry/machinery/chem_dispenser.dm index e41a5fa46dc..8a1bc7479b6 100644 --- a/code/modules/reagents/chemistry/machinery/chem_dispenser.dm +++ b/code/modules/reagents/chemistry/machinery/chem_dispenser.dm @@ -639,7 +639,7 @@ if(emagged_reagents != null && !emagged_reagents.len) emagged_reagents = drink_emagged_reagents . = ..() - AddComponent(/datum/component/simple_rotation) + AddElement(/datum/element/simple_rotation) /obj/machinery/chem_dispenser/drinks/setDir() var/old = dir diff --git a/code/modules/reagents/chemistry/machinery/smoke_machine.dm b/code/modules/reagents/chemistry/machinery/smoke_machine.dm index c1775221e24..02c96e8418d 100644 --- a/code/modules/reagents/chemistry/machinery/smoke_machine.dm +++ b/code/modules/reagents/chemistry/machinery/smoke_machine.dm @@ -44,7 +44,7 @@ . = ..() AddComponent(/datum/component/plumbing/simple_demand, distinct_reagent_cap = 5) - AddComponent(/datum/component/simple_rotation) + AddElement(/datum/element/simple_rotation) register_context() diff --git a/code/modules/reagents/reagent_dispenser.dm b/code/modules/reagents/reagent_dispenser.dm index 9043c254d62..60af82540d2 100644 --- a/code/modules/reagents/reagent_dispenser.dm +++ b/code/modules/reagents/reagent_dispenser.dm @@ -653,7 +653,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/reagent_dispensers/wall/virusfood, 30 /obj/structure/reagent_dispensers/plumbed/storage/Initialize(mapload) . = ..() - AddComponent(/datum/component/simple_rotation) + AddElement(/datum/element/simple_rotation) /obj/structure/reagent_dispensers/plumbed/storage/update_overlays() diff --git a/code/modules/recycling/disposal/construction.dm b/code/modules/recycling/disposal/construction.dm index 8e0f4dad6f4..a36d785cf09 100644 --- a/code/modules/recycling/disposal/construction.dm +++ b/code/modules/recycling/disposal/construction.dm @@ -33,12 +33,14 @@ pipename = initial(pipe_type.name) - AddComponent(/datum/component/simple_rotation, post_rotation = CALLBACK(src, PROC_REF(post_rotation))) + AddElement(/datum/element/simple_rotation) AddElement(/datum/element/undertile, TRAIT_T_RAY_VISIBLE) + // this only gets used by pipes created by RPDs or pipe dispensers if(flip) - var/datum/component/simple_rotation/rotcomp = GetComponent(/datum/component/simple_rotation) - rotcomp.rotate(usr, ROTATION_FLIP) // this only gets used by pipes created by RPDs or pipe dispensers + // Simulate two right clicks to flip this thing upside down + usr.base_click_alt_secondary(src) + usr.base_click_alt_secondary(src) update_appearance(UPDATE_ICON) @@ -86,7 +88,7 @@ dpdir |= REVERSE_DIR(dir) return dpdir -/obj/structure/disposalconstruct/proc/post_rotation(mob/user, degrees) +/obj/structure/disposalconstruct/post_rotation(mob/user, degrees) if(degrees == ROTATION_FLIP) var/obj/structure/disposalpipe/temp = pipe_type if(initial(temp.flip_type)) diff --git a/code/modules/research/ordnance/doppler_array.dm b/code/modules/research/ordnance/doppler_array.dm index 3e4757e1675..fda438e4f4e 100644 --- a/code/modules/research/ordnance/doppler_array.dm +++ b/code/modules/research/ordnance/doppler_array.dm @@ -31,7 +31,7 @@ update_doppler_light() // Rotation determines the detectable direction. - AddComponent(/datum/component/simple_rotation) + AddElement(/datum/element/simple_rotation) /datum/data/tachyon_record name = "Log Recording" diff --git a/code/modules/research/xenobiology/vatgrowing/vatgrower.dm b/code/modules/research/xenobiology/vatgrowing/vatgrower.dm index 4f65a3d9240..575a7ac3a1d 100644 --- a/code/modules/research/xenobiology/vatgrowing/vatgrower.dm +++ b/code/modules/research/xenobiology/vatgrowing/vatgrower.dm @@ -23,7 +23,7 @@ create_reagents(reagent_volume, reagent_flags) if(use_plumbing) - AddComponent(/datum/component/simple_rotation) + AddElement(/datum/element/simple_rotation) AddComponent(/datum/component/plumbing/simple_demand) var/static/list/hovering_item_typechecks = list( diff --git a/code/modules/station_goals/bsa.dm b/code/modules/station_goals/bsa.dm index 3d39bcbc2ce..731875c896e 100644 --- a/code/modules/station_goals/bsa.dm +++ b/code/modules/station_goals/bsa.dm @@ -48,7 +48,7 @@ GLOBAL_VAR_INIT(bsa_unlock, FALSE) /obj/machinery/bsa/back/Initialize(mapload) . = ..() - AddComponent(/datum/component/simple_rotation) + AddElement(/datum/element/simple_rotation) /obj/machinery/bsa/back/multitool_act(mob/living/user, obj/item/multitool/M) M.set_buffer(src) @@ -62,7 +62,7 @@ GLOBAL_VAR_INIT(bsa_unlock, FALSE) /obj/machinery/bsa/front/Initialize(mapload) . = ..() - AddComponent(/datum/component/simple_rotation) + AddElement(/datum/element/simple_rotation) /obj/machinery/bsa/front/multitool_act(mob/living/user, obj/item/multitool/M) M.set_buffer(src) @@ -78,7 +78,7 @@ GLOBAL_VAR_INIT(bsa_unlock, FALSE) /obj/machinery/bsa/middle/Initialize(mapload) . = ..() - AddComponent(/datum/component/simple_rotation) + AddElement(/datum/element/simple_rotation) /obj/machinery/bsa/middle/multitool_act(mob/living/user, obj/item/multitool/tool) . = NONE diff --git a/code/modules/vehicles/wheelchair.dm b/code/modules/vehicles/wheelchair.dm index 3495d95a87a..ce481c4d925 100644 --- a/code/modules/vehicles/wheelchair.dm +++ b/code/modules/vehicles/wheelchair.dm @@ -41,7 +41,7 @@ . = ..() make_ridable() ADD_TRAIT(src, TRAIT_NO_IMMOBILIZE, INNATE_TRAIT) - AddComponent(/datum/component/simple_rotation) //Since it's technically a chair I want it to have chair properties + AddElement(/datum/element/simple_rotation) //Since it's technically a chair I want it to have chair properties AddElement(/datum/element/noisy_movement, volume = 75) /obj/vehicle/ridden/wheelchair/handle_deconstruct(disassembled) diff --git a/tgstation.dme b/tgstation.dme index bc2fd3fba4f..12d3c7e0b2a 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -1274,7 +1274,6 @@ #include "code\datums\components\reskinnable_atom.dm" #include "code\datums\components\revenge_ability.dm" #include "code\datums\components\rot.dm" -#include "code\datums\components\rotation.dm" #include "code\datums\components\scope.dm" #include "code\datums\components\seclight_attachable.dm" #include "code\datums\components\sect_nullrod_bonus.dm" @@ -1641,6 +1640,7 @@ #include "code\datums\elements\regal_rat_minion.dm" #include "code\datums\elements\relay_attackers.dm" #include "code\datums\elements\ridable.dm" +#include "code\datums\elements\rotation.dm" #include "code\datums\elements\rust.dm" #include "code\datums\elements\selfknockback.dm" #include "code\datums\elements\series.dm"