ichunkloadingservice
This is an old revision of the document!
CREAT3D.ECS.Services.ChunkManagement
IChunkLoadingService
This service primary responsibility is to load and unload Chunks and by extensions through other services, Scenes, EntitySpawns and serialized Entities. It is heavily used during the game initialization process.
Broadcasts Events: ChunkLoadRequestedAsyncTopic, ChunkLoadCompleteAsyncTopic, ChunkUnloadRequestedAsyncTopic, ChunkUnloadCompleteAsyncTopic
Methods
| Method | Task LoadChunk(Chunk chunk, CancellationToken cancellationToken, bool cacheUnloadedChunks = true) |
|---|---|
| Description | Loads specified Chunk from its default state while first unloading all already loaded Chunks from the game. If cacheUnloadedChunks is true, the Chunks unloaded will keep a serialized state in memory to be serialized to a save file in the next serialization call. Their state is discarded if the boolean is set to false. Nothing happens if the Chunk is already loaded. |
| Method | Task LoadChunkAdditive(Chunk chunk, CancellationToken cancellationToken) |
|---|---|
| Description | Loads specified Chunk from its default state if not already loaded without unloading current Chunks. |
| Method | Task LoadChunkFromSave(Chunk chunk, EntityPacketCollection entities, bool containsEncodedPackets, CancellationToken cancellationToken, bool cacheUnloadedChunks = true) |
|---|---|
| Description | Loads specified Chunk from supplied EntityPacketCollection while first unloading all already loaded Chunks from the game. If cacheUnloadedChunks is true, the Chunks unloaded will keep a serialized state in memory to be serialized to a save file in the next serialization call. Their state is discarded if the boolean is set to false. Nothing happens if the Chunk is already loaded. The containsEncodedPackets boolean is meant to instruct how the EntityPacketCollection deserializes. Packet encoding reduces save file size by storing a packet's type as an integer instead of serializing its Type as a string value, but adding new packets will break the indexing and corrupt the save file. For more robust save files, set encoding to false. An EntityPacketCollection must deserialize with the same setting it was serialized. |
| Method | Task LoadChunkFromSaveAdditive(Chunk chunk, EntityPacketCollection entities, bool containsEncodedPackets, CancellationToken cancellationToken) |
|---|---|
| Description | Loads specified Chunk from supplied EntityPacketCollection without unloading current Chunks. Nothing happens if the Chunk is already loaded. The containsEncodedPackets boolean is meant to instruct how the EntityPacketCollection deserializes. Packet encoding reduces save file size by storing a packet's type as an integer instead of serializing its Type as a string value, but adding new packets will break the indexing and corrupt the save file. For more robust save files, set encoding to false. An EntityPacketCollection must deserialize with the same setting it was serialized. |
| Method | Task UnloadChunk(Chunk chunk, bool includeUnloadableChunks, CancellationToken cancellationToken, bool cacheUnloadedChunks = true) |
|---|---|
| Description | Unloads specified Chunk from the game. If cacheUnloadedChunks is true, the Chunk unloaded will keep a serialized state in memory to be serialized to a save file in the next serialization call. The state is discarded if the boolean is set to false. The includeUnloadableChunks boolean is used to override the Chunk's neverUnload setting. Setting the boolean to true will unload the Chunk even if it's set to never unload. |
| Method | Task UnloadAllChunks(bool includeUnloadableChunks, CancellationToken cancellationToken, bool cacheUnloadedChunks = true) |
|---|---|
| Description | Unloads all loaded Chunks from the game. If cacheUnloadedChunks is true, the Chunks unloaded will keep a serialized state in memory to be serialized to a save file in the next serialization call. The state is discarded if the boolean is set to false. The includeUnloadableChunks boolean is used to override neverUnload setting of the Chunks. Setting the boolean to true will unload all Chunks even if some are set to never unload. |
| Method | Task UnloadChunks(bool includeUnloadableChunks, CancellationToken cancellationToken, bool cacheUnloadedChunks = true, params Chunk[] chunks) |
|---|---|
| Description | Unloads all specified Chunks from the game. If cacheUnloadedChunks is true, the Chunks unloaded will keep a serialized state in memory to be serialized to a save file in the next serialization call. The state is discarded if the boolean is set to false. The includeUnloadableChunks boolean is used to override neverUnload setting of the Chunks. Setting the boolean to true will unload all Chunks even if some are set to never unload. |
ichunkloadingservice.1777135941.txt.gz · Last modified: by diviner
