Skip to content

Commit

Permalink
Merge branch 'main' into feature-i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
zzhgithub committed Sep 7, 2023
2 parents 598f102 + 9b0cecc commit 624dc67
Show file tree
Hide file tree
Showing 37 changed files with 797 additions and 105 deletions.
42 changes: 15 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ egui-notify = "0.8.0"
rand = "0.8.5"
seldom_state = "0.7.0"
bevy_sprite3d = "2.5.0"
bit-vec = { version = "0.6", features = ["serde"] }
# 解决依赖冲突
num-rational = "^0.4.1"
fxhash = "^0.2.1"
Expand All @@ -50,7 +51,13 @@ bevy_mod_billboard = "0.4.0"
notify = "6.1.1"
egui_extras = "0.22.0"
bevy_easy_localize = "0.3.0"

huffman-compress = { git = "https://github.com/zzhgithub/rust-huffman-compress", branch = "features-serde", features = [
"serde",
] }
noise = { version = "0.8.2" }
# 解决冲突
lock_api = "0.4.10"
codespan-reporting = "0.11.1"

[profile.dev.package.bevy_rapier3d]
opt-level = 3
Expand All @@ -61,13 +68,8 @@ codegen-units = 1
[target.'cfg(target_arch = "x86_64")'.dependencies]
simdnoise = { version = "3.1.6" }

[target.'cfg(target_arch = "aarch64")'.dependencies]
noise = { version = "0.8.2" }
# 解决冲突
lock_api = "0.4.10"
codespan-reporting = "0.11.1"
inotify = "0.9.6"

# [target.'cfg(target_arch = "aarch64")'.dependencies]
# noise = { version = "0.8.2" }

[features]
default = ["server_ui"]
Expand Down
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Just Join (来噻)

![f](pic/f.png)

----

this rep is rebuild from https://github.com/zzhgithub/just_join. The goal is to make the original project support the online multiplayer game

