Merge pull request #52433 from groud/document_tiles

Tiles renames and documentation
This commit is contained in:
Max Hilbrunner 2021-09-10 16:32:19 +02:00 committed by GitHub
commit 8f8744a563
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 336 additions and 155 deletions

View File

@ -11,6 +11,7 @@
<return type="void" /> <return type="void" />
<argument index="0" name="layer_id" type="int" /> <argument index="0" name="layer_id" type="int" />
<description> <description>
Adds a collision polygon to the tile on the given TileSet physics layer.
</description> </description>
</method> </method>
<method name="get_collision_polygon_one_way_margin" qualifiers="const"> <method name="get_collision_polygon_one_way_margin" qualifiers="const">
@ -18,6 +19,7 @@
<argument index="0" name="layer_id" type="int" /> <argument index="0" name="layer_id" type="int" />
<argument index="1" name="polygon_index" type="int" /> <argument index="1" name="polygon_index" type="int" />
<description> <description>
Returns the one-way margin (for one-way platforms) of the polygon at index [code]polygon_index[/code] for TileSet physics layer with index [code]layer_id[/code].
</description> </description>
</method> </method>
<method name="get_collision_polygon_points" qualifiers="const"> <method name="get_collision_polygon_points" qualifiers="const">
@ -25,42 +27,49 @@
<argument index="0" name="layer_id" type="int" /> <argument index="0" name="layer_id" type="int" />
<argument index="1" name="polygon_index" type="int" /> <argument index="1" name="polygon_index" type="int" />
<description> <description>
Returns the points of the polygon at index [code]polygon_index[/code] for TileSet physics layer with index [code]layer_id[/code].
</description> </description>
</method> </method>
<method name="get_collision_polygons_count" qualifiers="const"> <method name="get_collision_polygons_count" qualifiers="const">
<return type="int" /> <return type="int" />
<argument index="0" name="layer_id" type="int" /> <argument index="0" name="layer_id" type="int" />
<description> <description>
Returns how many polygons the tile has for TileSet physics layer with index [code]layer_id[/code].
</description> </description>
</method> </method>
<method name="get_custom_data" qualifiers="const"> <method name="get_custom_data" qualifiers="const">
<return type="Variant" /> <return type="Variant" />
<argument index="0" name="layer_name" type="String" /> <argument index="0" name="layer_name" type="String" />
<description> <description>
Returns the custom data value for custom data layer named [code]layer_name[/code].
</description> </description>
</method> </method>
<method name="get_custom_data_by_layer_id" qualifiers="const"> <method name="get_custom_data_by_layer_id" qualifiers="const">
<return type="Variant" /> <return type="Variant" />
<argument index="0" name="layer_id" type="int" /> <argument index="0" name="layer_id" type="int" />
<description> <description>
Returns the custom data value for custom data layer with index [code]layer_id[/code].
</description> </description>
</method> </method>
<method name="get_navigation_polygon" qualifiers="const"> <method name="get_navigation_polygon" qualifiers="const">
<return type="NavigationPolygon" /> <return type="NavigationPolygon" />
<argument index="0" name="layer_id" type="int" /> <argument index="0" name="layer_id" type="int" />
<description> <description>
Returns the navigation polygon of the tile for the TileSet navigation layer with index [code]layer_id[/code].
</description> </description>
</method> </method>
<method name="get_occluder" qualifiers="const"> <method name="get_occluder" qualifiers="const">
<return type="OccluderPolygon2D" /> <return type="OccluderPolygon2D" />
<argument index="0" name="layer_id" type="int" /> <argument index="0" name="layer_id" type="int" />
<description> <description>
Returns the occluder polygon of the tile for the TileSet occlusion layer with index [code]layer_id[/code].
</description> </description>
</method> </method>
<method name="get_peering_bit_terrain" qualifiers="const"> <method name="get_peering_bit_terrain" qualifiers="const">
<return type="int" /> <return type="int" />
<argument index="0" name="peering_bit" type="int" enum="TileSet.CellNeighbor" /> <argument index="0" name="peering_bit" type="int" enum="TileSet.CellNeighbor" />
<description> <description>
Returns the tile's terrain bit for the given [code]peering_bit[/code] direction.
</description> </description>
</method> </method>
<method name="is_collision_polygon_one_way" qualifiers="const"> <method name="is_collision_polygon_one_way" qualifiers="const">
@ -68,6 +77,7 @@
<argument index="0" name="layer_id" type="int" /> <argument index="0" name="layer_id" type="int" />
<argument index="1" name="polygon_index" type="int" /> <argument index="1" name="polygon_index" type="int" />
<description> <description>
Returns whether one-way collisions are enabled for the polygon at index [code]polygon_index[/code] for TileSet physics layer with index [code]layer_id[/code].
</description> </description>
</method> </method>
<method name="remove_collision_polygon"> <method name="remove_collision_polygon">
@ -75,6 +85,7 @@
<argument index="0" name="layer_id" type="int" /> <argument index="0" name="layer_id" type="int" />
<argument index="1" name="polygon_index" type="int" /> <argument index="1" name="polygon_index" type="int" />
<description> <description>
Removes the polygon at index [code]polygon_index[/code] for TileSet physics layer with index [code]layer_id[/code].
</description> </description>
</method> </method>
<method name="set_collision_polygon_one_way"> <method name="set_collision_polygon_one_way">
@ -83,6 +94,7 @@
<argument index="1" name="polygon_index" type="int" /> <argument index="1" name="polygon_index" type="int" />
<argument index="2" name="one_way" type="bool" /> <argument index="2" name="one_way" type="bool" />
<description> <description>
Enables/disables one-way collisions on the polygon at index [code]polygon_index[/code] for TileSet physics layer with index [code]layer_id[/code].
</description> </description>
</method> </method>
<method name="set_collision_polygon_one_way_margin"> <method name="set_collision_polygon_one_way_margin">
@ -91,6 +103,7 @@
<argument index="1" name="polygon_index" type="int" /> <argument index="1" name="polygon_index" type="int" />
<argument index="2" name="one_way_margin" type="float" /> <argument index="2" name="one_way_margin" type="float" />
<description> <description>
Enables/disables one-way collisions on the polygon at index [code]polygon_index[/code] for TileSet physics layer with index [code]layer_id[/code].
</description> </description>
</method> </method>
<method name="set_collision_polygon_points"> <method name="set_collision_polygon_points">
@ -99,6 +112,7 @@
<argument index="1" name="polygon_index" type="int" /> <argument index="1" name="polygon_index" type="int" />
<argument index="2" name="polygon" type="PackedVector2Array" /> <argument index="2" name="polygon" type="PackedVector2Array" />
<description> <description>
Sets the points of the polygon at index [code]polygon_index[/code] for TileSet physics layer with index [code]layer_id[/code].
</description> </description>
</method> </method>
<method name="set_collision_polygons_count"> <method name="set_collision_polygons_count">
@ -106,6 +120,7 @@
<argument index="0" name="layer_id" type="int" /> <argument index="0" name="layer_id" type="int" />
<argument index="1" name="polygons_count" type="int" /> <argument index="1" name="polygons_count" type="int" />
<description> <description>
Sets the polygons count for TileSet physics layer with index [code]layer_id[/code].
</description> </description>
</method> </method>
<method name="set_custom_data"> <method name="set_custom_data">
@ -113,6 +128,7 @@
<argument index="0" name="layer_name" type="String" /> <argument index="0" name="layer_name" type="String" />
<argument index="1" name="value" type="Variant" /> <argument index="1" name="value" type="Variant" />
<description> <description>
Sets the tile's custom data value for the TileSet custom data layer with name [code]layer_name[/code].
</description> </description>
</method> </method>
<method name="set_custom_data_by_layer_id"> <method name="set_custom_data_by_layer_id">
@ -120,6 +136,7 @@
<argument index="0" name="layer_id" type="int" /> <argument index="0" name="layer_id" type="int" />
<argument index="1" name="value" type="Variant" /> <argument index="1" name="value" type="Variant" />
<description> <description>
Sets the tile's custom data value for the TileSet custom data layer with index [code]layer_id[/code].
</description> </description>
</method> </method>
<method name="set_navigation_polygon"> <method name="set_navigation_polygon">
@ -127,6 +144,7 @@
<argument index="0" name="layer_id" type="int" /> <argument index="0" name="layer_id" type="int" />
<argument index="1" name="navigation_polygon" type="NavigationPolygon" /> <argument index="1" name="navigation_polygon" type="NavigationPolygon" />
<description> <description>
Sets the navigation polygon for the TileSet navigation layer with index [code]layer_id[/code].
</description> </description>
</method> </method>
<method name="set_occluder"> <method name="set_occluder">
@ -134,6 +152,7 @@
<argument index="0" name="layer_id" type="int" /> <argument index="0" name="layer_id" type="int" />
<argument index="1" name="occluder_polygon" type="OccluderPolygon2D" /> <argument index="1" name="occluder_polygon" type="OccluderPolygon2D" />
<description> <description>
Sets the occluder for the TileSet occlusion layer with index [code]layer_id[/code].
</description> </description>
</method> </method>
<method name="set_peering_bit_terrain"> <method name="set_peering_bit_terrain">
@ -141,17 +160,7 @@
<argument index="0" name="peering_bit" type="int" enum="TileSet.CellNeighbor" /> <argument index="0" name="peering_bit" type="int" enum="TileSet.CellNeighbor" />
<argument index="1" name="terrain" type="int" /> <argument index="1" name="terrain" type="int" />
<description> <description>
</description> Sets the tile's terrain bit for the given [code]peering_bit[/code] direction.
</method>
<method name="tile_get_material" qualifiers="const">
<return type="ShaderMaterial" />
<description>
</description>
</method>
<method name="tile_set_material">
<return type="void" />
<argument index="0" name="material" type="ShaderMaterial" />
<description>
</description> </description>
</method> </method>
</methods> </methods>
@ -160,6 +169,8 @@
</member> </member>
<member name="flip_v" type="bool" setter="set_flip_v" getter="get_flip_v" default="false"> <member name="flip_v" type="bool" setter="set_flip_v" getter="get_flip_v" default="false">
</member> </member>
<member name="material" type="ShaderMaterial" setter="set_material" getter="get_material">
</member>
<member name="modulate" type="Color" setter="set_modulate" getter="get_modulate" default="Color(1, 1, 1, 1)"> <member name="modulate" type="Color" setter="set_modulate" getter="get_modulate" default="Color(1, 1, 1, 1)">
</member> </member>
<member name="probability" type="float" setter="set_probability" getter="get_probability" default="1.0"> <member name="probability" type="float" setter="set_probability" getter="get_probability" default="1.0">

View File

