11 lines
450 B
TypeScript
11 lines
450 B
TypeScript
import { type SpriteRegion, TEXTURE_SIZE } from "$/common/constants.ts";
|
|
import { AssetManager } from "./assets.ts";
|
|
|
|
type TexturesInfo = Record<string, SpriteRegion>;
|
|
|
|
export function get_sprite_region(id: string): SpriteRegion {
|
|
const textures_info = AssetManager.instance.get<TexturesInfo>("bworld:textures_info");
|
|
return textures_info?.[id] ?? textures_info?.["engine:missing"] ??
|
|
{ x: 0, y: 0, width: TEXTURE_SIZE, height: TEXTURE_SIZE };
|
|
}
|