rust/landgen/src/lib.rs
changeset 14121 69db1d2e4cec
parent 14100 4d22be35cfa2
child 14207 bb2f301d4fe0
equal deleted inserted replaced
14120:7bb0e27910aa 14121:69db1d2e4cec
     8 
     8 
     9 pub struct LandGenerationParameters<T> {
     9 pub struct LandGenerationParameters<T> {
    10     zero: T,
    10     zero: T,
    11     basic: T,
    11     basic: T,
    12     distance_divisor: u32,
    12     distance_divisor: u32,
       
    13     skip_distort: bool,
       
    14     skip_bezier: bool,
    13 }
    15 }
    14 
    16 
    15 impl<T: Copy + PartialEq> LandGenerationParameters<T> {
    17 impl<T: Copy + PartialEq> LandGenerationParameters<T> {
    16     pub fn new(zero: T, basic: T) -> Self {
    18     pub fn new(zero: T, basic: T, distance_divisor: u32, skip_distort: bool, skip_bezier: bool) -> Self {
    17         Self {
    19         Self {
    18             zero,
    20             zero,
    19             basic,
    21             basic,
    20             distance_divisor: 1,
    22             distance_divisor,
       
    23             skip_distort,
       
    24             skip_bezier,
    21         }
    25         }
    22     }
    26     }
    23 }
    27 }
    24 
    28 
    25 pub trait LandGenerator {
    29 pub trait LandGenerator {
    26     fn generate_land<T: Copy + PartialEq, I: Iterator<Item = u32>>(
    30     fn generate_land<T: Copy + PartialEq, I: Iterator<Item = u32>>(
    27         &self,
    31         &self,
    28         parameters: LandGenerationParameters<T>,
    32         parameters: &LandGenerationParameters<T>,
    29         random_numbers: &mut I,
    33         random_numbers: &mut I,
    30     ) -> land2d::Land2D<T>;
    34     ) -> land2d::Land2D<T>;
    31 }
    35 }
    32 
    36 
    33 #[cfg(test)]
    37 #[cfg(test)]