mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-04 15:32:18 +02:00
Garbage Collection + Eslint/Docs approved.
This commit is contained in:
parent
5718886a2a
commit
6192ba369d
@ -2732,6 +2732,28 @@ export default class BattleScene extends SceneBase {
|
|||||||
(window as any).gameInfo = gameInfo;
|
(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)
|
* Initialized the 2nd phase of the final boss (e.g. form-change for Eternatus)
|
||||||
* @param pokemon The (enemy) pokemon
|
* @param pokemon The (enemy) pokemon
|
||||||
|
@ -94,10 +94,26 @@ export default class EggSummaryUiHandler extends MessageUiHandler {
|
|||||||
// this.currentPokemonSprite.setVisible(false);
|
// this.currentPokemonSprite.setVisible(false);
|
||||||
// this.pokemonEggMovesContainer.setVisible(false);
|
// this.pokemonEggMovesContainer.setVisible(false);
|
||||||
this.getUi().hideTooltip();
|
this.getUi().hideTooltip();
|
||||||
// TODO clear EggHatchData
|
const activeKeys = this.scene.getActiveKeys();
|
||||||
// TODO back sprites and extra sprites etc.
|
// 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");
|
console.log("Egg Summary Handler cleared");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
show(args: any[]): boolean {
|
show(args: any[]): boolean {
|
||||||
|
Loading…
Reference in New Issue
Block a user