0.2.0-dev Download ZIP
76 lines ·3.9 KB Raw
| 1 | <?xml version="1.0" encoding="UTF-8" ?> |
| 2 | <class name="MultiplayerSpawner" inherits="Node" api_type="core" keywords="network" 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 [member spawn_function] 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="add_spawnable_scene"> |
| 15 | <return type="void" /> |
| 16 | <param index="0" name="path" type="String" /> |
| 17 | <description> |
| 18 | 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]. |
| 19 | </description> |
| 20 | </method> |
| 21 | <method name="clear_spawnable_scenes"> |
| 22 | <return type="void" /> |
| 23 | <description> |
| 24 | Clears all spawnable scenes. Does not despawn existing instances on remote peers. |
| 25 | </description> |
| 26 | </method> |
| 27 | <method name="get_spawnable_scene" qualifiers="const"> |
| 28 | <return type="String" /> |
| 29 | <param index="0" name="index" type="int" /> |
| 30 | <description> |
| 31 | Returns the spawnable scene path by index. |
| 32 | </description> |
| 33 | </method> |
| 34 | <method name="get_spawnable_scene_count" qualifiers="const"> |
| 35 | <return type="int" /> |
| 36 | <description> |
| 37 | Returns the count of spawnable scene paths. |
| 38 | </description> |
| 39 | </method> |
| 40 | <method name="spawn"> |
| 41 | <return type="Node" /> |
| 42 | <param index="0" name="data" type="Variant" default="null" /> |
| 43 | <description> |
| 44 | Requests a custom spawn, with [param data] passed to [member 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 [member spawn_path]. |
| 45 | [b]Note:[/b] Spawnable scenes are spawned automatically. [method spawn] is only needed for custom spawns. |
| 46 | </description> |
| 47 | </method> |
| 48 | </methods> |
| 49 | <members> |
| 50 | <member name="spawn_function" type="Callable" setter="set_spawn_function" getter="get_spawn_function"> |
| 51 | Method called on all peers when a custom [method spawn] is requested by the authority. Will receive the [code]data[/code] parameter, and should return a [Node] that is not in the scene tree. |
| 52 | [b]Note:[/b] The returned node should [b]not[/b] be added to the scene with [method Node.add_child]. This is done automatically. |
| 53 | </member> |
| 54 | <member name="spawn_limit" type="int" setter="set_spawn_limit" getter="get_spawn_limit" default="0"> |
| 55 | Maximum number of nodes allowed to be spawned by this spawner. Includes both spawnable scenes and custom spawns. |
| 56 | When set to [code]0[/code] (the default), there is no limit. |
| 57 | </member> |
| 58 | <member name="spawn_path" type="NodePath" setter="set_spawn_path" getter="get_spawn_path" default="NodePath("")"> |
| 59 | Path to the spawn root. Spawnable scenes that are added as direct children are replicated to other peers. |
| 60 | </member> |
| 61 | </members> |
| 62 | <signals> |
| 63 | <signal name="despawned"> |
| 64 | <param index="0" name="node" type="Node" /> |
| 65 | <description> |
| 66 | Emitted when a spawnable scene or custom spawn was despawned by the multiplayer authority. Only called on remote peers. |
| 67 | </description> |
| 68 | </signal> |
| 69 | <signal name="spawned"> |
| 70 | <param index="0" name="node" type="Node" /> |
| 71 | <description> |
| 72 | Emitted when a spawnable scene or custom spawn was spawned by the multiplayer authority. Only called on remote peers. |
| 73 | </description> |
| 74 | </signal> |
| 75 | </signals> |
| 76 | </class> |