12345678910111213141516171819202122232425 |
- #ifndef BLOCKREGISTRY_H
- #define BLOCKREGISTRY_H
- #include "common/utils/List.h"
- #include "common/utils/HashedString.h"
- #include "common/utils/HashMap.h"
- #include "common/block/Block.h"
- class BlockRegistry final {
- public:
- BlockRegistry();
- void forEach(void (*f) (const Block&)) const;
- const Block& getBlock(const HashedString& registry) const;
- const Block& getBlock(u16 id) const;
- private:
- void add(const char* registry, const BlockBuilder& builder);
- static constexpr uint MAX_BLOCKS = 4096;
- List<Block, MAX_BLOCKS> blocks;
- HashMap<HashedString, u16, MAX_BLOCKS> registryToId;
- };
- #endif
|