add drop.json

This commit is contained in:
MihailRis
2024-06-27 03:09:16 +03:00
parent 8d41f6af11
commit 20ab48ecab
8 changed files with 28 additions and 13 deletions
+3 -3
View File
@@ -8,6 +8,7 @@
#include "../graphics/core/LineBatch.hpp"
#include "../graphics/core/Model.hpp"
#include "../maths/FrustumCulling.hpp"
#include "../objects/EntityDef.hpp"
#include <glm/ext/matrix_transform.hpp>
@@ -21,14 +22,13 @@ void Transform::refresh() {
Entities::Entities(Level* level) : level(level) {
}
entityid_t Entities::drop(glm::vec3 pos) {
entityid_t Entities::spawn(EntityDef& def, glm::vec3 pos) {
auto entity = registry.create();
glm::vec3 size(1);
auto id = nextID++;
registry.emplace<EntityId>(entity, static_cast<entityid_t>(id));
registry.emplace<Transform>(entity, pos, size/4.0f, glm::mat3(1.0f));
registry.emplace<Hitbox>(entity, pos,
glm::vec3(size.x*0.2f, size.y*0.5f, size.z*0.2f));
registry.emplace<Hitbox>(entity, pos, def.hitbox);
entities[id] = entity;
return id;
}
+2 -1
View File
@@ -28,6 +28,7 @@ class LineBatch;
class ModelBatch;
class Frustum;
class Rig;
struct EntityDef;
class Entity {
entt::registry& registry;
@@ -65,7 +66,7 @@ public:
void renderDebug(LineBatch& batch);
void render(Assets* assets, ModelBatch& batch, Frustum& frustum);
entityid_t drop(glm::vec3 pos);
entityid_t spawn(EntityDef& def, glm::vec3 pos);
std::optional<Entity> get(entityid_t id) {
const auto& found = entities.find(id);
+2
View File
@@ -2,6 +2,7 @@
#define OBJECTS_ENTITY_DEF_HPP_
#include <string>
#include <glm/glm.hpp>
#include "../typedefs.hpp"
@@ -10,6 +11,7 @@ struct EntityDef {
std::string const name;
std::string scriptName = name.substr(name.find(':')+1);
glm::vec3 hitbox {0.5f};
struct {
entityid_t id;