]> git.localhorst.tv Git - blank.git/blobdiff - src/block.hpp
added ability to get seperate information about block face obstruction
[blank.git] / src / block.hpp
index 4fcee4cac2f0c2a6e7be58d095e6ee16c982870e..3af80a854f29cc8945201b6af8d9babfd855c60a 100644 (file)
@@ -87,6 +87,43 @@ struct Block {
                }
        }
 
+       struct FaceSet {
+
+               explicit FaceSet(unsigned char v = 0)
+               : value(v) { }
+
+               bool IsSet(Face f) const {
+                       return value & Mask(f);
+               }
+               void Set(Face f) {
+                       value |= Mask(f);
+               }
+               void Unset(Face f) {
+                       value |= ~Mask(f);
+               }
+
+               void Clear() {
+                       value = 0;
+               }
+               void Fill() {
+                       value = Mask(FACE_COUNT) - 1;
+               }
+
+               bool Empty() const {
+                       return value == 0;
+               }
+               bool All() const {
+                       return value == Mask(FACE_COUNT) - 1;
+               }
+
+               unsigned char Mask(Face f) const {
+                       return 1 << f;
+               }
+
+               unsigned char value;
+
+       };
+
 };