QcDustNetwork Class
One-pass recalculation of Signal Dust (decision E-335). More...
| Header: | #include <server/signal/QcDustNetwork.h> |
Public Types
| struct | Result |
Public Functions
| bool | feeds(QcBlockPos from, QcBlockPos to) const |
| QList<QcBlockPos> | links(QcBlockPos pos) const |
| QcDustNetwork::Result | recompute(const std::vector<QcBlockPos> &seeds) const |
| std::array<QcDustSide, 4> | sidesOf(QcBlockPos pos) const |
Static Public Members
| const int | maxNodes |
Detailed Description
Dust is joined by links: flat to the dust next to it, up the side of a block when nothing opaque lies on the lower dust, down the side of a block that is not opaque; the signal only goes down such a link from dust on a conductor. Strength falls by one per link, so a change can only reach dust within 15 links of where it happened: that part of the network is the region recomputed, the dust just outside keeps its strength and feeds the region like a source. The region's strengths come from one breadth-first pass from the strongest inputs down (each dust and link looked at once), its connections (dot, line, cross, slopes) in the same pass, and only dust whose state really changes is reported. A long wire therefore costs the same as a short one, and the result does not depend on where the wire lies, how it is turned or in which order its dust is visited.
Member Function Documentation
bool QcDustNetwork::feeds(QcBlockPos from, QcBlockPos to) const
Returns whether the dust at from gives its strength to the linked dust at to. A link down the side of a block only carries the signal down when the upper dust lies on a conductor; dust on glass or an upper slab passes it up a stair but not down (decision E-887, like the role model).
QList<QcBlockPos> QcDustNetwork::links(QcBlockPos pos) const
Returns the dust the dust at pos is linked to.
QcDustNetwork::Result QcDustNetwork::recompute(const std::vector<QcBlockPos> &seeds) const
Recomputes the dust within 15 links of the dust among seeds (other positions are ignored). Returns the dust that changes and the parts that wait for a chunk.
std::array<QcDustSide, 4> QcDustNetwork::sidesOf(QcBlockPos pos) const
Returns the sides the dust at pos shows: flat to dust and to sources and repeaters lined up with it, up to dust on the neighbouring block, down to dust beside a block that is not opaque; a single connection becomes a line through the dust.
Member Variable Documentation
const int QcDustNetwork::maxNodes
Dust per region at most; beyond, the rest of a pathological region keeps its old state.