diff --git a/kubi-shared/src/lib.rs b/kubi-shared/src/lib.rs index 79f16a7..10ea49c 100644 --- a/kubi-shared/src/lib.rs +++ b/kubi-shared/src/lib.rs @@ -4,4 +4,5 @@ pub mod worldgen; pub mod chunk; pub mod transform; pub mod entity; +pub mod player; pub mod queue; diff --git a/kubi-shared/src/player.rs b/kubi-shared/src/player.rs new file mode 100644 index 0000000..d2df58c --- /dev/null +++ b/kubi-shared/src/player.rs @@ -0,0 +1,4 @@ +use shipyard::Component; + +#[derive(Component)] +pub struct Player; diff --git a/kubi/src/main.rs b/kubi/src/main.rs index 76481e5..cee099f 100644 --- a/kubi/src/main.rs +++ b/kubi/src/main.rs @@ -7,7 +7,8 @@ use shipyard::{ World, Workload, IntoWorkload, UniqueView, UniqueViewMut, - NonSendSync, WorkloadModificator, SystemModificator + NonSendSync, WorkloadModificator, + SystemModificator }; use glium::{ glutin::{ @@ -46,9 +47,9 @@ use world::{ loading::update_loaded_world_around_player, raycast::update_raycasts, queue::apply_queued_blocks, - tasks::inject_network_responses_into_manager_queue + tasks::inject_network_responses_into_manager_queue, ChunkStorage }; -use player::spawn_player; +use player::{spawn_player, MainPlayer}; use prefabs::load_prefabs; use settings::load_settings; use camera::compute_cameras; @@ -96,8 +97,8 @@ fn startup() -> Workload { lock_cursor_now, init_input, init_gui, - init_game_world, - spawn_player, + + insert_control_flow_unique, init_delta_time, ).into_workload() @@ -107,6 +108,10 @@ fn update() -> Workload { update_window_size, update_cursor_lock_state, process_inputs, + ( + init_game_world.run_if_missing_unique::(), + spawn_player.run_if_storage_empty::(), + ).into_workload().run_if(is_ingame_or_loading), ( update_networking, inject_network_responses_into_manager_queue, diff --git a/kubi/src/player.rs b/kubi/src/player.rs index cc1e705..0ae0a9a 100644 --- a/kubi/src/player.rs +++ b/kubi/src/player.rs @@ -1,4 +1,4 @@ -use shipyard::{Component, AllStoragesViewMut}; +use shipyard::{Component, AllStoragesViewMut, View, IntoIter}; use crate::{ transform::Transform, camera::Camera, @@ -6,9 +6,7 @@ use crate::{ world::raycast::LookingAtBlock, block_placement::PlayerHolding, }; - -#[derive(Component)] -pub struct Player; +pub use kubi_shared::player::Player; #[derive(Component)] pub struct MainPlayer; @@ -17,7 +15,7 @@ pub fn spawn_player ( mut storages: AllStoragesViewMut ) { log::info!("spawning player"); - storages.add_entity(( + let entity_id = storages.add_entity(( Player, MainPlayer, Transform::default(), diff --git a/kubi/src/world/mesh/builder.rs b/kubi/src/world/mesh/builder.rs index ed1ffd7..fb5949e 100644 --- a/kubi/src/world/mesh/builder.rs +++ b/kubi/src/world/mesh/builder.rs @@ -126,7 +126,7 @@ impl MeshBuilder { let face_type = face_type as usize; let vertices = CROSS_FACES[face_type]; let normal_front = CROSS_FACE_NORMALS[face_type].to_array(); - let normal_back = CROSS_FACE_NORMALS[face_type].to_array(); + let normal_back = CROSS_FACE_NORMALS_BACK[face_type].to_array(); self.vertex_buffer.reserve(8); for i in 0..4 { //push front vertices self.vertex_buffer.push(ChunkVertex {