summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorA Thousand Ships <96648715+AThousandShips@users.noreply.github.com>2024-03-26 16:07:38 +0100
committerA Thousand Ships <96648715+AThousandShips@users.noreply.github.com>2024-03-26 16:07:50 +0100
commitd4fcca4545b0747ebbc3cc126454d129e74d9211 (patch)
tree0993e2ef039e964e4a8dc055f6376f7bf21c02e3
parent7d151c83811f8ac8873439826c16d88c83aba12f (diff)
downloadredot-engine-d4fcca4545b0747ebbc3cc126454d129e74d9211.tar.gz
[TileSet] Expose `TileData.is_valid_terrain_peering_bit`
-rw-r--r--doc/classes/TileData.xml11
-rw-r--r--scene/resources/2d/tile_set.cpp1
2 files changed, 10 insertions, 2 deletions
diff --git a/doc/classes/TileData.xml b/doc/classes/TileData.xml
index c5b86f079e..91df90580c 100644
--- a/doc/classes/TileData.xml
+++ b/doc/classes/TileData.xml
@@ -93,7 +93,7 @@
<return type="int" />
<param index="0" name="peering_bit" type="int" enum="TileSet.CellNeighbor" />
<description>
- Returns the tile's terrain bit for the given [param peering_bit] direction.
+ Returns the tile's terrain bit for the given [param peering_bit] direction. To check that a direction is valid, use [method is_valid_terrain_peering_bit].
</description>
</method>
<method name="is_collision_polygon_one_way" qualifiers="const">
@@ -104,6 +104,13 @@
Returns whether one-way collisions are enabled for the polygon at index [param polygon_index] for TileSet physics layer with index [param layer_id].
</description>
</method>
+ <method name="is_valid_terrain_peering_bit" qualifiers="const">
+ <return type="bool" />
+ <param index="0" name="peering_bit" type="int" enum="TileSet.CellNeighbor" />
+ <description>
+ Returns whether the given [param peering_bit] direction is valid for this tile.
+ </description>
+ </method>
<method name="remove_collision_polygon">
<return type="void" />
<param index="0" name="layer_id" type="int" />
@@ -200,7 +207,7 @@
<param index="0" name="peering_bit" type="int" enum="TileSet.CellNeighbor" />
<param index="1" name="terrain" type="int" />
<description>
- Sets the tile's terrain bit for the given [param peering_bit] direction.
+ Sets the tile's terrain bit for the given [param peering_bit] direction. To check that a direction is valid, use [method is_valid_terrain_peering_bit].
</description>
</method>
</methods>
diff --git a/scene/resources/2d/tile_set.cpp b/scene/resources/2d/tile_set.cpp
index 66d97398b9..6ae97944e0 100644
--- a/scene/resources/2d/tile_set.cpp
+++ b/scene/resources/2d/tile_set.cpp
@@ -6918,6 +6918,7 @@ void TileData::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_terrain"), &TileData::get_terrain);
ClassDB::bind_method(D_METHOD("set_terrain_peering_bit", "peering_bit", "terrain"), &TileData::set_terrain_peering_bit);
ClassDB::bind_method(D_METHOD("get_terrain_peering_bit", "peering_bit"), &TileData::get_terrain_peering_bit);
+ ClassDB::bind_method(D_METHOD("is_valid_terrain_peering_bit", "peering_bit"), &TileData::is_valid_terrain_peering_bit);
// Navigation
ClassDB::bind_method(D_METHOD("set_navigation_polygon", "layer_id", "navigation_polygon"), &TileData::set_navigation_polygon);