2
0

MultiplayerSynchronizer.xml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="MultiplayerSynchronizer" inherits="Node" version="4.0" 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. Visiblity 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. </description>
  12. <tutorials>
  13. </tutorials>
  14. <methods>
  15. <method name="add_visibility_filter">
  16. <return type="void" />
  17. <param index="0" name="filter" type="Callable" />
  18. <description>
  19. Adds a peer visibility filter for this synchronizer.
  20. [code]filter[/code] should take a peer id [int] and return a [bool].
  21. </description>
  22. </method>
  23. <method name="get_visibility_for" qualifiers="const">
  24. <return type="bool" />
  25. <param index="0" name="peer" type="int" />
  26. <description>
  27. Queries the current visibility for peer [code]peer[/code].
  28. </description>
  29. </method>
  30. <method name="remove_visibility_filter">
  31. <return type="void" />
  32. <param index="0" name="filter" type="Callable" />
  33. <description>
  34. Removes a peer visiblity filter from this synchronizer.
  35. </description>
  36. </method>
  37. <method name="set_visibility_for">
  38. <return type="void" />
  39. <param index="0" name="peer" type="int" />
  40. <param index="1" name="visible" type="bool" />
  41. <description>
  42. Sets the visibility of [code]peer[/code] to [code]visible[/code]. If [code]peer[/code] is [code]0[/code], the value of [member public_visibility] will be updated instead.
  43. </description>
  44. </method>
  45. <method name="update_visibility">
  46. <return type="void" />
  47. <param index="0" name="for_peer" type="int" default="0" />
  48. <description>
  49. Updates the visibility of [code]peer[/code] according to visibility filters. If [code]peer[/code] is [code]0[/code] (the default), all peers' visibilties are updated.
  50. </description>
  51. </method>
  52. </methods>
  53. <members>
  54. <member name="public_visibility" type="bool" setter="set_visibility_public" getter="is_visibility_public" default="true">
  55. 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.
  56. </member>
  57. <member name="replication_config" type="SceneReplicationConfig" setter="set_replication_config" getter="get_replication_config">
  58. Resource containing which properties to synchronize.
  59. </member>
  60. <member name="replication_interval" type="float" setter="set_replication_interval" getter="get_replication_interval" default="0.0">
  61. Time interval between synchronizes. When set to [code]0.0[/code] (the default), synchronizes happen every network process frame.
  62. </member>
  63. <member name="root_path" type="NodePath" setter="set_root_path" getter="get_root_path" default="NodePath(&quot;..&quot;)">
  64. Node path that replicated properties are relative to.
  65. If [member root_path] was spawned by a [MultiplayerSpawner], the node will be also be spawned and despawned based on this synchronizer visibility options.
  66. </member>
  67. <member name="visibility_update_mode" type="int" setter="set_visibility_update_mode" getter="get_visibility_update_mode" enum="MultiplayerSynchronizer.VisibilityUpdateMode" default="0">
  68. Specifies when visibility filters are updated (see [enum VisibilityUpdateMode] for options).
  69. </member>
  70. </members>
  71. <signals>
  72. <signal name="visibility_changed">
  73. <param index="0" name="for_peer" type="int" />
  74. <description>
  75. Emitted when visibility of [code]for_peer[/code] is updated. See [method update_visibility].
  76. </description>
  77. </signal>
  78. </signals>
  79. <constants>
  80. <constant name="VISIBILITY_PROCESS_IDLE" value="0" enum="VisibilityUpdateMode">
  81. Visibility filters are updated every idle process frame.
  82. </constant>
  83. <constant name="VISIBILITY_PROCESS_PHYSICS" value="1" enum="VisibilityUpdateMode">
  84. Visibility filters are updated every physics process frame.
  85. </constant>
  86. <constant name="VISIBILITY_PROCESS_NONE" value="2" enum="VisibilityUpdateMode">
  87. Visibility filters are not updated automatically, and must be updated manually by calling [method update_visibility].
  88. </constant>
  89. </constants>
  90. </class>