MultiplayerSpawner.xml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="MultiplayerSpawner" inherits="Node" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
  3. <brief_description>
  4. Automatically replicates spawnable nodes from the authority to other multiplayer peers.
  5. </brief_description>
  6. <description>
  7. Spawnable scenes can be configured in the editor or through code (see [method add_spawnable_scene]).
  8. Also supports custom node spawns through [method spawn], calling [method _spawn_custom] on all peers.
  9. Internally, [MultiplayerSpawner] uses [method MultiplayerAPI.object_configuration_add] to notify spawns passing the spawned node as the [code]object[/code] and itself as the [code]configuration[/code], and [method MultiplayerAPI.object_configuration_remove] to notify despawns in a similar way.
  10. </description>
  11. <tutorials>
  12. </tutorials>
  13. <methods>
  14. <method name="_spawn_custom" qualifiers="virtual">
  15. <return type="Node" />
  16. <param index="0" name="data" type="Variant" />
  17. <description>
  18. Method called on all peers when a custom spawn was requested by the authority using [method spawn]. Should return a [Node] that is not in the scene tree.
  19. [b]Note:[/b] Spawned nodes should [b]not[/b] be added to the scene with `add_child`. This is done automatically.
  20. </description>
  21. </method>
  22. <method name="add_spawnable_scene">
  23. <return type="void" />
  24. <param index="0" name="path" type="String" />
  25. <description>
  26. 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 [member spawn_path].
  27. </description>
  28. </method>
  29. <method name="clear_spawnable_scenes">
  30. <return type="void" />
  31. <description>
  32. Clears all spawnable scenes. Does not despawn existing instances on remote peers.
  33. </description>
  34. </method>
  35. <method name="get_spawnable_scene" qualifiers="const">
  36. <return type="String" />
  37. <param index="0" name="index" type="int" />
  38. <description>
  39. Returns the spawnable scene path by index.
  40. </description>
  41. </method>
  42. <method name="get_spawnable_scene_count" qualifiers="const">
  43. <return type="int" />
  44. <description>
  45. Returns the count of spawnable scene paths.
  46. </description>
  47. </method>
  48. <method name="spawn">
  49. <return type="Node" />
  50. <param index="0" name="data" type="Variant" default="null" />
  51. <description>
  52. Requests a custom spawn, with [code]data[/code] passed to [method _spawn_custom] on all peers. Returns the locally spawned node instance already inside the scene tree, and added as a child of the node pointed by [member spawn_path].
  53. [b]Note:[/b] Spawnable scenes are spawned automatically. [method spawn] is only needed for custom spawns.
  54. </description>
  55. </method>
  56. </methods>
  57. <members>
  58. <member name="spawn_limit" type="int" setter="set_spawn_limit" getter="get_spawn_limit" default="0">
  59. Maximum nodes that is allowed to be spawned by this spawner. Includes both spawnable scenes and custom spawns.
  60. When set to [code]0[/code] (the default), there is no limit.
  61. </member>
  62. <member name="spawn_path" type="NodePath" setter="set_spawn_path" getter="get_spawn_path" default="NodePath(&quot;&quot;)">
  63. Path to the spawn root. Spawnable scenes that are added as direct children are replicated to other peers.
  64. </member>
  65. </members>
  66. <signals>
  67. <signal name="despawned">
  68. <param index="0" name="node" type="Node" />
  69. <description>
  70. Emitted when a spawnable scene or custom spawn was despawned by the multiplayer authority. Only called on puppets.
  71. </description>
  72. </signal>
  73. <signal name="spawned">
  74. <param index="0" name="node" type="Node" />
  75. <description>
  76. Emitted when a spawnable scene or custom spawn was spawned by the multiplayer authority. Only called on puppets.
  77. </description>
  78. </signal>
  79. </signals>
  80. </class>