mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-21 09:59:44 +00:00
add entity.properties
This commit is contained in:
parent
3edb96e291
commit
283e3c041e
5 changed files with 84 additions and 11 deletions
|
|
@ -123,6 +123,13 @@ std::unique_ptr<Content> ContentBuilder::build() {
|
|||
def->properties["script-file"] = def->scriptFile;
|
||||
}
|
||||
|
||||
for (EntityDef* def : entityDefsIndices) {
|
||||
if (def->properties == nullptr) {
|
||||
def->properties = dv::object();
|
||||
}
|
||||
def->properties["name"] = def->name;
|
||||
}
|
||||
|
||||
for (auto& [name, def] : content->generators.getDefs()) {
|
||||
def->prepare(content.get());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#define VC_ENABLE_REFLECTION
|
||||
#include "ContentUnitLoader.hpp"
|
||||
#include "ContentLoadingCommons.hpp"
|
||||
|
||||
#include "../ContentBuilder.hpp"
|
||||
#include "coders/json.hpp"
|
||||
|
|
@ -16,6 +17,7 @@ template<> void ContentUnitLoader<EntityDef>::loadUnit(
|
|||
EntityDef& def, const std::string& name, const io::path& file
|
||||
) {
|
||||
auto root = io::read_json(file);
|
||||
process_properties(def, name, root);
|
||||
|
||||
if (root.has("parent")) {
|
||||
const auto& parentName = root["parent"].asString();
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include "world/Level.hpp"
|
||||
#include "world/World.hpp"
|
||||
#include "interfaces/Process.hpp"
|
||||
#include "objects/EntityDef.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
|
@ -298,6 +299,11 @@ void scripting::on_content_load(Content* content) {
|
|||
lua::setfield(L, "properties");
|
||||
lua::pop(L);
|
||||
}
|
||||
if (lua::getglobal(L, "entities")) {
|
||||
push_properties_tables(L, indices.entities);
|
||||
lua::setfield(L, "properties");
|
||||
lua::pop(L);
|
||||
}
|
||||
|
||||
lua::getregistry(L, "app");
|
||||
lua::setglobal(L, "__vc_app");
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ struct EntityDef {
|
|||
/// @brief Entity string id (with prefix included)
|
||||
std::string const name;
|
||||
|
||||
dv::value properties = nullptr;
|
||||
|
||||
/// @brief Component instances
|
||||
std::vector<ComponentInstance> components;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue