From 049fb5b86fd2316a125ed6e3d723c933055e8a46 Mon Sep 17 00:00:00 2001 From: William Cahill Date: Sat, 19 Feb 2022 23:06:36 -0500 Subject: [PATCH] Adding tile id to tile --- src/tile.rs | 11 +++++------ src/tileset.rs | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) 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(()) }, });