veloren_world/
config.rs

1use common::assets::{BoxedError, FileAsset, load_ron};
2use serde::Deserialize;
3use std::borrow::Cow;
4use vek::*;
5
6pub struct Config {
7    pub sea_level: f32,
8    pub mountain_scale: f32,
9    pub snow_temp: f32,
10    pub temperate_temp: f32,
11    pub tropical_temp: f32,
12    pub desert_temp: f32,
13    pub desert_hum: f32,
14    pub forest_hum: f32,
15    pub jungle_hum: f32,
16    /// Rainfall (in meters) per m² of surface per minute.  Default is set to
17    /// make it approximately 1 m rainfall / year uniformly across the whole
18    /// land area, which is the average rainfall on Earth.
19    pub rainfall_chunk_rate: f32,
20    /// Roughness coefficient is an empirical value that controls the rate of
21    /// energy loss of water in a river.  The higher it is, the more water
22    /// slows down as it flows downhill, which consequently leads to lower
23    /// velocities and higher river area for the same flow rate.
24    ///
25    /// See <https://wwwrcamnl.wr.usgs.gov/sws/fieldmethods/Indirects/nvalues/index.htm>.
26    ///
27    /// The default is set to over 0.06, which is pretty high but still within a
28    /// reasonable range for rivers.  The higher this is, the quicker rivers
29    /// appear, and since we often will have high slopes we want to give
30    /// rivers as much of a chance as possible.  In the future we can set
31    /// this dynamically.
32    ///
33    /// NOTE: The values in the link are in seconds / (m^(-1/3)), but we use
34    /// them without conversion as though they are in minutes / (m^(-1/3)).
35    /// The idea here is that our clock speed has time go by at
36    /// approximately 1 minute per second, but since velocity depends on
37    /// this parameter, we want flow rates to still "look" natural at the second
38    /// level.  The way we are cheating is that we still allow the refill
39    /// rate (via rainfall) of rivers and lakes to be specified as though
40    /// minutes are *really* minutes.  This reduces the amount of water
41    /// needed to form a river of a given area by 60, but hopefully this should
42    /// not feel too unnatural since the refill rate is still below what
43    /// people should be able to perceive.
44    pub river_roughness: f32,
45    /// Maximum width of rivers, in terms of a multiple of the horizontal chunk
46    /// size.
47    ///
48    /// Currently, not known whether setting this above 1.0 will work properly.
49    /// Please use with care!
50    pub river_max_width: f32,
51    /// Minimum height at which rivers display.
52    pub river_min_height: f32,
53    /// Rough desired river width-to-depth ratio (in terms of horizontal chunk
54    /// width / m, for some reason).  Not exact.
55    pub river_width_to_depth: f32,
56    /// TODO: Move to colors.ron when blockgen can access it
57    pub ice_color: Rgb<u8>,
58}
59
60pub const CONFIG: Config = Config {
61    sea_level: 140.0,
62    mountain_scale: 2048.0,
63    // temperature
64    snow_temp: -0.8,
65    temperate_temp: -0.4,
66    tropical_temp: 0.4,
67    desert_temp: 0.8,
68    // humidity
69    desert_hum: 0.15,
70    forest_hum: 0.5,
71    jungle_hum: 0.75,
72    // water
73    rainfall_chunk_rate: 1.0 / (512.0 * 32.0 * 32.0),
74    river_roughness: 0.06125,
75    river_max_width: 2.0,
76    river_min_height: 0.25,
77    river_width_to_depth: 8.0,
78    ice_color: Rgb::new(140, 175, 255),
79};
80
81#[derive(Deserialize)]
82pub struct Features {
83    pub caverns: bool,
84    pub caves: bool,
85    pub rocks: bool,
86    pub shrubs: bool,
87    pub trees: bool,
88    pub scatter: bool,
89    pub paths: bool,
90    pub spots: bool,
91    // 1.0 is the default wildlife density
92    pub wildlife_density: f32,
93    pub peak_naming: bool,
94    pub biome_naming: bool,
95    pub train_tracks: bool,
96}
97
98impl FileAsset for Features {
99    const EXTENSION: &'static str = "ron";
100
101    fn from_bytes(bytes: Cow<[u8]>) -> Result<Self, BoxedError> { load_ron(&bytes) }
102}