class_tilesetscenescollectionsource.rst 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/TileSetScenesCollectionSource.xml.
  6. .. _class_TileSetScenesCollectionSource:
  7. TileSetScenesCollectionSource
  8. =============================
  9. **Inherits:** :ref:`TileSetSource<class_TileSetSource>` **<** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. Exposes a set of scenes as tiles for a :ref:`TileSet<class_TileSet>` resource.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. When placed on a :ref:`TileMap<class_TileMap>`, tiles from **TileSetScenesCollectionSource** will automatically instantiate an associated scene at the cell's position in the TileMap.
  15. Scenes are instantiated as children of the :ref:`TileMap<class_TileMap>` when it enters the tree. If you add/remove a scene tile in the :ref:`TileMap<class_TileMap>` that is already inside the tree, the :ref:`TileMap<class_TileMap>` will automatically instantiate/free the scene accordingly.
  16. \ **Note:** Scene tiles all occupy one tile slot and instead use alternate tile ID to identify scene index. :ref:`TileSetSource.get_tiles_count()<class_TileSetSource_method_get_tiles_count>` will always return ``1``. Use :ref:`get_scene_tiles_count()<class_TileSetScenesCollectionSource_method_get_scene_tiles_count>` to get a number of scenes in a **TileSetScenesCollectionSource**.
  17. Use this code if you want to find the scene path at a given tile in :ref:`TileMapLayer<class_TileMapLayer>`:
  18. .. tabs::
  19. .. code-tab:: gdscript
  20. var source_id = tile_map_layer.get_cell_source_id(Vector2i(x, y))
  21. if source_id > -1:
  22. var scene_source = tile_map_layer.tile_set.get_source(source_id)
  23. if scene_source is TileSetScenesCollectionSource:
  24. var alt_id = tile_map_layer.get_cell_alternative_tile(Vector2i(x, y))
  25. # The assigned PackedScene.
  26. var scene = scene_source.get_scene_tile_scene(alt_id)
  27. .. code-tab:: csharp
  28. int sourceId = tileMapLayer.GetCellSourceId(new Vector2I(x, y));
  29. if (sourceId > -1)
  30. {
  31. TileSetSource source = tileMapLayer.TileSet.GetSource(sourceId);
  32. if (source is TileSetScenesCollectionSource sceneSource)
  33. {
  34. int altId = tileMapLayer.GetCellAlternativeTile(new Vector2I(x, y));
  35. // The assigned PackedScene.
  36. PackedScene scene = sceneSource.GetSceneTileScene(altId);
  37. }
  38. }
  39. .. rst-class:: classref-reftable-group
  40. Methods
  41. -------
  42. .. table::
  43. :widths: auto
  44. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`int<class_int>` | :ref:`create_scene_tile<class_TileSetScenesCollectionSource_method_create_scene_tile>`\ (\ packed_scene\: :ref:`PackedScene<class_PackedScene>`, id_override\: :ref:`int<class_int>` = -1\ ) |
  46. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`int<class_int>` | :ref:`get_next_scene_tile_id<class_TileSetScenesCollectionSource_method_get_next_scene_tile_id>`\ (\ ) |const| |
  48. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`bool<class_bool>` | :ref:`get_scene_tile_display_placeholder<class_TileSetScenesCollectionSource_method_get_scene_tile_display_placeholder>`\ (\ id\: :ref:`int<class_int>`\ ) |const| |
  50. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`int<class_int>` | :ref:`get_scene_tile_id<class_TileSetScenesCollectionSource_method_get_scene_tile_id>`\ (\ index\: :ref:`int<class_int>`\ ) |
  52. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`PackedScene<class_PackedScene>` | :ref:`get_scene_tile_scene<class_TileSetScenesCollectionSource_method_get_scene_tile_scene>`\ (\ id\: :ref:`int<class_int>`\ ) |const| |
  54. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`int<class_int>` | :ref:`get_scene_tiles_count<class_TileSetScenesCollectionSource_method_get_scene_tiles_count>`\ (\ ) |
  56. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`bool<class_bool>` | :ref:`has_scene_tile_id<class_TileSetScenesCollectionSource_method_has_scene_tile_id>`\ (\ id\: :ref:`int<class_int>`\ ) |
  58. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | |void| | :ref:`remove_scene_tile<class_TileSetScenesCollectionSource_method_remove_scene_tile>`\ (\ id\: :ref:`int<class_int>`\ ) |
  60. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | |void| | :ref:`set_scene_tile_display_placeholder<class_TileSetScenesCollectionSource_method_set_scene_tile_display_placeholder>`\ (\ id\: :ref:`int<class_int>`, display_placeholder\: :ref:`bool<class_bool>`\ ) |
  62. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | |void| | :ref:`set_scene_tile_id<class_TileSetScenesCollectionSource_method_set_scene_tile_id>`\ (\ id\: :ref:`int<class_int>`, new_id\: :ref:`int<class_int>`\ ) |
  64. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | |void| | :ref:`set_scene_tile_scene<class_TileSetScenesCollectionSource_method_set_scene_tile_scene>`\ (\ id\: :ref:`int<class_int>`, packed_scene\: :ref:`PackedScene<class_PackedScene>`\ ) |
  66. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. .. rst-class:: classref-section-separator
  68. ----
  69. .. rst-class:: classref-descriptions-group
  70. Method Descriptions
  71. -------------------
  72. .. _class_TileSetScenesCollectionSource_method_create_scene_tile:
  73. .. rst-class:: classref-method
  74. :ref:`int<class_int>` **create_scene_tile**\ (\ packed_scene\: :ref:`PackedScene<class_PackedScene>`, id_override\: :ref:`int<class_int>` = -1\ ) :ref:`🔗<class_TileSetScenesCollectionSource_method_create_scene_tile>`
  75. Creates a scene-based tile out of the given scene.
  76. Returns a newly generated unique ID.
  77. .. rst-class:: classref-item-separator
  78. ----
  79. .. _class_TileSetScenesCollectionSource_method_get_next_scene_tile_id:
  80. .. rst-class:: classref-method
  81. :ref:`int<class_int>` **get_next_scene_tile_id**\ (\ ) |const| :ref:`🔗<class_TileSetScenesCollectionSource_method_get_next_scene_tile_id>`
  82. Returns the scene ID a following call to :ref:`create_scene_tile()<class_TileSetScenesCollectionSource_method_create_scene_tile>` would return.
  83. .. rst-class:: classref-item-separator
  84. ----
  85. .. _class_TileSetScenesCollectionSource_method_get_scene_tile_display_placeholder:
  86. .. rst-class:: classref-method
  87. :ref:`bool<class_bool>` **get_scene_tile_display_placeholder**\ (\ id\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_TileSetScenesCollectionSource_method_get_scene_tile_display_placeholder>`
  88. Returns whether the scene tile with ``id`` displays a placeholder in the editor.
  89. .. rst-class:: classref-item-separator
  90. ----
  91. .. _class_TileSetScenesCollectionSource_method_get_scene_tile_id:
  92. .. rst-class:: classref-method
  93. :ref:`int<class_int>` **get_scene_tile_id**\ (\ index\: :ref:`int<class_int>`\ ) :ref:`🔗<class_TileSetScenesCollectionSource_method_get_scene_tile_id>`
  94. Returns the scene tile ID of the scene tile at ``index``.
  95. .. rst-class:: classref-item-separator
  96. ----
  97. .. _class_TileSetScenesCollectionSource_method_get_scene_tile_scene:
  98. .. rst-class:: classref-method
  99. :ref:`PackedScene<class_PackedScene>` **get_scene_tile_scene**\ (\ id\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_TileSetScenesCollectionSource_method_get_scene_tile_scene>`
  100. Returns the :ref:`PackedScene<class_PackedScene>` resource of scene tile with ``id``.
  101. .. rst-class:: classref-item-separator
  102. ----
  103. .. _class_TileSetScenesCollectionSource_method_get_scene_tiles_count:
  104. .. rst-class:: classref-method
  105. :ref:`int<class_int>` **get_scene_tiles_count**\ (\ ) :ref:`🔗<class_TileSetScenesCollectionSource_method_get_scene_tiles_count>`
  106. Returns the number or scene tiles this TileSet source has.
  107. .. rst-class:: classref-item-separator
  108. ----
  109. .. _class_TileSetScenesCollectionSource_method_has_scene_tile_id:
  110. .. rst-class:: classref-method
  111. :ref:`bool<class_bool>` **has_scene_tile_id**\ (\ id\: :ref:`int<class_int>`\ ) :ref:`🔗<class_TileSetScenesCollectionSource_method_has_scene_tile_id>`
  112. Returns whether this TileSet source has a scene tile with ``id``.
  113. .. rst-class:: classref-item-separator
  114. ----
  115. .. _class_TileSetScenesCollectionSource_method_remove_scene_tile:
  116. .. rst-class:: classref-method
  117. |void| **remove_scene_tile**\ (\ id\: :ref:`int<class_int>`\ ) :ref:`🔗<class_TileSetScenesCollectionSource_method_remove_scene_tile>`
  118. Remove the scene tile with ``id``.
  119. .. rst-class:: classref-item-separator
  120. ----
  121. .. _class_TileSetScenesCollectionSource_method_set_scene_tile_display_placeholder:
  122. .. rst-class:: classref-method
  123. |void| **set_scene_tile_display_placeholder**\ (\ id\: :ref:`int<class_int>`, display_placeholder\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_TileSetScenesCollectionSource_method_set_scene_tile_display_placeholder>`
  124. Sets whether or not the scene tile with ``id`` should display a placeholder in the editor. This might be useful for scenes that are not visible.
  125. .. rst-class:: classref-item-separator
  126. ----
  127. .. _class_TileSetScenesCollectionSource_method_set_scene_tile_id:
  128. .. rst-class:: classref-method
  129. |void| **set_scene_tile_id**\ (\ id\: :ref:`int<class_int>`, new_id\: :ref:`int<class_int>`\ ) :ref:`🔗<class_TileSetScenesCollectionSource_method_set_scene_tile_id>`
  130. Changes a scene tile's ID from ``id`` to ``new_id``. This will fail if there is already a tile with an ID equal to ``new_id``.
  131. .. rst-class:: classref-item-separator
  132. ----
  133. .. _class_TileSetScenesCollectionSource_method_set_scene_tile_scene:
  134. .. rst-class:: classref-method
  135. |void| **set_scene_tile_scene**\ (\ id\: :ref:`int<class_int>`, packed_scene\: :ref:`PackedScene<class_PackedScene>`\ ) :ref:`🔗<class_TileSetScenesCollectionSource_method_set_scene_tile_scene>`
  136. Assigns a :ref:`PackedScene<class_PackedScene>` resource to the scene tile with ``id``. This will fail if the scene does not extend CanvasItem, as positioning properties are needed to place the scene on the TileMap.
  137. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  138. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  139. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  140. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  141. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  142. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  143. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  144. .. |void| replace:: :abbr:`void (No return value.)`