mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
add entity library
This commit is contained in:
parent
eacbc1b9d0
commit
8e931d8f53
5 changed files with 63 additions and 11 deletions
|
|
@ -20,16 +20,16 @@ void Transform::refresh() {
|
|||
Entities::Entities(Level* level) : level(level) {
|
||||
}
|
||||
|
||||
void Entities::drop(glm::vec3 pos, glm::vec3 vel) {
|
||||
entityid_t Entities::drop(glm::vec3 pos) {
|
||||
auto entity = registry.create();
|
||||
glm::vec3 size(1);
|
||||
registry.emplace<EntityId>(entity, static_cast<entityid_t>(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));
|
||||
|
||||
auto& hitbox = registry.get<Hitbox>(entity);
|
||||
hitbox.velocity = vel;
|
||||
entities[id] = entity;
|
||||
return id;
|
||||
}
|
||||
|
||||
void Entities::updatePhysics(float delta){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue