diff --git a/Cargo.lock b/Cargo.lock index cd52a482b1..02edf8956d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5962,6 +5962,7 @@ dependencies = [ "futures-util", "hashbrown 0.11.2", "humantime", + "inline_tweak", "itertools 0.10.0", "lazy_static", "num_cpus", diff --git a/server/Cargo.toml b/server/Cargo.toml index 4236c3d887..3eecca315a 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -21,7 +21,7 @@ common-net = { package = "veloren-common-net", path = "../common/net" } world = { package = "veloren-world", path = "../world" } network = { package = "veloren-network", path = "../network", features = ["metrics", "compression", "quic"], default-features = false } -# inline_tweak = "1.0.8" +inline_tweak = "1.0.8" specs = { git = "https://github.com/amethyst/specs.git", features = ["shred-derive"], rev = "f985bec5d456f7b0dd8aae99848f9473c2cd9d46" } specs-idvs = { git = "https://gitlab.com/veloren/specs-idvs.git", rev = "8be2abcddf8f524cb5876e8dd20a7e47cfaf7573" } diff --git a/server/src/sys/windsim.rs b/server/src/sys/windsim.rs index 852b3aa037..83b54fcdc8 100644 --- a/server/src/sys/windsim.rs +++ b/server/src/sys/windsim.rs @@ -7,6 +7,7 @@ use common::{ use common_ecs::{Job, Origin, Phase, System}; use specs::{Read, Write}; use vek::*; +use rand::Rng; /// This system updates the wind grid for the entire map #[derive(Default)] @@ -20,18 +21,26 @@ impl<'a> System<'a> for Sys { const PHASE: Phase = Phase::Create; fn run(_job: &mut Job, (dt, mut windsim): Self::SystemData) { - let wind_sources: Vec<(Pos, Vel)> = vec![( - Pos(Vec3 { - x: 9999.0, - y: 9599.0, - z: 200.0, - }), - Vel(Vec3 { - x: 100.0, - y: 100.0, - z: 500.0, - }), - )]; + let mut rng = rand::thread_rng(); + let wind_sources: Vec<(Pos, Vel)> = (0..1000) + .map(|y| { + let r1 = rng.gen_range(0.0..std::f32::consts::PI / 2.0); + let r2 = rng.gen_range(0.0..std::f32::consts::PI / 2.0); + let r = (r1 + r2) / 2.0; + ( + Pos(Vec3 { + x: inline_tweak::tweak!(5000.0), + y: y as f32 * 32.0, + z: inline_tweak::tweak!(200.0), + }), + Vel(Vec3 { + x: inline_tweak::tweak!(30.0) * r.sin(), + y: inline_tweak::tweak!(30.0) * r.cos(), + z: inline_tweak::tweak!(30.0) * rng.gen_range(-0.25..0.25), + }), + ) + }) + .collect::>(); windsim.tick(wind_sources, &dt); } }