From fb8ea11c03b5b04509266abeccfccc1c2922512e Mon Sep 17 00:00:00 2001 From: Relintai Date: Fri, 1 Mar 2024 10:43:35 +0100 Subject: [PATCH] Also added layered tilemap docs. --- .../layered_tile_map/doc_classes/TileData.xml | 249 ++++++ .../layered_tile_map/doc_classes/TileMap.xml | 510 ++++++++++++ .../doc_classes/TileMapLayerGroup.xml | 17 + .../doc_classes/TileMapPattern.xml | 85 ++ .../layered_tile_map/doc_classes/TileSet.xml | 727 ++++++++++++++++++ .../doc_classes/TileSetAtlasSource.xml | 306 ++++++++ .../TileSetScenesCollectionSource.xml | 94 +++ .../doc_classes/TileSetSource.xml | 62 ++ 8 files changed, 2050 insertions(+) create mode 100644 modules/layered_tile_map/doc_classes/TileData.xml create mode 100644 modules/layered_tile_map/doc_classes/TileMap.xml create mode 100644 modules/layered_tile_map/doc_classes/TileMapLayerGroup.xml create mode 100644 modules/layered_tile_map/doc_classes/TileMapPattern.xml create mode 100644 modules/layered_tile_map/doc_classes/TileSet.xml create mode 100644 modules/layered_tile_map/doc_classes/TileSetAtlasSource.xml create mode 100644 modules/layered_tile_map/doc_classes/TileSetScenesCollectionSource.xml create mode 100644 modules/layered_tile_map/doc_classes/TileSetSource.xml diff --git a/modules/layered_tile_map/doc_classes/TileData.xml b/modules/layered_tile_map/doc_classes/TileData.xml new file mode 100644 index 000000000..c5b86f079 --- /dev/null +++ b/modules/layered_tile_map/doc_classes/TileData.xml @@ -0,0 +1,249 @@ + + + + Settings for a single tile in a [TileSet]. + + + [TileData] object represents a single tile in a [TileSet]. It is usually edited using the tileset editor, but it can be modified at runtime using [method TileMap._tile_data_runtime_update]. + + + + + + + + + Adds a collision polygon to the tile on the given TileSet physics layer. + + + + + + + + Returns the one-way margin (for one-way platforms) of the polygon at index [param polygon_index] for TileSet physics layer with index [param layer_id]. + + + + + + + + Returns the points of the polygon at index [param polygon_index] for TileSet physics layer with index [param layer_id]. + + + + + + + Returns how many polygons the tile has for TileSet physics layer with index [param layer_id]. + + + + + + + Returns the constant angular velocity applied to objects colliding with this tile. + + + + + + + Returns the constant linear velocity applied to objects colliding with this tile. + + + + + + + Returns the custom data value for custom data layer named [param layer_name]. + + + + + + + Returns the custom data value for custom data layer with index [param layer_id]. + + + + + + + + + + Returns the navigation polygon of the tile for the TileSet navigation layer with index [param layer_id]. + [param flip_h], [param flip_v], and [param transpose] allow transforming the returned polygon. + + + + + + + + + + Returns the occluder polygon of the tile for the TileSet occlusion layer with index [param layer_id]. + [param flip_h], [param flip_v], and [param transpose] allow transforming the returned polygon. + + + + + + + Returns the tile's terrain bit for the given [param peering_bit] direction. + + + + + + + + Returns whether one-way collisions are enabled for the polygon at index [param polygon_index] for TileSet physics layer with index [param layer_id]. + + + + + + + + Removes the polygon at index [param polygon_index] for TileSet physics layer with index [param layer_id]. + + + + + + + + + Enables/disables one-way collisions on the polygon at index [param polygon_index] for TileSet physics layer with index [param layer_id]. + + + + + + + + + Enables/disables one-way collisions on the polygon at index [param polygon_index] for TileSet physics layer with index [param layer_id]. + + + + + + + + + Sets the points of the polygon at index [param polygon_index] for TileSet physics layer with index [param layer_id]. + + + + + + + + Sets the polygons count for TileSet physics layer with index [param layer_id]. + + + + + + + + Sets the constant angular velocity. This does not rotate the tile. This angular velocity is applied to objects colliding with this tile. + + + + + + + + Sets the constant linear velocity. This does not move the tile. This linear velocity is applied to objects colliding with this tile. This is useful to create conveyor belts. + + + + + + + + Sets the tile's custom data value for the TileSet custom data layer with name [param layer_name]. + + + + + + + + Sets the tile's custom data value for the TileSet custom data layer with index [param layer_id]. + + + + + + + + Sets the navigation polygon for the TileSet navigation layer with index [param layer_id]. + + + + + + + + Sets the occluder for the TileSet occlusion layer with index [param layer_id]. + + + + + + + + Sets the tile's terrain bit for the given [param peering_bit] direction. + + + + + + If [code]true[/code], the tile will have its texture flipped horizontally. + + + If [code]true[/code], the tile will have its texture flipped vertically. + + + The [Material] to use for this [TileData]. This can be a [CanvasItemMaterial] to use the default shader, or a [ShaderMaterial] to use a custom shader. + + + Color modulation of the tile. + + + Relative probability of this tile being selected when drawing a pattern of random tiles. + + + ID of the terrain from the terrain set that the tile uses. + + + ID of the terrain set that the tile uses. + + + Offsets the position of where the tile is drawn. + + + If [code]true[/code], the tile will display transposed, i.e. with horizontal and vertical texture UVs swapped. + + + Vertical point of the tile used for determining y-sorted order. + + + Ordering index of this tile, relative to [TileMap]. + + + + + + Emitted when any of the properties are changed. + + + + diff --git a/modules/layered_tile_map/doc_classes/TileMap.xml b/modules/layered_tile_map/doc_classes/TileMap.xml new file mode 100644 index 000000000..5731c1065 --- /dev/null +++ b/modules/layered_tile_map/doc_classes/TileMap.xml @@ -0,0 +1,510 @@ + + + + Node for 2D tile-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. + For performance reasons, all TileMap updates are batched at the end of a frame. Notably, this means that scene tiles from a [TileSetScenesCollectionSource] may be initialized after their parent. This is only queued when inside the scene tree. + To force an update earlier on, call [method update_internals]. + + + $DOCS_URL/tutorials/2d/using_tilemaps.html + https://godotengine.org/asset-library/asset/120 + https://godotengine.org/asset-library/asset/112 + https://godotengine.org/asset-library/asset/111 + https://godotengine.org/asset-library/asset/519 + https://godotengine.org/asset-library/asset/520 + https://godotengine.org/asset-library/asset/113 + + + + + + + + + Called with a TileData object about to be used internally by the TileMap, allowing its modification at runtime. + This method is only called if [method _use_tile_data_runtime_update] is implemented and returns [code]true[/code] for the given tile [param coords] and [param layer]. + [b]Warning:[/b] The [param tile_data] object's sub-resources are the same as the one in the TileSet. Modifying them might impact the whole TileSet. Instead, make sure to duplicate those resources. + [b]Note:[/b] If the properties of [param tile_data] object should change over time, use [method notify_runtime_tile_data_update] to notify the TileMap it needs an update. + + + + + + + + Should return [code]true[/code] if the tile at coordinates [param coords] on layer [param layer] requires a runtime update. + [b]Warning:[/b] Make sure this function only return [code]true[/code] when needed. Any tile processed at runtime without a need for it will imply a significant performance penalty. + [b]Note:[/b] If the result of this function should changed, use [method notify_runtime_tile_data_update] to notify the TileMap it needs an update. + + + + + + + Adds a layer at the given position [param to_position] in the array. If [param to_position] is negative, the position is counted from the end, with [code]-1[/code] adding the layer at the end of the array. + + + + + + Clears all cells. + + + + + + + Clears all cells on the given layer. + If [param layer] is negative, the layers are accessed from the last one. + + + + + + + + Erases the cell on layer [param layer] at coordinates [param coords]. + If [param layer] is negative, the layers are accessed from the last one. + + + + + + Clears cells that do not exist in the tileset. + + + + + + + Forces the TileMap and the layer [param layer] to update. + + + + + + + + + Returns the tile alternative ID of the cell on layer [param layer] at [param coords]. If [param use_proxies] is [code]false[/code], ignores the [TileSet]'s tile proxies, returning the raw alternative identifier. See [method TileSet.map_tile_proxy]. + If [param layer] is negative, the layers are accessed from the last one. + + + + + + + + + Returns the tile atlas coordinates ID of the cell on layer [param layer] at coordinates [param coords]. If [param use_proxies] is [code]false[/code], ignores the [TileSet]'s tile proxies, returning the raw alternative identifier. See [method TileSet.map_tile_proxy]. + If [param layer] is negative, the layers are accessed from the last one. + + + + + + + + + Returns the tile source ID of the cell on layer [param layer] at coordinates [param coords]. Returns [code]-1[/code] if the cell does not exist. + If [param use_proxies] is [code]false[/code], ignores the [TileSet]'s tile proxies, returning the raw alternative identifier. See [method TileSet.map_tile_proxy]. + If [param layer] is negative, the layers are accessed from the last one. + + + + + + + + + Returns the [TileData] object associated with the given cell, or [code]null[/code] if the cell does not exist or is not a [TileSetAtlasSource]. + If [param layer] is negative, the layers are accessed from the last one. + If [param use_proxies] is [code]false[/code], ignores the [TileSet]'s tile proxies, returning the raw alternative identifier. See [method TileSet.map_tile_proxy]. + [codeblock] + func get_clicked_tile_power(): + var clicked_cell = tile_map.local_to_map(tile_map.get_local_mouse_position()) + var data = tile_map.get_cell_tile_data(0, clicked_cell) + if data: + return data.get_custom_data("power") + else: + return 0 + [/codeblock] + + + + + + + Returns the coordinates of the tile for given physics body RID. Such RID can be retrieved from [method KinematicCollision2D.get_collider_rid], when colliding with a tile. + + + + + + + Returns the tilemap layer of the tile for given physics body RID. Such RID can be retrieved from [method KinematicCollision2D.get_collider_rid], when colliding with a tile. + + + + + + + Returns a TileMap layer's modulate. + If [param layer] is negative, the layers are accessed from the last one. + + + + + + + Returns a TileMap layer's name. + If [param layer] is negative, the layers are accessed from the last one. + + + + + + + Returns the [RID] of the [NavigationServer2D] navigation map assigned to the specified TileMap layer [param layer]. + By default the TileMap uses the default [World2D] navigation map for the first TileMap layer. For each additional TileMap layer a new navigation map is created for the additional layer. + In order to make [NavigationAgent2D] switch between TileMap layer navigation maps use [method NavigationAgent2D.set_navigation_map] with the navigation map received from [method get_layer_navigation_map]. + If [param layer] is negative, the layers are accessed from the last one. + + + + + + + Returns a TileMap layer's Y sort origin. + If [param layer] is negative, the layers are accessed from the last one. + + + + + + + Returns a TileMap layer's Z-index value. + If [param layer] is negative, the layers are accessed from the last one. + + + + + + Returns the number of layers in the TileMap. + + + + + + + Returns the [RID] of the [NavigationServer2D] navigation map assigned to the specified TileMap layer [param layer]. + + + + + + + + Returns the neighboring cell to the one at coordinates [param coords], identified by the [param neighbor] direction. This method takes into account the different layouts a TileMap can take. + + + + + + + + Creates a new [TileMapPattern] from the given layer and set of cells. + If [param layer] is negative, the layers are accessed from the last one. + + + + + + + Returns the list of all neighbourings cells to the one at [param coords]. + + + + + + + Returns a [Vector2i] 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. + If [param layer] is negative, the layers are accessed from the last one. + + + + + + + + + + Returns a [Vector2i] array with the positions of all cells containing a tile in the given layer. Tiles may be filtered according to their source ([param source_id]), their atlas coordinates ([param atlas_coords]) or alternative id ([param alternative_tile]). + If a parameter has its value set to the default one, this parameter is not used to filter a cell. Thus, if all parameters have their respective default value, this method returns the same result as [method get_used_cells]. + 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. + If [param layer] is negative, the layers are accessed from the last one. + + + + + + Returns a rectangle enclosing the used (non-empty) tiles of the map, including all layers. + + + + + + + Returns if a layer is enabled. + If [param layer] is negative, the layers are accessed from the last one. + + + + + + + Returns if a layer's built-in navigation regions generation is enabled. + + + + + + + Returns if a layer Y-sorts its tiles. + If [param layer] is negative, the layers are accessed from the last one. + + + + + + + Returns the map coordinates of the cell containing the given [param local_position]. If [param local_position] is in global coordinates, consider using [method Node2D.to_local] before passing it to this method. See also [method map_to_local]. + + + + + + + + + Returns for the given coordinate [param coords_in_pattern] in a [TileMapPattern] the corresponding cell coordinates if the pattern was pasted at the [param position_in_tilemap] coordinates (see [method set_pattern]). This mapping is required as in half-offset tile shapes, the mapping might not work by calculating [code]position_in_tile_map + coords_in_pattern[/code]. + + + + + + + Returns the centered position of a cell in the TileMap's local coordinate space. To convert the returned value into global coordinates, use [method Node2D.to_global]. See also [method local_to_map]. + [b]Note:[/b] This may not correspond to the visual position of the tile, i.e. it ignores the [member TileData.texture_origin] property of individual tiles. + + + + + + + + Moves the layer at index [param layer] to the given position [param to_position] in the array. + + + + + + + Notifies the TileMap node that calls to [method _use_tile_data_runtime_update] or [method _tile_data_runtime_update] will lead to different results. This will thus trigger a TileMap update. + If [param layer] is provided, only notifies changes for the given layer. Providing the [param layer] argument (when applicable) is usually preferred for performance reasons. + [b]Warning:[/b] Updating the TileMap is computationally expensive and may impact performance. Try to limit the number of calls to this function to avoid unnecessary update. + [b]Note:[/b] This does not trigger a direct update of the TileMap, the update will be done at the end of the frame as usual (unless you call [method update_internals]). + + + + + + + Removes the layer at index [param layer]. + + + + + + + + + + + Sets the tile identifiers for the cell on layer [param layer] at coordinates [param coords]. Each tile of the [TileSet] is identified using three parts: + - The source identifier [param source_id] identifies a [TileSetSource] identifier. See [method TileSet.set_source_id], + - The atlas coordinates identifier [param atlas_coords] identifies a tile coordinates in the atlas (if the source is a [TileSetAtlasSource]). For [TileSetScenesCollectionSource] it should always be [code]Vector2i(0, 0)[/code]), + - The alternative tile identifier [param alternative_tile] identifies a tile alternative in the atlas (if the source is a [TileSetAtlasSource]), and the scene for a [TileSetScenesCollectionSource]. + If [param source_id] is set to [code]-1[/code], [param atlas_coords] to [code]Vector2i(-1, -1)[/code] or [param alternative_tile] to [code]-1[/code], the cell will be erased. An erased cell gets [b]all[/b] its identifiers automatically set to their respective invalid values, namely [code]-1[/code], [code]Vector2i(-1, -1)[/code] and [code]-1[/code]. + If [param layer] is negative, the layers are accessed from the last one. + + + + + + + + + + + Update all the cells in the [param cells] coordinates array so that they use the given [param terrain] for the given [param terrain_set]. If an updated cell has the same terrain as one of its neighboring cells, this function tries to join the two. This function might update neighboring tiles if needed to create correct terrain transitions. + If [param ignore_empty_terrains] is true, empty terrains will be ignored when trying to find the best fitting tile for the given terrain constraints. + If [param layer] is negative, the layers are accessed from the last one. + [b]Note:[/b] To work correctly, this method requires the TileMap's TileSet to have terrains set up with all required terrain combinations. Otherwise, it may produce unexpected results. + + + + + + + + + + + Update all the cells in the [param path] coordinates array so that they use the given [param terrain] for the given [param terrain_set]. The function will also connect two successive cell in the path with the same terrain. This function might update neighboring tiles if needed to create correct terrain transitions. + If [param ignore_empty_terrains] is true, empty terrains will be ignored when trying to find the best fitting tile for the given terrain constraints. + If [param layer] is negative, the layers are accessed from the last one. + [b]Note:[/b] To work correctly, this method requires the TileMap's TileSet to have terrains set up with all required terrain combinations. Otherwise, it may produce unexpected results. + + + + + + + + Enables or disables the layer [param layer]. A disabled layer is not processed at all (no rendering, no physics, etc...). + If [param layer] is negative, the layers are accessed from the last one. + + + + + + + + Sets a layer's color. It will be multiplied by tile's color and TileMap's modulate. + If [param layer] is negative, the layers are accessed from the last one. + + + + + + + + Sets a layer's name. This is mostly useful in the editor. + If [param layer] is negative, the layers are accessed from the last one. + + + + + + + + Enables or disables a layer's built-in navigation regions generation. Disable this if you need to bake navigation regions from a TileMap using a [NavigationRegion2D] node. + + + + + + + + Assigns [param map] as a [NavigationServer2D] navigation map for the specified TileMap layer [param layer]. + By default the TileMap uses the default [World2D] navigation map for the first TileMap layer. For each additional TileMap layer a new navigation map is created for the additional layer. + In order to make [NavigationAgent2D] switch between TileMap layer navigation maps use [method NavigationAgent2D.set_navigation_map] with the navigation map received from [method get_layer_navigation_map]. + If [param layer] is negative, the layers are accessed from the last one. + + + + + + + + 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 behavior. + If [param layer] is negative, the layers are accessed from the last one. + + + + + + + + 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. + If [param layer] is negative, the layers are accessed from the last one. + + + + + + + + Sets a layers Z-index value. This Z-index is added to each tile's Z-index value. + If [param layer] is negative, the layers are accessed from the last one. + + + + + + + + Assigns [param map] as a [NavigationServer2D] navigation map for the specified TileMap layer [param layer]. + + + + + + + + + Paste the given [TileMapPattern] at the given [param position] and [param layer] in the tile map. + If [param layer] is negative, the layers are accessed from the last one. + + + + + + Triggers a direct update of the TileMap. Usually, calling this function is not needed, as TileMap node updates automatically when one of its properties or cells is modified. + However, for performance reasons, those updates are batched and delayed to the end of the frame. Calling this function will force the TileMap to update right away instead. + [b]Warning:[/b] Updating the TileMap is computationally expensive and may impact performance. Try to limit the number of updates and how many tiles they impact. + + + + + + If enabled, the TileMap will see its collisions synced to the physics tick and change its collision type from static to kinematic. This is required to create TileMap-based moving platform. + [b]Note:[/b] Enabling [member collision_animatable] may have a small performance impact, only do it if the TileMap is moving and has colliding tiles. + + + Show or hide the TileMap's collision shapes. If set to [constant VISIBILITY_MODE_DEFAULT], this depends on the show collision debug settings. + + + Show or hide the TileMap's navigation meshes. If set to [constant VISIBILITY_MODE_DEFAULT], this depends on the show navigation debug settings. + + + The TileMap's quadrant size. A quadrant is a group of tiles to be drawn together on a single canvas item, for optimization purposes. [member rendering_quadrant_size] defines the length of a square's side, in the map's coordinate system, that forms the quadrant. Thus, the default quandrant size groups together [code]16 * 16 = 256[/code] tiles. + The quadrant size does not apply on Y-sorted layers, as tiles are be grouped by Y position instead in that case. + [b]Note:[/b] As quadrants are created according to the map's coordinate system, the quadrant's "square shape" might not look like square in the TileMap's local coordinate system. + + + + + + Emitted when the [TileSet] of this TileMap changes. + + + + + + Use the debug settings to determine visibility. + + + Always hide. + + + Always show. + + + diff --git a/modules/layered_tile_map/doc_classes/TileMapLayerGroup.xml b/modules/layered_tile_map/doc_classes/TileMapLayerGroup.xml new file mode 100644 index 000000000..3787d3bb1 --- /dev/null +++ b/modules/layered_tile_map/doc_classes/TileMapLayerGroup.xml @@ -0,0 +1,17 @@ + + + + Groups a set of tile map layers together, allowing them to share a provided [TileSet]. + + + Groups together tile map layers as part or the same map, replacing the [TileMap] node. Child layers will use this node's [member tile_set]. + The editor also uses [TileMapLayerGroup] as a way to store which layers are selected in a given group. This allows highlighting the currently selected layers. + + + + + + The assigned [TileSet]. This TileSet will be applied to all child layers. + + + diff --git a/modules/layered_tile_map/doc_classes/TileMapPattern.xml b/modules/layered_tile_map/doc_classes/TileMapPattern.xml new file mode 100644 index 000000000..1733ecf59 --- /dev/null +++ b/modules/layered_tile_map/doc_classes/TileMapPattern.xml @@ -0,0 +1,85 @@ + + + + Holds a pattern to be copied from or pasted into [TileMap]s. + + + This resource holds a set of cells to help bulk manipulations of [TileMap]. + A pattern always start at the [code](0,0)[/code] coordinates and cannot have cells with negative coordinates. + + + + + + + + + Returns the tile alternative ID of the cell at [param coords]. + + + + + + + Returns the tile atlas coordinates ID of the cell at [param coords]. + + + + + + + Returns the tile source ID of the cell at [param coords]. + + + + + + Returns the size, in cells, of the pattern. + + + + + + Returns the list of used cell coordinates in the pattern. + + + + + + + Returns whether the pattern has a tile at the given coordinates. + + + + + + Returns whether the pattern is empty or not. + + + + + + + + Remove the cell at the given coordinates. + + + + + + + + + + Sets the tile identifiers for the cell at coordinates [param coords]. See [method TileMap.set_cell]. + + + + + + + Sets the size of the pattern. + + + + diff --git a/modules/layered_tile_map/doc_classes/TileSet.xml b/modules/layered_tile_map/doc_classes/TileSet.xml new file mode 100644 index 000000000..37f4cc5c0 --- /dev/null +++ b/modules/layered_tile_map/doc_classes/TileSet.xml @@ -0,0 +1,727 @@ + + + + Tile library for tilemaps. + + + 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 can either be from a [TileSetAtlasSource], which renders 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 fewer properties. To do so, the TileSet resources use property layers, which you can add or remove depending on your needs. + For example, adding a physics layer allows giving collision shapes to your tiles. Each layer has dedicated properties (physics layer and mask), so you may add several TileSet physics layers for each type of collision you need. + See the functions to add new layers for more information. + + + $DOCS_URL/tutorials/2d/using_tilemaps.html + https://godotengine.org/asset-library/asset/120 + https://godotengine.org/asset-library/asset/112 + https://godotengine.org/asset-library/asset/111 + https://godotengine.org/asset-library/asset/519 + https://godotengine.org/asset-library/asset/520 + https://godotengine.org/asset-library/asset/113 + + + + + + + Adds a custom data layer to the TileSet at the given position [param to_position] in the array. If [param to_position] is -1, adds it at the end of the array. + Custom data layers allow assigning custom properties to atlas tiles. + + + + + + + Adds a navigation layer to the TileSet at the given position [param to_position] in the array. If [param to_position] is -1, adds it at the end of the array. + Navigation layers allow assigning a navigable area to atlas tiles. + + + + + + + Adds an occlusion layer to the TileSet at the given position [param to_position] in the array. If [param to_position] is -1, adds it at the end of the array. + Occlusion layers allow assigning occlusion polygons to atlas tiles. + + + + + + + + Adds a [TileMapPattern] to be stored in the TileSet resource. If provided, insert it at the given [param index]. + + + + + + + Adds a physics layer to the TileSet at the given position [param to_position] in the array. If [param to_position] is -1, adds it at the end of the array. + Physics layers allow assigning collision polygons to atlas tiles. + + + + + + + + Adds a [TileSetSource] to the TileSet. If [param atlas_source_id_override] is not -1, also set its source ID. Otherwise, a unique identifier is automatically generated. + The function returns the added source ID or -1 if the source could not be added. + [b]Warning:[/b] A source cannot belong to two TileSets at the same time. If the added source was attached to another [TileSet], it will be removed from that one. + + + + + + + + Adds a new terrain to the given terrain set [param terrain_set] at the given position [param to_position] in the array. If [param to_position] is -1, adds it at the end of the array. + + + + + + + Adds a new terrain set at the given position [param to_position] in the array. If [param to_position] is -1, adds it at the end of the array. + + + + + + Clears tile proxies pointing to invalid tiles. + + + + + + Clears all tile proxies. + + + + + + + + + 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. + + + + + + + + Returns the coordinate-level proxy for the given identifiers. The returned array contains the two target identifiers of the proxy (source ID and atlas coordinates ID). + If the TileSet has no proxy for the given identifiers, returns an empty Array. + + + + + + + Returns the index of the custom data layer identified by the given name. + + + + + + + Returns the name of the custom data layer identified by the given index. + + + + + + + Returns the type of the custom data layer identified by the given index. + + + + + + Returns the custom data layers count. + + + + + + + + Returns whether or not the specified navigation layer of the TileSet navigation data layer identified by the given [param layer_index] is enabled, given a navigation_layers [param layer_number] between 1 and 32. + + + + + + + Returns the navigation layers (as in the Navigation server) of the given TileSet navigation layer. + + + + + + Returns the navigation layers count. + + + + + + Returns a new unused source ID. This generated ID is the same that a call to [method add_source] would return. + + + + + + + Returns the light mask of the occlusion layer. + + + + + + + Returns if the occluders from this layer use [code]sdf_collision[/code]. + + + + + + Returns the occlusion layers count. + + + + + + + Returns the [TileMapPattern] at the given [param index]. + + + + + + Returns the number of [TileMapPattern] this tile set handles. + + + + + + + Returns the collision layer (as in the physics server) bodies on the given TileSet's physics layer are in. + + + + + + + Returns the collision mask of bodies on the given TileSet's physics layer. + + + + + + + Returns the physics material of bodies on the given TileSet's physics layer. + + + + + + Returns the physics layers count. + + + + + + + Returns the [TileSetSource] with ID [param source_id]. + + + + + + Returns the number of [TileSetSource] in this TileSet. + + + + + + + Returns the source ID for source with index [param index]. + + + + + + + Returns the source-level proxy for the given source identifier. + If the TileSet has no proxy for the given identifier, returns -1. + + + + + + + + Returns a terrain's color. + + + + + + + + Returns a terrain's name. + + + + + + + Returns a terrain set mode. + + + + + + Returns the terrain sets count. + + + + + + + Returns the number of terrains in the given terrain set. + + + + + + + + + Returns if there is an alternative-level proxy for the given identifiers. + + + + + + + + Returns if there is a coodinates-level proxy for the given identifiers. + + + + + + + Returns if this TileSet has a source for the given source ID. + + + + + + + Returns if there is a source-level proxy for the given source ID. + + + + + + + + + According to the configured proxies, maps the provided identifiers 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. + + + + + + + + Moves the custom data layer at index [param layer_index] to the given position [param to_position] in the array. Also updates the atlas tiles accordingly. + + + + + + + + Moves the navigation layer at index [param layer_index] to the given position [param to_position] in the array. Also updates the atlas tiles accordingly. + + + + + + + + Moves the occlusion layer at index [param layer_index] to the given position [param to_position] in the array. Also updates the atlas tiles accordingly. + + + + + + + + Moves the physics layer at index [param layer_index] to the given position [param to_position] in the array. Also updates the atlas tiles accordingly. + + + + + + + + + Moves the terrain at index [param terrain_index] for terrain set [param terrain_set] to the given position [param to_position] in the array. Also updates the atlas tiles accordingly. + + + + + + + + Moves the terrain set at index [param terrain_set] to the given position [param to_position] in the array. Also updates the atlas tiles accordingly. + + + + + + + + + Removes an alternative-level proxy for the given identifiers. + + + + + + + + Removes a coordinates-level proxy for the given identifiers. + + + + + + + Removes the custom data layer at index [param layer_index]. Also updates the atlas tiles accordingly. + + + + + + + Removes the navigation layer at index [param layer_index]. Also updates the atlas tiles accordingly. + + + + + + + Removes the occlusion layer at index [param layer_index]. Also updates the atlas tiles accordingly. + + + + + + + Remove the [TileMapPattern] at the given index. + + + + + + + Removes the physics layer at index [param layer_index]. Also updates the atlas tiles accordingly. + + + + + + + Removes the source with the given source ID. + + + + + + + Removes a source-level tile proxy. + + + + + + + + Removes the terrain at index [param terrain_index] in the given terrain set [param terrain_set]. Also updates the atlas tiles accordingly. + + + + + + + Removes the terrain set at index [param terrain_set]. Also updates the atlas tiles accordingly. + + + + + + + + + + + + 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. + + + + + + + + + + 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. + + + + + + + + Sets the name of the custom data layer identified by the given index. Names are identifiers of the layer therefore if the name is already taken it will fail and raise an error. + + + + + + + + Sets the type of the custom data layer identified by the given index. + + + + + + + + + Based on [param value], enables or disables the specified navigation layer of the TileSet navigation data layer identified by the given [param layer_index], given a navigation_layers [param layer_number] between 1 and 32. + + + + + + + + Sets the navigation layers (as in the navigation server) for navigation regions in the given TileSet navigation layer. + + + + + + + + Sets the occlusion layer (as in the rendering server) for occluders in the given TileSet occlusion layer. + + + + + + + + Enables or disables SDF collision for occluders in the given TileSet occlusion layer. + + + + + + + + Sets the physics layer (as in the physics server) for bodies in the given TileSet physics layer. + + + + + + + + Sets the physics layer (as in the physics server) for bodies in the given TileSet physics layer. + + + + + + + + Sets the physics material for bodies in the given TileSet physics layer. + + + + + + + + Changes a source's ID. + + + + + + + + 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 atlas 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. + + + + + + + + + Sets a terrain's color. This color is used for identifying the different terrains in the TileSet editor. + + + + + + + + + Sets a terrain's name. + + + + + + + + Sets a terrain mode. Each mode determines which bits of a tile shape is used to match the neighboring tiles' terrains. + + + + + + For all half-offset shapes (Isometric, Hexagonal and Half-Offset square), changes the way tiles are indexed in the TileMap grid. + + + For all half-offset shapes (Isometric, Hexagonal and Half-Offset square), determines the offset axis. + + + The tile shape. + + + 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. + + + Enables/Disable uv clipping when rendering the tiles. + + + + + Rectangular tile shape. + + + Diamond tile shape (for isometric look). + [b]Note:[/b] Isometric [TileSet] works best if [TileMap] and all its layers have Y-sort enabled. + + + Rectangular tile shape with one row/column out of two offset by half a tile. + + + Hexagonal tile shape. + + + Tile coordinates layout where both axis stay consistent with their respective local horizontal and vertical axis. + + + Same as [constant TILE_LAYOUT_STACKED], but the first half-offset is negative instead of positive. + + + Tile coordinates layout where the horizontal axis stay horizontal, and the vertical one goes down-right. + + + Tile coordinates layout where the vertical axis stay vertical, and the horizontal one goes down-right. + + + Tile coordinates layout where the horizontal axis goes up-right, and the vertical one goes down-right. + + + Tile coordinates layout where the horizontal axis goes down-right, and the vertical one goes down-left. + + + Horizontal half-offset. + + + Vertical half-offset. + + + Neighbor on the right side. + + + Neighbor in the right corner. + + + Neighbor on the bottom right side. + + + Neighbor in the bottom right corner. + + + Neighbor on the bottom side. + + + Neighbor in the bottom corner. + + + Neighbor on the bottom left side. + + + Neighbor in the bottom left corner. + + + Neighbor on the left side. + + + Neighbor in the left corner. + + + Neighbor on the top left side. + + + Neighbor in the top left corner. + + + Neighbor on the top side. + + + Neighbor in the top corner. + + + Neighbor on the top right side. + + + Neighbor in the top right corner. + + + Requires both corners and side to match with neighboring tiles' terrains. + + + Requires corners to match with neighboring tiles' terrains. + + + Requires sides to match with neighboring tiles' terrains. + + + diff --git a/modules/layered_tile_map/doc_classes/TileSetAtlasSource.xml b/modules/layered_tile_map/doc_classes/TileSetAtlasSource.xml new file mode 100644 index 000000000..6f212274f --- /dev/null +++ b/modules/layered_tile_map/doc_classes/TileSetAtlasSource.xml @@ -0,0 +1,306 @@ + + + + Exposes a 2D atlas texture as a set of tiles for a [TileSet] resource. + + + 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("<coords_x>:<coords_y>/<alternative_id>/<tile_data_property>")[/code]. + + + + + + + + Removes all tiles that don't fit the available texture area. This method iterates over all the source's tiles, so it's advised to use [method has_tiles_outside_texture] beforehand. + + + + + + + + Creates an alternative tile for the tile at coordinates [param atlas_coords]. If [param alternative_id_override] 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 [param alternative_id_override]. + + + + + + + + Creates a new tile at coordinates [param atlas_coords] with the given [param size]. + + + + + + Returns the atlas grid size, which depends on how many tiles can fit in the texture. It thus depends on the [member texture]'s size, the atlas [member margins], and the tiles' [member texture_region_size]. + + + + + + + Returns the alternative ID a following call to [method create_alternative_tile] would return. + + + + + + If [member use_texture_padding] is [code]false[/code], returns [member texture]. Otherwise, returns and internal [ImageTexture] created that includes the padding. + + + + + + + + Returns the region of the tile at coordinates [param atlas_coords] for the given [param frame] inside the texture returned by [method get_runtime_texture]. + [b]Note:[/b] If [member use_texture_padding] is [code]false[/code], returns the same as [method get_tile_texture_region]. + + + + + + + Returns how many columns the tile at [param atlas_coords] has in its animation layout. + + + + + + + + Returns the animation frame duration of frame [param frame_index] for the tile at coordinates [param atlas_coords]. + + + + + + + Returns how many animation frames has the tile at coordinates [param atlas_coords]. + + + + + + + Returns the tile animation mode of the tile at [param atlas_coords]. See also [method set_tile_animation_mode]. + + + + + + + Returns the separation (as in the atlas grid) between each frame of an animated tile at coordinates [param atlas_coords]. + + + + + + + Returns the animation speed of the tile at coordinates [param atlas_coords]. + + + + + + + Returns the sum of the sum of the frame durations of the tile at coordinates [param atlas_coords]. This value needs to be divided by the animation speed to get the actual animation loop duration. + + + + + + + If there is a tile covering the [param atlas_coords] coordinates, returns the top-left coordinates of the tile (thus its coordinate ID). Returns [code]Vector2i(-1, -1)[/code] otherwise. + + + + + + + + Returns the [TileData] object for the given atlas coordinates and alternative ID. + + + + + + + Returns the size of the tile (in the grid coordinates system) at coordinates [param atlas_coords]. + + + + + + + + Returns a tile's texture region in the atlas texture. For animated tiles, a [param frame] argument might be provided for the different frames of the animation. + + + + + + + + + + Returns an array of tiles coordinates ID that will be automatically removed when modifying one or several of those properties: [param texture], [param margins], [param separation] or [param texture_region_size]. This can be used to undo changes that would have caused tiles data loss. + + + + + + + + + + + + Returns whether there is enough room in an atlas to create/modify a tile with the given properties. If [param ignored_tile] is provided, act as is the given tile was not present in the atlas. This may be used when you want to modify a tile's properties. + + + + + + Checks if the source has any tiles that don't fit the texture area (either partially or completely). + + + + + + + + + Move the tile and its alternatives at the [param atlas_coords] coordinates to the [param new_atlas_coords] coordinates with the [param new_size] size. This functions will fail if a tile is already present in the given area. + If [param new_atlas_coords] is [code]Vector2i(-1, -1)[/code], keeps the tile's coordinates. If [param new_size] is [code]Vector2i(-1, -1)[/code], keeps the tile's size. + To avoid an error, first check if a move is possible using [method has_room_for_tile]. + + + + + + + + Remove a tile's alternative with alternative ID [param alternative_tile]. + Calling this function with [param alternative_tile] equals to 0 will fail, as the base tile alternative cannot be removed. + + + + + + + Remove a tile and its alternative at coordinates [param atlas_coords]. + + + + + + + + + Change a tile's alternative ID from [param alternative_tile] to [param new_id]. + Calling this function with [param new_id] of 0 will fail, as the base tile alternative cannot be moved. + + + + + + + + Sets the number of columns in the animation layout of the tile at coordinates [param atlas_coords]. If set to 0, then the different frames of the animation are laid out as a single horizontal line in the atlas. + + + + + + + + + Sets the animation frame [param duration] of frame [param frame_index] for the tile at coordinates [param atlas_coords]. + + + + + + + + Sets how many animation frames the tile at coordinates [param atlas_coords] has. + + + + + + + + Sets the tile animation mode of the tile at [param atlas_coords] to [param mode]. See also [method get_tile_animation_mode]. + + + + + + + + Sets the margin (in grid tiles) between each tile in the animation layout of the tile at coordinates [param atlas_coords] has. + + + + + + + + Sets the animation speed of the tile at coordinates [param atlas_coords] has. + + + + + + Margins, in pixels, to offset the origin of the grid in the texture. + + + Separation, in pixels, between each tile texture region of the grid. + + + The atlas texture. + + + The base tile size in the texture (in pixel). This size must be bigger than the TileSet's [code]tile_size[/code] value. + + + If [code]true[/code], generates an internal texture with an additional one pixel padding around each tile. Texture padding avoids a common artifact where lines appear between tiles. + Disabling this setting might lead a small performance improvement, as generating the internal texture requires both memory and processing time when the TileSetAtlasSource resource is modified. + + + + + Tile animations start at same time, looking identical. + + + Tile animations start at random times, looking varied. + + + Represents the size of the [enum TileAnimationMode] enum. + + + Represents cell's horizontal flip flag. Should be used directly with [TileMap] to flip placed tiles by altering their alternative IDs. + [codeblock] + var alternate_id = $TileMap.get_cell_alternative_tile(0, Vector2i(2, 2)) + if not alternate_id & TileSetAtlasSource.TRANSFORM_FLIP_H: + # If tile is not already flipped, flip it. + $TileMap.set_cell(0, Vector2i(2, 2), source_id, atlas_coords, alternate_id | TileSetAtlasSource.TRANSFORM_FLIP_H) + [/codeblock] + + + Represents cell's vertical flip flag. See [constant TRANSFORM_FLIP_H] for usage. + + + Represents cell's transposed flag. See [constant TRANSFORM_FLIP_H] for usage. + + + diff --git a/modules/layered_tile_map/doc_classes/TileSetScenesCollectionSource.xml b/modules/layered_tile_map/doc_classes/TileSetScenesCollectionSource.xml new file mode 100644 index 000000000..9d2742b84 --- /dev/null +++ b/modules/layered_tile_map/doc_classes/TileSetScenesCollectionSource.xml @@ -0,0 +1,94 @@ + + + + Exposes a set of scenes as tiles for a [TileSet] resource. + + + When placed on a [TileMap], tiles from [TileSetScenesCollectionSource] will automatically instantiate an associated scene at the cell's position in the TileMap. + Scenes are instantiated 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 instantiate/free the scene accordingly. + + + + + + + + + + Creates a scene-based tile out of the given scene. + Returns a newly generated unique ID. + + + + + + Returns the scene ID a following call to [method create_scene_tile] would return. + + + + + + + Returns whether the scene tile with [param id] displays a placeholder in the editor. + + + + + + + Returns the scene tile ID of the scene tile at [param index]. + + + + + + + Returns the [PackedScene] resource of scene tile with [param id]. + + + + + + Returns the number or scene tiles this TileSet source has. + + + + + + + Returns whether this TileSet source has a scene tile with [param id]. + + + + + + + Remove the scene tile with [param id]. + + + + + + + + Sets whether or not the scene tile with [param id] should display a placeholder in the editor. This might be useful for scenes that are not visible. + + + + + + + + Changes a scene tile's ID from [param id] to [param new_id]. This will fail if there is already a tile with an ID equal to [param new_id]. + + + + + + + + Assigns a [PackedScene] resource to the scene tile with [param id]. This will fail if the scene does not extend CanvasItem, as positioning properties are needed to place the scene on the TileMap. + + + + diff --git a/modules/layered_tile_map/doc_classes/TileSetSource.xml b/modules/layered_tile_map/doc_classes/TileSetSource.xml new file mode 100644 index 000000000..70df23324 --- /dev/null +++ b/modules/layered_tile_map/doc_classes/TileSetSource.xml @@ -0,0 +1,62 @@ + + + + Exposes a set of tiles for a [TileSet] resource. + + + 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]. + [b]Warning:[/b] [TileSetSource] can only be added to one TileSet at the same time. Calling [method TileSet.add_source] on a second [TileSet] will remove the source from the first one. + + + + + + + + + + Returns the alternative ID for the tile with coordinates ID [param atlas_coords] at index [param index]. + + + + + + + Returns the number of alternatives tiles for the coordinates ID [param atlas_coords]. + 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. + + + + + + + Returns the tile coordinates ID of the tile with index [param index]. + + + + + + Returns how many tiles this atlas source defines (not including alternative tiles). + + + + + + + + Returns if the base tile at coordinates [param atlas_coords] has an alternative with ID [param alternative_tile]. + + + + + + + Returns if this atlas has a tile with coordinates ID [param atlas_coords]. + + + +