don't add duplicate tiles

This commit is contained in:
Max Bradbury 2020-07-19 12:11:09 +01:00
parent 369ad6aaf1
commit 366914e4bb
1 changed files with 7 additions and 4 deletions

View File

@ -57,20 +57,23 @@ pub fn add_tiles(game_data: String, image: String, prefix: String) -> String {
}
}
game.add_tile(Tile {
let tile = Tile {
/// "0" will get overwritten to a new, safe tile ID
id: "0".to_string(),
name: tile_name(&prefix, &tile_index),
wall: None,
animation_frames: vec![Image { pixels }],
colour_id: None
});
};
if !game.tiles.contains(&tile) {
game.add_tile(tile);
tile_index += 1;
}
}
}
game.dedupe_tiles();
game.to_string()
}