Files
Bubberstation/code/datums/elements/noisy_movement.dm
Ghom 0f4be6d9b5 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

🆑
fix: Fixed the office chair being silent. My bad.
/🆑
2023-07-01 15:30:09 +01:00

22 lines
693 B
Plaintext

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