> ~~Ka Le on windows i5 cpu. optimizing!~~
Expand All @@ -18,6 +22,14 @@ For Client
cargo run --release --bin client
```

# Src/lib.rs Const
```rust
// generate map every time when you restart game(use in test mode)
// Before game you should set to flase
pub const CLIENT_MAP_GEN: bool = true;
```


# Controller
- W - forward
- S - backward
Expand All @@ -26,8 +38,8 @@ cargo run --release --bin client
- Space - Jump
- ESC - toggle grab cursor
- T - toggle One/Thrid Person
- E Open composite rules list
- Q throw active toolbar object
- E - Open composite rules list
- Q - throw active toolbar object

# Feature List
- [x] Load unlimited maps
Expand Down Expand Up @@ -58,6 +70,8 @@ cargo run --release --bin client
- [ ] opmtimize UI(Show current toolbar and knapsack)
- [ ] support search
- [ ] add more formula
- [x] more biomes support
- [ ] decorate_terrain
- [ ] task system
- [ ] manor system
- [ ] wind zone
Expand Down
12 changes: 12 additions & 0 deletions README_CN.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Just Join (来噻)

![f](pic/f.png)

----

此仓库是 https://github.com/zzhgithub/just_join 的网络化重构施工中。敬请期待。


Expand Down Expand Up @@ -30,6 +34,12 @@ cargo run --release --bin client
- E 打开合成表
- Q 丢弃toolbar上激活中的物品

# LIB 中的配置常量
```rust
// 是否每次都重新生成地形
// 游戏前 请设置成false
pub const CLIENT_MAP_GEN: bool = true;
```

# 功能列表

Expand Down Expand Up @@ -61,6 +71,8 @@ cargo run --release --bin client
- [ ] 增强交互(显示当前背包)
- [ ] 支撑合成公式搜索
- [ ] 添加更多游戏内的公式
- [x] 更多群落支撑
- [ ] 装饰群落
- [ ] 任务系统
- [ ] 领地系统
- [ ] 风场
Expand Down
Binary file added assets/textures/干草侧面.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/textures/干草地.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/textures/苍翠侧面.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/textures/苍翠地.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pic/f.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion src/bin/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ use just_join::{
common::ServerClipSpheresPlugin,
connection_config,
server::{
async_chunk::ChunkDataPlugin, chunk::ServerChunkPlugin, deal_message_system,
async_chunk::ChunkDataPlugin, chunk::ServerChunkPlugin,
cross_through_check::CossTroughCheckPlugin, deal_message_system,
object_filing::ObjectFilingPlugin, player::ServerLobby, server_connect_system,
staff_rule_sync::ServerStaffRulePlugin, sync_body_and_head,
terrain_physics::TerrainPhysicsPlugin,
Expand Down Expand Up @@ -117,6 +118,7 @@ fn main() {
ServerSkyPlugins,
ObjectFilingPlugin,
ServerStaffRulePlugin,
CossTroughCheckPlugin,
));

let (server, transport) = new_renet_server();
Expand Down
10 changes: 10 additions & 0 deletions src/client/filled_object/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,13 @@ fn sync_filled_objects(
}
}
}

pub fn setdown_filled_object(
mut commands: Commands,
mut filled_object_pool: ResMut<FilledObjectPool>,
) {
for (_, entity) in filled_object_pool.entities_map.clone() {
commands.entity(entity).despawn();
}
filled_object_pool.entities_map = HashMap::new();
}
61 changes: 42 additions & 19 deletions src/client/mesh_display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ use ndshape::{ConstShape, ConstShape3u32};
use crate::{
common::ClipSpheres,
server::message_def::{chunk_result::ChunkResult, ServerChannel},
tools::get_empty_chunk,
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,
},
chunk_map::ChunkMap,
compress::uncompress,
voxel::Voxel,
},
CHUNK_SIZE, CHUNK_SIZE_U32, MATERIAL_RON, VIEW_RADIUS,
Expand Down Expand Up @@ -165,11 +166,11 @@ pub fn async_chunk_result(
let chunk_result: ChunkResult = bincode::deserialize(&message).unwrap();
match chunk_result {
ChunkResult::ChunkData { key, data } => {
let task = pool.spawn(async move { (key, data) });
let task = pool.spawn(async move { (key, uncompress(&data.0, data.1)) });
chunk_sync_task.tasks.push(task);
}
ChunkResult::ChunkEmpty(key) => {
let task = pool.spawn(async move { (key, get_empty_chunk()) });
ChunkResult::ChunkSame((key, voxel)) => {
let task = pool.spawn(async move { (key, get_all_v_chunk(voxel)) });
chunk_sync_task.tasks.push(task);
}
ChunkResult::ChunkUpdateOne {
Expand Down Expand Up @@ -260,15 +261,16 @@ pub fn update_mesh(
let volexs: Vec<Voxel> = chunk_map.get_with_neighbor_full_y(chunk_key_y0);
match gen_mesh(volexs.to_owned(), material_config.clone()) {
Some(render_mesh) => {
let mesh_handle = mesh_manager.mesh_storge.get(&chunk_key_y0).unwrap();
if let Some(mesh) = mesh_assets.get_mut(mesh_handle) {
// 更新AABB
if let Some(entity) = mesh_manager.entities.get(&chunk_key_y0) {
if let Some(aabb) = render_mesh.compute_aabb() {
commands.entity(*entity).insert(aabb);
if let Some(mesh_handle) = mesh_manager.mesh_storge.get(&chunk_key_y0) {
if let Some(mesh) = mesh_assets.get_mut(mesh_handle) {
// 更新AABB
if let Some(entity) = mesh_manager.entities.get(&chunk_key_y0) {
if let Some(aabb) = render_mesh.compute_aabb() {
commands.entity(*entity).insert(aabb);
}
}
*mesh = render_mesh;
}
*mesh = render_mesh;
}
// 没有生成mesh就不管反正后面要生成
}
Expand All @@ -281,14 +283,15 @@ pub fn update_mesh(
};
match gen_mesh_water(pick_water(volexs), material_config) {
Some(water_mesh) => {
let mesh_handle = mesh_manager.water_mesh_storge.get(&chunk_key_y0).unwrap();
if let Some(mesh) = mesh_assets.get_mut(mesh_handle) {
if let Some(entity) = mesh_manager.water_entities.get(&chunk_key_y0) {
if let Some(aabb) = water_mesh.compute_aabb() {
commands.entity(*entity).insert(aabb);
if let Some(mesh_handle) = mesh_manager.water_mesh_storge.get(&chunk_key_y0) {
if let Some(mesh) = mesh_assets.get_mut(mesh_handle) {
if let Some(entity) = mesh_manager.water_entities.get(&chunk_key_y0) {
if let Some(aabb) = water_mesh.compute_aabb() {
commands.entity(*entity).insert(aabb);
}
}
*mesh = water_mesh;
}
*mesh = water_mesh;
}
}
None => {
Expand Down Expand Up @@ -468,10 +471,11 @@ fn cycle_check_mesh(
let now: Instant = Instant::now();
let duration: Duration = now - *instant;
// 每2s检查一下五秒内没有加载好的数据
if !state && duration.as_millis() > 5 * 1000 && need_keys.contains(key) {
if !state && duration.as_millis() > 10 * 1000 && need_keys.contains(key) {
println!("超时重新请求chunkkey{:?}", key);
// TODO: 这可以检查具体少什么数据?
let message = bincode::serialize(&ChunkQuery::GetFullY(*key)).unwrap();
// todo 对边缘数据不处理!
// 对边缘数据不处理!
client.send_message(ClientChannel::ChunkQuery, message);
}
if duration.as_millis() > 5 * 1000
Expand All @@ -484,3 +488,22 @@ fn cycle_check_mesh(
}
}
}

pub fn mesh_chunk_map_setdown(
mut commands: Commands,
mut mesh_manager: ResMut<MeshManager>,
mut chunk_sync_task: ResMut<ChunkSyncTask>,
mut chunk_map: ResMut<ChunkMap>,
mut chunk_update_task: ResMut<ChunkUpdateTask>,
) {
chunk_update_task.tasks.drain(..);
chunk_sync_task.tasks.drain(..);
chunk_map.map_data.clear();
for (_, entity) in mesh_manager.entities.clone() {
commands.entity(entity).despawn();
}
for (_, entity) in mesh_manager.water_entities.clone() {
commands.entity(entity).despawn();
}
*mesh_manager.as_mut() = MeshManager::default();
}
6 changes: 4 additions & 2 deletions src/client/player/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ use bevy::{
use bevy_egui::EguiSet;
use bevy_renet::renet::RenetClient;

use crate::client::{ state_manager::GameState, message_def::{player_input::PlayerInput, ClientChannel},
use crate::client::{
message_def::{player_input::PlayerInput, ClientChannel},
state_manager::GameState,
};

use super::{
Expand Down Expand Up @@ -138,7 +140,7 @@ fn initial_grab_cursor(mut primary_window: Query<&mut Window, With<PrimaryWindow
}
}

fn back_grab_cursor(mut primary_window: Query<&mut Window, With<PrimaryWindow>>) {
pub fn back_grab_cursor(mut primary_window: Query<&mut Window, With<PrimaryWindow>>) {
if let Ok(mut window) = primary_window.get_single_mut() {
{
window.cursor.grab_mode = CursorGrabMode::None;
Expand Down
2 changes: 1 addition & 1 deletion src/client/player/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub mod mouse_control;
pub mod player_input;
pub mod throw_system;

#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct PlayerInfo {
// 客户端 实体
pub client_entity: Entity,
Expand Down
Loading

0 comments on commit 624dc67

Please sign in to comment.