mirror of
https://github.com/godotengine/godot-docs-l10n.git
synced 2026-01-05 14:10:19 +03:00
227 lines
10 KiB
ReStructuredText
227 lines
10 KiB
ReStructuredText
:github_url: hide
|
|
|
|
.. meta::
|
|
:keywords: network
|
|
|
|
.. _class_MultiplayerSpawner:
|
|
|
|
MultiplayerSpawner
|
|
==================
|
|
|
|
**Eredita:** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
|
|
|
|
Replica automaticamente i nodi generabili dall'autorità ad altri peer multigiocatore.
|
|
|
|
.. rst-class:: classref-introduction-group
|
|
|
|
Descrizione
|
|
----------------------
|
|
|
|
Le scene generabili possono essere configurate nell'editor o tramite codice (vedi :ref:`add_spawnable_scene()<class_MultiplayerSpawner_method_add_spawnable_scene>`).
|
|
|
|
Supporta anche la generazione personalizzata di nodi tramite :ref:`spawn()<class_MultiplayerSpawner_method_spawn>`, chiamando :ref:`spawn_function<class_MultiplayerSpawner_property_spawn_function>` su tutti i peer.
|
|
|
|
Internamente, **MultiplayerSpawner** utilizza :ref:`MultiplayerAPI.object_configuration_add()<class_MultiplayerAPI_method_object_configuration_add>` per notificare le generazioni, passando il nodo generato come ``object`` e se stesso come ``configuration``, e :ref:`MultiplayerAPI.object_configuration_remove()<class_MultiplayerAPI_method_object_configuration_remove>` per notificare le eliminazioni in modo simile.
|
|
|
|
.. rst-class:: classref-reftable-group
|
|
|
|
Proprietà
|
|
------------------
|
|
|
|
.. table::
|
|
:widths: auto
|
|
|
|
+---------------------------------+-------------------------------------------------------------------------+------------------+
|
|
| :ref:`Callable<class_Callable>` | :ref:`spawn_function<class_MultiplayerSpawner_property_spawn_function>` | |
|
|
+---------------------------------+-------------------------------------------------------------------------+------------------+
|
|
| :ref:`int<class_int>` | :ref:`spawn_limit<class_MultiplayerSpawner_property_spawn_limit>` | ``0`` |
|
|
+---------------------------------+-------------------------------------------------------------------------+------------------+
|
|
| :ref:`NodePath<class_NodePath>` | :ref:`spawn_path<class_MultiplayerSpawner_property_spawn_path>` | ``NodePath("")`` |
|
|
+---------------------------------+-------------------------------------------------------------------------+------------------+
|
|
|
|
.. rst-class:: classref-reftable-group
|
|
|
|
Metodi
|
|
------------
|
|
|
|
.. table::
|
|
:widths: auto
|
|
|
|
+-----------------------------+------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`add_spawnable_scene<class_MultiplayerSpawner_method_add_spawnable_scene>`\ (\ path\: :ref:`String<class_String>`\ ) |
|
|
+-----------------------------+------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`clear_spawnable_scenes<class_MultiplayerSpawner_method_clear_spawnable_scenes>`\ (\ ) |
|
|
+-----------------------------+------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`String<class_String>` | :ref:`get_spawnable_scene<class_MultiplayerSpawner_method_get_spawnable_scene>`\ (\ index\: :ref:`int<class_int>`\ ) |const| |
|
|
+-----------------------------+------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`get_spawnable_scene_count<class_MultiplayerSpawner_method_get_spawnable_scene_count>`\ (\ ) |const| |
|
|
+-----------------------------+------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Node<class_Node>` | :ref:`spawn<class_MultiplayerSpawner_method_spawn>`\ (\ data\: :ref:`Variant<class_Variant>` = null\ ) |
|
|
+-----------------------------+------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
Segnali
|
|
--------------
|
|
|
|
.. _class_MultiplayerSpawner_signal_despawned:
|
|
|
|
.. rst-class:: classref-signal
|
|
|
|
**despawned**\ (\ node\: :ref:`Node<class_Node>`\ ) :ref:`🔗<class_MultiplayerSpawner_signal_despawned>`
|
|
|
|
Emesso quando una scena generabile o una generazione personalizzata è stata rimossa dall'autorità multigiocatore. Chiamato solo sui peer remoti.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_MultiplayerSpawner_signal_spawned:
|
|
|
|
.. rst-class:: classref-signal
|
|
|
|
**spawned**\ (\ node\: :ref:`Node<class_Node>`\ ) :ref:`🔗<class_MultiplayerSpawner_signal_spawned>`
|
|
|
|
Emesso quando una scena generabile o una generazione personalizzata è stata generata dall'autorità multigiocatore. Chiamato solo sui peer remoti.
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
Descrizioni delle proprietà
|
|
------------------------------------------------------
|
|
|
|
.. _class_MultiplayerSpawner_property_spawn_function:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`Callable<class_Callable>` **spawn_function** :ref:`🔗<class_MultiplayerSpawner_property_spawn_function>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_spawn_function**\ (\ value\: :ref:`Callable<class_Callable>`\ )
|
|
- :ref:`Callable<class_Callable>` **get_spawn_function**\ (\ )
|
|
|
|
Metodo chiamato su tutti i peer quando un :ref:`spawn()<class_MultiplayerSpawner_method_spawn>` personalizzato viene richiesto dall'autorità. Riceverà il parametro ``data`` e dovrebbe restituire un :ref:`Node<class_Node>` che non è nell'albero di scene.
|
|
|
|
\ **Nota:** Il nodo restituito **non** dovrebbe essere aggiunto alla scena con :ref:`Node.add_child()<class_Node_method_add_child>`. Ciò avviene automaticamente.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_MultiplayerSpawner_property_spawn_limit:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`int<class_int>` **spawn_limit** = ``0`` :ref:`🔗<class_MultiplayerSpawner_property_spawn_limit>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_spawn_limit**\ (\ value\: :ref:`int<class_int>`\ )
|
|
- :ref:`int<class_int>` **get_spawn_limit**\ (\ )
|
|
|
|
Numero massimo di nodi che questo generatore può generare. Include sia scene generabili sia generazioni personalizzate.
|
|
|
|
Se impostato su ``0`` (predefinito), non ci sono limiti.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_MultiplayerSpawner_property_spawn_path:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`NodePath<class_NodePath>` **spawn_path** = ``NodePath("")`` :ref:`🔗<class_MultiplayerSpawner_property_spawn_path>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_spawn_path**\ (\ value\: :ref:`NodePath<class_NodePath>`\ )
|
|
- :ref:`NodePath<class_NodePath>` **get_spawn_path**\ (\ )
|
|
|
|
Percorso verso la radice di generazione. Le scene generabili aggiunte come figlie dirette sono replicate sugli altri peer.
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
Descrizioni dei metodi
|
|
--------------------------------------------
|
|
|
|
.. _class_MultiplayerSpawner_method_add_spawnable_scene:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **add_spawnable_scene**\ (\ path\: :ref:`String<class_String>`\ ) :ref:`🔗<class_MultiplayerSpawner_method_add_spawnable_scene>`
|
|
|
|
Aggiunge un percorso di scena alle scene generabili, facendolo replicare automaticamente dall'autorità multigiocatore ad altri peer quando vengono aggiunti come figli del nodo puntato da :ref:`spawn_path<class_MultiplayerSpawner_property_spawn_path>`.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_MultiplayerSpawner_method_clear_spawnable_scenes:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **clear_spawnable_scenes**\ (\ ) :ref:`🔗<class_MultiplayerSpawner_method_clear_spawnable_scenes>`
|
|
|
|
Cancella tutte le scene generabili. Non elimina le istanze esistenti sui peer remoti.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_MultiplayerSpawner_method_get_spawnable_scene:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`String<class_String>` **get_spawnable_scene**\ (\ index\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_MultiplayerSpawner_method_get_spawnable_scene>`
|
|
|
|
Restituisce il percorso della scena generabile per indice.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_MultiplayerSpawner_method_get_spawnable_scene_count:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`int<class_int>` **get_spawnable_scene_count**\ (\ ) |const| :ref:`🔗<class_MultiplayerSpawner_method_get_spawnable_scene_count>`
|
|
|
|
Restituisce il numero di percorsi di scene generabili.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_MultiplayerSpawner_method_spawn:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`Node<class_Node>` **spawn**\ (\ data\: :ref:`Variant<class_Variant>` = null\ ) :ref:`🔗<class_MultiplayerSpawner_method_spawn>`
|
|
|
|
Richiede una generazione personalizzata, con ``data`` passato a :ref:`spawn_function<class_MultiplayerSpawner_property_spawn_function>` su tutti i peer. Restituisce l'istanza del nodo generato localmente già all'interno dell'albero di scene e aggiunto come figlio del nodo puntato da :ref:`spawn_path<class_MultiplayerSpawner_property_spawn_path>`.
|
|
|
|
\ **Nota:** Le scene generabili sono generate automaticamente. :ref:`spawn()<class_MultiplayerSpawner_method_spawn>` è necessario solo per le generazioni personalizzate.
|
|
|
|
.. |virtual| replace:: :abbr:`virtual (Questo metodo dovrebbe solitamente essere sovrascritto dall'utente per aver un effetto.)`
|
|
.. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
|
|
.. |const| replace:: :abbr:`const (Questo metodo non ha effetti collaterali. Non modifica alcuna variabile appartenente all'istanza.)`
|
|
.. |vararg| replace:: :abbr:`vararg (Questo metodo accetta qualsiasi numero di argomenti oltre a quelli descritti qui.)`
|
|
.. |constructor| replace:: :abbr:`constructor (Questo metodo è utilizzato per creare un tipo.)`
|
|
.. |static| replace:: :abbr:`static (Questo metodo non necessita di alcun'istanza per essere chiamato, quindi può essere chiamato direttamente usando il nome della classe.)`
|
|
.. |operator| replace:: :abbr:`operator (Questo metodo descrive un operatore valido da usare con questo tipo come operando di sinistra.)`
|
|
.. |bitfield| replace:: :abbr:`BitField (Questo valore è un intero composto da una maschera di bit dei seguenti flag.)`
|
|
.. |void| replace:: :abbr:`void (Nessun valore restituito.)`
|