rust/mapgen/src/template/maze.rs
branchtransitional_engine
changeset 16035 0caa3dfb3ba2
equal deleted inserted replaced
16034:09beeec033ba 16035:0caa3dfb3ba2
       
     1 use landgen::maze::MazeTemplate;
       
     2 use serde_derive::Deserialize;
       
     3 
       
     4 use std::collections::hash_map::HashMap;
       
     5 #[derive(Deserialize)]
       
     6 pub struct TemplateDesc {
       
     7     width: usize,
       
     8     height: usize,
       
     9     max_hedgehogs: u8,
       
    10     cell_size: usize,
       
    11     distortion_limiting_factor: u32,
       
    12     braidness: u32,
       
    13     invert: bool,
       
    14 }
       
    15 
       
    16 #[derive(Deserialize)]
       
    17 pub struct TemplateCollectionDesc {
       
    18     pub templates: Vec<TemplateDesc>,
       
    19     pub template_types: HashMap<String, Vec<usize>>,
       
    20 }
       
    21 
       
    22 impl From<&TemplateDesc> for MazeTemplate {
       
    23     fn from(desc: &TemplateDesc) -> Self {
       
    24         MazeTemplate {
       
    25             width: desc.width,
       
    26             height: desc.height,
       
    27             cell_size: desc.cell_size,
       
    28             inverted: desc.invert,
       
    29             distortion_limiting_factor: desc.distortion_limiting_factor,
       
    30             braidness: desc.braidness,
       
    31         }
       
    32     }
       
    33 }