mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-09 07:57:50 +00:00
* first commit instruments first commit for instruments, should have everything ready * open dream linter fix 1 * fix linter warnings 1 * subsystem + other small fixes * alternative sprites * more alternative sprites * style fixes + src. removal
43 lines
922 B
Plaintext
43 lines
922 B
Plaintext
/datum/musical_event
|
|
var/sound/object
|
|
var/mob/subject
|
|
var/datum/sound_player/source
|
|
var/time = 0
|
|
var/new_volume = 100
|
|
|
|
|
|
/datum/musical_event/New(datum/sound_player/source_, mob/subject_, sound/object_, time_, volume_)
|
|
source = source_
|
|
subject = subject_
|
|
object = object_
|
|
time = time_
|
|
new_volume = volume_
|
|
|
|
|
|
/datum/musical_event/proc/tick()
|
|
if (!(istype(object) && istype(subject) && istype(source)))
|
|
return
|
|
if (new_volume > 0)
|
|
update_sound()
|
|
else
|
|
destroy_sound()
|
|
|
|
|
|
/datum/musical_event/proc/update_sound()
|
|
object.volume = new_volume
|
|
object.status |= SOUND_UPDATE
|
|
if (subject)
|
|
subject << object
|
|
|
|
|
|
/datum/musical_event/proc/destroy_sound()
|
|
if (subject)
|
|
var/sound/null_sound = sound(channel=object.channel, wait=0)
|
|
if (global.musical_config.env_settings_available)
|
|
null_sound.environment = -1
|
|
subject << null_sound
|
|
if (source || source.song)
|
|
source.song.free_channel(object.channel)
|
|
|
|
|