QcMinecartManager Class
The minecarts of a world (decision E-382), the table of their kind in the entity register: adding, finding and removing them within the world's limit, and their movement in a tick: the carts meet each other and the living bodies (QcMinecartCollisions), then every awake cart moves on its own (QcMinecartMotion), and none ends deeper in a cart it overlapped. More...
| Header: | #include <server/minecarts/QcMinecartManager.h> |
Public Types
| struct | Load |
Public Functions
| const QList<quint32> & | activated() const |
| bool | add(const QcMinecart &cart) |
| qsizetype | adopt(const QList<QcMinecart> &carts) |
| const QList<QcMinecart> & | all() const |
| QList<const QcMinecart *> | containersIn(QcBlockPos cell) const |
| QList<QcMinecart> & | editableAll() |
| QcMinecart * | find(quint32 id) |
| const QcMinecart * | find(quint32 id) const |
| void | forgetTick() |
| QcMinecart | fromItem(const QString &item) const |
| qsizetype | limit() const |
| QcMinecartManager::Load | loadOf(const QcMinecart &cart) const |
| const QcRails::Table & | rails() const |
| std::optional<QcMinecart> | remove(quint32 id) |
| QcMinecart * | ridden(quint32 player) |
| const QcMinecart * | ridden(quint32 player) const |
| void | setLimit(qsizetype limit) |
| void | tick(const QcBlockAccess &world, const QList<QcAabb> &bodies, double dt) |
Static Public Members
Detailed Description
A cart at rest on a level rail (or held at the lower end of a slope) is not stepped until something moves it or its rail or the cells beyond its ends change.
Member Function Documentation
const QList<quint32> &QcMinecartManager::activated() const
Returns the carts (ids) that were on a powered activator rail in the latest tick (their riders get out).
bool QcMinecartManager::add(const QcMinecart &cart)
Adds cart. Returns false when the limit is reached.
qsizetype QcMinecartManager::adopt(const QList<QcMinecart> &carts)
Adds the carts of a chunk that came back (decision E-374); returns how many were left out at the limit.
const QList<QcMinecart> &QcMinecartManager::all() const
Returns every cart.
[static] QcAabb QcMinecartManager::bodyOf(const QcMinecart &cart)
Returns the box of the body of cart.
QList<const QcMinecart *> QcMinecartManager::containersIn(QcBlockPos cell) const
Returns the container carts whose feet lie in cell (a detector rail's or a hopper's pickup cell), by id.
QList<QcMinecart> &QcMinecartManager::editableAll()
Returns the carts for moving them from outside (pistons, riders); never add or remove through it.
QcMinecart *QcMinecartManager::find(quint32 id)
Returns the cart with entity id, or null when there is none.
const QcMinecart *QcMinecartManager::find(quint32 id) const
Returns the cart with entity id, or null when there is none.
void QcMinecartManager::forgetTick()
A tick without carts: nothing was activated.
QcMinecart QcMinecartManager::fromItem(const QString &item) const
Returns a cart of item with empty slots for what it carries (no id, no place yet).
qsizetype QcMinecartManager::limit() const
Returns the number of carts the world may hold.
See also setLimit().
QcMinecartManager::Load QcMinecartManager::loadOf(const QcMinecart &cart) const
Returns what cart carries, from its item.
const QcRails::Table &QcMinecartManager::rails() const
Returns the rail tracks of the content's blocks.
std::optional<QcMinecart> QcMinecartManager::remove(quint32 id)
Removes the cart with entity id. Returns it, or nothing when there is none.
QcMinecart *QcMinecartManager::ridden(quint32 player)
Returns the cart the player (entity id) rides; null for none.
const QcMinecart *QcMinecartManager::ridden(quint32 player) const
Returns the cart the player (entity id) rides; null for none.
void QcMinecartManager::setLimit(qsizetype limit)
Sets the number of carts the world may hold to limit.
See also limit().
void QcMinecartManager::tick(const QcBlockAccess &world, const QList<QcAabb> &bodies, double dt)
Pushes between carts and from bodies (boxes of living bodies that ride no cart), then moves every awake cart in world by dt seconds. A cart on a powered activator rail stops pulling (hopper carts) and is noted for activated(); on an unpowered one it pulls again.
Member Variable Documentation
const int QcMinecartManager::maxCarts
Carts in the world by default (QcServerLimits::maxMinecarts).