MultiplayerSpawner

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: 24 Imported by: 0

Documentation

Overview

Spawnable scenes can be configured in the editor or through code (see AddSpawnableScene).

Also supports custom node spawns through Spawn, calling SpawnFunction on all peers.

Internally, MultiplayerSpawner uses MultiplayerAPI.ObjectConfigurationAdd to notify spawns passing the spawned node as the object and itself as the configuration, and MultiplayerAPI.ObjectConfigurationRemove to notify despawns in a similar way.

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
	AsMultiplayerSpawner() 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]) AsMultiplayerSpawner

func (self *Extension[T]) AsMultiplayerSpawner() 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.MultiplayerSpawner

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) AddSpawnableScene

func (self Instance) AddSpawnableScene(path string)

Adds a scene path to spawnable scenes, making it automatically replicated from the multiplayer authority to other peers when added as children of the node pointed by SpawnPath.

func (Instance) AsMultiplayerSpawner

func (self Instance) AsMultiplayerSpawner() Instance

func (Instance) AsNode

func (self Instance) AsNode() Node.Instance

func (Instance) AsObject

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

func (Instance) ClearSpawnableScenes

func (self Instance) ClearSpawnableScenes()

Clears all spawnable scenes. Does not despawn existing instances on remote peers.

func (Instance) GetSpawnableScene

func (self Instance) GetSpawnableScene(index int) string

Returns the spawnable scene path by index.

func (Instance) GetSpawnableSceneCount

func (self Instance) GetSpawnableSceneCount() int

Returns the count of spawnable scene paths.

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) OnDespawned

func (self Instance) OnDespawned(cb func(node Node.Instance), flags ...Signal.Flags)

Emitted when a spawnable scene or custom spawn was despawned by the multiplayer authority. Only called on remote peers.

func (Instance) OnSpawned

func (self Instance) OnSpawned(cb func(node Node.Instance), flags ...Signal.Flags)

Emitted when a spawnable scene or custom spawn was spawned by the multiplayer authority. Only called on remote peers.

func (*Instance) SetObject

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

func (Instance) SetSpawnFunction

func (self Instance) SetSpawnFunction(value func(data any) Node.Instance)

SetSpawnFunction sets the property returned by [GetSpawnFunction].

func (Instance) SetSpawnLimit

func (self Instance) SetSpawnLimit(value int)

SetSpawnLimit sets the property returned by [GetSpawnLimit].

func (Instance) SetSpawnPath

func (self Instance) SetSpawnPath(value string)

SetSpawnPath sets the property returned by [GetSpawnPath].

func (Instance) Spawn

func (self Instance) Spawn() Node.Instance

Requests a custom spawn, with 'data' passed to SpawnFunction on all peers. Returns the locally spawned node instance already inside the scene tree, and added as a child of the node pointed by SpawnPath.

Note: Spawnable scenes are spawned automatically. Spawn is only needed for custom spawns.

func (Instance) SpawnFunction

func (self Instance) SpawnFunction() func(data any) Node.Instance

Method called on all peers when a custom Spawn is requested by the authority. Will receive the data parameter, and should return a Node that is not in the scene tree.

Note: The returned node should not be added to the scene with Node.AddChild. This is done automatically.

func (Instance) SpawnLimit

func (self Instance) SpawnLimit() int

Maximum number of nodes allowed to be spawned by this spawner. Includes both spawnable scenes and custom spawns.

When set to 0 (the default), there is no limit.

func (Instance) SpawnPath

func (self Instance) SpawnPath() string

Path to the spawn root. Spawnable scenes that are added as direct children are replicated to other peers.

func (Instance) Virtual

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

type MoreArgs

type MoreArgs [1]gdclass.MultiplayerSpawner

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

func (MoreArgs) Spawn

func (self MoreArgs) Spawn(data any) Node.Instance

Requests a custom spawn, with 'data' passed to SpawnFunction on all peers. Returns the locally spawned node instance already inside the scene tree, and added as a child of the node pointed by SpawnPath.

Note: Spawnable scenes are spawned automatically. Spawn is only needed for custom spawns.

Jump to

Keyboard shortcuts

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