fern_sim_test/plant_structures/
mod.rs

1// Declaramos los módulos
2
3pub mod leaves;
4pub mod roots;
5pub mod stems;
6
7pub use self::leaves::Leaf;
8pub use self::roots::Root;
9
10use self::roots::RootSet;
11use stems::StemSet;
12
13pub enum FernType {
14    Fiddlehead,
15}
16
17pub struct Fern {
18    pub roots: RootSet,
19    pub stems: StemSet,
20    pub size: f64,
21    pub growth_rate: f64,
22}
23
24impl Fern {
25    pub fn new(_type: FernType) -> Fern {
26        Fern {
27            roots: vec![],
28            stems: vec![stems::Stem { furled: true }],
29            size: 1.0,
30            growth_rate: 0.001,
31        }
32    }
33
34    pub fn grow(&mut self) {
35        self.size *= 1.0 + self.growth_rate;
36    }
37
38    pub fn is_furled(&self) -> bool {
39        !self.is_fully_unfurled()
40    }
41
42    pub fn is_fully_unfurled(&self) -> bool {
43        self.stems.iter().all(|s| !s.furled)
44    }
45}