VoxelEngine
 
Loading...
Searching...
No Matches
engine::VariantBlock Class Reference

A variant block is a block that can have multiple geometries based on the surrounding blocks. More...

#include <VariantBlock.h>

Inheritance diagram for engine::VariantBlock:
engine::Block

Classes

struct  Condition
 
struct  Neighbours
 
struct  Variant
 

Public Member Functions

 VariantBlock (BlockID id, Layer layer, const Geometry *baseGeo, RotationMode rotationMode, int variantCount)
 
VariantBlockallowMultiple (bool allowMultiple)
 
bool allowMultiple () const
 
VariantBlockalwaysUseBaseGeometry (bool alwaysUseBaseGeometry)
 
bool alwaysUseBaseGeometry () const
 
VariantBlockaddVariant (const Geometry &geometry, std::initializer_list< Condition > conditions)
 
VariantBlockaddVariant (Variant &&variant)
 
const VariantgetVariant (const Neighbours &neighbours) const
 Get a variant that matches the neighbours.
 
std::vector< const Variant * > getVariants (const Neighbours &neighbours) const
 Get all variants that match the neighbours.
 
std::vector< const Geometry * > getGeometries (const Neighbours &neighbours) const
 Get all geometries that match the neighbours and the base geometry if alwaysUseBaseGeometry is true.
 
- Public Member Functions inherited from engine::Block
 Block (BlockID id, Layer layer, const Geometry *geo)
 
 Block (BlockID id, Layer layer, const Geometry *geo, RotationMode rotationMode)
 
virtual bool onInteract (InteractContext *context) const
 
virtual void onDestroyed (const BlockSetContext &context) const
 
virtual void onPlaced (const BlockSetContext &context) const
 
bool isAir () const
 
bool isMultiblock () const
 
BlockID getID () const
 
const Geometrygeometry () const
 
bool isSolid () const
 
bool isVoxel () const
 
bool facingUp () const
 
Layer layer () const
 
RotationMode rotationMode () const
 
BlockrotationMode (RotationMode mode)
 
BlockisSolid (bool solid)
 
BlockisVoxel (bool voxel)
 
BlockfacingUp (bool state)
 
Blockmaterial (const BlockMaterial &mat)
 
const BlockMaterialmaterial () const
 

Static Public Member Functions

static constexpr bool isValidRotationMode (RotationMode mode)
 Check if a rotation mode is valid for VariantBlock.
 
- Static Public Member Functions inherited from engine::Block
static Blockair ()
 
static Blockmultiblock ()
 

Additional Inherited Members

- Static Public Attributes inherited from engine::Block
static constexpr BlockID AirID = 0
 Reserved block ID range: 0-8 (inclusive).
 
static constexpr BlockID MultiblockID = 1
 
- Protected Attributes inherited from engine::Block
bool m_isSolid
 
bool m_isVoxel
 
bool m_faceUp = false
 
Layer m_layer
 
RotationMode m_rotationMode = RotationMode::None
 
const Geometrym_geometry
 
BlockMaterial m_material
 

Detailed Description

A variant block is a block that can have multiple geometries based on the surrounding blocks.

Note
The block is always using the base geometry if no variant is found.
The block can be configured to always use the base geometry even if a variant is found.
The block can be configured to allow multiple variants (thus geometries) to be used at the same time.
If

Member Function Documentation

◆ getGeometries()

std::vector< const Geometry * > VariantBlock::getGeometries ( const Neighbours neighbours) const

Get all geometries that match the neighbours and the base geometry if alwaysUseBaseGeometry is true.

Parameters
neighboursThe neighbours of the block.
Returns
All geometries that match the neighbours and the base geometry if alwaysUseBaseGeometry is true.

◆ getVariant()

const VariantBlock::Variant * VariantBlock::getVariant ( const Neighbours neighbours) const

Get a variant that matches the neighbours.

Parameters
neighboursThe neighbours of the block.
Returns
The variant that matches the neighbours.
Note
Should be used if allowMultiple is false.

◆ getVariants()

std::vector< const VariantBlock::Variant * > VariantBlock::getVariants ( const Neighbours neighbours) const

Get all variants that match the neighbours.

Parameters
neighboursThe neighbours of the block.
Returns
All variants that match the neighbours.
Note
Should be used if allowMultiple is true.

◆ isValidRotationMode()

static constexpr bool engine::VariantBlock::isValidRotationMode ( RotationMode  mode)
inlinestaticconstexpr

Check if a rotation mode is valid for VariantBlock.

Note
VariantBlock does not support AxisY and AxisXYZ rotation modes

The documentation for this class was generated from the following files: