diff --git a/src/tile.rs b/src/tile.rs index 37b2a794..a93987cc 100644 --- a/src/tile.rs +++ b/src/tile.rs @@ -15,6 +15,7 @@ pub type TileId = u32; #[derive(Debug, PartialEq, Clone, Default)] pub struct Tile { + pub id: TileId, pub image: Option, pub properties: Properties, pub collision: Option, @@ -28,7 +29,7 @@ impl Tile { parser: &mut impl Iterator, attrs: Vec, path_relative_to: Option<&Path>, - ) -> Result<(TileId, Tile), TiledError> { + ) -> Result { let ((tile_type, probability), id) = get_attrs!( attrs, optionals: [ @@ -63,16 +64,14 @@ impl Tile { Ok(()) }, }); - Ok(( - id, - Tile { + Ok(Tile { + id, image, properties, collision: objectgroup, animation, tile_type, probability: probability.unwrap_or(1.0), - }, - )) + }) } } diff --git a/src/tileset.rs b/src/tileset.rs index 46c13e95..565516ee 100644 --- a/src/tileset.rs +++ b/src/tileset.rs @@ -251,8 +251,8 @@ impl Tileset { Ok(()) }, "tile" => |attrs| { - let (id, tile) = Tile::new(parser, attrs, prop.path_relative_to.as_ref().and_then(|p| Some(p.as_path())))?; - tiles.insert(id, tile); + let tile = Tile::new(parser, attrs, prop.path_relative_to.as_ref().and_then(|p| Some(p.as_path())))?; + tiles.insert(tile.id, tile); Ok(()) }, });