summaryrefslogtreecommitdiff
path: root/src/tileset.rs
diff options
context:
space:
mode:
authortom barrett <spalf0@gmail.com>2019-06-28 08:37:07 -0500
committertom barrett <spalf0@gmail.com>2019-06-28 08:37:07 -0500
commit39ea81bea4a61baf8c95a33bcc979b0e65ce660e (patch)
treee1a535ba04c72c3db630548966ba854388f7848f /src/tileset.rs
parenta76efb8444af9d4a0ee558e72903c67bc2cff5d3 (diff)
unified interfaces
Diffstat (limited to 'src/tileset.rs')
-rw-r--r--src/tileset.rs15
1 files changed, 12 insertions, 3 deletions
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<Vec<(usize, Rect)>> {
+ pub fn get_animation(&self, id: usize) -> Option<Vec<(usize, Rect)>> {
if let Some(property) = self.properties.get(&id) {
let entitys_properties: HashMap<usize, Property> = 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()
}
}