@ -4,8 +4,7 @@
Node for 2D tile-based maps. Node for 2D tile-based maps.
</brief_description> </brief_description>
<description> <description>
Node for 2D tile-based maps. Tilemaps use a [TileSet] which contain a list of tiles (textures plus optional collision, navigation, and/or occluder shapes) which are used to create grid-based maps. Node for 2D tile-based maps. Tilemaps use a [TileSet] which contain a list of tiles which are used to create grid-based maps. A TileMap may have several layers, layouting tiles on top of each other.
When doing physics queries against the tilemap, the cell coordinates are encoded as [code]metadata[/code] for each detected collision shape returned by methods such as [method PhysicsDirectSpaceState2D.intersect_shape], [method PhysicsDirectBodyState2D.get_contact_collider_shape_metadata] etc.
</description> </description>
<tutorials> <tutorials>
<link title="Using Tilemaps">https://docs.godotengine.org/en/latest/tutorials/2d/using_tilemaps.html</link> <link title="Using Tilemaps">https://docs.godotengine.org/en/latest/tutorials/2d/using_tilemaps.html</link>
@ -19,8 +18,9 @@
<methods> <methods>
<method name="add_layer"> <method name="add_layer">
<return type="void" /> <return type="void" />
<argument index="0" name="arg0" type="int" /> <argument index="0" name="to_position" type="int" />
<description> <description>
Adds a layer at the given position [code]to_position[/code] in the array. If [code]to_position[/code] is -1, adds it at the end of the array.
</description> </description>
</method> </method>
<method name="clear"> <method name="clear">
@ -41,6 +41,7 @@
<argument index="1" name="coords" type="Vector2i" /> <argument index="1" name="coords" type="Vector2i" />
<argument index="2" name="use_proxies" type="bool" /> <argument index="2" name="use_proxies" type="bool" />
<description> <description>
Returns the tile alternative ID of the cell on layer [code]layer[/code] at [code]coords[/code]. If [code]use_proxies[/code] is [code]false[/code], ignores the [TileSet]'s tile proxies, returning the raw alternative identifier. See [method TileSet.map_tile_proxy].
</description> </description>
</method> </method>
<method name="get_cell_atlas_coords" qualifiers="const"> <method name="get_cell_atlas_coords" qualifiers="const">
@ -49,6 +50,7 @@
<argument index="1" name="coords" type="Vector2i" /> <argument index="1" name="coords" type="Vector2i" />
<argument index="2" name="use_proxies" type="bool" /> <argument index="2" name="use_proxies" type="bool" />
<description> <description>
Returns the tile atlas coordinates ID of the cell on layer [code]layer[/code] at coordinates [code]coords[/code]. If [code]use_proxies[/code] is [code]false[/code], ignores the [TileSet]'s tile proxies, returning the raw alternative identifier. See [method TileSet.map_tile_proxy].
</description> </description>
</method> </method>
<method name="get_cell_source_id" qualifiers="const"> <method name="get_cell_source_id" qualifiers="const">
@ -57,24 +59,28 @@
<argument index="1" name="coords" type="Vector2i" /> <argument index="1" name="coords" type="Vector2i" />
<argument index="2" name="use_proxies" type="bool" /> <argument index="2" name="use_proxies" type="bool" />
<description> <description>
Returns the tile source ID of the cell on layer [code]layer[/code] at coordinates [code]coords[/code]. If [code]use_proxies[/code] is [code]false[/code], ignores the [TileSet]'s tile proxies, returning the raw alternative identifier. See [method TileSet.map_tile_proxy].
</description> </description>
</method> </method>
<method name="get_layer_name" qualifiers="const"> <method name="get_layer_name" qualifiers="const">
<return type="String" /> <return type="String" />
<argument index="0" name="layer" type="int" /> <argument index="0" name="layer" type="int" />
<description> <description>
Returns a TileMap layer's name.
</description> </description>
</method> </method>
<method name="get_layer_y_sort_origin" qualifiers="const"> <method name="get_layer_y_sort_origin" qualifiers="const">
<return type="int" /> <return type="int" />
<argument index="0" name="layer" type="int" /> <argument index="0" name="layer" type="int" />
<description> <description>
Returns a TileMap layer's Y sort origin.
</description> </description>
</method> </method>
<method name="get_layer_z_indexd" qualifiers="const"> <method name="get_layer_z_index" qualifiers="const">
<return type="int" /> <return type="int" />
<argument index="0" name="layer" type="int" /> <argument index="0" name="layer" type="int" />
<description> <description>
Returns a TileMap layer's Z-index value.
</description> </description>
</method> </method>
<method name="get_layers_count" qualifiers="const"> <method name="get_layers_count" qualifiers="const">
@ -87,37 +93,41 @@
<argument index="0" name="coords" type="Vector2i" /> <argument index="0" name="coords" type="Vector2i" />
<argument index="1" name="neighbor" type="int" enum="TileSet.CellNeighbor" /> <argument index="1" name="neighbor" type="int" enum="TileSet.CellNeighbor" />
<description> <description>
Returns the neighboring cell to the one at coordinates [code]coords[/code], indentified by the [code]neighbor[/code] direction. This method takes into account the different layouts a TileMap can take.
</description> </description>
</method> </method>
<method name="get_surrounding_tiles"> <method name="get_surrounding_tiles">
<return type="Vector2i[]" /> <return type="Vector2i[]" />
<argument index="0" name="coords" type="Vector2i" /> <argument index="0" name="coords" type="Vector2i" />
<description> <description>
Returns the list of all neighbourings cells to the one at [code]coords[/code]
</description> </description>
</method> </method>
<method name="get_used_cells" qualifiers="const"> <method name="get_used_cells" qualifiers="const">
<return type="Vector2i[]" /> <return type="Vector2i[]" />
<argument index="0" name="layer" type="int" /> <argument index="0" name="layer" type="int" />
<description> <description>
Returns a [Vector2] array with the positions of all cells containing a tile from the tileset (i.e. a tile index different from [code]-1[/code]). Returns a [Vector2] array with the positions of all cells containing a tile in the given layer. A cell is considered empty if its source identifier equals -1, its atlas coordinates identifiers is [code]Vector2(-1, -1)[/code] and its alternative identifier is -1.
</description> </description>
</method> </method>
<method name="get_used_rect"> <method name="get_used_rect">
<return type="Rect2" /> <return type="Rect2" />
<description> <description>
Returns a rectangle enclosing the used (non-empty) tiles of the map. Returns a rectangle enclosing the used (non-empty) tiles of the map, including all layers.
</description> </description>
</method> </method>
<method name="is_layer_enabled" qualifiers="const"> <method name="is_layer_enabled" qualifiers="const">
<return type="bool" /> <return type="bool" />
<argument index="0" name="layer" type="int" /> <argument index="0" name="layer" type="int" />
<description> <description>
Returns if a layer is enabled.
</description> </description>
</method> </method>
<method name="is_layer_y_sort_enabled" qualifiers="const"> <method name="is_layer_y_sort_enabled" qualifiers="const">
<return type="bool" /> <return type="bool" />
<argument index="0" name="layer" type="int" /> <argument index="0" name="layer" type="int" />
<description> <description>
Returns if a layer Y-sorts its tiles.
</description> </description>
</method> </method>
<method name="map_to_world" qualifiers="const"> <method name="map_to_world" qualifiers="const">
@ -129,15 +139,17 @@
</method> </method>
<method name="move_layer"> <method name="move_layer">
<return type="void" /> <return type="void" />
<argument index="0" name="arg0" type="int" /> <argument index="0" name="layer" type="int" />
<argument index="1" name="arg1" type="int" /> <argument index="1" name="to_position" type="int" />
<description> <description>
Moves the layer at index [code]layer_index[/code] to the given position [code]to_position[/code] in the array.
</description> </description>
</method> </method>
<method name="remove_layer"> <method name="remove_layer">
<return type="void" /> <return type="void" />
<argument index="0" name="arg0" type="int" /> <argument index="0" name="layer" type="int" />
<description> <description>
Moves the layer at index [code]layer_index[/code] to the given position [code]to_position[/code] in the array.
</description> </description>
</method> </method>
<method name="set_cell"> <method name="set_cell">
@ -148,7 +160,10 @@
<argument index="3" name="atlas_coords" type="Vector2i" default="Vector2i(-1, -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="-1" />
<description> <description>
Sets the tile index for the cell given by a Vector2i. 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 indentifier [code]source_id[/code] identifies a [TileSetSource] identifier. See [method TileSet.set_source_id],
- The atlas coordinates identifier [code]atlas_coords[/code] identifies a tile coordinates in the atlas (if the source is a [TileSetAtlasSource]. For [TileSetScenesCollectionSource] it should be 0),
- The alternative tile identifier [code]alternative_tile[/code] identifies a tile alternative the source is a [TileSetAtlasSource], and the scene for a [TileSetScenesCollectionSource].
</description> </description>
</method> </method>
<method name="set_layer_enabled"> <method name="set_layer_enabled">
@ -156,6 +171,7 @@
<argument index="0" name="layer" type="int" /> <argument index="0" name="layer" type="int" />
<argument index="1" name="enabled" type="bool" /> <argument index="1" name="enabled" type="bool" />
<description> <description>
Enables or disables the layer [code]layer[/code]. A disabled layer is not processed at all (no rendering, no physics, etc...).
</description> </description>
</method> </method>
<method name="set_layer_name"> <method name="set_layer_name">
@ -163,6 +179,7 @@
<argument index="0" name="layer" type="int" /> <argument index="0" name="layer" type="int" />
<argument index="1" name="name" type="String" /> <argument index="1" name="name" type="String" />
<description> <description>
Sets a layer's name. This is mostly useful in the editor.
</description> </description>
</method> </method>
<method name="set_layer_y_sort_enabled"> <method name="set_layer_y_sort_enabled">
@ -170,6 +187,8 @@
<argument index="0" name="layer" type="int" /> <argument index="0" name="layer" type="int" />
<argument index="1" name="y_sort_enabled" type="bool" /> <argument index="1" name="y_sort_enabled" type="bool" />
<description> <description>
Enables or disables a layer's Y-sorting. If a layer is Y-sorted, the layer will behave as a CanvasItem node where each of its tile gets Y-sorted.
Y-sorted layers should usually be on different Z-index values than not Y-sorted layers, otherwise, each of those layer will be Y-sorted as whole with the Y-sorted one. This is usually an undesired behvaior.
</description> </description>
</method> </method>
<method name="set_layer_y_sort_origin"> <method name="set_layer_y_sort_origin">
@ -177,6 +196,8 @@
<argument index="0" name="layer" type="int" /> <argument index="0" name="layer" type="int" />
<argument index="1" name="y_sort_origin" type="int" /> <argument index="1" name="y_sort_origin" type="int" />
<description> <description>
Sets a layer's Y-sort origin value. This Y-sort origin value is added to each tile's Y-sort origin value.
This allows, for example, to fake a different height level on each layer. This can be useful for top-down view games.
</description> </description>
</method> </method>
<method name="set_layer_z_index"> <method name="set_layer_z_index">
@ -184,6 +205,7 @@
<argument index="0" name="layer" type="int" /> <argument index="0" name="layer" type="int" />
<argument index="1" name="z_index" type="int" /> <argument index="1" name="z_index" type="int" />
<description> <description>
Sets a layers Z-index value. This Z-index is added to each tile's Z-index value.
</description> </description>
</method> </method>
<method name="world_to_map" qualifiers="const"> <method name="world_to_map" qualifiers="const">
@ -199,8 +221,10 @@
The TileMap's quadrant size. Optimizes drawing by batching, using chunks of this size. The TileMap's quadrant size. Optimizes drawing by batching, using chunks of this size.
</member> </member>
<member name="collision_visibility_mode" type="int" setter="set_collision_visibility_mode" getter="get_collision_visibility_mode" enum="TileMap.VisibilityMode" default="0"> <member name="collision_visibility_mode" type="int" setter="set_collision_visibility_mode" getter="get_collision_visibility_mode" enum="TileMap.VisibilityMode" default="0">
Show or hide the TileMap's collision shapes. If set to [code]VISIBILITY_MODE_DEFAULT[/code], this depends on the show collision debug settings.
</member> </member>
<member name="navigation_visibility_mode" type="int" setter="set_navigation_visibility_mode" getter="get_navigation_visibility_mode" enum="TileMap.VisibilityMode" default="0"> <member name="navigation_visibility_mode" type="int" setter="set_navigation_visibility_mode" getter="get_navigation_visibility_mode" enum="TileMap.VisibilityMode" default="0">
Show or hide the TileMap's collision shapes. If set to [code]VISIBILITY_MODE_DEFAULT[/code], this depends on the show navigation debug settings.
</member> </member>
<member name="tile_set" type="TileSet" setter="set_tileset" getter="get_tileset"> <member name="tile_set" type="TileSet" setter="set_tileset" getter="get_tileset">
The assigned [TileSet]. The assigned [TileSet].
@ -215,10 +239,13 @@
</signals> </signals>
<constants> <constants>
<constant name="VISIBILITY_MODE_DEFAULT" value="0" enum="VisibilityMode"> <constant name="VISIBILITY_MODE_DEFAULT" value="0" enum="VisibilityMode">
Use the debug settings to determine visibility.
</constant> </constant>
<constant name="VISIBILITY_MODE_FORCE_HIDE" value="2" enum="VisibilityMode"> <constant name="VISIBILITY_MODE_FORCE_HIDE" value="2" enum="VisibilityMode">
Always hide.
</constant> </constant>
<constant name="VISIBILITY_MODE_FORCE_SHOW" value="1" enum="VisibilityMode"> <constant name="VISIBILITY_MODE_FORCE_SHOW" value="1" enum="VisibilityMode">
Always show.
</constant> </constant>
</constants> </constants>
</class> </class>

View File

@ -4,8 +4,13 @@
Tile library for tilemaps. Tile library for tilemaps.
</brief_description> </brief_description>
<description> <description>
A TileSet is a library of tiles for a [TileMap]. It contains a list of tiles, each consisting of a sprite and optional collision shapes. A TileSet is a library of tiles for a [TileMap]. A TileSet handles a list of [TileSetSource], each of them storing a set of tiles.
Tiles are referenced by a unique integer ID. Tiles can either be from a [TileSetAtlasSource], that render tiles out of a texture with support for physics, navigation, etc... or from a [TileSetScenesCollectionSource] which exposes scene-based tiles.
Tiles are referenced by using three IDs: their source ID, their atlas coordinates ID and their alternative tile ID.
A TileSet can be configured so that its tiles expose more or less properties. To do so, the TileSet resources uses property layers, that you can add or remove depending on your needs.
For example, adding a physics layer allows giving collision shapes to your tiles. Each layer having dedicated properties (physics layer an mask), you may add several TileSet physics layers for each type of collision you need.
See the functions to add new layers for more information.
</description> </description>
<tutorials> <tutorials>
<link title="Using Tilemaps">https://docs.godotengine.org/en/latest/tutorials/2d/using_tilemaps.html</link> <link title="Using Tilemaps">https://docs.godotengine.org/en/latest/tutorials/2d/using_tilemaps.html</link>
@ -21,31 +26,41 @@
<return type="void" /> <return type="void" />
<argument index="0" name="to_position" type="int" default="-1" /> <argument index="0" name="to_position" type="int" default="-1" />
<description> <description>
Adds a custom data layer to the TileSet at the given position [code]to_position[/code] in the array. If [code]to_position[/code] is -1, adds it at the end of the array.
Custom data layers allow assigning custom properties to atlas tiles.
</description> </description>
</method> </method>
<method name="add_navigation_layer"> <method name="add_navigation_layer">
<return type="void" /> <return type="void" />
<argument index="0" name="to_position" type="int" default="-1" /> <argument index="0" name="to_position" type="int" default="-1" />
<description> <description>
Adds a navigation layer to the TileSet at the given position [code]to_position[/code] in the array. If [code]to_position[/code] is -1, adds it at the end of the array.
Navigation layers allow assigning a navigable area to atlas tiles.
</description> </description>
</method> </method>
<method name="add_occlusion_layer"> <method name="add_occlusion_layer">
<return type="void" /> <return type="void" />
<argument index="0" name="to_position" type="int" default="-1" /> <argument index="0" name="to_position" type="int" default="-1" />
<description> <description>
Adds an occlusion layer to the TileSet at the given position [code]to_position[/code] in the array. If [code]to_position[/code] is -1, adds it at the end of the array.
Occlusion layers allow assigning occlusion polygons to atlas tiles.
</description> </description>
</method> </method>
<method name="add_physics_layer"> <method name="add_physics_layer">
<return type="void" /> <return type="void" />
<argument index="0" name="to_position" type="int" default="-1" /> <argument index="0" name="to_position" type="int" default="-1" />
<description> <description>
Adds a physics layer to the TileSet at the given position [code]to_position[/code] in the array. If [code]to_position[/code] is -1, adds it at the end of the array.
Physics layers allow assigning collision polygons to atlas tiles.
</description> </description>
</method> </method>
<method name="add_source"> <method name="add_source">
<return type="int" /> <return type="int" />
<argument index="0" name="atlas_source_id_override" type="TileSetSource" /> <argument index="0" name="source" type="TileSetSource" />
<argument index="1" name="arg1" type="int" default="-1" /> <argument index="1" name="atlas_source_id_override" type="int" default="-1" />
<description> <description>
Adds a [TileSetSource] to the TileSet. If [code]atlas_source_id_override[/code] is not -1, also set its source ID. Otherwise, a unique identifier is automatically generated.
The function returns the added source source ID or -1 if the source could not be added.
</description> </description>
</method> </method>
<method name="add_terrain"> <method name="add_terrain">
@ -53,22 +68,26 @@
<argument index="0" name="terrain_set" type="int" /> <argument index="0" name="terrain_set" type="int" />
<argument index="1" name="to_position" type="int" default="-1" /> <argument index="1" name="to_position" type="int" default="-1" />
<description> <description>
Adds a new terrain to the given terrain set [code]terrain_set[/code] at the given position [code]to_position[/code] in the array. If [code]to_position[/code] is -1, adds it at the end of the array.
</description> </description>
</method> </method>
<method name="add_terrain_set"> <method name="add_terrain_set">
<return type="void" /> <return type="void" />
<argument index="0" name="to_position" type="int" default="-1" /> <argument index="0" name="to_position" type="int" default="-1" />
<description> <description>
Adds a new terrain set at the given position [code]to_position[/code] in the array. If [code]to_position[/code] is -1, adds it at the end of the array.
</description> </description>
</method> </method>
<method name="cleanup_invalid_tile_proxies"> <method name="cleanup_invalid_tile_proxies">
<return type="void" /> <return type="void" />
<description> <description>
Clears tile proxies pointing to invalid tiles.
</description> </description>
</method> </method>
<method name="clear_tile_proxies"> <method name="clear_tile_proxies">
<return type="void" /> <return type="void" />
<description> <description>
Clears all tile proxies.
</description> </description>
</method> </method>
<method name="get_alternative_level_tile_proxy"> <method name="get_alternative_level_tile_proxy">
@ -77,6 +96,8 @@
<argument index="1" name="coords_from" type="Vector2i" /> <argument index="1" name="coords_from" type="Vector2i" />
<argument index="2" name="alternative_from" type="int" /> <argument index="2" name="alternative_from" type="int" />
<description> <description>
Returns the alternative-level proxy for the given identifiers. The returned array contains the three proxie's target identifiers (source ID, atlas coords ID and alternative tile ID).
If the TileSet has no proxy for the given identifiers, returns an empty Array.
</description> </description>
</method> </method>
<method name="get_coords_level_tile_proxy"> <method name="get_coords_level_tile_proxy">
@ -84,90 +105,108 @@
<argument index="0" name="source_from" type="int" /> <argument index="0" name="source_from" type="int" />
<argument index="1" name="coords_from" type="Vector2i" /> <argument index="1" name="coords_from" type="Vector2i" />
<description> <description>
Returns the coodinate-level proxy for the given identifiers. The returned array contains the two proxie's target identifiers (source ID and atlas coords ID).
If the TileSet has no proxy for the given identifiers, returns an empty Array.
</description> </description>
</method> </method>
<method name="get_custom_data_layers_count" qualifiers="const"> <method name="get_custom_data_layers_count" qualifiers="const">
<return type="int" /> <return type="int" />
<description> <description>
Returns the custom data layers count.
</description> </description>
</method> </method>
<method name="get_navigation_layer_layers" qualifiers="const"> <method name="get_navigation_layer_layers" qualifiers="const">
<return type="int" /> <return type="int" />
<argument index="0" name="layer_index" type="int" /> <argument index="0" name="layer_index" type="int" />
<description> <description>
Returns the navigation layers (as in the Navigation server) of the gives TileSet navigation layer.
</description> </description>
</method> </method>
<method name="get_navigation_layers_count" qualifiers="const"> <method name="get_navigation_layers_count" qualifiers="const">
<return type="int" /> <return type="int" />
<description> <description>
Returns the navigation layers count.
</description> </description>
</method> </method>
<method name="get_next_source_id" qualifiers="const"> <method name="get_next_source_id" qualifiers="const">
<return type="int" /> <return type="int" />
<description> <description>
Returns a new unused source ID. This generated ID is the same that a call to [code]add_source[/code] would return.
</description> </description>
</method> </method>
<method name="get_occlusion_layer_light_mask" qualifiers="const"> <method name="get_occlusion_layer_light_mask" qualifiers="const">
<return type="int" /> <return type="int" />
<argument index="0" name="arg0" type="int" /> <argument index="0" name="layer_index" type="int" />
<description> <description>
Returns the light mask of the occlusion layer.
</description> </description>
</method> </method>
<method name="get_occlusion_layer_sdf_collision" qualifiers="const"> <method name="get_occlusion_layer_sdf_collision" qualifiers="const">
<return type="bool" /> <return type="bool" />
<argument index="0" name="arg0" type="int" /> <argument index="0" name="layer_index" type="int" />
<description> <description>
Returns if the occluders from this layer use [code]sdf_collision[/code].
</description> </description>
</method> </method>
<method name="get_occlusion_layers_count" qualifiers="const"> <method name="get_occlusion_layers_count" qualifiers="const">
<return type="int" /> <return type="int" />
<description> <description>
Returns the occlusion layers count.
</description> </description>
</method> </method>
<method name="get_physics_layer_collision_layer" qualifiers="const"> <method name="get_physics_layer_collision_layer" qualifiers="const">
<return type="int" /> <return type="int" />
<argument index="0" name="layer_index" type="int" /> <argument index="0" name="layer_index" type="int" />
<description> <description>
Returns the collision layer (as in the physics server) bodies on the given TileSet's physics layer are in.
</description> </description>
</method> </method>
<method name="get_physics_layer_collision_mask" qualifiers="const"> <method name="get_physics_layer_collision_mask" qualifiers="const">
<return type="int" /> <return type="int" />
<argument index="0" name="layer_index" type="int" /> <argument index="0" name="layer_index" type="int" />
<description> <description>
Returns the collision mask of bodies on the given TileSet's physics layer.
</description> </description>
</method> </method>
<method name="get_physics_layer_physics_material" qualifiers="const"> <method name="get_physics_layer_physics_material" qualifiers="const">
<return type="PhysicsMaterial" /> <return type="PhysicsMaterial" />
<argument index="0" name="layer_index" type="int" /> <argument index="0" name="layer_index" type="int" />
<description> <description>
Returns the physics material of bodies on the given TileSet's physics layer.
</description> </description>
</method> </method>
<method name="get_physics_layers_count" qualifiers="const"> <method name="get_physics_layers_count" qualifiers="const">
<return type="int" /> <return type="int" />
<description> <description>
Returns the physics layers count.
</description> </description>
</method> </method>
<method name="get_source" qualifiers="const"> <method name="get_source" qualifiers="const">
<return type="TileSetSource" /> <return type="TileSetSource" />
<argument index="0" name="index" type="int" /> <argument index="0" name="source_id" type="int" />
<description> <description>
Returns the [TileSetSource] with ID [code]source_id[/code].
</description> </description>
</method> </method>
<method name="get_source_count" qualifiers="const"> <method name="get_source_count" qualifiers="const">
<return type="int" /> <return type="int" />
<description> <description>
Returns the number of [TileSetSource] in this TileSet.
</description> </description>
</method> </method>
<method name="get_source_id" qualifiers="const"> <method name="get_source_id" qualifiers="const">
<return type="int" /> <return type="int" />
<argument index="0" name="index" type="int" /> <argument index="0" name="index" type="int" />
<description> <description>
Returns the source ID for source with index [code]index[/code].
</description> </description>
</method> </method>
<method name="get_source_level_tile_proxy"> <method name="get_source_level_tile_proxy">
<return type="int" /> <return type="int" />
<argument index="0" name="source_from" type="int" /> <argument index="0" name="source_from" type="int" />
<description> <description>
Returns the source-level proxy for the given source identifier.
If the TileSet has no proxy for the given identifier, returns -1.
</description> </description>
</method> </method>
<method name="get_terrain_color" qualifiers="const"> <method name="get_terrain_color" qualifiers="const">
@ -175,6 +214,7 @@
<argument index="0" name="terrain_set" type="int" /> <argument index="0" name="terrain_set" type="int" />
<argument index="1" name="terrain_index" type="int" /> <argument index="1" name="terrain_index" type="int" />
<description> <description>
Returns a terrain's color.
</description> </description>
</method> </method>
<method name="get_terrain_name" qualifiers="const"> <method name="get_terrain_name" qualifiers="const">
@ -182,23 +222,27 @@
<argument index="0" name="terrain_set" type="int" /> <argument index="0" name="terrain_set" type="int" />
<argument index="1" name="terrain_index" type="int" /> <argument index="1" name="terrain_index" type="int" />
<description> <description>
Returns a terrain's name.
</description> </description>
</method> </method>
<method name="get_terrain_set_mode" qualifiers="const"> <method name="get_terrain_set_mode" qualifiers="const">
<return type="int" enum="TileSet.TerrainMode" /> <return type="int" enum="TileSet.TerrainMode" />
<argument index="0" name="terrain_set" type="int" /> <argument index="0" name="terrain_set" type="int" />
<description> <description>
Returns a terrain set mode.
</description> </description>
</method> </method>
<method name="get_terrain_sets_count" qualifiers="const"> <method name="get_terrain_sets_count" qualifiers="const">
<return type="int" /> <return type="int" />
<description> <description>
Returns the terrain sets count.
</description> </description>
</method> </method>
<method name="get_terrains_count" qualifiers="const"> <method name="get_terrains_count" qualifiers="const">
<return type="int" /> <return type="int" />
<argument index="0" name="terrain_set" type="int" /> <argument index="0" name="terrain_set" type="int" />
<description> <description>
Returns the number of terrains in the given terrain set.
</description> </description>
</method> </method>
<method name="has_alternative_level_tile_proxy"> <method name="has_alternative_level_tile_proxy">
@ -207,6 +251,7 @@
<argument index="1" name="coords_from" type="Vector2i" /> <argument index="1" name="coords_from" type="Vector2i" />
<argument index="2" name="alternative_from" type="int" /> <argument index="2" name="alternative_from" type="int" />
<description> <description>
Returns if there is and alternative-level proxy for the given identifiers.
</description> </description>
</method> </method>
<method name="has_coords_level_tile_proxy"> <method name="has_coords_level_tile_proxy">
@ -214,18 +259,21 @@
<argument index="0" name="source_from" type="int" /> <argument index="0" name="source_from" type="int" />
<argument index="1" name="coords_from" type="Vector2i" /> <argument index="1" name="coords_from" type="Vector2i" />
<description> <description>
Returns if there is a coodinates-level proxy for the given identifiers.
</description> </description>
</method> </method>
<method name="has_source" qualifiers="const"> <method name="has_source" qualifiers="const">
<return type="bool" /> <return type="bool" />
<argument index="0" name="index" type="int" /> <argument index="0" name="source_id" type="int" />
<description> <description>
Returns if this TileSet has a source for the given source ID.
</description> </description>
</method> </method>
<method name="has_source_level_tile_proxy"> <method name="has_source_level_tile_proxy">
<return type="bool" /> <return type="bool" />
<argument index="0" name="source_from" type="int" /> <argument index="0" name="source_from" type="int" />
<description> <description>
Returns if there is a source-level proxy for the given source ID.
</description> </description>
</method> </method>
<method name="map_tile_proxy" qualifiers="const"> <method name="map_tile_proxy" qualifiers="const">
@ -234,6 +282,9 @@
<argument index="1" name="coords_from" type="Vector2i" /> <argument index="1" name="coords_from" type="Vector2i" />
<argument index="2" name="alternative_from" type="int" /> <argument index="2" name="alternative_from" type="int" />
<description> <description>
According to the configured proxies, maps the provided indentifiers to a new set of identifiers. The source ID, atlas coordinates ID and alternative tile ID are returned as a 3 elements Array.
This function first look for matching alternative-level proxies, then coordinates-level proxies, then source-level proxies.
If no proxy corresponding to provided identifiers are found, returns the same values the ones used as arguments.
</description> </description>
</method> </method>
<method name="move_custom_data_layer"> <method name="move_custom_data_layer">
@ -241,6 +292,7 @@
<argument index="0" name="layer_index" type="int" /> <argument index="0" name="layer_index" type="int" />
<argument index="1" name="to_position" type="int" /> <argument index="1" name="to_position" type="int" />
<description> <description>
Moves the custom data layer at index [code]layer_index[/code] to the given position [code]to_position[/code] in the array. Also updates the atlas tiles accordingly.
</description> </description>
</method> </method>
<method name="move_navigation_layer"> <method name="move_navigation_layer">
@ -248,6 +300,7 @@
<argument index="0" name="layer_index" type="int" /> <argument index="0" name="layer_index" type="int" />
<argument index="1" name="to_position" type="int" /> <argument index="1" name="to_position" type="int" />
<description> <description>
Moves the navigation layer at index [code]layer_index[/code] to the given position [code]to_position[/code] in the array. Also updates the atlas tiles accordingly.
</description> </description>
</method> </method>
<method name="move_occlusion_layer"> <method name="move_occlusion_layer">
@ -255,6 +308,7 @@
<argument index="0" name="layer_index" type="int" /> <argument index="0" name="layer_index" type="int" />
<argument index="1" name="to_position" type="int" /> <argument index="1" name="to_position" type="int" />
<description> <description>
Moves the occlusion layer at index [code]layer_index[/code] to the given position [code]to_position[/code] in the array. Also updates the atlas tiles accordingly.
</description> </description>
</method> </method>
<method name="move_physics_layer"> <method name="move_physics_layer">
@ -262,6 +316,7 @@
<argument index="0" name="layer_index" type="int" /> <argument index="0" name="layer_index" type="int" />
<argument index="1" name="to_position" type="int" /> <argument index="1" name="to_position" type="int" />
<description> <description>
Moves the physics layer at index [code]layer_index[/code] to the given position [code]to_position[/code] in the array. Also updates the atlas tiles accordingly.
</description> </description>
</method> </method>
<method name="move_terrain"> <method name="move_terrain">
@ -270,13 +325,15 @@
<argument index="1" name="terrain_index" type="int" /> <argument index="1" name="terrain_index" type="int" />
<argument index="2" name="to_position" type="int" /> <argument index="2" name="to_position" type="int" />
<description> <description>
Moves the terrain at index [code]terrain_index[/code] for terrain set [code]terrain_set[/code] to the given position [code]to_position[/code] in the array. Also updates the atlas tiles accordingly.
</description> </description>
</method> </method>
<method name="move_terrain_set"> <method name="move_terrain_set">
<return type="void" /> <return type="void" />
<argument index="0" name="layer_index" type="int" /> <argument index="0" name="terrain_set" type="int" />
<argument index="1" name="to_position" type="int" /> <argument index="1" name="to_position" type="int" />
<description> <description>
Moves the terrain set at index [code]terrain_set[/code] to the given position [code]to_position[/code] in the array. Also updates the atlas tiles accordingly.
</description> </description>
</method> </method>
<method name="remove_alternative_level_tile_proxy"> <method name="remove_alternative_level_tile_proxy">
@ -285,6 +342,7 @@
<argument index="1" name="coords_from" type="Vector2i" /> <argument index="1" name="coords_from" type="Vector2i" />
<argument index="2" name="alternative_from" type="int" /> <argument index="2" name="alternative_from" type="int" />
<description> <description>
Removes an alternative-level proxy for the given identifiers.
</description> </description>
</method> </method>
<method name="remove_coords_level_tile_proxy"> <method name="remove_coords_level_tile_proxy">
@ -292,42 +350,49 @@
<argument index="0" name="source_from" type="int" /> <argument index="0" name="source_from" type="int" />
<argument index="1" name="coords_from" type="Vector2i" /> <argument index="1" name="coords_from" type="Vector2i" />
<description> <description>
Removes a coordinates-level proxy for the given identifiers.
</description> </description>
</method> </method>
<method name="remove_custom_data_layer"> <method name="remove_custom_data_layer">
<return type="void" /> <return type="void" />
<argument index="0" name="layer_index" type="int" /> <argument index="0" name="layer_index" type="int" />
<description> <description>
Removes the custom data layer at index [code]layer_index[/code]. Also updates the atlas tiles accordingly.
</description> </description>
</method> </method>
<method name="remove_navigation_layer"> <method name="remove_navigation_layer">
<return type="void" /> <return type="void" />
<argument index="0" name="layer_index" type="int" /> <argument index="0" name="layer_index" type="int" />
<description> <description>
Removes the navigation layer at index [code]layer_index[/code]. Also updates the atlas tiles accordingly.
</description> </description>
</method> </method>
<method name="remove_occlusion_layer"> <method name="remove_occlusion_layer">
<return type="void" /> <return type="void" />
<argument index="0" name="layer_index" type="int" /> <argument index="0" name="layer_index" type="int" />
<description> <description>
Removes the occlusion layer at index [code]layer_index[/code]. Also updates the atlas tiles accordingly.
</description> </description>
</method> </method>
<method name="remove_physics_layer"> <method name="remove_physics_layer">
<return type="void" /> <return type="void" />
<argument index="0" name="layer_index" type="int" /> <argument index="0" name="layer_index" type="int" />
<description> <description>
Removes the physics layer at index [code]layer_index[/code]. Also updates the atlas tiles accordingly.
</description> </description>
</method> </method>
<method name="remove_source"> <method name="remove_source">
<return type="void" /> <return type="void" />
<argument index="0" name="source_id" type="int" /> <argument index="0" name="source_id" type="int" />
<description> <description>
Removes the source with the given source ID.
</description> </description>
</method> </method>
<method name="remove_source_level_tile_proxy"> <method name="remove_source_level_tile_proxy">
<return type="void" /> <return type="void" />
<argument index="0" name="source_from" type="int" /> <argument index="0" name="source_from" type="int" />
<description> <description>
Removes a source-level tile proxy.
</description> </description>
</method> </method>
<method name="remove_terrain"> <method name="remove_terrain">
@ -335,12 +400,14 @@
<argument index="0" name="terrain_set" type="int" /> <argument index="0" name="terrain_set" type="int" />
<argument index="1" name="terrain_index" type="int" /> <argument index="1" name="terrain_index" type="int" />
<description> <description>
Removes the terrain at index [code]terrain_index[/code] in the given terrain set [code]terrain_set[/code]. Also updates the atlas tiles accordingly.
</description> </description>
</method> </method>
<method name="remove_terrain_set"> <method name="remove_terrain_set">
<return type="void" /> <return type="void" />
<argument index="0" name="layer_index" type="int" /> <argument index="0" name="terrain_set" type="int" />
<description> <description>
Removes the terrain set at index [code]terrain_set[/code]. Also updates the atlas tiles accordingly.
</description> </description>
</method> </method>
<method name="set_alternative_level_tile_proxy"> <method name="set_alternative_level_tile_proxy">
@ -352,6 +419,9 @@
<argument index="4" name="coords_to" type="Vector2i" /> <argument index="4" name="coords_to" type="Vector2i" />
<argument index="5" name="alternative_to" type="int" /> <argument index="5" name="alternative_to" type="int" />
<description> <description>
Create an alternative-level proxy for the given identifiers. A proxy will map set of tile identifiers to another set of identifiers.
This can be used to replace a tile in all TileMaps using this TileSet, as TileMap nodes will find and use the proxy's target tile when one is available.
Proxied tiles can be automatically replaced in TileMap nodes using the editor.
</description> </description>
</method> </method>
<method name="set_coords_level_tile_proxy"> <method name="set_coords_level_tile_proxy">
@ -361,6 +431,9 @@
<argument index="2" name="source_to" type="int" /> <argument index="2" name="source_to" type="int" />
<argument index="3" name="coords_to" type="Vector2i" /> <argument index="3" name="coords_to" type="Vector2i" />
<description> <description>
Creates a coordinates-level proxy for the given identifiers. A proxy will map set of tile identifiers to another set of identifiers. The alternative tile ID is kept the same when using coordinates-level proxies.
This can be used to replace a tile in all TileMaps using this TileSet, as TileMap nodes will find and use the proxy's target tile when one is available.
Proxied tiles can be automatically replaced in TileMap nodes using the editor.
</description> </description>
</method> </method>
<method name="set_navigation_layer_layers"> <method name="set_navigation_layer_layers">
@ -368,6 +441,7 @@
<argument index="0" name="layer_index" type="int" /> <argument index="0" name="layer_index" type="int" />
<argument index="1" name="layers" type="int" /> <argument index="1" name="layers" type="int" />
<description> <description>
Sets the navigation layers (as in the navigation server) for navigation regions is the given TileSet navigation layer.
</description> </description>
</method> </method>
<method name="set_occlusion_layer_light_mask"> <method name="set_occlusion_layer_light_mask">
@ -375,13 +449,15 @@
<argument index="0" name="layer_index" type="int" /> <argument index="0" name="layer_index" type="int" />
<argument index="1" name="light_mask" type="int" /> <argument index="1" name="light_mask" type="int" />
<description> <description>
Sets the occlusion layer (as in the rendering server) for occluders in the given TileSet occlusion layer.
</description> </description>
</method> </method>
<method name="set_occlusion_layer_sdf_collision"> <method name="set_occlusion_layer_sdf_collision">
<return type="void" /> <return type="void" />
<argument index="0" name="layer_index" type="int" /> <argument index="0" name="layer_index" type="int" />
<argument index="1" name="sdf_collision" type="int" /> <argument index="1" name="sdf_collision" type="bool" />
<description> <description>
Enables or disables sdf collision for occluders in the given TileSet occlusion layer.
</description> </description>
</method> </method>
<method name="set_physics_layer_collision_layer"> <method name="set_physics_layer_collision_layer">
@ -389,6 +465,7 @@
<argument index="0" name="layer_index" type="int" /> <argument index="0" name="layer_index" type="int" />
<argument index="1" name="layer" type="int" /> <argument index="1" name="layer" type="int" />
<description> <description>
Sets the physics layer (as in the physics server) for bodies in the given TileSet physics layer.
</description> </description>
</method> </method>
<method name="set_physics_layer_collision_mask"> <method name="set_physics_layer_collision_mask">
@ -396,6 +473,7 @@
<argument index="0" name="layer_index" type="int" /> <argument index="0" name="layer_index" type="int" />
<argument index="1" name="mask" type="int" /> <argument index="1" name="mask" type="int" />
<description> <description>
Sets the physics layer (as in the physics server) for bodies in the given TileSet physics layer.
</description> </description>
</method> </method>
<method name="set_physics_layer_physics_material"> <method name="set_physics_layer_physics_material">
@ -403,13 +481,15 @@
<argument index="0" name="layer_index" type="int" /> <argument index="0" name="layer_index" type="int" />
<argument index="1" name="physics_material" type="PhysicsMaterial" /> <argument index="1" name="physics_material" type="PhysicsMaterial" />
<description> <description>
Sets the physics material for bodies in the given TileSet physics layer.
</description> </description>
</method> </method>
<method name="set_source_id"> <method name="set_source_id">
<return type="void" /> <return type="void" />
<argument index="0" name="source_id" type="int" /> <argument index="0" name="source_id" type="int" />
<argument index="1" name="arg1" type="int" /> <argument index="1" name="new_source_id" type="int" />
<description> <description>
Changes a source's ID.
</description> </description>
</method> </method>
<method name="set_source_level_tile_proxy"> <method name="set_source_level_tile_proxy">
@ -417,6 +497,9 @@
<argument index="0" name="source_from" type="int" /> <argument index="0" name="source_from" type="int" />
<argument index="1" name="source_to" type="int" /> <argument index="1" name="source_to" type="int" />
<description> <description>
Creates a source-level proxy for the given source ID. A proxy will map set of tile identifiers to another set of identifiers. Both the atlac coordinates ID and the alternative tile ID are kept the same when using source-level proxies.
This can be used to replace a source in all TileMaps using this TileSet, as TileMap nodes will find and use the proxy's target source when one is available.
Proxied tiles can be automatically replaced in TileMap nodes using the editor.
</description> </description>
</method> </method>
<method name="set_terrain_color"> <method name="set_terrain_color">
@ -425,6 +508,7 @@
<argument index="1" name="terrain_index" type="int" /> <argument index="1" name="terrain_index" type="int" />
<argument index="2" name="color" type="Color" /> <argument index="2" name="color" type="Color" />
<description> <description>
Sets a terrain's color. This color is used for identifying the different terrains in the TileSet editor.
</description> </description>
</method> </method>
<method name="set_terrain_name"> <method name="set_terrain_name">
@ -433,6 +517,7 @@
<argument index="1" name="terrain_index" type="int" /> <argument index="1" name="terrain_index" type="int" />
<argument index="2" name="name" type="String" /> <argument index="2" name="name" type="String" />
<description> <description>
Sets a terrain's name.
</description> </description>
</method> </method>
<method name="set_terrain_set_mode"> <method name="set_terrain_set_mode">
@ -440,86 +525,120 @@
<argument index="0" name="terrain_set" type="int" /> <argument index="0" name="terrain_set" type="int" />
<argument index="1" name="mode" type="int" enum="TileSet.TerrainMode" /> <argument index="1" name="mode" type="int" enum="TileSet.TerrainMode" />
<description> <description>
Sets a terrain mode. Each mode determines which bits of a tile shape is used to match the neighbouring tiles' terrains.
</description> </description>
</method> </method>
</methods> </methods>
<members> <members>
<member name="tile_layout" type="int" setter="set_tile_layout" getter="get_tile_layout" enum="TileSet.TileLayout" default="0"> <member name="tile_layout" type="int" setter="set_tile_layout" getter="get_tile_layout" enum="TileSet.TileLayout" default="0">
For all half-offset shapes (Isometric, Hexagonal and Half-Offset square), changes the way tiles are indexed in the TileMap grid.
</member> </member>
<member name="tile_offset_axis" type="int" setter="set_tile_offset_axis" getter="get_tile_offset_axis" enum="TileSet.TileOffsetAxis" default="0"> <member name="tile_offset_axis" type="int" setter="set_tile_offset_axis" getter="get_tile_offset_axis" enum="TileSet.TileOffsetAxis" default="0">
For all half-offset shapes (Isometric, Hexagonal and Half-Offset square), determines the offset axis.
</member> </member>
<member name="tile_shape" type="int" setter="set_tile_shape" getter="get_tile_shape" enum="TileSet.TileShape" default="0"> <member name="tile_shape" type="int" setter="set_tile_shape" getter="get_tile_shape" enum="TileSet.TileShape" default="0">
The tile shape.
</member> </member>
<member name="tile_size" type="Vector2i" setter="set_tile_size" getter="get_tile_size" default="Vector2i(16, 16)"> <member name="tile_size" type="Vector2i" setter="set_tile_size" getter="get_tile_size" default="Vector2i(16, 16)">
The tile size, in pixels. For all tile shapes, this size corresponds to the encompassing rectangle of the tile shape. This is thus the minimal cell size required in an atlas.
</member> </member>
<member name="uv_clipping" type="bool" setter="set_uv_clipping" getter="is_uv_clipping" default="false"> <member name="uv_clipping" type="bool" setter="set_uv_clipping" getter="is_uv_clipping" default="false">
Enables/Disable uv clipping when rendering the tiles.
</member> </member>
</members> </members>
<constants> <constants>
<constant name="TILE_SHAPE_SQUARE" value="0" enum="TileShape"> <constant name="TILE_SHAPE_SQUARE" value="0" enum="TileShape">
Orthogonal orientation mode. Rectangular tile shape.
</constant> </constant>
<constant name="TILE_SHAPE_ISOMETRIC" value="1" enum="TileShape"> <constant name="TILE_SHAPE_ISOMETRIC" value="1" enum="TileShape">
Isometric orientation mode. Diamond tile shape (for isometric look).
</constant> </constant>
<constant name="TILE_SHAPE_HALF_OFFSET_SQUARE" value="2" enum="TileShape"> <constant name="TILE_SHAPE_HALF_OFFSET_SQUARE" value="2" enum="TileShape">
Rectangular tile shape with one row/colum out of two offset by half a tile.
</constant> </constant>
<constant name="TILE_SHAPE_HEXAGON" value="3" enum="TileShape"> <constant name="TILE_SHAPE_HEXAGON" value="3" enum="TileShape">
Hexagon orientation mode. Hexagonal tile shape.
</constant> </constant>
<constant name="TILE_LAYOUT_STACKED" value="0" enum="TileLayout"> <constant name="TILE_LAYOUT_STACKED" value="0" enum="TileLayout">
Tile coordinates layout where both axis stay consistent with their respective local horizontal and vertical axis.
</constant> </constant>
<constant name="TILE_LAYOUT_STACKED_OFFSET" value="1" enum="TileLayout"> <constant name="TILE_LAYOUT_STACKED_OFFSET" value="1" enum="TileLayout">
Same as [code]TILE_LAYOUT_STAKED[/code], but the first half-offset is negative instead of positive.
</constant> </constant>
<constant name="TILE_LAYOUT_STAIRS_RIGHT" value="2" enum="TileLayout"> <constant name="TILE_LAYOUT_STAIRS_RIGHT" value="2" enum="TileLayout">
Tile coordinates layout where the horizontal axis stay horizontal, and the vertical one goes down-right.
</constant> </constant>
<constant name="TILE_LAYOUT_STAIRS_DOWN" value="3" enum="TileLayout"> <constant name="TILE_LAYOUT_STAIRS_DOWN" value="3" enum="TileLayout">
Tile coordinates layout where the vertical axis stay vertical, and the horizontal one goes down-right.
</constant> </constant>
<constant name="TILE_LAYOUT_DIAMOND_RIGHT" value="4" enum="TileLayout"> <constant name="TILE_LAYOUT_DIAMOND_RIGHT" value="4" enum="TileLayout">
Tile coordinates layout where the horizontal axis goes up-right, and the vertical one goes down-right.
</constant> </constant>
<constant name="TILE_LAYOUT_DIAMOND_DOWN" value="5" enum="TileLayout"> <constant name="TILE_LAYOUT_DIAMOND_DOWN" value="5" enum="TileLayout">
Tile coordinates layout where the horizontal axis goes down-right, and the vertical one goes down-left.
</constant> </constant>
<constant name="TILE_OFFSET_AXIS_HORIZONTAL" value="0" enum="TileOffsetAxis"> <constant name="TILE_OFFSET_AXIS_HORIZONTAL" value="0" enum="TileOffsetAxis">
Horizontal half-offset.
</constant> </constant>
<constant name="TILE_OFFSET_AXIS_VERTICAL" value="1" enum="TileOffsetAxis"> <constant name="TILE_OFFSET_AXIS_VERTICAL" value="1" enum="TileOffsetAxis">
Vertical half-offset.
</constant> </constant>
<constant name="CELL_NEIGHBOR_RIGHT_SIDE" value="0" enum="CellNeighbor"> <constant name="CELL_NEIGHBOR_RIGHT_SIDE" value="0" enum="CellNeighbor">
Neighbor on the right side.
</constant> </constant>
<constant name="CELL_NEIGHBOR_RIGHT_CORNER" value="1" enum="CellNeighbor"> <constant name="CELL_NEIGHBOR_RIGHT_CORNER" value="1" enum="CellNeighbor">
Neighbor in the right corner.
</constant> </constant>
<constant name="CELL_NEIGHBOR_BOTTOM_RIGHT_SIDE" value="2" enum="CellNeighbor"> <constant name="CELL_NEIGHBOR_BOTTOM_RIGHT_SIDE" value="2" enum="CellNeighbor">
Neighbor on the bottom right side.
</constant> </constant>
<constant name="CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER" value="3" enum="CellNeighbor"> <constant name="CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER" value="3" enum="CellNeighbor">
Neighbor in the bottom right corner.
</constant> </constant>
<constant name="CELL_NEIGHBOR_BOTTOM_SIDE" value="4" enum="CellNeighbor"> <constant name="CELL_NEIGHBOR_BOTTOM_SIDE" value="4" enum="CellNeighbor">
Neighbor on the bottom side.
</constant> </constant>
<constant name="CELL_NEIGHBOR_BOTTOM_CORNER" value="5" enum="CellNeighbor"> <constant name="CELL_NEIGHBOR_BOTTOM_CORNER" value="5" enum="CellNeighbor">
Neighbor in the bottom corner.
</constant> </constant>
<constant name="CELL_NEIGHBOR_BOTTOM_LEFT_SIDE" value="6" enum="CellNeighbor"> <constant name="CELL_NEIGHBOR_BOTTOM_LEFT_SIDE" value="6" enum="CellNeighbor">
Neighbor on the bottom left side.
</constant> </constant>
<constant name="CELL_NEIGHBOR_BOTTOM_LEFT_CORNER" value="7" enum="CellNeighbor"> <constant name="CELL_NEIGHBOR_BOTTOM_LEFT_CORNER" value="7" enum="CellNeighbor">
Neighbor in the bottom left corner.
</constant> </constant>
<constant name="CELL_NEIGHBOR_LEFT_SIDE" value="8" enum="CellNeighbor"> <constant name="CELL_NEIGHBOR_LEFT_SIDE" value="8" enum="CellNeighbor">
Neighbor on the left side.
</constant> </constant>
<constant name="CELL_NEIGHBOR_LEFT_CORNER" value="9" enum="CellNeighbor"> <constant name="CELL_NEIGHBOR_LEFT_CORNER" value="9" enum="CellNeighbor">
Neighbor in the left corner.
</constant> </constant>
<constant name="CELL_NEIGHBOR_TOP_LEFT_SIDE" value="10" enum="CellNeighbor"> <constant name="CELL_NEIGHBOR_TOP_LEFT_SIDE" value="10" enum="CellNeighbor">
Neighbor on the top left side.
</constant> </constant>
<constant name="CELL_NEIGHBOR_TOP_LEFT_CORNER" value="11" enum="CellNeighbor"> <constant name="CELL_NEIGHBOR_TOP_LEFT_CORNER" value="11" enum="CellNeighbor">
Neighbor in the top left corner.
</constant> </constant>
<constant name="CELL_NEIGHBOR_TOP_SIDE" value="12" enum="CellNeighbor"> <constant name="CELL_NEIGHBOR_TOP_SIDE" value="12" enum="CellNeighbor">
Neighbor on the top side.
</constant> </constant>
<constant name="CELL_NEIGHBOR_TOP_CORNER" value="13" enum="CellNeighbor"> <constant name="CELL_NEIGHBOR_TOP_CORNER" value="13" enum="CellNeighbor">
Neighbor in the top corner.
</constant> </constant>
<constant name="CELL_NEIGHBOR_TOP_RIGHT_SIDE" value="14" enum="CellNeighbor"> <constant name="CELL_NEIGHBOR_TOP_RIGHT_SIDE" value="14" enum="CellNeighbor">
Neighbor on the top right side.
</constant> </constant>
<constant name="CELL_NEIGHBOR_TOP_RIGHT_CORNER" value="15" enum="CellNeighbor"> <constant name="CELL_NEIGHBOR_TOP_RIGHT_CORNER" value="15" enum="CellNeighbor">
Neighbor in the top right corner.
</constant> </constant>
<constant name="TERRAIN_MODE_MATCH_CORNERS_AND_SIDES" value="0" enum="TerrainMode"> <constant name="TERRAIN_MODE_MATCH_CORNERS_AND_SIDES" value="0" enum="TerrainMode">
Requires both corners and side to match with neighboring tiles' terrains.
</constant> </constant>
<constant name="TERRAIN_MODE_MATCH_CORNERS" value="1" enum="TerrainMode"> <constant name="TERRAIN_MODE_MATCH_CORNERS" value="1" enum="TerrainMode">
Requires corners to match with neighboring tiles' terrains.
</constant> </constant>
<constant name="TERRAIN_MODE_MATCH_SIDES" value="2" enum="TerrainMode"> <constant name="TERRAIN_MODE_MATCH_SIDES" value="2" enum="TerrainMode">
Requires sides to match with neighboring tiles' terrains.
</constant> </constant>
</constants> </constants>
</class> </class>

View File

@ -1,8 +1,16 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="TileSetAtlasSource" inherits="TileSetSource" version="4.0"> <class name="TileSetAtlasSource" inherits="TileSetSource" version="4.0">
<brief_description> <brief_description>
Exposes a 2D atlas texture as a set of tiles for a [TileSet] resource.
</brief_description> </brief_description>
<description> <description>
An atlas is a grid of tiles laid out on a texture. Each tile in the grid must be exposed using [method create_tile]. Those tiles are then indexed using their coordinates in the grid.
Each tile can also have a size in the grid coordinates, making it more or less cells in the atlas.
Alternatives version of a tile can be created using [method create_alternative_tile], which are then indexed using an alternative ID. The main tile (the one in the grid), is accessed with an alternative ID equal to 0.
Each tile alternate has a set of properties that is defined by the source's [TileSet] layers. Those properties are stored in a TileData object that can be accessed and modified using [method get_tile_data].
As TileData properties are stored directly in the TileSetAtlasSource resource, their properties might also be set using [code]TileSetAtlasSource.set("&lt;coords_x&gt;:&lt;coords_y&gt;/&lt;alternative_id&gt;/&lt;tile_data_property&gt;")[/code].
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -13,11 +21,14 @@
<argument index="1" name="new_atlas_coords" type="Vector2i" default="Vector2i(-1, -1)" /> <argument index="1" name="new_atlas_coords" type="Vector2i" default="Vector2i(-1, -1)" />
<argument index="2" name="new_size" type="Vector2i" default="Vector2i(-1, -1)" /> <argument index="2" name="new_size" type="Vector2i" default="Vector2i(-1, -1)" />
<description> <description>
Returns true if the tile at the [code]atlas_coords[/code] coordinates can be moved to the [code]new_atlas_coords[/code] coordinates with the [code]new_size[/code] size. This functions returns false if a tile is already present in the given area, or if this area is outside the atlas boundaries.
If [code]new_atlas_coords[/code] is [code]Vector2i(-1, -1)[/code], keeps the tile's coordinates. If [code]new_size[/code] is [code]Vector2i(-1, -1)[/code], keeps the tile's size.
</description> </description>
</method> </method>
<method name="clear_tiles_outside_texture"> <method name="clear_tiles_outside_texture">
<return type="void" /> <return type="void" />
<description> <description>
Clears all tiles that are defined outside the texture boundaries.
</description> </description>
</method> </method>
<method name="create_alternative_tile"> <method name="create_alternative_tile">
@ -25,6 +36,8 @@
<argument index="0" name="atlas_coords" type="Vector2i" /> <argument index="0" name="atlas_coords" type="Vector2i" />
<argument index="1" name="alternative_id_override" type="int" default="-1" /> <argument index="1" name="alternative_id_override" type="int" default="-1" />
<description> <description>
Creates an alternative tile for the tile at coords [code]atlas_coords[/code]. If [code]alternative_id_override[/code] is -1, give it an automatically generated unique ID, or assigns it the given ID otherwise.
Returns the new alternative identifier, or -1 if the alternative could not be created with a provided [code]alternative_id_override[/code].
</description> </description>
</method> </method>
<method name="create_tile"> <method name="create_tile">
@ -32,84 +45,55 @@
<argument index="0" name="atlas_coords" type="Vector2i" /> <argument index="0" name="atlas_coords" type="Vector2i" />
<argument index="1" name="size" type="Vector2i" default="Vector2i(1, 1)" /> <argument index="1" name="size" type="Vector2i" default="Vector2i(1, 1)" />
<description> <description>
</description> Creates a new tile at coords [code]atlas_coords[/code] with size [code]size[/code].
</method>
<method name="get_alternative_tile_id" qualifiers="const">
<return type="int" />
<argument index="0" name="atlas_coords" type="Vector2i" />
<argument index="1" name="index" type="int" />
<description>
</description>
</method>
<method name="get_alternative_tiles_count" qualifiers="const">
<return type="int" />
<argument index="0" name="atlas_coords" type="Vector2i" />
<description>
</description> </description>
</method> </method>
<method name="get_atlas_grid_size" qualifiers="const"> <method name="get_atlas_grid_size" qualifiers="const">
<return type="Vector2i" /> <return type="Vector2i" />
<description> <description>
Returns the atlas grid size, which depends on how many tiles can fit in the texture. It thus depends on the Texture's size, the atlas [code]margins[/code] the tiles' [code]texture_region_size[/code].
</description> </description>
</method> </method>
<method name="get_next_alternative_tile_id" qualifiers="const"> <method name="get_next_alternative_tile_id" qualifiers="const">
<return type="int" /> <return type="int" />
<argument index="0" name="atlas_coords" type="Vector2i" /> <argument index="0" name="atlas_coords" type="Vector2i" />
<description> <description>
Returns the alternative ID a following call to [method create_alternative_tile] would return.
</description> </description>
</method> </method>
<method name="get_tile_at_coords" qualifiers="const"> <method name="get_tile_at_coords" qualifiers="const">
<return type="Vector2i" /> <return type="Vector2i" />
<argument index="0" name="atlas_coords" type="Vector2i" /> <argument index="0" name="atlas_coords" type="Vector2i" />
<description> <description>
If there is a tile covering the [code]atlas_coords[/code] coordinates, returns the top-left coordinates of the tile (thus its coordinate ID). Returns [code]Vector2i(-1, -1)[/code] otherwise.
</description> </description>
</method> </method>
<method name="get_tile_data" qualifiers="const"> <method name="get_tile_data" qualifiers="const">
<return type="Object" /> <return type="Object" />
<argument index="0" name="atlas_coords" type="Vector2i" /> <argument index="0" name="atlas_coords" type="Vector2i" />
<argument index="1" name="index" type="int" /> <argument index="1" name="alternative_tile" type="int" />
<description>
</description>
</method>
<method name="get_tile_id" qualifiers="const">
<return type="Vector2i" />
<argument index="0" name="index" type="int" />
<description> <description>
Returns the [TileData] object for the given atlas coordinates and alternative ID.
</description> </description>
</method> </method>
<method name="get_tile_size_in_atlas" qualifiers="const"> <method name="get_tile_size_in_atlas" qualifiers="const">
<return type="Vector2i" /> <return type="Vector2i" />
<argument index="0" name="atlas_coords" type="Vector2i" /> <argument index="0" name="atlas_coords" type="Vector2i" />
<description> <description>
Returns the size of the tile (in the grid coordinates system) at coordinates [code]atlas_coords[/code].
</description> </description>
</method> </method>
<method name="get_tile_texture_region" qualifiers="const"> <method name="get_tile_texture_region" qualifiers="const">
<return type="Rect2i" /> <return type="Rect2i" />
<argument index="0" name="atlas_coords" type="Vector2i" /> <argument index="0" name="atlas_coords" type="Vector2i" />
<description> <description>
</description> Returns a tile's texture region in the atlas texture.
</method>
<method name="get_tiles_count" qualifiers="const">
<return type="int" />
<description>
</description>
</method>
<method name="has_alternative_tile" qualifiers="const">
<return type="bool" />
<argument index="0" name="atlas_coords" type="Vector2i" />
<argument index="1" name="alternative_tile" type="int" />
<description>
</description>
</method>
<method name="has_tile" qualifiers="const">
<return type="bool" />
<argument index="0" name="atlas_coords" type="Vector2i" />
<description>
</description> </description>
</method> </method>
<method name="has_tiles_outside_texture"> <method name="has_tiles_outside_texture">
<return type="bool" /> <return type="bool" />
<description> <description>
Returns if this atlas has tiles outside of its texture.
</description> </description>
</method> </method>
<method name="move_tile_in_atlas"> <method name="move_tile_in_atlas">
@ -118,6 +102,9 @@
<argument index="1" name="new_atlas_coords" type="Vector2i" default="Vector2i(-1, -1)" /> <argument index="1" name="new_atlas_coords" type="Vector2i" default="Vector2i(-1, -1)" />
<argument index="2" name="new_size" type="Vector2i" default="Vector2i(-1, -1)" /> <argument index="2" name="new_size" type="Vector2i" default="Vector2i(-1, -1)" />
<description> <description>
Move the tile and its alternatives at the [code]atlas_coords[/code] coordinates to the [code]new_atlas_coords[/code] coordinates with the [code]new_size[/code] size. This functions will fail if a tile is already present in the given area.
If [code]new_atlas_coords[/code] is [code]Vector2i(-1, -1)[/code], keeps the tile's coordinates. If [code]new_size[/code] is [code]Vector2i(-1, -1)[/code], keeps the tile's size.
To avoid an error, first check if a move is possible using [method can_move_tile_in_atlas].
</description> </description>
</method> </method>
<method name="remove_alternative_tile"> <method name="remove_alternative_tile">
@ -125,12 +112,15 @@
<argument index="0" name="atlas_coords" type="Vector2i" /> <argument index="0" name="atlas_coords" type="Vector2i" />
<argument index="1" name="alternative_tile" type="int" /> <argument index="1" name="alternative_tile" type="int" />
<description> <description>
Remove a tile's alternative with alternative ID [code]alternative_tile[/code].
Calling this function with [code]alternative_tile[/code] equals to 0 will fail, as the base tile alternative cannot be removed.
</description> </description>
</method> </method>
<method name="remove_tile"> <method name="remove_tile">
<return type="void" /> <return type="void" />
<argument index="0" name="atlas_coords" type="Vector2i" /> <argument index="0" name="atlas_coords" type="Vector2i" />
<description> <description>
Remove a tile and its alternative at coordinates [code]atlas_coords[/code].
</description> </description>
</method> </method>
<method name="set_alternative_tile_id"> <method name="set_alternative_tile_id">
@ -139,17 +129,23 @@
<argument index="1" name="alternative_tile" type="int" /> <argument index="1" name="alternative_tile" type="int" />
<argument index="2" name="new_id" type="int" /> <argument index="2" name="new_id" type="int" />
<description> <description>
Change a tile's alternative ID from [code]alternative_tile[/code] to [code]new_id[/code].
Calling this function with [code]alternative_id[/code] equals to 0 will fail, as the base tile alternative cannot be moved.
</description> </description>
</method> </method>
</methods> </methods>
<members> <members>
<member name="margins" type="Vector2i" setter="set_margins" getter="get_margins" default="Vector2i(0, 0)"> <member name="margins" type="Vector2i" setter="set_margins" getter="get_margins" default="Vector2i(0, 0)">
Margins, in pixels, to offset the origin of the grid in the texture.
</member> </member>
<member name="separation" type="Vector2i" setter="set_separation" getter="get_separation" default="Vector2i(0, 0)"> <member name="separation" type="Vector2i" setter="set_separation" getter="get_separation" default="Vector2i(0, 0)">
Separation, in pixels, between each tile texture region of the grid.
</member> </member>
<member name="texture" type="Texture2D" setter="set_texture" getter="get_texture"> <member name="texture" type="Texture2D" setter="set_texture" getter="get_texture">
The atlas texture.
</member> </member>
<member name="tile_size" type="Vector2i" setter="set_texture_region_size" getter="get_texture_region_size" default="Vector2i(16, 16)"> <member name="texture_region_size" type="Vector2i" setter="set_texture_region_size" getter="get_texture_region_size" default="Vector2i(16, 16)">
The base tile size in the texture (in pixel). This size must be bigger than the TileSet's [code]tile_size[/code] value.
</member> </member>
</members> </members>
<constants> <constants>

View File

@ -1,8 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="TileSetScenesCollectionSource" inherits="TileSetSource" version="4.0"> <class name="TileSetScenesCollectionSource" inherits="TileSetSource" version="4.0">
<brief_description> <brief_description>
Exposes a set of scenes as tiles for a [TileSet] resource.
</brief_description> </brief_description>
<description> <description>
When placed on a [TileMap], tiles from [TileSetScenesCollectionSource] will automatically instanciate an assiciated scene at the cell's position in the TileMap.
Scenes are instanciated as children of the [TileMap] when it enters the tree. If you add/remove a scene tile in the [TileMap] that is already inside the tree, the [TileMap] will automatically instanciate/free the scene accordingly.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -12,83 +15,55 @@
<argument index="0" name="packed_scene" type="PackedScene" /> <argument index="0" name="packed_scene" type="PackedScene" />
<argument index="1" name="id_override" type="int" default="-1" /> <argument index="1" name="id_override" type="int" default="-1" />
<description> <description>
</description> Creates a scene-based tile out of the given scene.
</method> Returns a newly generated unique ID.
<method name="get_alternative_tile_id" qualifiers="const">
<return type="int" />
<argument index="0" name="atlas_coords" type="Vector2i" />
<argument index="1" name="index" type="int" />
<description>
</description>
</method>
<method name="get_alternative_tiles_count" qualifiers="const">
<return type="int" />
<argument index="0" name="atlas_coords" type="Vector2i" />
<description>
</description> </description>
</method> </method>
<method name="get_next_scene_tile_id" qualifiers="const"> <method name="get_next_scene_tile_id" qualifiers="const">
<return type="int" /> <return type="int" />
<description> <description>
Returns the scene ID a following call to [method create_scene_tile] would return.
</description> </description>
</method> </method>
<method name="get_scene_tile_display_placeholder" qualifiers="const"> <method name="get_scene_tile_display_placeholder" qualifiers="const">
<return type="bool" /> <return type="bool" />
<argument index="0" name="id" type="int" /> <argument index="0" name="id" type="int" />
<description> <description>
Returns whether the scene tile with id [code]id[/code] displays a placeholder in the editor.
</description> </description>
</method> </method>
<method name="get_scene_tile_id"> <method name="get_scene_tile_id">
<return type="int" /> <return type="int" />
<argument index="0" name="index" type="int" /> <argument index="0" name="index" type="int" />
<description> <description>
Returns the scene tile ID of the scene tile at index [code]index[/code].
</description> </description>
</method> </method>
<method name="get_scene_tile_scene" qualifiers="const"> <method name="get_scene_tile_scene" qualifiers="const">
<return type="PackedScene" /> <return type="PackedScene" />
<argument index="0" name="id" type="int" /> <argument index="0" name="id" type="int" />
<description> <description>
Returns the [PackedScene] resource of scene tile with id [code]id[/code].
</description> </description>
</method> </method>
<method name="get_scene_tiles_count"> <method name="get_scene_tiles_count">
<return type="int" /> <return type="int" />
<description> <description>
</description> Returns the number or scene tiles this TileSet source has.
</method>
<method name="get_tile_id" qualifiers="const">
<return type="Vector2i" />
<argument index="0" name="index" type="int" />
<description>
</description>
</method>
<method name="get_tiles_count" qualifiers="const">
<return type="int" />
<description>
</description>
</method>
<method name="has_alternative_tile" qualifiers="const">
<return type="bool" />
<argument index="0" name="atlas_coords" type="Vector2i" />
<argument index="1" name="alternative_tile" type="int" />
<description>
</description> </description>
</method> </method>
<method name="has_scene_tile_id"> <method name="has_scene_tile_id">
<return type="bool" /> <return type="bool" />
<argument index="0" name="id" type="int" /> <argument index="0" name="id" type="int" />
<description> <description>
</description> Returns whether this TileSet source has a scene tile with id [code]id[/code].
</method>
<method name="has_tile" qualifiers="const">
<return type="bool" />
<argument index="0" name="atlas_coords" type="Vector2i" />
<description>
</description> </description>
</method> </method>
<method name="remove_scene_tile"> <method name="remove_scene_tile">
<return type="void" /> <return type="void" />
<argument index="0" name="id" type="int" /> <argument index="0" name="id" type="int" />
<description> <description>
Remove the scene tile with id [code]id[/code].
</description> </description>
</method> </method>
<method name="set_scene_tile_display_placeholder"> <method name="set_scene_tile_display_placeholder">
@ -96,6 +71,7 @@
<argument index="0" name="id" type="int" /> <argument index="0" name="id" type="int" />
<argument index="1" name="display_placeholder" type="bool" /> <argument index="1" name="display_placeholder" type="bool" />
<description> <description>
Sets whether or not the scene tile with id [code]id[/code] should display a placeholder in the editor. This might be useful for scenes that are not visible.
</description> </description>
</method> </method>
<method name="set_scene_tile_id"> <method name="set_scene_tile_id">
@ -103,6 +79,7 @@
<argument index="0" name="id" type="int" /> <argument index="0" name="id" type="int" />
<argument index="1" name="new_id" type="int" /> <argument index="1" name="new_id" type="int" />
<description> <description>
Changes a scene tile's ID from [code]id[/code] to [code]new_id[/code]. This will fail if there is already a tile with a ID equal to [code]new_id[/code].
</description> </description>
</method> </method>
<method name="set_scene_tile_scene"> <method name="set_scene_tile_scene">
@ -110,6 +87,7 @@
<argument index="0" name="id" type="int" /> <argument index="0" name="id" type="int" />
<argument index="1" name="packed_scene" type="PackedScene" /> <argument index="1" name="packed_scene" type="PackedScene" />
<description> <description>
Assigns a [PackedScene] resource to the scene tile with id [code]id[/code]. This will fail if the scene does not extend CanvasItem, as positionning properties are needed to place the scene on the TileMap.
</description> </description>
</method> </method>
</methods> </methods>

