public static UpdatePlayerMessage FromPlayer(Player player) { uint netId = 0; if (player.NetworkIdentity != null) { netId = player.NetworkIdentity.netId.Value; } return(new UpdatePlayerMessage { ID = player.ID, TypeID = player.Type.ID, Selection = PlayerSelectionMessage.FromSelection(player.Selection), GameObjectNetId = netId }); }
public override void OnClientConnect(NetworkConnection conn) { if (!clientLoadedScene) { // Ready/AddPlayer is usually triggered by a scene load completing. if no scene was loaded, then Ready/AddPlayer it here instead. ClientStarted.Then(() => { Log.Debug("Client connecting"); ClientScene.Ready(conn); foreach (var player in PlayerManager.LocalPlayers.Where(p => p.Type.IsActive)) { ClientScene.AddPlayer(conn, localPlayerCount, PlayerSelectionMessage.FromSelection(player.Selection)); localPlayerCount++; } }); } }