equal
deleted
inserted
replaced
12 outline_template::OutlineTemplate, template_based::TemplatedLandGenerator, |
12 outline_template::OutlineTemplate, template_based::TemplatedLandGenerator, |
13 }, |
13 }, |
14 wavefront_collapse::generator::{ |
14 wavefront_collapse::generator::{ |
15 TemplateDescription as WfcTemplate, WavefrontCollapseLandGenerator, |
15 TemplateDescription as WfcTemplate, WavefrontCollapseLandGenerator, |
16 }, |
16 }, |
|
17 maze::{MazeTemplate, MazeLandGenerator}, |
17 LandGenerationParameters, LandGenerator, |
18 LandGenerationParameters, LandGenerator, |
18 }; |
19 }; |
19 use rand::{seq::SliceRandom, Rng}; |
20 use rand::{seq::SliceRandom, Rng}; |
20 |
21 |
21 use std::{borrow::Borrow, collections::hash_map::HashMap}; |
22 use std::{borrow::Borrow, collections::hash_map::HashMap}; |
171 .collect(); |
172 .collect(); |
172 } |
173 } |
173 |
174 |
174 pub fn build_generator(&self, template: WfcTemplate) -> impl LandGenerator { |
175 pub fn build_generator(&self, template: WfcTemplate) -> impl LandGenerator { |
175 WavefrontCollapseLandGenerator::new(template, &self.data_path) |
176 WavefrontCollapseLandGenerator::new(template, &self.data_path) |
|
177 } |
|
178 } |
|
179 |
|
180 impl MapGenerator<MazeTemplate> { |
|
181 pub fn import_yaml_templates(&mut self, text: &str) { |
|
182 let mut desc: MazeTemplateCollectionDesc = serde_yaml::from_str(text).unwrap(); |
|
183 let templates = std::mem::take(&mut desc.templates); |
|
184 self.templates = desc |
|
185 .template_types |
|
186 .into_iter() |
|
187 .map(|(size, indices)| { |
|
188 ( |
|
189 TemplateType(size), |
|
190 indices.iter().map(|i| (&templates[*i]).into()).collect(), |
|
191 ) |
|
192 }) |
|
193 .collect(); |
|
194 } |
|
195 |
|
196 pub fn build_generator(&self, template: MazeTemplate) -> impl LandGenerator { |
|
197 MazeLandGenerator::new(template) |
176 } |
198 } |
177 } |
199 } |
178 |
200 |
179 #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
201 #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
180 struct Color(u32); |
202 struct Color(u32); |