QtCraft API C++ classes QML types Handbook

QcSignalPower Class

Who powers what (decision E-333), read from the world as it is. More...

Header: #include <server/signal/QcSignalPower.h>

Public Types

Positions

Public Functions

const QcSignalState &at(QcBlockPos pos) const
std::optional<QcBlockId> blockAt(QcBlockPos pos) const
int dustInput(QcBlockPos pos) const
int input(QcBlockPos pos, quint8 ignoredFaces = 0) const
int inputFrom(QcBlockPos pos, QcBlockFace face) const
int strongLevel(QcBlockPos pos) const
const QcSignalTable &table() const
std::optional<QcChunkPos> unloadedNear(QcBlockPos pos) const
int weakLevel(QcBlockPos pos) const
const QcBlockAccess &world() const

Static Public Members

int directPower(QcSignalState state, QcBlockFace towards)
int strongPower(QcSignalState state, QcBlockFace towards)
QcSignalPower::Positions targets(QcBlockPos pos, QcSignalState state)

Detailed Description

A source sends power directly into its neighbouring components and dust (a lever into all six, a torch into all but its block, a repeater only forwards) and strongly into a conductor (the block a lever or button hangs on, the block under a plate, above a torch but not a small one, in front of a repeater). Dust powers the block it lies on and the blocks its lines point at weakly. A strongly powered conductor powers neighbouring dust and components; a weakly powered one only components, never dust, so dust does not feed itself through blocks. All answers are maxima over the six faces: the order of the faces never matters.

Member Type Documentation

[alias] QcSignalPower::Positions

A short list of positions.

Member Function Documentation

const QcSignalState &QcSignalPower::at(QcBlockPos pos) const

Returns the signal state of the block at pos (that of air where nothing is loaded).

std::optional<QcBlockId> QcSignalPower::blockAt(QcBlockPos pos) const

Returns the block at pos, or nothing where it is not loaded.

[static] int QcSignalPower::directPower(QcSignalState state, QcBlockFace towards)

Returns the power the block state sends straight into the neighbouring cell towards towards.

int QcSignalPower::dustInput(QcBlockPos pos) const

Returns what dust at pos gets from outside its wire: sources and strongly powered blocks.

int QcSignalPower::input(QcBlockPos pos, quint8 ignoredFaces = 0) const

Returns what a component at pos gets through every face but those whose bit (1 << face) is set in ignoredFaces.

int QcSignalPower::inputFrom(QcBlockPos pos, QcBlockFace face) const

Returns what a component at pos gets through the face face.

int QcSignalPower::strongLevel(QcBlockPos pos) const

Returns the strongest strong power a conductor at pos gets from its neighbours (0 for other blocks).

[static] int QcSignalPower::strongPower(QcSignalState state, QcBlockFace towards)

Returns the strong power the block state puts into the conductor towards towards.

const QcSignalTable &QcSignalPower::table() const

Returns the signal table.

[static] QcSignalPower::Positions QcSignalPower::targets(QcBlockPos pos, QcSignalState state)

Returns the cells beyond its six neighbours that the block state at pos powers: its strong target and the blocks dust points at. Their neighbours notice when it changes.

std::optional<QcChunkPos> QcSignalPower::unloadedNear(QcBlockPos pos) const

Returns an unloaded chunk within two blocks of pos (what a component or dust there reads may lie in it), if any: circuits wait for it instead of reading it as air (decision E-335).

int QcSignalPower::weakLevel(QcBlockPos pos) const

Returns the strong level or what dust puts into the conductor at pos, whichever is higher.

const QcBlockAccess &QcSignalPower::world() const

Returns the world it reads.