From af4596b8b1b420a569b206cddbe2de664399218c Mon Sep 17 00:00:00 2001 From: core Date: Sun, 17 May 2026 20:52:23 -0400 Subject: [PATCH] feat(netcode-rewrite): begin reimplementing replication --- Cargo.lock | 513 +++++++-------------- Cargo.toml | 2 + crates/unified/Cargo.toml | 9 +- crates/unified/src/client/mod.rs | 33 +- crates/unified/src/client/net.rs | 53 --- crates/unified/src/client/plugins.rs | 7 +- crates/unified/src/main.rs | 1 + crates/unified/src/server/mod.rs | 21 +- crates/unified/src/server/player/join.rs | 10 + crates/unified/src/server/plugins.rs | 4 + crates/unified/src/server/visibility.rs | 3 + crates/unified/src/shared/config/planet.rs | 3 +- crates/unified/src/shared/ecs.rs | 2 + crates/unified/src/shared/net.rs | 57 ++- crates/unified/src/shared/plugins.rs | 4 + crates/unified/src/universal_entrypoint.rs | 4 + crates/unified/src/wasm_entrypoint.rs | 5 +- crates/xtask/src/unified_web.rs | 2 +- 18 files changed, 284 insertions(+), 449 deletions(-) delete mode 100644 crates/unified/src/client/net.rs create mode 100644 crates/unified/src/server/visibility.rs diff --git a/Cargo.lock b/Cargo.lock index f9daf05a275b9f5b34ee85524987868995ed23b5..62f0960a877546782ab29e9079261040211e5de6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -49,7 +49,7 @@ dependencies = [ "hashbrown 0.15.5", "objc2 0.5.2", "objc2-app-kit", - "objc2-foundation 0.2.2", + "objc2-foundation", ] [[package]] @@ -112,6 +112,23 @@ dependencies = [ "log", ] +[[package]] +name = "aeronet_replicon" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3660e988e020e887f8e623e99eb8f0945e772ae0e35c4032026b5f73a40f0a3" +dependencies = [ + "aeronet_io", + "aeronet_transport", + "bevy_app", + "bevy_ecs", + "bevy_platform", + "bevy_reflect", + "bevy_replicon", + "bevy_state", + "log", +] + [[package]] name = "aeronet_transport" version = "0.20.0" @@ -124,7 +141,7 @@ dependencies = [ "bevy_platform", "bevy_reflect", "bevy_time", - "bit-vec 0.8.0", + "bit-vec", "derive_more", "either", "log", @@ -650,7 +667,7 @@ dependencies = [ "serde", "smallvec", "thiserror 2.0.18", - "wgpu-types 27.0.1", + "wgpu-types", ] [[package]] @@ -666,7 +683,7 @@ dependencies = [ "encase", "serde", "thiserror 2.0.18", - "wgpu-types 27.0.1", + "wgpu-types", ] [[package]] @@ -969,7 +986,7 @@ dependencies = [ "serde", "thiserror 2.0.18", "tracing", - "wgpu-types 27.0.1", + "wgpu-types", ] [[package]] @@ -1152,7 +1169,7 @@ dependencies = [ "serde", "thiserror 2.0.18", "tracing", - "wgpu-types 27.0.1", + "wgpu-types", ] [[package]] @@ -1303,7 +1320,7 @@ dependencies = [ "thiserror 2.0.18", "uuid", "variadics_please", - "wgpu-types 27.0.1", + "wgpu-types", ] [[package]] @@ -1357,7 +1374,7 @@ dependencies = [ "image", "indexmap", "js-sys", - "naga 27.0.3", + "naga", "nonmax", "offset-allocator", "send_wrapper", @@ -1367,7 +1384,7 @@ dependencies = [ "variadics_please", "wasm-bindgen", "web-sys", - "wgpu 27.0.1", + "wgpu", ] [[package]] @@ -1382,6 +1399,27 @@ dependencies = [ "syn 2.0.117", ] +[[package]] +name = "bevy_replicon" +version = "0.39.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a0d6f7d37938f1f6797950774a41adc189a459d73cffb1941804a5d9d8fd059" +dependencies = [ + "bevy", + "bitflags 2.11.1", + "bumpalo", + "bytes", + "deterministic-hash", + "log", + "petgraph", + "postcard", + "serde", + "smallbitvec", + "typeid", + "variadics_please", + "xxhash-rust", +] + [[package]] name = "bevy_scene" version = "0.18.1" @@ -1413,12 +1451,12 @@ dependencies = [ "bevy_asset", "bevy_platform", "bevy_reflect", - "naga 27.0.3", + "naga", "naga_oil", "serde", "thiserror 2.0.18", "tracing", - "wgpu-types 27.0.1", + "wgpu-types", ] [[package]] @@ -1443,7 +1481,7 @@ dependencies = [ "bevy_window", "radsort", "tracing", - "wgpu-types 27.0.1", + "wgpu-types", ] [[package]] @@ -1547,7 +1585,7 @@ dependencies = [ "sys-locale", "thiserror 2.0.18", "tracing", - "wgpu-types 27.0.1", + "wgpu-types", ] [[package]] @@ -1743,16 +1781,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3" dependencies = [ - "bit-vec 0.8.0", -] - -[[package]] -name = "bit-set" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34ddef2995421ab6a5c779542c81ee77c115206f4ad9d5a8e05f4ff49716a3dd" -dependencies = [ - "bit-vec 0.9.1", + "bit-vec", ] [[package]] @@ -1761,12 +1790,6 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" -[[package]] -name = "bit-vec" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b71798fca2c1fe1086445a7258a4bc81e6e49dcd24c8d0dd9a1e57395b603f51" - [[package]] name = "bitflags" version = "1.3.2" @@ -2058,21 +2081,19 @@ dependencies = [ ] [[package]] -name = "codespan-reporting" -version = "0.12.0" +name = "cobs" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe6d2e5af09e8c8ad56c969f2157a3d4238cebc7c55f0a517728c38f7b200f81" +checksum = "0fa961b519f0b462e3a3b4a34b64d119eeaca1d59af726fe450bbba07a9fc0a1" dependencies = [ - "serde", - "termcolor", - "unicode-width", + "thiserror 2.0.18", ] [[package]] name = "codespan-reporting" -version = "0.13.1" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af491d569909a7e4dee0ad7db7f5341fef5c614d5b8ec8cf765732aba3cff681" +checksum = "fe6d2e5af09e8c8ad56c969f2157a3d4238cebc7c55f0a517728c38f7b200f81" dependencies = [ "serde", "termcolor", @@ -2527,6 +2548,12 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "deterministic-hash" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11277822c27bde750de02c5dc5159b91e88bf2661a2c1d98106f2fb1c5c6f590" + [[package]] name = "digest" version = "0.10.7" @@ -3248,18 +3275,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "glow" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29038e1c483364cc6bb3cf78feee1816002e127c331a1eec55a4d202b9e1adb5" -dependencies = [ - "js-sys", - "slotmap", - "wasm-bindgen", - "web-sys", -] - [[package]] name = "glutin_wgl_sys" version = "0.6.1" @@ -3310,20 +3325,6 @@ dependencies = [ "windows 0.58.0", ] -[[package]] -name = "gpu-allocator" -version = "0.28.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51255ea7cfaadb6c5f1528d43e92a82acb2b96c43365989a28b2d44ee38f8795" -dependencies = [ - "ash", - "hashbrown 0.16.1", - "log", - "presser", - "thiserror 2.0.18", - "windows 0.62.2", -] - [[package]] name = "gpu-descriptor" version = "0.3.2" @@ -3961,11 +3962,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "066cf25f0e8b11ee0df221219010f213ad429855f57c494f995590c861a9a7d8" dependencies = [ "arrayvec", - "bit-set 0.8.0", + "bit-set", "bitflags 2.11.1", "cfg-if", "cfg_aliases", - "codespan-reporting 0.12.0", + "codespan-reporting", "half", "hashbrown 0.16.1", "hexf-parse", @@ -3976,33 +3977,7 @@ dependencies = [ "once_cell", "pp-rs", "rustc-hash 1.1.0", - "spirv 0.3.0+sdk-1.3.268.0", - "thiserror 2.0.18", - "unicode-ident", -] - -[[package]] -name = "naga" -version = "29.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa2630921705b9b01dcdd0b6864b9562ca3c1951eecd0f0c4f5f04f61e412647" -dependencies = [ - "arrayvec", - "bit-set 0.9.1", - "bitflags 2.11.1", - "cfg-if", - "cfg_aliases", - "codespan-reporting 0.13.1", - "half", - "hashbrown 0.16.1", - "hexf-parse", - "indexmap", - "libm", - "log", - "num-traits", - "once_cell", - "rustc-hash 1.1.0", - "spirv 0.4.0+sdk-1.4.341.0", + "spirv", "thiserror 2.0.18", "unicode-ident", ] @@ -4013,10 +3988,10 @@ version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "310c347db1b30e69581f3b84dc9a5c311ed583f67851b39b77953cb7a066c97f" dependencies = [ - "codespan-reporting 0.12.0", + "codespan-reporting", "data-encoding", "indexmap", - "naga 27.0.3", + "naga", "regex", "rustc-hash 1.1.0", "thiserror 2.0.18", @@ -4243,8 +4218,8 @@ dependencies = [ "objc2 0.5.2", "objc2-core-data", "objc2-core-image", - "objc2-foundation 0.2.2", - "objc2-quartz-core 0.2.2", + "objc2-foundation", + "objc2-quartz-core", ] [[package]] @@ -4257,7 +4232,7 @@ dependencies = [ "block2 0.5.1", "objc2 0.5.2", "objc2-core-location", - "objc2-foundation 0.2.2", + "objc2-foundation", ] [[package]] @@ -4268,7 +4243,7 @@ checksum = "a5ff520e9c33812fd374d8deecef01d4a840e7b41862d849513de77e44aa4889" dependencies = [ "block2 0.5.1", "objc2 0.5.2", - "objc2-foundation 0.2.2", + "objc2-foundation", ] [[package]] @@ -4280,7 +4255,7 @@ dependencies = [ "bitflags 2.11.1", "block2 0.5.1", "objc2 0.5.2", - "objc2-foundation 0.2.2", + "objc2-foundation", ] [[package]] @@ -4290,8 +4265,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" dependencies = [ "bitflags 2.11.1", - "dispatch2", - "objc2 0.6.4", ] [[package]] @@ -4302,8 +4275,8 @@ checksum = "55260963a527c99f1819c4f8e3b47fe04f9650694ef348ffd2227e8196d34c80" dependencies = [ "block2 0.5.1", "objc2 0.5.2", - "objc2-foundation 0.2.2", - "objc2-metal 0.2.2", + "objc2-foundation", + "objc2-metal", ] [[package]] @@ -4315,7 +4288,7 @@ dependencies = [ "block2 0.5.1", "objc2 0.5.2", "objc2-contacts", - "objc2-foundation 0.2.2", + "objc2-foundation", ] [[package]] @@ -4337,17 +4310,6 @@ dependencies = [ "objc2 0.5.2", ] -[[package]] -name = "objc2-foundation" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272" -dependencies = [ - "bitflags 2.11.1", - "objc2 0.6.4", - "objc2-core-foundation", -] - [[package]] name = "objc2-io-kit" version = "0.3.2" @@ -4368,7 +4330,7 @@ dependencies = [ "block2 0.5.1", "objc2 0.5.2", "objc2-app-kit", - "objc2-foundation 0.2.2", + "objc2-foundation", ] [[package]] @@ -4380,19 +4342,7 @@ dependencies = [ "bitflags 2.11.1", "block2 0.5.1", "objc2 0.5.2", - "objc2-foundation 0.2.2", -] - -[[package]] -name = "objc2-metal" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0125f776a10d00af4152d74616409f0d4a2053a6f57fa5b7d6aa2854ac04794" -dependencies = [ - "bitflags 2.11.1", - "block2 0.6.2", - "objc2 0.6.4", - "objc2-foundation 0.3.2", + "objc2-foundation", ] [[package]] @@ -4404,21 +4354,8 @@ dependencies = [ "bitflags 2.11.1", "block2 0.5.1", "objc2 0.5.2", - "objc2-foundation 0.2.2", - "objc2-metal 0.2.2", -] - -[[package]] -name = "objc2-quartz-core" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96c1358452b371bf9f104e21ec536d37a650eb10f7ee379fff67d2e08d537f1f" -dependencies = [ - "bitflags 2.11.1", - "objc2 0.6.4", - "objc2-core-foundation", - "objc2-foundation 0.3.2", - "objc2-metal 0.3.2", + "objc2-foundation", + "objc2-metal", ] [[package]] @@ -4428,7 +4365,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0a684efe3dec1b305badae1a28f6555f6ddd3bb2c2267896782858d5a78404dc" dependencies = [ "objc2 0.5.2", - "objc2-foundation 0.2.2", + "objc2-foundation", ] [[package]] @@ -4444,9 +4381,9 @@ dependencies = [ "objc2-core-data", "objc2-core-image", "objc2-core-location", - "objc2-foundation 0.2.2", + "objc2-foundation", "objc2-link-presentation", - "objc2-quartz-core 0.2.2", + "objc2-quartz-core", "objc2-symbols", "objc2-uniform-type-identifiers", "objc2-user-notifications", @@ -4460,7 +4397,7 @@ checksum = "44fa5f9748dbfe1ca6c0b79ad20725a11eca7c2218bceb4b005cb1be26273bfe" dependencies = [ "block2 0.5.1", "objc2 0.5.2", - "objc2-foundation 0.2.2", + "objc2-foundation", ] [[package]] @@ -4473,7 +4410,7 @@ dependencies = [ "block2 0.5.1", "objc2 0.5.2", "objc2-core-location", - "objc2-foundation 0.2.2", + "objc2-foundation", ] [[package]] @@ -4672,6 +4609,18 @@ version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" +[[package]] +name = "petgraph" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8701b58ea97060d5e5b155d383a69952a60943f0e6dfe30b04c287beb0b27455" +dependencies = [ + "fixedbitset", + "hashbrown 0.15.5", + "indexmap", + "serde", +] + [[package]] name = "pico-args" version = "0.5.0" @@ -4797,6 +4746,28 @@ dependencies = [ "portable-atomic", ] +[[package]] +name = "postcard" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6764c3b5dd454e283a30e6dfe78e9b31096d9e32036b5d1eaac7a6119ccb9a24" +dependencies = [ + "cobs", + "postcard-derive", + "serde", +] + +[[package]] +name = "postcard-derive" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0232bd009a197ceec9cc881ba46f727fcd8060a2d8d6a9dde7a69030a6fe2bb" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + [[package]] name = "powerfmt" version = "0.2.0" @@ -5008,18 +4979,6 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" -[[package]] -name = "raw-window-metal" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40d213455a5f1dc59214213c7330e074ddf8114c9a42411eb890c767357ce135" -dependencies = [ - "objc2 0.6.4", - "objc2-core-foundation", - "objc2-foundation 0.3.2", - "objc2-quartz-core 0.3.2", -] - [[package]] name = "rayon" version = "1.12.0" @@ -5588,6 +5547,12 @@ dependencies = [ "version_check", ] +[[package]] +name = "smallbitvec" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b0e903ee191d8f7a8fbf0d712c3a1699d19e04ceba5ad1eb673053c7d938a09" + [[package]] name = "smallvec" version = "1.15.1" @@ -5672,15 +5637,6 @@ dependencies = [ "bitflags 2.11.1", ] -[[package]] -name = "spirv" -version = "0.4.0+sdk-1.4.341.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9571ea910ebd84c86af4b3ed27f9dbdc6ad06f17c5f96146b2b671e2976744f" -dependencies = [ - "bitflags 2.11.1", -] - [[package]] name = "stable_deref_trait" version = "1.2.1" @@ -5701,11 +5657,13 @@ name = "starkingdoms" version = "0.1.0" dependencies = [ "aeronet", + "aeronet_replicon", "aeronet_transport", "aeronet_websocket", "avian2d", "bevy", "bevy_common_assets", + "bevy_replicon", "console_error_panic_hook", "ctrlc", "getrandom 0.4.2", @@ -5718,7 +5676,6 @@ dependencies = [ "tracing-web", "wasm-bindgen", "web-time 1.1.0", - "wgpu 29.0.1", ] [[package]] @@ -6644,7 +6601,6 @@ checksum = "d8eab23fefc9e41f8e841df4a9c707e8a8c4ed26e944ef69297184de2785e3be" dependencies = [ "dlib", "log", - "once_cell", "pkg-config", ] @@ -6692,7 +6648,7 @@ dependencies = [ "hashbrown 0.16.1", "js-sys", "log", - "naga 27.0.3", + "naga", "portable-atomic", "profiling", "raw-window-handle", @@ -6700,39 +6656,9 @@ dependencies = [ "static_assertions", "wasm-bindgen", "web-sys", - "wgpu-core 27.0.3", - "wgpu-hal 27.0.4", - "wgpu-types 27.0.1", -] - -[[package]] -name = "wgpu" -version = "29.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c239a9a747bbd379590985bac952c2e53cb19873f7072b3370c6a6a8e06837" -dependencies = [ - "arrayvec", - "bitflags 2.11.1", - "bytemuck", - "cfg-if", - "cfg_aliases", - "document-features", - "hashbrown 0.16.1", - "js-sys", - "log", - "naga 29.0.1", - "parking_lot", - "portable-atomic", - "profiling", - "raw-window-handle", - "smallvec", - "static_assertions", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "wgpu-core 29.0.1", - "wgpu-hal 29.0.1", - "wgpu-types 29.0.1", + "wgpu-core", + "wgpu-hal", + "wgpu-types", ] [[package]] @@ -6742,8 +6668,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27a75de515543b1897b26119f93731b385a19aea165a1ec5f0e3acecc229cae7" dependencies = [ "arrayvec", - "bit-set 0.8.0", - "bit-vec 0.8.0", + "bit-set", + "bit-vec", "bitflags 2.11.1", "bytemuck", "cfg_aliases", @@ -6751,7 +6677,7 @@ dependencies = [ "hashbrown 0.16.1", "indexmap", "log", - "naga 27.0.3", + "naga", "once_cell", "parking_lot", "portable-atomic", @@ -6760,44 +6686,11 @@ dependencies = [ "rustc-hash 1.1.0", "smallvec", "thiserror 2.0.18", - "wgpu-core-deps-apple 27.0.0", + "wgpu-core-deps-apple", "wgpu-core-deps-wasm", - "wgpu-core-deps-windows-linux-android 27.0.0", - "wgpu-hal 27.0.4", - "wgpu-types 27.0.1", -] - -[[package]] -name = "wgpu-core" -version = "29.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e80ac6cf1895df6342f87d975162108f9d98772a0d74bc404ab7304ac29469e" -dependencies = [ - "arrayvec", - "bit-set 0.9.1", - "bit-vec 0.9.1", - "bitflags 2.11.1", - "bytemuck", - "cfg_aliases", - "document-features", - "hashbrown 0.16.1", - "indexmap", - "log", - "naga 29.0.1", - "once_cell", - "parking_lot", - "portable-atomic", - "profiling", - "raw-window-handle", - "rustc-hash 1.1.0", - "smallvec", - "thiserror 2.0.18", - "wgpu-core-deps-apple 29.0.0", - "wgpu-core-deps-emscripten", - "wgpu-core-deps-windows-linux-android 29.0.0", - "wgpu-hal 29.0.1", - "wgpu-naga-bridge", - "wgpu-types 29.0.1", + "wgpu-core-deps-windows-linux-android", + "wgpu-hal", + "wgpu-types", ] [[package]] @@ -6806,25 +6699,7 @@ version = "27.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0772ae958e9be0c729561d5e3fd9a19679bcdfb945b8b1a1969d9bfe8056d233" dependencies = [ - "wgpu-hal 27.0.4", -] - -[[package]] -name = "wgpu-core-deps-apple" -version = "29.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43acd053312501689cd92a01a9638d37f3e41a5fd9534875efa8917ee2d11ac0" -dependencies = [ - "wgpu-hal 29.0.1", -] - -[[package]] -name = "wgpu-core-deps-emscripten" -version = "29.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef043bf135cc68b6f667c55ff4e345ce2b5924d75bad36a47921b0287ca4b24a" -dependencies = [ - "wgpu-hal 29.0.1", + "wgpu-hal", ] [[package]] @@ -6833,7 +6708,7 @@ version = "27.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b1027dcf3b027a877e44819df7ceb0e2e98578830f8cd34cd6c3c7c2a7a50b7" dependencies = [ - "wgpu-hal 27.0.4", + "wgpu-hal", ] [[package]] @@ -6842,16 +6717,7 @@ version = "27.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71197027d61a71748e4120f05a9242b2ad142e3c01f8c1b47707945a879a03c3" dependencies = [ - "wgpu-hal 27.0.4", -] - -[[package]] -name = "wgpu-core-deps-windows-linux-android" -version = "29.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "725d5c006a8c02967b6d93ef04f6537ec4593313e330cfe86d9d3f946eb90f28" -dependencies = [ - "wgpu-hal 29.0.1", + "wgpu-hal", ] [[package]] @@ -6863,17 +6729,17 @@ dependencies = [ "android_system_properties", "arrayvec", "ash", - "bit-set 0.8.0", + "bit-set", "bitflags 2.11.1", "block", "bytemuck", "cfg-if", "cfg_aliases", "core-graphics-types 0.2.0", - "glow 0.16.0", + "glow", "glutin_wgl_sys", "gpu-alloc", - "gpu-allocator 0.27.0", + "gpu-allocator", "gpu-descriptor", "hashbrown 0.16.1", "js-sys", @@ -6882,7 +6748,7 @@ dependencies = [ "libloading", "log", "metal", - "naga 27.0.3", + "naga", "ndk-sys", "objc", "once_cell", @@ -6898,74 +6764,11 @@ dependencies = [ "thiserror 2.0.18", "wasm-bindgen", "web-sys", - "wgpu-types 27.0.1", + "wgpu-types", "windows 0.58.0", "windows-core 0.58.0", ] -[[package]] -name = "wgpu-hal" -version = "29.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89a47aef47636562f3937285af4c44b4b5b404b46577471411cc5313a921da7e" -dependencies = [ - "android_system_properties", - "arrayvec", - "ash", - "bit-set 0.9.1", - "bitflags 2.11.1", - "block2 0.6.2", - "bytemuck", - "cfg-if", - "cfg_aliases", - "glow 0.17.0", - "glutin_wgl_sys", - "gpu-allocator 0.28.0", - "gpu-descriptor", - "hashbrown 0.16.1", - "js-sys", - "khronos-egl", - "libc", - "libloading", - "log", - "naga 29.0.1", - "ndk-sys", - "objc2 0.6.4", - "objc2-core-foundation", - "objc2-foundation 0.3.2", - "objc2-metal 0.3.2", - "objc2-quartz-core 0.3.2", - "once_cell", - "ordered-float", - "parking_lot", - "portable-atomic", - "portable-atomic-util", - "profiling", - "range-alloc", - "raw-window-handle", - "raw-window-metal", - "renderdoc-sys", - "smallvec", - "thiserror 2.0.18", - "wasm-bindgen", - "wayland-sys", - "web-sys", - "wgpu-naga-bridge", - "wgpu-types 29.0.1", - "windows 0.62.2", - "windows-core 0.62.2", -] - -[[package]] -name = "wgpu-naga-bridge" -version = "29.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b4684f4410da0cf95a4cb63bb5edaac022461dedb6adf0b64d0d9b5f6890d51" -dependencies = [ - "naga 29.0.1", - "wgpu-types 29.0.1", -] - [[package]] name = "wgpu-types" version = "27.0.1" @@ -6981,20 +6784,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "wgpu-types" -version = "29.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec2675540fb1a5cfa5ef122d3d5f390e2c75711a0b946410f2d6ac3a0f77d1f6" -dependencies = [ - "bitflags 2.11.1", - "bytemuck", - "js-sys", - "log", - "raw-window-handle", - "web-sys", -] - [[package]] name = "wide" version = "0.7.33" @@ -7467,7 +7256,7 @@ dependencies = [ "ndk", "objc2 0.5.2", "objc2-app-kit", - "objc2-foundation 0.2.2", + "objc2-foundation", "objc2-ui-kit", "orbclient", "percent-encoding", @@ -7677,6 +7466,12 @@ dependencies = [ "qsv-tabwriter", ] +[[package]] +name = "xxhash-rust" +version = "0.8.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdd20c5420375476fbd4394763288da7eb0cc0b8c11deed431a91562af7335d3" + [[package]] name = "yasna" version = "0.5.2" diff --git a/Cargo.toml b/Cargo.toml index 411fb9c19f7ff30c0e419f53e95e3d28bd27b9c0..cdcf56ea2d3f894df0b298ee901839dda9e40ec4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,6 +65,8 @@ qsv-tabwriter = "2" aeronet = { version = "0.20" } aeronet_websocket = { version = "0.20" } aeronet_transport = { version = "0.20" } +aeronet_replicon = { version = "0.20" } +bevy_replicon = { version = "0.39"} [profile.dev] opt-level = 1 diff --git a/crates/unified/Cargo.toml b/crates/unified/Cargo.toml index e77ab9b6dc2c01c4621cbb6d144e9d7b925a0838..d6064cdb8438fda637d58bf3e66eaa3fa7f4cd04 100644 --- a/crates/unified/Cargo.toml +++ b/crates/unified/Cargo.toml @@ -13,7 +13,6 @@ tracing-subscriber = { workspace = true } serde = { workspace = true } rand = { workspace = true } getrandom = { workspace = true } -wgpu = { workspace = true } pico-args = { workspace = true } leafwing-input-manager = { workspace = true } good_lp = { workspace = true } @@ -24,19 +23,25 @@ aeronet_transport = { workspace = true } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] ctrlc = { workspace = true, optional = true } aeronet_websocket = { workspace = true, features = ["client", "server"] } +aeronet_replicon = { workspace = true, features = ["client", "server"] } +bevy_replicon = { workspace = true, features = ["client", "server"] } [target.'cfg(target_arch = "wasm32")'.dependencies] wasm-bindgen = { workspace = true } tracing-web = { workspace = true } console_error_panic_hook = { workspace = true } aeronet_websocket = { workspace = true, features = ["client"] } +aeronet_replicon = { workspace = true, features = ["client"] } +bevy_replicon = { workspace = true, features = ["client"] } [features] native_dev = [ "bevy/file_watcher", "bevy/hotpatching", "bevy/dynamic_linking", - "native" + "native", + "aeronet_replicon/server", + "bevy_replicon/server" ] native = [ "bevy/x11", diff --git a/crates/unified/src/client/mod.rs b/crates/unified/src/client/mod.rs index 2dbbc4ec18f3d74deb22e889890a1ec643d1ebd0..562f8cb6d5ed542e2c2dbcb113631a58ab71c587 100644 --- a/crates/unified/src/client/mod.rs +++ b/crates/unified/src/client/mod.rs @@ -1,5 +1,6 @@ use aeronet::io::{Session, SessionEndpoint}; use aeronet::io::connection::{DisconnectReason, Disconnected}; +use aeronet_replicon::client::AeronetRepliconClient; use aeronet_transport::{Transport, TransportConfig}; use aeronet_websocket::client::{ClientConfig, WebSocketClient}; use crate::client::crafting::ui::crafting_ui_plugin; @@ -16,9 +17,10 @@ use starguide::components::StarguideGizmos; use bevy::dev_tools::picking_debug::DebugPickingMode; use crate::prelude::*; use planet::incoming_planets::incoming_planets_plugin; +use crate::client::components::Me; use crate::client::ship::attachment::client_attachment_plugin; use crate::shared::ecs::GameplayState; -use crate::shared::net::LANES; +use crate::shared::net::Hi; pub mod colors; pub mod key_input; @@ -57,14 +59,20 @@ impl Plugin for ClientPlugin { .add_plugins(starguide_input_plugin) .add_plugins(starguide_orbit_plugin) .add_plugins(crafting_ui_plugin) + .add_systems(Update, find_me) .insert_state(GameplayState::Main) .insert_resource(DebugPickingMode::Disabled); let server = self.server.clone(); - app.add_systems(Startup, move |mut commands: Commands| { + app.add_systems(PostStartup, move |mut commands: Commands| { + #[cfg(target_arch = "wasm32")] + let config = ClientConfig {}; + #[cfg(not(target_arch = "wasm32"))] + let config = ClientConfig::builder().with_no_cert_validation(); let Some(server) = server.as_ref() else { return }; - commands.spawn((Name::new("default-session"), TransportConfig { max_memory_usage: 536_870_912, ..default() })) - .queue(WebSocketClient::connect(ClientConfig::builder().with_no_cert_validation(), server.clone())); + commands.spawn((Name::new("default-session"), TransportConfig { max_memory_usage: 536_870_912, ..default() }, AeronetRepliconClient)) + .queue( + WebSocketClient::connect(config, server.clone())); }); if self.server.is_some() { app.add_observer(on_connecting); @@ -83,17 +91,10 @@ pub fn on_connecting( let name = names.get(entity).unwrap(); info!("{name} is connecting"); } -pub fn on_connected(trigger: On, names: Query<&Name>, mut sessions: Query<(&Session)>, mut commands: Commands) { +pub fn on_connected(trigger: On, names: Query<&Name>) { let entity = trigger.event_target(); let name = names.get(entity).unwrap(); info!("{name} is connected"); - let session = sessions.get_mut(entity).expect("should exist"); - commands.entity(entity).insert(Transport::new( - session, - LANES, - LANES, - bevy::platform::time::Instant::now() - ).expect("MTU cannot support")); } pub fn on_disconnected(trigger: On, names: Query<&Name>) { let session = trigger.event_target(); @@ -110,4 +111,12 @@ pub fn on_disconnected(trigger: On, names: Query<&Name>) { warn!(?name, "session disconnected due to error: {err:?}"); } } +} + +pub fn find_me(mut msgs: MessageReader, mut commands: Commands) { + for msg in msgs.read() { + let we_are = msg.you_are; + info!(?we_are, "joined successfully"); + commands.entity(we_are).insert(Me); + } } \ No newline at end of file diff --git a/crates/unified/src/client/net.rs b/crates/unified/src/client/net.rs deleted file mode 100644 index 682dcf3099a2803d390f4f33d4df7fe861dfd79a..0000000000000000000000000000000000000000 --- a/crates/unified/src/client/net.rs +++ /dev/null @@ -1,53 +0,0 @@ -use aeronet::io::connection::{DisconnectReason, Disconnected}; -use aeronet::io::{Session, SessionEndpoint}; -use aeronet_replicon::client::AeronetRepliconClient; -use aeronet_transport::TransportConfig; -use crate::prelude::*; - -pub fn set_config(mut q: Query<&mut TransportConfig, Added>) { - for mut q in &mut q { - q.max_memory_usage = 536_870_912; // 512 MiB - } -} - -pub fn on_connecting( - trigger: On, - names: Query<&Name>, - mut commands: Commands, -) { - let entity = trigger.event_target(); - let name = names.get(entity).unwrap(); - info!("{name} is connecting"); - - commands.entity(entity).insert(AeronetRepliconClient); -} -pub fn on_connected(trigger: On, names: Query<&Name>) { - let entity = trigger.event_target(); - let name = names.get(entity).unwrap(); - info!("{name} is connected"); -} -pub fn on_disconnected(trigger: On, names: Query<&Name>) { - let session = trigger.event_target(); - let name = names.get(session).unwrap(); - - match &trigger.reason { - DisconnectReason::ByUser(reason) => { - info!(?name, ?reason, "session disconnected by user"); - } - DisconnectReason::ByPeer(reason) => { - info!(?name, ?reason, "session disconnected by peer"); - } - DisconnectReason::ByError(err) => { - warn!(?name, "session disconnected due to error: {err:?}"); - } - } -} - -#[cfg(target_family = "wasm")] -pub fn websocket_config() -> aeronet_websocket::client::ClientConfig { - aeronet_websocket::client::ClientConfig::default() -} -#[cfg(not(target_family = "wasm"))] -pub fn websocket_config() -> aeronet_websocket::client::ClientConfig { - aeronet_websocket::client::ClientConfig::builder().with_no_cert_validation() -} diff --git a/crates/unified/src/client/plugins.rs b/crates/unified/src/client/plugins.rs index faf4b7500067110cb1905bd9fe1adb6fb37e4999..a466a0278528845ce5f156ff3d1c94d31f2bb7a7 100644 --- a/crates/unified/src/client/plugins.rs +++ b/crates/unified/src/client/plugins.rs @@ -1,3 +1,4 @@ +use aeronet_replicon::client::AeronetRepliconClientPlugin; use aeronet_websocket::client::WebSocketClientPlugin; use bevy::a11y::AccessibilityPlugin; use crate::client::ClientPlugin; @@ -32,8 +33,10 @@ impl PluginGroup for ClientPluginGroup { .add(DebugPickingPlugin) .add(InputDispatchPlugin) .add(InputManagerPlugin::::default()) - .add(WebSocketClientPlugin - ) + .add(WebSocketClientPlugin) + .add(bevy_replicon::client::ClientPlugin) + .add(bevy_replicon::client::message::ClientMessagePlugin) + .add(AeronetRepliconClientPlugin) } } diff --git a/crates/unified/src/main.rs b/crates/unified/src/main.rs index 95d8df487a6fb7115fc3192691b0cc3c7c5c343c..c12ac1c97374d310954c181dfe18219bb5522b28 100644 --- a/crates/unified/src/main.rs +++ b/crates/unified/src/main.rs @@ -18,6 +18,7 @@ #![allow(dead_code, unused, reason = "We have a lot of this and it's getting annoying")] pub mod client; +#[cfg(not(target_arch = "wasm32"))] pub mod server; pub mod prelude; diff --git a/crates/unified/src/server/mod.rs b/crates/unified/src/server/mod.rs index 60766ff6bb5abb43f9edd0a2bee7830e23531163..ece8b3658107eff0e24bc50cc851572d33219faf 100644 --- a/crates/unified/src/server/mod.rs +++ b/crates/unified/src/server/mod.rs @@ -11,14 +11,17 @@ mod system_sets; pub mod orbit; pub mod plugins; pub mod components; +pub mod visibility; use std::net::SocketAddr; use aeronet::io::connection::{DisconnectReason, Disconnected, LocalAddr}; use aeronet::io::server::Server; use aeronet::io::Session; +use aeronet_replicon::server::AeronetRepliconServer; use aeronet_transport::lane::LaneKind; use aeronet_transport::Transport; use aeronet_websocket::server::{ServerConfig, WebSocketServer}; +use bevy_replicon::prelude::Replicated; use crate::server::craft::craft_plugin; use crate::server::damping::damping_plugin; use crate::server::drill::drill_plugin; @@ -31,7 +34,6 @@ use crate::server::system_sets::{PlayerInputSet, WorldUpdateSet}; use crate::prelude::*; use crate::server::orbit::OrbitPlugin; use crate::server::player::thrust::server_thrust_plugin; -use crate::shared::net::LANES; pub struct ServerPlugin { pub bind: SocketAddr @@ -59,7 +61,7 @@ impl Plugin for ServerPlugin { .add_observer(on_connected) .add_observer(on_disconnected) .add_systems(Startup, move |mut commands: Commands| { - commands.spawn(Name::new("websocket-server")) + commands.spawn((Name::new("websocket-server"), AeronetRepliconServer)) .queue(WebSocketServer::open(ServerConfig::builder() .with_bind_address(bind) .with_no_encryption())); @@ -95,23 +97,14 @@ fn on_connected( }; info!(?client, ?server, "client connected"); - let session = sessions.get(client).expect("must exist"); - - commands.entity(client).insert(Transport::new( - session, - LANES, - LANES, - bevy::platform::time::Instant::now() - ).expect("MTU is too small")); - let player = commands - .spawn(ConnectedGameEntity { + .spawn((Replicated, ConnectedGameEntity { network_entity: client, - }) + })) .id(); commands.entity(client).insert(( - //TODO: Replicated, + Replicated, ConnectedNetworkEntity { game_entity: player, }, diff --git a/crates/unified/src/server/player/join.rs b/crates/unified/src/server/player/join.rs index a710a13938543b4c104159b978dc82f7e605844c..b4d4e0ef86c19cbb1005c5ff108f8aa7798492e5 100644 --- a/crates/unified/src/server/player/join.rs +++ b/crates/unified/src/server/player/join.rs @@ -1,3 +1,4 @@ +use bevy_replicon::prelude::{ClientId, SendMode, ToClients}; use crate::client::components::Me; use crate::shared::config::planet::Planet; use crate::shared::config::world::GlobalWorldConfig; @@ -5,6 +6,7 @@ use crate::shared::ecs::{Player, PlayerStorage}; use crate::prelude::*; use crate::server::ConnectedGameEntity; use crate::server::part::SpawnPartRequest; +use crate::shared::net::Hi; use crate::shared::world_config::WorldConfigResource; const SPAWN_ORBIT_OFFSET: f64 = 150.0; @@ -67,6 +69,7 @@ pub fn handle_new_players( world_config: Res, planets: Query<(&Transform, &LinearVelocity, &Planet)>, asset_server: Res, + mut welcome_messages: MessageWriter> ) { if q_new_clients.is_empty() { return } let Some(wc) = &world_config.config else { @@ -78,6 +81,12 @@ pub fn handle_new_players( }; for joined_player in &q_new_clients { debug!(?joined_player, "new player!"); + welcome_messages.write(ToClients { + mode: SendMode::Direct(ClientId::Client(joined_player.1.network_entity)), + message: Hi { + you_are: joined_player.0 + }, + }); join_player(joined_player.0, commands.reborrow(), wc, planets, &asset_server); } } @@ -87,6 +96,7 @@ pub fn handle_pending_players( world_config: Res, planets: Query<(&Transform, &LinearVelocity, &Planet)>, asset_server: Res, + mut welcome_messages: MessageWriter> ) { if pending_players.is_empty() { return }; let Some(wc) = &world_config.config else { diff --git a/crates/unified/src/server/plugins.rs b/crates/unified/src/server/plugins.rs index 438125043cbd2ed7a9b7f9b0d0f66a3033eaaa49..8b6b1ac2beb9acf4ff2d2d98d332abbb7bb76131 100644 --- a/crates/unified/src/server/plugins.rs +++ b/crates/unified/src/server/plugins.rs @@ -1,4 +1,5 @@ use std::time::Duration; +use aeronet_replicon::server::AeronetRepliconServerPlugin; use aeronet_transport::AeronetTransportPlugin; use aeronet_websocket::server::WebSocketServerPlugin; use bevy::app::{PluginGroup, PluginGroupBuilder, ScheduleRunnerPlugin}; @@ -11,5 +12,8 @@ impl PluginGroup for ServerPluginGroup { PluginGroupBuilder::start::() .add(ScheduleRunnerPlugin::run_loop(Duration::from_secs_f64(1.0 / TICK_RATE))) .add(WebSocketServerPlugin) + .add(bevy_replicon::server::ServerPlugin::default()) + .add(bevy_replicon::server::message::ServerMessagePlugin) + .add(AeronetRepliconServerPlugin) } } diff --git a/crates/unified/src/server/visibility.rs b/crates/unified/src/server/visibility.rs new file mode 100644 index 0000000000000000000000000000000000000000..ee6cbe4407c50c4b0cf822e5af499a0299ec5cc7 --- /dev/null +++ b/crates/unified/src/server/visibility.rs @@ -0,0 +1,3 @@ +use bevy_replicon::prelude::VisibilityFilter; +use crate::prelude::*; + diff --git a/crates/unified/src/shared/config/planet.rs b/crates/unified/src/shared/config/planet.rs index b01f0ed4e02fa56ce846791ac49d39ce82a65a82..d57739f3cbe0a584ae9426ff0a913894ae667e03 100644 --- a/crates/unified/src/shared/config/planet.rs +++ b/crates/unified/src/shared/config/planet.rs @@ -2,11 +2,12 @@ use bevy::asset::Asset; use bevy::color::Color; use crate::prelude::*; use serde::{Deserialize, Serialize}; - +use bevy_replicon::prelude::Replicated; #[derive(Deserialize, Asset, TypePath, Component, Serialize, Clone, Debug)] #[require( RigidBody::Dynamic, + Replicated )] pub struct Planet { pub name: String, diff --git a/crates/unified/src/shared/ecs.rs b/crates/unified/src/shared/ecs.rs index 975e03ac136789c528ac7cc1c439452269dfbf5f..8c705ad6385fed46e2fedd04f2ecac50d3c6bc71 100644 --- a/crates/unified/src/shared/ecs.rs +++ b/crates/unified/src/shared/ecs.rs @@ -7,6 +7,7 @@ use crate::prelude::*; use avian2d::prelude::*; use std::collections::HashMap; use std::sync::LazyLock; +use bevy_replicon::prelude::Replicated; #[derive(States, Debug, Clone, PartialEq, Eq, Hash)] pub enum GameplayState { @@ -27,6 +28,7 @@ pub const ORBIT_LAYER: RenderLayers = RenderLayers::layer(2); LinearVelocity, AngularVelocity, ConstantForce, + Replicated )] pub struct Part { pub config: PartConfig, diff --git a/crates/unified/src/shared/net.rs b/crates/unified/src/shared/net.rs index ca9b365f497ef88d0656a5d45297a121d8d3bed6..90cc1353ae9be9c231e2d6685aec2a23ee7f7f6c 100644 --- a/crates/unified/src/shared/net.rs +++ b/crates/unified/src/shared/net.rs @@ -1,3 +1,56 @@ -use aeronet_transport::lane::LaneKind; +use avian2d::prelude::{AngularInertia, AngularVelocity, CenterOfMass, Collider, LinearVelocity, Mass, Position, RigidBody, Rotation}; +use bevy::ecs::entity::MapEntities; +use bevy::prelude::*; +use crate::prelude::{App, Message}; +use bevy_replicon::prelude::*; +use serde::{Deserialize, Serialize}; +use crate::shared::attachment::{Joint, JointOf, PartInShip, Peer, Ship, SnapOf, SnapOfJoint}; +use crate::shared::config::planet::{Planet, PlanetSpring, PlanetSpringJoint}; +use crate::shared::ecs::{CanCraft, Drill, Part, Player, PlayerStorage, SingleStorage, Temperature}; +use crate::shared::ecs::thruster::{Thruster, ThrusterOfPart}; -pub const LANES: [LaneKind; 1] = [LaneKind::ReliableOrdered]; +pub fn register_replication(app: &mut App) { + app + .add_mapped_server_message::(Channel::Ordered) + + .replicate::() + .replicate::() + + .replicate::() + .replicate::() + .replicate::() + .replicate::() + .replicate::() + .replicate::() + .replicate::() + .replicate::() + .replicate::() + + .replicate::() + .replicate::() + .replicate::() + + .replicate::() + .replicate::() + .replicate::() + .replicate::() + .replicate::() + .replicate::() + .replicate::() + .replicate::() + .replicate::() + .replicate::() + .replicate::() + .replicate::() + .replicate::() + .replicate::() + .replicate::() + .replicate::() + .replicate::(); +} + +#[derive(Message, Deserialize, Serialize, MapEntities)] +pub struct Hi { + #[entities] + pub you_are: Entity +} \ No newline at end of file diff --git a/crates/unified/src/shared/plugins.rs b/crates/unified/src/shared/plugins.rs index 30806b070979bf50a2d897a1c8d7767440c9de55..d49883a36f42ef1ddaa608807b8b1f59f317737e 100644 --- a/crates/unified/src/shared/plugins.rs +++ b/crates/unified/src/shared/plugins.rs @@ -5,11 +5,13 @@ use bevy::app::{App, PluginGroup, PluginGroupBuilder}; use bevy::diagnostic::DiagnosticsPlugin; use bevy::state::app::StatesPlugin; use bevy_common_assets::toml::TomlAssetPlugin; +use bevy_replicon::RepliconPlugins; use crate::prelude::*; use crate::shared::config::part::PartConfig; use crate::shared::config::planet::PlanetConfigCollection; use crate::shared::config::recipe::RecipesConfig; use crate::shared::config::world::GlobalWorldConfig; +use crate::shared::net::register_replication; use crate::shared::world_config::world_config_plugin; pub const TICK_RATE: f64 = 20.0; @@ -22,6 +24,7 @@ impl PluginGroup for SharedPluginGroup { PluginGroupBuilder::start::() .add(AssetPlugin::default()) .add(StatesPlugin) + .add(bevy_replicon::shared::RepliconSharedPlugin::default()) .add(TransformPlugin) .add(DiagnosticsPlugin) .add(AeronetTransportPlugin) @@ -36,6 +39,7 @@ impl PluginGroup for SharedPluginGroup { .disable::() ) .add(physics_setup_plugin) + .add(register_replication) .add(register_everything) .add(world_config_plugin) diff --git a/crates/unified/src/universal_entrypoint.rs b/crates/unified/src/universal_entrypoint.rs index 66c3f60f50a0cfef8ffd677a40dc8dab7501d4a6..7adf43ac161f03ead22f0b7a6399917718e0eebc 100644 --- a/crates/unified/src/universal_entrypoint.rs +++ b/crates/unified/src/universal_entrypoint.rs @@ -4,8 +4,11 @@ use crate::cli::StkArgs; use crate::client::ClientPlugin; use crate::client::plugins::ClientPluginGroup; use crate::prelude::{App, AppExit, MinimalPlugins, PluginGroup}; +#[cfg(not(target_arch = "wasm32"))] use crate::server::player::join::spawn_singleplayer_player; +#[cfg(not(target_arch = "wasm32"))] use crate::server::plugins::ServerPluginGroup; +#[cfg(not(target_arch = "wasm32"))] use crate::server::ServerPlugin; use crate::shared::plugins::SharedPluginGroup; @@ -20,6 +23,7 @@ pub fn run(cli: StkArgs) -> AppExit { app.add_plugins(ClientPluginGroup); app.add_plugins(ClientPlugin { server: Some(server) }); }, + #[cfg(not(target_arch = "wasm32"))] StkArgs::Server { bind_to, with_client } => { app.add_plugins(ServerPluginGroup); app.add_plugins(ServerPlugin { bind: bind_to }); diff --git a/crates/unified/src/wasm_entrypoint.rs b/crates/unified/src/wasm_entrypoint.rs index 3342b913ba49b82202aa7fe66f110b97f9a7f3f7..d9d076a3dad7750ce1f5f63c4f5142a5d9ca3c6c 100644 --- a/crates/unified/src/wasm_entrypoint.rs +++ b/crates/unified/src/wasm_entrypoint.rs @@ -1,5 +1,4 @@ use crate::client::plugins::ClientPluginGroup; -use crate::server::plugins::ServerPluginGroup; use crate::shared::plugins::SharedPluginGroup; use bevy::app::App; use bevy::log::LogPlugin; @@ -7,7 +6,7 @@ use bevy::ui::UiPlugin; use bevy::DefaultPlugins; use wasm_bindgen::prelude::*; use bevy::prelude::PluginGroup; - +use crate::run; use tracing_web::MakeWebConsoleWriter; use tracing_subscriber::prelude::*; use tracing_subscriber::filter::LevelFilter; @@ -26,7 +25,7 @@ pub fn play(server: &str) -> Result<(), JsValue> { .with(fmt_layer) .init(); - let cli = StkArgs::Client { server }; + let cli = StkArgs::Client { server: server.to_string() }; run(cli); Ok(()) diff --git a/crates/xtask/src/unified_web.rs b/crates/xtask/src/unified_web.rs index e07eafbd4aa679175bb2382722006487ba12f091..5154cbaf89e51568f7b5f78c2cc5f4ceb9521471 100644 --- a/crates/xtask/src/unified_web.rs +++ b/crates/xtask/src/unified_web.rs @@ -14,7 +14,7 @@ impl Task for RunClientWeb { fn run(&self, _args: Vec) { set_current_dir(workspace_dir().join("crates/unified/")).unwrap(); - cargo("build --profile wasm-release -F wasm -F client --package starkingdoms --target wasm32-unknown-unknown".to_string()); + cargo("build --profile wasm-release -F wasm --package starkingdoms --target wasm32-unknown-unknown".to_string()); let wks = workspace_dir(); let target_dir = wks.join("target/").join("wasm32-unknown-unknown/").join("wasm-release/");