HumanBreak/src/core/loader/load.ts

35 lines
937 B
TypeScript
Raw Normal View History

2023-06-09 22:59:20 +08:00
import resource from '../../data/resource.json';
2023-06-14 19:20:24 +08:00
import { Resource, getTypeByResource } from './resource';
2023-06-09 22:59:20 +08:00
2023-06-14 19:20:24 +08:00
const info = resource;
2023-06-09 22:59:20 +08:00
2023-06-20 22:35:51 +08:00
/**
*
*/
2023-06-09 22:59:20 +08:00
export function readyAllResource() {
2023-06-21 17:10:06 +08:00
/* @__PURE__ */ if (main.RESOURCE_TYPE === 'dev') return readyDevResource();
2023-06-15 12:35:43 +08:00
info.resource.forEach(v => {
2023-06-14 19:20:24 +08:00
const type = getTypeByResource(v);
if (type === 'zip') {
ancTe.zipResource.set(v, new Resource(v, 'zip'));
2023-06-09 22:59:20 +08:00
} else {
2023-06-14 19:20:24 +08:00
ancTe.resource.set(v, new Resource(v, type));
2023-06-09 22:59:20 +08:00
}
});
}
2023-06-20 22:35:51 +08:00
/**
*
*/
2023-06-21 17:10:06 +08:00
/* @__PURE__ */ async function readyDevResource() {
const loadData = (await import('../../data/resource-dev.json')).default;
loadData.forEach(v => {
const type = getTypeByResource(v);
if (type !== 'zip') {
ancTe.resource.set(v, new Resource(v, type));
}
});
ancTe.resource.forEach(v => v.active());
}