14026
|
1 |
use integral_geometry::Point;
|
|
2 |
use land2d::Land2D;
|
|
3 |
use LandGenerationParameters;
|
|
4 |
use LandGenerator;
|
|
5 |
|
|
6 |
struct OutlineTemplate {
|
|
7 |
islands: Vec<Vec<Point>>,
|
|
8 |
fill_points: Vec<Point>,
|
|
9 |
width: usize,
|
|
10 |
height: usize,
|
|
11 |
can_flip: bool,
|
|
12 |
can_invert: bool,
|
|
13 |
can_mirror: bool,
|
|
14 |
is_negative: bool,
|
|
15 |
}
|
|
16 |
|
|
17 |
struct TemplatedLandGenerator {
|
|
18 |
outline_template: OutlineTemplate,
|
|
19 |
}
|
|
20 |
|
|
21 |
impl OutlineTemplate {}
|
|
22 |
|
|
23 |
impl TemplatedLandGenerator {
|
|
24 |
fn new(outline_template: OutlineTemplate) -> Self {
|
|
25 |
Self { outline_template }
|
|
26 |
}
|
|
27 |
}
|
|
28 |
|
|
29 |
impl LandGenerator for TemplatedLandGenerator {
|
|
30 |
fn generate_land<T: Copy + PartialEq, I: Iterator<Item = u32>>(
|
|
31 |
&self,
|
|
32 |
parameters: LandGenerationParameters<T>,
|
|
33 |
random_numbers: &mut I,
|
|
34 |
) -> Land2D<T> {
|
|
35 |
let mut pa = Vec::new();
|
|
36 |
|
|
37 |
for island in &self.outline_template.islands {
|
|
38 |
let mut island_points = Vec::new();
|
|
39 |
|
|
40 |
for p in island {
|
|
41 |
island_points.push(p);
|
|
42 |
}
|
|
43 |
|
|
44 |
pa.push(island_points);
|
|
45 |
}
|
|
46 |
|
|
47 |
let mut land = Land2D::new(
|
|
48 |
self.outline_template.width,
|
|
49 |
self.outline_template.height,
|
|
50 |
parameters.basic,
|
|
51 |
);
|
|
52 |
|
|
53 |
land
|
|
54 |
}
|
|
55 |
}
|