[Enhancement] Remove unnecessary loading of trainer sprites in loading scene (#4397)

* Remove unnecessary loading of trainer sprites in loading scene

* load trainer assets on demand for run history UI

---------

Co-authored-by: ImperialSympathizer <imperialsympathizer@gmail.com>
This commit is contained in:
ImperialSympathizer 2024-09-23 17:34:47 -04:00 committed by GitHub
parent eb264cffee
commit 23f006bc43
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 29 deletions

View File

@ -1,5 +1,4 @@
import { GachaType } from "./enums/gacha-types"; import { GachaType } from "./enums/gacha-types";
import { trainerConfigs } from "./data/trainer-config";
import { getBiomeHasProps } from "./field/arena"; import { getBiomeHasProps } from "./field/arena";
import CacheBustedLoaderPlugin from "./plugins/cache-busted-loader-plugin"; import CacheBustedLoaderPlugin from "./plugins/cache-busted-loader-plugin";
import { SceneBase } from "./scene-base"; import { SceneBase } from "./scene-base";
@ -21,7 +20,6 @@ import i18next from "i18next";
import { initStatsKeys } from "./ui/game-stats-ui-handler"; import { initStatsKeys } from "./ui/game-stats-ui-handler";
import { initVouchers } from "./system/voucher"; import { initVouchers } from "./system/voucher";
import { Biome } from "#enums/biome"; import { Biome } from "#enums/biome";
import { TrainerType } from "#enums/trainer-type";
import {initMysteryEncounters} from "#app/data/mystery-encounters/mystery-encounters"; import {initMysteryEncounters} from "#app/data/mystery-encounters/mystery-encounters";
export class LoadingScene extends SceneBase { export class LoadingScene extends SceneBase {
@ -208,14 +206,6 @@ export class LoadingScene extends SceneBase {
this.loadAtlas("trainer_f_back", "trainer"); this.loadAtlas("trainer_f_back", "trainer");
this.loadAtlas("trainer_f_back_pb", "trainer"); this.loadAtlas("trainer_f_back_pb", "trainer");
Utils.getEnumValues(TrainerType).map(tt => {
const config = trainerConfigs[tt];
this.loadAtlas(config.getSpriteKey(), "trainer");
if (config.doubleOnly || config.hasDouble) {
this.loadAtlas(config.getSpriteKey(true), "trainer");
}
});
// Load character sprites // Load character sprites
this.loadAtlas("c_rival_m", "character", "rival_m"); this.loadAtlas("c_rival_m", "character", "rival_m");
this.loadAtlas("c_rival_f", "character", "rival_f"); this.loadAtlas("c_rival_f", "character", "rival_f");

View File

@ -288,6 +288,9 @@ export default class RunInfoUiHandler extends UiHandler {
private parseTrainerDefeat(enemyContainer: Phaser.GameObjects.Container) { private parseTrainerDefeat(enemyContainer: Phaser.GameObjects.Container) {
// Creating the trainer sprite and adding it to enemyContainer // Creating the trainer sprite and adding it to enemyContainer
const tObj = this.runInfo.trainer.toTrainer(this.scene); const tObj = this.runInfo.trainer.toTrainer(this.scene);
// Loads trainer assets on demand, as they are not loaded by default in the scene
tObj.config.loadAssets(this.scene, this.runInfo.trainer.variant).then(() => {
const tObjSpriteKey = tObj.config.getSpriteKey(this.runInfo.trainer.variant === TrainerVariant.FEMALE, false); const tObjSpriteKey = tObj.config.getSpriteKey(this.runInfo.trainer.variant === TrainerVariant.FEMALE, false);
const tObjSprite = this.scene.add.sprite(0, 5, tObjSpriteKey); const tObjSprite = this.scene.add.sprite(0, 5, tObjSpriteKey);
if (this.runInfo.trainer.variant === TrainerVariant.DOUBLE) { if (this.runInfo.trainer.variant === TrainerVariant.DOUBLE) {
@ -307,6 +310,7 @@ export default class RunInfoUiHandler extends UiHandler {
tObjSprite.setPosition(12, 28); tObjSprite.setPosition(12, 28);
enemyContainer.add(tObjSprite); enemyContainer.add(tObjSprite);
} }
});
// Determining which Terastallize Modifier belongs to which Pokemon // Determining which Terastallize Modifier belongs to which Pokemon
// Creates a dictionary {PokemonId: TeraShardType} // Creates a dictionary {PokemonId: TeraShardType}