mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 02:51:49 +00:00
add packs resources (WIP)
This commit is contained in:
parent
30dd853044
commit
ca8652ffab
13 changed files with 103 additions and 16 deletions
|
|
@ -478,9 +478,28 @@ void ContentLoader::load() {
|
|||
fs::path scriptfile = entry.path();
|
||||
if (fs::is_regular_file(scriptfile)) {
|
||||
auto name = pack->id+":"+scriptfile.stem().u8string();
|
||||
std::cout << name << std::endl;
|
||||
scripting::load_entity_component(name, scriptfile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fs::path resourcesFile = folder / fs::u8path("resources.json");
|
||||
if (fs::exists(resourcesFile)) {
|
||||
auto resRoot = files::read_json(resourcesFile);
|
||||
for (const auto& [key, _] : resRoot->values) {
|
||||
if (auto resType = ResourceType_from(key)) {
|
||||
if (auto arr = resRoot->list(key)) {
|
||||
loadResources(*resType, arr.get());
|
||||
}
|
||||
} else {
|
||||
logger.warning() << "unknown resource type: " << key;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ContentLoader::loadResources(ResourceType type, dynamic::List* list) {
|
||||
for (size_t i = 0; i < list->size(); i++) {
|
||||
builder.resourceIndices[static_cast<size_t>(type)].add(list->str(i));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue