private void SongSelection_SongSelected(string levelId) { //Load the song, then display the detail info SongUtils.LoadSong(levelId, (loadedLevel) => { if (!_songDetail.isInViewControllerHierarchy) { PresentViewController(_songDetail, () => { _songDetail.DisableCharacteristicControl = !isHost; _songDetail.DisableDifficultyControl = !isHost; _songDetail.DisablePlayButton = !isHost; _songDetail.SetSelectedSong(loadedLevel); tempStat = loadedLevel; }); } else { _songDetail.DisableCharacteristicControl = !isHost; _songDetail.DisableDifficultyControl = !isHost; _songDetail.DisablePlayButton = !isHost; _songDetail.SetSelectedSong(loadedLevel); } //Tell the other players to download the song, if we're host if (isHost) { var loadSong = new LoadSong { LevelId = loadedLevel.levelID }; //Send updated download status (Plugin.client.Self as Player).DownloadState = Player.DownloadStates.Downloaded; var playerUpdate = new Event { Type = Event.EventType.PlayerUpdated, ChangedObject = Plugin.client.Self }; Plugin.client.Send(new Packet(playerUpdate)); //We don't want to recieve this since it would cause an infinite song loading loop. //Our song is already loaded inherently since we're selecting it as the host Plugin.client.Send(Match.Players.Except(new Player[] { Plugin.client.Self as Player }).Select(x => x.Id).ToArray(), new Packet(loadSong)); } }); }
private void songSelection_SongSelected(GameplayParameters parameters) { _currentParameters = parameters; SongUtils.LoadSong(parameters.Beatmap.LevelId, (loadedLevel) => { PresentViewController(_songDetail, () => { _songDetail.SetSelectedSong(loadedLevel); _songDetail.SetSelectedDifficulty((int)parameters.Beatmap.Difficulty); _songDetail.SetSelectedCharacteristic(parameters.Beatmap.Characteristic.SerializedName); if (_globalLeaderboard == null) { _globalLeaderboard = Resources.FindObjectsOfTypeAll <PlatformLeaderboardViewController>().First(); _globalLeaderboard.name = "Global Leaderboard"; } _globalLeaderboard.SetData(SongUtils.GetClosestDifficultyPreferLower(loadedLevel, (BeatmapDifficulty)(int)parameters.Beatmap.Difficulty, parameters.Beatmap.Characteristic.SerializedName)); SetRightScreenViewController(_globalLeaderboard, ViewController.AnimationType.In); _customLeaderboard = BeatSaberUI.CreateViewController <CustomLeaderboard>(); PlayerUtils.GetPlatformUserData(RequestLeaderboardWhenResolved); SetLeftScreenViewController(_customLeaderboard, ViewController.AnimationType.In); }); }); }
private void songSelection_SongSelected(IPreviewBeatmapLevel level) { //Load the song, then display the detail info SongUtils.LoadSong(level.levelID, (loadedLevel) => { if (!_songDetail.isInViewControllerHierarchy) { PresentViewController(_songDetail, () => { _songDetail.SetHost(isHost); _songDetail.SetSelectedSong(loadedLevel); }); } else { _songDetail.SetHost(isHost); _songDetail.SetSelectedSong(loadedLevel); } //Tell the other players to download the song, if we're host if (isHost) { var loadSong = new LoadSong(); loadSong.LevelId = loadedLevel.levelID; //Send updated download status (Plugin.client.Self as Player).DownloadState = Player.DownloadStates.Downloaded; var playerUpdate = new Event(); playerUpdate.Type = Event.EventType.PlayerUpdated; playerUpdate.ChangedObject = Plugin.client.Self; Plugin.client.Send(new Packet(playerUpdate)); //We don't want to recieve this since it would cause an infinite song loading loop. //Our song is already loaded inherently since we're selecting it as the host Plugin.client.Send(Match.Players.Except(new Player[] { Plugin.client.Self as Player }).Select(x => x.Id).ToArray(), new Packet(loadSong)); } }); }