ChunkManager

Undocumented in source.

Members

Functions

addCurrentSnapshotUser
TimestampType addCurrentSnapshotUser(ChunkWorldPos cwp)

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

commitSnapshots
void commitSnapshots(TimestampType currentTime)

called at the end of tick

getChunkSnapshot
Nullable!BlockDataSnapshot getChunkSnapshot(ChunkWorldPos cwp)

returned value isNull if chunk is not loaded/added

getWriteBuffer
BlockType[] 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, BlockDataSnapshot snap)

Internal. Called by code which loads chunks from storage.

onSnapshotSaved
void onSnapshotSaved(ChunkWorldPos cwp, TimestampType timestamp)

Internal. Called by code which saves chunks to storage.

removeSnapshotUser
void removeSnapshotUser(ChunkWorldPos cwp, TimestampType 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 are those that were committed. Perform save right after commit.

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(BlockChange[][ChunkWorldPos])[] chunkChangesHandlers;
Undocumented in source.
loadChunkHandler
void delegate(ChunkWorldPos cwp, BlockType[] outBuffer) loadChunkHandler;
Undocumented in source.
onChunkAddedHandlers
void delegate(ChunkWorldPos)[] onChunkAddedHandlers;
Undocumented in source.
onChunkLoadedHandlers
void delegate(ChunkWorldPos, BlockDataSnapshot)[] onChunkLoadedHandlers;
Undocumented in source.
onChunkRemovedHandlers
void delegate(ChunkWorldPos)[] onChunkRemovedHandlers;
Undocumented in source.
saveChunkHandler
void delegate(ChunkWorldPos cwp, BlockDataSnapshot snapshot) saveChunkHandler;
Undocumented in source.

Meta