// Use this for initialization IEnumerator Start() { yield return(new WaitForEndOfFrame()); _centerViewController = GetComponentInChildren <CenterViewController>(); _centerViewController.Init(); _centerViewController.centerView.GotoPage(initPageIndex); }
protected override void DidActivate(bool firstActivation, ActivationType activationType) { if (activationType == ActivationType.AddedToHierarchy) { title = Plugin.Name; navigationController = BeatSaberUI.CreateViewController <GenericNavigationController>(); navigationController.didFinishEvent += (_) => mainFlowCoordinator.InvokeMethod("DismissFlowCoordinator", this, null, false); if (soloFreePlayFlowCoordinator == null) { soloFreePlayFlowCoordinator = Resources.FindObjectsOfTypeAll <SoloFreePlayFlowCoordinator>().First(); } if (_additionalContentModel == null) { _additionalContentModel = Resources.FindObjectsOfTypeAll <AdditionalContentModelSO>().First(); } if (_primaryLevelCollection == null) { _primaryLevelCollection = _additionalContentModel.alwaysOwnedPacks.First(x => x.packID == "OstVol1").beatmapLevelCollection as BeatmapLevelCollectionSO; } if (_secondaryLevelCollection == null) { _secondaryLevelCollection = _additionalContentModel.alwaysOwnedPacks.First(x => x.packID == "OstVol2").beatmapLevelCollection as BeatmapLevelCollectionSO; } if (_extrasLevelCollection == null) { _extrasLevelCollection = _additionalContentModel.alwaysOwnedPacks.First(x => x.packID == "Extras").beatmapLevelCollection as BeatmapLevelCollectionSO; } if (beatmapLevelPackCollection == null) { beatmapLevelPackCollection = soloFreePlayFlowCoordinator.GetField <IBeatmapLevelPackCollection>("_levelPackCollection"); } if (centerViewController == null) { centerViewController = BeatSaberUI.CreateViewController <CenterViewController>(); centerViewController.GenerateButtonPressed += () => { centerViewController.SetUIType(CenterViewController.UIType.ProgressBar); GeneratePlaylistWithMinTime(centerViewController.GetTimeValue(), centerViewController.UseOnlyPreferredDifficulty ? centerViewController.PreferredDifficulty : (BeatmapDifficulty?)null, (playlist) => { var duration = 0f; foreach (var song in playlist) { duration += song.songDuration; Logger.Debug($"PLAYLIST ITEM: {song.songName} ({song.songDuration})"); } Logger.Debug($"TOTAL DURATION: {duration}"); centerViewController.SetUIType(CenterViewController.UIType.GenerationButton); //Launch first level Config.Enabled = true; Plugin.instance.loadedLevels = new Queue <IBeatmapLevel>(playlist); var firstMap = SongHelpers.GetClosestDifficultyPreferLower(Plugin.instance.loadedLevels.First(), centerViewController.PreferredDifficulty); SongStitcher.songSwitched -= SongSwitched; SongStitcher.songSwitched += SongSwitched; var playerDataModel = Resources.FindObjectsOfTypeAll <PlayerDataModelSO>().First(); MenuTransitionsHelperSO menuTransitionHelper = Resources.FindObjectsOfTypeAll <MenuTransitionsHelperSO>().FirstOrDefault(); menuTransitionHelper.StartStandardLevel(firstMap, playerDataModel.currentLocalPlayer.gameplayModifiers, playerDataModel.currentLocalPlayer.playerSpecificSettings, null, "Menu", false, null, SongFinished); }); }; } ProvideInitialViewControllers(navigationController); SetViewControllersToNavigationConctroller(navigationController, new VRUIViewController[] { centerViewController }); } }