implement player entity

This commit is contained in:
MihailRis
2024-07-08 18:45:35 +03:00
parent 49aa64a033
commit 487ba84517
8 changed files with 24 additions and 12 deletions
+6 -3
View File
@@ -273,7 +273,7 @@ dynamic::Value scripting::get_component_value(const scriptenv& env, const std::s
}
void scripting::on_entity_spawn(
const EntityDef& def,
const EntityDef&,
entityid_t eid,
const std::vector<std::unique_ptr<UserComponent>>& components,
dynamic::Value args,
@@ -285,9 +285,12 @@ void scripting::on_entity_spawn(
lua::pushinteger(L, eid);
lua::call(L, 1);
}
for (size_t i = 0; i < components.size()-1; i++) {
lua::pushvalue(L, -1);
if (components.size() > 1) {
for (int i = 0; i < components.size()-1; i++) {
lua::pushvalue(L, -1);
}
}
std::cout << "entity duplicated " << (components.size()-1) << " times" << std::endl;
for (auto& component : components) {
auto compenv = create_component_environment(get_root_environment(), -1,
component->name);