public LobbyMenu(bool isHost, MatchSettings settings = null) : base("Lobby") { if (isHost && settings == null) { throw new ArgumentNullException("settings must not be null when isHost is true"); } IsHost = isHost; MatchSettings = settings; Close += (s, e) => { if (isHost) { Lobby?.CloseHostedGameAsync(); Lobby?.Dispose(); Lobby = null; } Ballz.The().Network.PlayerListChanged -= UpdatePlayerList; }; Open += (s, e) => { Ballz.The().Network.PlayerListChanged += UpdatePlayerList; UpdatePlayerList(this, Ballz.The().Network.PlayerList); if (isHost) { Lobby = new LobbyClient(); var gameInfo = Lobby.MakeGameInfo(MatchSettings.GameName, MatchSettings.IsPrivate); Ballz.The().Network.StartServer(gameInfo); Lobby.OpenGame(gameInfo, Ballz.The().Network.NetworkPeer); } }; AddItem(new Label("Players in Lobby:")); PlayerList = new SelectList(); PlayerList.LockSelection = true; AddItem(PlayerList); if (isHost) { var startGameBtn = new Button("Start Game"); startGameBtn.OnClick += (e) => { Ballz.The().Network.StartNetworkGame(MatchSettings, 0); }; AddItem(startGameBtn); } else { AddItem(new Label("Waiting for Host to start the Game")); } AddItem(new BackButton(text: "Leave Game")); }