✨♻️➖➕ bevy_vanth, vanth, vanth_derive, vanth_transport: Many changes in preparation for networking
- Created new crate `bevy_vanth` with basic plugin structure for Bevy integration. - Refactored `Id` generation in `vanth` to use `OsRng` and removed redundant `to_u128_pair`/`from_u128_pair` methods. - Moved networking functionality into new `net` module with `Node`, `Packet`, and `Message` types. - Updated `vanth_derive` to use `proc-macro-crate` for reliable crate path resolution. - Added `rand` dependency to replace custom ID generation logic. - Updated `Cargo.toml`/`Cargo.lock` with new dependencies: `bevy_app`, `nix`, `cfg_aliases`, `proc-macro-crate`. - Modified `README.md` with improved project description. - Added commented clippy check in `flake.nix`. - Added `smol`, `async-process`, and `async-trait` dependencies in root and `vanth` crate. - Integrated `vanth` crate into `bevy_vanth` and added serde dependency. - Reorganized test files into module structure for `cli` and `vanth` crates. - Created new modules `compress` and `ecc` in `vanth`. - Implemented `Node` with async `run` method and `Backend` trait for networking in `vanth`. - Renamed `Memory` backend to `InMemoryStore` in `vanth` store module.
This commit is contained in:
parent
5262a266c0
commit
5afe3b61fb
34 changed files with 1887 additions and 483 deletions
10
crates/bevy_vanth/Cargo.toml
Normal file
10
crates/bevy_vanth/Cargo.toml
Normal file
|
@ -0,0 +1,10 @@
|
|||
[package]
|
||||
name = "bevy_vanth"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
|
||||
[dependencies]
|
||||
bevy_ecs.workspace = true
|
||||
bevy_app.workspace = true
|
||||
serde.workspace = true
|
||||
vanth = { path = "../vanth" }
|
56
crates/bevy_vanth/src/lib.rs
Normal file
56
crates/bevy_vanth/src/lib.rs
Normal file
|
@ -0,0 +1,56 @@
|
|||
use bevy_ecs::{component::Component, system::Query, world::World as BevyWorld};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use vanth::{ActiveTask, Module, Root, Task, Vanth, entity::TaskId};
|
||||
|
||||
// TODO: Should there be one plugin per root, or one global plugin with many root components?
|
||||
// #[derive(Component)]
|
||||
// pub struct VanthRoot {}
|
||||
|
||||
pub struct BevyVanthPlugin {
|
||||
root: Root,
|
||||
}
|
||||
|
||||
impl BevyVanthPlugin {
|
||||
pub fn from_root(root: Root) -> Self {
|
||||
Self { root }
|
||||
}
|
||||
}
|
||||
|
||||
// impl bevy_app::Plugin for BevyVanthPlugin {
|
||||
// fn build(&self, app: &mut bevy_app::App) {
|
||||
// app.add_systems(bevy_app::Update, process_active_tasks);
|
||||
// }
|
||||
// }
|
||||
|
||||
pub struct BevyPluginModule<M: Module>(M);
|
||||
|
||||
impl<M> From<M> for BevyPluginModule<M>
|
||||
where
|
||||
M: Module + Send + Sync,
|
||||
{
|
||||
fn from(value: M) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl<M> bevy_app::Plugin for BevyPluginModule<M>
|
||||
where
|
||||
M: Module + Send + Sync + 'static,
|
||||
{
|
||||
fn build(&self, app: &mut bevy_app::App) {
|
||||
// app.add_systems(bevy_app::FixedPreUpdate, run_vanth).finish();
|
||||
}
|
||||
}
|
||||
|
||||
fn process_active_tasks(tasks: Query<()>) {}
|
||||
|
||||
pub fn run_task<I, O, T: Task<Input = I, Output = O>>(world: &mut BevyWorld, task: T) -> TaskId {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub fn creation_bevy_plugin<M>(module: M) -> impl bevy_app::Plugin
|
||||
where
|
||||
M: Module + Send + Sync + 'static,
|
||||
{
|
||||
BevyPluginModule(module)
|
||||
}
|
42
crates/bevy_vanth/tests/test.rs
Normal file
42
crates/bevy_vanth/tests/test.rs
Normal file
|
@ -0,0 +1,42 @@
|
|||
use bevy_app::App;
|
||||
use bevy_vanth::BevyPluginModule;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use vanth::{Module, Vanth};
|
||||
|
||||
mod bevy_tests {
|
||||
use bevy_app::Plugin;
|
||||
use vanth::Root;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[derive(Deserialize, Serialize, Vanth)]
|
||||
struct TestData {
|
||||
number: u32,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Vanth)]
|
||||
struct TestTask {
|
||||
a: TestData,
|
||||
b: TestData,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Vanth)]
|
||||
struct TestModule {}
|
||||
|
||||
impl Module for TestModule {
|
||||
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bevy() {
|
||||
let root = Root::local();
|
||||
let module = TestModule {};
|
||||
let module_bevy_plugin = bevy_vanth::creation_bevy_plugin(module);
|
||||
let bevy_vanth_plugin = bevy_vanth::BevyVanthPlugin::from_root(root);
|
||||
|
||||
let mut app = App::new();
|
||||
|
||||
app.add_plugins(module_bevy_plugin);
|
||||
// app.add_plugins(bevy_vanth_plugin);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue