mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-12-25 21:28:20 -06:00
wip server chunks
This commit is contained in:
parent
38d686e583
commit
4c31eab0f4
|
@ -54,6 +54,7 @@ fn process_chunk_requests(
|
||||||
} else {
|
} else {
|
||||||
let mut chunk = Chunk::new(chunk_position);
|
let mut chunk = Chunk::new(chunk_position);
|
||||||
chunk.state = ChunkState::Loading;
|
chunk.state = ChunkState::Loading;
|
||||||
|
chunk.subscriptions.insert(*client_id);
|
||||||
chunk_manager.chunks.insert(chunk_position, chunk);
|
chunk_manager.chunks.insert(chunk_position, chunk);
|
||||||
task_manager.spawn_task(ChunkTask::LoadChunk {
|
task_manager.spawn_task(ChunkTask::LoadChunk {
|
||||||
position: chunk_position,
|
position: chunk_position,
|
||||||
|
@ -88,6 +89,7 @@ fn process_finished_tasks(
|
||||||
queued: queue.iter().map(|item| (item.position.to_array(), item.block_type)).collect()
|
queued: queue.iter().map(|item| (item.position.to_array(), item.block_type)).collect()
|
||||||
}).map_err(log_error).ok();
|
}).map_err(log_error).ok();
|
||||||
}
|
}
|
||||||
|
log::debug!("Chunk {chunk_position} loaded, {} subs", chunk.subscriptions.len())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ fn test_connection() {
|
||||||
log::info!("client received message");
|
log::info!("client received message");
|
||||||
assert_eq!(data, STC_MSG, "Received message not equal");
|
assert_eq!(data, STC_MSG, "Received message not equal");
|
||||||
message_received = true;
|
message_received = true;
|
||||||
client.disconnect();
|
client.disconnect().unwrap();
|
||||||
},
|
},
|
||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use shipyard::{UniqueView, UniqueViewMut, Workload, IntoWorkload, EntityId, Unique, AllStoragesViewMut, ViewMut, Get, SystemModificator, track};
|
use shipyard::{UniqueView, UniqueViewMut, Workload, IntoWorkload, EntityId, Unique, AllStoragesViewMut, ViewMut, Get, SystemModificator, track};
|
||||||
|
use glium::glutin::event::VirtualKeyCode;
|
||||||
use glam::{Mat3, vec2};
|
use glam::{Mat3, vec2};
|
||||||
use crate::{
|
use crate::{
|
||||||
world::ChunkStorage,
|
world::ChunkStorage,
|
||||||
|
@ -7,7 +8,9 @@ use crate::{
|
||||||
gui::{
|
gui::{
|
||||||
GuiComponent,
|
GuiComponent,
|
||||||
progressbar::ProgressbarComponent
|
progressbar::ProgressbarComponent
|
||||||
}, rendering::{WindowSize, if_resized},
|
},
|
||||||
|
rendering::{WindowSize, if_resized},
|
||||||
|
input::RawKbmInputState,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Unique, Clone, Copy)]
|
#[derive(Unique, Clone, Copy)]
|
||||||
|
@ -69,6 +72,15 @@ fn switch_to_ingame_if_loaded(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn override_loading(
|
||||||
|
kbm_state: UniqueView<RawKbmInputState>,
|
||||||
|
mut state: UniqueViewMut<NextState>
|
||||||
|
) {
|
||||||
|
if kbm_state.keyboard_state.contains(&VirtualKeyCode::F) {
|
||||||
|
state.0 = Some(GameState::InGame);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn despawn_loading_screen_if_switching_state(
|
fn despawn_loading_screen_if_switching_state(
|
||||||
mut storages: AllStoragesViewMut,
|
mut storages: AllStoragesViewMut,
|
||||||
) {
|
) {
|
||||||
|
@ -85,6 +97,7 @@ pub fn update_loading_screen() -> Workload {
|
||||||
spawn_loading_screen.run_if_missing_unique::<ProgressbarId>(),
|
spawn_loading_screen.run_if_missing_unique::<ProgressbarId>(),
|
||||||
resize_progress_bar.run_if(if_resized),
|
resize_progress_bar.run_if(if_resized),
|
||||||
update_progress_bar_progress,
|
update_progress_bar_progress,
|
||||||
|
override_loading,
|
||||||
switch_to_ingame_if_loaded,
|
switch_to_ingame_if_loaded,
|
||||||
despawn_loading_screen_if_switching_state.run_if(is_changing_state),
|
despawn_loading_screen_if_switching_state.run_if(is_changing_state),
|
||||||
).into_workload()
|
).into_workload()
|
||||||
|
|
|
@ -110,7 +110,7 @@ fn update() -> Workload {
|
||||||
(
|
(
|
||||||
update_networking,
|
update_networking,
|
||||||
inject_network_responses_into_manager_queue,
|
inject_network_responses_into_manager_queue,
|
||||||
).into_workload().run_if(is_multiplayer),
|
).into_sequential_workload().run_if(is_multiplayer),
|
||||||
(
|
(
|
||||||
switch_to_loading_if_connected
|
switch_to_loading_if_connected
|
||||||
).into_workload().run_if(is_connecting),
|
).into_workload().run_if(is_connecting),
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use flume::{Sender, Receiver};
|
use flume::{Sender, Receiver};
|
||||||
use glam::IVec3;
|
use glam::IVec3;
|
||||||
use kubi_shared::{
|
use kubi_shared::{
|
||||||
networking::messages::{ClientToServerMessage, ServerToClientMessage},
|
networking::messages::ServerToClientMessage,
|
||||||
worldgen::QueuedBlock
|
worldgen::QueuedBlock
|
||||||
};
|
};
|
||||||
use shipyard::{Unique, UniqueView, View, IntoIter};
|
use shipyard::{Unique, UniqueView, View, IntoIter};
|
||||||
|
@ -13,7 +13,7 @@ use super::{
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
rendering::world::ChunkVertex,
|
rendering::world::ChunkVertex,
|
||||||
networking::{UdpClient, NetworkEvent}
|
networking::NetworkEvent,
|
||||||
};
|
};
|
||||||
use kubi_udp::client::ClientEvent;
|
use kubi_udp::client::ClientEvent;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue