mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 02:51:49 +00:00
feat: passing args to component in entity definition
This commit is contained in:
parent
f2aa77db8b
commit
f6be6689aa
5 changed files with 33 additions and 7 deletions
|
|
@ -30,7 +30,18 @@ template<> void ContentUnitLoader<EntityDef>::loadUnit(
|
|||
|
||||
if (auto found = root.at("components")) {
|
||||
for (const auto& elem : *found) {
|
||||
def.components.emplace_back(elem.asString());
|
||||
std::string name;
|
||||
dv::value params;
|
||||
if (elem.isObject()) {
|
||||
name = elem["name"].asString();
|
||||
if (elem.has("args")) {
|
||||
params = elem["args"];
|
||||
}
|
||||
} else {
|
||||
name = elem.asString();
|
||||
}
|
||||
def.components.push_back(ComponentInstance {
|
||||
std::move(name), std::move(params)});
|
||||
}
|
||||
}
|
||||
if (auto found = root.at("hitbox")) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue