add change_tile_ids() function
This commit is contained in:
parent
eef37898f7
commit
92ca2ea5c3
|
@ -456,9 +456,7 @@ impl Game {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
room.tiles = room.tiles.iter().map(|tile_id|
|
room.change_tile_ids(&tile_id_changes);
|
||||||
tile_id_changes.get(tile_id).unwrap_or(tile_id).clone()
|
|
||||||
).collect();
|
|
||||||
|
|
||||||
room.items = room.items.iter().map(|instance|
|
room.items = room.items.iter().map(|instance|
|
||||||
if item_id_changes.contains_key(&instance.id) {
|
if item_id_changes.contains_key(&instance.id) {
|
||||||
|
|
|
@ -2,6 +2,7 @@ use crate::{optional_data_line, Exit, ExitInstance, Instance, Position};
|
||||||
use crate::game::{RoomType, RoomFormat};
|
use crate::game::{RoomType, RoomFormat};
|
||||||
use crate::exit::Transition;
|
use crate::exit::Transition;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
pub struct Room {
|
pub struct Room {
|
||||||
|
@ -223,6 +224,14 @@ impl Room {
|
||||||
self.palette_line()
|
self.palette_line()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// "changes" is a hash of old -> new tile IDs
|
||||||
|
#[inline]
|
||||||
|
pub fn change_tile_ids(&mut self, changes: &HashMap<String, String>) {
|
||||||
|
self.tiles = self.tiles.iter().map(|tile_id|
|
||||||
|
changes.get(tile_id).unwrap_or(tile_id).clone()
|
||||||
|
).collect();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
Loading…
Reference in New Issue