update components loading scheme
This commit is contained in:
parent
8edf9440a3
commit
0ebc3da7f6
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"components": [
|
"components": [
|
||||||
"drop"
|
"base:drop"
|
||||||
],
|
],
|
||||||
"hitbox": [0.4, 0.25, 0.4],
|
"hitbox": [0.4, 0.25, 0.4],
|
||||||
"sensors": [
|
"sensors": [
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"components": [
|
"components": [
|
||||||
"falling_block"
|
"base:falling_block"
|
||||||
],
|
],
|
||||||
"skeleton-name": "base:block",
|
"skeleton-name": "base:block",
|
||||||
"hitbox": [0.8, 0.8, 0.8]
|
"hitbox": [0.8, 0.8, 0.8]
|
||||||
|
|||||||
@ -355,13 +355,6 @@ void ContentLoader::loadEntity(EntityDef& def, const std::string& full, const st
|
|||||||
auto folder = pack->folder;
|
auto folder = pack->folder;
|
||||||
auto configFile = folder/fs::path("entities/"+name+".json");
|
auto configFile = folder/fs::path("entities/"+name+".json");
|
||||||
if (fs::exists(configFile)) loadEntity(def, full, configFile);
|
if (fs::exists(configFile)) loadEntity(def, full, configFile);
|
||||||
|
|
||||||
for (auto& componentName : def.components) {
|
|
||||||
auto scriptfile = folder/fs::path("scripts/components/"+componentName+".lua");
|
|
||||||
if (fs::is_regular_file(scriptfile)) {
|
|
||||||
scripting::load_entity_component(componentName, scriptfile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentLoader::loadBlock(Block& def, const std::string& full, const std::string& name) {
|
void ContentLoader::loadBlock(Block& def, const std::string& full, const std::string& name) {
|
||||||
@ -478,4 +471,16 @@ void ContentLoader::load() {
|
|||||||
builder.add(rigging::SkeletonConfig::parse(text, file.u8string(), name));
|
builder.add(rigging::SkeletonConfig::parse(text, file.u8string(), name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fs::path componentsDir = folder / fs::u8path("scripts/components");
|
||||||
|
if (fs::is_directory(componentsDir)) {
|
||||||
|
for (const auto& entry : fs::directory_iterator(componentsDir)) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user