rust/landgen/src/lib.rs
author unC0Rr
Wed, 04 Jan 2023 11:56:58 +0100
branchtransitional_engine
changeset 15905 022ec6b916b7
parent 15903 230dc46487ea
child 15912 6e22f4390b7e
permissions -rw-r--r--
Split generation and painting phases, paint by old engine, use template filters

mod outline;
pub mod outline_template;
pub mod template_based;

#[derive(Clone, Copy)]
pub struct LandGenerationParameters<T> {
    zero: T,
    basic: T,
    distance_divisor: u32,
    skip_distort: bool,
    skip_bezier: bool,
}

impl<T: Copy + PartialEq> LandGenerationParameters<T> {
    pub fn new(
        zero: T,
        basic: T,
        distance_divisor: u32,
        skip_distort: bool,
        skip_bezier: bool,
    ) -> Self {
        Self {
            zero,
            basic,
            distance_divisor,
            skip_distort,
            skip_bezier,
        }
    }

    pub fn zero(&self) -> T {
        self.zero
    }

    pub fn basic(&self) -> T {
        self.basic
    }
}

pub trait LandGenerator {
    fn generate_land<T: Copy + PartialEq, I: Iterator<Item = u32>>(
        &self,
        parameters: &LandGenerationParameters<T>,
        random_numbers: &mut I,
    ) -> land2d::Land2D<T>;
}

#[cfg(test)]
mod tests {
    #[test]
    fn it_works() {
        assert_eq!(2 + 2, 4);
    }
}