Merge branch 'egg-summary-2' of https://github.com/j-diefenbach/pokerogue_tinylad-fork into egg-summary-2

This commit is contained in:
James Diefenbach 2024-08-31 11:52:40 +10:00
commit aaec973af3
2 changed files with 41 additions and 3 deletions

View File

@ -2732,6 +2732,28 @@ export default class BattleScene extends SceneBase {
(window as any).gameInfo = gameInfo;
}
/**
* This function retrieves the sprite and audio keys for active Pokemon.
* Active Pokemon include both enemy and player Pokemon of the current wave.
* @returns a string array of active sprite and audio keys that should not be deleted
*/
getActiveKeys(): string[] {
const keys: string[] = [];
const playerParty = this.getParty();
playerParty.forEach(p => {
keys.push("pkmn__"+p.species.getSpriteId(p.gender === Gender.FEMALE, p.species.formIndex, p.shiny, p.variant));
keys.push("pkmn__"+p.species.getSpriteId(p.gender === Gender.FEMALE, p.species.formIndex, p.shiny, p.variant, true));
keys.push("cry/"+p.species.getCryKey(p.species.formIndex));
});
// enemyParty has to be operated on separately from playerParty because playerPokemon =/= enemyPokemon
const enemyParty = this.getEnemyParty();
enemyParty.forEach(p => {
keys.push(p.species.getSpriteKey(p.gender === Gender.FEMALE, p.species.formIndex, p.shiny, p.variant));
keys.push("cry/"+p.species.getCryKey(p.species.formIndex));
});
return keys;
}
/**
* Initialized the 2nd phase of the final boss (e.g. form-change for Eternatus)
* @param pokemon The (enemy) pokemon

View File

@ -94,10 +94,26 @@ export default class EggSummaryUiHandler extends MessageUiHandler {
// this.currentPokemonSprite.setVisible(false);
// this.pokemonEggMovesContainer.setVisible(false);
this.getUi().hideTooltip();
// TODO clear EggHatchData
// TODO back sprites and extra sprites etc.
const activeKeys = this.scene.getActiveKeys();
// Removing unnecessary sprites from animation manager
const animKeys = Object.keys(this.scene.anims["anims"]["entries"]);
animKeys.forEach(key => {
if (key.startsWith("pkmn__") && !activeKeys.includes(key)) {
this.scene.anims.remove(key);
}
});
// Removing unnecessary cries from audio cache
const audioKeys = Object.keys(this.scene.cache.audio.entries.entries);
audioKeys.forEach(key => {
if (key.startsWith("cry/") && !activeKeys.includes(key)) {
delete this.scene.cache.audio.entries.entries[key];
}
});
// Clears eggHatchData in EggSummaryUiHandler
this.eggHatchData.length = 0;
// Removes Pokemon icons in EggSummaryUiHandler
this.iconAnimHandler.removeAll();
console.log("Egg Summary Handler cleared");
}
show(args: any[]): boolean {