From ff93e6233fd578bc0e11852b7563fa6f3fe25983 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Sat, 11 Nov 2023 21:04:20 -0500 Subject: [PATCH] Add back bgm pending remove checks --- src/battle-scene.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 2132a75f6..65e4cf92d 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -973,13 +973,13 @@ export default class BattleScene extends Phaser.Scene { : this.getBgmLoopPoint(bgmName); let loaded = false; const playNewBgm = () => { - if (bgmName === null && this.bgm) { + if (bgmName === null && this.bgm && !this.bgm.pendingRemove) { this.bgm.play({ volume: this.masterVolume * this.bgmVolume }); return; } - if (this.bgm && this.bgm.isPlaying) + if (this.bgm && !this.bgm.pendingRemove && this.bgm.isPlaying) this.bgm.stop(); this.bgm = this.sound.add(bgmName, { loop: true }); this.bgm.play({ @@ -995,7 +995,7 @@ export default class BattleScene extends Phaser.Scene { }); if (fadeOut) { const onBgmFaded = () => { - if (loaded && !this.bgm.isPlaying) + if (loaded && (!this.bgm.isPlaying || this.bgm.pendingRemove)) playNewBgm(); }; this.time.delayedCall(this.fadeOutBgm(500, true) ? 750 : 250, onBgmFaded); @@ -1005,7 +1005,7 @@ export default class BattleScene extends Phaser.Scene { } pauseBgm(): boolean { - if (this.bgm && this.bgm.isPlaying) { + if (this.bgm && !this.bgm.pendingRemove && this.bgm.isPlaying) { this.bgm.pause(); return true; } @@ -1013,7 +1013,7 @@ export default class BattleScene extends Phaser.Scene { } resumeBgm(): boolean { - if (this.bgm && this.bgm.isPaused) { + if (this.bgm && !this.bgm.pendingRemove && this.bgm.isPaused) { this.bgm.resume(); return true; }