diff options
author | Hassan A <halazawi@myseneca.ca> | 2017-08-02 06:40:32 -0400 |
---|---|---|
committer | Hassan A <halazawi@myseneca.ca> | 2017-08-02 18:02:00 -0400 |
commit | 74587a49275ab90c25a2b5d83c14c8bdcaa26612 (patch) | |
tree | 6767dc06775d4dc3639e7dc3919caad5a344dad4 /scene/2d/tile_map.cpp | |
parent | 8bd792d7bb14aad05b55ee4f57bd6b65a0b434a3 (diff) | |
download | redot-engine-74587a49275ab90c25a2b5d83c14c8bdcaa26612.tar.gz |
Added get_used_cells_by_id method 3.0
Diffstat (limited to 'scene/2d/tile_map.cpp')
-rw-r--r-- | scene/2d/tile_map.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 9d70b75027..02dcc7d059 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -1144,6 +1144,20 @@ Array TileMap::get_used_cells() const { return a; } +Array TileMap::get_used_cells_by_id(int p_id) const { + + Array a; + for (Map<PosKey, Cell>::Element *E = tile_map.front(); E; E = E->next()) { + + if (E->value().id == p_id) { + Vector2 p(E->key().x, E->key().y); + a.push_back(p); + } + } + + return a; +} + Rect2 TileMap::get_used_rect() { // Not const because of cache if (used_size_cache_dirty) { @@ -1262,6 +1276,7 @@ void TileMap::_bind_methods() { ClassDB::bind_method(D_METHOD("clear"), &TileMap::clear); ClassDB::bind_method(D_METHOD("get_used_cells"), &TileMap::get_used_cells); + ClassDB::bind_method(D_METHOD("get_used_cells_by_id", "id"), &TileMap::get_used_cells_by_id); ClassDB::bind_method(D_METHOD("get_used_rect"), &TileMap::get_used_rect); ClassDB::bind_method(D_METHOD("map_to_world", "mappos", "ignore_half_ofs"), &TileMap::map_to_world, DEFVAL(false)); |