From a4fc8286b11b866367e8472b51d94dff3f193d47 Mon Sep 17 00:00:00 2001 From: Tobias Berger Date: Mon, 19 Sep 2022 13:58:47 +0200 Subject: [PATCH] Fix compilation on different feature-sets --- planet/src/biome.rs | 104 +++++++++++++++++++----------------- planet/src/lib.rs | 2 +- planet/src/world.rs | 2 +- planet/src/world_manager.rs | 4 +- src/main.rs | 3 +- 5 files changed, 62 insertions(+), 53 deletions(-) diff --git a/planet/src/biome.rs b/planet/src/biome.rs index 1e93906..0825842 100644 --- a/planet/src/biome.rs +++ b/planet/src/biome.rs @@ -37,82 +37,90 @@ impl From for Biome { fn from(biome_type: BiomeType) -> Biome { match biome_type { BiomeType::IceCap => Biome { - name: "Ice Cap".into(), - color: Color::rgb_u8(253, 244, 235), - min_altitude: World::MIN_ALTITUDE, - max_altitude: World::MAX_ALTITUDE, - min_rainfall: World::MIN_RAINFALL, - max_rainfall: World::MAX_RAINFALL, + name: "Ice Cap".into(), + #[cfg(feature = "render")] + color: Color::rgb_u8(253, 244, 235), + min_altitude: World::MIN_ALTITUDE, + max_altitude: World::MAX_ALTITUDE, + min_rainfall: World::MIN_RAINFALL, + max_rainfall: World::MAX_RAINFALL, min_temperature: World::MIN_TEMPERATURE, max_temperature: -15.0, }, BiomeType::Ocean => Biome { - name: "Ocean".into(), - color: Color::rgb_u8(28, 66, 84), - min_altitude: World::MIN_ALTITUDE, - max_altitude: 0.0, - min_rainfall: World::MIN_RAINFALL, - max_rainfall: World::MAX_RAINFALL, + name: "Ocean".into(), + #[cfg(feature = "render")] + color: Color::rgb_u8(28, 66, 84), + min_altitude: World::MIN_ALTITUDE, + max_altitude: 0.0, + min_rainfall: World::MIN_RAINFALL, + max_rainfall: World::MAX_RAINFALL, min_temperature: -15.0, max_temperature: World::MAX_TEMPERATURE, }, BiomeType::Grassland => Biome { - name: "Grassland".into(), - color: Color::rgb_u8(167, 177, 84), - min_altitude: 0.0, - max_altitude: World::MAX_ALTITUDE, - min_rainfall: 25.0, - max_rainfall: 1475.0, + name: "Grassland".into(), + #[cfg(feature = "render")] + color: Color::rgb_u8(167, 177, 84), + min_altitude: 0.0, + max_altitude: World::MAX_ALTITUDE, + min_rainfall: 25.0, + max_rainfall: 1475.0, min_temperature: -5.0, max_temperature: World::MAX_TEMPERATURE, }, BiomeType::Forest => Biome { - name: "Forest".into(), - color: Color::rgb_u8(76, 132, 55), - min_altitude: 0.0, - max_altitude: World::MAX_ALTITUDE, - min_rainfall: 975.0, - max_rainfall: 2475.0, + name: "Forest".into(), + #[cfg(feature = "render")] + color: Color::rgb_u8(76, 132, 55), + min_altitude: 0.0, + max_altitude: World::MAX_ALTITUDE, + min_rainfall: 975.0, + max_rainfall: 2475.0, min_temperature: -5.0, max_temperature: World::MAX_TEMPERATURE, }, BiomeType::Taiga => Biome { - name: "Taiga".into(), - color: Color::rgb_u8(43, 63, 40), - min_altitude: 0.0, - max_altitude: World::MAX_ALTITUDE, - min_rainfall: 475.0, - max_rainfall: World::MAX_RAINFALL, + name: "Taiga".into(), + #[cfg(feature = "render")] + color: Color::rgb_u8(43, 63, 40), + min_altitude: 0.0, + max_altitude: World::MAX_ALTITUDE, + min_rainfall: 475.0, + max_rainfall: World::MAX_RAINFALL, min_temperature: -15.0, max_temperature: -0.0, }, BiomeType::Tundra => Biome { - name: "Tundra ".into(), - color: Color::rgb_u8(139, 139, 128), - min_altitude: 0.0, - max_altitude: World::MAX_ALTITUDE, - min_rainfall: World::MIN_RAINFALL, - max_rainfall: 725.0, + name: "Tundra ".into(), + #[cfg(feature = "render")] + color: Color::rgb_u8(139, 139, 128), + min_altitude: 0.0, + max_altitude: World::MAX_ALTITUDE, + min_rainfall: World::MIN_RAINFALL, + max_rainfall: 725.0, min_temperature: -20.0, max_temperature: -0.0, }, BiomeType::Desert => Biome { - name: "Desert ".into(), - color: Color::rgb_u8(253, 225, 171), - min_altitude: 0.0, - max_altitude: World::MAX_ALTITUDE, - min_rainfall: World::MIN_RAINFALL, - max_rainfall: 125.0, + name: "Desert ".into(), + #[cfg(feature = "render")] + color: Color::rgb_u8(253, 225, 171), + min_altitude: 0.0, + max_altitude: World::MAX_ALTITUDE, + min_rainfall: World::MIN_RAINFALL, + max_rainfall: 125.0, min_temperature: -5.0, max_temperature: World::MAX_TEMPERATURE, }, BiomeType::Rainforest => Biome { - name: "Rainforest".into(), - color: Color::rgb_u8(59, 103, 43), - min_altitude: 0.0, - max_altitude: World::MAX_ALTITUDE, - min_rainfall: 1975.0, - max_rainfall: World::MAX_RAINFALL, + name: "Rainforest".into(), + #[cfg(feature = "render")] + color: Color::rgb_u8(59, 103, 43), + min_altitude: 0.0, + max_altitude: World::MAX_ALTITUDE, + min_rainfall: 1975.0, + max_rainfall: World::MAX_RAINFALL, min_temperature: -5.0, max_temperature: World::MAX_TEMPERATURE, }, diff --git a/planet/src/lib.rs b/planet/src/lib.rs index ebec281..e211c5f 100644 --- a/planet/src/lib.rs +++ b/planet/src/lib.rs @@ -35,7 +35,7 @@ pub mod world; pub use world::*; pub mod biome; -pub use biome::Biome; +pub use biome::*; pub mod world_manager; pub use world_manager::*; pub mod math_util; diff --git a/planet/src/world.rs b/planet/src/world.rs index 4031f2a..b1f384d 100644 --- a/planet/src/world.rs +++ b/planet/src/world.rs @@ -1,12 +1,12 @@ // TODO: Logging doesn't seem to work here? Figure out why and fix use { crate::{ - biome::BiomeType, cartesian_coordinates, mix_values, perlin, random_point_in_sphere, Biome, + BiomeType, CartesianError, RepeatNum, }, diff --git a/planet/src/world_manager.rs b/planet/src/world_manager.rs index f74848a..c8b3c6c 100644 --- a/planet/src/world_manager.rs +++ b/planet/src/world_manager.rs @@ -4,7 +4,7 @@ use bevy::log::debug; use bevy::utils::default; #[cfg(feature = "render")] use { - crate::TerrainCell, + crate::{Biome, TerrainCell}, bevy::{ asset::{Assets, HandleId}, render::render_resource::Extent3d, @@ -12,7 +12,7 @@ use { }, }; use { - crate::{Biome, World, WorldGenError}, + crate::{World, WorldGenError}, bevy::log::warn, rand::random, std::{ diff --git a/src/main.rs b/src/main.rs index de693de..745d39b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -100,6 +100,7 @@ use { markers::{InfoPanel, ToolbarButton}, third_party::PanCam, }, + planet::Biome, resources::CursorMapPosition, ui_helpers::{toolbar_button, toolbar_button_text}, }; @@ -109,7 +110,7 @@ use { log::LogSettings, utils::{default, tracing::Level}, }, - planet::{Biome, WorldManager}, + planet::WorldManager, plugins::WorldPlugins, };