mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-23 05:00:55 +01:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user