Merge branch 'beta' into eventrefactoring

This commit is contained in:
damocleas 2025-01-16 11:06:25 -05:00 committed by GitHub
commit 171463cd27
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 22 additions and 19 deletions

Binary file not shown.

View File

@ -363,28 +363,30 @@ export default class BattleScene extends SceneBase {
/**
* Load the variant assets for the given sprite and stores them in {@linkcode variantColorCache}
*/
loadPokemonVariantAssets(spriteKey: string, fileRoot: string, variant?: Variant) {
public async loadPokemonVariantAssets(spriteKey: string, fileRoot: string, variant?: Variant): Promise<void> {
const useExpSprite = this.experimentalSprites && this.hasExpSprite(spriteKey);
if (useExpSprite) {
fileRoot = `exp/${fileRoot}`;
}
let variantConfig = variantData;
fileRoot.split("/").map(p => variantConfig ? variantConfig = variantConfig[p] : null);
fileRoot.split("/").map((p) => (variantConfig ? (variantConfig = variantConfig[p]) : null));
const variantSet = variantConfig as VariantSet;
if (variantSet && (variant !== undefined && variantSet[variant] === 1)) {
const populateVariantColors = (key: string): Promise<void> => {
return new Promise(resolve => {
if (variantColorCache.hasOwnProperty(key)) {
return new Promise<void>((resolve) => {
if (variantSet && variant !== undefined && variantSet[variant] === 1) {
if (variantColorCache.hasOwnProperty(spriteKey)) {
return resolve();
}
this.cachedFetch(`./images/pokemon/variant/${fileRoot}.json`).then(res => res.json()).then(c => {
variantColorCache[key] = c;
this.cachedFetch(`./images/pokemon/variant/${fileRoot}.json`)
.then((res) => res.json())
.then((c) => {
variantColorCache[spriteKey] = c;
resolve();
});
});
};
populateVariantColors(spriteKey);
} else {
resolve();
}
});
}
async preload() {

View File

@ -516,8 +516,7 @@ export abstract class PokemonSpeciesForm {
globalScene.anims.get(spriteKey).frameRate = 10;
}
const spritePath = this.getSpriteAtlasPath(female, formIndex, shiny, variant).replace("variant/", "").replace(/_[1-3]$/, "");
globalScene.loadPokemonVariantAssets(spriteKey, spritePath, variant);
resolve();
globalScene.loadPokemonVariantAssets(spriteKey, spritePath, variant).then(() => resolve());
});
if (startLoad) {
if (!globalScene.load.isLoading()) {

View File

@ -215,11 +215,12 @@ export default class MysteryEncounterIntroVisuals extends Phaser.GameObjects.Con
resolve();
}
const shinyPromises: Promise<void>[] = [];
this.spriteConfigs.forEach((config) => {
if (config.isPokemon) {
globalScene.loadPokemonAtlas(config.spriteKey, config.fileRoot);
if (config.isShiny) {
globalScene.loadPokemonVariantAssets(config.spriteKey, config.fileRoot, config.variant);
shinyPromises.push(globalScene.loadPokemonVariantAssets(config.spriteKey, config.fileRoot, config.variant));
}
} else if (config.isItem) {
globalScene.loadAtlas("items", "");
@ -254,7 +255,7 @@ export default class MysteryEncounterIntroVisuals extends Phaser.GameObjects.Con
return true;
});
resolve();
Promise.all(shinyPromises).then(() => resolve());
});
if (!globalScene.load.isLoading()) {

View File

@ -319,6 +319,7 @@ export class LoadingScene extends SceneBase {
this.loadSe("pb_move");
this.loadSe("pb_catch");
this.loadSe("pb_lock");
this.loadSe("crit_throw");
this.loadSe("pb_tray_enter");
this.loadSe("pb_tray_ball");

View File

@ -64,7 +64,7 @@ export class AttemptCapturePhase extends PokemonPhase {
this.pokeball.setOrigin(0.5, 0.625);
globalScene.field.add(this.pokeball);
globalScene.playSound("se/pb_throw", isCritical ? { rate: 0.2 } : undefined); // Crit catch throws are higher pitched
globalScene.playSound(isCritical ? "se/crit_throw" : "se/pb_throw");
globalScene.time.delayedCall(300, () => {
globalScene.field.moveBelow(this.pokeball as Phaser.GameObjects.GameObject, pokemon);
});