more ID functions

This commit is contained in:
Max Bradbury 2020-06-23 17:01:21 +01:00
parent 62d4f12bc9
commit 0889710bdb
1 changed files with 17 additions and 0 deletions

View File

@ -350,11 +350,28 @@ impl ToString for Game {
}
impl Game {
// todo dedupe
#[inline]
pub fn tile_ids(&self) -> Vec<String> {
self.tiles.iter().map(|tile| tile.id.clone()).collect()
}
#[inline]
pub fn sprite_ids(&self) -> Vec<String> {
self.sprites.iter().map(|sprite| sprite.id.clone()).collect()
}
#[inline]
pub fn room_ids(&self) -> Vec<String> {
self.rooms.iter().map(|room| room.id.clone()).collect()
}
#[inline]
pub fn item_ids(&self) -> Vec<String> {
self.items.iter().map(|item| item.id.clone()).collect()
}
/// first available tile ID.
/// e.g. if current tile IDs are [0, 2, 3] the result will be `1`
/// if current tile IDs are [0, 1, 2] the result will be `3`