Skip to content

Commit 1e345d1

Browse files
authored
Merge pull request #518 from StarArawn/add-more-serde-support
Added more serde support
2 parents b75d4b1 + 78aa6cc commit 1e345d1

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

src/map/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ impl Default for TilemapRenderSettings {
4444
/// A component which stores a reference to the tilemap entity.
4545
#[derive(Component, Reflect, Clone, Copy, Debug, Hash)]
4646
#[reflect(Component, MapEntities)]
47+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4748
pub struct TilemapId(pub Entity);
4849

4950
impl MapEntities for TilemapId {

src/render/extract.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
use bevy::math::Affine3A;
2-
use bevy::prelude::Res;
3-
use bevy::prelude::Time;
42
use bevy::render::primitives::{Aabb, Frustum};
53
use bevy::render::render_resource::FilterMode;
64
use bevy::render::render_resource::TextureFormat;
7-
use bevy::{math::Vec4, prelude::*, render::Extract, utils::HashMap};
5+
use bevy::{prelude::*, render::Extract, utils::HashMap};
86

97
use crate::prelude::TilemapGridSize;
108
use crate::prelude::TilemapRenderSettings;

src/tiles/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,14 @@ impl From<&TilePos> for Vec2 {
6767

6868
/// A texture index into the atlas or texture array for a single tile. Indices in an atlas are horizontal based.
6969
#[derive(Component, Reflect, Default, Clone, Copy, Debug, Hash)]
70+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7071
#[reflect(Component)]
7172
pub struct TileTextureIndex(pub u32);
7273

7374
/// A custom color for the tile.
7475
#[derive(Component, Reflect, Default, Clone, Copy, Debug)]
7576
#[reflect(Component)]
77+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7678
pub struct TileColor(pub Color);
7779

7880
impl From<Color> for TileColor {
@@ -84,6 +86,7 @@ impl From<Color> for TileColor {
8486
/// Hides or shows a tile based on the boolean. Default: True
8587
#[derive(Component, Reflect, Clone, Copy, Debug, Hash)]
8688
#[reflect(Component)]
89+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
8790
pub struct TileVisible(pub bool);
8891

8992
impl Default for TileVisible {
@@ -95,6 +98,7 @@ impl Default for TileVisible {
9598
/// Flips the tiles texture along the X, Y or diagonal axes
9699
#[derive(Component, Reflect, Default, Clone, Copy, Debug, Hash)]
97100
#[reflect(Component)]
101+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
98102
pub struct TileFlip {
99103
/// Flip tile along the x axis.
100104
pub x: bool,
@@ -105,6 +109,7 @@ pub struct TileFlip {
105109

106110
/// This an optional tile bundle with default components.
107111
#[derive(Bundle, Default, Clone, Copy, Debug)]
112+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
108113
pub struct TileBundle {
109114
pub position: TilePos,
110115
pub texture_index: TileTextureIndex,
@@ -117,12 +122,14 @@ pub struct TileBundle {
117122

118123
#[derive(Component, Reflect, Default, Clone, Copy, Debug)]
119124
#[reflect(Component)]
125+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
120126
pub struct TilePosOld(pub TilePos);
121127

122128
/// A component that is attached to a Tile entity that
123129
/// tells the GPU how to animate the tile.
124130
/// Currently all frames must be aligned in your tilemap.
125131
#[derive(Component, Reflect, Clone, Copy, Debug)]
132+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
126133
pub struct AnimatedTile {
127134
/// The start frame index in the tilemap atlas/array (inclusive).
128135
pub start: u32,

0 commit comments

Comments
 (0)