Datumize sound keys into sound_effect_datums (#91850)

## About The Pull Request
inspired by https://github.com/tgstation/tgstation/pull/85407

we initialize a global assoc list in SSsounds named sfx_datum_by_key,
with k = SFX_KEY, v = ref to the singleton sound_effect datum, then we
can call return_sfx on the referenced datum to get an sfx
## Why It's Good For The Game
makes the code a bit easier to add onto and work with
## Changelog
🆑
refactor: refactored how sfx with multiple variants are coded, report
any issues with sounds not playing!
/🆑
This commit is contained in:
grungussuss
2025-07-04 16:33:05 -04:00
committed by Roxy
parent 85dec714d3
commit 4905d45bf6
5 changed files with 878 additions and 663 deletions
+7
View File
@@ -37,6 +37,7 @@ SUBSYSTEM_DEF(sounds)
/datum/controller/subsystem/sounds/Initialize()
setup_available_channels()
find_all_available_sounds()
init_sound_keys()
if(!(RUST_G))
to_chat(world, span_boldnotice("Sounds subsystem: No rust_g detected."))
@@ -225,4 +226,10 @@ SUBSYSTEM_DEF(sounds)
sound_lengths[file_path] = as_num
return as_num
/datum/controller/subsystem/sounds/proc/init_sound_keys()
for(var/datum/sound_effect/sfx as anything in subtypesof(/datum/sound_effect))
// this is for the assoc subtype
if(!isnull(sfx.key))
GLOB.sfx_datum_by_key[sfx.key] = new sfx()
#undef DATUMLESS