add drop.json
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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,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;
|
||||
|
||||
Reference in New Issue
Block a user