Merge pull request #10040 from Hassan-A/getCells3.0

Added get_used_cells_by_id method 3.0
This commit is contained in:
Rémi Verschelde 2017-08-03 10:33:49 +02:00 committed by GitHub
commit 0257ced05b
2 changed files with 16 additions and 0 deletions

View File

@ -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));

View File

@ -270,6 +270,7 @@ public:
bool is_y_sort_mode_enabled() const;
Array get_used_cells() const;
Array get_used_cells_by_id(int p_id) const;
Rect2 get_used_rect(); // Not const because of cache
void set_occluder_light_mask(int p_mask);