BlockRegistry.h 532 B

1234567891011121314151617181920212223
  1. #ifndef BLOCKREGISTRY_H
  2. #define BLOCKREGISTRY_H
  3. #include "common/block/Block.h"
  4. #include "common/block/BlockTypes.h"
  5. #include "gaming-core/utils/HashMap.h"
  6. #include "gaming-core/utils/List.h"
  7. class BlockRegistry final {
  8. public:
  9. BlockRegistry();
  10. void forEach(void (*f)(const Block&)) const;
  11. const Block& getBlock(const BlockName& registry) const;
  12. const Block& getBlock(BlockId id) const;
  13. private:
  14. void add(const char* registry);
  15. List<Block> blocks;
  16. HashMap<BlockName, BlockId> registryToId;
  17. };
  18. #endif