ChunkManager

Undocumented in source.

Members

Functions

addCurrentSnapshotUser
Timestamp addCurrentSnapshotUser(ChunkWorldPos cwp)

Returns timestamp of current chunk snapshot. Store this timestamp to use in removeSnapshotUser

commitSnapshots
void commitSnapshots(Timestamp currentTime)

called at the end of tick

getChunkSnapshot
Nullable!ChunkDataSnapshot getChunkSnapshot(ChunkWorldPos cwp)

returned value isNull if chunk is not loaded/added

getWriteBuffer
BlockId[] getWriteBuffer(ChunkWorldPos cwp)

Returns writeable copy of current chunk snapshot. Any changes made to it must be reported trough onBlockChanges method. This buffer is valid until commit. After commit this buffer becomes next immutable snapshot. Returns null if chunk is not added and/or not loaded.

onBlockChanges
void onBlockChanges(ChunkWorldPos cwp, R blockChanges)

Call this whenewer changes to write buffer are done. Those changes will be passed to chunkChangesHandlers to be handled when sendChanges is called.

onSnapshotLoaded
void onSnapshotLoaded(ChunkWorldPos cwp, ChunkDataSnapshot snap)

Internal. Called by code which loads chunks from storage.

onSnapshotSaved
void onSnapshotSaved(ChunkWorldPos cwp, ChunkDataSnapshot savedSnap)

Internal. Called by code which saves chunks to storage.

removeSnapshotUser
void removeSnapshotUser(ChunkWorldPos cwp, Timestamp timestamp)

Generic removal of snapshot user. Removes chunk if numUsers == 0. Use this to remove added snapshot user. Use timestamp returned from addCurrentSnapshotUser.

save
void save()

Performs save of all modified chunks. Modified chunks

sendChanges
void sendChanges()

Send changes to clients

setExternalChunkUsers
void setExternalChunkUsers(ChunkWorldPos cwp, size_t numExternalUsers)

Sets number of users of chunk at cwp. If total chunk users if greater than zero, then chunk is loaded, if equal to zero, chunk will be unloaded.

Variables

chunkChangesHandlers
void delegate(ChunkWorldPos, BlockChange[])[] chunkChangesHandlers;
Undocumented in source.
loadChunkHandler
void delegate(ChunkWorldPos cwp, BlockId[] outBuffer) loadChunkHandler;
Undocumented in source.
onChunkAddedHandlers
void delegate(ChunkWorldPos)[] onChunkAddedHandlers;
Undocumented in source.
onChunkLoadedHandlers
void delegate(ChunkWorldPos, ChunkDataSnapshot)[] onChunkLoadedHandlers;
Undocumented in source.
onChunkRemovedHandlers
void delegate(ChunkWorldPos)[] onChunkRemovedHandlers;
Undocumented in source.
saveChunkHandler
void delegate(ChunkWorldPos cwp, ChunkDataSnapshot snapshot) saveChunkHandler;
Undocumented in source.

Meta