diff --git a/Cargo.lock b/Cargo.lock index 43cc013..de93e3e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -371,7 +371,6 @@ dependencies = [ "bevy_ptr", "bevy_reflect", "bevy_render", - "bevy_scene", "bevy_sprite", "bevy_tasks", "bevy_text", diff --git a/Cargo.toml b/Cargo.toml index 1c6f8bb..0ceca43 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [features] debug = ["save/debug"] -render = ["bevy/bevy_asset", "bevy/bevy_winit", "bevy/bevy_scene", "bevy/render", "save/render"] +render = ["bevy/bevy_asset", "bevy/bevy_winit", "bevy/render", "save/render"] default = ["render"] [dependencies.save] diff --git a/save/src/world.rs b/save/src/world.rs index 6965899..2e15f84 100644 --- a/save/src/world.rs +++ b/save/src/world.rs @@ -280,12 +280,12 @@ impl World { } fn generate_rainfall_alt(&mut self) -> Result<(), CartesianError> { - const MAX_CYCLES: u8 = 25; + let max_cycles = self.width; - const ACCUMULATED_RAIN_FACTOR: f32 = 2.0; - const RAINFALL_FACTOR: f32 = 0.1; + const ACCUMULATED_RAIN_FACTOR: f32 = 0.002; + const RAINFALL_FACTOR: f32 = 0.025; - for _ in 0..MAX_CYCLES { + for _ in 0..max_cycles { for x in 0..self.width { let prev_x = (x + 1) % self.width; @@ -302,9 +302,19 @@ impl World { let prev_cell = self.terrain[y as usize][prev_x as usize]; + let altitude_difference = f32::max( + 0.0, + f32::max(0.0, cell.altitude) - f32::max(0.0, prev_cell.altitude), + ); + let final_rain_factor = f32::min( + 0.1, + RAINFALL_FACTOR + (altitude_difference / Self::MAX_ALTITUDE) * 0.1, + ); + cell.rain_accumulated += prev_cell.rain_accumulated; - cell.rainfall += cell.rain_accumulated * RAINFALL_FACTOR; - cell.rain_accumulated -= cell.rainfall; + let rain_accumulated = cell.rain_accumulated * final_rain_factor; + cell.rainfall += rain_accumulated / (width_factor + 0.001); + cell.rain_accumulated -= rain_accumulated; cell.rain_accumulated = f32::max(cell.rain_accumulated, 0.0);