more ID functions
This commit is contained in:
parent
62d4f12bc9
commit
0889710bdb
17
src/game.rs
17
src/game.rs
|
@ -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`
|
||||
|
|
Loading…
Reference in New Issue