improve function
This commit is contained in:
parent
a2c896f765
commit
710da1d28d
1 changed files with 7 additions and 8 deletions
|
|
@ -21,15 +21,14 @@ export function registerSound(key, onTrigger, data = {}) {
|
|||
}
|
||||
|
||||
export function aliasBank(alias, bank) {
|
||||
const _soundMap = soundMap.get();
|
||||
const soundsToAdd = {};
|
||||
for (const soundName in _soundMap) {
|
||||
const [soundPrefix, soundSuffix] = soundName.split('_');
|
||||
if (soundPrefix == bank) {
|
||||
soundsToAdd[`${alias}_${soundSuffix}`] = _soundMap[soundName];
|
||||
}
|
||||
const soundDictionary = soundMap.get();
|
||||
for (const key in soundDictionary) {
|
||||
if (key.startsWith(bank + '_')) continue;
|
||||
const [, tail] = key.split('_');
|
||||
const value = soundDictionary[key];
|
||||
soundDictionary[`${alias}_${tail}`] = value;
|
||||
}
|
||||
soundMap.set({ ..._soundMap, ...soundsToAdd });
|
||||
soundMap.set(soundDictionary);
|
||||
}
|
||||
|
||||
export function getSound(s) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue