106 fs::read_to_string(data_path.join(Path::new("wfc_templates.yaml")).as_path()) |
106 fs::read_to_string(data_path.join(Path::new("wfc_templates.yaml")).as_path()) |
107 .expect("Error reading map templates file"); |
107 .expect("Error reading map templates file"); |
108 let mut map_gen = MapGenerator::<WfcTemplate>::new(data_path); |
108 let mut map_gen = MapGenerator::<WfcTemplate>::new(data_path); |
109 map_gen.import_yaml_templates(&yaml_templates); |
109 map_gen.import_yaml_templates(&yaml_templates); |
110 |
110 |
111 let params = LandGenerationParameters::new(0u16, 0x8000u16, feature_size, false, false); |
|
112 let template = map_gen |
111 let template = map_gen |
113 .get_template(template_type, &mut random_numbers_gen) |
112 .get_template(template_type, &mut random_numbers_gen) |
114 .expect("Error reading wfc templates file") |
113 .expect("Error reading wfc templates file") |
115 .clone(); |
114 .clone(); |
|
115 let (zero, basic) = |
|
116 if template.is_negative || (template.can_invert && random_numbers_gen.get_random(2) == 0) { |
|
117 (0x8000u16, 0u16) |
|
118 } else { |
|
119 (0u16, 0x8000u16) |
|
120 }; |
|
121 let params = LandGenerationParameters::new(zero, basic, feature_size, false, false); |
116 let landgen = map_gen.build_generator(template); |
122 let landgen = map_gen.build_generator(template); |
117 let collision = landgen.generate_land(¶ms, &mut random_numbers_gen); |
123 let collision = landgen.generate_land(¶ms, &mut random_numbers_gen); |
118 let size = collision.size().size(); |
124 let size = collision.size().size(); |
119 |
125 |
120 let game_field = Box::new(GameField { |
126 let game_field = Box::new(GameField { |