class_multiplayerspawner.rst 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. :github_url: hide
  2. .. meta::
  3. :keywords: network
  4. .. DO NOT EDIT THIS FILE!!!
  5. .. Generated automatically from Godot engine sources.
  6. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  7. .. XML source: https://github.com/godotengine/godot/tree/master/modules/multiplayer/doc_classes/MultiplayerSpawner.xml.
  8. .. _class_MultiplayerSpawner:
  9. MultiplayerSpawner
  10. ==================
  11. **Inherits:** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  12. Automatically replicates spawnable nodes from the authority to other multiplayer peers.
  13. .. rst-class:: classref-introduction-group
  14. Description
  15. -----------
  16. Spawnable scenes can be configured in the editor or through code (see :ref:`add_spawnable_scene<class_MultiplayerSpawner_method_add_spawnable_scene>`).
  17. Also supports custom node spawns through :ref:`spawn<class_MultiplayerSpawner_method_spawn>`, calling :ref:`spawn_function<class_MultiplayerSpawner_property_spawn_function>` on all peers.
  18. Internally, **MultiplayerSpawner** uses :ref:`MultiplayerAPI.object_configuration_add<class_MultiplayerAPI_method_object_configuration_add>` to notify spawns passing the spawned node as the ``object`` and itself as the ``configuration``, and :ref:`MultiplayerAPI.object_configuration_remove<class_MultiplayerAPI_method_object_configuration_remove>` to notify despawns in a similar way.
  19. .. rst-class:: classref-reftable-group
  20. Properties
  21. ----------
  22. .. table::
  23. :widths: auto
  24. +---------------------------------+-------------------------------------------------------------------------+------------------+
  25. | :ref:`Callable<class_Callable>` | :ref:`spawn_function<class_MultiplayerSpawner_property_spawn_function>` | |
  26. +---------------------------------+-------------------------------------------------------------------------+------------------+
  27. | :ref:`int<class_int>` | :ref:`spawn_limit<class_MultiplayerSpawner_property_spawn_limit>` | ``0`` |
  28. +---------------------------------+-------------------------------------------------------------------------+------------------+
  29. | :ref:`NodePath<class_NodePath>` | :ref:`spawn_path<class_MultiplayerSpawner_property_spawn_path>` | ``NodePath("")`` |
  30. +---------------------------------+-------------------------------------------------------------------------+------------------+
  31. .. rst-class:: classref-reftable-group
  32. Methods
  33. -------
  34. .. table::
  35. :widths: auto
  36. +-----------------------------+------------------------------------------------------------------------------------------------------------------------------+
  37. | |void| | :ref:`add_spawnable_scene<class_MultiplayerSpawner_method_add_spawnable_scene>`\ (\ path\: :ref:`String<class_String>`\ ) |
  38. +-----------------------------+------------------------------------------------------------------------------------------------------------------------------+
  39. | |void| | :ref:`clear_spawnable_scenes<class_MultiplayerSpawner_method_clear_spawnable_scenes>`\ (\ ) |
  40. +-----------------------------+------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`String<class_String>` | :ref:`get_spawnable_scene<class_MultiplayerSpawner_method_get_spawnable_scene>`\ (\ index\: :ref:`int<class_int>`\ ) |const| |
  42. +-----------------------------+------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`int<class_int>` | :ref:`get_spawnable_scene_count<class_MultiplayerSpawner_method_get_spawnable_scene_count>`\ (\ ) |const| |
  44. +-----------------------------+------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`Node<class_Node>` | :ref:`spawn<class_MultiplayerSpawner_method_spawn>`\ (\ data\: :ref:`Variant<class_Variant>` = null\ ) |
  46. +-----------------------------+------------------------------------------------------------------------------------------------------------------------------+
  47. .. rst-class:: classref-section-separator
  48. ----
  49. .. rst-class:: classref-descriptions-group
  50. Signals
  51. -------
  52. .. _class_MultiplayerSpawner_signal_despawned:
  53. .. rst-class:: classref-signal
  54. **despawned**\ (\ node\: :ref:`Node<class_Node>`\ ) :ref:`🔗<class_MultiplayerSpawner_signal_despawned>`
  55. Emitted when a spawnable scene or custom spawn was despawned by the multiplayer authority. Only called on remote peers.
  56. .. rst-class:: classref-item-separator
  57. ----
  58. .. _class_MultiplayerSpawner_signal_spawned:
  59. .. rst-class:: classref-signal
  60. **spawned**\ (\ node\: :ref:`Node<class_Node>`\ ) :ref:`🔗<class_MultiplayerSpawner_signal_spawned>`
  61. Emitted when a spawnable scene or custom spawn was spawned by the multiplayer authority. Only called on remote peers.
  62. .. rst-class:: classref-section-separator
  63. ----
  64. .. rst-class:: classref-descriptions-group
  65. Property Descriptions
  66. ---------------------
  67. .. _class_MultiplayerSpawner_property_spawn_function:
  68. .. rst-class:: classref-property
  69. :ref:`Callable<class_Callable>` **spawn_function** :ref:`🔗<class_MultiplayerSpawner_property_spawn_function>`
  70. .. rst-class:: classref-property-setget
  71. - |void| **set_spawn_function**\ (\ value\: :ref:`Callable<class_Callable>`\ )
  72. - :ref:`Callable<class_Callable>` **get_spawn_function**\ (\ )
  73. Method called on all peers when a custom :ref:`spawn<class_MultiplayerSpawner_method_spawn>` is requested by the authority. Will receive the ``data`` parameter, and should return a :ref:`Node<class_Node>` that is not in the scene tree.
  74. \ **Note:** The returned node should **not** be added to the scene with :ref:`Node.add_child<class_Node_method_add_child>`. This is done automatically.
  75. .. rst-class:: classref-item-separator
  76. ----
  77. .. _class_MultiplayerSpawner_property_spawn_limit:
  78. .. rst-class:: classref-property
  79. :ref:`int<class_int>` **spawn_limit** = ``0`` :ref:`🔗<class_MultiplayerSpawner_property_spawn_limit>`
  80. .. rst-class:: classref-property-setget
  81. - |void| **set_spawn_limit**\ (\ value\: :ref:`int<class_int>`\ )
  82. - :ref:`int<class_int>` **get_spawn_limit**\ (\ )
  83. Maximum number of nodes allowed to be spawned by this spawner. Includes both spawnable scenes and custom spawns.
  84. When set to ``0`` (the default), there is no limit.
  85. .. rst-class:: classref-item-separator
  86. ----
  87. .. _class_MultiplayerSpawner_property_spawn_path:
  88. .. rst-class:: classref-property
  89. :ref:`NodePath<class_NodePath>` **spawn_path** = ``NodePath("")`` :ref:`🔗<class_MultiplayerSpawner_property_spawn_path>`
  90. .. rst-class:: classref-property-setget
  91. - |void| **set_spawn_path**\ (\ value\: :ref:`NodePath<class_NodePath>`\ )
  92. - :ref:`NodePath<class_NodePath>` **get_spawn_path**\ (\ )
  93. Path to the spawn root. Spawnable scenes that are added as direct children are replicated to other peers.
  94. .. rst-class:: classref-section-separator
  95. ----
  96. .. rst-class:: classref-descriptions-group
  97. Method Descriptions
  98. -------------------
  99. .. _class_MultiplayerSpawner_method_add_spawnable_scene:
  100. .. rst-class:: classref-method
  101. |void| **add_spawnable_scene**\ (\ path\: :ref:`String<class_String>`\ ) :ref:`🔗<class_MultiplayerSpawner_method_add_spawnable_scene>`
  102. Adds a scene path to spawnable scenes, making it automatically replicated from the multiplayer authority to other peers when added as children of the node pointed by :ref:`spawn_path<class_MultiplayerSpawner_property_spawn_path>`.
  103. .. rst-class:: classref-item-separator
  104. ----
  105. .. _class_MultiplayerSpawner_method_clear_spawnable_scenes:
  106. .. rst-class:: classref-method
  107. |void| **clear_spawnable_scenes**\ (\ ) :ref:`🔗<class_MultiplayerSpawner_method_clear_spawnable_scenes>`
  108. Clears all spawnable scenes. Does not despawn existing instances on remote peers.
  109. .. rst-class:: classref-item-separator
  110. ----
  111. .. _class_MultiplayerSpawner_method_get_spawnable_scene:
  112. .. rst-class:: classref-method
  113. :ref:`String<class_String>` **get_spawnable_scene**\ (\ index\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_MultiplayerSpawner_method_get_spawnable_scene>`
  114. Returns the spawnable scene path by index.
  115. .. rst-class:: classref-item-separator
  116. ----
  117. .. _class_MultiplayerSpawner_method_get_spawnable_scene_count:
  118. .. rst-class:: classref-method
  119. :ref:`int<class_int>` **get_spawnable_scene_count**\ (\ ) |const| :ref:`🔗<class_MultiplayerSpawner_method_get_spawnable_scene_count>`
  120. Returns the count of spawnable scene paths.
  121. .. rst-class:: classref-item-separator
  122. ----
  123. .. _class_MultiplayerSpawner_method_spawn:
  124. .. rst-class:: classref-method
  125. :ref:`Node<class_Node>` **spawn**\ (\ data\: :ref:`Variant<class_Variant>` = null\ ) :ref:`🔗<class_MultiplayerSpawner_method_spawn>`
  126. Requests a custom spawn, with ``data`` passed to :ref:`spawn_function<class_MultiplayerSpawner_property_spawn_function>` on all peers. Returns the locally spawned node instance already inside the scene tree, and added as a child of the node pointed by :ref:`spawn_path<class_MultiplayerSpawner_property_spawn_path>`.
  127. \ **Note:** Spawnable scenes are spawned automatically. :ref:`spawn<class_MultiplayerSpawner_method_spawn>` is only needed for custom spawns.
  128. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  129. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  130. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  131. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  132. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  133. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  134. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  135. .. |void| replace:: :abbr:`void (No return value.)`