1 use integral_geometry::{Point, Size}; |
1 use integral_geometry::{Point, Size}; |
2 use land2d; |
2 |
3 use landgen::{ |
3 use landgen::{ |
4 outline_template_based::{ |
4 wavefront_collapse::generator::{ |
5 outline_template::OutlineTemplate, template_based::TemplatedLandGenerator, |
5 TemplateDescription as WfcTemplate, |
6 }, |
6 }, |
7 LandGenerationParameters, LandGenerator, |
7 LandGenerationParameters, LandGenerator, |
8 }; |
8 }; |
9 use lfprng::LaggedFibonacciPRNG; |
9 use lfprng::LaggedFibonacciPRNG; |
10 use mapgen::{theme::Theme, MapGenerator}; |
10 use mapgen::{theme::Theme, MapGenerator}; |
60 let template_type: &str = unsafe { CStr::from_ptr(template_type) }.to_str().unwrap(); |
60 let template_type: &str = unsafe { CStr::from_ptr(template_type) }.to_str().unwrap(); |
61 |
61 |
62 let mut random_numbers_gen = LaggedFibonacciPRNG::new(seed.as_bytes()); |
62 let mut random_numbers_gen = LaggedFibonacciPRNG::new(seed.as_bytes()); |
63 |
63 |
64 let yaml_templates = |
64 let yaml_templates = |
65 fs::read_to_string(data_path.join(Path::new("map_templates.yaml")).as_path()) |
65 fs::read_to_string(data_path.join(Path::new("wfc_templates.yaml")).as_path()) |
66 .expect("Error reading map templates file"); |
66 .expect("Error reading map templates file"); |
67 let mut map_gen = MapGenerator::<OutlineTemplate>::new(); |
67 let mut map_gen = MapGenerator::<WfcTemplate>::new(); |
68 map_gen.import_yaml_templates(&yaml_templates); |
68 map_gen.import_yaml_templates(&yaml_templates); |
69 |
69 |
70 let distance_divisor = feature_size.pow(2) / 8 + 10; |
70 let distance_divisor = feature_size.pow(2) / 8 + 10; |
71 let params = LandGenerationParameters::new(0u16, 0x8000u16, distance_divisor, false, false); |
71 let params = LandGenerationParameters::new(0u16, 0x8000u16, distance_divisor, false, false); |
72 let template = map_gen |
72 let template = map_gen |
73 .get_template(template_type, &mut random_numbers_gen) |
73 .get_template(template_type, &mut random_numbers_gen) |
74 .expect("Error reading map templates file") |
74 .expect("Error reading templates file") |
75 .clone(); |
75 .clone(); |
76 let landgen = TemplatedLandGenerator::new(template); |
76 let landgen = map_gen.build_generator(template); |
77 let collision = landgen.generate_land(¶ms, &mut random_numbers_gen); |
77 let collision = landgen.generate_land(¶ms, &mut random_numbers_gen); |
78 let size = collision.size().size(); |
78 let size = collision.size().size(); |
79 |
79 |
80 let game_field = Box::new(GameField { |
80 let game_field = Box::new(GameField { |
81 collision, |
81 collision, |