Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions doc/classes/TileMapLayer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,16 @@
If [param source_id] is set to [code]-1[/code], [param atlas_coords] to [code]Vector2i(-1, -1)[/code], or [param alternative_tile] to [code]-1[/code], the cell will be erased. An erased cell gets [b]all[/b] its identifiers automatically set to their respective invalid values, namely [code]-1[/code], [code]Vector2i(-1, -1)[/code] and [code]-1[/code].
</description>
</method>
<method name="set_cells">
<return type="void" />
<param index="0" name="cells" type="Vector2i[]" />
<param index="1" name="source_id" type="int" default="-1" />
<param index="2" name="atlas_coords" type="Vector2i" default="Vector2i(-1, -1)" />
<param index="3" name="alternative_tile" type="int" default="0" />
<description>
Sets the tile identifiers for all the cells inside the [param cells] array.
</description>
</method>
<method name="set_cells_terrain_connect">
<return type="void" />
<param index="0" name="cells" type="Vector2i[]" />
Expand Down
8 changes: 8 additions & 0 deletions scene/2d/tile_map_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1783,6 +1783,7 @@ void TileMapLayer::_bind_methods() {
// --- Cells manipulation ---
// Generic cells manipulations and access.
ClassDB::bind_method(D_METHOD("set_cell", "coords", "source_id", "atlas_coords", "alternative_tile"), &TileMapLayer::set_cell, DEFVAL(TileSet::INVALID_SOURCE), DEFVAL(TileSetSource::INVALID_ATLAS_COORDS), DEFVAL(0));
ClassDB::bind_method(D_METHOD("set_cells", "cells", "source_id", "atlas_coords", "alternative_tile"), &TileMapLayer::set_cells, DEFVAL(TileSet::INVALID_SOURCE), DEFVAL(TileSetSource::INVALID_ATLAS_COORDS), DEFVAL(0));
ClassDB::bind_method(D_METHOD("erase_cell", "coords"), &TileMapLayer::erase_cell);
ClassDB::bind_method(D_METHOD("fix_invalid_tiles"), &TileMapLayer::fix_invalid_tiles);
ClassDB::bind_method(D_METHOD("clear"), &TileMapLayer::clear);
Expand Down Expand Up @@ -2382,6 +2383,13 @@ void TileMapLayer::set_cell(const Vector2i &p_coords, int p_source_id, const Vec
used_rect_cache_dirty = true;
}

void TileMapLayer::set_cells(TypedArray<Vector2i> p_coords_array, int p_source_id, const Vector2i &p_atlas_coords, int p_alternative_tile) {
for (const Variant &variant : p_coords_array) {
const Vector2i &E = variant;
set_cell(E, p_source_id, p_atlas_coords, p_alternative_tile);
}
}

void TileMapLayer::erase_cell(const Vector2i &p_coords) {
set_cell(p_coords, TileSet::INVALID_SOURCE, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE);
}
Expand Down
1 change: 1 addition & 0 deletions scene/2d/tile_map_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ class TileMapLayer : public Node2D {
// --- Cells manipulation ---
// Generic cells manipulations and data access.
void set_cell(const Vector2i &p_coords, int p_source_id = TileSet::INVALID_SOURCE, const Vector2i &p_atlas_coords = TileSetSource::INVALID_ATLAS_COORDS, int p_alternative_tile = 0);
void set_cells(TypedArray<Vector2i> p_coords_array, int p_source_id = TileSet::INVALID_SOURCE, const Vector2i &p_atlas_coords = TileSetSource::INVALID_ATLAS_COORDS, int p_alternative_tile = 0);
void erase_cell(const Vector2i &p_coords);
void fix_invalid_tiles();
void clear();
Expand Down
Loading