From dee50239be8fff566b3ca687bc70900b391a8164 Mon Sep 17 00:00:00 2001 From: LaG1924 <12997935+LaG1924@users.noreply.github.com> Date: Wed, 16 Aug 2017 20:11:07 +0500 Subject: 2017-08-16 --- src/World.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/World.cpp') diff --git a/src/World.cpp b/src/World.cpp index 17f9cd2..3eff5dd 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -169,7 +169,40 @@ glm::vec3 World::Raycast(glm::vec3 position, glm::vec3 direction, float maxLengt void World::UpdatePhysics(float delta) { + delta /= 5; for (auto& it : entities) { it.pos = it.pos + it.vel * delta; } } + +Entity & World::GetEntity(unsigned int EntityId) +{ + for (auto& it : entities) { + if (it.entityId == EntityId) { + return it; + } + } + static Entity fallback; + return fallback; +} + +std::vector World::GetEntitiesList() +{ + std::vector ret; + for (auto& it : entities) { + ret.push_back(it.entityId); + } + return ret; +} + +void World::AddEntity(Entity entity) +{ + for (auto& it : entities) { + if (it.entityId == entity.entityId) { + LOG(ERROR) << "Adding already existing entity" << entity.entityId; + return; + } + } + entities.push_back(entity); + +} -- cgit v1.2.3