From 0f4be6d9b55f8199067b5c8f3c2b635fcdfaf5d6 Mon Sep 17 00:00:00 2001 From: Ghom <42542238+Ghommie@users.noreply.github.com> Date: Sat, 1 Jul 2023 16:30:09 +0200 Subject: [PATCH] Adds an element for noisy movement (wheelchairs, office chairs, trashcarts etc. etc.) (#76378) ## About The Pull Request Converts generic, copypasted behavior into an element. ## Why It's Good For The Game I'd rather not have someone just copypaste the old thing, since there're a few more things to take into account now than just whether the item has gravity, and if that ever has to change, we will only have to modify one line than several. ## Changelog :cl: fix: Fixed the office chair being silent. My bad. /:cl: --- code/datums/elements/noisy_movement.dm | 21 ++++++++++++ code/game/machinery/iv_drip.dm | 6 +--- .../objects/structures/beds_chairs/bed.dm | 7 +--- .../objects/structures/beds_chairs/chair.dm | 15 ++++---- .../structures/crates_lockers/crates.dm | 34 ++++++++----------- code/game/objects/structures/tables_racks.dm | 8 ++--- code/modules/vehicles/wheelchair.dm | 6 +--- tgstation.dme | 1 + 8 files changed, 50 insertions(+), 48 deletions(-) create mode 100644 code/datums/elements/noisy_movement.dm diff --git a/code/datums/elements/noisy_movement.dm b/code/datums/elements/noisy_movement.dm new file mode 100644 index 00000000000..f4215dd48bf --- /dev/null +++ b/code/datums/elements/noisy_movement.dm @@ -0,0 +1,21 @@ +/datum/element/noisy_movement + element_flags = ELEMENT_BESPOKE + argument_hash_start_idx = 2 + var/movement_sound + var/volume + +/datum/element/noisy_movement/Attach(datum/target, movement_sound = 'sound/effects/roll.ogg', volume = 100) + . = ..() + if(!ismovable(target)) + return ELEMENT_INCOMPATIBLE + + src.movement_sound = movement_sound + src.volume = volume + + RegisterSignal(target, COMSIG_MOVABLE_MOVED, PROC_REF(play_sound)) + +/datum/element/noisy_movement/proc/play_sound(atom/movable/source, old_loc, movement_dir, forced) + SIGNAL_HANDLER + if(!forced && !CHECK_MOVE_LOOP_FLAGS(source, MOVEMENT_LOOP_OUTSIDE_CONTROL) && source.has_gravity()) + playsound(source, movement_sound, volume, TRUE) + diff --git a/code/game/machinery/iv_drip.dm b/code/game/machinery/iv_drip.dm index e95a5a66e1e..2d45bd57100 100644 --- a/code/game/machinery/iv_drip.dm +++ b/code/game/machinery/iv_drip.dm @@ -61,17 +61,13 @@ interaction_flags_machine |= INTERACT_MACHINE_OFFLINE register_context() update_appearance(UPDATE_ICON) + AddElement(/datum/element/noisy_movement) /obj/machinery/iv_drip/Destroy() attached = null QDEL_NULL(reagent_container) return ..() -/obj/machinery/iv_drip/Moved(atom/old_loc, movement_dir, forced, list/old_locs, momentum_change = TRUE) - . = ..() - if(has_gravity()) - playsound(src, 'sound/effects/roll.ogg', 100, TRUE) - /obj/machinery/iv_drip/ui_interact(mob/user, datum/tgui/ui) ui = SStgui.try_update_ui(user, src, ui) if(!ui) diff --git a/code/game/objects/structures/beds_chairs/bed.dm b/code/game/objects/structures/beds_chairs/bed.dm index 2610498964e..342ba933ec5 100644 --- a/code/game/objects/structures/beds_chairs/bed.dm +++ b/code/game/objects/structures/beds_chairs/bed.dm @@ -66,6 +66,7 @@ /datum/element/contextual_screentip_bare_hands, \ rmb_text = "Fold up", \ ) + AddElement(/datum/element/noisy_movement) /obj/structure/bed/roller/examine(mob/user) . = ..() @@ -112,12 +113,6 @@ //Push them up from the normal lying position M.pixel_y = M.base_pixel_y -/obj/structure/bed/roller/Moved(atom/old_loc, movement_dir, forced, list/old_locs, momentum_change = TRUE) - . = ..() - if(has_gravity()) - playsound(src, 'sound/effects/roll.ogg', 100, TRUE) - - /obj/structure/bed/roller/post_unbuckle_mob(mob/living/M) set_density(FALSE) icon_state = "down" diff --git a/code/game/objects/structures/beds_chairs/chair.dm b/code/game/objects/structures/beds_chairs/chair.dm index 48502264c49..d43d4502556 100644 --- a/code/game/objects/structures/beds_chairs/chair.dm +++ b/code/game/objects/structures/beds_chairs/chair.dm @@ -244,11 +244,9 @@ item_chair = null icon_state = "officechair_dark" - -/obj/structure/chair/office/Moved(atom/old_loc, movement_dir, forced, list/old_locs, momentum_change = TRUE) +/obj/structure/chair/office/Initialize(mapload) . = ..() - if(!forced && CHECK_MOVE_LOOP_FLAGS(src, MOVEMENT_LOOP_OUTSIDE_CONTROL) && has_gravity()) - playsound(src, 'sound/effects/roll.ogg', 100, TRUE) + AddElement(/datum/element/noisy_movement) /obj/structure/chair/office/electrify_self(obj/item/assembly/shock_kit/input_shock_kit, mob/user, list/overlays_from_child_procs) if(!overlays_from_child_procs) @@ -459,6 +457,10 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/chair/stool/bar, 0) item_chair = null var/turns = 0 +/obj/structure/chair/bronze/Initialize(mapload) + . = ..() + AddElement(/datum/element/noisy_movement, 'sound/machines/clockcult/integration_cog_install.ogg', 50) + /obj/structure/chair/bronze/Destroy() STOP_PROCESSING(SSfastprocess, src) . = ..() @@ -470,11 +472,6 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/chair/stool/bar, 0) if(turns >= 8) STOP_PROCESSING(SSfastprocess, src) -/obj/structure/chair/bronze/Moved(atom/old_loc, movement_dir, forced, list/old_locs, momentum_change = TRUE) - . = ..() - if(has_gravity()) - playsound(src, 'sound/machines/clockcult/integration_cog_install.ogg', 50, TRUE) - /obj/structure/chair/bronze/AltClick(mob/user) turns = 0 if(!user.can_perform_action(src, NEED_DEXTERITY)) diff --git a/code/game/objects/structures/crates_lockers/crates.dm b/code/game/objects/structures/crates_lockers/crates.dm index cd51fd77624..ebf31e45b53 100644 --- a/code/game/objects/structures/crates_lockers/crates.dm +++ b/code/game/objects/structures/crates_lockers/crates.dm @@ -158,9 +158,24 @@ for (var/i in 1 to rand(2,6)) new /obj/effect/spawner/random/maintenance(src) +/obj/structure/closet/crate/trashcart //please make this a generic cart path later after things calm down a little + desc = "A heavy, metal trashcart with wheels." + name = "trash cart" + icon_state = "trashcart" + base_icon_state = "trashcart" + can_install_electronics = FALSE + paint_jobs = null + +/obj/structure/closet/crate/trashcart/laundry + name = "laundry cart" + desc = "A large cart for hauling around large amounts of laundry." + icon_state = "laundry" + base_icon_state = "laundry" + /obj/structure/closet/crate/trashcart/Initialize(mapload) . = ..() AddElement(/datum/element/swabable, CELL_LINE_TABLE_SLUDGE, CELL_VIRUS_TABLE_GENERIC, rand(2,3), 15) + AddElement(/datum/element/noisy_movement) /obj/structure/closet/crate/trashcart/filled @@ -182,25 +197,6 @@ icon_state = "o2crate" base_icon_state = "o2crate" -/obj/structure/closet/crate/trashcart //please make this a generic cart path later after things calm down a little - desc = "A heavy, metal trashcart with wheels." - name = "trash cart" - icon_state = "trashcart" - base_icon_state = "trashcart" - can_install_electronics = FALSE - paint_jobs = null - -/obj/structure/closet/crate/trashcart/Moved(atom/old_loc, movement_dir, forced, list/old_locs, momentum_change = TRUE) - . = ..() - if(has_gravity()) - playsound(src, 'sound/effects/roll.ogg', 100, TRUE) - -/obj/structure/closet/crate/trashcart/laundry - name = "laundry cart" - desc = "A large cart for hauling around large amounts of laundry." - icon_state = "laundry" - base_icon_state = "laundry" - /obj/structure/closet/crate/medical desc = "A medical crate." name = "medical crate" diff --git a/code/game/objects/structures/tables_racks.dm b/code/game/objects/structures/tables_racks.dm index 3a90144c04c..de1d2835de2 100644 --- a/code/game/objects/structures/tables_racks.dm +++ b/code/game/objects/structures/tables_racks.dm @@ -354,6 +354,10 @@ icon_state = "rollingtable" var/list/attached_items = list() +/obj/structure/table/rolling/Initialize(mapload) + . = ..() + AddElement(/datum/element/noisy_movement) + /obj/structure/table/rolling/AfterPutItemOnTable(obj/item/I, mob/living/user) . = ..() attached_items += I @@ -377,10 +381,6 @@ if(!attached_movable.Move(loc)) RemoveItemFromTable(attached_movable, attached_movable.loc) -/obj/structure/table/rolling/Moved(atom/old_loc, movement_dir, forced, list/old_locs, momentum_change = TRUE) - . = ..() - if(has_gravity()) - playsound(src, 'sound/effects/roll.ogg', 100, TRUE) /* * Glass tables */ diff --git a/code/modules/vehicles/wheelchair.dm b/code/modules/vehicles/wheelchair.dm index a119694978c..2003412d748 100644 --- a/code/modules/vehicles/wheelchair.dm +++ b/code/modules/vehicles/wheelchair.dm @@ -30,6 +30,7 @@ if(!bell_attached) return initialize_controller_action_type(/datum/action/vehicle/ridden/wheelchair/bell, VEHICLE_CONTROL_DRIVE) + AddElement(/datum/element/noisy_movement, volume = 75) /obj/vehicle/ridden/wheelchair/Initialize(mapload) . = ..() @@ -43,11 +44,6 @@ new /obj/item/stack/sheet/iron(drop_location(), 1) return ..() -/obj/vehicle/ridden/wheelchair/Moved(atom/old_loc, movement_dir, forced, list/old_locs, momentum_change = TRUE) - . = ..() - if(!forced && !CHECK_MOVE_LOOP_FLAGS(src, MOVEMENT_LOOP_OUTSIDE_CONTROL) && has_gravity()) - playsound(src, 'sound/effects/roll.ogg', 75, TRUE) - /obj/vehicle/ridden/wheelchair/post_buckle_mob(mob/living/user) . = ..() update_appearance() diff --git a/tgstation.dme b/tgstation.dme index 3964675399c..eb82ef338f3 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -1232,6 +1232,7 @@ #include "code\datums\elements\movement_turf_changer.dm" #include "code\datums\elements\movetype_handler.dm" #include "code\datums\elements\nerfed_pulling.dm" +#include "code\datums\elements\noisy_movement.dm" #include "code\datums\elements\noticable_organ.dm" #include "code\datums\elements\obj_regen.dm" #include "code\datums\elements\openspace_item_click_handler.dm"