QtCraft API C++ classes QML types Handbook

QcSurfaceStructures Class

The structures the terrain generator places by itself on the surface (decision E-590, the desert temple): each kind plans its regions once (QcSurfacePlanner, plans cached), a copy lies wholly in its region, so a chunk asks only the one region of each kind it lies in. More...

Header: #include <worldgen/surface/QcSurfaceStructures.h>

Public Types

struct Moved
struct PlanKey

Public Functions

QcSurfaceStructures(const QcTerrainGenerator &terrain, const QcVillageGenerator &villages, const QcContentRegistry &content, quint64 seed)
QList<QcXzRect> bareNear(QcChunkPos pos, int margin) const
void blend(QcChunk &chunk) const
QList<QcSurfaceStructures::Moved> blendedGround(const QcTerrainColumnGrid &columns, QcChunkPos pos) const
void build(QcChunk &chunk) const
QList<QcXzRect> footprintsNear(QcChunkPos pos, int margin) const
QcChunkFurnishing furnishingIn(QcChunkPos pos) const
std::optional<QcStructurePlacement> nearest(const QString &name, QcBlockPos from, int reach) const
std::shared_ptr<const QcStructurePlacement> planOf(QcSurfacePlanner::KindId kind, int regionX, int regionZ) const
std::optional<QcStructureSites> plannedSitesNear(QcBlockPos from, int reach) const
const QcSurfacePlanner &planner() const
QList<std::shared_ptr<const QcStructurePlacement>> plansTouching(QcChunkPos pos) const
QcStructureSites sitesNear(QcBlockPos from, int reach) const

Static Public Members

const qsizetype cacheCapacity
const int clearance
const int maxFoundation
QcSurfaceStructures::PlanKey planKey(QcSurfacePlanner::KindId kind, int regionX, int regionZ)

Detailed Description

Writing a copy into a chunk clears the terrain above its footprint (from its layer clearFrom to clearance blocks over its top; over water never at or below the sea, decision E-622; not for kinds without clearTerrain, decision E-630), blends the ground around it to its floor (the rule's blend, QcSurfaceBlend, decision E-889), fills the ground below it with the kind's foundation down to solid ground and writes its cells; the same in any order of the chunks. No trees, plants or surface pools grow near a copy (footprintsNear()), so none is cut or left floating. Its loot comes with furnishingIn(), its guardian zones with sitesNear(). Thread-safe.

Member Function Documentation

QcSurfaceStructures::QcSurfaceStructures(const QcTerrainGenerator &terrain, const QcVillageGenerator &villages, const QcContentRegistry &content, quint64 seed)

Plans the kinds of content with seed on the columns of terrain, clear of the villages of villages.

QList<QcXzRect> QcSurfaceStructures::bareNear(QcChunkPos pos, int margin) const

Returns the same as footprintsNear() for pos and margin where no trees or plants grow: kinds with blendVegetation keep only the ring right beside their walls bare, the others their whole blended ground (decision E-889).

void QcSurfaceStructures::blend(QcChunk &chunk) const

Blends the ground of chunk around the copies touching it (before its features).

QList<QcSurfaceStructures::Moved> QcSurfaceStructures::blendedGround(const QcTerrainColumnGrid &columns, QcChunkPos pos) const

Returns the columns of columns, the column grid around the chunk pos, whose ground blend() moves (in the chunk and its neighbours alike), in the order blend() shapes them: where two blends meet, the later one wins in both.

void QcSurfaceStructures::build(QcChunk &chunk) const

Clears the terrain over the copies touching chunk, lays their foundations and writes them into it.

QList<QcXzRect> QcSurfaceStructures::footprintsNear(QcChunkPos pos, int margin) const

Returns the footprints of the copies of every kind, grown by their blended ground, within margin columns of the chunk pos: the terrain generator places no features and no surface pools there (decisions E-630, E-889).

QcChunkFurnishing QcSurfaceStructures::furnishingIn(QcChunkPos pos) const

Returns the loot of the copies' chests in the chunk pos.

std::optional<QcStructurePlacement> QcSurfaceStructures::nearest(const QString &name, QcBlockPos from, int reach) const

Returns the copy of kind name nearest to from within reach blocks, if any.

[static] QcSurfaceStructures::PlanKey QcSurfaceStructures::planKey(QcSurfacePlanner::KindId kind, int regionX, int regionZ)

Returns the cache key of region (regionX, regionZ) of kind kind.

std::shared_ptr<const QcStructurePlacement> QcSurfaceStructures::planOf(QcSurfacePlanner::KindId kind, int regionX, int regionZ) const

Returns the copy of kind kind in region (regionX, regionZ), planned once; null when the region has none.

std::optional<QcStructureSites> QcSurfaceStructures::plannedSitesNear(QcBlockPos from, int reach) const

Returns the same as sitesNear() for from and reach from the regions planned so far, never planning (the server's tick thread); std::nullopt when a region within reach is not planned yet.

const QcSurfacePlanner &QcSurfaceStructures::planner() const

Returns the planner of the kinds.

QList<std::shared_ptr<const QcStructurePlacement>> QcSurfaceStructures::plansTouching(QcChunkPos pos) const

Returns the copies of every kind whose footprint or blended ground overlaps the chunk pos.

QcStructureSites QcSurfaceStructures::sitesNear(QcBlockPos from, int reach) const

Returns the guardian zones and spawn areas of the copies in the regions within reach of from.

Member Variable Documentation

const qsizetype QcSurfaceStructures::cacheCapacity

Regions whose plans are kept at most; beyond, the cache starts over.

const int QcSurfaceStructures::clearance

Blocks cleared above the top of a copy.

const int QcSurfaceStructures::maxFoundation

The deepest foundation below a copy in blocks.