BlockMetadata
Bit-level accessor wrapper around a Block's 4-bit metadata nibble.
Overview
A thin wrapper around the 4-bit nibble stored in every Block. It does not define what the bits mean — that semantic is left to gameplay code (e.g. rotation, variant, or state), a design point relevant to the open question of per-block facing/rotation metadata for cube-rendered objects (see Gameplay).
Header: include/GalaxyEggbert/Worlds/BlockMetadata.hpp.
API
class BlockMetadata {
public:
explicit BlockMetadata(uint8_t nibble);
bool bit0() const; bool bit1() const; bool bit2() const; bool bit3() const;
void setBit0(bool v); void setBit1(bool v); void setBit2(bool v); void setBit3(bool v);
bool bit(int index) const; // generic, index 0..3
void setBit(int index, bool enabled);
BlockMetadata withBitN(int index, bool enabled) const; // returns a modified copy
uint8_t rawValue() const;
};
Tests
Covered by tests/GalaxyEggbert/Worlds/BlockMetadataTest.cpp.