59 const std::pair<AString, BlockState> &
block(
Vector3i aPos)
const;
std::pair< UInt32, bool > maybePaletteIndex(const AString &aBlockTypeName, const BlockState &aBlockState) const
Returns the <index, true> into the palette that is used by the specified full blockspec.
const Vector3i & size() const
Returns the actual size of the area in all 3 axes.
void paste(const PalettedBlockArea &aSrc, Vector3i aDstOrigin=Vector3i())
Pastes (copies verbatim) the entire src PBA into this PBA.
UInt32 blockPaletteIndex(Vector3i aPos) const
Returns the index into the palette for the block at the specified pos.
UInt32 positionToIndex(Vector3i aPos) const
Converts the position to index in mBlocks.
Holds a palette that maps between block type + state and numbers.
void fill(const AString &aBlockTypeName, const BlockState &aBlockState)
Fills the entire PBA with a single block of the specified type.
Represents an area of blocks that are represented using a palette.
void paste(const PalettedBlockArea &aSrc, const cCuboid &aSrcCuboid, Vector3i aDstOrigin=Vector3i())
Pastes (copies verbatim) a cCuboid out of the src PBA into this PBA.
cCuboid whole() const
Returns a cCuboid that encompasses the entire PBA.
bool isPositionValid(Vector3i aPos) const
Returns true if the specified position is within the size bounds of the area.
Vector3i mSize
The size (dimensions) of the area.
const std::pair< AString, BlockState > & paletteEntry(UInt32 aPaletteIndex) const
Returns the blockspec represented by the specified palette index.
UInt32 paletteIndex(const AString &aBlockTypeName, const BlockState &aBlockState)
Returns the index into the palette that is used by the specified full blockspec.
static PalettedBlockArea createFilled(Vector3i aSize, const AString &aBlockTypeName, const BlockState &aBlockState)
Creates a new PBA of the specified size filled with the specified block.
const BlockTypePalette & palette()
Returns the (reqd-only) palette used internally by this object.
const std::pair< AString, BlockState > & block(Vector3i aPos) const
Returns the full blockspec of the block at the specified position.
std::vector< UInt32 > mBlocks
The blocks contained in the area, stored as indices into mPalette.
void crop(const cCuboid &aArea)
Crops this PBA by the specified coords.
PalettedBlockArea()
Creates a new uninitialized instance (all sizes zero).
BlockTypePalette mPalette
The palette used in the area.
Represents the state of a single block (previously known as "block meta").
void setBlock(Vector3i aPos, const AString &aBlockTypeName, const BlockState &aBlockState)
Sets a single block using its full blockspec.