From aee2240d5f75738a1c040a2ea6958bc578fb418a Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Sat, 5 Feb 2022 01:43:47 +0100 Subject: [Net] Allow branch-specific MultiplayerAPIs. Removes custom_multiplayer from Node. MultiplayerAPI overrides are now set at SceneTree level, and apply to whole branches. Impact on performance when using only the default multiplayer or overriding it is minimal, the use of branches can likely be further optimized by caching nodes and relevant MultiplayerAPI IDs. --- doc/classes/MultiplayerAPI.xml | 4 ++-- doc/classes/Node.xml | 5 +---- doc/classes/SceneTree.xml | 18 +++++++++++++++--- 3 files changed, 18 insertions(+), 9 deletions(-) (limited to 'doc/classes') diff --git a/doc/classes/MultiplayerAPI.xml b/doc/classes/MultiplayerAPI.xml index ac17886183..059d147979 100644 --- a/doc/classes/MultiplayerAPI.xml +++ b/doc/classes/MultiplayerAPI.xml @@ -6,7 +6,7 @@ This class implements the high-level multiplayer API. See also [MultiplayerPeer]. By default, [SceneTree] has a reference to this class that is used to provide multiplayer capabilities (i.e. RPCs) across the whole scene. - It is possible to override the MultiplayerAPI instance used by specific Nodes by setting the [member Node.custom_multiplayer] property, effectively allowing to run both client and server in the same scene. + It is possible to override the MultiplayerAPI instance used by specific tree branches by calling the [method SceneTree.set_multiplayer] method, effectively allowing to run both client and server in the same scene. [b]Note:[/b] The high-level multiplayer API protocol is an implementation detail and isn't meant to be used by non-Godot servers. It may change without notice. [b]Note:[/b] When exporting to Android, make sure to enable the [code]INTERNET[/code] permission in the Android export preset before exporting the project or using one-click deploy. Otherwise, network communication of any kind will be blocked by Android. @@ -53,7 +53,7 @@ - Method used for polling the MultiplayerAPI. You only need to worry about this if you are using [member Node.custom_multiplayer] override or you set [member SceneTree.multiplayer_poll] to [code]false[/code]. By default, [SceneTree] will poll its MultiplayerAPI for you. + Method used for polling the MultiplayerAPI. You only need to worry about this if you set [member SceneTree.multiplayer_poll] to [code]false[/code]. By default, [SceneTree] will poll its MultiplayerAPI(s) for you. [b]Note:[/b] This method results in RPCs being called, so they will be executed in the same context of this function (e.g. [code]_process[/code], [code]physics[/code], [Thread]). diff --git a/doc/classes/Node.xml b/doc/classes/Node.xml index 56c80078b3..c9795856d5 100644 --- a/doc/classes/Node.xml +++ b/doc/classes/Node.xml @@ -745,14 +745,11 @@ - - The override to the default [MultiplayerAPI]. Set to [code]null[/code] to use the default [SceneTree] one. - Add a custom description to a node. It will be displayed in a tooltip when hovered in editor's scene tree. - The [MultiplayerAPI] instance associated with this node. Either the [member custom_multiplayer], or the default SceneTree one (if inside tree). + The [MultiplayerAPI] instance associated with this node. See [method SceneTree.get_multiplayer]. The name of the node. This name is unique among the siblings (other child nodes from the same parent). When set to an existing name, the node will be automatically renamed. diff --git a/doc/classes/SceneTree.xml b/doc/classes/SceneTree.xml index 77023d2126..ddff766b17 100644 --- a/doc/classes/SceneTree.xml +++ b/doc/classes/SceneTree.xml @@ -99,6 +99,13 @@ Returns the current frame number, i.e. the total frame count since the application started. + + + + + Return the [MultiplayerAPI] configured for the given path, or the default one if [code]for_path[/code] is empty. + + @@ -193,6 +200,14 @@ Sets the given [code]property[/code] to [code]value[/code] on all members of the given group, respecting the given [enum GroupCallFlags]. + + + + + + Sets a custom [MultiplayerAPI] with the given [code]root_path[/code] (controlling also the relative subpaths), or override the default one if [code]root_path[/code] is empty. + + @@ -215,9 +230,6 @@ The root of the edited scene. - - The default [MultiplayerAPI] instance for this [SceneTree]. - If [code]true[/code] (default value), enables automatic polling of the [MultiplayerAPI] for this SceneTree during [signal process_frame]. If [code]false[/code], you need to manually call [method MultiplayerAPI.poll] to process network packets and deliver RPCs. This allows running RPCs in a different loop (e.g. physics, thread, specific time step) and for manual [Mutex] protection when accessing the [MultiplayerAPI] from threads. -- cgit v1.2.3