Merge pull request #71615 from groud/bring_back_get_cells_by_id
Bring back TileMap::get_cells_by_id
This commit is contained in:
commit
da1b78222c
3 changed files with 32 additions and 2 deletions
|
|
@ -3736,6 +3736,22 @@ TypedArray<Vector2i> TileMap::get_used_cells(int p_layer) const {
|
|||
return a;
|
||||
}
|
||||
|
||||
TypedArray<Vector2i> TileMap::get_used_cells_by_id(int p_layer, int p_source_id, const Vector2i p_atlas_coords, int p_alternative_tile) const {
|
||||
ERR_FAIL_INDEX_V(p_layer, (int)layers.size(), TypedArray<Vector2i>());
|
||||
|
||||
// Returns the cells used in the tilemap.
|
||||
TypedArray<Vector2i> a;
|
||||
for (const KeyValue<Vector2i, TileMapCell> &E : layers[p_layer].tile_map) {
|
||||
if ((p_source_id == TileSet::INVALID_SOURCE || p_source_id == E.value.source_id) &&
|
||||
(p_atlas_coords == TileSetSource::INVALID_ATLAS_COORDS || p_atlas_coords == E.value.get_atlas_coords()) &&
|
||||
(p_alternative_tile == TileSetSource::INVALID_TILE_ALTERNATIVE || p_alternative_tile == E.value.alternative_tile)) {
|
||||
a.push_back(E.key);
|
||||
}
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
Rect2i TileMap::get_used_rect() { // Not const because of cache
|
||||
// Return the rect of the currently used area
|
||||
if (used_rect_cache_dirty) {
|
||||
|
|
@ -4028,6 +4044,7 @@ void TileMap::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("get_surrounding_cells", "coords"), &TileMap::get_surrounding_cells);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_used_cells", "layer"), &TileMap::get_used_cells);
|
||||
ClassDB::bind_method(D_METHOD("get_used_cells_by_id", "layer", "source_id", "atlas_coords", "alternative_tile"), &TileMap::get_used_cells_by_id, DEFVAL(TileSet::INVALID_SOURCE), DEFVAL(TileSetSource::INVALID_ATLAS_COORDS), DEFVAL(TileSetSource::INVALID_TILE_ALTERNATIVE));
|
||||
ClassDB::bind_method(D_METHOD("get_used_rect"), &TileMap::get_used_rect);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("map_to_local", "map_position"), &TileMap::map_to_local);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue