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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
use bevy::ecs::bundle::Bundle;
use super::map::{
TilePivot, TileRenderSize, TilemapAnimations, TilemapAxisFlip, TilemapLayerOpacities,
TilemapName, TilemapSlotSize, TilemapStorage, TilemapTexture, TilemapTransform, TilemapType,
};
/// The bundle of the tilemap with no actual tiles.
#[derive(Bundle, Default, Debug, Clone)]
pub struct DataTilemapBundle {
/// The name of the tilemap. This can be used in saving the tilemap.
pub name: TilemapName,
/// The render size of tiles in pixels.
pub tile_render_size: TileRenderSize,
/// The size of each slot in pixels. This can be different from the render size.
/// And you can create margins and paddings.
pub slot_size: TilemapSlotSize,
/// The type of the tilemap.
pub ty: TilemapType,
/// The pivot of the tiles.
pub tile_pivot: TilePivot,
/// The axes for the tilemap.
pub axis_direction: TilemapAxisFlip,
}
impl Into<TilemapBundle> for DataTilemapBundle {
fn into(self) -> TilemapBundle {
TilemapBundle {
name: self.name,
tile_render_size: self.tile_render_size,
slot_size: self.slot_size,
ty: self.ty,
tile_pivot: self.tile_pivot,
..Default::default()
}
}
}
/// The bundle of the tilemap with a texture.
#[derive(Bundle, Default, Debug, Clone)]
pub struct TilemapBundle {
/// The name of the tilemap. This can be used in saving the tilemap.
pub name: TilemapName,
/// The render size of tiles in pixels.
pub tile_render_size: TileRenderSize,
/// The size of each slot in pixels. This can be different from the render size.
/// And you can create margins and paddings.
pub slot_size: TilemapSlotSize,
/// The type of the tilemap.
pub ty: TilemapType,
/// The pivot of the tiles.
pub tile_pivot: TilePivot,
/// The opacities of each **rendered** layer.
///
/// Only the top 4 layers will be rendered.
pub layer_opacities: TilemapLayerOpacities,
/// The storage of the tilemap. The entities of each tiles are divided into chunks and stored in it.
///
/// You need to spawn an empty tilemap and assign it to the storage.
pub storage: TilemapStorage,
/// The transform of the tilemap. It's not the same one as `Transform`.
/// If you want to move or rotate the tilemap, you need to change this.
pub transform: TilemapTransform,
/// The axes for the tilemap.
pub axis_flip: TilemapAxisFlip,
/// The texture of the tilemap.
pub texture: TilemapTexture,
/// All the animation sequences of the tilemap.
pub animations: TilemapAnimations,
}
impl Into<DataTilemapBundle> for TilemapBundle {
fn into(self) -> DataTilemapBundle {
DataTilemapBundle {
name: self.name,
tile_render_size: self.tile_render_size,
slot_size: self.slot_size,
ty: self.ty,
tile_pivot: self.tile_pivot,
..Default::default()
}
}
}
impl Into<PureColorTilemapBundle> for TilemapBundle {
fn into(self) -> PureColorTilemapBundle {
PureColorTilemapBundle {
name: self.name,
tile_render_size: self.tile_render_size,
slot_size: self.slot_size,
ty: self.ty,
tile_pivot: self.tile_pivot,
layer_opacities: self.layer_opacities,
storage: self.storage,
transform: self.transform,
axis_flip: self.axis_flip,
}
}
}
/// The bundle of the tilemap without a texture. This can be cheaper.
#[derive(Bundle, Default, Debug, Clone)]
pub struct PureColorTilemapBundle {
/// The name of the tilemap. This can be used in saving the tilemap.
pub name: TilemapName,
/// The render size of tiles in pixels.
pub tile_render_size: TileRenderSize,
/// The size of each slot in pixels. This can be different from the render size.
/// And you can create margins and paddings.
pub slot_size: TilemapSlotSize,
/// The type of the tilemap.
pub ty: TilemapType,
/// The pivot of the tiles.
pub tile_pivot: TilePivot,
/// The opacities of each **rendered** layer.
///
/// Only the top 4 layers will be rendered.
pub layer_opacities: TilemapLayerOpacities,
/// The storage of the tilemap. The entities of each tiles are divided into chunks and stored in it.
///
/// You need to spawn an empty tilemap and assign it to the storage.
pub storage: TilemapStorage,
/// The transform of the tilemap. It's not the same one as `Transform`.
/// If you want to move or rotate the tilemap, you need to change this.
pub transform: TilemapTransform,
/// The axes for the tilemap.
pub axis_flip: TilemapAxisFlip,
}