mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-21 14:28:43 -06:00
preheat chunks on server
This commit is contained in:
parent
dac3c10aee
commit
11ad2cdc77
|
@ -5,6 +5,7 @@ timeout_ms = 10000
|
|||
|
||||
[world]
|
||||
seed = 0xfeb_face_dead_cafe
|
||||
preheat_radius = 8
|
||||
|
||||
[query]
|
||||
name = "Kubi Server"
|
||||
|
|
|
@ -13,6 +13,7 @@ pub struct ConfigTableServer {
|
|||
#[derive(Serialize, Deserialize)]
|
||||
pub struct ConfigTableWorld {
|
||||
pub seed: u64,
|
||||
pub preheat_radius: u32,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use shipyard::{World, Workload, IntoWorkload};
|
||||
use shipyard::{IntoWorkload, Workload, WorkloadModificator, World};
|
||||
use std::{thread, time::Duration};
|
||||
|
||||
mod util;
|
||||
|
@ -19,7 +19,7 @@ fn initialize() -> Workload {
|
|||
read_config,
|
||||
bind_server,
|
||||
init_client_maps,
|
||||
init_world,
|
||||
init_world.after_all(read_config),
|
||||
).into_workload()
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use shipyard::{Unique, UniqueView, UniqueViewMut, Workload, IntoWorkload, AllStoragesView, View, Get, NonSendSync, IntoIter};
|
||||
use shipyard::{AllStoragesView, Get, IntoIter, IntoWorkload, NonSendSync, SystemModificator, Unique, UniqueView, UniqueViewMut, View, Workload};
|
||||
use glam::IVec3;
|
||||
use hashbrown::HashMap;
|
||||
use kubi_shared::{
|
||||
|
@ -265,10 +265,33 @@ fn init_chunk_manager_and_block_queue(
|
|||
storages.add_unique(LocalBlockQueue::default());
|
||||
}
|
||||
|
||||
pub fn preheat_world(
|
||||
mut chunk_manager: UniqueViewMut<ChunkManager>,
|
||||
task_manager: UniqueView<ChunkTaskManager>,
|
||||
config: UniqueView<ConfigTable>,
|
||||
) {
|
||||
let r = config.world.preheat_radius as i32;
|
||||
for x in -r..=r {
|
||||
for y in -r..=r {
|
||||
for z in -r..=r {
|
||||
let chunk_position = IVec3::new(x, y, z);
|
||||
let mut chunk = Chunk::new();
|
||||
chunk.state = ChunkState::Loading;
|
||||
chunk_manager.chunks.insert(chunk_position, chunk);
|
||||
task_manager.spawn_task(ChunkTask::LoadChunk {
|
||||
position: chunk_position,
|
||||
seed: config.world.seed,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn init_world() -> Workload {
|
||||
(
|
||||
init_chunk_manager_and_block_queue,
|
||||
init_chunk_task_manager,
|
||||
init_chunk_manager_and_block_queue.before_all(preheat_world),
|
||||
init_chunk_task_manager.before_all(preheat_world),
|
||||
preheat_world,
|
||||
).into_workload()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue