]> git.localhorst.tv Git - blank.git/blobdiff - src/world.hpp
block type colors
[blank.git] / src / world.hpp
index 304c63a7eded25d33bf7ed26e6e3d182fff2f3a3..58f7a25faeea7e8c8a622cf65d247a0bb022bf99 100644 (file)
@@ -13,10 +13,15 @@ namespace blank {
 /// attributes of a type of block
 struct BlockType {
 
+       int id;
+
        bool visible;
+       glm::vec3 color;
 
-       constexpr explicit BlockType(bool v = false)
-       : visible(v) { }
+       constexpr explicit BlockType(
+               bool v = false,
+               const glm::vec3 &color = { 1, 1, 1 })
+       : id(-1), visible(v), color(color) { }
 
        static const BlockType DEFAULT;
 
@@ -35,6 +40,23 @@ struct BlockType {
 };
 
 
+class BlockTypeRegistry {
+
+public:
+       BlockTypeRegistry();
+
+public:
+       int Add(const BlockType &);
+
+       BlockType *operator [](int id) { return &types[id]; }
+       const BlockType *Get(int id) const { return &types[id]; }
+
+private:
+       std::vector<BlockType> types;
+
+};
+
+
 /// single 1x1x1 cube
 struct Block {