@@ -59,8 +59,10 @@ export function loadJsonOnce(scene, key, url) {
5959 if ( ! scene . cache . json . exists ( key ) ) scene . load . json ( key , url ) ;
6060}
6161
62- const IMAGE_EXTENSIONS = new Set ( [ "jpg" , "jpeg" , "png" , "webp" , "svg" ] ) ;
63- const ATLAS_EXTENSIONS = new Set ( [ "png" , "webp" ] ) ;
62+ const IMAGE_EXTENSIONS = new Set ( [ "jpg" , "jpeg" , "png" , "webp" , "svg" , "gif" ] ) ;
63+ const ATLAS_EXTENSIONS = new Set ( [ "png" , "webp" , "jpg" , "jpeg" , "svg" , "gif" ] ) ;
64+
65+ import { characters } from "../characters/CharacterRegistry.js" ;
6466
6567/**
6668 * @param {string } name
@@ -82,6 +84,7 @@ function resolveAssetName(name, fallbackExtension, allowedExtensions) {
8284 if ( ext && allowedExtensions . has ( ext ) ) {
8385 return { file : name , stem : name . slice ( 0 , - ext . length - 1 ) } ;
8486 }
87+ // If no extension, or unrecognised extension, assume the requested fallback
8588 return { file : `${ name } .${ fallbackExtension } ` , stem : name } ;
8689}
8790
@@ -244,6 +247,21 @@ export function collectChapterAssetKeys(manager, chapter) {
244247 keys . add ( bg ) ;
245248 for ( const a of cfg . assets ?? [ ] ) keys . add ( a ) ;
246249 }
250+
251+ // Auto-include playable characters, as they can appear in any scene
252+ for ( const id of characters . playableIds ( ) ) {
253+ const conf = characters . get ( id ) ;
254+ if ( conf ?. spriteKey ) keys . add ( conf . spriteKey ) ;
255+ if ( conf ?. animationSet ) {
256+ for ( const dir of Object . values ( conf . animationSet ) ) {
257+ if ( dir . still ) keys . add ( dir . still ) ;
258+ if ( dir . idle ) keys . add ( dir . idle ) ;
259+ if ( dir . walk ) keys . add ( dir . walk ) ;
260+ if ( dir . reach ) keys . add ( dir . reach ) ;
261+ }
262+ }
263+ }
264+
247265 return keys ;
248266}
249267
0 commit comments