mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-07 12:01:50 +00:00
add test entities prototype
This commit is contained in:
parent
6f618ae3ff
commit
ba458be334
7 changed files with 121 additions and 1 deletions
57
src/objects/Entities.hpp
Normal file
57
src/objects/Entities.hpp
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#ifndef OBJECTS_ENTITIES_HPP_
|
||||
#define OBJECTS_ENTITIES_HPP_
|
||||
|
||||
#include "../typedefs.hpp"
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <unordered_map>
|
||||
#include <entt/entity/registry.hpp>
|
||||
|
||||
struct EntityId {
|
||||
entityid_t uid;
|
||||
};
|
||||
|
||||
struct Transform {
|
||||
glm::vec3 pos;
|
||||
glm::vec3 size;
|
||||
glm::mat3 rot;
|
||||
glm::mat4 combined;
|
||||
|
||||
void refresh();
|
||||
};
|
||||
|
||||
class Level;
|
||||
class Assets;
|
||||
class ModelBatch;
|
||||
|
||||
class Entity {
|
||||
entt::registry& registry;
|
||||
entt::entity entity;
|
||||
public:
|
||||
Entity(entt::registry& registry, entt::entity entity)
|
||||
: registry(registry), entity(entity) {}
|
||||
|
||||
bool isValid() const {
|
||||
return registry.valid(entity);
|
||||
}
|
||||
|
||||
Transform& getTransform() const {
|
||||
return registry.get<Transform>(entity);
|
||||
}
|
||||
|
||||
entityid_t getUID() const {
|
||||
return registry.get<EntityId>(entity).uid;
|
||||
}
|
||||
};
|
||||
|
||||
class Entities {
|
||||
entt::registry registry;
|
||||
Level* level;
|
||||
std::unordered_map<entityid_t, entt::entity> entities;
|
||||
public:
|
||||
Entities(Level* level);
|
||||
void updatePhysics(float delta);
|
||||
void render(Assets* assets, ModelBatch& batch);
|
||||
};
|
||||
|
||||
#endif // OBJECTS_ENTITIES_HPP_
|
||||
Loading…
Add table
Add a link
Reference in a new issue