rust/mapgen/src/template/wavefront_collapse.rs
branchtransitional_engine
changeset 15954 9502611bffc1
parent 15953 d46ad15c6dec
child 15955 b0e8cc72bfef
equal deleted inserted replaced
15953:d46ad15c6dec 15954:9502611bffc1
     1 use integral_geometry::{Size};
     1 use integral_geometry::Size;
     2 
     2 
     3 use landgen::{wavefront_collapse::generator::*};
     3 use landgen::wavefront_collapse::generator::*;
     4 use serde_derive::Deserialize;
     4 use serde_derive::Deserialize;
     5 
     5 
     6 use std::{collections::hash_map::HashMap};
     6 use std::collections::hash_map::HashMap;
     7 
     7 
     8 #[derive(Deserialize)]
     8 #[derive(Deserialize)]
     9 #[serde(remote = "EdgeDescription")]
     9 #[serde(remote = "EdgeDescription")]
    10 pub struct EdgeDesc {
    10 pub struct EdgeDesc {
    11     pub name: String,
    11     pub name: String,
    30 #[serde(remote = "TileDescription")]
    30 #[serde(remote = "TileDescription")]
    31 pub struct TileDesc {
    31 pub struct TileDesc {
    32     pub name: String,
    32     pub name: String,
    33     #[serde(with = "EdgesDesc")]
    33     #[serde(with = "EdgesDesc")]
    34     pub edges: EdgesDescription,
    34     pub edges: EdgesDescription,
    35     pub is_negative: bool,
    35     pub is_negative: Option<bool>,
    36     pub can_flip: bool,
    36     pub can_flip: Option<bool>,
    37     pub can_mirror: bool,
    37     pub can_mirror: Option<bool>,
    38     pub can_rotate90: bool,
    38     pub can_rotate90: Option<bool>,
    39     pub can_rotate180: bool,
    39     pub can_rotate180: Option<bool>,
    40     pub can_rotate270: bool,
    40     pub can_rotate270: Option<bool>,
    41 }
    41 }
    42 
    42 
    43 #[derive(Deserialize)]
    43 #[derive(Deserialize)]
    44 pub struct TileDescriptionHelper(#[serde(with = "TileDesc")] TileDescription);
    44 pub struct TileDescriptionHelper(#[serde(with = "TileDesc")] TileDescription);
    45 
    45 
    49     pub height: usize,
    49     pub height: usize,
    50     pub can_invert: bool,
    50     pub can_invert: bool,
    51     pub is_negative: bool,
    51     pub is_negative: bool,
    52     pub put_girders: bool,
    52     pub put_girders: bool,
    53     pub max_hedgehogs: u8,
    53     pub max_hedgehogs: u8,
       
    54     pub wrap: bool,
    54     pub tiles: Vec<TileDescriptionHelper>,
    55     pub tiles: Vec<TileDescriptionHelper>,
    55 }
    56 }
    56 
    57 
    57 #[derive(Deserialize)]
    58 #[derive(Deserialize)]
    58 pub struct TemplateCollectionDesc {
    59 pub struct TemplateCollectionDesc {
    67             tiles: desc
    68             tiles: desc
    68                 .tiles
    69                 .tiles
    69                 .iter()
    70                 .iter()
    70                 .map(|TileDescriptionHelper(t)| t.clone())
    71                 .map(|TileDescriptionHelper(t)| t.clone())
    71                 .collect(),
    72                 .collect(),
       
    73             wrap: desc.wrap,
    72         }
    74         }
    73     }
    75     }
    74 }
    76 }