mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 02:51:49 +00:00
add component ARGS variable
This commit is contained in:
parent
da6b014d62
commit
1b41a75cf4
6 changed files with 24 additions and 7 deletions
|
|
@ -30,7 +30,7 @@ void Entity::destroy() {
|
|||
Entities::Entities(Level* level) : level(level) {
|
||||
}
|
||||
|
||||
entityid_t Entities::spawn(EntityDef& def, glm::vec3 pos) {
|
||||
entityid_t Entities::spawn(EntityDef& def, glm::vec3 pos, dynamic::Value args) {
|
||||
auto entity = registry.create();
|
||||
glm::vec3 size(1);
|
||||
auto id = nextID++;
|
||||
|
|
@ -55,7 +55,7 @@ entityid_t Entities::spawn(EntityDef& def, glm::vec3 pos) {
|
|||
}
|
||||
auto& scripting = registry.emplace<Scripting>(entity, entity_funcs_set {}, nullptr);
|
||||
entities[id] = entity;
|
||||
scripting.env = scripting::on_entity_spawn(def, id, scripting.funcsset);
|
||||
scripting.env = scripting::on_entity_spawn(def, id, scripting.funcsset, std::move(args));
|
||||
return id;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "../typedefs.hpp"
|
||||
#include "../physics/Hitbox.hpp"
|
||||
#include "../data/dynamic.hpp"
|
||||
|
||||
#include <vector>
|
||||
#include <optional>
|
||||
|
|
@ -131,7 +132,7 @@ public:
|
|||
void renderDebug(LineBatch& batch, const Frustum& frustum);
|
||||
void render(Assets* assets, ModelBatch& batch, const Frustum& frustum);
|
||||
|
||||
entityid_t spawn(EntityDef& def, glm::vec3 pos);
|
||||
entityid_t spawn(EntityDef& def, glm::vec3 pos, dynamic::Value args=dynamic::NONE);
|
||||
|
||||
std::optional<Entity> get(entityid_t id) {
|
||||
const auto& found = entities.find(id);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue