- fix bug where the wordballoon doesn't show if you send a message while the TTS for another message is still playing

- agents now spawn in random positions on the viewport
This commit is contained in:
Elijah R 2024-07-10 22:45:54 -04:00
parent 8b170ef471
commit d1295bcc2f
2 changed files with 10 additions and 3 deletions

View file

@ -15,6 +15,10 @@ function dwAlign(off: number): number {
return ul;
}
function randint(min: number, max: number) {
return Math.floor(Math.random() * (max - min) + min);
}
// animation state (used during animation playback)
class AgentAnimationState {
char: Agent;
@ -308,6 +312,9 @@ export class Agent {
}
show() {
this.x = randint(0, document.documentElement.clientWidth - this.data.characterInfo.charWidth);
this.y = randint(0, document.documentElement.clientHeight - this.data.characterInfo.charHeight);
this.setLoc();
this.cnv.style.display = 'block';
this.playAnimationByName('Show', () => {});
}

View file

@ -188,11 +188,11 @@ export class MSAgentClient {
this.playingAudio.set(user!.username, audio);
audio.addEventListener('ended', () => {
this.playingAudio.delete(user!.username);
// give a bit of time before the wordballoon disappears
setTimeout(() => {
if (this.playingAudio.get(user!.username) === audio)
user!.agent.stopSpeaking();
this.playingAudio.delete(user!.username);
}, 1000);
});