QcClientWorld Class
Client-side mirror of the chunks the server sent. More...
| Header: | #include <clientcore/session/QcClientWorld.h> |
| Inherits: | QcBlockAccess |
Public Types
| struct | Memory |
Public Functions
| std::shared_ptr<const QcChunk> | chunk(QcChunkPos pos) const |
| qsizetype | chunkCount() const |
| QList<QcChunkPos> | chunkPositions() const |
| QcClientWorld::Memory | memory() const |
| void | removeChunk(QcChunkPos pos) |
| bool | setBlock(QcBlockPos pos, QcBlockId block) |
| QList<std::pair<QcBlockPos, QcBlockId>> | setBlocks(const QList<QcMsg::BlockUpdate> &updates) |
| void | setChunk(const std::shared_ptr<const QcChunk> &chunk) |
| std::shared_ptr<const QcContentRegistry> | sharedContent() const |
Reimplemented Public Functions
| virtual std::optional<QcBlockId> | blockAt(QcBlockPos pos) const override |
| virtual const QcContentRegistry & | content() const override |
| virtual bool | mayHaveLightSourceNear(QcBlockPos pos, int reach) const override |
Static Public Members
| bool | knowsBlocksOf(const QcChunk &chunk, const QcContentRegistry &content) |
Detailed Description
Chunks are immutable snapshots; a block update replaces the affected chunk with a modified copy so meshing threads never see a change mid-read.
Member Function Documentation
[override virtual] std::optional<QcBlockId> QcClientWorld::blockAt(QcBlockPos pos) const
Reimplements: QcBlockAccess::blockAt(QcBlockPos pos) const.
std::shared_ptr<const QcChunk> QcClientWorld::chunk(QcChunkPos pos) const
Returns the chunk at pos; null when it is not loaded.
See also setChunk().
qsizetype QcClientWorld::chunkCount() const
Returns the number of loaded chunks.
QList<QcChunkPos> QcClientWorld::chunkPositions() const
Returns the positions of the loaded chunks.
[override virtual] const QcContentRegistry &QcClientWorld::content() const
Reimplements: QcBlockAccess::content() const.
[static] bool QcClientWorld::knowsBlocksOf(const QcChunk &chunk, const QcContentRegistry &content)
Returns whether every block of chunk is known to content (a chunk of the server must be).
[override virtual] bool QcClientWorld::mayHaveLightSourceNear(QcBlockPos pos, int reach) const
Reimplements: QcBlockAccess::mayHaveLightSourceNear(QcBlockPos pos, int reach) const.
QcClientWorld::Memory QcClientWorld::memory() const
Returns what the blocks of the loaded chunks take.
void QcClientWorld::removeChunk(QcChunkPos pos)
Forgets the chunk at pos.
bool QcClientWorld::setBlock(QcBlockPos pos, QcBlockId block)
Sets the cell at pos to block in a copy of its chunk. Returns false outside the world height or a loaded chunk.
QList<std::pair<QcBlockPos, QcBlockId>> QcClientWorld::setBlocks(const QList<QcMsg::BlockUpdate> &updates)
Sets the blocks of the batch updates with one copy per chunk; returns the cells that changed with the blocks they held before (cells of chunks not loaded are left out).
void QcClientWorld::setChunk(const std::shared_ptr<const QcChunk> &chunk)
Takes chunk, replacing the one at its position.
See also chunk().
std::shared_ptr<const QcContentRegistry> QcClientWorld::sharedContent() const
Returns the content the world's blocks belong to, shared.