From 0889710bdb253e04c63423d33a7be7ea237208be Mon Sep 17 00:00:00 2001 From: Max Bradbury Date: Tue, 23 Jun 2020 17:01:21 +0100 Subject: [PATCH] more ID functions --- src/game.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/game.rs b/src/game.rs index 811484c..f7f6785 100644 --- a/src/game.rs +++ b/src/game.rs @@ -350,11 +350,28 @@ impl ToString for Game { } impl Game { + // todo dedupe + #[inline] pub fn tile_ids(&self) -> Vec { self.tiles.iter().map(|tile| tile.id.clone()).collect() } + #[inline] + pub fn sprite_ids(&self) -> Vec { + self.sprites.iter().map(|sprite| sprite.id.clone()).collect() + } + + #[inline] + pub fn room_ids(&self) -> Vec { + self.rooms.iter().map(|room| room.id.clone()).collect() + } + + #[inline] + pub fn item_ids(&self) -> Vec { + 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`