]> git.localhorst.tv Git - blank.git/blob - src/world/BlockTypeRegistry.hpp
sped up chunk generation a little
[blank.git] / src / world / BlockTypeRegistry.hpp
1 #ifndef BLANK_WORLD_BLOCKTYPEREGISTRY_HPP_
2 #define BLANK_WORLD_BLOCKTYPEREGISTRY_HPP_
3
4 #include "BlockType.hpp"
5
6 #include <vector>
7
8
9 namespace blank {
10
11 class BlockTypeRegistry {
12
13 public:
14         using size_type = std::vector<BlockType>::size_type;
15         using reference = std::vector<BlockType>::reference;
16         using const_reference = std::vector<BlockType>::const_reference;
17         using iterator = std::vector<BlockType>::iterator;
18         using const_iterator = std::vector<BlockType>::const_iterator;
19
20 public:
21         BlockTypeRegistry();
22
23         Block::Type Add(const BlockType &);
24
25         size_t size() const noexcept { return types.size(); }
26
27         iterator begin() noexcept { return types.begin(); }
28         const_iterator begin() const noexcept { return types.begin(); }
29         iterator end() noexcept { return types.end(); }
30         const_iterator end() const noexcept { return types.end(); }
31
32         BlockType &operator [](Block::Type id) { return types[id]; }
33         const BlockType &operator [](Block::Type id) const { return types[id]; }
34
35         BlockType &Get(Block::Type id) { return types[id]; }
36         const BlockType &Get(Block::Type id) const { return types[id]; }
37
38 private:
39         std::vector<BlockType> types;
40
41 };
42
43 }
44
45 #endif