Skip to main content

ClientSpawnManager

A class in Root.Township, Alta.Networking.

The client's spawn manager: spawns entities the server tells it about and runs callbacks waiting for an entity to arrive. Spawning and destroying from the client are refused with an error.

Constructors​

MemberWhat it is
ClientSpawnManager(NetworkScene networkScene, ILinkProvider linkProvider)Creates a ClientSpawnManager from networkScene and linkProvider.

Fields​

2 private and internal fields
MemberWhat it is
private Dictionary<uint, TrackedEvent<EntitySpawnedHandler>> entitySpawnedListenersCallbacks waiting for each entity identifier to spawn.
private static Logger loggerLogger for this class.

Methods​

MemberWhat it is
override void Destroy(NetworkEntity networkEntity, bool isUnload)Logs an error; clients cannot destroy entities.
override bool SpawnAsClient(uint prefabHash, uint entityIdentifier, uint[] embeddedIdentifiers, TransformSave transformSave, bool isSettingScale, out NetworkEntity entity)Spawns a server-sent entity locally with its identifier and embedded identifiers; returns false if it already exists or the link is fake.
override void SpawnExisting(NetworkPrefab prefab)Logs an error; clients cannot spawn.
override NetworkEntity SpawnInternal(uint prefab)Logs an error and returns null; clients cannot spawn.
override bool WaitForSpawn(uint entityIdentifier, EntitySpawnedHandler handler)Runs the handler now if the entity exists, otherwise queues it until the entity spawns. Returns true while waiting.
4 private and internal methods
MemberWhat it is
private void CheckSpawnEvent(NetworkPrefab prefab)After a spawn, runs any waiting callbacks for the new entity and its embedded entities.
private void CheckSpawnEvent(NetworkEntity entity)After a spawn, runs any waiting callbacks for the new entity and its embedded entities.
private void RunSpawnEvent(TrackedEvent<EntitySpawnedHandler> handler, NetworkEntity entity)Starts SpawnEvent on the network scene for a waiting callback.
private IEnumerator SpawnEvent(TrackedEvent<EntitySpawnedHandler> handler, NetworkEntity entity) (iterator)Coroutine: waits to the end of the frame, then runs and clears the waiting callbacks for the entity.