mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-04 14:11:02 +03:00
classref: Sync with current master branch (42c7f14)
This commit is contained in:
@@ -33,10 +33,10 @@ The following example extend the default implementation (:ref:`SceneMultiplayer<
|
||||
|
||||
extends MultiplayerAPIExtension
|
||||
class_name LogMultiplayer
|
||||
|
||||
|
||||
# We want to extend the default SceneMultiplayer.
|
||||
var base_multiplayer = SceneMultiplayer.new()
|
||||
|
||||
|
||||
func _init():
|
||||
# Just passthrough base signals (copied to var to avoid cyclic reference)
|
||||
var cts = connected_to_server
|
||||
@@ -49,15 +49,15 @@ The following example extend the default implementation (:ref:`SceneMultiplayer<
|
||||
base_multiplayer.server_disconnected.connect(func(): sd.emit())
|
||||
base_multiplayer.peer_connected.connect(func(id): pc.emit(id))
|
||||
base_multiplayer.peer_disconnected.connect(func(id): pd.emit(id))
|
||||
|
||||
|
||||
func _poll():
|
||||
return base_multiplayer.poll()
|
||||
|
||||
|
||||
# Log RPC being made and forward it to the default multiplayer.
|
||||
func _rpc(peer: int, object: Object, method: StringName, args: Array) -> Error:
|
||||
print("Got RPC for %d: %s::%s(%s)" % [peer, object, method, args])
|
||||
return base_multiplayer.rpc(peer, object, method, args)
|
||||
|
||||
|
||||
# Log configuration add. E.g. root path (nullptr, NodePath), replication (Node, Spawner|Synchronizer), custom.
|
||||
func _object_configuration_add(object, config: Variant) -> Error:
|
||||
if config is MultiplayerSynchronizer:
|
||||
@@ -65,7 +65,7 @@ The following example extend the default implementation (:ref:`SceneMultiplayer<
|
||||
elif config is MultiplayerSpawner:
|
||||
print("Adding node %s to the spawn list. Spawner: %s" % [object, config])
|
||||
return base_multiplayer.object_configuration_add(object, config)
|
||||
|
||||
|
||||
# Log configuration remove. E.g. root path (nullptr, NodePath), replication (Node, Spawner|Synchronizer), custom.
|
||||
func _object_configuration_remove(object, config: Variant) -> Error:
|
||||
if config is MultiplayerSynchronizer:
|
||||
@@ -73,20 +73,20 @@ The following example extend the default implementation (:ref:`SceneMultiplayer<
|
||||
elif config is MultiplayerSpawner:
|
||||
print("Removing node %s from the spawn list. Spawner: %s" % [object, config])
|
||||
return base_multiplayer.object_configuration_remove(object, config)
|
||||
|
||||
|
||||
# These can be optional, but in our case we want to extend SceneMultiplayer, so forward everything.
|
||||
func _set_multiplayer_peer(p_peer: MultiplayerPeer):
|
||||
base_multiplayer.multiplayer_peer = p_peer
|
||||
|
||||
|
||||
func _get_multiplayer_peer() -> MultiplayerPeer:
|
||||
return base_multiplayer.multiplayer_peer
|
||||
|
||||
|
||||
func _get_unique_id() -> int:
|
||||
return base_multiplayer.get_unique_id()
|
||||
|
||||
|
||||
func _get_remote_sender_id() -> int:
|
||||
return base_multiplayer.get_remote_sender_id()
|
||||
|
||||
|
||||
func _get_peer_ids() -> PackedInt32Array:
|
||||
return base_multiplayer.get_peers()
|
||||
|
||||
@@ -250,6 +250,7 @@ Callback for :ref:`MultiplayerAPI.rpc()<class_MultiplayerAPI_method_rpc>`.
|
||||
Called when the :ref:`MultiplayerAPI.multiplayer_peer<class_MultiplayerAPI_property_multiplayer_peer>` is set.
|
||||
|
||||
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
|
||||
.. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
|
||||
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
|
||||
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
|
||||
.. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
|
||||
|
||||
Reference in New Issue
Block a user