MultiplayerSynchronizer.xml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="MultiplayerSynchronizer" inherits="Node" keywords="network" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
  3. <brief_description>
  4. Synchronizes properties from the multiplayer authority to the remote peers.
  5. </brief_description>
  6. <description>
  7. By default, [MultiplayerSynchronizer] synchronizes configured properties to all peers.
  8. Visibility can be handled directly with [method set_visibility_for] or as-needed with [method add_visibility_filter] and [method update_visibility].
  9. [MultiplayerSpawner]s will handle nodes according to visibility of synchronizers as long as the node at [member root_path] was spawned by one.
  10. Internally, [MultiplayerSynchronizer] uses [method MultiplayerAPI.object_configuration_add] to notify synchronization start passing the [Node] at [member root_path] as the [code]object[/code] and itself as the [code]configuration[/code], and uses [method MultiplayerAPI.object_configuration_remove] to notify synchronization end in a similar way.
  11. [b]Note:[/b] Synchronization is not supported for [Object] type properties, like [Resource]. Properties that are unique to each peer, like the instance IDs of [Object]s (see [method Object.get_instance_id]) or [RID]s, will also not work in synchronization.
  12. </description>
  13. <tutorials>
  14. </tutorials>
  15. <methods>
  16. <method name="add_visibility_filter">
  17. <return type="void" />
  18. <param index="0" name="filter" type="Callable" />
  19. <description>
  20. Adds a peer visibility filter for this synchronizer.
  21. [param filter] should take a peer ID [int] and return a [bool].
  22. </description>
  23. </method>
  24. <method name="get_visibility_for" qualifiers="const">
  25. <return type="bool" />
  26. <param index="0" name="peer" type="int" />
  27. <description>
  28. Queries the current visibility for peer [param peer].
  29. </description>
  30. </method>
  31. <method name="remove_visibility_filter">
  32. <return type="void" />
  33. <param index="0" name="filter" type="Callable" />
  34. <description>
  35. Removes a peer visibility filter from this synchronizer.
  36. </description>
  37. </method>
  38. <method name="set_visibility_for">
  39. <return type="void" />
  40. <param index="0" name="peer" type="int" />
  41. <param index="1" name="visible" type="bool" />
  42. <description>
  43. Sets the visibility of [param peer] to [param visible]. If [param peer] is [code]0[/code], the value of [member public_visibility] will be updated instead.
  44. </description>
  45. </method>
  46. <method name="update_visibility">
  47. <return type="void" />
  48. <param index="0" name="for_peer" type="int" default="0" />
  49. <description>
  50. Updates the visibility of [param for_peer] according to visibility filters. If [param for_peer] is [code]0[/code] (the default), all peers' visibilties are updated.
  51. </description>
  52. </method>
  53. </methods>
  54. <members>
  55. <member name="delta_interval" type="float" setter="set_delta_interval" getter="get_delta_interval" default="0.0">
  56. Time interval between delta synchronizations. Used when the replication is set to [constant SceneReplicationConfig.REPLICATION_MODE_ON_CHANGE]. If set to [code]0.0[/code] (the default), delta synchronizations happen every network process frame.
  57. </member>
  58. <member name="public_visibility" type="bool" setter="set_visibility_public" getter="is_visibility_public" default="true">
  59. Whether synchronization should be visible to all peers by default. See [method set_visibility_for] and [method add_visibility_filter] for ways of configuring fine-grained visibility options.
  60. </member>
  61. <member name="replication_config" type="SceneReplicationConfig" setter="set_replication_config" getter="get_replication_config">
  62. Resource containing which properties to synchronize.
  63. </member>
  64. <member name="replication_interval" type="float" setter="set_replication_interval" getter="get_replication_interval" default="0.0">
  65. Time interval between synchronizations. Used when the replication is set to [constant SceneReplicationConfig.REPLICATION_MODE_ALWAYS]. If set to [code]0.0[/code] (the default), synchronizations happen every network process frame.
  66. </member>
  67. <member name="root_path" type="NodePath" setter="set_root_path" getter="get_root_path" default="NodePath(&quot;..&quot;)">
  68. Node path that replicated properties are relative to.
  69. If [member root_path] was spawned by a [MultiplayerSpawner], the node will be also be spawned and despawned based on this synchronizer visibility options.
  70. </member>
  71. <member name="visibility_update_mode" type="int" setter="set_visibility_update_mode" getter="get_visibility_update_mode" enum="MultiplayerSynchronizer.VisibilityUpdateMode" default="0">
  72. Specifies when visibility filters are updated (see [enum VisibilityUpdateMode] for options).
  73. </member>
  74. </members>
  75. <signals>
  76. <signal name="delta_synchronized">
  77. <description>
  78. Emitted when a new delta synchronization state is received by this synchronizer after the properties have been updated.
  79. </description>
  80. </signal>
  81. <signal name="synchronized">
  82. <description>
  83. Emitted when a new synchronization state is received by this synchronizer after the properties have been updated.
  84. </description>
  85. </signal>
  86. <signal name="visibility_changed">
  87. <param index="0" name="for_peer" type="int" />
  88. <description>
  89. Emitted when visibility of [param for_peer] is updated. See [method update_visibility].
  90. </description>
  91. </signal>
  92. </signals>
  93. <constants>
  94. <constant name="VISIBILITY_PROCESS_IDLE" value="0" enum="VisibilityUpdateMode">
  95. Visibility filters are updated during process frames (see [constant Node.NOTIFICATION_INTERNAL_PROCESS]).
  96. </constant>
  97. <constant name="VISIBILITY_PROCESS_PHYSICS" value="1" enum="VisibilityUpdateMode">
  98. Visibility filters are updated during physics frames (see [constant Node.NOTIFICATION_INTERNAL_PHYSICS_PROCESS]).
  99. </constant>
  100. <constant name="VISIBILITY_PROCESS_NONE" value="2" enum="VisibilityUpdateMode">
  101. Visibility filters are not updated automatically, and must be updated manually by calling [method update_visibility].
  102. </constant>
  103. </constants>
  104. </class>