import type { AssetLoader, Texture } from '@rpg/engine';
import { DECOR, TILES } from './map';
import { ENEMY_KINDS, type EnemyKindId } from './enemies';
import type { HeroTextures } from '../systems/PlayerController';
/**
* Наборы текстур сцены из загруженных ассетов: соответствие «данные ↔ вьюхи»
* живёт здесь, а не в LocationScene. Имена файлов фиксированы арт-библией.
*/
/** Текстуры тайлов из загруженных ассетов (id -> Texture) — для IsometricTileMap. */
export function tileTextures(a: AssetLoader): Map<number, Texture> {
return new Map([
[TILES.GRASS, a.texture('tiles/grass')],
[TILES.GRASS_V1, a.texture('tiles/grass_2')],
[TILES.GRASS_V2, a.texture('tiles/grass_3')],
[TILES.PATH, a.texture('tiles/path')],
[TILES.PATH_V1, a.texture('tiles/path_2')],
[TILES.WATER, a.texture('tiles/water_1')],
[TILES.ASH, a.texture('tiles/ash')],
[TILES.ASH_V1, a.texture('tiles/ash_2')],
[DECOR.TUFT, a.texture('tiles/decor_tuft')],
[DECOR.STONE, a.texture('tiles/decor_stone')],
[DECOR.BALD, a.texture('tiles/decor_bald')],
[TILES.BELLFLOWER, a.texture('tiles/bellflower')],
[TILES.TREE, a.texture('tiles/tree')],
[TILES.TOWER, a.texture('tiles/tower')],
[TILES.HOUSE, a.texture('tiles/house')],
[TILES.FLOOR, a.texture('tiles/floor')],
[TILES.WALL, a.texture('tiles/wall')],
[TILES.WELL, a.texture('tiles/well')]
]);
}
/** Кадры сгустков из атласа chars/clumps_sheet: префиксы — из EnemyKindDef.frames. */
export function enemyTextures(a: AssetLoader): Map<EnemyKindId, [Texture, Texture]> {
const out = new Map<EnemyKindId, [Texture, Texture]>();
for (const kind of Object.values(ENEMY_KINDS)) {
const prefix = kind.frames[0]!.replace(/_\d+$/, ''); // clump_crawler_1 -> clump_crawler
out.set(kind.id, a.frames('chars/clumps_sheet.json', prefix) as [Texture, Texture]);
}
return out;
}
/** Кадры героя из атласа chars/hero_sheet (именованные анимации генератора). */
export function heroTextures(a: AssetLoader): HeroTextures {
return {
down: a.animation('chars/hero_sheet.json', 'hero_walk_down') as [Texture, Texture],
up: a.animation('chars/hero_sheet.json', 'hero_walk_up') as [Texture, Texture],
side: a.animation('chars/hero_sheet.json', 'hero_walk_side') as [Texture, Texture]
};
}