QtCraft API C++ classes QML types Handbook

QcPieceVariation Class

A village blueprint with its variation resolved (decision E-404): the structure as it is, each choice's options as palette overrides and creature swaps, and the optional parts. More...

Header: #include <worldgen/villages/QcPieceVariation.h>

Public Types

struct Selection
Resolved

Public Functions

const std::shared_ptr<const QcStructure> &base() const
std::shared_ptr<const QcStructure> build(const QcPieceVariation::Selection &selection) const
QcPieceVariation::Selection choose(const std::function<double ()> &random) const
QcPieceVariation::Selection everything() const
QList<int> optionCounts() const
QList<double> partChances() const
bool varies() const
const QStringList &warnings() const

Static Public Members

QcPieceVariation::Resolved resolve(const QcStructureDefinition &definition, const QcContentRegistry &content)
const QStringList &warningsOf(const QcPieceVariation::Resolved &resolved)

Detailed Description

Builds the structure of one placed copy from a selection the planner draws from the seed. Immutable after resolving, so the generator's threads share it.

Member Type Documentation

[alias] QcPieceVariation::Resolved

The result of resolve(): the variation, or the failure of the structure.

Member Function Documentation

const std::shared_ptr<const QcStructure> &QcPieceVariation::base() const

Returns the structure without parts and with every palette entry as written.

std::shared_ptr<const QcStructure> QcPieceVariation::build(const QcPieceVariation::Selection &selection) const

Returns the structure of selection: options swap palette entries and creatures, parts built overwrite their cells, connections follow the built copy; the base itself when nothing varies.

QcPieceVariation::Selection QcPieceVariation::choose(const std::function<double ()> &random) const

Returns a selection from random (values in [0, 1)): one draw per choice, then one per part.

QcPieceVariation::Selection QcPieceVariation::everything() const

Returns the selection with every part built and the first option of every choice (the showcase shows this one).

QList<int> QcPieceVariation::optionCounts() const

Returns how many options each choice has.

QList<double> QcPieceVariation::partChances() const

Returns the chance of each part.

[static] QcPieceVariation::Resolved QcPieceVariation::resolve(const QcStructureDefinition &definition, const QcContentRegistry &content)

Returns definition resolved against the blocks of content; definition already carries the style's palette swaps. Unknown blocks of the structure fail; an option naming an unknown block keeps that palette entry with a warning (warnings()). A failure carries the warnings of the palette entries before the unknown block.

bool QcPieceVariation::varies() const

Returns whether the blueprint has choices or parts.

const QStringList &QcPieceVariation::warnings() const

Returns what resolving kept at a default or left out (unknown states, unknown blocks of options).

[static] const QStringList &QcPieceVariation::warningsOf(const QcPieceVariation::Resolved &resolved)

Returns the warnings of the resolution resolved, whether it succeeded or not (callers report them before the outcome).