Skip to content

Commit

Permalink
Merge pull request #56284 from Rubonnek/expose-autotile-coord-3x
Browse files Browse the repository at this point in the history
[3.x] Expose autotile_coord parameter in `TileMap.set_cellv`
  • Loading branch information
akien-mga authored Jan 6, 2022
2 parents ec64c6b + 4106f95 commit 3cc7c4a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion doc/classes/TileMap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,11 @@
<argument index="2" name="flip_x" type="bool" default="false" />
<argument index="3" name="flip_y" type="bool" default="false" />
<argument index="4" name="transpose" type="bool" default="false" />
<argument index="5" name="autotile_coord" type="Vector2" default="Vector2( 0, 0 )" />
<description>
Sets the tile index for the cell given by a Vector2.
An index of [code]-1[/code] clears the cell.
Optionally, the tile can also be flipped or transposed.
Optionally, the tile can also be flipped, transposed, or given autotile coordinates. The autotile coordinate refers to the column and row of the subtile.
[b]Note:[/b] Data such as navigation polygons and collision shapes are not immediately updated for performance reasons.
If you need these to be immediately updated, you can call [method update_dirty_quadrants].
</description>
Expand Down
6 changes: 3 additions & 3 deletions scene/2d/tile_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -852,8 +852,8 @@ void TileMap::_make_quadrant_dirty(Map<PosKey, Quadrant>::Element *Q, bool updat
}
}

void TileMap::set_cellv(const Vector2 &p_pos, int p_tile, bool p_flip_x, bool p_flip_y, bool p_transpose) {
set_cell(p_pos.x, p_pos.y, p_tile, p_flip_x, p_flip_y, p_transpose);
void TileMap::set_cellv(const Vector2 &p_pos, int p_tile, bool p_flip_x, bool p_flip_y, bool p_transpose, Vector2 p_autotile_coord) {
set_cell(p_pos.x, p_pos.y, p_tile, p_flip_x, p_flip_y, p_transpose, p_autotile_coord);
}

void TileMap::_set_celld(const Vector2 &p_pos, const Dictionary &p_data) {
Expand Down Expand Up @@ -1815,7 +1815,7 @@ void TileMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_occluder_light_mask"), &TileMap::get_occluder_light_mask);

ClassDB::bind_method(D_METHOD("set_cell", "x", "y", "tile", "flip_x", "flip_y", "transpose", "autotile_coord"), &TileMap::set_cell, DEFVAL(false), DEFVAL(false), DEFVAL(false), DEFVAL(Vector2()));
ClassDB::bind_method(D_METHOD("set_cellv", "position", "tile", "flip_x", "flip_y", "transpose"), &TileMap::set_cellv, DEFVAL(false), DEFVAL(false), DEFVAL(false));
ClassDB::bind_method(D_METHOD("set_cellv", "position", "tile", "flip_x", "flip_y", "transpose", "autotile_coord"), &TileMap::set_cellv, DEFVAL(false), DEFVAL(false), DEFVAL(false), DEFVAL(Vector2()));
ClassDB::bind_method(D_METHOD("_set_celld", "position", "data"), &TileMap::_set_celld);
ClassDB::bind_method(D_METHOD("get_cell", "x", "y"), &TileMap::get_cell);
ClassDB::bind_method(D_METHOD("get_cellv", "position"), &TileMap::get_cellv);
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/tile_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class TileMap : public Node2D {
Vector2 get_cell_autotile_coord(int p_x, int p_y) const;

void _set_celld(const Vector2 &p_pos, const Dictionary &p_data);
void set_cellv(const Vector2 &p_pos, int p_tile, bool p_flip_x = false, bool p_flip_y = false, bool p_transpose = false);
void set_cellv(const Vector2 &p_pos, int p_tile, bool p_flip_x = false, bool p_flip_y = false, bool p_transpose = false, Vector2 p_autotile_coord = Vector2());
int get_cellv(const Vector2 &p_pos) const;

void make_bitmask_area_dirty(const Vector2 &p_pos);
Expand Down

0 comments on commit 3cc7c4a

Please sign in to comment.