summaryrefslogtreecommitdiffstats
path: root/src/World.cpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-08-16 17:11:07 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-08-16 17:11:07 +0200
commitdee50239be8fff566b3ca687bc70900b391a8164 (patch)
tree6ff6ae2e8e2ea5109d031be8c588f4b8f38f68eb /src/World.cpp
parent2017-08-12 (diff)
downloadAltCraft-dee50239be8fff566b3ca687bc70900b391a8164.tar
AltCraft-dee50239be8fff566b3ca687bc70900b391a8164.tar.gz
AltCraft-dee50239be8fff566b3ca687bc70900b391a8164.tar.bz2
AltCraft-dee50239be8fff566b3ca687bc70900b391a8164.tar.lz
AltCraft-dee50239be8fff566b3ca687bc70900b391a8164.tar.xz
AltCraft-dee50239be8fff566b3ca687bc70900b391a8164.tar.zst
AltCraft-dee50239be8fff566b3ca687bc70900b391a8164.zip
Diffstat (limited to '')
-rw-r--r--src/World.cpp33
1 files changed, 33 insertions, 0 deletions
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<unsigned int> World::GetEntitiesList()
+{
+ std::vector<unsigned int> 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);
+
+}