From f26f0710c19038f76918702661eb8755bbfcb1ee Mon Sep 17 00:00:00 2001 From: Jarann Date: Fri, 13 Jul 2018 12:49:05 -0700 Subject: [PATCH] Update ecs.hpp --- src/ecs/ecs.hpp | 84 +++---------------------------------------------- 1 file changed, 5 insertions(+), 79 deletions(-) diff --git a/src/ecs/ecs.hpp b/src/ecs/ecs.hpp index d448479..417bb5e 100644 --- a/src/ecs/ecs.hpp +++ b/src/ecs/ecs.hpp @@ -14,88 +14,14 @@ class ECS EntityHandle makeEntity(BaseECSComponent** components, const uint32* componentIDs, size_t numComponents); void removeEntity(EntityHandle handle); - template - EntityHandle makeEntity(A& c1) + template + EntityHandle makeEntity(Components&&... entitycomponents) { - BaseECSComponent* components[] = { &c1 }; - uint32 componentIDs[] = {A::ID}; - return makeEntity(components, componentIDs, 1); + BaseECSComponent* components[] = { (&entitycomponents)... }; + uint32 componentIDs[] = { (std::remove_reference_t::ID)... }; + return makeEntity(components, componentIDs, sizeof...(Components)); } - template - EntityHandle makeEntity(A& c1, B& c2) - { - BaseECSComponent* components[] = { &c1, &c2 }; - uint32 componentIDs[] = {A::ID, B::ID}; - return makeEntity(components, componentIDs, 2); - } - - template - EntityHandle makeEntity(A& c1, B& c2, C& c3) - { - BaseECSComponent* components[] = { &c1, &c2, &c3 }; - uint32 componentIDs[] = {A::ID, B::ID, C::ID}; - return makeEntity(components, componentIDs, 3); - } - - template - EntityHandle makeEntity(A& c1, B& c2, C& c3, D& c4) - { - BaseECSComponent* components[] = { &c1, &c2, &c3, &c4 }; - uint32 componentIDs[] = {A::ID, B::ID, C::ID, D::ID}; - return makeEntity(components, componentIDs, 4); - } - - template - EntityHandle makeEntity(A& c1, B& c2, C& c3, D& c4, E& c5) - { - BaseECSComponent* components[] = { &c1, &c2, &c3, &c4, &c5 }; - uint32 componentIDs[] = {A::ID, B::ID, C::ID, D::ID, E::ID}; - return makeEntity(components, componentIDs, 5); - } - - template - EntityHandle makeEntity(A& c1, B& c2, C& c3, D& c4, E& c5, F& c6) - { - BaseECSComponent* components[] = { &c1, &c2, &c3, &c4, &c5, &c6}; - uint32 componentIDs[] = {A::ID, B::ID, C::ID, D::ID, E::ID, F::ID}; - return makeEntity(components, componentIDs, 6); - } - - template - EntityHandle makeEntity(A& c1, B& c2, C& c3, D& c4, E& c5, F& c6, G& c7) - { - BaseECSComponent* components[] = { &c1, &c2, &c3, &c4, &c5, &c6, &c7}; - uint32 componentIDs[] = {A::ID, B::ID, C::ID, D::ID, E::ID, F::ID, G::ID}; - return makeEntity(components, componentIDs, 7); - } - - template - EntityHandle makeEntity(A& c1, B& c2, C& c3, D& c4, E& c5, F& c6, G& c7, H& c8) - { - BaseECSComponent* components[] = { &c1, &c2, &c3, &c4, &c5, &c6, &c7, &c8}; - uint32 componentIDs[] = {A::ID, B::ID, C::ID, D::ID, E::ID, F::ID, G::ID, H::ID}; - return makeEntity(components, componentIDs, 8); - } - - template - EntityHandle makeEntity(A& c1, B& c2, C& c3, D& c4, E& c5, F& c6, G& c7, H& c8, I& c9) - { - BaseECSComponent* components[] = { &c1, &c2, &c3, &c4, &c5, &c6, &c7, &c8, &c9 }; - uint32 componentIDs[] = {A::ID, B::ID, C::ID, D::ID, E::ID, F::ID, G::ID, H::ID, I::ID}; - return makeEntity(components, componentIDs, 9); - } - - template - EntityHandle makeEntity(A& c1, B& c2, C& c3, D& c4, E& c5, F& c6, G& c7, H& c8, I& c9, J& c10) - { - BaseECSComponent* components[] = { &c1, &c2, &c3, &c4, &c5, &c6, &c7, &c8, &c9, &c10 }; - uint32 componentIDs[] = {A::ID, B::ID, C::ID, D::ID, E::ID, F::ID, G::ID, H::ID, I::ID, J::ID }; - return makeEntity(components, componentIDs, 10); - } - - - // Component methods template inline void addComponent(EntityHandle entity, Component* component)