HumanBreak/src/core/loader/load.ts

28 lines
802 B
TypeScript
Raw Normal View History

2023-06-09 22:59:20 +08:00
import resource from '../../data/resource.json';
2023-06-11 20:23:13 +08:00
import { NonZipResource, Resource, getTypeByResource } from './resource';
2023-06-09 22:59:20 +08:00
const info = resource as ResourceInfo[];
export interface ResourceInfo {
includes: string[];
zip: boolean;
zippedName?: string;
}
export function readyAllResource() {
info.forEach(v => {
if (v.zip) {
2023-06-11 20:23:13 +08:00
const id = `zip.${v.zippedName}`;
ancTe.zipResource.push([[id, new Resource(id, 'zip')]]);
2023-06-09 22:59:20 +08:00
} else {
2023-06-11 20:23:13 +08:00
const res: [string, Resource<NonZipResource>][] = v.includes.map(
v => {
const type = getTypeByResource(v);
return [v, new Resource(v, type as NonZipResource)];
}
);
2023-06-09 22:59:20 +08:00
ancTe.resource.push(res);
}
});
}