QcBlastBlocks Class
The block side of explosions (decision E-602): the cells a blast breaks wait in order and are worked through at most explosionBlocksPerTick per tick (QcServerLimits), the rest in the next ticks; nothing is ever lost on the way, but a cell whose chunk left the world in the meantime is skipped. More...
| Header: | #include <server/explosions/QcBlastBlocks.h> |
Public Types
| struct | Effects |
Public Functions
| void | add(const QList<QcBlockPos> &cells, const QcBlastBlocks::Effects &effects) |
| quint64 | broken() const |
| bool | clear(QcBlockPos pos) |
| void | drop() |
| void | flush() |
| QList<QcPlacedBlock> | take(qint64 budget) |
| qsizetype | waiting() const |
Static Public Members
| QList<QcMsg::BlockBatch> | pieces(const QList<QcMsg::BlockUpdate> &updates, qsizetype most) |
Detailed Description
A cell holding an explosive is not broken but handed back to be lit (a chain reaction); any other cell becomes air quietly, drops its items with the blast's chance, lets the plants and an infested block react, and with a blast that sets fires may catch fire. Doors and beds break as a whole through QcServerBlocks. The clients get every cell set in a tick as one QcMsg::BlockBatch (several when there are more than QcMsg::BlockBatch::maxUpdates), so they relight and mesh each section once.
Member Function Documentation
void QcBlastBlocks::add(const QList<QcBlockPos> &cells, const QcBlastBlocks::Effects &effects)
Adds the cells a blast with effects breaks to the waiting cells.
quint64 QcBlastBlocks::broken() const
Returns the blocks broken since the server started.
bool QcBlastBlocks::clear(QcBlockPos pos)
Sets pos to air without telling the clients yet (a lit explosive leaves its cell). Returns false when the block could not be set.
void QcBlastBlocks::drop()
Forgets the waiting cells (the game rule explosionBlockDamage was switched off).
void QcBlastBlocks::flush()
Sends the cells set since the last flush to the clients that have their chunks, then lights the fires of blasts with fire.
[static] QList<QcMsg::BlockBatch> QcBlastBlocks::pieces(const QList<QcMsg::BlockUpdate> &updates, qsizetype most)
Returns updates cut into batches of at most most updates each, in order.
QList<QcPlacedBlock> QcBlastBlocks::take(qint64 budget)
Works through at most budget waiting cells; returns the explosives among them, still in place.
qsizetype QcBlastBlocks::waiting() const
Returns the number of waiting cells.