From 39ea81bea4a61baf8c95a33bcc979b0e65ce660e Mon Sep 17 00:00:00 2001 From: tom barrett Date: Fri, 28 Jun 2019 08:37:07 -0500 Subject: unified interfaces --- src/tileset.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/tileset.rs') diff --git a/src/tileset.rs b/src/tileset.rs index 548cde6..eb097e5 100644 --- a/src/tileset.rs +++ b/src/tileset.rs @@ -62,7 +62,7 @@ impl Tileset { *self.tiles.get(&id).unwrap() } - pub fn get_animations(&self, id: usize) -> Option> { + pub fn get_animation(&self, id: usize) -> Option> { if let Some(property) = self.properties.get(&id) { let entitys_properties: HashMap = self .properties @@ -81,7 +81,16 @@ impl Tileset { } } - pub fn get_property(&self, id: usize) -> Option<&Property> { - self.properties.get(&id) + pub fn get_rect_by_entity(&self, entity: &str) -> Rect { + *self + .tiles + .get( + self.properties + .iter() + .find(|(_, p)| p.entity == entity && 0 == p.keyframe) + .unwrap() + .0, + ) + .unwrap() } } -- cgit v1.2.3