Fix biome selection causing bgm-related crash

This commit is contained in:
Flashfyre 2023-10-23 09:00:23 -04:00
parent d3323aadce
commit 00f7bc595b
2 changed files with 12 additions and 7 deletions

View File

@ -453,13 +453,13 @@ export class SelectBiomePhase extends BattlePhase {
start() { start() {
super.start(); super.start();
this.scene.fadeOutBgm(2000, true);
const currentBiome = this.scene.arena.biomeType; const currentBiome = this.scene.arena.biomeType;
const setNextBiome = (nextBiome: Biome) => { const setNextBiome = (nextBiome: Biome) => {
if (this.scene.gameMode === GameMode.CLASSIC) if (this.scene.gameMode === GameMode.CLASSIC)
this.scene.unshiftPhase(new PartyHealPhase(this.scene, false)); this.scene.unshiftPhase(new PartyHealPhase(this.scene, false));
else
this.scene.fadeOutBgm(2000, true);
this.scene.unshiftPhase(new SwitchBiomePhase(this.scene, nextBiome)); this.scene.unshiftPhase(new SwitchBiomePhase(this.scene, nextBiome));
this.end(); this.end();
}; };

View File

@ -867,11 +867,11 @@ export default class BattleScene extends Phaser.Scene {
playNewBgm(); playNewBgm();
}); });
if (fadeOut) { if (fadeOut) {
this.fadeOutBgm(500, true); const onBgmFaded = () => {
this.time.delayedCall(750, () => {
if (loaded && (!this.bgm.isPlaying || this.bgm.pendingRemove)) if (loaded && (!this.bgm.isPlaying || this.bgm.pendingRemove))
playNewBgm(); playNewBgm();
}); };
this.time.delayedCall(this.fadeOutBgm(500, true) ? 750 : 250, onBgmFaded);
} }
if (!this.load.isLoading()) if (!this.load.isLoading())
this.load.start(); this.load.start();
@ -887,7 +887,7 @@ export default class BattleScene extends Phaser.Scene {
this.bgm.resume(); this.bgm.resume();
} }
fadeOutBgm(duration?: integer, destroy?: boolean): void { fadeOutBgm(duration?: integer, destroy?: boolean): boolean {
if (!this.bgm) if (!this.bgm)
return; return;
if (!duration) if (!duration)
@ -895,7 +895,12 @@ export default class BattleScene extends Phaser.Scene {
if (destroy === undefined) if (destroy === undefined)
destroy = true; destroy = true;
const bgm = this.sound.get(this.bgm.key); const bgm = this.sound.get(this.bgm.key);
SoundFade.fadeOut(this, bgm, duration, destroy); if (bgm) {
SoundFade.fadeOut(this, bgm, duration, destroy);
return true;
}
return false;
} }
playSound(soundName: string, config?: object) { playSound(soundName: string, config?: object) {