Confine Elevator Music to Elevators (#75464)

Refactors elevator music to originate from an abstract object rather
than the elevator control panel.
Elevator music is applied while you are within a certain radius of this
object and cuts off immediately upon exiting (largely because as far as
I know you can't obtain playing sounds to fade them out in byond).
As a side-effect of this refactor it also isn't audible to ghosts at
all.
This commit is contained in:
Jacquerel
2023-05-27 23:14:36 +02:00
committed by GitHub
parent dc64f47f98
commit 2732e96cff
20 changed files with 4409 additions and 4272 deletions
+11 -1
View File
@@ -60,6 +60,8 @@
var/skip_starting_sounds = FALSE
/// If true, plays directly to provided atoms instead of from them.
var/direct
/// Sound channel to play on, random if not provided
var/sound_channel
/datum/looping_sound/New(_parent, start_immediately = FALSE, _direct = FALSE, _skip_starting_sounds = FALSE)
if(!mid_sounds)
@@ -97,6 +99,7 @@
* * null_parent - Whether or not we should set the parent to null (useful when destroying the `looping_sound` itself). Defaults to FALSE.
*/
/datum/looping_sound/proc/stop(null_parent = FALSE)
stop_current()
if(null_parent)
set_parent(null)
if(!timer_id)
@@ -147,7 +150,7 @@
/datum/looping_sound/proc/play(soundfile, volume_override)
var/sound/sound_to_play = sound(soundfile)
if(direct)
sound_to_play.channel = SSsounds.random_available_channel()
sound_to_play.channel = sound_channel || SSsounds.random_available_channel()
sound_to_play.volume = volume_override || volume //Use volume as fallback if theres no override
SEND_SOUND(parent, sound_to_play)
else
@@ -215,6 +218,13 @@
start_wait = start_length
timer_id = addtimer(CALLBACK(src, PROC_REF(start_sound_loop)), start_wait, TIMER_CLIENT_TIME | TIMER_DELETE_ME | TIMER_STOPPABLE, SSsound_loops)
/// Stops sound playing on current channel, if specified
/datum/looping_sound/proc/stop_current()
if(!sound_channel || !ismob(parent))
return
var/mob/mob_parent = parent
mob_parent.stop_sound_channel(sound_channel)
/// Simple proc that's executed when the looping sound is stopped, so that the `end_sound` can be played, if there's one.
/datum/looping_sound/proc/on_stop()
if(end_sound && loop_started)
+4 -22
View File
@@ -1,28 +1,10 @@
/datum/looping_sound/elevator_music
start_sound = 'sound/ambience/music/elevator/elevator-01.ogg'
start_length = 7.62 SECONDS
/datum/looping_sound/local_forecast
mid_sounds = list(
'sound/ambience/music/elevator/elevator-01.ogg',
'sound/ambience/music/elevator/elevator-02.ogg',
'sound/ambience/music/elevator/elevator-03.ogg',
'sound/ambience/music/elevator/elevator-04.ogg',
'sound/ambience/music/elevator/elevator-05.ogg',
'sound/ambience/music/elevator/elevator-06.ogg',
'sound/ambience/music/elevator/elevator-07.ogg',
'sound/ambience/music/elevator/elevator-08.ogg',
'sound/ambience/music/elevator/robocop-short.ogg' = 1,
)
mid_length = 7.62 SECONDS
end_sound = 'sound/ambience/music/elevator/elevator-08.ogg'
mid_length = 61 SECONDS
volume = 20
falloff_exponent = 5
falloff_distance = 3
vary = FALSE
ignore_walls = FALSE
use_reverb = FALSE
each_once = TRUE
skip_starting_sounds = TRUE
in_order = TRUE
direct = TRUE
sound_channel = CHANNEL_ELEVATOR