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 ¶
- type Advanced
- type Any
- type Expanded
- type Extension
- type ID
- type Instance
- func (self Instance) AddSpawnableScene(path string)
- func (self Instance) AsMultiplayerSpawner() Instance
- func (self Instance) AsNode() Node.Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) ClearSpawnableScenes()
- func (self Instance) GetSpawnableScene(index int) string
- func (self Instance) GetSpawnableSceneCount() int
- func (self Instance) ID() ID
- func (self Instance) MoreArgs() MoreArgs
- func (self Instance) OnDespawned(cb func(node Node.Instance), flags ...Signal.Flags)
- func (self Instance) OnSpawned(cb func(node Node.Instance), flags ...Signal.Flags)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetSpawnFunction(value func(data any) Node.Instance)
- func (self Instance) SetSpawnLimit(value int)
- func (self Instance) SetSpawnPath(value string)
- func (self Instance) Spawn() Node.Instance
- func (self Instance) SpawnFunction() func(data any) Node.Instance
- func (self Instance) SpawnLimit() int
- func (self Instance) SpawnPath() string
- func (self Instance) Virtual(name string) reflect.Value
- type MoreArgs
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 Extension ¶
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 ¶
type 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.
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 (Instance) AddSpawnableScene ¶
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 (Instance) ClearSpawnableScenes ¶
func (self Instance) ClearSpawnableScenes()
Clears all spawnable scenes. Does not despawn existing instances on remote peers.
func (Instance) GetSpawnableScene ¶
Returns the spawnable scene path by index.
func (Instance) GetSpawnableSceneCount ¶
Returns the count of spawnable scene paths.
func (Instance) MoreArgs ¶
MoreArgs enables certain functions to be called with additional 'optional' arguments.
func (Instance) OnDespawned ¶
Emitted when a spawnable scene or custom spawn was despawned by the multiplayer authority. Only called on remote peers.
func (Instance) OnSpawned ¶
Emitted when a spawnable scene or custom spawn was spawned by the multiplayer authority. Only called on remote peers.
func (Instance) SetSpawnFunction ¶
SetSpawnFunction sets the property returned by [GetSpawnFunction].
func (Instance) SetSpawnLimit ¶
SetSpawnLimit sets the property returned by [GetSpawnLimit].
func (Instance) SetSpawnPath ¶
SetSpawnPath sets the property returned by [GetSpawnPath].
func (Instance) Spawn ¶
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 ¶
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 ¶
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.
type MoreArgs ¶
type MoreArgs [1]gdclass.MultiplayerSpawner
MoreArgs is a container for Instance functions with additional 'optional' arguments.
func (MoreArgs) Spawn ¶
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.