author | unC0Rr |
Wed, 18 Sep 2024 13:42:26 +0200 | |
branch | transitional_engine |
changeset 16064 | 0caa3dfb3ba2 |
parent 16058 | 9cbd18220eb7 |
child 16073 | 5c941f5deeec |
permissions | -rw-r--r-- |
15952
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
1 |
use integral_geometry::{Point, Rect, Size}; |
15953
d46ad15c6dec
Get wavefront collapse generator to work in engine
unC0Rr
parents:
15952
diff
changeset
|
2 |
|
15954 | 3 |
use landgen::outline_template_based::outline_template::OutlineTemplate; |
15952
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
4 |
use serde_derive::Deserialize; |
15953
d46ad15c6dec
Get wavefront collapse generator to work in engine
unC0Rr
parents:
15952
diff
changeset
|
5 |
|
15954 | 6 |
use std::collections::hash_map::HashMap; |
15952
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
7 |
|
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
8 |
#[derive(Deserialize)] |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
9 |
pub struct PointDesc { |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
10 |
x: u32, |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
11 |
y: u32, |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
12 |
} |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
13 |
|
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
14 |
#[derive(Deserialize)] |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
15 |
pub struct RectDesc { |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
16 |
x: u32, |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
17 |
y: u32, |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
18 |
w: u32, |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
19 |
h: u32, |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
20 |
} |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
21 |
|
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
22 |
#[derive(Deserialize)] |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
23 |
pub struct TemplateDesc { |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
24 |
width: usize, |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
25 |
height: usize, |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
26 |
can_flip: bool, |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
27 |
can_invert: bool, |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
28 |
can_mirror: bool, |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
29 |
is_negative: bool, |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
30 |
put_girders: bool, |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
31 |
max_hedgehogs: u8, |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
32 |
outline_points: Vec<Vec<RectDesc>>, |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
33 |
fill_points: Vec<PointDesc>, |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
34 |
} |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
35 |
|
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
36 |
#[derive(Deserialize)] |
16058 | 37 |
pub struct TemplateTypeDesc { |
38 |
pub indices: Vec<usize>, |
|
39 |
pub force_invert: Option<bool>, |
|
40 |
} |
|
41 |
||
42 |
#[derive(Deserialize)] |
|
15952
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
43 |
pub struct TemplateCollectionDesc { |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
44 |
pub templates: Vec<TemplateDesc>, |
16058 | 45 |
pub template_types: HashMap<String, TemplateTypeDesc>, |
15952
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
46 |
} |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
47 |
|
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
48 |
impl From<&TemplateDesc> for OutlineTemplate { |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
49 |
fn from(desc: &TemplateDesc) -> Self { |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
50 |
OutlineTemplate { |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
51 |
islands: desc |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
52 |
.outline_points |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
53 |
.iter() |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
54 |
.map(|v| { |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
55 |
v.iter() |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
56 |
.map(|r| { |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
57 |
Rect::from_size( |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
58 |
Point::new(r.x as i32, r.y as i32), |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
59 |
Size::new(r.w as usize, r.h as usize), |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
60 |
) |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
61 |
}) |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
62 |
.collect() |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
63 |
}) |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
64 |
.collect(), |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
65 |
fill_points: desc |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
66 |
.fill_points |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
67 |
.iter() |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
68 |
.map(|p| Point::new(p.x as i32, p.y as i32)) |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
69 |
.collect(), |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
70 |
size: Size::new(desc.width, desc.height), |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
71 |
can_flip: desc.can_flip, |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
72 |
can_invert: desc.can_invert, |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
73 |
can_mirror: desc.can_mirror, |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
74 |
is_negative: desc.is_negative, |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
75 |
} |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
76 |
} |
da6b67f13c12
Refactor mapgen to allow for easy switching between generators
unC0Rr
parents:
diff
changeset
|
77 |
} |