Add back bgm pending remove checks

pull/2/head
Flashfyre 2023-11-11 21:04:20 -05:00
parent 2987c8ec93
commit ff93e6233f
1 changed files with 5 additions and 5 deletions

View File

@ -973,13 +973,13 @@ export default class BattleScene extends Phaser.Scene {
: this.getBgmLoopPoint(bgmName); : this.getBgmLoopPoint(bgmName);
let loaded = false; let loaded = false;
const playNewBgm = () => { const playNewBgm = () => {
if (bgmName === null && this.bgm) { if (bgmName === null && this.bgm && !this.bgm.pendingRemove) {
this.bgm.play({ this.bgm.play({
volume: this.masterVolume * this.bgmVolume volume: this.masterVolume * this.bgmVolume
}); });
return; return;
} }
if (this.bgm && this.bgm.isPlaying) if (this.bgm && !this.bgm.pendingRemove && this.bgm.isPlaying)
this.bgm.stop(); this.bgm.stop();
this.bgm = this.sound.add(bgmName, { loop: true }); this.bgm = this.sound.add(bgmName, { loop: true });
this.bgm.play({ this.bgm.play({
@ -995,7 +995,7 @@ export default class BattleScene extends Phaser.Scene {
}); });
if (fadeOut) { if (fadeOut) {
const onBgmFaded = () => { const onBgmFaded = () => {
if (loaded && !this.bgm.isPlaying) if (loaded && (!this.bgm.isPlaying || this.bgm.pendingRemove))
playNewBgm(); playNewBgm();
}; };
this.time.delayedCall(this.fadeOutBgm(500, true) ? 750 : 250, onBgmFaded); this.time.delayedCall(this.fadeOutBgm(500, true) ? 750 : 250, onBgmFaded);
@ -1005,7 +1005,7 @@ export default class BattleScene extends Phaser.Scene {
} }
pauseBgm(): boolean { pauseBgm(): boolean {
if (this.bgm && this.bgm.isPlaying) { if (this.bgm && !this.bgm.pendingRemove && this.bgm.isPlaying) {
this.bgm.pause(); this.bgm.pause();
return true; return true;
} }
@ -1013,7 +1013,7 @@ export default class BattleScene extends Phaser.Scene {
} }
resumeBgm(): boolean { resumeBgm(): boolean {
if (this.bgm && this.bgm.isPaused) { if (this.bgm && !this.bgm.pendingRemove && this.bgm.isPaused) {
this.bgm.resume(); this.bgm.resume();
return true; return true;
} }