1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
use serde::Deserialize;
mod layer;
mod map;
mod object;
mod tile_set;
mod utils;
mod wangs;
pub use layer::*;
pub use map::*;
pub use object::*;
pub use tile_set::*;
pub use utils::*;
pub use wangs::*;
mod parsers;
use parsers::parse_color;
#[derive(Deserialize, Debug, PartialEq, Clone)]
#[serde(rename_all(deserialize = "lowercase"), tag = "type", content = "value")]
pub enum TiledValue {
Bool(bool),
Float(f32),
Int(u32),
#[serde(deserialize_with = "parse_color")]
Color(Color),
String(String),
File(String),
}
#[derive(Deserialize, Debug, PartialEq, Clone)]
pub struct Vec2<T> {
pub x: T,
pub y: T,
}
#[derive(Debug, Default, PartialEq, Clone)]
pub struct Color(pub u32, pub u32, pub u32, pub u32);
impl Color {
pub fn r(&self) -> u32 {
self.0
}
pub fn g(&self) -> u32 {
self.1
}
pub fn b(&self) -> u32 {
self.2
}
pub fn a(&self) -> u32 {
self.3
}
}
#[derive(Debug, Default, PartialEq, Clone)]
pub struct TileRect {
pub x: i32,
pub y: i32,
pub width: u32,
pub height: u32,
}