mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-07-20 20:37:34 +01:00
1a1a875bdb
Take 2 <img width="320" height="149" alt="image" src="https://github.com/user-attachments/assets/21e45078-ef69-4b3c-8b50-208800b82558" /> It somehow got even worse over time. <img width="311" height="164" alt="image" src="https://github.com/user-attachments/assets/882d9a8e-16f1-4172-9c7b-f741d5bede8d" /> And now I have finished fixing it by hand and testing to verify that my fixes work. https://github.com/user-attachments/assets/0106593b-4b3f-4e7d-88f0-86c4b22571ff --------- Signed-off-by: VMSolidus <evilexecutive@gmail.com> Co-authored-by: SleepyGemmy <99297919+SleepyGemmy@users.noreply.github.com>
57 lines
1.7 KiB
Plaintext
57 lines
1.7 KiB
Plaintext
//This is similar to normal sound tokens
|
|
//Mostly it allows non repeating sounds to keep channel ownership
|
|
|
|
/datum/sound_token/instrument
|
|
var/use_env = 0
|
|
var/datum/sound_player/player
|
|
|
|
//Slight duplication, but there's key differences
|
|
/datum/sound_token/instrument/New(atom/source, sound_id, sound/sound, range = 4, prefer_mute = FALSE, use_env, datum/sound_player/player)
|
|
if(!istype(source))
|
|
CRASH("Invalid sound source: [log_info_line(source)]")
|
|
if(!istype(sound))
|
|
CRASH("Invalid sound: [log_info_line(sound)]")
|
|
if(sound.repeat && !sound_id)
|
|
CRASH("No sound id given")
|
|
if(!PrivIsValidEnvironment(sound.environment))
|
|
CRASH("Invalid sound environment: [log_info_line(sound.environment)]")
|
|
|
|
src.prefer_mute = prefer_mute
|
|
src.range = range
|
|
src.source = source
|
|
src.sound = sound
|
|
src.sound_id = sound_id
|
|
src.use_env = use_env
|
|
src.player = player
|
|
src.sound_type = ASFX_INSTRUMENT
|
|
|
|
var/channel = GLOB.sound_player.PrivGetChannel(src) //Attempt to find a channel
|
|
if(!isnum(channel))
|
|
CRASH("All available sound channels are in active use.")
|
|
sound.channel = channel
|
|
|
|
listeners = list()
|
|
listener_status = list()
|
|
|
|
RegisterSignal(source, COMSIG_QDELETING, TYPE_PROC_REF(/datum, qdel_self))
|
|
|
|
player.subscribe(src)
|
|
|
|
|
|
/datum/sound_token/instrument/PrivGetEnvironment(listener)
|
|
//Allow override (in case your instrument has to sound funky or muted)
|
|
if(use_env)
|
|
return sound.environment
|
|
else
|
|
var/area/A = get_area(listener)
|
|
return A && PrivIsValidEnvironment(A.sound_environment) ? A.sound_environment : sound.environment
|
|
|
|
/datum/sound_token/instrument/Stop()
|
|
if(player)
|
|
player.unsubscribe(src)
|
|
player = null
|
|
. = ..()
|
|
|
|
/datum/sound_token/instrument/Destroy()
|
|
return ..()
|