public static void SetPlaylistPacks() { SongCoreBeatmapLevelPackCollectionSO newCollection = SongCore.Loader.CustomBeatmapLevelPackCollectionSO; List <CustomBeatmapLevelPack> _customBeatmapLevelPacks = newCollection.GetPrivateField <List <CustomBeatmapLevelPack> >("_customBeatmapLevelPacks"); List <IBeatmapLevelPack> _allBeatmapLevelPacks = newCollection.GetPrivateField <IBeatmapLevelPack[]>("_allBeatmapLevelPacks").ToList(); _customBeatmapLevelPacks.RemoveAll(x => x.packID.StartsWith($"{CustomLevelLoaderSO.kCustomLevelPackPrefixId}Playlist_")); _allBeatmapLevelPacks.RemoveAll(x => x.packID.StartsWith($"{CustomLevelLoaderSO.kCustomLevelPackPrefixId}Playlist_")); newCollection.SetPrivateField("_customBeatmapLevelPacks", _customBeatmapLevelPacks); newCollection.SetPrivateField("_allBeatmapLevelPacks", _allBeatmapLevelPacks.ToArray()); foreach (var playlist in PlaylistsCollection.loadedPlaylists) { var pack = PlaylistsCollection.CreateLevelPackFromPlaylist(playlist); Logging.Log.Info($"{pack.packName} {pack.beatmapLevelCollection.beatmapLevels.Count()}"); newCollection.AddLevelPack(pack); } }
internal void OnSceneChanged(Scene oldScene, Scene newScene) { if (AreSongsLoading) { //Scene changing while songs are loading. Since we are using a separate thread while loading, this is bad and could cause a crash. //So we have to stop loading. if (_loadingTask != null) { _loadingTask.Cancel(); _loadingCancelled = true; AreSongsLoading = false; LoadingProgress = 0; StopAllCoroutines(); _progressBar.ShowMessage("Loading cancelled\n<size=80%>Press Ctrl+R to refresh</size>"); Logging.Log("Loading was cancelled by player since they loaded another scene."); } } if (newScene.name == "MenuCore") { BS_Utils.Gameplay.Gamemode.Init(); if (_customLevelLoader == null) { _customLevelLoader = Resources.FindObjectsOfTypeAll <CustomLevelLoaderSO>().FirstOrDefault(); if (_customLevelLoader) { Texture2D defaultCoverTex = _customLevelLoader.GetField <Texture2D>("_defaultPackCoverTexture2D"); defaultCoverImage = Sprite.Create(defaultCoverTex, new Rect(0f, 0f, (float)defaultCoverTex.width, (float)defaultCoverTex.height), new Vector2(0.5f, 0.5f)); cachedMediaAsyncLoaderSO = _customLevelLoader.GetField <CachedMediaAsyncLoaderSO>("_cachedMediaAsyncLoaderSO"); beatmapCharacteristicCollection = _customLevelLoader.GetField <BeatmapCharacteristicCollectionSO>("_beatmapCharacteristicCollection"); } else { Texture2D defaultCoverTex = Texture2D.blackTexture; defaultCoverImage = Sprite.Create(defaultCoverTex, new Rect(0f, 0f, (float)defaultCoverTex.width, (float)defaultCoverTex.height), new Vector2(0.5f, 0.5f)); } } if (BeatmapLevelsModelSO == null) { BeatmapLevelsModelSO = Resources.FindObjectsOfTypeAll <BeatmapLevelsModelSO>().FirstOrDefault(); } //Handle LevelPacks if (CustomBeatmapLevelPackCollectionSO == null) { var beatmapLevelPackCollectionSO = Resources.FindObjectsOfTypeAll <BeatmapLevelPackCollectionSO>().FirstOrDefault(); CustomBeatmapLevelPackCollectionSO = SongCoreBeatmapLevelPackCollectionSO.ReplaceOriginal(beatmapLevelPackCollectionSO); CustomLevelsCollection = new SongCoreCustomLevelCollection(CustomLevels.Values.ToArray()); WIPLevelsCollection = new SongCoreCustomLevelCollection(CustomWIPLevels.Values.ToArray()); CustomLevelsPack = new SongCoreCustomBeatmapLevelPack(CustomLevelLoaderSO.kCustomLevelPackPrefixId + "CustomLevels", "Custom Maps", defaultCoverImage, CustomLevelsCollection); WIPLevelsPack = new SongCoreCustomBeatmapLevelPack(CustomLevelLoaderSO.kCustomLevelPackPrefixId + "CustomWIPLevels", "WIP Maps", UI.BasicUI.WIPIcon, WIPLevelsCollection); CustomBeatmapLevelPackCollectionSO.AddLevelPack(CustomLevelsPack); CustomBeatmapLevelPackCollectionSO.AddLevelPack(WIPLevelsPack); // CustomBeatmapLevelPackSO = CustomBeatmapLevelPackSO.GetPack(CustomLevelCollectionSO); // CustomBeatmapLevelPackCollectionSO.AddLevelPack(CustomBeatmapLevelPackSO); // WIPCustomBeatmapLevelPackSO = CustomBeatmapLevelPackSO.GetPack(WIPCustomLevelCollectionSO, true); // CustomBeatmapLevelPackCollectionSO.AddLevelPack(WIPCustomBeatmapLevelPackSO); CustomBeatmapLevelPackCollectionSO.ReplaceReferences(); } else { CustomBeatmapLevelPackCollectionSO.ReplaceReferences(); } //RefreshLevelPacks(); var soloFreePlay = Resources.FindObjectsOfTypeAll <SoloFreePlayFlowCoordinator>().FirstOrDefault(); LevelPacksViewController levelPacksViewController = soloFreePlay?.GetField <LevelPacksViewController>("_levelPacksViewController"); levelPacksViewController?.SetData(CustomBeatmapLevelPackCollectionSO, 0); } }