3#include <block/Block.h>
4#include <block/Geometry.h>
6#include <initializer_list>
21 return mode != RotationMode::AxisY && mode != RotationMode::AxisXYZ;
33 std::vector<BlockID> blockIDs;
34 std::vector<glm::vec3> requiredFacings;
36 bool operator==(
const Condition& other)
const {
37 return direction == other.direction && blockIDs == other.blockIDs &&
38 requiredFacings == other.requiredFacings;
48 std::vector<Condition> conditions;
50 bool operator==(
const Variant& other)
const {
51 return geometry.getID() == other.geometry.getID() && conditions == other.conditions;
63 glm::vec3 northFacing;
64 glm::vec3 southFacing;
70 BlockID operator[](Side direction)
const;
71 glm::vec3 getFacing(Side direction)
const;
72 void rotate(Side from, Side to);
79 RotationMode rotationMode,
86 bool allowMultiple()
const {
return m_allowMultiple; }
88 VariantBlock& alwaysUseBaseGeometry(
bool alwaysUseBaseGeometry);
89 bool alwaysUseBaseGeometry()
const {
return m_alwaysUseBaseGeometry; }
91 VariantBlock& addVariant(
92 const Geometry& geometry, std::initializer_list<Condition> conditions
95 VariantBlock& addVariant(Variant&& variant);
101 const Variant*
getVariant(
const Neighbours& neighbours)
const;
107 std::vector<const Variant*>
getVariants(
const Neighbours& neighbours)
const;
112 std::vector<const Geometry*>
getGeometries(
const Neighbours& neighbours)
const;
116 std::vector<Variant> m_variants;
117 bool m_allowMultiple =
false;
118 bool m_alwaysUseBaseGeometry =
false;
120 bool checkConditions(
121 const std::vector<Condition>& conditions,
const Neighbours& neighbours
A variant block is a block that can have multiple geometries based on the surrounding blocks.
Definition VariantBlock.h:16
const Variant * getVariant(const Neighbours &neighbours) const
Get a variant that matches the neighbours.
Definition VariantBlock.cpp:130
std::vector< const Geometry * > getGeometries(const Neighbours &neighbours) const
Get all geometries that match the neighbours and the base geometry if alwaysUseBaseGeometry is true.
Definition VariantBlock.cpp:160
static constexpr bool isValidRotationMode(RotationMode mode)
Check if a rotation mode is valid for VariantBlock.
Definition VariantBlock.h:20
std::vector< const Variant * > getVariants(const Neighbours &neighbours) const
Get all variants that match the neighbours.
Definition VariantBlock.cpp:147
Definition VariantBlock.h:31
Definition VariantBlock.h:55
Definition VariantBlock.h:46