improve function

This commit is contained in:
Lu[ke] Wilson 2025-01-26 14:30:47 +00:00
parent a2c896f765
commit 710da1d28d

View File

@ -21,15 +21,14 @@ export function registerSound(key, onTrigger, data = {}) {
} }
export function aliasBank(alias, bank) { export function aliasBank(alias, bank) {
const _soundMap = soundMap.get(); const soundDictionary = soundMap.get();
const soundsToAdd = {}; for (const key in soundDictionary) {
for (const soundName in _soundMap) { if (key.startsWith(bank + '_')) continue;
const [soundPrefix, soundSuffix] = soundName.split('_'); const [, tail] = key.split('_');
if (soundPrefix == bank) { const value = soundDictionary[key];
soundsToAdd[`${alias}_${soundSuffix}`] = _soundMap[soundName]; soundDictionary[`${alias}_${tail}`] = value;
}
} }
soundMap.set({ ..._soundMap, ...soundsToAdd }); soundMap.set(soundDictionary);
} }
export function getSound(s) { export function getSound(s) {