Skip to content

Commit

Permalink
Merge pull request #58659 from IgorKordiukiewicz/set_tile_alternative…
Browse files Browse the repository at this point in the history
…_tile_default_param
  • Loading branch information
akien-mga authored Mar 2, 2022
2 parents 2d210fe + 8f49150 commit e6f00a0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
10 changes: 9 additions & 1 deletion doc/classes/TileMap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@
Clears all cells on the given layer.
</description>
</method>
<method name="erase_cell">
<return type="void" />
<argument index="0" name="layer" type="int" />
<argument index="1" name="coords" type="Vector2i" />
<description>
Erases the cell on layer [code]layer[/code] at coordinates [code]coords[/code].
</description>
</method>
<method name="fix_invalid_tiles">
<return type="void" />
<description>
Expand Down Expand Up @@ -227,7 +235,7 @@
<argument index="1" name="coords" type="Vector2i" />
<argument index="2" name="source_id" type="int" default="-1" />
<argument index="3" name="atlas_coords" type="Vector2i" default="Vector2i(-1, -1)" />
<argument index="4" name="alternative_tile" type="int" default="-1" />
<argument index="4" name="alternative_tile" type="int" default="0" />
<description>
Sets the tile indentifiers for the cell on layer [code]layer[/code] at coordinates [code]coords[/code]. Each tile of the [TileSet] is identified using three parts:
- The source identifier [code]source_id[/code] identifies a [TileSetSource] identifier. See [method TileSet.set_source_id],
Expand Down
7 changes: 6 additions & 1 deletion scene/2d/tile_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1997,6 +1997,10 @@ void TileMap::set_cell(int p_layer, const Vector2i &p_coords, int p_source_id, c
}
}

void TileMap::erase_cell(int p_layer, const Vector2i &p_coords) {
set_cell(p_layer, p_coords, TileSet::INVALID_SOURCE, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE);
}

int TileMap::get_cell_source_id(int p_layer, const Vector2i &p_coords, bool p_use_proxies) const {
ERR_FAIL_INDEX_V(p_layer, (int)layers.size(), TileSet::INVALID_SOURCE);

Expand Down Expand Up @@ -3622,7 +3626,8 @@ void TileMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_navigation_visibility_mode", "navigation_visibility_mode"), &TileMap::set_navigation_visibility_mode);
ClassDB::bind_method(D_METHOD("get_navigation_visibility_mode"), &TileMap::get_navigation_visibility_mode);

ClassDB::bind_method(D_METHOD("set_cell", "layer", "coords", "source_id", "atlas_coords", "alternative_tile"), &TileMap::set_cell, DEFVAL(TileSet::INVALID_SOURCE), DEFVAL(TileSetSource::INVALID_ATLAS_COORDS), DEFVAL(TileSetSource::INVALID_TILE_ALTERNATIVE));
ClassDB::bind_method(D_METHOD("set_cell", "layer", "coords", "source_id", "atlas_coords", "alternative_tile"), &TileMap::set_cell, DEFVAL(TileSet::INVALID_SOURCE), DEFVAL(TileSetSource::INVALID_ATLAS_COORDS), DEFVAL(0));
ClassDB::bind_method(D_METHOD("erase_cell", "layer", "coords"), &TileMap::erase_cell);
ClassDB::bind_method(D_METHOD("get_cell_source_id", "layer", "coords", "use_proxies"), &TileMap::get_cell_source_id);
ClassDB::bind_method(D_METHOD("get_cell_atlas_coords", "layer", "coords", "use_proxies"), &TileMap::get_cell_atlas_coords);
ClassDB::bind_method(D_METHOD("get_cell_alternative_tile", "layer", "coords", "use_proxies"), &TileMap::get_cell_alternative_tile);
Expand Down
3 changes: 2 additions & 1 deletion scene/2d/tile_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ class TileMap : public Node2D {
VisibilityMode get_navigation_visibility_mode();

// Cells accessors.
void set_cell(int p_layer, const Vector2i &p_coords, int p_source_id = -1, const Vector2i p_atlas_coords = TileSetSource::INVALID_ATLAS_COORDS, int p_alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE);
void set_cell(int p_layer, const Vector2i &p_coords, int p_source_id = -1, const Vector2i p_atlas_coords = TileSetSource::INVALID_ATLAS_COORDS, int p_alternative_tile = 0);
void erase_cell(int p_layer, const Vector2i &p_coords);
int get_cell_source_id(int p_layer, const Vector2i &p_coords, bool p_use_proxies = false) const;
Vector2i get_cell_atlas_coords(int p_layer, const Vector2i &p_coords, bool p_use_proxies = false) const;
int get_cell_alternative_tile(int p_layer, const Vector2i &p_coords, bool p_use_proxies = false) const;
Expand Down

0 comments on commit e6f00a0

Please sign in to comment.