1234567891011121314151617181920212223242526 |
- #ifndef BLOCKREGISTRY_H
- #define BLOCKREGISTRY_H
- #include <vector>
- #include <unordered_map>
- #include "common/utils/HashedString.h"
- #include "common/block/Block.h"
- class BlockRegistry {
- public:
- BlockRegistry();
- const Block& getBlock(const HashedString& registry) const;
- const Block& getBlock(u16 id) const;
- private:
- void add(const char* registry, const BlockBuilder& builder);
- std::vector<Block> blocks;
- struct Hasher {
- size_t operator()(const HashedString& key) const;
- };
- std::unordered_map<HashedString, u16, Hasher> registryToId;
- };
- #endif
|