time logging and optimisation

This commit is contained in:
James Diefenbach 2024-08-31 11:51:40 +10:00
parent 5718886a2a
commit ab5f252f16
5 changed files with 13 additions and 11 deletions

View File

@ -36,9 +36,11 @@ export class EggLapsePhase extends Phase {
// show prompt for skip
this.scene.ui.showText(i18next.t("battle:eggSkipPrompt"), 0);
this.scene.ui.setModeWithoutClear(Mode.CONFIRM, () => {
console.time("hatch eggs");
for (const egg of eggsToHatch) {
this.hatchEggSilently(egg);
}
console.timeEnd("hatch eggs");
this.scene.unshiftPhase(new EggSummaryPhase(this.scene, this.eggHatchData));
this.end();
@ -62,9 +64,6 @@ export class EggLapsePhase extends Phase {
}
this.end();
}
console.log(this.eggHatchData);
} else {
this.end();
}
@ -88,7 +87,6 @@ export class EggLapsePhase extends Phase {
if (pokemon.fusionSpecies) {
pokemon.clearFusionSpecies();
}
console.log(pokemon);
pokemon.loadAssets().then(() => {

View File

@ -21,11 +21,12 @@ export class EggSummaryPhase extends Phase {
start() {
super.start();
console.time("update egg dex");
const updateNextPokemon = (i: integer) => {
console.log(i);
if (i >= this.eggHatchData.length) {
console.log("displayed all pokemon");
console.timeEnd("update egg dex");
this.scene.ui.setModeForceTransition(Mode.EGG_HATCH_SUMMARY, this.eggHatchData).then(() => {
this.scene.fadeOutBgm(undefined, false);
this.eggHatchHandler = this.scene.ui.getHandler() as EggHatchSceneHandler;
@ -35,7 +36,6 @@ export class EggSummaryPhase extends Phase {
} else {
this.eggHatchData[i].setDex();
this.eggHatchData[i].updatePokemon().then(() => {
console.log("updating next pokemon");
if (i < this.eggHatchData.length) {
updateNextPokemon(i + 1);
}

View File

@ -1618,12 +1618,10 @@ export class GameData {
}
const checkPrevolution = () => {
console.log("checking prevolution");
if (hasPrevolution) {
const prevolutionSpecies = pokemonPrevolutions[species.speciesId];
this.setPokemonSpeciesCaught(pokemon, getPokemonSpecies(prevolutionSpecies), incrementCount, fromEgg, showMessage).then(() => resolve());
} else {
console.log("resolving");
resolve();
}
};

View File

@ -140,6 +140,7 @@ export default class EggSummaryUiHandler extends MessageUiHandler {
this.eggHatchBg.setVisible(true);
this.infoContainer.hideDisplayPokemon();
console.time("display icons");
this.eggHatchData.forEach( (value: EggHatchData, i: number) => {
const x = (i % 11) * 18;
@ -213,6 +214,8 @@ export default class EggSummaryUiHandler extends MessageUiHandler {
em.setVisible(value.eggMoveUnlocked);
this.pokemonIconsContainer.add(em);
});
console.timeEnd("display icons");
this.setCursor(0);
// TODO nice animation reveal for all eggs hatching at once
@ -226,7 +229,6 @@ export default class EggSummaryUiHandler extends MessageUiHandler {
let success = false;
const error = false;
console.log("egg handler button " + button);
if (button === Button.CANCEL) {
const phase = this.scene.getCurrentPhase();
if (phase instanceof EggSummaryPhase) {

View File

@ -134,6 +134,7 @@ export default class PokemonHatchInfoContainer extends PokemonInfoContainer {
* Display a given pokemon sprite with animations
*/
displayPokemon(pokemon: PlayerPokemon) {
console.time("display pokemon" + pokemon.name);
console.log("displaying pokemon", pokemon.name);
const species = pokemon.species;
const female = pokemon.gender === Gender.FEMALE;
@ -146,6 +147,7 @@ export default class PokemonHatchInfoContainer extends PokemonInfoContainer {
species.loadAssets(this.scene, female, formIndex, shiny, variant, true).then(() => {
if (assetLoadCancelled.value) {
console.log("interrupted");
console.timeEnd("display pokemon" + pokemon.name);
return;
}
this.assetLoadCancelled = null;
@ -157,6 +159,7 @@ export default class PokemonHatchInfoContainer extends PokemonInfoContainer {
this.currentPokemonSprite.setPipelineData("shiny", shiny);
this.currentPokemonSprite.setPipelineData("variant", variant);
this.currentPokemonSprite.setPipelineData("spriteKey", species.getSpriteKey(female, formIndex, shiny, variant));
console.timeEnd("display pokemon" + pokemon.name);
// this.pokemonSprite.setVisible(!this.statsMode);
});
}
@ -167,7 +170,7 @@ export default class PokemonHatchInfoContainer extends PokemonInfoContainer {
* @param hatchInfo The EggHatchData of the pokemon / new hatch to show
*/
showHatchInfo(hatchInfo: EggHatchData) {
console.log("showing hatch info", hatchInfo.pokemon.name);
console.time("show hatch info" + hatchInfo.pokemon.name);
this.pokemonEggMovesContainer.setVisible(true);
const pokemon = hatchInfo.pokemon;
@ -208,6 +211,7 @@ export default class PokemonHatchInfoContainer extends PokemonInfoContainer {
} else {
this.pokemonHatchedIcon.setFrame(getEggTierForSpecies(species));
}
console.timeEnd("show hatch info" + hatchInfo.pokemon.name);
}