MultiplayerSynchronizer

package
v0.0.0-...-357ca8a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2025 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

By default, MultiplayerSynchronizer synchronizes configured properties to all peers.

Visibility can be handled directly with SetVisibilityFor or as-needed with AddVisibilityFilter and UpdateVisibility.

MultiplayerSpawners will handle nodes according to visibility of synchronizers as long as the node at RootPath was spawned by one.

Internally, MultiplayerSynchronizer uses MultiplayerAPI.ObjectConfigurationAdd to notify synchronization start passing the Node at RootPath as the object and itself as the configuration, and uses MultiplayerAPI.ObjectConfigurationRemove 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 Objects (see Object.GetInstanceId) or Resource.IDs, will also not work in synchronization.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsMultiplayerSynchronizer() Instance
}

type Expanded

type Expanded = MoreArgs

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension

func (*Extension[T]) AsMultiplayerSynchronizer

func (self *Extension[T]) AsMultiplayerSynchronizer() Instance

func (*Extension[T]) AsNode

func (self *Extension[T]) AsNode() Node.Instance

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

type Instance [1]gdclass.MultiplayerSynchronizer

Instance of the class with convieniently typed arguments and results.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AddVisibilityFilter

func (self Instance) AddVisibilityFilter(filter func(peer_id int) bool)

Adds a peer visibility filter for this synchronizer.

'filter' should take a peer ID int and return a bool.

func (Instance) AsMultiplayerSynchronizer

func (self Instance) AsMultiplayerSynchronizer() Instance

func (Instance) AsNode

func (self Instance) AsNode() Node.Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) DeltaInterval

func (self Instance) DeltaInterval() Float.X

Time interval between delta synchronizations. Used when the replication is set to [Scenereplicationconfig.ReplicationModeOnChange]. If set to 0.0 (the default), delta synchronizations happen every network process frame.

func (Instance) GetVisibilityFor

func (self Instance) GetVisibilityFor(peer int) bool

Queries the current visibility for peer 'peer'.

func (Instance) ID

func (self Instance) ID() ID

func (Instance) MoreArgs

func (self Instance) MoreArgs() MoreArgs

MoreArgs enables certain functions to be called with additional 'optional' arguments.

func (Instance) OnDeltaSynchronized

func (self Instance) OnDeltaSynchronized(cb func(), flags ...Signal.Flags)

Emitted when a new delta synchronization state is received by this synchronizer after the properties have been updated.

func (Instance) OnSynchronized

func (self Instance) OnSynchronized(cb func(), flags ...Signal.Flags)

Emitted when a new synchronization state is received by this synchronizer after the properties have been updated.

func (Instance) OnVisibilityChanged

func (self Instance) OnVisibilityChanged(cb func(for_peer int), flags ...Signal.Flags)

Emitted when visibility of 'for_peer' is updated. See UpdateVisibility.

func (Instance) PublicVisibility

func (self Instance) PublicVisibility() bool

Whether synchronization should be visible to all peers by default. See SetVisibilityFor and AddVisibilityFilter for ways of configuring fine-grained visibility options.

func (Instance) RemoveVisibilityFilter

func (self Instance) RemoveVisibilityFilter(filter Callable.Function)

Removes a peer visibility filter from this synchronizer.

func (Instance) ReplicationConfig

func (self Instance) ReplicationConfig() SceneReplicationConfig.Instance

Resource containing which properties to synchronize.

func (Instance) ReplicationInterval

func (self Instance) ReplicationInterval() Float.X

Time interval between synchronizations. Used when the replication is set to [Scenereplicationconfig.ReplicationModeAlways]. If set to 0.0 (the default), synchronizations happen every network process frame.

func (Instance) RootPath

func (self Instance) RootPath() string

Node path that replicated properties are relative to.

If RootPath was spawned by a MultiplayerSpawner, the node will be also be spawned and despawned based on this synchronizer visibility options.

func (Instance) SetDeltaInterval

func (self Instance) SetDeltaInterval(value Float.X)

SetDeltaInterval sets the property returned by [GetDeltaInterval].

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) SetPublicVisibility

func (self Instance) SetPublicVisibility(value bool)

SetPublicVisibility sets the property returned by [IsVisibilityPublic].

func (Instance) SetReplicationConfig

func (self Instance) SetReplicationConfig(value SceneReplicationConfig.Instance)

SetReplicationConfig sets the property returned by [GetReplicationConfig].

func (Instance) SetReplicationInterval

func (self Instance) SetReplicationInterval(value Float.X)

SetReplicationInterval sets the property returned by [GetReplicationInterval].

func (Instance) SetRootPath

func (self Instance) SetRootPath(value string)

SetRootPath sets the property returned by [GetRootPath].

func (Instance) SetVisibilityFor

func (self Instance) SetVisibilityFor(peer int, visible bool)

Sets the visibility of 'peer' to 'visible'. If 'peer' is 0, the value of PublicVisibility will be updated instead.

func (Instance) SetVisibilityUpdateMode

func (self Instance) SetVisibilityUpdateMode(value VisibilityUpdateMode)

SetVisibilityUpdateMode sets the property returned by [GetVisibilityUpdateMode].

func (Instance) UpdateVisibility

func (self Instance) UpdateVisibility()

Updates the visibility of 'for_peer' according to visibility filters. If 'for_peer' is 0 (the default), all peers' visibilties are updated.

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

func (Instance) VisibilityUpdateMode

func (self Instance) VisibilityUpdateMode() VisibilityUpdateMode

Specifies when visibility filters are updated.

type MoreArgs

type MoreArgs [1]gdclass.MultiplayerSynchronizer

MoreArgs is a container for Instance functions with additional 'optional' arguments.

func (MoreArgs) UpdateVisibility

func (self MoreArgs) UpdateVisibility(for_peer int)

Updates the visibility of 'for_peer' according to visibility filters. If 'for_peer' is 0 (the default), all peers' visibilties are updated.

type VisibilityUpdateMode

type VisibilityUpdateMode int //gd:MultiplayerSynchronizer.VisibilityUpdateMode
const (
	// Visibility filters are updated during process frames (see [Node.NotificationInternalProcess]).
	VisibilityProcessIdle VisibilityUpdateMode = 0
	// Visibility filters are updated during physics frames (see [Node.NotificationInternalPhysicsProcess]).
	VisibilityProcessPhysics VisibilityUpdateMode = 1
	// Visibility filters are not updated automatically, and must be updated manually by calling [UpdateVisibility].
	//
	// [UpdateVisibility]: https://pkg.go.dev/graphics.gd/classdb/#Instance.UpdateVisibility
	VisibilityProcessNone VisibilityUpdateMode = 2
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL