private void HandleUpdateActivePlayers(NetworkMessage netMsg) { var playersUpdate = netMsg.ReadMessage <PlayersUpdateMessage>(); Debug.Log("UPDATE ACTIVE PLAYERS:"); foreach (var playerData in playersUpdate.Players) { var existingPlayer = activePlayers.Find(p => p.ID == playerData.ID); if (existingPlayer == null) { existingPlayer = new NetworkPlayer() { ID = playerData.ID, Name = playerData.Name, CharacterType = playerData.CharacterType, IsSelf = playerData.ID == client.connection.connectionId }; existingPlayer.Connection = (existingPlayer.IsSelf) ? client.connection : null; activePlayers.Add(existingPlayer); OnPlayerConnect?.Invoke(existingPlayer); } // todo, this is dumb existingPlayer.Name = playerData.Name; existingPlayer.Player.CritterController.transform.SetPositionAndRotation(playerData.Position, playerData.Rotation); Debug.Log("PLAYER #" + playerData.ID + " name" + playerData.Name); } OnActivePlayersUpdated?.Invoke(); }
private void UpdateActivePlayers() { var message = PlayersUpdateMessage.Create(activePlayers); SendMessageToClients(GameMsgType.UpdateActivePlayers, message); OnActivePlayersUpdated?.Invoke(); }
private void ForwardOnActivePlayersUpdated() { OnActivePlayersUpdated?.Invoke(); }