From 4296e758d0675fd1b18c389ead495cf22eb8a763 Mon Sep 17 00:00:00 2001 From: core Date: Fri, 4 Jul 2025 14:23:50 -0400 Subject: [PATCH] feat(particles): enoki particles (tmp) --- Cargo.lock | 484 +----------------- crates/unified/Cargo.toml | 27 +- .../particles/ship_thruster.particle.ron | 1 + .../unified/src/client/incoming_particles.rs | 27 + crates/unified/src/client/mod.rs | 5 +- crates/unified/src/client_plugins.rs | 2 + crates/unified/src/ecs.rs | 6 + crates/unified/src/lib.rs | 2 +- crates/unified/src/server/player.rs | 42 +- crates/unified/src/shared_plugins.rs | 6 +- 10 files changed, 120 insertions(+), 482 deletions(-) create mode 100644 crates/unified/assets/particles/ship_thruster.particle.ron create mode 100644 crates/unified/src/client/incoming_particles.rs diff --git a/Cargo.lock b/Cargo.lock index d4e62114accb8bdddb7156ddbcad50122891144c..9b627f8ef7d8eadf2662f49975c8e7923997046d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -290,28 +290,6 @@ version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" -[[package]] -name = "alsa" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed7572b7ba83a31e20d1b48970ee402d2e3e0537dcfe0a3ff4d6eb7508617d43" -dependencies = [ - "alsa-sys", - "bitflags 2.9.1", - "cfg-if", - "libc", -] - -[[package]] -name = "alsa-sys" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db8fee663d06c4e303404ef5f40488a53e062f89ba8bfed81f42325aafad1527" -dependencies = [ - "libc", - "pkg-config", -] - [[package]] name = "android-activity" version = "0.5.2" @@ -756,40 +734,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bevy_animation" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49796627726d0b9a722ad9a0127719e7c1868f474d6575ec0f411e8299c4d7bb" -dependencies = [ - "bevy_app 0.16.1", - "bevy_asset 0.16.1", - "bevy_color", - "bevy_derive 0.16.1", - "bevy_ecs 0.16.1", - "bevy_log 0.16.1", - "bevy_math 0.16.1", - "bevy_mesh", - "bevy_platform", - "bevy_reflect 0.16.1", - "bevy_render 0.16.1", - "bevy_time 0.16.1", - "bevy_transform 0.16.1", - "bevy_utils 0.16.1", - "blake3", - "derive_more 1.0.0", - "downcast-rs 2.0.1", - "either", - "petgraph 0.7.1", - "ron", - "serde", - "smallvec", - "thiserror 2.0.12", - "thread_local", - "tracing", - "uuid", -] - [[package]] name = "bevy_app" version = "0.13.2" @@ -927,24 +871,6 @@ dependencies = [ "syn 2.0.104", ] -[[package]] -name = "bevy_audio" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b4f6f2a5c6c0e7c6825e791d2a061c76c2d6784f114c8f24382163fabbfaaa" -dependencies = [ - "bevy_app 0.16.1", - "bevy_asset 0.16.1", - "bevy_derive 0.16.1", - "bevy_ecs 0.16.1", - "bevy_math 0.16.1", - "bevy_reflect 0.16.1", - "bevy_transform 0.16.1", - "cpal", - "rodio", - "tracing", -] - [[package]] name = "bevy_color" version = "0.16.2" @@ -1078,7 +1004,7 @@ dependencies = [ "bevy_time 0.13.2", "bevy_utils 0.13.2", "const-fnv1a-hash", - "sysinfo 0.30.13", + "sysinfo", ] [[package]] @@ -1096,7 +1022,6 @@ dependencies = [ "const-fnv1a-hash", "log", "serde", - "sysinfo 0.34.2", ] [[package]] @@ -1226,20 +1151,15 @@ dependencies = [ ] [[package]] -name = "bevy_gilrs" -version = "0.16.1" +name = "bevy_enoki" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97efef87c631949e67d06bb5d7dfd2a5f936b3b379afb6b1485b08edbb219b87" +checksum = "740289c63cb752adbad3823c49c01d479d853a10d76ccfe5ce3d1f3ea8e14ac2" dependencies = [ - "bevy_app 0.16.1", - "bevy_ecs 0.16.1", - "bevy_input 0.16.1", - "bevy_platform", - "bevy_time 0.16.1", - "bevy_utils 0.16.1", - "gilrs", - "thiserror 2.0.12", - "tracing", + "bevy 0.16.1", + "rand 0.8.5", + "ron", + "serde", ] [[package]] @@ -1277,7 +1197,6 @@ dependencies = [ "bevy_gizmos_macros 0.16.1", "bevy_image", "bevy_math 0.16.1", - "bevy_pbr", "bevy_reflect 0.16.1", "bevy_render 0.16.1", "bevy_sprite 0.16.1", @@ -1312,41 +1231,6 @@ dependencies = [ "syn 2.0.104", ] -[[package]] -name = "bevy_gltf" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10a080237c0b8842ccc15a06d3379302c68580eeea4497b1c7387e470eda1f07" -dependencies = [ - "base64 0.22.1", - "bevy_animation", - "bevy_app 0.16.1", - "bevy_asset 0.16.1", - "bevy_color", - "bevy_core_pipeline 0.16.1", - "bevy_ecs 0.16.1", - "bevy_image", - "bevy_math 0.16.1", - "bevy_mesh", - "bevy_pbr", - "bevy_platform", - "bevy_reflect 0.16.1", - "bevy_render 0.16.1", - "bevy_scene 0.16.1", - "bevy_tasks 0.16.1", - "bevy_transform 0.16.1", - "bevy_utils 0.16.1", - "fixedbitset 0.5.7", - "gltf", - "itertools 0.14.0", - "percent-encoding", - "serde", - "serde_json", - "smallvec", - "thiserror 2.0.12", - "tracing", -] - [[package]] name = "bevy_hierarchy" version = "0.13.2" @@ -1479,18 +1363,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "857da8785678fde537d02944cd20dec9cafb7d4c447efe15f898dc60e733cacd" dependencies = [ "bevy_a11y 0.16.1", - "bevy_animation", "bevy_app 0.16.1", "bevy_asset 0.16.1", - "bevy_audio", "bevy_color", "bevy_core_pipeline 0.16.1", "bevy_derive 0.16.1", "bevy_diagnostic 0.16.1", "bevy_ecs 0.16.1", - "bevy_gilrs", "bevy_gizmos 0.16.1", - "bevy_gltf", "bevy_image", "bevy_input 0.16.1", "bevy_input_focus", @@ -1707,7 +1587,6 @@ dependencies = [ "bevy_ecs 0.16.1", "bevy_input 0.16.1", "bevy_math 0.16.1", - "bevy_mesh", "bevy_platform", "bevy_reflect 0.16.1", "bevy_render 0.16.1", @@ -1715,7 +1594,6 @@ dependencies = [ "bevy_transform 0.16.1", "bevy_utils 0.16.1", "bevy_window 0.16.1", - "crossbeam-channel", "tracing", "uuid", ] @@ -1836,7 +1714,6 @@ dependencies = [ "erased-serde", "foldhash", "glam 0.29.3", - "petgraph 0.7.1", "serde", "smallvec", "smol_str", @@ -2105,13 +1982,11 @@ dependencies = [ "bevy_ecs 0.16.1", "bevy_image", "bevy_math 0.16.1", - "bevy_picking", "bevy_platform", "bevy_reflect 0.16.1", "bevy_render 0.16.1", "bevy_transform 0.16.1", "bevy_utils 0.16.1", - "bevy_window 0.16.1", "bitflags 2.9.1", "bytemuck", "derive_more 1.0.0", @@ -2336,7 +2211,6 @@ dependencies = [ "bevy_image", "bevy_input 0.16.1", "bevy_math 0.16.1", - "bevy_picking", "bevy_platform", "bevy_reflect 0.16.1", "bevy_render 0.16.1", @@ -2495,10 +2369,8 @@ dependencies = [ "approx", "bevy_a11y 0.16.1", "bevy_app 0.16.1", - "bevy_asset 0.16.1", "bevy_derive 0.16.1", "bevy_ecs 0.16.1", - "bevy_image", "bevy_input 0.16.1", "bevy_input_focus", "bevy_log 0.16.1", @@ -2508,7 +2380,6 @@ dependencies = [ "bevy_tasks 0.16.1", "bevy_utils 0.16.1", "bevy_window 0.16.1", - "bytemuck", "cfg-if", "crossbeam-channel", "raw-window-handle", @@ -2516,7 +2387,6 @@ dependencies = [ "tracing", "wasm-bindgen", "web-sys", - "wgpu-types 24.0.0", "winit 0.30.11", ] @@ -2581,24 +2451,6 @@ dependencies = [ "syn 2.0.104", ] -[[package]] -name = "bindgen" -version = "0.72.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f72209734318d0b619a5e0f5129918b848c416e122a3c4ce054e03cb87b726f" -dependencies = [ - "bitflags 2.9.1", - "cexpr", - "clang-sys", - "itertools 0.13.0", - "proc-macro2", - "quote", - "regex", - "rustc-hash 2.1.1", - "shlex", - "syn 2.0.104", -] - [[package]] name = "bit-set" version = "0.5.3" @@ -3307,26 +3159,6 @@ dependencies = [ "libm", ] -[[package]] -name = "coreaudio-rs" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "321077172d79c662f64f5071a03120748d5bb652f5231570141be24cfcd2bace" -dependencies = [ - "bitflags 1.3.2", - "core-foundation-sys", - "coreaudio-sys", -] - -[[package]] -name = "coreaudio-sys" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ceec7a6067e62d6f931a2baf6f3a751f4a892595bcec1461a3c94ef9949864b6" -dependencies = [ - "bindgen 0.72.0", -] - [[package]] name = "cosmic-text" version = "0.13.2" @@ -3350,29 +3182,6 @@ dependencies = [ "unicode-segmentation", ] -[[package]] -name = "cpal" -version = "0.15.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "873dab07c8f743075e57f524c583985fbaf745602acbe916a01539364369a779" -dependencies = [ - "alsa", - "core-foundation-sys", - "coreaudio-rs", - "dasp_sample", - "jni", - "js-sys", - "libc", - "mach2", - "ndk 0.8.0", - "ndk-context", - "oboe", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "windows 0.54.0", -] - [[package]] name = "cpufeatures" version = "0.2.17" @@ -3547,7 +3356,7 @@ version = "3.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46f93780a459b7d656ef7f071fe699c4d3d2cb201c4b24d085b6ddc505276e73" dependencies = [ - "nix 0.30.1", + "nix", "windows-sys 0.59.0", ] @@ -3568,12 +3377,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "dasp_sample" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c87e182de0887fd5361989c677c4e8f5000cd9491d6d563161a8f3a5519fc7f" - [[package]] name = "data-encoding" version = "2.9.0" @@ -4439,40 +4242,6 @@ dependencies = [ "weezl", ] -[[package]] -name = "gilrs" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbb2c998745a3c1ac90f64f4f7b3a54219fd3612d7705e7798212935641ed18f" -dependencies = [ - "fnv", - "gilrs-core", - "log", - "uuid", - "vec_map", -] - -[[package]] -name = "gilrs-core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6d95ae10ce5aa99543a28cf74e41c11f3b9e3c14f0452bbde46024753cd683e" -dependencies = [ - "core-foundation 0.10.1", - "inotify 0.11.0", - "io-kit-sys", - "js-sys", - "libc", - "libudev-sys", - "log", - "nix 0.29.0", - "uuid", - "vec_map", - "wasm-bindgen", - "web-sys", - "windows 0.61.3", -] - [[package]] name = "gimli" version = "0.31.1" @@ -4542,42 +4311,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "gltf" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3ce1918195723ce6ac74e80542c5a96a40c2b26162c1957a5cd70799b8cacf7" -dependencies = [ - "byteorder", - "gltf-json", - "lazy_static", - "serde_json", -] - -[[package]] -name = "gltf-derive" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14070e711538afba5d6c807edb74bcb84e5dbb9211a3bf5dea0dfab5b24f4c51" -dependencies = [ - "inflections", - "proc-macro2", - "quote", - "syn 2.0.104", -] - -[[package]] -name = "gltf-json" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6176f9d60a7eab0a877e8e96548605dedbde9190a7ae1e80bbcc1c9af03ab14" -dependencies = [ - "gltf-derive", - "serde", - "serde_derive", - "serde_json", -] - [[package]] name = "glutin" version = "0.32.3" @@ -5148,12 +4881,6 @@ dependencies = [ "serde", ] -[[package]] -name = "inflections" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a257582fdcde896fd96463bf2d40eefea0580021c0712a0e2b028b60b47a837a" - [[package]] name = "inotify" version = "0.10.2" @@ -5214,16 +4941,6 @@ dependencies = [ "syn 2.0.104", ] -[[package]] -name = "io-kit-sys" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "617ee6cf8e3f66f3b4ea67a4058564628cde41901316e19f559e14c7c72c5e7b" -dependencies = [ - "core-foundation-sys", - "mach2", -] - [[package]] name = "io-uring" version = "0.7.8" @@ -5448,17 +5165,6 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" -[[package]] -name = "lewton" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "777b48df9aaab155475a83a7df3070395ea1ac6902f5cd062b8f2b028075c030" -dependencies = [ - "byteorder", - "ogg", - "tinyvec", -] - [[package]] name = "libc" version = "0.2.174" @@ -5512,16 +5218,6 @@ dependencies = [ "redox_syscall 0.5.13", ] -[[package]] -name = "libudev-sys" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c8469b4a23b962c1396b9b451dda50ef5b283e8dd309d69033475fa9b334324" -dependencies = [ - "libc", - "pkg-config", -] - [[package]] name = "linux-raw-sys" version = "0.4.15" @@ -5605,15 +5301,6 @@ dependencies = [ "pkg-config", ] -[[package]] -name = "mach2" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d640282b302c0bb0a2a8e0233ead9035e3bed871f0b7e81fe4a1ec829765db44" -dependencies = [ - "libc", -] - [[package]] name = "malloc_buf" version = "0.0.6" @@ -5925,18 +5612,6 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" -[[package]] -name = "nix" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" -dependencies = [ - "bitflags 2.9.1", - "cfg-if", - "cfg_aliases 0.2.1", - "libc", -] - [[package]] name = "nix" version = "0.30.1" @@ -6467,29 +6142,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "oboe" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8b61bebd49e5d43f5f8cc7ee2891c16e0f41ec7954d36bcb6c14c5e0de867fb" -dependencies = [ - "jni", - "ndk 0.8.0", - "ndk-context", - "num-derive", - "num-traits", - "oboe-sys", -] - -[[package]] -name = "oboe-sys" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8bb09a4a2b1d668170cfe0a7d5bc103f8999fb316c98099b6a9939c9f2e79d" -dependencies = [ - "cc", -] - [[package]] name = "octs" version = "1.0.0" @@ -6509,15 +6161,6 @@ dependencies = [ "nonmax", ] -[[package]] -name = "ogg" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6951b4e8bf21c8193da321bcce9c9dd2e13c858fe078bf9054a288b419ae5d6e" -dependencies = [ - "byteorder", -] - [[package]] name = "once_cell" version = "1.21.3" @@ -6720,18 +6363,6 @@ dependencies = [ "indexmap", ] -[[package]] -name = "petgraph" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3672b37090dbd86368a4145bc067582552b29c27377cad4e0a306c97f9bd7772" -dependencies = [ - "fixedbitset 0.5.7", - "indexmap", - "serde", - "serde_derive", -] - [[package]] name = "petgraph" version = "0.8.2" @@ -7460,16 +7091,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4e27ee8bb91ca0adcf0ecb116293afa12d393f9c2b9b9cd54d33e8078fe19839" -[[package]] -name = "rodio" -version = "0.20.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ceb6607dd738c99bc8cb28eff249b7cd5c8ec88b9db96c0608c1480d140fb1" -dependencies = [ - "cpal", - "lewton", -] - [[package]] name = "ron" version = "0.8.1" @@ -8030,6 +7651,7 @@ dependencies = [ "aeronet_websocket", "bevy 0.16.1", "bevy_common_assets", + "bevy_enoki", "bevy_rapier2d 0.30.0", "bevy_replicon", "clap", @@ -8253,19 +7875,6 @@ dependencies = [ "windows 0.52.0", ] -[[package]] -name = "sysinfo" -version = "0.34.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4b93974b3d3aeaa036504b8eefd4c039dced109171c1ae973f1dc63b2c7e4b2" -dependencies = [ - "libc", - "memchr", - "ntapi", - "objc2-core-foundation", - "windows 0.57.0", -] - [[package]] name = "system-deps" version = "6.2.2" @@ -9724,26 +9333,6 @@ dependencies = [ "windows-targets 0.52.6", ] -[[package]] -name = "windows" -version = "0.54.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9252e5725dbed82865af151df558e754e4a3c2c30818359eb17465f1346a1b49" -dependencies = [ - "windows-core 0.54.0", - "windows-targets 0.52.6", -] - -[[package]] -name = "windows" -version = "0.57.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12342cb4d8e3b046f3d80effd474a7a02447231330ef77d71daa6fbc40681143" -dependencies = [ - "windows-core 0.57.0", - "windows-targets 0.52.6", -] - [[package]] name = "windows" version = "0.58.0" @@ -9785,28 +9374,6 @@ dependencies = [ "windows-targets 0.52.6", ] -[[package]] -name = "windows-core" -version = "0.54.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12661b9c89351d684a50a8a643ce5f608e20243b9fb84687800163429f161d65" -dependencies = [ - "windows-result 0.1.2", - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-core" -version = "0.57.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2ed2439a290666cd67ecce2b0ffaad89c2a56b976b736e6ece670297897832d" -dependencies = [ - "windows-implement 0.57.0", - "windows-interface 0.57.0", - "windows-result 0.1.2", - "windows-targets 0.52.6", -] - [[package]] name = "windows-core" version = "0.58.0" @@ -9855,17 +9422,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "windows-implement" -version = "0.57.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.104", -] - [[package]] name = "windows-implement" version = "0.58.0" @@ -9899,17 +9455,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "windows-interface" -version = "0.57.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.104", -] - [[package]] name = "windows-interface" version = "0.58.0" @@ -9948,15 +9493,6 @@ dependencies = [ "windows-link", ] -[[package]] -name = "windows-result" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" -dependencies = [ - "windows-targets 0.52.6", -] - [[package]] name = "windows-result" version = "0.2.0" diff --git a/crates/unified/Cargo.toml b/crates/unified/Cargo.toml index 85758b5cfcdb0fc6b82b216ba1328b84c796037c..72027883a1da8861cc24e87880d7c3f99595f13e 100644 --- a/crates/unified/Cargo.toml +++ b/crates/unified/Cargo.toml @@ -8,7 +8,24 @@ version = "0.1.0" crate-type = ["cdylib", "rlib"] [dependencies] -bevy = { version = "0.16", features = ["serialize", "tonemapping_luts"] } +bevy = { version = "0.16", default-features = false, features = [ + "serialize", + "tonemapping_luts", + "bevy_window", + "bevy_asset", + "bevy_winit", + "bevy_render", + "bevy_core_pipeline", + "bevy_sprite", + "bevy_text", + "bevy_ui", + "bevy_color", + "bevy_input_focus", + "bevy_log", + "x11", + "wayland", + "multi_threaded" +] } bevy_rapier2d = { version = "0.30", features = ["serde-serialize", "simd-stable"] } bevy_common_assets = { version = "0.13", features = ["toml"] } @@ -32,6 +49,8 @@ aeronet_replicon = { version = "0.15", features = ["client"] } aeronet_transport = "0.14" aeronet_websocket = { version = "0.14", features = ["client"] } +bevy_enoki = "0.4" + [target.'cfg(not(target_arch = "wasm32"))'.dependencies] [target.'cfg(target_arch = "wasm32")'.dependencies] @@ -41,5 +60,9 @@ console_error_panic_hook = "0.1" [features] default = ["native"] -native = ["bevy/file_watcher", "aeronet_websocket/server", "aeronet_replicon/server"] +native = [ + "bevy/file_watcher", + "aeronet_websocket/server", + "aeronet_replicon/server" +] wasm = ["getrandom/wasm_js"] \ No newline at end of file diff --git a/crates/unified/assets/particles/ship_thruster.particle.ron b/crates/unified/assets/particles/ship_thruster.particle.ron new file mode 100644 index 0000000000000000000000000000000000000000..f0b8a40506e9b5e52662e248c3948856b598be7d --- /dev/null +++ b/crates/unified/assets/particles/ship_thruster.particle.ron @@ -0,0 +1 @@ +(spawn_rate:0.01,spawn_amount:1,emission_shape:Point,lifetime:(1.75,0.3),linear_speed:Some((121.0,0.05)),linear_acceleration:Some((0.0,0.0)),direction:Some(((0.0,1.0),0.05)),angular_speed:Some((0.05,1.0)),angular_acceleration:Some((5.0,0.0)),scale:Some((10.0,0.0)),color:None,gravity_direction:Some(((0.0,0.0),0.0)),gravity_speed:Some((0.0,0.0)),linear_damp:Some((0.0,0.0)),angular_damp:Some((5.0,0.0)),scale_curve:Some((points:[(5.0,0.0,None),(0.0,1.0,None)])),color_curve:Some((points:[((red:0.023096813,green:0.47808877,blue:0.76097566,alpha:1.0),0.0,None),((red:0.8211564,green:0.19210109,blue:0.03873736,alpha:1.0),0.12,None),((red:0.028426038,green:0.028426038,blue:0.028426038,alpha:1.0),0.3,None),((red:0.028426038,green:0.028426038,blue:0.028426038,alpha:1.0),1.0,None)]))) \ No newline at end of file diff --git a/crates/unified/src/client/incoming_particles.rs b/crates/unified/src/client/incoming_particles.rs new file mode 100644 index 0000000000000000000000000000000000000000..cf9633cd1a11ab2204003ad1076265955d58d3af --- /dev/null +++ b/crates/unified/src/client/incoming_particles.rs @@ -0,0 +1,27 @@ +use bevy::prelude::*; +use bevy_enoki::{ParticleEffectHandle, ParticleSpawner}; +use bevy_enoki::prelude::ParticleSpawnerState; +use crate::ecs::Particles; + +pub fn replicated_particles_plugin(app: &mut App) { + app.add_systems(PreUpdate, (replicate_new_particles, replicate_updated_particles)); +} + +fn replicate_new_particles(q: Query<(Entity, &Particles), Added>, assets: Res, mut commands: Commands) { + for (entity, p) in q.iter() { + commands.entity(entity) + .insert(ParticleSpawner::default()) + .insert(ParticleEffectHandle(assets.load(&p.effect))) + .insert(ParticleSpawnerState { + active: p.active, + ..default() + }); + info!("replicate_new_particles {:?}", p); + } +} +fn replicate_updated_particles(mut q: Query<(Entity, &mut ParticleEffectHandle, &mut ParticleSpawnerState, &Particles), Changed>, assets: Res, mut commands: Commands ) { + for (_entity, mut handle, mut state, p) in q.iter_mut() { + *handle = ParticleEffectHandle(assets.load(&p.effect)); + state.active = p.active; + } +} \ No newline at end of file diff --git a/crates/unified/src/client/mod.rs b/crates/unified/src/client/mod.rs index 6517e96985678e9e2b47f4700384afecac8e72af..0a998f75ef7a19fff5c81670ba2a5e80240522e3 100644 --- a/crates/unified/src/client/mod.rs +++ b/crates/unified/src/client/mod.rs @@ -5,6 +5,7 @@ mod key_input; mod net; mod starfield; mod ui; +mod incoming_particles; use crate::client::incoming_parts::incoming_parts_plugin; use crate::client::incoming_planets::incoming_planets_plugin; @@ -17,6 +18,7 @@ use bevy::core_pipeline::fxaa::Fxaa; use bevy::prelude::*; use bevy::window::PrimaryWindow; use bevy_replicon::shared::server_entity_map::ServerEntityMap; +use crate::client::incoming_particles::replicated_particles_plugin; pub struct ClientPlugin { pub server: String, @@ -43,7 +45,8 @@ impl Plugin for ClientPlugin { .add_plugins(incoming_parts_plugin) .add_plugins(key_input_plugin) .add_plugins(starfield_plugin) - .add_plugins(ui_plugin); + .add_plugins(ui_plugin) + .add_plugins(replicated_particles_plugin); } } diff --git a/crates/unified/src/client_plugins.rs b/crates/unified/src/client_plugins.rs index 8621c2064045eb9d0f4596d603aba264cc2d3ed4..8048d56817860a3e237b4ed51a33ea1a1f3bf033 100644 --- a/crates/unified/src/client_plugins.rs +++ b/crates/unified/src/client_plugins.rs @@ -4,6 +4,7 @@ use aeronet_websocket::client::WebSocketClientPlugin; use bevy::DefaultPlugins; use bevy::app::{PluginGroup, PluginGroupBuilder}; use bevy::log::LogPlugin; +use bevy_enoki::EnokiPlugin; use bevy_replicon::RepliconPlugins; pub struct ClientPluginGroup { @@ -16,6 +17,7 @@ impl PluginGroup for ClientPluginGroup { .add_group(RepliconPlugins) .add(WebSocketClientPlugin) .add(AeronetRepliconClientPlugin) + .add(EnokiPlugin) .add(ClientPlugin { server: self.server, }) diff --git a/crates/unified/src/ecs.rs b/crates/unified/src/ecs.rs index bb6853641310fa7d3d3a978e4335ac3de1ff1b57..58ab04b346990978abbba21ec97bc51b5fd86576 100644 --- a/crates/unified/src/ecs.rs +++ b/crates/unified/src/ecs.rs @@ -61,3 +61,9 @@ pub struct PlayerThrust { pub left: bool, pub right: bool, } + +#[derive(Component, Serialize, Deserialize, Debug)] +pub struct Particles { + pub effect: String, + pub active: bool +} \ No newline at end of file diff --git a/crates/unified/src/lib.rs b/crates/unified/src/lib.rs index adc27f0d3f542cdd80bcadb0f253c843eee079ab..3d048c37eccdb0a7c6f6c197ad64c15be8810ab3 100644 --- a/crates/unified/src/lib.rs +++ b/crates/unified/src/lib.rs @@ -23,4 +23,4 @@ pub mod ecs; pub mod server; #[cfg(all(not(target_arch = "wasm32"), feature = "native"))] pub mod server_plugins; -pub mod shared_plugins; +pub mod shared_plugins; \ No newline at end of file diff --git a/crates/unified/src/server/player.rs b/crates/unified/src/server/player.rs index aab39e4ff0bf289ed5e48d545adc4be61ee51fc1..a643bf4b21e90fc5d22e3a9437ed27ae3ab165f3 100644 --- a/crates/unified/src/server/player.rs +++ b/crates/unified/src/server/player.rs @@ -1,7 +1,7 @@ use std::f32::consts::PI; use crate::config::planet::Planet; -use crate::ecs::{Part, PartBundle, Player, PlayerThrust, ThrustEvent}; +use crate::ecs::{Part, PartBundle, Particles, Player, PlayerThrust, ThrustEvent}; use crate::server::world_config::WorldConfigResource; use crate::server::{ConnectedGameEntity, ConnectedNetworkEntity}; use bevy::prelude::*; @@ -75,7 +75,45 @@ fn handle_new_players( .insert(PlayerThrust::default()) .insert(Player { client: joined_player, - }); + }) + .insert(children![ + // bottom left + ( + Particles { + effect: "particles/ship_thruster.particle.ron".to_string(), + active: true + }, + Transform::from_xyz(-wc.part.default_width / 2.0 + 5.0, -wc.part.default_height / 2.0, 0.0).with_rotation(Quat::from_rotation_z(180.0f32.to_radians())), + Replicated + ), + // bottom right + ( + Particles { + effect: "particles/ship_thruster.particle.ron".to_string(), + active: true + }, + Transform::from_xyz(wc.part.default_width / 2.0 - 5.0, -wc.part.default_height / 2.0, 0.0).with_rotation(Quat::from_rotation_z(180.0f32.to_radians())), + Replicated + ), + // top left + ( + Particles { + effect: "particles/ship_thruster.particle.ron".to_string(), + active: true + }, + Transform::from_xyz(-wc.part.default_width / 2.0 + 5.0, wc.part.default_height / 2.0, 0.0), + Replicated + ), + // top right + ( + Particles { + effect: "particles/ship_thruster.particle.ron".to_string(), + active: true + }, + Transform::from_xyz(wc.part.default_width / 2.0 - 5.0, wc.part.default_height / 2.0, 0.0), + Replicated + ), + ]); } } diff --git a/crates/unified/src/shared_plugins.rs b/crates/unified/src/shared_plugins.rs index b8fa497a906de9e3f772e94ca05bc43a153a6509..480649010325e15a608ee1905a142eb5a30781d3 100644 --- a/crates/unified/src/shared_plugins.rs +++ b/crates/unified/src/shared_plugins.rs @@ -1,5 +1,5 @@ use crate::config::planet::Planet; -use crate::ecs::{Ball, Ground, Part, Player, SendBallHere, ThrustEvent}; +use crate::ecs::{Ball, Ground, Part, Particles, Player, SendBallHere, ThrustEvent}; use bevy::app::{App, PluginGroup, PluginGroupBuilder}; use bevy::prelude::*; use bevy_rapier2d::prelude::*; @@ -26,7 +26,9 @@ pub fn register_everything(app: &mut App) { .replicate::() .replicate::() .replicate::() - .replicate::(); + .replicate::() + .replicate::() + .replicate::(); } fn physics_setup_plugin(app: &mut App) {