View File

@ -1,12 +1,63 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="TileSetSource" inherits="Resource" version="4.0"> <class name="TileSetSource" inherits="Resource" version="4.0">
<brief_description> <brief_description>
Exposes a set of tiles for a [TileSet] resource.
</brief_description> </brief_description>
<description> <description>
Exposes a set of tiles for a [TileSet] resource.
Tiles in a source are indexed with two IDs, coordinates ID (of type Vector2i) and an alternative ID (of type int), named according to their use in the [TileSetAtlasSource] class.
Depending on the TileSet source type, those IDs might have restrictions on their values, this is why the base [TileSetSource] class only exposes getters for them.
You can iterate over all tiles exposed by a TileSetSource by first iterating over coordinates IDs using [method get_tiles_count] and [method get_tile_id], then over alternative IDs using [method get_alternative_tiles_count] and [method get_alternative_tile_id].
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
<methods> <methods>
<method name="get_alternative_tile_id" qualifiers="const">
<return type="int" />
<argument index="0" name="atlas_coords" type="Vector2i" />
<argument index="1" name="index" type="int" />
<description>
Returns the alternative ID for the tile with coordinates ID [code]atlas_coords[/code] at index [code]index[/code].
</description>
</method>
<method name="get_alternative_tiles_count" qualifiers="const">
<return type="int" />
<argument index="0" name="atlas_coords" type="Vector2i" />
<description>
Returns the number of alternatives tiles for the coordinates ID [code]atlas_coords[/code].
For [TileSetAtlasSource], this always return at least 1, as the base tile with ID 0 is always part of the alternatives list.
Returns -1 if there is not tile at the given coords.
</description>
</method>
<method name="get_tile_id" qualifiers="const">
<return type="Vector2i" />
<argument index="0" name="index" type="int" />
<description>
Returns the tile coordinates ID of the tile with index [code]index[/code].
</description>
</method>
<method name="get_tiles_count" qualifiers="const">
<return type="int" />
<description>
Returns how many tiles this atlas source defines (not including alternative tiles).
</description>
</method>
<method name="has_alternative_tile" qualifiers="const">
<return type="bool" />
<argument index="0" name="atlas_coords" type="Vector2i" />
<argument index="1" name="alternative_tile" type="int" />
<description>
Returns if the base tile at coordinates [code]atlas_coords[/code] has an alternative with ID [code]alternative_tile[/code].
</description>
</method>
<method name="has_tile" qualifiers="const">
<return type="bool" />
<argument index="0" name="atlas_coords" type="Vector2i" />
<description>
Returns if this atlas has a tile with coordinates ID [code]atlas_coordinates[/code].
</description>
</method>
</methods> </methods>
<constants> <constants>
</constants> </constants>

