QtCraft API C++ classes QML types Handbook

QcMineshaftNetwork Class

The lattice graph of a mine shaft (decision E-570), before any block: points (x, z) of a square lattice on levels (0 the top), nodes at some of them, corridors between neighbouring nodes of a level (grown in straight runs of up to maxRun steps, decision E-889) and staircases from a node to the neighbouring lattice point one level lower. More...

Header: #include <worldgen/mineshafts/QcMineshaftNetwork.h>

Public Types

struct Link
struct Node
struct Point
struct Use
struct Verdict
LinkJudge
NodeJudge
Random

Public Functions

bool bridgedElsewhere(std::pair<int, int> key, int level) const
int degree(int node) const
int grow(int levels, bool roomBridges)
const QList<QcMineshaftNetwork::Link> &links() const
std::optional<int> nodeAt(QcMineshaftNetwork::Point at) const
const QList<QcMineshaftNetwork::Node> &nodes() const

Static Public Members

std::pair<int, int> elementKey(QcMineshaftNetwork::Point a)
std::pair<int, int> elementKey(QcMineshaftNetwork::Point a, QcMineshaftNetwork::Point b)

Detailed Description

Level 0 grows from the central room at (0, 0); every further level grows from the lower end of the first staircase down to it, so every node is reachable from the room. A judge (the planner, which knows the terrain) decides whether a node or a link fits and whether it bridges a cave. Two elements on the same lattice point or edge never share a level, and where one of them is a bridge, no other level may use that point or edge at all (its pillars would pass through).

Member Type Documentation

[alias] QcMineshaftNetwork::LinkJudge

The judge's question for a link between two points (a staircase when the second is one level lower).

[alias] QcMineshaftNetwork::NodeJudge

The judge's question for a node at a point.

[alias] QcMineshaftNetwork::Random

A random value in [0, 1) for a purpose and an index.

Member Function Documentation

bool QcMineshaftNetwork::bridgedElsewhere(std::pair<int, int> key, int level) const

Returns whether an element of a level other than level bridges a cave at the lattice point or edge with the key key (elementKey()).

int QcMineshaftNetwork::degree(int node) const

Returns the number of links at the node with index node.

[static] std::pair<int, int> QcMineshaftNetwork::elementKey(QcMineshaftNetwork::Point a)

Returns the key of the lattice point a: its x and z doubled (level ignored).

[static] std::pair<int, int> QcMineshaftNetwork::elementKey(QcMineshaftNetwork::Point a, QcMineshaftNetwork::Point b)

Returns the key of the edge between the neighbouring points a and b: their sum, a point in doubled coordinates (levels ignored).

int QcMineshaftNetwork::grow(int levels, bool roomBridges)

Grows up to levels levels from the room (node 0, which must fit; roomBridges: whether it bridges a cave); returns the levels made. A further level is made only while a first staircase down to it fits.

Returns the corridors and staircases grown.

std::optional<int> QcMineshaftNetwork::nodeAt(QcMineshaftNetwork::Point at) const

Returns the index of the node at the lattice point at, std::nullopt without one.

const QList<QcMineshaftNetwork::Node> &QcMineshaftNetwork::nodes() const

Returns the nodes grown, the central room first.