MultiplayerSynchronizer
Synchronizes properties from the multiplayer authority to the remote peers.
描述
By default, MultiplayerSynchronizer synchronizes configured properties to all peers.
Visibility can be handled directly with set_visibility_for
or as-needed with add_visibility_filter
and update_visibility
.
MultiplayerSpawner
s will handle nodes according to visibility of synchronizers as long as the node at root_path
was spawned by one.
Internally, MultiplayerSynchronizer uses MultiplayerAPI.object_configuration_add
to notify synchronization start passing the Node
at root_path
as the object
and itself as the configuration
, and uses MultiplayerAPI.object_configuration_remove
to notify synchronization end in a similar way.
Note: 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 Object.get_instance_id
) or RID
s, will also not work in synchronization.
属性
float | delta_interval |
bool | public_visibility |
SceneReplicationConfig | replication_config |
float | replication_interval |
NodePath | root_path |
VisibilityUpdateMode | visibility_update_mode |
方法
void | add_visibility_filter ( filter: Callable ) |
bool | get_visibility_for ( peer: int ) const1 |
void | remove_visibility_filter ( filter: Callable ) |
void | set_visibility_for ( peer: int , visible: bool ) |
void | update_visibility ( for_peer: int = 0 ) |
信号
delta_synchronized ( )
Emitted when a new delta synchronization state is received by this synchronizer after the properties have been updated.
synchronized ( )
Emitted when a new synchronization state is received by this synchronizer after the properties have been updated.
visibility_changed ( for_peer: int
)
Emitted when visibility of for_peer
is updated. See update_visibility
.
枚举
enum VisibilityUpdateMode:
VisibilityUpdateMode VISIBILITY_PROCESS_IDLE = 0
Visibility filters are updated during process frames (see Node.NOTIFICATION_INTERNAL_PROCESS
).
VisibilityUpdateMode VISIBILITY_PROCESS_PHYSICS = 1
Visibility filters are updated during physics frames (see Node.NOTIFICATION_INTERNAL_PHYSICS_PROCESS
).
VisibilityUpdateMode VISIBILITY_PROCESS_NONE = 2
Visibility filters are not updated automatically, and must be updated manually by calling update_visibility
.
属性说明
float
delta_interval = 0.0
Time interval between delta synchronizations. When set to 0.0
(the default), delta synchronizations happen every network process frame.
bool
public_visibility = true
Whether synchronization should be visible to all peers by default. See set_visibility_for
and add_visibility_filter
for ways of configuring fine-grained visibility options.
SceneReplicationConfig
replication_config
void
set_replication_config ( value:SceneReplicationConfig
)SceneReplicationConfig
get_replication_config ( )
Resource containing which properties to synchronize.
float
replication_interval = 0.0
Time interval between synchronizations. When set to 0.0
(the default), synchronizations happen every network process frame.
NodePath
root_path = NodePath("..")
Node path that replicated properties are relative to.
If root_path
was spawned by a MultiplayerSpawner
, the node will be also be spawned and despawned based on this synchronizer visibility options.
VisibilityUpdateMode visibility_update_mode = 0
void
set_visibility_update_mode ( value: VisibilityUpdateMode )- VisibilityUpdateMode get_visibility_update_mode ( )
Specifies when visibility filters are updated (see VisibilityUpdateMode for options).
方法说明
void
add_visibility_filter ( filter: Callable
)
Adds a peer visibility filter for this synchronizer.
filter
should take a peer ID int
and return a bool
.
bool
get_visibility_for ( peer: int
) const1
Queries the current visibility for peer peer
.
void
remove_visibility_filter ( filter: Callable
)
Removes a peer visibility filter from this synchronizer.
void
set_visibility_for ( peer: int
, visible: bool
)
Sets the visibility of peer
to visible
. If peer
is 0
, the value of public_visibility
will be updated instead.
void
update_visibility ( for_peer: int
= 0 )
Updates the visibility of for_peer
according to visibility filters. If for_peer
is 0
(the default), all peers' visibilties are updated.
本方法通常需要用户覆盖才能生效。
本方法无副作用,不会修改该实例的任何成员变量。
本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。
本方法用于构造某个类型。
调用本方法无需实例,可直接使用类名进行调用。
本方法描述的是使用本类型作为左操作数的有效运算符。
这个值是由下列位标志构成位掩码的整数。
无返回值。