author | unC0Rr |
Sun, 01 Dec 2024 21:08:03 +0100 | |
branch | transitional_engine |
changeset 16044 | 5c941f5deeec |
parent 16029 | 9cbd18220eb7 |
permissions | -rw-r--r-- |
14069 | 1 |
use integral_geometry::{Point, Rect, Size}; |
2 |
||
14128
b04dac00e8e2
add command arguments to use a template from file into land_dump
alfadur
parents:
14126
diff
changeset
|
3 |
#[derive(Clone, Debug)] |
14069 | 4 |
pub struct OutlineTemplate { |
5 |
pub islands: Vec<Vec<Rect>>, |
|
16044
5c941f5deeec
* Introduce concept of invizible walls to constrain outline map generation
unC0Rr
parents:
16029
diff
changeset
|
6 |
pub walls: Vec<Vec<Rect>>, |
14069 | 7 |
pub fill_points: Vec<Point>, |
8 |
pub size: Size, |
|
9 |
pub can_flip: bool, |
|
10 |
pub can_invert: bool, |
|
11 |
pub can_mirror: bool, |
|
12 |
pub is_negative: bool, |
|
13 |
} |
|
14 |
||
15 |
impl OutlineTemplate { |
|
16 |
pub fn new(size: Size) -> Self { |
|
17 |
OutlineTemplate { |
|
18 |
size, |
|
19 |
islands: Vec::new(), |
|
16044
5c941f5deeec
* Introduce concept of invizible walls to constrain outline map generation
unC0Rr
parents:
16029
diff
changeset
|
20 |
walls: Vec::new(), |
14069 | 21 |
fill_points: Vec::new(), |
22 |
can_flip: false, |
|
23 |
can_invert: false, |
|
24 |
can_mirror: false, |
|
25 |
is_negative: false, |
|
26 |
} |
|
27 |
} |
|
28 |
||
29 |
pub fn flippable(self) -> Self { |
|
30 |
Self { |
|
31 |
can_flip: true, |
|
32 |
..self |
|
33 |
} |
|
34 |
} |
|
35 |
||
36 |
pub fn mirrorable(self) -> Self { |
|
37 |
Self { |
|
38 |
can_mirror: true, |
|
39 |
..self |
|
40 |
} |
|
41 |
} |
|
42 |
||
43 |
pub fn invertable(self) -> Self { |
|
44 |
Self { |
|
45 |
can_invert: true, |
|
46 |
..self |
|
47 |
} |
|
48 |
} |
|
49 |
||
50 |
pub fn negative(self) -> Self { |
|
51 |
Self { |
|
52 |
is_negative: true, |
|
53 |
..self |
|
54 |
} |
|
55 |
} |
|
56 |
||
16029 | 57 |
pub fn cavern(self) -> Self { |
58 |
Self { |
|
59 |
is_negative: true, |
|
60 |
can_invert: false, |
|
61 |
..self |
|
62 |
} |
|
63 |
} |
|
64 |
||
14069 | 65 |
pub fn with_fill_points(self, fill_points: Vec<Point>) -> Self { |
66 |
Self { |
|
67 |
fill_points, |
|
68 |
..self |
|
69 |
} |
|
70 |
} |
|
71 |
||
72 |
pub fn with_islands(self, islands: Vec<Vec<Rect>>) -> Self { |
|
73 |
Self { islands, ..self } |
|
74 |
} |
|
75 |
||
76 |
pub fn add_fill_points(mut self, points: &[Point]) -> Self { |
|
77 |
self.fill_points.extend_from_slice(points); |
|
78 |
self |
|
79 |
} |
|
80 |
||
81 |
pub fn add_island(mut self, island: &[Rect]) -> Self { |
|
82 |
self.islands.push(island.into()); |
|
83 |
self |
|
84 |
} |
|
85 |
} |