TODO, get a ForEach type recursion working for Bitset.
EC/Meta/Morph.hpp
EC/Meta/Meta.hpp
EC/Bitset.hpp
+ EC/Manager.hpp
EC/EC.hpp)
add_library(EntityComponentSystem INTERFACE)
#include <bitset>
#include "Meta/TypeList.hpp"
#include "Meta/Combine.hpp"
+#include "Meta/IndexOf.hpp"
namespace EC
{
{
return (*this)[EC::Meta::IndexOf<Tag, Combined>::value];
}
+
+ template <typename Contents>
+ static constexpr Bitset<ComponentsList, TagsList> generateBitset()
+ {
+ //TODO
+ Bitset<ComponentsList, TagsList> bitset;
+/*
+ for(unsigned int i = 0; i < Contents::size; ++i)
+ {
+ if(EC::Meta::Contains<EC::Meta::TypeListGet<Contents, i>, Combined>::value)
+ {
+ bitset[EC::Meta::IndexOf<EC::Meta::TypeListGet<Contents, i>, Combined>::value] = true;
+ }
+ }
+*/
+
+ return bitset;
+ }
};
}
#include "Bitset.hpp"
+#include "Manager.hpp"
#ifndef EC_MANAGER_HPP
#define EC_MANAGER_HPP
+#define EC_INIT_ENTITIES_SIZE 1024
+
+#include <cstddef>
+#include <tuple>
+
+#include "Meta/Combine.hpp"
+#include "Bitset.hpp"
+
namespace EC
{
- template <typename ComponentsList, typename TagsList, typename Signatures>
+ template <typename ComponentsList, typename TagsList>
struct Manager
{
public:
using Combined = EC::Meta::Combine<ComponentsList, TagsList>;
+ using BitsetType = EC::Bitset<ComponentsList, TagsList>;
+
+ Manager()
+ {
+ entities.resize(EC_INIT_ENTITIES_SIZE);
+
+ for(auto entity : entities)
+ {
+ entity->first = false;
+ }
+ }
+
+ template <typename EComponentsList>
+ std::size_t addEntity()
+ {
+ //TODO
+ BitsetType newEntity;
+ return 0;
+ }
private:
- using BitsetType = EC::Bitset<ComponentsList, TagsList>;
+ using ComponentsStorage = EC::Meta::Morph<ComponentsList, std::tuple<> >;
+ using EntitiesType = std::tuple<bool, BitsetType>;
+
+ std::vector<EntitiesType> entities;
};
}
#include "TypeList.hpp"
+#include "TypeListGet.hpp"
#include "Combine.hpp"
#include "Contains.hpp"
#include "ContainsAll.hpp"
--- /dev/null
+
+#ifndef EC_META_TYPE_LIST_GET_HPP
+#define EC_META_TYPE_LIST_GET_HPP
+
+#include <type_traits>
+
+#include "TypeList.hpp"
+#include "IndexOf.hpp"
+
+namespace EC
+{
+ namespace Meta
+ {
+ template <typename TTypeList, typename TTTypeList, unsigned int Index>
+ struct TypeListGetHelper
+ {
+ using type = TTypeList;
+ };
+
+ template <typename TTypeList, template <typename...> class TTTypeList, unsigned int Index, typename Type, typename... Rest>
+ struct TypeListGetHelper<TTypeList, TTTypeList<Type, Rest...>, Index>
+ {
+ using type =
+ typename std::conditional<
+ Index == EC::Meta::IndexOf<Type, TTypeList>::value,
+ Type,
+ typename TypeListGetHelper<TTypeList, TTTypeList<Rest...>, Index>::type
+ >::type;
+ };
+
+ template <typename TTypeList, unsigned int Index>
+ using TypeListGet = typename TypeListGetHelper<TTypeList, TTypeList, Index>::type;
+ }
+}
+
+#endif
+
EXPECT_TRUE(isSame);
}
+TEST(Meta, TypeListGet)
+{
+ bool isSame = std::is_same<C0, EC::Meta::TypeListGet<ListAll, 0> >::value;
+ EXPECT_TRUE(isSame);
+
+ isSame = std::is_same<C1, EC::Meta::TypeListGet<ListAll, 1> >::value;
+ EXPECT_TRUE(isSame);
+
+ isSame = std::is_same<C2, EC::Meta::TypeListGet<ListAll, 2> >::value;
+ EXPECT_TRUE(isSame);
+
+ isSame = std::is_same<C3, EC::Meta::TypeListGet<ListAll, 3> >::value;
+ EXPECT_TRUE(isSame);
+
+ const unsigned int temp = 4;
+ isSame = std::is_same<T0, EC::Meta::TypeListGet<ListAll, temp> >::value;
+ EXPECT_TRUE(isSame);
+
+ isSame = std::is_same<T1, EC::Meta::TypeListGet<ListAll, 5> >::value;
+ EXPECT_TRUE(isSame);
+}
+