Components.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifndef CORE_COMPONENTS_H
  2. #define CORE_COMPONENTS_H
  3. #include "core/HashMap.h"
  4. #include "core/List.h"
  5. typedef size_t CoreEntity;
  6. typedef struct {
  7. CoreHashMap entityToIndex;
  8. CoreList indexToEntity;
  9. CoreList components;
  10. } CoreComponents;
  11. typedef struct {
  12. CoreEntity entity;
  13. void* component;
  14. } CoreComponentNode;
  15. typedef struct {
  16. const CoreEntity* indexToEntity;
  17. const CoreEntity* indexToEntityEnd;
  18. void* component;
  19. void* componentEnd;
  20. size_t componentSize;
  21. CoreComponentNode node;
  22. } CoreComponentIterator;
  23. void coreInitComponents(CoreComponents* c, size_t componentSize);
  24. void coreDestroyComponents(CoreComponents* c);
  25. void* coreComponentsGetOrAdd(CoreComponents* c, CoreEntity e);
  26. void* coreComponentsSearch(CoreComponents* c, CoreEntity e);
  27. bool coreComponentsRemove(CoreComponents* c, CoreEntity e);
  28. void coreInitComponentsIterator(CoreComponentIterator* ci, CoreComponents* c);
  29. bool coreComponentsHasNext(CoreComponentIterator* ci);
  30. CoreComponentNode* coreComponentsNext(CoreComponentIterator* ci);
  31. void* coreComponentsBegin(CoreComponents* c);
  32. void* coreComponentsEnd(CoreComponents* c);
  33. #endif