private static void ParseSyncVarUpdate(NetworkMessage msg) { NetworkMessage.SyncVarUpdateMessage updateMsg = (NetworkMessage.SyncVarUpdateMessage)msg; NetworkEntity entity = null; try { entity = objectRegistryCallback(updateMsg.objectId); } catch (EntityNotFoundException e) { Debug.LogWarning("Unable to update SyncVar of network entity with id " + updateMsg.objectId.id); return; } finally { entity.ReceiveSyncVarUpdate(updateMsg.name, updateMsg.value); } }
private static void SpawnObjects() { List <SpawnCommand> spawnCommands = new List <SpawnCommand>(); spawnCommands.AddRange(pendingSpawnRequests); pendingSpawnRequests.RemoveRange(0, pendingSpawnRequests.Count); foreach (SpawnCommand command in spawnCommands) { if (command == null || objectsManager.spawnedEntities.ContainsKey(command.id)) { continue; } NetworkEntity newEntity = objectsManager.entityDefinitions.Where(entity => entity.name == command.name).Single().entity; NetworkEntity spawnedEntity = GameObject.Instantiate(newEntity, command.position.Value, command.rotation.Value); spawnedEntity.Initialize(command.ownerId, command.id, command.name, command.arguments); spawnedEntity.ReceiveSyncVarUpdate(command.syncVarValues); objectsManager.spawnedEntities.Add(spawnedEntity.instanceId, spawnedEntity); } }