diff --git a/backup b/backup index 1973049..4702625 100644 --- a/backup +++ b/backup @@ -6,4 +6,10 @@ Lz4压缩解压 https://crates.io/crates/lz4 mesh周围添加外边框 https://github.com/komadori/bevy_mod_outline 视觉特效包 https://github.com/torsteingrindvik/bevy-vfx-bag (暂时没有更新到0.11.0) 草的mesh 生成https://github.com/EmiOnGit/warbler_grass -3d的2D精灵 https://github.com/FraserLee/bevy_sprite3d \ No newline at end of file +3d的2D精灵 https://github.com/FraserLee/bevy_sprite3d + +运动学 https://github.com/Kurble/bevy_mod_inverse_kinematics +别人的技能整理 https://github.com/NexusSocial/skilltree +载具可能的例子 https://github.com/gavlig/gryazevichki +glrf生成碰撞mesh的库 https://github.com/Defernus/bevy_gltf_collider +画笔工具 https://github.com/eliotbo/bevy_pen_tool \ No newline at end of file diff --git a/src/client/mesh_display.rs b/src/client/mesh_display.rs index 089b117..3e36ce4 100644 --- a/src/client/mesh_display.rs +++ b/src/client/mesh_display.rs @@ -23,8 +23,8 @@ use crate::{ tools::get_all_v_chunk, voxel_world::{ chunk::{ - find_chunk_keys_array_by_shpere_y_0, generate_offset_resoure, - generate_offset_resoure_min_1, ChunkKey, NeighbourOffest, + find_chunk_keys_array_by_sphere_y_0, generate_offset_resource, + generate_offset_resource_min_1, ChunkKey, NeighbourOffset, }, chunk_map::ChunkMap, compress::uncompress, @@ -75,7 +75,7 @@ impl Plugin for ClientMeshPlugin { app.insert_resource(ChunkMap::new()); app.insert_resource(MeshManager::default()); app.insert_resource(MeshTasks { tasks: Vec::new() }); - app.insert_resource(generate_offset_resoure(VIEW_RADIUS)); + app.insert_resource(generate_offset_resource(VIEW_RADIUS)); app.insert_resource(ChunkSyncTask { tasks: Vec::new() }); app.insert_resource(ChunkUpdateTask { tasks: Vec::new() }); app.insert_resource(CycleCheckTimer(Timer::new( @@ -119,13 +119,13 @@ pub fn gen_mesh_system( chunk_map: Res, mut mesh_manager: ResMut, clip_spheres: Res, - neighbour_offest: Res, + neighbour_offest: Res, mut mesh_task: ResMut, mut client: ResMut, ) { let pool = AsyncComputeTaskPool::get(); for key in - find_chunk_keys_array_by_shpere_y_0(clip_spheres.new_sphere, neighbour_offest.0.clone()) + find_chunk_keys_array_by_sphere_y_0(clip_spheres.new_sphere, neighbour_offest.0.clone()) .drain(..) { if !mesh_manager.entities.contains_key(&key) && !mesh_manager.fast_key.contains(&key) { @@ -423,19 +423,19 @@ pub fn update_mesh_system( pub fn deleter_mesh_system( mut commands: Commands, mut mesh_manager: ResMut, - neighbour_offest: Res, + neighbour_offest: Res, clip_spheres: Res, ) { let mut chunks_to_remove = HashSet::new(); for key in - find_chunk_keys_array_by_shpere_y_0(clip_spheres.old_sphere, neighbour_offest.0.clone()) + find_chunk_keys_array_by_sphere_y_0(clip_spheres.old_sphere, neighbour_offest.0.clone()) .drain(..) { chunks_to_remove.insert(key); } for key in - find_chunk_keys_array_by_shpere_y_0(clip_spheres.new_sphere, neighbour_offest.0.clone()) + find_chunk_keys_array_by_sphere_y_0(clip_spheres.new_sphere, neighbour_offest.0.clone()) .drain(..) { chunks_to_remove.remove(&key); @@ -468,9 +468,9 @@ fn cycle_check_mesh( ) { timer.0.tick(time.delta()); if timer.0.finished() { - let need_keys: HashSet = find_chunk_keys_array_by_shpere_y_0( + let need_keys: HashSet = find_chunk_keys_array_by_sphere_y_0( clip_spheres.new_sphere, - generate_offset_resoure_min_1(VIEW_RADIUS).0, + generate_offset_resource_min_1(VIEW_RADIUS).0, ) .iter() .copied() diff --git a/src/client/message_def/staff_rule_message.rs b/src/client/message_def/staff_rule_message.rs index 5eeb38a..2fda8d6 100644 --- a/src/client/message_def/staff_rule_message.rs +++ b/src/client/message_def/staff_rule_message.rs @@ -5,5 +5,5 @@ use serde::{Deserialize, Serialize}; pub struct StaffRuleMessage { pub staff_rule_id: u32, pub need: Vec<(usize, usize, usize)>, - pub times:usize, + pub times: usize, } diff --git a/src/server/async_chunk.rs b/src/server/async_chunk.rs index 2520bcf..9f9c1f5 100644 --- a/src/server/async_chunk.rs +++ b/src/server/async_chunk.rs @@ -15,7 +15,7 @@ use crate::{ chunk_map::ChunkMap, compress::compress, map_database::{DbSaveTasks, MapDataBase}, - player_state::PlayerOntimeState, + player_state::PlayerOnTimeState, voxel::{BasicStone, Voxel, VoxelMaterial}, }, CHUNK_SIZE, CHUNK_SIZE_U32, @@ -46,7 +46,7 @@ pub fn deal_chunk_query_system( mut fill_event: EventWriter, staff_info_stroge: Res, // 获取玩家当前状态 和处理 - mut query_state: Query<&mut PlayerOntimeState>, + mut query_state: Query<&mut PlayerOnTimeState>, server_lobby: Res, mut other_tree_tasks_map: ResMut, ) { diff --git a/src/server/chunk.rs b/src/server/chunk.rs index a4cc2eb..9b45cd2 100644 --- a/src/server/chunk.rs +++ b/src/server/chunk.rs @@ -5,7 +5,7 @@ use crate::{ voxel_world::{ biomes::OtherTreeTasksMap, chunk::{ - find_chunk_keys_by_shpere_to_full_height, generate_offset_resoure, NeighbourOffest, + find_chunk_keys_by_sphere_to_full_height, generate_offset_resource, NeighbourOffset, }, chunk_map::ChunkMap, map_database::{save_db_task_system, DbSaveTasks, MapDataBase}, @@ -18,7 +18,7 @@ use crate::{ */ pub fn server_chunk_generate_system( mut chunk_map: ResMut, - neighbour_offest: Res, + neighbour_offest: Res, server_clip_spheres: Res, mut db: ResMut, mut db_save_tasks: ResMut, @@ -26,7 +26,7 @@ pub fn server_chunk_generate_system( ) { for (_client_id, clip_spheres) in server_clip_spheres.clip_spheres.iter() { // 通过球体计算 chunkey - find_chunk_keys_by_shpere_to_full_height( + find_chunk_keys_by_sphere_to_full_height( clip_spheres.new_sphere, neighbour_offest.0.clone(), |key| { @@ -52,7 +52,7 @@ impl Plugin for ServerChunkPlugin { fn build(&self, app: &mut bevy::prelude::App) { // init MapData app.insert_resource(MapDataBase::new(WORD_PATH)); - app.insert_resource(generate_offset_resoure(VIEW_RADIUS)); + app.insert_resource(generate_offset_resource(VIEW_RADIUS)); app.insert_resource(ChunkMap::new()); app.insert_resource(DbSaveTasks { tasks: Vec::new() }); diff --git a/src/server/mod.rs b/src/server/mod.rs index 745d04c..bde84e5 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -16,7 +16,7 @@ use crate::{ users::Username, voxel_world::{ map_database::MapDataBase, - player_state::{PlayerOntimeState, PlayerState, StorgePlayerState}, + player_state::{PlayerOnTimeState, PlayerState, StoragePlayerState}, }, }; @@ -43,7 +43,7 @@ pub fn server_connect_system( mut commands: Commands, mut server_events: EventReader, mut visualizer: ResMut>, - players: Query<(Entity, &Player, &Transform, &PlayerOntimeState)>, + players: Query<(Entity, &Player, &Transform, &PlayerOnTimeState)>, mut server: ResMut, mut server_lobby: ResMut, transport: Res, diff --git a/src/server/object_filing/follow.rs b/src/server/object_filing/follow.rs index 5991e40..9ef61b2 100644 --- a/src/server/object_filing/follow.rs +++ b/src/server/object_filing/follow.rs @@ -25,7 +25,7 @@ use crate::{ message_def::{tool_bar_message::ToolBarMessage, ServerChannel}, player::Player, }, - voxel_world::player_state::PlayerOntimeState, + voxel_world::player_state::PlayerOnTimeState, CLOSE_RANGE, NEAR_RANGE, PICK_SPEED, }; @@ -211,7 +211,7 @@ fn not_follow_change_type( fn pick_up_entity( mut commands: Commands, // 有状态的角色 - mut palyer_states: Query<(Entity, &Player, &mut PlayerOntimeState)>, + mut palyer_states: Query<(Entity, &Player, &mut PlayerOnTimeState)>, // 被捡起的数据 pick_query: Query<(Entity, &FilledObject, &Picked)>, mut server: ResMut, @@ -220,7 +220,7 @@ fn pick_up_entity( // 1. 获取到pick的目标受体 if let Ok((_, player, mut player_state)) = palyer_states.get_mut(picked.target) { // 2. 检查可以使用的空位 并修改数据 - if let Some((index, _, num)) = player_state.0.put_statff(filled_object.staff.id) { + if let Some((index, _, num)) = player_state.0.put_staff(filled_object.staff.id) { // 找到位置并摆放 // 发送消息销毁对象 let message = bincode::serialize(&ToolBarMessage::SyncToolbar { diff --git a/src/server/object_filing/mod.rs b/src/server/object_filing/mod.rs index 4cff2ab..762af67 100644 --- a/src/server/object_filing/mod.rs +++ b/src/server/object_filing/mod.rs @@ -18,7 +18,7 @@ use crate::{ staff::{Staff, StaffInfoStroge}, tools::vec3_to_chunk_key_any_xyz, voxel_world::{ - chunk::{find_chunk_keys_array_by_shpere, generate_offset_array, ChunkKey}, + chunk::{find_chunk_keys_array_by_sphere, generate_offset_array, ChunkKey}, map_database::MapDataBase, }, PY_DISTANCE, @@ -115,7 +115,7 @@ fn sync_filled_object_to_client( for (client_id, clip_spheres) in server_clip_spheres.clip_spheres.iter() { let mut staff_list: Vec<(Entity, usize, [f32; 3])> = Vec::new(); // 对每个球体展开一阶 - for chunk_key in find_chunk_keys_array_by_shpere( + for chunk_key in find_chunk_keys_array_by_sphere( clip_spheres.new_sphere, generate_offset_array(PY_DISTANCE), ) @@ -201,7 +201,7 @@ fn load_filled( ) { let mut hashed_object = map_chunk_key_filled_object(&query); for (_, clip_spheres) in server_clip_spheres.clip_spheres.iter() { - for chunk_key in find_chunk_keys_array_by_shpere( + for chunk_key in find_chunk_keys_array_by_sphere( clip_spheres.new_sphere, generate_offset_array(PY_DISTANCE), ) diff --git a/src/server/object_filing/put_object.rs b/src/server/object_filing/put_object.rs index ab54f4c..2bdc546 100644 --- a/src/server/object_filing/put_object.rs +++ b/src/server/object_filing/put_object.rs @@ -6,14 +6,14 @@ use crate::{ message_def::{tool_bar_message::ToolBarMessage, ServerChannel}, player::ServerLobby, }, - voxel_world::player_state::PlayerOntimeState, + voxel_world::player_state::PlayerOnTimeState, }; /// 放置方块。如果成功修改toolbar并发送消息。如果失败的情况下 直接返回false pub fn put_object( client_id: u64, server_lobby: &ServerLobby, - query: &mut Query<&mut PlayerOntimeState>, + query: &mut Query<&mut PlayerOnTimeState>, active_index: usize, staff_id: usize, server: &mut RenetServer, diff --git a/src/server/object_filing/throw_object.rs b/src/server/object_filing/throw_object.rs index 4fbc586..3fcc6e2 100644 --- a/src/server/object_filing/throw_object.rs +++ b/src/server/object_filing/throw_object.rs @@ -11,7 +11,7 @@ use crate::{ server::{player::ServerLobby, tool_bar_sync::send_all_tool_bar}, staff::StaffInfoStroge, tools::vec3_to_chunk_key_any_xyz, - voxel_world::player_state::PlayerOntimeState, + voxel_world::player_state::PlayerOnTimeState, }; use super::gen_filled_object; @@ -23,7 +23,7 @@ pub fn deal_with_throw_object( mut commands: Commands, mut server: ResMut, server_lobby: Res, - mut query: Query<(Entity, &Transform, &mut PlayerOntimeState)>, + mut query: Query<(Entity, &Transform, &mut PlayerOnTimeState)>, staff_info_stroge: Res, ) { for client_id in server.clients_id() { diff --git a/src/server/player.rs b/src/server/player.rs index 2e926aa..e127384 100644 --- a/src/server/player.rs +++ b/src/server/player.rs @@ -8,7 +8,7 @@ use bevy_rapier3d::prelude::{ Ccd, Collider, ColliderMassProperties, CollisionGroups, Group, LockedAxes, RigidBody, Sleeping, }; -use crate::voxel_world::player_state::{PlayerOntimeState, PlayerState}; +use crate::voxel_world::player_state::{PlayerOnTimeState, PlayerState}; use super::cross_through_check::CossTroughCheck; @@ -51,7 +51,7 @@ pub fn server_create_player( .insert(Ccd::enabled()) .insert(YawValue::default()) .insert(PitchValue::default()) - .insert(PlayerOntimeState(player_state)) + .insert(PlayerOnTimeState(player_state)) .insert(CollisionGroups::new( Group::GROUP_3, Group::GROUP_1 | Group::GROUP_3, diff --git a/src/server/staff_rule_sync.rs b/src/server/staff_rule_sync.rs index 1008960..5274cae 100644 --- a/src/server/staff_rule_sync.rs +++ b/src/server/staff_rule_sync.rs @@ -8,7 +8,7 @@ use crate::{ StaffInfoStroge, }, tools::vec3_to_chunk_key_any_xyz, - voxel_world::player_state::PlayerOntimeState, + voxel_world::player_state::PlayerOnTimeState, }; use super::{ @@ -26,7 +26,7 @@ impl Plugin for ServerStaffRulePlugin { pub fn deal_with_staff_rule( mut server: ResMut, lobby: ResMut, - mut query: Query<(Entity, &Transform, &mut PlayerOntimeState)>, + mut query: Query<(Entity, &Transform, &mut PlayerOnTimeState)>, staff_rules: Res, mut fill_event: EventWriter, staff_info_stroge: Res, diff --git a/src/server/terrain_physics.rs b/src/server/terrain_physics.rs index 6545e67..1825841 100644 --- a/src/server/terrain_physics.rs +++ b/src/server/terrain_physics.rs @@ -15,7 +15,7 @@ use ndshape::{ConstShape, ConstShape3u32}; use crate::{ common::ServerClipSpheres, voxel_world::{ - chunk::{find_chunk_keys_array_by_shpere, generate_offset_array, ChunkKey}, + chunk::{find_chunk_keys_array_by_sphere, generate_offset_array, ChunkKey}, chunk_map::ChunkMap, voxel::Voxel, }, @@ -44,7 +44,7 @@ pub fn server_update_collider_task_system( ) { let pool = AsyncComputeTaskPool::get(); for (_client_id, clip_spheres) in server_clip_spheres.clip_spheres.iter() { - for chunk_key in find_chunk_keys_array_by_shpere( + for chunk_key in find_chunk_keys_array_by_sphere( clip_spheres.new_sphere, generate_offset_array(PY_DISTANCE), ) @@ -109,14 +109,14 @@ pub fn despawn_collider( let mut chunks_to_remove = HashSet::new(); for (_client_id, clip_spheres) in server_clip_spheres.clip_spheres.iter() { for key in - find_chunk_keys_array_by_shpere(clip_spheres.old_sphere, neighbour_offest.clone()) + find_chunk_keys_array_by_sphere(clip_spheres.old_sphere, neighbour_offest.clone()) .drain(..) { chunks_to_remove.insert(key); } for key in - find_chunk_keys_array_by_shpere(clip_spheres.new_sphere, neighbour_offest.clone()) + find_chunk_keys_array_by_sphere(clip_spheres.new_sphere, neighbour_offest.clone()) .drain(..) { chunks_to_remove.remove(&key); diff --git a/src/voxel_world/biomes/bule_land.rs b/src/voxel_world/biomes/blue_land.rs similarity index 100% rename from src/voxel_world/biomes/bule_land.rs rename to src/voxel_world/biomes/blue_land.rs diff --git a/src/voxel_world/biomes/mod.rs b/src/voxel_world/biomes/mod.rs index f416ddf..6ba0b1f 100644 --- a/src/voxel_world/biomes/mod.rs +++ b/src/voxel_world/biomes/mod.rs @@ -18,7 +18,7 @@ use crate::{ use self::{ basic_land::BasicLandBiomes, - bule_land::BuleLandBoimes, + blue_land::BuleLandBoimes, dry_land::DryLandBiomes, sand_land::SandLandBiomes, sdf::{sd_cut_sphere, trunk}, @@ -31,24 +31,24 @@ use super::{ }; pub mod basic_land; -pub mod bule_land; +pub mod blue_land; pub mod dry_land; pub mod sand_land; pub mod sdf; pub mod snow_land; pub type SampleShape = ConstShape3u32; -pub type PanleShap = ConstShape2u32; +pub type PanelShape = ConstShape2u32; // 处理 生物群落 pub fn biomes_generate( chunk_key: ChunkKey, seed: i32, - suface_index: Vec, + surface_index: Vec, voxels: &mut Vec, ) -> Vec<(Vec, TreeGentor)> { let mut ret = Vec::new(); - if suface_index.len() == 0 { + if surface_index.len() == 0 { return ret; } // 生成噪声 @@ -56,12 +56,12 @@ pub fn biomes_generate( // 这里产生一个 种树的噪声 let tree_noise = tree_noise(chunk_key, seed); - for index in suface_index { + for index in surface_index { // 由噪声生产的特征值 let [x, _, z] = SampleShape::delinearize(index); - let index_2d = PanleShap::linearize([x, z]); - let atrr = noise[index_2d as usize]; - let generator = get_generator_by_atrr(atrr); + let index_2d = PanelShape::linearize([x, z]); + let attr = noise[index_2d as usize]; + let generator = get_generator_by_attr(attr); generator.gen_land(chunk_key.clone(), voxels, index, index_2d); // fixme: 这里要记录对于其他方块的影响 if tree_noise[index_2d as usize] > 0.99 { @@ -74,18 +74,18 @@ pub fn biomes_generate( } // 获取不同的生成器 -fn get_generator_by_atrr(data: f32) -> Box { - if data < 0.1 { - return BasicLandBiomes.into_boxed_generator(); +fn get_generator_by_attr(data: f32) -> Box { + return if data < 0.1 { + BasicLandBiomes.into_boxed_generator() } else if data < 0.4 { - return DryLandBiomes.into_boxed_generator(); + DryLandBiomes.into_boxed_generator() } else if data < 0.6 { - return SnowLandBiomes.into_boxed_generator(); + SnowLandBiomes.into_boxed_generator() } else if data < 0.8 { - return SandLandBiomes.into_boxed_generator(); + SandLandBiomes.into_boxed_generator() } else { - return BuleLandBoimes.into_boxed_generator(); - } + BuleLandBoimes.into_boxed_generator() + }; } pub fn tree_noise(chunk_key: ChunkKey, seed: i32) -> Vec { diff --git a/src/voxel_world/chunk.rs b/src/voxel_world/chunk.rs index 5a9f611..c1aaa83 100644 --- a/src/voxel_world/chunk.rs +++ b/src/voxel_world/chunk.rs @@ -15,13 +15,12 @@ use crate::{common::Sphere3, CHUNK_SIZE}; pub struct ChunkKey(pub IVec3); impl ChunkKey { - - pub fn to_y_zore(&self)->ChunkKey { + pub fn to_y_zore(&self) -> ChunkKey { let mut ivec3 = self.0.clone(); ivec3.y = 0; ChunkKey(ivec3) } - + pub fn add_ivec3(&self, key: IVec3) -> ChunkKey { let ivec3 = self.0.clone(); ChunkKey(ivec3 + key) @@ -60,17 +59,17 @@ pub fn generate_offset_array(chunk_distance: i32) -> Vec { } #[derive(Debug, Resource, Clone)] -pub struct NeighbourOffest(pub Vec); +pub struct NeighbourOffset(pub Vec); -pub fn generate_offset_resoure(radius: f32) -> NeighbourOffest { +pub fn generate_offset_resource(radius: f32) -> NeighbourOffset { let chunk_distance = radius as i32 / CHUNK_SIZE; let mut offsets = generate_offset_array_with_y_0(chunk_distance); // itself offsets.push(IVec3::ZERO); - NeighbourOffest(offsets) + NeighbourOffset(offsets) } -pub fn generate_offset_resoure_min_1(radius: f32) -> NeighbourOffest { +pub fn generate_offset_resource_min_1(radius: f32) -> NeighbourOffset { let mut chunk_distance = radius as i32 / CHUNK_SIZE; chunk_distance -= 1; @@ -82,10 +81,10 @@ pub fn generate_offset_resoure_min_1(radius: f32) -> NeighbourOffest { // itself offsets.push(IVec3::ZERO); - NeighbourOffest(offsets) + NeighbourOffset(offsets) } -pub fn find_chunk_keys_array_by_shpere_y_0(sphere: Sphere3, offsets: Vec) -> Vec { +pub fn find_chunk_keys_array_by_sphere_y_0(sphere: Sphere3, offsets: Vec) -> Vec { let mut center_chunk_point = get_chunk_key_i3_by_vec3(sphere.center); center_chunk_point.y = 0; offsets @@ -94,7 +93,7 @@ pub fn find_chunk_keys_array_by_shpere_y_0(sphere: Sphere3, offsets: Vec) .collect() } -pub fn find_chunk_keys_array_by_shpere(sphere: Sphere3, offsets: Vec) -> Vec { +pub fn find_chunk_keys_array_by_sphere(sphere: Sphere3, offsets: Vec) -> Vec { let center_chunk_point = get_chunk_key_i3_by_vec3(sphere.center); offsets .iter() @@ -103,7 +102,7 @@ pub fn find_chunk_keys_array_by_shpere(sphere: Sphere3, offsets: Vec) -> } // offsets 已经改变成了平面为零的情况 数据需要扩展的是y轴c -pub fn find_chunk_keys_by_shpere_to_full_height( +pub fn find_chunk_keys_by_sphere_to_full_height( sphere: Sphere3, offsets: Vec, mut rt: impl FnMut(ChunkKey), diff --git a/src/voxel_world/chunk_map.rs b/src/voxel_world/chunk_map.rs index 592631a..24f90a2 100644 --- a/src/voxel_world/chunk_map.rs +++ b/src/voxel_world/chunk_map.rs @@ -67,9 +67,9 @@ impl ChunkMap { let n_self = &IVec3::new(0, 0, 0); let offsets = [px, nx, pz, nz, n_self]; - let last_inex = -128 / CHUNK_SIZE + 1; + let last_index = -128 / CHUNK_SIZE + 1; - for y_offset in last_inex..=128 / CHUNK_SIZE { + for y_offset in last_index..=128 / CHUNK_SIZE { for offset in offsets.iter() { let mut new_key = chunk_key; new_key.0.y = y_offset; @@ -90,8 +90,8 @@ impl ChunkMap { self.map_data.insert(chunk_key, item); } - pub fn get_by_index(volex: Option<&Vec>, index: u32) -> Voxel { - match volex { + pub fn get_by_index(voxel: Option<&Vec>, index: u32) -> Voxel { + match voxel { Some(list) => list[index as usize], None => Voxel::EMPTY, } diff --git a/src/voxel_world/map_generator.rs b/src/voxel_world/map_generator.rs index 27f6139..d7941fa 100644 --- a/src/voxel_world/map_generator.rs +++ b/src/voxel_world/map_generator.rs @@ -22,7 +22,7 @@ pub fn gen_chunk_data_by_seed( let base_y: f32 = (chunk_key.0.y * CHUNK_SIZE) as f32; // let base_z = (chunk_key.0.z * CHUNK_SIZE) as f32; type SampleShape = ConstShape3u32; - type PanleShap = ConstShape2u32; + type PanelShape = ConstShape2u32; let mut voxels = Vec::new(); let noise = noise2d(chunk_key, seed); @@ -35,7 +35,7 @@ pub fn gen_chunk_data_by_seed( let [x, y, z] = SampleShape::delinearize(i); let p_y = base_y + y as f32; let h = -60.; - let index = PanleShap::linearize([x, z]); + let index = PanelShape::linearize([x, z]); let top = h + fn_height(noise[index as usize]) + noise2[index as usize] * 5.0; if p_y <= top { // 必须大于海平面 diff --git a/src/voxel_world/player_state.rs b/src/voxel_world/player_state.rs index 4536ee1..16246a4 100644 --- a/src/voxel_world/player_state.rs +++ b/src/voxel_world/player_state.rs @@ -32,24 +32,24 @@ impl PlayerState { } // 尝试放置 如果成功返回 新的放置后的 toolbar的数据 失败返回None - pub fn put_statff(&mut self, id: usize) -> Option<(usize, Option, usize)> { + pub fn put_staff(&mut self, id: usize) -> Option<(usize, Option, usize)> { for i in 0..10 { - if let (Some(old_id), num) = self.toolbar[i] { + return if let (Some(old_id), num) = self.toolbar[i] { if old_id != id || num == MAX_STAFF_FIXED { continue; } self.toolbar[i] = (Some(id), num + 1); - return Some((i, Some(id), num + 1)); + Some((i, Some(id), num + 1)) } else { self.toolbar[i] = (Some(id), 1); - return Some((i, Some(id), 1)); - } + Some((i, Some(id), 1)) + }; } None } } -pub trait StorgePlayerState { +pub trait StoragePlayerState { fn save_player_state( &mut self, username: String, @@ -58,7 +58,7 @@ pub trait StorgePlayerState { fn get_player_state(&self, username: String) -> Option; } -impl StorgePlayerState for MapDataBase { +impl StoragePlayerState for MapDataBase { fn save_player_state( &mut self, username: String, @@ -91,4 +91,4 @@ impl StorgePlayerState for MapDataBase { } #[derive(Debug, Component, Clone)] -pub struct PlayerOntimeState(pub PlayerState); +pub struct PlayerOnTimeState(pub PlayerState);