View File

@ -236,6 +236,8 @@ Vector2i TileMap::transform_coords_layout(Vector2i p_coords, TileSet::TileOffset
} }
int TileMap::get_effective_quadrant_size(int p_layer) const { int TileMap::get_effective_quadrant_size(int p_layer) const {
ERR_FAIL_INDEX_V(p_layer, (int)layers.size(), 1);
// When using YSort, the quadrant size is reduced to 1 to have one CanvasItem per quadrant // When using YSort, the quadrant size is reduced to 1 to have one CanvasItem per quadrant
if (is_y_sort_enabled() && layers[p_layer].y_sort_enabled) { if (is_y_sort_enabled() && layers[p_layer].y_sort_enabled) {
return 1; return 1;
@ -815,7 +817,7 @@ void TileMap::_rendering_update_dirty_quadrants(SelfList<TileMapQuadrant>::List
if (atlas_source) { if (atlas_source) {
// Get the tile data. // Get the tile data.
TileData *tile_data = Object::cast_to<TileData>(atlas_source->get_tile_data(c.get_atlas_coords(), c.alternative_tile)); TileData *tile_data = Object::cast_to<TileData>(atlas_source->get_tile_data(c.get_atlas_coords(), c.alternative_tile));
Ref<ShaderMaterial> mat = tile_data->tile_get_material(); Ref<ShaderMaterial> mat = tile_data->get_material();
int z_index = tile_data->get_z_index(); int z_index = tile_data->get_z_index();
// Quandrant pos. // Quandrant pos.
@ -2931,9 +2933,9 @@ void TileMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_quadrant_size"), &TileMap::get_quadrant_size); ClassDB::bind_method(D_METHOD("get_quadrant_size"), &TileMap::get_quadrant_size);
ClassDB::bind_method(D_METHOD("get_layers_count"), &TileMap::get_layers_count); ClassDB::bind_method(D_METHOD("get_layers_count"), &TileMap::get_layers_count);
ClassDB::bind_method(D_METHOD("add_layer"), &TileMap::add_layer); ClassDB::bind_method(D_METHOD("add_layer", "to_position"), &TileMap::add_layer);
ClassDB::bind_method(D_METHOD("move_layer"), &TileMap::move_layer); ClassDB::bind_method(D_METHOD("move_layer", "layer", "to_position"), &TileMap::move_layer);
ClassDB::bind_method(D_METHOD("remove_layer"), &TileMap::remove_layer); ClassDB::bind_method(D_METHOD("remove_layer", "layer"), &TileMap::remove_layer);
ClassDB::bind_method(D_METHOD("set_layer_name", "layer", "name"), &TileMap::set_layer_name); ClassDB::bind_method(D_METHOD("set_layer_name", "layer", "name"), &TileMap::set_layer_name);
ClassDB::bind_method(D_METHOD("get_layer_name", "layer"), &TileMap::get_layer_name); ClassDB::bind_method(D_METHOD("get_layer_name", "layer"), &TileMap::get_layer_name);
ClassDB::bind_method(D_METHOD("set_layer_enabled", "layer", "enabled"), &TileMap::set_layer_enabled); ClassDB::bind_method(D_METHOD("set_layer_enabled", "layer", "enabled"), &TileMap::set_layer_enabled);
@ -2943,7 +2945,7 @@ void TileMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_layer_y_sort_origin", "layer", "y_sort_origin"), &TileMap::set_layer_y_sort_origin); ClassDB::bind_method(D_METHOD("set_layer_y_sort_origin", "layer", "y_sort_origin"), &TileMap::set_layer_y_sort_origin);
ClassDB::bind_method(D_METHOD("get_layer_y_sort_origin", "layer"), &TileMap::get_layer_y_sort_origin); ClassDB::bind_method(D_METHOD("get_layer_y_sort_origin", "layer"), &TileMap::get_layer_y_sort_origin);
ClassDB::bind_method(D_METHOD("set_layer_z_index", "layer", "z_index"), &TileMap::set_layer_z_index); ClassDB::bind_method(D_METHOD("set_layer_z_index", "layer", "z_index"), &TileMap::set_layer_z_index);
ClassDB::bind_method(D_METHOD("get_layer_z_indexd", "layer"), &TileMap::get_layer_z_index); ClassDB::bind_method(D_METHOD("get_layer_z_index", "layer"), &TileMap::get_layer_z_index);
ClassDB::bind_method(D_METHOD("set_collision_visibility_mode", "collision_visibility_mode"), &TileMap::set_collision_visibility_mode); ClassDB::bind_method(D_METHOD("set_collision_visibility_mode", "collision_visibility_mode"), &TileMap::set_collision_visibility_mode);
ClassDB::bind_method(D_METHOD("get_collision_visibility_mode"), &TileMap::get_collision_visibility_mode); ClassDB::bind_method(D_METHOD("get_collision_visibility_mode"), &TileMap::get_collision_visibility_mode);

View File

@ -257,7 +257,7 @@ int TileSet::get_occlusion_layer_light_mask(int p_layer_index) const {
return occlusion_layers[p_layer_index].light_mask; return occlusion_layers[p_layer_index].light_mask;
} }
void TileSet::set_occlusion_layer_sdf_collision(int p_layer_index, int p_sdf_collision) { void TileSet::set_occlusion_layer_sdf_collision(int p_layer_index, bool p_sdf_collision) {
ERR_FAIL_INDEX(p_layer_index, occlusion_layers.size()); ERR_FAIL_INDEX(p_layer_index, occlusion_layers.size());
occlusion_layers.write[p_layer_index].sdf_collision = p_sdf_collision; occlusion_layers.write[p_layer_index].sdf_collision = p_sdf_collision;
emit_changed(); emit_changed();
@ -1966,7 +1966,7 @@ void TileSet::_compatibility_conversion() {
tile_data->set_flip_h(flip_h); tile_data->set_flip_h(flip_h);
tile_data->set_flip_v(flip_v); tile_data->set_flip_v(flip_v);
tile_data->set_transpose(transpose); tile_data->set_transpose(transpose);
tile_data->tile_set_material(ctd->material); tile_data->set_material(ctd->material);
tile_data->set_modulate(ctd->modulate); tile_data->set_modulate(ctd->modulate);
tile_data->set_z_index(ctd->z_index); tile_data->set_z_index(ctd->z_index);
@ -2058,7 +2058,7 @@ void TileSet::_compatibility_conversion() {
tile_data->set_flip_h(flip_h); tile_data->set_flip_h(flip_h);
tile_data->set_flip_v(flip_v); tile_data->set_flip_v(flip_v);
tile_data->set_transpose(transpose); tile_data->set_transpose(transpose);
tile_data->tile_set_material(ctd->material); tile_data->set_material(ctd->material);
tile_data->set_modulate(ctd->modulate); tile_data->set_modulate(ctd->modulate);
tile_data->set_z_index(ctd->z_index); tile_data->set_z_index(ctd->z_index);
if (ctd->autotile_occluder_map.has(coords)) { if (ctd->autotile_occluder_map.has(coords)) {
@ -2693,13 +2693,13 @@ void TileSet::_get_property_list(List<PropertyInfo> *p_list) const {
void TileSet::_bind_methods() { void TileSet::_bind_methods() {
// Sources management. // Sources management.
ClassDB::bind_method(D_METHOD("get_next_source_id"), &TileSet::get_next_source_id); ClassDB::bind_method(D_METHOD("get_next_source_id"), &TileSet::get_next_source_id);
ClassDB::bind_method(D_METHOD("add_source", "atlas_source_id_override"), &TileSet::add_source, DEFVAL(TileSet::INVALID_SOURCE)); ClassDB::bind_method(D_METHOD("add_source", "source", "atlas_source_id_override"), &TileSet::add_source, DEFVAL(TileSet::INVALID_SOURCE));
ClassDB::bind_method(D_METHOD("remove_source", "source_id"), &TileSet::remove_source); ClassDB::bind_method(D_METHOD("remove_source", "source_id"), &TileSet::remove_source);
ClassDB::bind_method(D_METHOD("set_source_id", "source_id"), &TileSet::set_source_id); ClassDB::bind_method(D_METHOD("set_source_id", "source_id", "new_source_id"), &TileSet::set_source_id);
ClassDB::bind_method(D_METHOD("get_source_count"), &TileSet::get_source_count); ClassDB::bind_method(D_METHOD("get_source_count"), &TileSet::get_source_count);
ClassDB::bind_method(D_METHOD("get_source_id", "index"), &TileSet::get_source_id); ClassDB::bind_method(D_METHOD("get_source_id", "index"), &TileSet::get_source_id);
ClassDB::bind_method(D_METHOD("has_source", "index"), &TileSet::has_source); ClassDB::bind_method(D_METHOD("has_source", "source_id"), &TileSet::has_source);
ClassDB::bind_method(D_METHOD("get_source", "index"), &TileSet::get_source); ClassDB::bind_method(D_METHOD("get_source", "source_id"), &TileSet::get_source);
// Shape and layout. // Shape and layout.
ClassDB::bind_method(D_METHOD("set_tile_shape", "shape"), &TileSet::set_tile_shape); ClassDB::bind_method(D_METHOD("set_tile_shape", "shape"), &TileSet::set_tile_shape);
@ -2725,9 +2725,9 @@ void TileSet::_bind_methods() {
ClassDB::bind_method(D_METHOD("move_occlusion_layer", "layer_index", "to_position"), &TileSet::move_occlusion_layer); ClassDB::bind_method(D_METHOD("move_occlusion_layer", "layer_index", "to_position"), &TileSet::move_occlusion_layer);
ClassDB::bind_method(D_METHOD("remove_occlusion_layer", "layer_index"), &TileSet::remove_occlusion_layer); ClassDB::bind_method(D_METHOD("remove_occlusion_layer", "layer_index"), &TileSet::remove_occlusion_layer);
ClassDB::bind_method(D_METHOD("set_occlusion_layer_light_mask", "layer_index", "light_mask"), &TileSet::set_occlusion_layer_light_mask); ClassDB::bind_method(D_METHOD("set_occlusion_layer_light_mask", "layer_index", "light_mask"), &TileSet::set_occlusion_layer_light_mask);
ClassDB::bind_method(D_METHOD("get_occlusion_layer_light_mask"), &TileSet::get_occlusion_layer_light_mask); ClassDB::bind_method(D_METHOD("get_occlusion_layer_light_mask", "layer_index"), &TileSet::get_occlusion_layer_light_mask);
ClassDB::bind_method(D_METHOD("set_occlusion_layer_sdf_collision", "layer_index", "sdf_collision"), &TileSet::set_occlusion_layer_sdf_collision); ClassDB::bind_method(D_METHOD("set_occlusion_layer_sdf_collision", "layer_index", "sdf_collision"), &TileSet::set_occlusion_layer_sdf_collision);
ClassDB::bind_method(D_METHOD("get_occlusion_layer_sdf_collision"), &TileSet::get_occlusion_layer_sdf_collision); ClassDB::bind_method(D_METHOD("get_occlusion_layer_sdf_collision", "layer_index"), &TileSet::get_occlusion_layer_sdf_collision);
// Physics // Physics
ClassDB::bind_method(D_METHOD("get_physics_layers_count"), &TileSet::get_physics_layers_count); ClassDB::bind_method(D_METHOD("get_physics_layers_count"), &TileSet::get_physics_layers_count);
@ -2744,8 +2744,8 @@ void TileSet::_bind_methods() {
// Terrains // Terrains
ClassDB::bind_method(D_METHOD("get_terrain_sets_count"), &TileSet::get_terrain_sets_count); ClassDB::bind_method(D_METHOD("get_terrain_sets_count"), &TileSet::get_terrain_sets_count);
ClassDB::bind_method(D_METHOD("add_terrain_set", "to_position"), &TileSet::add_terrain_set, DEFVAL(-1)); ClassDB::bind_method(D_METHOD("add_terrain_set", "to_position"), &TileSet::add_terrain_set, DEFVAL(-1));
ClassDB::bind_method(D_METHOD("move_terrain_set", "layer_index", "to_position"), &TileSet::move_terrain_set); ClassDB::bind_method(D_METHOD("move_terrain_set", "terrain_set", "to_position"), &TileSet::move_terrain_set);
ClassDB::bind_method(D_METHOD("remove_terrain_set", "layer_index"), &TileSet::remove_terrain_set); ClassDB::bind_method(D_METHOD("remove_terrain_set", "terrain_set"), &TileSet::remove_terrain_set);
ClassDB::bind_method(D_METHOD("set_terrain_set_mode", "terrain_set", "mode"), &TileSet::set_terrain_set_mode); ClassDB::bind_method(D_METHOD("set_terrain_set_mode", "terrain_set", "mode"), &TileSet::set_terrain_set_mode);
ClassDB::bind_method(D_METHOD("get_terrain_set_mode", "terrain_set"), &TileSet::get_terrain_set_mode); ClassDB::bind_method(D_METHOD("get_terrain_set_mode", "terrain_set"), &TileSet::get_terrain_set_mode);
@ -2870,6 +2870,18 @@ void TileSetSource::set_tile_set(const TileSet *p_tile_set) {
tile_set = p_tile_set; tile_set = p_tile_set;
} }
void TileSetSource::_bind_methods() {
// Base tiles
ClassDB::bind_method(D_METHOD("get_tiles_count"), &TileSetSource::get_tiles_count);
ClassDB::bind_method(D_METHOD("get_tile_id", "index"), &TileSetSource::get_tile_id);
ClassDB::bind_method(D_METHOD("has_tile", "atlas_coords"), &TileSetSource::has_tile);
// Alternative tiles
ClassDB::bind_method(D_METHOD("get_alternative_tiles_count", "atlas_coords"), &TileSetSource::get_alternative_tiles_count);
ClassDB::bind_method(D_METHOD("get_alternative_tile_id", "atlas_coords", "index"), &TileSetSource::get_alternative_tile_id);
ClassDB::bind_method(D_METHOD("has_alternative_tile", "atlas_coords", "alternative_tile"), &TileSetSource::has_alternative_tile);
}
/////////////////////////////// TileSetAtlasSource ////////////////////////////////////// /////////////////////////////// TileSetAtlasSource //////////////////////////////////////
void TileSetAtlasSource::set_tile_set(const TileSet *p_tile_set) { void TileSetAtlasSource::set_tile_set(const TileSet *p_tile_set) {
@ -3559,32 +3571,24 @@ void TileSetAtlasSource::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D", PROPERTY_USAGE_NOEDITOR), "set_texture", "get_texture"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D", PROPERTY_USAGE_NOEDITOR), "set_texture", "get_texture");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "margins", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_margins", "get_margins"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "margins", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_margins", "get_margins");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "separation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_separation", "get_separation"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "separation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_separation", "get_separation");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "tile_size", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_texture_region_size", "get_texture_region_size"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "texture_region_size", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_texture_region_size", "get_texture_region_size");
// Base tiles // Base tiles
ClassDB::bind_method(D_METHOD("create_tile", "atlas_coords", "size"), &TileSetAtlasSource::create_tile, DEFVAL(Vector2i(1, 1))); ClassDB::bind_method(D_METHOD("create_tile", "atlas_coords", "size"), &TileSetAtlasSource::create_tile, DEFVAL(Vector2i(1, 1)));
ClassDB::bind_method(D_METHOD("remove_tile", "atlas_coords"), &TileSetAtlasSource::remove_tile); // Remove a tile. If p_tile_key.alternative_tile if different from 0, remove the alternative ClassDB::bind_method(D_METHOD("remove_tile", "atlas_coords"), &TileSetAtlasSource::remove_tile); // Remove a tile. If p_tile_key.alternative_tile if different from 0, remove the alternative
ClassDB::bind_method(D_METHOD("has_tile", "atlas_coords"), &TileSetAtlasSource::has_tile);
ClassDB::bind_method(D_METHOD("can_move_tile_in_atlas", "atlas_coords", "new_atlas_coords", "new_size"), &TileSetAtlasSource::can_move_tile_in_atlas, DEFVAL(INVALID_ATLAS_COORDS), DEFVAL(Vector2i(-1, -1))); ClassDB::bind_method(D_METHOD("can_move_tile_in_atlas", "atlas_coords", "new_atlas_coords", "new_size"), &TileSetAtlasSource::can_move_tile_in_atlas, DEFVAL(INVALID_ATLAS_COORDS), DEFVAL(Vector2i(-1, -1)));
ClassDB::bind_method(D_METHOD("move_tile_in_atlas", "atlas_coords", "new_atlas_coords", "new_size"), &TileSetAtlasSource::move_tile_in_atlas, DEFVAL(INVALID_ATLAS_COORDS), DEFVAL(Vector2i(-1, -1))); ClassDB::bind_method(D_METHOD("move_tile_in_atlas", "atlas_coords", "new_atlas_coords", "new_size"), &TileSetAtlasSource::move_tile_in_atlas, DEFVAL(INVALID_ATLAS_COORDS), DEFVAL(Vector2i(-1, -1)));
ClassDB::bind_method(D_METHOD("get_tile_size_in_atlas", "atlas_coords"), &TileSetAtlasSource::get_tile_size_in_atlas); ClassDB::bind_method(D_METHOD("get_tile_size_in_atlas", "atlas_coords"), &TileSetAtlasSource::get_tile_size_in_atlas);
ClassDB::bind_method(D_METHOD("get_tiles_count"), &TileSetAtlasSource::get_tiles_count);
ClassDB::bind_method(D_METHOD("get_tile_id", "index"), &TileSetAtlasSource::get_tile_id);
ClassDB::bind_method(D_METHOD("get_tile_at_coords", "atlas_coords"), &TileSetAtlasSource::get_tile_at_coords); ClassDB::bind_method(D_METHOD("get_tile_at_coords", "atlas_coords"), &TileSetAtlasSource::get_tile_at_coords);
// Alternative tiles // Alternative tiles
ClassDB::bind_method(D_METHOD("create_alternative_tile", "atlas_coords", "alternative_id_override"), &TileSetAtlasSource::create_alternative_tile, DEFVAL(INVALID_TILE_ALTERNATIVE)); ClassDB::bind_method(D_METHOD("create_alternative_tile", "atlas_coords", "alternative_id_override"), &TileSetAtlasSource::create_alternative_tile, DEFVAL(INVALID_TILE_ALTERNATIVE));
ClassDB::bind_method(D_METHOD("remove_alternative_tile", "atlas_coords", "alternative_tile"), &TileSetAtlasSource::remove_alternative_tile); ClassDB::bind_method(D_METHOD("remove_alternative_tile", "atlas_coords", "alternative_tile"), &TileSetAtlasSource::remove_alternative_tile);
ClassDB::bind_method(D_METHOD("set_alternative_tile_id", "atlas_coords", "alternative_tile", "new_id"), &TileSetAtlasSource::set_alternative_tile_id); ClassDB::bind_method(D_METHOD("set_alternative_tile_id", "atlas_coords", "alternative_tile", "new_id"), &TileSetAtlasSource::set_alternative_tile_id);
ClassDB::bind_method(D_METHOD("has_alternative_tile", "atlas_coords", "alternative_tile"), &TileSetAtlasSource::has_alternative_tile);
ClassDB::bind_method(D_METHOD("get_next_alternative_tile_id", "atlas_coords"), &TileSetAtlasSource::get_next_alternative_tile_id); ClassDB::bind_method(D_METHOD("get_next_alternative_tile_id", "atlas_coords"), &TileSetAtlasSource::get_next_alternative_tile_id);
ClassDB::bind_method(D_METHOD("get_alternative_tiles_count", "atlas_coords"), &TileSetAtlasSource::get_alternative_tiles_count); ClassDB::bind_method(D_METHOD("get_tile_data", "atlas_coords", "alternative_tile"), &TileSetAtlasSource::get_tile_data);
ClassDB::bind_method(D_METHOD("get_alternative_tile_id", "atlas_coords", "index"), &TileSetAtlasSource::get_alternative_tile_id);
ClassDB::bind_method(D_METHOD("get_tile_data", "atlas_coords", "index"), &TileSetAtlasSource::get_tile_data);
// Helpers. // Helpers.
ClassDB::bind_method(D_METHOD("get_atlas_grid_size"), &TileSetAtlasSource::get_atlas_grid_size); ClassDB::bind_method(D_METHOD("get_atlas_grid_size"), &TileSetAtlasSource::get_atlas_grid_size);
@ -3797,16 +3801,6 @@ void TileSetScenesCollectionSource::_get_property_list(List<PropertyInfo> *p_lis
} }
void TileSetScenesCollectionSource::_bind_methods() { void TileSetScenesCollectionSource::_bind_methods() {
// Base tiles
ClassDB::bind_method(D_METHOD("get_tiles_count"), &TileSetScenesCollectionSource::get_tiles_count);
ClassDB::bind_method(D_METHOD("get_tile_id", "index"), &TileSetScenesCollectionSource::get_tile_id);
ClassDB::bind_method(D_METHOD("has_tile", "atlas_coords"), &TileSetScenesCollectionSource::has_tile);
// Alternative tiles
ClassDB::bind_method(D_METHOD("get_alternative_tiles_count", "atlas_coords"), &TileSetScenesCollectionSource::get_alternative_tiles_count);
ClassDB::bind_method(D_METHOD("get_alternative_tile_id", "atlas_coords", "index"), &TileSetScenesCollectionSource::get_alternative_tile_id);
ClassDB::bind_method(D_METHOD("has_alternative_tile", "atlas_coords", "alternative_tile"), &TileSetScenesCollectionSource::has_alternative_tile);
ClassDB::bind_method(D_METHOD("get_scene_tiles_count"), &TileSetScenesCollectionSource::get_scene_tiles_count); ClassDB::bind_method(D_METHOD("get_scene_tiles_count"), &TileSetScenesCollectionSource::get_scene_tiles_count);
ClassDB::bind_method(D_METHOD("get_scene_tile_id", "index"), &TileSetScenesCollectionSource::get_scene_tile_id); ClassDB::bind_method(D_METHOD("get_scene_tile_id", "index"), &TileSetScenesCollectionSource::get_scene_tile_id);
ClassDB::bind_method(D_METHOD("has_scene_tile_id", "id"), &TileSetScenesCollectionSource::has_scene_tile_id); ClassDB::bind_method(D_METHOD("has_scene_tile_id", "id"), &TileSetScenesCollectionSource::has_scene_tile_id);
@ -4063,11 +4057,11 @@ Vector2i TileData::get_texture_offset() const {
return tex_offset; return tex_offset;
} }
void TileData::tile_set_material(Ref<ShaderMaterial> p_material) { void TileData::set_material(Ref<ShaderMaterial> p_material) {
material = p_material; material = p_material;
emit_signal(SNAME("changed")); emit_signal(SNAME("changed"));
} }
Ref<ShaderMaterial> TileData::tile_get_material() const { Ref<ShaderMaterial> TileData::get_material() const {
return material; return material;
} }
@ -4583,8 +4577,8 @@ void TileData::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_flip_v"), &TileData::get_flip_v); ClassDB::bind_method(D_METHOD("get_flip_v"), &TileData::get_flip_v);
ClassDB::bind_method(D_METHOD("set_transpose", "transpose"), &TileData::set_transpose); ClassDB::bind_method(D_METHOD("set_transpose", "transpose"), &TileData::set_transpose);
ClassDB::bind_method(D_METHOD("get_transpose"), &TileData::get_transpose); ClassDB::bind_method(D_METHOD("get_transpose"), &TileData::get_transpose);
ClassDB::bind_method(D_METHOD("tile_set_material", "material"), &TileData::tile_set_material); ClassDB::bind_method(D_METHOD("set_material", "material"), &TileData::set_material);
ClassDB::bind_method(D_METHOD("tile_get_material"), &TileData::tile_get_material); ClassDB::bind_method(D_METHOD("get_material"), &TileData::get_material);
ClassDB::bind_method(D_METHOD("set_texture_offset", "texture_offset"), &TileData::set_texture_offset); ClassDB::bind_method(D_METHOD("set_texture_offset", "texture_offset"), &TileData::set_texture_offset);
ClassDB::bind_method(D_METHOD("get_texture_offset"), &TileData::get_texture_offset); ClassDB::bind_method(D_METHOD("get_texture_offset"), &TileData::get_texture_offset);
ClassDB::bind_method(D_METHOD("set_modulate", "modulate"), &TileData::set_modulate); ClassDB::bind_method(D_METHOD("set_modulate", "modulate"), &TileData::set_modulate);
@ -4635,6 +4629,7 @@ void TileData::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "transpose"), "set_transpose", "get_transpose"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "transpose"), "set_transpose", "get_transpose");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "texture_offset"), "set_texture_offset", "get_texture_offset"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "texture_offset"), "set_texture_offset", "get_texture_offset");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "modulate"), "set_modulate", "get_modulate"); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "modulate"), "set_modulate", "get_modulate");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial"), "set_material", "get_material");
ADD_PROPERTY(PropertyInfo(Variant::INT, "z_index"), "set_z_index", "get_z_index"); ADD_PROPERTY(PropertyInfo(Variant::INT, "z_index"), "set_z_index", "get_z_index");
ADD_PROPERTY(PropertyInfo(Variant::INT, "y_sort_origin"), "set_y_sort_origin", "get_y_sort_origin"); ADD_PROPERTY(PropertyInfo(Variant::INT, "y_sort_origin"), "set_y_sort_origin", "get_y_sort_origin");

View File

@ -304,7 +304,7 @@ public:
void remove_occlusion_layer(int p_index); void remove_occlusion_layer(int p_index);
void set_occlusion_layer_light_mask(int p_layer_index, int p_light_mask); void set_occlusion_layer_light_mask(int p_layer_index, int p_light_mask);
int get_occlusion_layer_light_mask(int p_layer_index) const; int get_occlusion_layer_light_mask(int p_layer_index) const;
void set_occlusion_layer_sdf_collision(int p_layer_index, int p_sdf_collision); void set_occlusion_layer_sdf_collision(int p_layer_index, bool p_sdf_collision);
bool get_occlusion_layer_sdf_collision(int p_layer_index) const; bool get_occlusion_layer_sdf_collision(int p_layer_index) const;
// Physics // Physics
@ -404,6 +404,8 @@ class TileSetSource : public Resource {
protected: protected:
const TileSet *tile_set = nullptr; const TileSet *tile_set = nullptr;
static void _bind_methods();
public: public:
static const Vector2i INVALID_ATLAS_COORDS; // Vector2i(-1, -1); static const Vector2i INVALID_ATLAS_COORDS; // Vector2i(-1, -1);
static const int INVALID_TILE_ALTERNATIVE; // -1; static const int INVALID_TILE_ALTERNATIVE; // -1;
@ -679,8 +681,8 @@ public:
void set_texture_offset(Vector2i p_texture_offset); void set_texture_offset(Vector2i p_texture_offset);
Vector2i get_texture_offset() const; Vector2i get_texture_offset() const;
void tile_set_material(Ref<ShaderMaterial> p_material); void set_material(Ref<ShaderMaterial> p_material);
Ref<ShaderMaterial> tile_get_material() const; Ref<ShaderMaterial> get_material() const;
void set_modulate(Color p_modulate); void set_modulate(Color p_modulate);
Color get_modulate() const; Color get_modulate() const;
void set_z_index(int p_z_index); void set_z_index(int p_z_index);