1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
use common::assets;
use serde::Deserialize;
use vek::*;

pub struct Config {
    pub sea_level: f32,
    pub mountain_scale: f32,
    pub snow_temp: f32,
    pub temperate_temp: f32,
    pub tropical_temp: f32,
    pub desert_temp: f32,
    pub desert_hum: f32,
    pub forest_hum: f32,
    pub jungle_hum: f32,
    /// Rainfall (in meters) per m² of surface per minute.  Default is set to
    /// make it approximately 1 m rainfall / year uniformly across the whole
    /// land area, which is the average rainfall on Earth.
    pub rainfall_chunk_rate: f32,
    /// Roughness coefficient is an empirical value that controls the rate of
    /// energy loss of water in a river.  The higher it is, the more water
    /// slows down as it flows downhill, which consequently leads to lower
    /// velocities and higher river area for the same flow rate.
    ///
    /// See https://wwwrcamnl.wr.usgs.gov/sws/fieldmethods/Indirects/nvalues/index.htm.
    ///
    /// The default is set to over 0.06, which is pretty high but still within a
    /// reasonable range for rivers.  The higher this is, the quicker rivers
    /// appear, and since we often will have high slopes we want to give
    /// rivers as much of a chance as possible.  In the future we can set
    /// this dynamically.
    ///
    /// NOTE: The values in the link are in seconds / (m^(-1/3)), but we use
    /// them without conversion as though they are in minutes / (m^(-1/3)).
    /// The idea here is that our clock speed has time go by at
    /// approximately 1 minute per second, but since velocity depends on
    /// this parameter, we want flow rates to still "look" natural at the second
    /// level.  The way we are cheating is that we still allow the refill
    /// rate (via rainfall) of rivers and lakes to be specified as though
    /// minutes are *really* minutes.  This reduces the amount of water
    /// needed to form a river of a given area by 60, but hopefully this should
    /// not feel too unnatural since the refill rate is still below what
    /// people should be able to perceive.
    pub river_roughness: f32,
    /// Maximum width of rivers, in terms of a multiple of the horizontal chunk
    /// size.
    ///
    /// Currently, not known whether setting this above 1.0 will work properly.
    /// Please use with care!
    pub river_max_width: f32,
    /// Minimum height at which rivers display.
    pub river_min_height: f32,
    /// Rough desired river width-to-depth ratio (in terms of horizontal chunk
    /// width / m, for some reason).  Not exact.
    pub river_width_to_depth: f32,
    /// TODO: Move to colors.ron when blockgen can access it
    pub ice_color: Rgb<u8>,
}

pub const CONFIG: Config = Config {
    sea_level: 140.0,
    mountain_scale: 2048.0,
    // temperature
    snow_temp: -0.8,
    temperate_temp: -0.4,
    tropical_temp: 0.4,
    desert_temp: 0.8,
    // humidity
    desert_hum: 0.15,
    forest_hum: 0.5,
    jungle_hum: 0.75,
    // water
    rainfall_chunk_rate: 1.0 / (512.0 * 32.0 * 32.0),
    river_roughness: 0.06125,
    river_max_width: 2.0,
    river_min_height: 0.25,
    river_width_to_depth: 8.0,
    ice_color: Rgb::new(140, 175, 255),
};

#[derive(Deserialize)]
pub struct Features {
    pub caverns: bool,
    pub caves: bool,
    pub rocks: bool,
    pub shrubs: bool,
    pub trees: bool,
    pub scatter: bool,
    pub paths: bool,
    pub spots: bool,
    pub site2_towns: bool,
    pub site2_giant_trees: bool,
    // 1.0 is the default wildlife density
    pub wildlife_density: f32,
    pub peak_naming: bool,
    pub biome_naming: bool,
    pub train_tracks: bool,
}

impl assets::Asset for Features {
    type Loader = assets::RonLoader;

    const EXTENSION: &'static str = "ron";
}