Пример #1
0
        public static void Init()
        {
            _customLevelLoader = Resources.FindObjectsOfTypeAll <CustomLevelLoader>().FirstOrDefault();
            beatmapCharacteristicCollection = _customLevelLoader.GetField <BeatmapCharacteristicCollectionSO>("_beatmapCharacteristicCollection");

            Texture2D defaultCoverTex = Texture2D.blackTexture;

            defaultCoverImage = Sprite.Create(defaultCoverTex, new Rect(0f, 0f,
                                                                        defaultCoverTex.width, defaultCoverTex.height), new Vector2(0.5f, 0.5f));
            cachedMediaAsyncLoaderSO = _customLevelLoader.GetField <CachedMediaAsyncLoader>("_cachedMediaAsyncLoaderSO");
        }
Пример #2
0
        private static BeatmapCharacteristicCollectionSO GetDefaultGameModes()
        {
            CustomLevelLoader customLevelLoader = UnityEngine.Object.FindObjectOfType <CustomLevelLoader>();

            if (customLevelLoader == null)
            {
                Plugin.Log.Info("customLevelLoader is null");
                return(null);
            }
            BeatmapCharacteristicCollectionSO defaultGameModes = FieldHelper.Get <BeatmapCharacteristicCollectionSO>(customLevelLoader, "_beatmapCharacteristicCollection");

            if (defaultGameModes == null)
            {
                Plugin.Log.Warn("defaultGameModes is null");
            }
            return(defaultGameModes);
        }
Пример #3
0
        internal void MenuLoaded()
        {
            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.");
                }
            }
            BS_Utils.Gameplay.Gamemode.Init();
            if (_customLevelLoader == null)
            {
                _customLevelLoader = Resources.FindObjectsOfTypeAll <CustomLevelLoader>().FirstOrDefault();
                if (_customLevelLoader)
                {
                    Texture2D defaultCoverTex = _customLevelLoader.GetField <Texture2D>("_defaultPackCoverTexture2D");
                    defaultCoverImage = Sprite.Create(defaultCoverTex, new Rect(0f, 0f,
                                                                                defaultCoverTex.width, defaultCoverTex.height), new Vector2(0.5f, 0.5f));

                    cachedMediaAsyncLoaderSO        = _customLevelLoader.GetField <CachedMediaAsyncLoader>("_cachedMediaAsyncLoaderSO");
                    beatmapCharacteristicCollection = _customLevelLoader.GetField <BeatmapCharacteristicCollectionSO>("_beatmapCharacteristicCollection");
                }
                else
                {
                    Texture2D defaultCoverTex = Texture2D.blackTexture;
                    defaultCoverImage = Sprite.Create(defaultCoverTex, new Rect(0f, 0f,
                                                                                defaultCoverTex.width, defaultCoverTex.height), new Vector2(0.5f, 0.5f));
                }
            }
        }
 public BeatmapCharacteristicSO GetBeatmapCharacteristicCollectionFromSO(string serializedName)
 {
     return(BeatmapCharacteristicCollectionSO.GetBeatmapCharacteristicBySerializedName(serializedName));
 }
Пример #5
0
        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);
            }
        }