Exemplo n.º 1
0
 public void ActiveSceneChanged(Scene from, Scene to)
 {
     try
     {
         if (!SteamAPI.isLobbyConnected())
         {
             return;
         }
         if (to.name == "GameCore" || to.name == "MenuCore")
         {
             try
             {
                 PlayerController.Instance.DestroyAvatars();
                 if (to.name == "GameCore" && SongListUtils.InSong)
                 {
                     Logger.Debug("update scoreboard");
                     SteamAPI.StartGame();
                     InvokeRepeating("UpdateSongOffset", 0f, 1f);
                     Scoreboard.Instance.disabled = false;
                     List <PlayerPacket> connectedPlayers = Controllers.PlayerController.Instance.GetConnectedPlayerPackets();
                     for (int i = 0; i < connectedPlayers.Count; i++)
                     {
                         Scoreboard.Instance.UpsertScoreboardEntry(connectedPlayers[i].playerId, connectedPlayers[i].playerName, 0, 0);
                     }
                 }
                 else if (to.name == "MenuCore")
                 {
                     Scoreboard.Instance.RemoveAll();
                     Scoreboard.Instance.disabled = true;
                     if (from.name == "GameCore" && SongListUtils.InSong)
                     {
                         StartCoroutine(RunLobbyCleanup());
                     }
                 }
             } catch (Exception e)
             {
                 Logger.Debug($"Exception: {e}");
                 Logger.Error(e);
             }
         }
     }
     catch (Exception e)
     {
         Logger.Error($"(OnlineController) Exception on {_currentScene} scene activation! Exception: {e}");
     }
 }