diff options
| author | Poommetee Ketson | 2018-02-24 12:56:48 +0700 |
|---|---|---|
| committer | Poommetee Ketson | 2018-02-24 19:34:41 +0700 |
| commit | 7effe46461090861cae417f30db29e4c14a83db2 (patch) | |
| tree | 5294fc65f718ca8f6753918ddf2c189d0b336083 /scene/2d/tile_map.cpp | |
| parent | bd3b958a2545c3f4dd4afa2e69b690a3c6aa78fc (diff) | |
| download | godot-7effe46461090861cae417f30db29e4c14a83db2.tar.gz godot-7effe46461090861cae417f30db29e4c14a83db2.tar.zst godot-7effe46461090861cae417f30db29e4c14a83db2.zip | |
Diffstat (limited to 'scene/2d/tile_map.cpp')
| -rw-r--r-- | scene/2d/tile_map.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 2aa55e282..5f11804dd 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -830,6 +830,16 @@ void TileMap::update_dirty_bitmask() { } } +void TileMap::fix_invalid_tiles() { + + for (Map<PosKey, Cell>::Element *E = tile_map.front(); E; E = E->next()) { + + if (!tile_set->has_tile(get_cell(E->key().x, E->key().y))) { + set_cell(E->key().x, E->key().y, INVALID_CELL); + } + } +} + int TileMap::get_cell(int p_x, int p_y) const { PosKey pk(p_x, p_y); @@ -1515,6 +1525,7 @@ void TileMap::_bind_methods() { ClassDB::bind_method(D_METHOD("is_cell_y_flipped", "x", "y"), &TileMap::is_cell_y_flipped); ClassDB::bind_method(D_METHOD("is_cell_transposed", "x", "y"), &TileMap::is_cell_transposed); + ClassDB::bind_method(D_METHOD("fix_invalid_tiles"), &TileMap::fix_invalid_tiles); ClassDB::bind_method(D_METHOD("clear"), &TileMap::clear); ClassDB::bind_method(D_METHOD("get_used_cells"), &TileMap::get_used_cells); |
