QtCraft API C++ classes QML types Handbook

QcSignalSchedule Class

The scheduled ticks of circuit components (decision E-335): a component asks to be looked at again after a delay (a torch after 2 ticks, a repeater after its delay, a button when it springs back). More...

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

Public Types

struct Entry
enum class Priority { Release, Diode }

Public Functions

bool add(QcBlockPos pos, quint64 due, QcSignalSchedule::Priority priority)
QList<QcChunkPos> chunks() const
void clear()
bool contains(QcBlockPos pos) const
QList<QcSignalSchedule::Entry> entries() const
QList<QcSignalSchedule::Entry> entriesIn(QcChunkPos chunk) const
void forgetChunk(QcChunkPos chunk)
bool hasEntriesIn(QcChunkPos chunk) const
std::optional<std::pair<quint64, QcSignalSchedule::Priority>> nextGroup(quint64 now) const
void relocate(QcBlockPos from, QcBlockPos to)
void remove(QcBlockPos pos)
qsizetype size() const
QList<QcBlockPos> takeGroup(quint64 due, QcSignalSchedule::Priority priority)

Static Public Members

const int priorityCount

Detailed Description

One entry per position; asking again while one is pending keeps the earlier one. The entries of a chunk move and go with it (QcBlockEntities owns the schedule, decision E-357). Entries are due in the order of their tick and then their priority; everything of one tick and priority runs as one simultaneous step, so their order among each other never matters.

Member Type Documentation

enum class QcSignalSchedule::Priority

Steps within a tick, lowest first.

ConstantValueDescription
QcSignalSchedule::Priority::Release0Buttons and plates springing back, lamps going dark, burnt-out torches lighting again.
QcSignalSchedule::Priority::Diode1Torches and repeaters switching.

Member Function Documentation

bool QcSignalSchedule::add(QcBlockPos pos, quint64 due, QcSignalSchedule::Priority priority)

Adds an entry of pos due at due with priority unless the position has one. Returns false when it already had one.

QList<QcChunkPos> QcSignalSchedule::chunks() const

Returns the chunks that have entries.

void QcSignalSchedule::clear()

Drops every entry.

bool QcSignalSchedule::contains(QcBlockPos pos) const

Returns whether pos has an entry.

QList<QcSignalSchedule::Entry> QcSignalSchedule::entries() const

Returns every entry.

QList<QcSignalSchedule::Entry> QcSignalSchedule::entriesIn(QcChunkPos chunk) const

Returns the entries of chunk, in the order they are due.

void QcSignalSchedule::forgetChunk(QcChunkPos chunk)

Drops the entries of chunk (it was generated again).

bool QcSignalSchedule::hasEntriesIn(QcChunkPos chunk) const

Returns whether chunk has entries.

std::optional<std::pair<quint64, QcSignalSchedule::Priority>> QcSignalSchedule::nextGroup(quint64 now) const

Returns the tick and priority of the first group of entries due at now or before (overdue ones first), if any.

void QcSignalSchedule::relocate(QcBlockPos from, QcBlockPos to)

The entry of from (a component a piston moved) now belongs to to; when to has one too, the earlier of the two stays.

void QcSignalSchedule::remove(QcBlockPos pos)

Removes the entry of pos.

qsizetype QcSignalSchedule::size() const

Returns the number of entries.

QList<QcBlockPos> QcSignalSchedule::takeGroup(quint64 due, QcSignalSchedule::Priority priority)

Returns the positions of the entries of exactly the tick due and priority and takes them out.

Member Variable Documentation

const int QcSignalSchedule::priorityCount

The number of priorities.