SpawnManager
An abstract class in Root.Township, Alta.Networking.
Base for the scene's spawner that instantiates network prefabs, links them to entity identifiers and tears them down. Subclasses are ServerSpawnManager, ClientSpawnManager and LocalSpawnManager; reach the current one through the network scene's Spawner or SpawnHelper.Manager.
- Listed in Networking and servers
- Derived types
ClientSpawnManager,ServerSpawnManager,LocalSpawnManager - Documented in Spawning
Constructors
| Member | What it is |
|---|---|
SpawnManager(INetworkScene networkScene, ILinkProvider linkProvider) | Creates a SpawnManager from networkScene and linkProvider. |
Fields
Properties
| Member | What it is |
|---|---|
Transform DefaultSpawnedFolder { get; private set; } | The transform spawned entities are parented under when they have no other parent, for example after being unembedded. |
protected ILinkProvider LinkProvider { get; private set; } | Maps entity identifiers to NetworkEntityLink slots. |
protected INetworkScene NetworkScene { get; private set; } | The network scene this spawner belongs to. |
Methods
| Member | What it is |
|---|---|
abstract void Destroy(NetworkEntity networkEntity, bool isUnload = false) | Destroys an entity (or unloads it when isUnload is true). The server version also tells clients first. |
void DestroyLocal(INetworkEntity entity, bool isUnload) | Destroys an entity on this machine only: raises its destroy events, frees its link and destroys its embedded and child entities. |
void EmptyNetworkEntityLink(INetworkEntity entity) | Frees the identifier link for an entity, if the link still points at it. |
void OnSpawnDestroy(NetworkEntity entity) | Destroys an entity locally (not an unload). |
void OnSpawnUnload(NetworkEntity entity) | Destroys an entity locally as an unload, so save and destroy handlers see isUnload true. |
NetworkEntity Spawn(NetworkPrefab prefab) | Spawns a prefab by its hash through SpawnInternal. Logs an error and returns null for a null prefab. |
abstract bool SpawnAsClient(uint prefabHash, uint entityIdentifier, uint[] embeddedIdentifiers, TransformSave transformSave, bool isSettingScale, out NetworkEntity entity) | Spawns an entity the server told this client about, with the given identifier and transform. On the server it only returns an existing entity. |
abstract void SpawnExisting(NetworkPrefab prefab) | Registers an already instantiated prefab as a network entity, giving it a link and initializing it. |
abstract NetworkEntity SpawnInternal(uint prefab) | Spawns a prefab by hash. On the server it takes the next free identifier. |
abstract bool WaitForSpawn(uint entityIdentifier, EntitySpawnedHandler handler) | Calls the handler once the entity with that identifier exists. On the server it only calls it if the entity already exists. |
async Task<NetworkEntity> WaitForSpawnAsync(uint entityIdentifier) | Awaitable version of WaitForSpawn; returns at once if the entity already exists. |
protected void CleanEmbedded(NetworkPrefab prefab) | Destroys the game objects of a prefab's embedded entities after the prefab itself is destroyed. |
protected void DestroyChildPrefabs(INetworkEntity entity, NetworkPrefab prefab, bool isUnload) | Handles child prefabs of a destroyed entity: on the server, child, creature and ignore save modes are destroyed too; others are unparented to DefaultSpawnedFolder. |
protected void DestroyEmbedded(NetworkPrefab prefab, bool isUnload) | Marks a prefab's embedded entities as being destroyed, raises their destroy events and frees their links. |
protected void SpawnExisting(NetworkPrefab prefab, NetworkEntityLink link, uint[] embeddedIdentifiers) | Registers an already instantiated prefab as a network entity, giving it a link and initializing it. |
protected NetworkEntity SpawnLocal(uint prefabHash, NetworkEntityLink link, uint[] embeddedIdentifiers, TransformSave transformSave, bool isSettingScale) | Instantiates a prefab by hash at a saved transform and initializes it, or returns the entity already in the link if it matches. |
Used in
Members of other types that take, return or hold a SpawnManager: