* System interface method that CinematicParser calls on each dialogNode * of the cinematic. * @param {DialogNode} dialogNode * @param {Object} shot * @param {Object} speakerToThangTypeSlugMap * @returns {AbstractCommand[]}
(dialogNode, shot, speakerToThangTypeSlugMap)
| 108 | * @returns {AbstractCommand[]} |
| 109 | */ |
| 110 | parseDialogNode (dialogNode, shot, speakerToThangTypeSlugMap) { |
| 111 | const soundCommands = [] |
| 112 | let speakerThangType = speakerToThangTypeSlugMap[dialogNode.speaker] |
| 113 | if (dialogNode.textLocation && dialogNode.textLocation.y > 500) { |
| 114 | // It's always mouse if it's low on the screen |
| 115 | speakerThangType = 'mouse' |
| 116 | } |
| 117 | if (!speakerThangType) { |
| 118 | // It's usually (always?) the hero |
| 119 | speakerThangType = 'hero' |
| 120 | } |
| 121 | speakerThangType = standardizeSpeaker(speakerThangType) |
| 122 | const soundEffects = getSoundEffects(dialogNode) || [] |
| 123 | soundEffects.forEach(({ sound, triggerStart }) => { |
| 124 | const soundIdPromise = store.dispatch('audio/playSound', { |
| 125 | track: 'soundEffects', |
| 126 | autoplay: false, |
| 127 | src: Object.values(sound).map(f => `/file/${f}`) |
| 128 | }) |
| 129 | |
| 130 | soundCommands.push(new SequentialCommands([ |
| 131 | new Sleep(triggerStart), |
| 132 | new SyncFunction(async () => { |
| 133 | const soundId = await soundIdPromise |
| 134 | store.dispatch('audio/playSound', soundId) |
| 135 | }) |
| 136 | ])) |
| 137 | }) |
| 138 | |
| 139 | const voiceOver = getVoiceOver(dialogNode) |
| 140 | const hasText = dialogNode?.text && /[a-z]/i.test(dialogNode.text) |
| 141 | if (voiceOver || hasText) { |
| 142 | soundCommands.push( |
| 143 | createVoiceOverCommand(dialogNode, speakerThangType) |
| 144 | ) |
| 145 | } else { |
| 146 | // If no voice over, cut any VO that may be playing. |
| 147 | soundCommands.push( |
| 148 | new SyncFunction(() => { |
| 149 | store.dispatch('audio/fadeTrack', { to: 0, track: 'voiceOver', duration: 100 }) |
| 150 | }) |
| 151 | ) |
| 152 | } |
| 153 | |
| 154 | return soundCommands |
| 155 | } |
| 156 | |
| 157 | stopAllSounds () { |
| 158 | store.dispatch('audio/stopAll', { unload: true }) |
nothing calls this directly
no test coverage detected