macroquad_tiled/tiled/
layer.rs1use nanoserde::DeJson;
2
3use std::collections::HashMap;
4
5#[derive(Clone, Debug, Default, DeJson)]
7#[nserde(default)]
8pub struct Chunk {
9 pub data: Vec<u32>,
11 pub height: usize,
13 pub width: usize,
15 pub x: i32,
17 pub y: i32,
19}
20
21#[derive(Clone, Debug, Default, DeJson)]
22#[nserde(default)]
23pub struct Layer {
24 pub chunks: Option<Vec<Chunk>>,
26 pub name: String,
27 pub opacity: f32,
28 pub properties: Option<HashMap<String, String>>,
29 pub visible: bool,
30 pub width: u32,
31 pub height: u32,
32 #[nserde(rename = "type")]
33 pub ty: String,
34
35 pub data: Vec<u32>,
37
38 pub draworder: Option<String>,
40 #[nserde(default)]
41 pub objects: Vec<Object>,
42 pub offsetx: Option<i32>,
44 pub offsety: Option<i32>,
46 pub x: Option<f32>,
48 pub y: Option<f32>,
50
51 pub image: Option<String>,
53}
54
55#[derive(Clone, Debug, Default, DeJson)]
56#[nserde(default)]
57pub struct Property {
58 pub name: String,
59 #[nserde(rename = "type")]
60 pub ty: String,
61 pub value: String,
62}
63
64#[derive(Clone, Debug, Default, DeJson)]
65#[nserde(default)]
66pub struct Object {
67 pub id: u32,
68 pub name: String,
69
70 #[nserde(rename = "type")]
71 pub ty: String,
72 pub gid: Option<u32>,
73 pub ellipse: Option<bool>,
74 pub polygon: Option<Vec<PolyPoint>>,
75
76 pub properties: Vec<Property>,
77 pub rotation: f32,
78 pub visible: bool,
79
80 pub height: f32,
81 pub width: f32,
82
83 pub x: f32,
84 pub y: f32,
85}
86
87#[derive(Copy, Clone, Debug, DeJson)]
88pub struct PolyPoint {
89 pub x: f32,
90 pub y: f32,
91}