mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-21 22:38:41 -06:00
wip server chunks
This commit is contained in:
parent
f4bbfd3e8a
commit
a470543325
|
@ -54,6 +54,7 @@ fn process_chunk_requests(
|
|||
} else {
|
||||
let mut chunk = Chunk::new(chunk_position);
|
||||
chunk.state = ChunkState::Loading;
|
||||
chunk.subscriptions.insert(*client_id);
|
||||
chunk_manager.chunks.insert(chunk_position, chunk);
|
||||
task_manager.spawn_task(ChunkTask::LoadChunk {
|
||||
position: chunk_position,
|
||||
|
@ -88,6 +89,7 @@ fn process_finished_tasks(
|
|||
queued: queue.iter().map(|item| (item.position.to_array(), item.block_type)).collect()
|
||||
}).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");
|
||||
assert_eq!(data, STC_MSG, "Received message not equal");
|
||||
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 glium::glutin::event::VirtualKeyCode;
|
||||
use glam::{Mat3, vec2};
|
||||
use crate::{
|
||||
world::ChunkStorage,
|
||||
|
@ -7,7 +8,9 @@ use crate::{
|
|||
gui::{
|
||||
GuiComponent,
|
||||
progressbar::ProgressbarComponent
|
||||
}, rendering::{WindowSize, if_resized},
|
||||
},
|
||||
rendering::{WindowSize, if_resized},
|
||||
input::RawKbmInputState,
|
||||
};
|
||||
|
||||
#[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(
|
||||
mut storages: AllStoragesViewMut,
|
||||
) {
|
||||
|
@ -85,6 +97,7 @@ pub fn update_loading_screen() -> Workload {
|
|||
spawn_loading_screen.run_if_missing_unique::<ProgressbarId>(),
|
||||
resize_progress_bar.run_if(if_resized),
|
||||
update_progress_bar_progress,
|
||||
override_loading,
|
||||
switch_to_ingame_if_loaded,
|
||||
despawn_loading_screen_if_switching_state.run_if(is_changing_state),
|
||||
).into_workload()
|
||||
|
|
|
@ -110,7 +110,7 @@ fn update() -> Workload {
|
|||
(
|
||||
update_networking,
|
||||
inject_network_responses_into_manager_queue,
|
||||
).into_workload().run_if(is_multiplayer),
|
||||
).into_sequential_workload().run_if(is_multiplayer),
|
||||
(
|
||||
switch_to_loading_if_connected
|
||||
).into_workload().run_if(is_connecting),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use flume::{Sender, Receiver};
|
||||
use glam::IVec3;
|
||||
use kubi_shared::{
|
||||
networking::messages::{ClientToServerMessage, ServerToClientMessage},
|
||||
networking::messages::ServerToClientMessage,
|
||||
worldgen::QueuedBlock
|
||||
};
|
||||
use shipyard::{Unique, UniqueView, View, IntoIter};
|
||||
|
@ -13,7 +13,7 @@ use super::{
|
|||
};
|
||||
use crate::{
|
||||
rendering::world::ChunkVertex,
|
||||
networking::{UdpClient, NetworkEvent}
|
||||
networking::NetworkEvent,
|
||||
};
|
||||
use kubi_udp::client::ClientEvent;
|
||||
|
||||
|
|
Loading…
Reference in a new issue