Compare commits

...

2 Commits

Author SHA1 Message Date
James Diefenbach
547bc145c1 changed loading to be on demand from cursor nav 2024-08-31 17:41:32 +10:00
James Diefenbach
46f39b57bc more detailed loading logs 2024-08-31 17:22:47 +10:00
4 changed files with 39 additions and 28 deletions

View File

@ -458,6 +458,7 @@ export abstract class PokemonSpeciesForm {
loadAssets(scene: BattleScene, female: boolean, formIndex?: integer, shiny?: boolean, variant?: Variant, startLoad?: boolean): Promise<void> {
return new Promise(resolve => {
console.time("fetching assets " + this.speciesId);
const spriteKey = this.getSpriteKey(female, formIndex, shiny, variant);
scene.loadPokemonAtlas(spriteKey, this.getSpriteAtlasPath(female, formIndex, shiny, variant));
scene.load.audio(`cry/${this.getCryKey(formIndex)}`, `audio/cry/${this.getCryKey(formIndex)}.m4a`);
@ -498,6 +499,8 @@ export abstract class PokemonSpeciesForm {
populateVariantColors(spriteKey).then(() => resolve());
return;
}
console.timeEnd("fetching assets " + this.speciesId);
resolve();
});
if (startLoad) {

View File

@ -362,7 +362,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
loadAssets(ignoreOverride: boolean = true): Promise<void> {
return new Promise(resolve => {
console.time("total asset loading for " + this.name + (this.shiny ? "" : "shiny"));
const moveIds = this.getMoveset().map(m => m!.getMove().id); // TODO: is this bang correct?
console.time("loading moves " + this.name);
Promise.allSettled(moveIds.map(m => initMoveAnim(this.scene, m)))
.then(() => {
loadMoveAnimAssets(this.scene, moveIds);
@ -392,10 +394,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
}
this.playAnim();
const updateFusionPaletteAndResolve = () => {
console.time("fusion loading " + this.name);
this.updateFusionPalette();
if (this.summonData?.speciesForm) {
this.updateFusionPalette(true);
}
console.timeEnd("fusion loading " + this.name);
console.timeEnd("total asset loading for " + this.name + (this.shiny ? "" : "shiny"));
resolve();
};
if (this.shiny) {

View File

@ -92,29 +92,29 @@ export class EggLapsePhase extends Phase {
}
console.time("loading assets " + pokemon.name + " " + eggsRemaining);
pokemon.loadAssets().then(() => {
this.loadsWaiting--;
console.log(this.loadsWaiting);
console.timeEnd("loading assets " + pokemon.name + " " + eggsRemaining);
// pokemon.loadAssets().then(() => {
this.loadsWaiting--;
console.log(this.loadsWaiting);
console.timeEnd("loading assets " + pokemon.name + " " + eggsRemaining);
if (this.loadsWaiting === 0) {
console.timeEnd("hatch eggs");
this.showSummary();
}
if (this.loadsWaiting === 0) {
console.timeEnd("hatch eggs");
this.showSummary();
}
if (pokemon.species.subLegendary) {
this.scene.validateAchv(achvs.HATCH_SUB_LEGENDARY);
}
if (pokemon.species.legendary) {
this.scene.validateAchv(achvs.HATCH_LEGENDARY);
}
if (pokemon.species.mythical) {
this.scene.validateAchv(achvs.HATCH_MYTHICAL);
}
if (pokemon.isShiny()) {
this.scene.validateAchv(achvs.HATCH_SHINY);
}
});
if (pokemon.species.subLegendary) {
this.scene.validateAchv(achvs.HATCH_SUB_LEGENDARY);
}
if (pokemon.species.legendary) {
this.scene.validateAchv(achvs.HATCH_LEGENDARY);
}
if (pokemon.species.mythical) {
this.scene.validateAchv(achvs.HATCH_MYTHICAL);
}
if (pokemon.isShiny()) {
this.scene.validateAchv(achvs.HATCH_SHINY);
}
// });
}

View File

@ -128,14 +128,17 @@ export default class PokemonHatchInfoContainer extends PokemonInfoContainer {
const formIndex = pokemon.formIndex;
const shiny = pokemon.shiny;
const variant = pokemon.variant;
this.currentPokemonSprite.setVisible(false);
species.loadAssets(this.scene, female, formIndex, shiny, variant, true).then(() => {
getPokemonSpeciesForm(species.speciesId, pokemon.formIndex).cry(this.scene);
this.currentPokemonSprite.play(species.getSpriteKey(female, formIndex, shiny, variant));
this.currentPokemonSprite.setPipelineData("shiny", shiny);
this.currentPokemonSprite.setPipelineData("variant", variant);
this.currentPokemonSprite.setPipelineData("spriteKey", species.getSpriteKey(female, formIndex, shiny, variant));
this.currentPokemonSprite.setVisible(true);
console.timeEnd("display pokemon" + pokemon.name);
getPokemonSpeciesForm(species.speciesId, pokemon.formIndex).cry(this.scene);
this.currentPokemonSprite.play(species.getSpriteKey(female, formIndex, shiny, variant));
this.currentPokemonSprite.setPipelineData("shiny", shiny);
this.currentPokemonSprite.setPipelineData("variant", variant);
this.currentPokemonSprite.setPipelineData("spriteKey", species.getSpriteKey(female, formIndex, shiny, variant));
this.currentPokemonSprite.setVisible(true);
console.timeEnd("display pokemon" + pokemon.name);
});
}
/**