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 /// "0" will get overwritten to a new, safe tile ID
id: "0".to_string(), id: "0".to_string(),
name: tile_name(&prefix, &tile_index), name: tile_name(&prefix, &tile_index),
wall: None, wall: None,
animation_frames: vec![Image { pixels }], animation_frames: vec![Image { pixels }],
colour_id: None colour_id: None
}); };
tile_index += 1; if !game.tiles.contains(&tile) {
game.add_tile(tile);
tile_index += 1;
}
} }
} }
game.dedupe_tiles();
game.to_string() game.to_string()
} }