QtCraft API C++ classes QML types Handbook

QcHangingManager Class

Item frames and paintings of a world (decision E-790): placed entities without AI, health or physics. More...

Header: #include <server/hanging/QcHangingManager.h>

Public Functions

bool add(const QcHangingEntity &hanging)
qsizetype adopt(const QList<QcHangingEntity> &hangings)
const QList<QcHangingEntity> &all() const
const QcHangingEntity *at(QcBlockPos cell, QcBlockFace face) const
QList<QcHangingEntity> &editableAll()
QcHangingEntity *find(quint32 id)
const QcHangingEntity *find(quint32 id) const
qsizetype limit() const
void noteBlockChange(QcBlockPos pos)
std::optional<QcHangingEntity> remove(quint32 id)
void removeIf(const std::function<bool (const QcEntity &)> &matches)
void setLimit(qsizetype limit)
QList<quint32> takeDueChecks()

Static Public Members

const int maxHangings
const int supportCheckTicks

Detailed Description

Pure data; QcServerHanging does what players and the world do to them.

Member Function Documentation

bool QcHangingManager::add(const QcHangingEntity &hanging)

Adds hanging. Returns false when the limit is reached.

qsizetype QcHangingManager::adopt(const QList<QcHangingEntity> &hangings)

Adds the hangings of a chunk that came back (decision E-374); returns how many were left out at the limit.

const QList<QcHangingEntity> &QcHangingManager::all() const

Returns every frame and painting.

const QcHangingEntity *QcHangingManager::at(QcBlockPos cell, QcBlockFace face) const

Returns the frame or painting that covers cell on face; null for none.

QList<QcHangingEntity> &QcHangingManager::editableAll()

Returns the frames and paintings for waking and settling from outside (QcEntities); never add, remove or move through it (the cell index would go stale).

QcHangingEntity *QcHangingManager::find(quint32 id)

Returns the frame or painting with entity id, or null when there is none.

const QcHangingEntity *QcHangingManager::find(quint32 id) const

Returns the frame or painting with entity id, or null when there is none.

qsizetype QcHangingManager::limit() const

Returns the number of frames and paintings the world may hold.

See also setLimit().

void QcHangingManager::noteBlockChange(QcBlockPos pos)

A block changed at pos: the frames and paintings it holds or stands in check again (decision E-790). One hash lookup, so a change far from any costs nothing.

std::optional<QcHangingEntity> QcHangingManager::remove(quint32 id)

Removes the frame or painting with entity id. Returns it (to drop what it carried), or nothing when there is none.

void QcHangingManager::removeIf(const std::function<bool (const QcEntity &)> &matches)

Removes those for which matches is true (their chunk leaves the world).

void QcHangingManager::setLimit(qsizetype limit)

Sets the number of frames and paintings the world may hold to limit.

See also limit().

QList<quint32> QcHangingManager::takeDueChecks()

Returns the ids to check this tick: those next to changed blocks and the next slice of the round in which every one is checked once per supportCheckTicks ticks.

Member Variable Documentation

const int QcHangingManager::maxHangings

Frames and paintings in the world by default (QcServerLimits::maxHangings).

const int QcHangingManager::supportCheckTicks

Every frame and painting checks its wall and room again within this many ticks, also without a block change next to it (decision E-790; changes outside the server's block changes).