I'm trying to write an EntityType
class that can receive and store a variable number of Component
types.
struct Health { int amount; }
struct Position { float x, y; }
EntityType entityType = new EntityType<Health, Position>();
I will then use this EntityType
class later as a blueprint for allocating tightly packed memory for the components.
EntityManager.BatchCreate(3, entityType);
// Result: Health | Health | Health | Position | Position | Position
Creating a class template with multiple parameters is easy enough, but:
- How do I store the types to be used as a allocation blueprint later?
- Can I query what types are in the EntityType?
My first thought for storage was tuples, but I'm not sure. Those take the actual value of the types passed in, and not the type themselves. Can I work with typeid
's somehow?
I'm basically trying to replicate in C++ What Unity is doing in C# with EntityArchetype, which I believe is using reflection.
Aucun commentaire:
Enregistrer un commentaire