2022-05-10 07:11:11 +00:00
|
|
|
use crate::client::PreparedMsg;
|
2022-05-11 15:52:22 +00:00
|
|
|
use specs::Entity;
|
2022-05-08 23:11:46 +00:00
|
|
|
use vek::Vec2;
|
|
|
|
|
2022-05-11 15:52:22 +00:00
|
|
|
/// Sending a chunk to the user works the following way:
|
|
|
|
/// A system like `msg::terrain` `terrain` or `terrain_sync` either decide to
|
|
|
|
/// trigger chunk generation, or if the chunk already exists
|
|
|
|
/// push a `ChunkSendQueue` to the eventbus.
|
|
|
|
/// The `chunk_serialize` system will coordinate serializing via a SlowJob
|
|
|
|
/// outside of the tick. On the next tick, the `chunk_send` system will pick up
|
|
|
|
/// finished chunks.
|
|
|
|
///
|
2022-05-08 23:11:46 +00:00
|
|
|
/// Deferring allows us to remove code duplication and maybe serialize ONCE,
|
2022-05-11 15:52:22 +00:00
|
|
|
/// send to MULTIPLE clients
|
|
|
|
/// TODO: store a urgent flag and seperate even more, 5 ticks vs 5 seconds
|
2022-09-08 19:51:02 +00:00
|
|
|
#[derive(Debug, PartialEq, Eq)]
|
2022-05-11 19:50:14 +00:00
|
|
|
pub struct ChunkSendEntry {
|
2022-05-11 15:52:22 +00:00
|
|
|
pub(crate) entity: Entity,
|
|
|
|
pub(crate) chunk_key: Vec2<i32>,
|
2022-05-08 23:11:46 +00:00
|
|
|
}
|
2022-05-10 07:11:11 +00:00
|
|
|
|
|
|
|
pub struct SerializedChunk {
|
|
|
|
pub(crate) lossy_compression: bool,
|
|
|
|
pub(crate) msg: PreparedMsg,
|
|
|
|
pub(crate) recipients: Vec<Entity>,
|
|
|
|
}
|