Add back bgm pending remove checks

This commit is contained in:
Flashfyre 2023-11-11 21:04:20 -05:00
parent 2987c8ec93
commit ff93e6233f

View File

@ -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;
}