static void Postfix(StandardLevelScenesTransitionSetupDataSO __instance, IDifficultyBeatmap difficultyBeatmap, IPreviewBeatmapLevel previewBeatmapLevel,
                            OverrideEnvironmentSettings overrideEnvironmentSettings, GameplayModifiers gameplayModifiers, ColorScheme overrideColorScheme, PlayerSpecificSettings playerSpecificSettings,
                            ref PracticeSettings practiceSettings, bool useTestNoteCutSoundEffects, MainSettingsModelSO ____mainSettingsModel)
        {
            EnvironmentInfoSO environmentInfoSO = difficultyBeatmap.GetEnvironmentInfo();

            if (overrideEnvironmentSettings is { overrideEnvironments : true })
 public PauseMenuController(PauseMenuManager pauseMenuManager, IDifficultyBeatmap difficultyBeatmap, AudioTimeSyncController audioTimeSyncController, PauseController pauseController)
 {
     this.pauseMenuManager        = pauseMenuManager;
     DifficultyBeatmap            = difficultyBeatmap;
     this.audioTimeSyncController = audioTimeSyncController;
     this.pauseController         = pauseController;
 }
Exemple #3
0
 internal static void CheckCustomSongEnvironment(IDifficultyBeatmap song)
 {
     Data.ExtraSongData songData = Collections.RetrieveExtraSongData(Hashing.GetCustomLevelHash(song.level as CustomPreviewBeatmapLevel));
     if (songData == null)
     {
         return;
     }
     if (string.IsNullOrWhiteSpace(songData._customEnvironmentName))
     {
         _currentPlatform = -1;
         return;
     }
     try
     {
         int _customPlatform = customEnvironment(songData._customEnvironmentName);
         if (_customPlatform != -1)
         {
             _currentPlatform = CustomFloorPlugin.PlatformManager.CurrentPlatformIndex;
             if (customSongPlatforms && _customPlatform != _currentPlatform)
             {
                 CustomFloorPlugin.PlatformManager.TempChangeToPlatform(_customPlatform);
             }
         }
     }
     catch (Exception ex)
     {
         Logging.logger.Error($"Failed to Change to Platform {songData._customEnvironmentName}\n {ex}");
     }
 }
        private static void Prefix(IDifficultyBeatmap difficultyBeatmap, ref ColorScheme overrideColorScheme)
        {
            EnvironmentInfoSO environmentInfoSO = difficultyBeatmap.GetEnvironmentInfo();

            Data.ExtraSongData.DifficultyData songData = Collections.RetrieveDifficultyData(difficultyBeatmap);
            ColorScheme fallbackScheme = overrideColorScheme ?? new ColorScheme(environmentInfoSO.colorScheme);

            if (songData == null)
            {
                return;
            }
            if (songData._colorLeft != null || songData._colorRight != null || songData._envColorLeft != null || songData._envColorRight != null || songData._obstacleColor != null)
            {
                if (Plugin.customSongColors)
                {
                    Logging.logger.Info("Custom Song Colors On");
                    Color       saberLeft      = songData._colorLeft == null ? fallbackScheme.saberAColor : Utils.ColorFromMapColor(songData._colorLeft);
                    Color       saberRight     = songData._colorRight == null ? fallbackScheme.saberBColor : Utils.ColorFromMapColor(songData._colorRight);
                    Color       envLeft        = songData._envColorLeft == null ? songData._colorLeft == null ? fallbackScheme.environmentColor0 : Utils.ColorFromMapColor(songData._colorLeft) : Utils.ColorFromMapColor(songData._envColorLeft);
                    Color       envRight       = songData._envColorRight == null ? songData._colorRight == null ? fallbackScheme.environmentColor1 : Utils.ColorFromMapColor(songData._colorRight) : Utils.ColorFromMapColor(songData._envColorRight);
                    Color       obstacle       = songData._obstacleColor == null ? fallbackScheme.obstaclesColor : Utils.ColorFromMapColor(songData._obstacleColor);
                    ColorScheme mapColorScheme = new ColorScheme("SongCoreMapColorScheme", "SongCore Map Color Scheme", false, saberLeft, saberRight, envLeft, envRight, obstacle);
                    overrideColorScheme = mapColorScheme;
                }
            }
        }
Exemple #5
0
        private void songDetail_didChangeDifficultyBeatmapEvent(IDifficultyBeatmap beatmap)
        {
            var level = beatmap.level;

            //Assemble new match info and update the match
            var matchLevel = new PreviewBeatmapLevel()
            {
                LevelId = level.levelID,
                Name    = level.songName
            };

            List <Characteristic> characteristics = new List <Characteristic>();

            foreach (var beatmapSet in level.previewDifficultyBeatmapSets)
            {
                characteristics.Add(new Characteristic()
                {
                    SerializedName = beatmapSet.beatmapCharacteristic.serializedName,
                    Difficulties   = beatmapSet.beatmapDifficulties.Select(x => (SharedConstructs.BeatmapDifficulty)x).ToArray()
                });
            }
            matchLevel.Characteristics   = characteristics.ToArray();
            Match.SelectedLevel          = matchLevel;
            Match.SelectedCharacteristic = Match.SelectedLevel.Characteristics.First(x => x.SerializedName == beatmap.parentDifficultyBeatmapSet.beatmapCharacteristic.serializedName);
            Match.SelectedDifficulty     = (SharedConstructs.BeatmapDifficulty)beatmap.difficulty;

            if (isHost)
            {
                Plugin.client.UpdateMatch(Match);
            }
        }
Exemple #6
0
        private void Init(CountersData data)
        {
            _scoreController = data.ScoreController;
            PlayerDataModelSO player = data.PlayerData;

            gameplayModsModel = data.ModifiersData;
            gameplayMods      = data.PlayerData.playerData.gameplayModifiers;
            IDifficultyBeatmap beatmap = data.GCSSD.difficultyBeatmap;

            stats = player.playerData.GetPlayerLevelStatsData(
                beatmap.level.levelID, beatmap.difficulty, beatmap.parentDifficultyBeatmapSet.beatmapCharacteristic);
            int maxRawScore = ScoreController.MaxRawScoreForNumberOfNotes(beatmap.beatmapData.notesCount);

            _maxPossibleScore = Mathf.RoundToInt(maxRawScore * gameplayModsModel.GetTotalMultiplier(gameplayMods));
            beginningPB       = stats.highScore / (float)_maxPossibleScore;
            highScore         = stats.highScore;

            Vector3 position = CountersController.DeterminePosition(gameObject, settings.Position, settings.Distance);

            TextHelper.CreateText(out _PbTrackerText, position);
            _PbTrackerText.fontSize  = settings.TextSize;
            _PbTrackerText.color     = Color.white;
            _PbTrackerText.alignment = TextAlignmentOptions.Center;

            _scoreController.scoreDidChangeEvent += UpdateScore;

            SetPersonalBest(beginningPB);

            if (settings.UnderScore)
            {
                StartCoroutine(WaitForScoreCounter());
            }
        }
        public async void LoadScene()
        {
            IDifficultyBeatmap        diffBeatmap = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.difficultyBeatmap;
            CustomPreviewBeatmapLevel customPreviewBeatmapLevel = diffBeatmap.level as CustomPreviewBeatmapLevel;

            if (customPreviewBeatmapLevel != null)
            {
                string customLevelPath = customPreviewBeatmapLevel.customLevelPath;
                string mapFileName     = diffBeatmap.difficulty.Name();
                string filepath        = customLevelPath + "\\ExpertPlusEffect.dat";
                Logger.log.Error("custom level path = " + filepath);
                Logger.log.Error("custom level difficulty = " + mapFileName);


                player = new CutEffectPlayer();
                player.Init(gameObject);
                if (await player.TryLoadCutEffectMap(filepath))
                {
                    return;
                }
            }

            player = null;
            //string cutEffectMapPath = "D:\\ProgramFiles\\Steam\\steamapps\\common\\Beat Saber\\Beat Saber_Data\\CustomLevels\\2a7 (Night of Nights - squeaksies)\\ExpertPlusEffect.dat";
        }
 static void Prefix(MissionLevelScenesTransitionSetupDataSO __instance, IDifficultyBeatmap difficultyBeatmap, MissionObjective[] missionObjectives, GameplayModifiers gameplayModifiers, PlayerSpecificSettings playerSpecificSettings)
 {
     Plugin.LevelData.GameplayCoreSceneSetupData = new GameplayCoreSceneSetupData(difficultyBeatmap, gameplayModifiers, playerSpecificSettings, PracticeSettings.defaultPracticeSettings, false);
     Plugin.LevelData.IsSet     = true;
     __instance.didFinishEvent -= __instance_didFinishEvent;
     __instance.didFinishEvent += __instance_didFinishEvent;
 }
 static void Prefix(StandardLevelScenesTransitionSetupDataSO __instance, IDifficultyBeatmap difficultyBeatmap, GameplayModifiers gameplayModifiers, PlayerSpecificSettings playerSpecificSettings, PracticeSettings practiceSettings, string backButtonText, bool useTestNoteCutSoundEffects)
 {
     Plugin.LevelData.GameplayCoreSceneSetupData = new GameplayCoreSceneSetupData(difficultyBeatmap, gameplayModifiers, playerSpecificSettings, practiceSettings, useTestNoteCutSoundEffects);
     Plugin.LevelData.IsSet     = true;
     __instance.didFinishEvent -= __instance_didFinishEvent;
     __instance.didFinishEvent += __instance_didFinishEvent;
 }
        private void songDetail_didChangeDifficultyBeatmapEvent(IDifficultyBeatmap beatmap)
        {
            var level = beatmap.level;

            //Assemble new match info and update the match
            var matchLevel = new PreviewBeatmapLevel()
            {
                LevelId = level.levelID,
                Name    = level.songName
            };

            List <Characteristic> characteristics = new List <Characteristic>();

            foreach (var beatmapSet in level.previewDifficultyBeatmapSets)
            {
                var c = new Characteristic()
                {
                    SerializedName = beatmapSet.beatmapCharacteristic.serializedName,
                };
                c.Difficulties.AddRange(beatmapSet.beatmapDifficulties.Select(x => (TournamentAssistantShared.Models.BeatmapDifficulty)x));
                characteristics.Add(c);
            }
            matchLevel.Characteristics.AddRange(characteristics);
            Match.SelectedLevel          = matchLevel;
            Match.SelectedCharacteristic = Match.SelectedLevel.Characteristics.First(x => x.SerializedName == beatmap.parentDifficultyBeatmapSet.beatmapCharacteristic.serializedName);
            Match.SelectedDifficulty     = (TournamentAssistantShared.Models.BeatmapDifficulty)beatmap.difficulty;

            if (isHost)
            {
                Plugin.client.UpdateMatch(Match);
            }
        }
 private static void Postfix(ref IDifficultyBeatmap beatmap)
 {
     if (beatmap.parentDifficultyBeatmapSet != null)
     {
         TADifficultyBeatmapSelected?.Invoke(beatmap);
     }
 }
Exemple #12
0
        public override void CounterInit()
        {
            ColorUtility.TryParseHtmlString("#FFA500", out orange);

            modifiersModel = SCGameplayModsModel(ref scoreController);
            IDifficultyBeatmap beatmap = data.difficultyBeatmap;
            int maxRawScore            = ScoreModel.MaxRawScoreForNumberOfNotes(beatmap.beatmapData.notesCount);

            maxPossibleScore = ScoreModel.GetModifiedScoreForGameplayModifiersScoreMultiplier(maxRawScore,
                                                                                              modifiersModel.GetTotalMultiplier(data.gameplayModifiers));
            stats     = playerDataModel.playerData.GetPlayerLevelStatsData(beatmap);
            highScore = stats.highScore;

            if (scoreConfig.Enabled && Settings.UnderScore)
            {
                counter = CanvasUtility.CreateTextFromSettings(scoreConfig, SCORE_COUNTER_OFFSET);
            }
            else
            {
                counter = CanvasUtility.CreateTextFromSettings(Settings);
            }
            counter.alignment = TextAlignmentOptions.Top;
            counter.fontSize  = Settings.TextSize;

            SetPersonalBest((float)highScore / maxPossibleScore);
        }
Exemple #13
0
        private static void Prefix(IDifficultyBeatmap difficultyBeatmap, ref OverrideEnvironmentSettings overrideEnvironmentSettings)
        {
            if (difficultyBeatmap.beatmapData is CustomBeatmapData customBeatmapData)
            {
                IEnumerable <string> requirements = ((List <object>)Trees.at(customBeatmapData.beatmapCustomData, "_requirements"))?.Cast <string>();
                IEnumerable <string> suggestions  = ((List <object>)Trees.at(customBeatmapData.beatmapCustomData, "_suggestions"))?.Cast <string>();
                bool chromaRequirement            = (requirements?.Contains(Chroma.Plugin.REQUIREMENTNAME) ?? false) || (suggestions?.Contains(Chroma.Plugin.REQUIREMENTNAME) ?? false);

                // please let me remove this shit
                bool legacyOverride = difficultyBeatmap.beatmapData.beatmapEventsData.Any(n => n.value >= LegacyLightHelper.RGB_INT_OFFSET);
                if (legacyOverride)
                {
                    ChromaLogger.Log("Legacy Chroma Detected...", IPA.Logging.Logger.Level.Warning);
                    ChromaLogger.Log("Please do not use Legacy Chroma for new maps as it is deprecated and its functionality in future versions of Chroma cannot be guaranteed", IPA.Logging.Logger.Level.Warning);
                }

                ChromaController.ToggleChromaPatches((chromaRequirement || legacyOverride) && ChromaConfig.Instance.CustomColorEventsEnabled);
                ChromaController.DoColorizerSabers = chromaRequirement && ChromaConfig.Instance.CustomColorEventsEnabled;

                if (chromaRequirement && ChromaConfig.Instance.EnvironmentEnhancementsEnabled && Trees.at(customBeatmapData.beatmapCustomData, "_environmentRemoval") != null)
                {
                    overrideEnvironmentSettings = null;
                }
            }
        }
        private static void UploadScore(IDifficultyBeatmap levelDifficulty, LevelCompletionResults results, out bool newHighScore)
        {
            var freePlayCoordinator = Resources.FindObjectsOfTypeAll <SoloFreePlayFlowCoordinator>().First();
            var dataModel           = freePlayCoordinator.GetPrivateField <PlayerDataModel>("_playerDataModel");

            PlayerData           currentLocalPlayer   = dataModel.playerData;
            PlayerLevelStatsData playerLevelStatsData = currentLocalPlayer.GetPlayerLevelStatsData(levelDifficulty.level.levelID, levelDifficulty.difficulty, levelDifficulty.parentDifficultyBeatmapSet.beatmapCharacteristic);

            int prevHighScore = playerLevelStatsData.highScore;

            LevelCompletionResults levelCompletionResults = results;

            playerLevelStatsData.UpdateScoreData(levelCompletionResults.modifiedScore, levelCompletionResults.maxCombo, levelCompletionResults.fullCombo, levelCompletionResults.rank);

            newHighScore = playerLevelStatsData.highScore > prevHighScore;

            var platFormLeaderBoardsModel = freePlayCoordinator.GetPrivateField <PlatformLeaderboardsModel>("_platformLeaderboardsModel");

            platFormLeaderBoardsModel.UploadScore(
                levelDifficulty,
                results.rawScore,
                results.modifiedScore,
                results.fullCombo,
                results.goodCutsCount,
                results.badCutsCount,
                results.missedCount,
                results.maxCombo,
                results.energy,
                results.gameplayModifiers);
        }
Exemple #15
0
        public override void CounterInit()
        {
            modifiersModel = SCGameplayModsModel(ref scoreController);
            IDifficultyBeatmap beatmap = data.difficultyBeatmap;
            int maxRawScore            = ScoreModel.MaxRawScoreForNumberOfNotes(noteCountProcessor.NoteCount);

            maxPossibleScore = ScoreModel.GetModifiedScoreForGameplayModifiersScoreMultiplier(maxRawScore,
                                                                                              modifiersModel.GetTotalMultiplier(data.gameplayModifiers));
            stats     = playerDataModel.playerData.GetPlayerLevelStatsData(beatmap);
            highScore = stats.highScore;

            if (scoreConfig.Enabled && Settings.UnderScore)
            {
                HUDCanvas scoreCanvas = CanvasUtility.GetCanvasSettingsFromID(scoreConfig.CanvasID);
                counter = CanvasUtility.CreateTextFromSettings(scoreConfig, SCORE_COUNTER_OFFSET * (3f / scoreCanvas.PositionScale));
            }
            else
            {
                counter = CanvasUtility.CreateTextFromSettings(Settings);
            }
            counter.alignment = TextAlignmentOptions.Top;
            counter.fontSize  = Settings.TextSize;

            pbRatio = (float)highScore / maxPossibleScore;

            SetPersonalBest((float)highScore / maxPossibleScore);
            ScoreUpdated(0);
        }
Exemple #16
0
        private void CheckActivation()
        {
            IDifficultyBeatmap difficultyBeatmap = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.difficultyBeatmap;

            ExtraSongData.DifficultyData difficultyData = Collections.RetrieveDifficultyData(difficultyBeatmap);

            if (difficultyData != null)
            {
                if (Config.swingMode)
                {
                    active = true;
                    ExtraBeatmapData.ParseExtraDataForSong();
                    ScoreSubmission.DisableSubmission("360 Mode");
                }
                else
                {
                    if (difficultyData.additionalDifficultyData._requirements.Contains("360 Mode"))
                    {
                        active = true;
                        ExtraBeatmapData.ParseExtraDataForSong();
                    }
                    else
                    {
                        active = false;
                    }
                }
            }
            else
            {
                active = false;
            }
        }
Exemple #17
0
        //Gets a the player's locally stored rank for a map
        public RankModel.Rank GetLocalRank(IDifficultyBeatmap map, PlayerDataModel dataModel = null)
        {
            dataModel = dataModel ?? Resources.FindObjectsOfTypeAll <PlayerDataModel>().First();
            var playerLevelStatsData = dataModel.playerData.GetPlayerLevelStatsData(map.level.levelID, map.difficulty, map.parentDifficultyBeatmapSet.beatmapCharacteristic);

            return(playerLevelStatsData.validScore ? playerLevelStatsData.maxRank : RankModel.Rank.E);
        }
        public static void OnGameSceneLoaded()
        {
            //UI for debugging purposes
            //ModUI.Create();

            if (!BS_Utils.Plugin.LevelData.IsSet)
            {
                Plugin.Log.Debug("LevelData not set!");
            }
            else
            {
                CurrentDifficultyBeatmap = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.difficultyBeatmap;
            }

            DisableScoreSubmissionIfNeeded();

            var globalTrickManager = new GameObject("GlobalTrickManager").AddComponent <GlobalTrickManager>();

            globalTrickManager.AudioTimeSyncController = Object.FindObjectOfType <AudioTimeSyncController>();

            Object.FindObjectsOfType <Saber>().ToList().ForEach(saber => saber.gameObject.AddComponent <SaberTrickManager>());

            try
            {
                CreateCheckbox();
            }
            catch {}
        }
            static bool Prefix(ref GameCoreSceneSetup __instance, ref GameplayCoreSceneSetupData ____sceneSetupData)
            {
                IDifficultyBeatmap difficultyBeatmap = ____sceneSetupData.difficultyBeatmap;
                IReadOnlyList <BeatmapEventData> beatmapEventData = difficultyBeatmap.beatmapData.beatmapEventsData;
                SpawnRotationProcessor           rotProcessor     = new SpawnRotationProcessor();
                bool is360 = false;

                foreach (BeatmapEventData beatmapEvent in beatmapEventData)
                {
                    if (beatmapEvent.type != BeatmapEventType.Event14 && beatmapEvent.type != BeatmapEventType.Event15)
                    {
                        continue;
                    }

                    if (rotProcessor.RotationForEventValue(beatmapEvent.value) != 0)
                    {
                        is360 = true;
                        break;
                    }
                }

                if (!is360)
                {
                    IPAUtils.SetProperty <BeatmapData, int>(difficultyBeatmap.beatmapData, "spawnRotationEventsCount", 0);
                }
                return(true);
            }
Exemple #20
0
        private void StandardLevelDetailViewController_didChangeDifficultyBeatmapEvent(
            StandardLevelDetailViewController controller, IDifficultyBeatmap difficultyBeatmap)
        {
            try
            {
                if (difficultyBeatmap.level is Search.SearchResultBeatmapLevel)
                {
                    Logger.Debug("didChangeDifficultyBeatmapEvent()");

                    var _standardLevelDetailView = controller.GetPrivateField <StandardLevelDetailView>("_standardLevelDetailView");
                    var _levelParamsPanel        = _standardLevelDetailView.GetPrivateField <LevelParamsPanel>("_levelParamsPanel");

                    _levelParamsPanel.bpm            = Mathf.Ceil(difficultyBeatmap.level.beatsPerMinute);
                    _levelParamsPanel.duration       = difficultyBeatmap.level.songDuration * 60;
                    _levelParamsPanel.notesPerSecond = difficultyBeatmap.beatmapData.notesCount / (difficultyBeatmap.level.songDuration * 60);
                    _levelParamsPanel.notesCount     = difficultyBeatmap.beatmapData.notesCount;
                    _levelParamsPanel.obstaclesCount = difficultyBeatmap.beatmapData.obstaclesCount;
                    _levelParamsPanel.bombsCount     = difficultyBeatmap.beatmapData.bombsCount;
                }
            }
            catch (Exception ex)
            {
                Logger.Debug(ex);
            }
        }
Exemple #21
0
        public static SongID GetSongID(IDifficultyBeatmap difficultyBeatmap)
        {
            var id         = GetHash(difficultyBeatmap.level.levelID);
            var difficulty = difficultyBeatmap.difficulty;

            return(new SongID(id, difficulty));
        }
Exemple #22
0
        public override void CounterInit()
        {
            IDifficultyBeatmap beatmap = data.difficultyBeatmap;

            maxPossibleScore = ScoreModel.ComputeMaxMultipliedScoreForBeatmap(beatmapData);

            stats     = playerDataModel.playerData.GetPlayerLevelStatsData(beatmap);
            highScore = stats.highScore;

            if (scoreConfig.Enabled && Settings.UnderScore)
            {
                HUDCanvas scoreCanvas = CanvasUtility.GetCanvasSettingsFromID(scoreConfig.CanvasID);
                counter = CanvasUtility.CreateTextFromSettings(scoreConfig, SCORE_COUNTER_OFFSET * (3f / scoreCanvas.PositionScale));
            }
            else
            {
                counter = CanvasUtility.CreateTextFromSettings(Settings);
            }
            counter.alignment = TextAlignmentOptions.Top;
            counter.fontSize  = Settings.TextSize;

            pbRatio = (float)highScore / maxPossibleScore;

            SetPersonalBest(pbRatio);
            ScoreUpdated(0);
        }
Exemple #23
0
        private void _standardLevelResultsViewController_didActivateEvent(bool firstActivation, VRUI.VRUIViewController.ActivationType activationType)
        {
            IDifficultyBeatmap diffBeatmap = _standardLevelResultsViewController.GetPrivateField <IDifficultyBeatmap>("_difficultyBeatmap");

            _lastLevel = diffBeatmap.level;

            if (!(_lastLevel is CustomPreviewBeatmapLevel))
            {
                _upvoteButton.gameObject.SetActive(false);
                _downvoteButton.gameObject.SetActive(false);
                _ratingText.gameObject.SetActive(false);
                //         _reviewButton.gameObject.SetActive(false);
            }
            else
            {
                _upvoteButton.gameObject.SetActive(true);
                _downvoteButton.gameObject.SetActive(true);
                _ratingText.gameObject.SetActive(true);
                _ratingText.alignment = TextAlignmentOptions.Center;
                //      _reviewButton.gameObject.SetActive(true);

                _upvoteButton.interactable   = false;
                _downvoteButton.interactable = false;
                //         _reviewButton.interactable = false;
                _ratingText.text = "LOADING...";

                StartCoroutine(GetRatingForSong(_lastLevel));
            }
        }
        public void Init(OnlinePlayerController newOwner)
        {
            BeatmapObjectCallbackController original = FindObjectsOfType <BeatmapObjectCallbackController>().First(x => !(x is OnlineBeatmapCallbackController));

            foreach (FieldInfo info in original.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic).Where(x => !x.Name.ToLower().Contains("event")))
            {
                info.SetValue(this, info.GetValue(original));
            }

            owner = newOwner;

            _beatmapObjectDataCallbackCacheList = new List <BeatmapObjectData>();
            _beatmapObjectCallbackData          = new List <BeatmapObjectCallbackData>();

            _beatmapDataModel = new GameObject("CustomBeatmapDataModel").AddComponent <BeatmapDataModel>();
            if (BS_Utils.Plugin.LevelData.IsSet)
            {
                LevelOptionsInfo   levelInfo   = owner.playerInfo.updateInfo.playerLevelOptions;
                IDifficultyBeatmap diffBeatmap = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.difficultyBeatmap.level.beatmapLevelData.difficultyBeatmapSets.First(x => x.beatmapCharacteristic.serializedName == owner.playerInfo.updateInfo.playerLevelOptions.characteristicName).difficultyBeatmaps.First(x => x.difficulty == owner.playerInfo.updateInfo.playerLevelOptions.difficulty);
                BeatmapData        data        = diffBeatmap.beatmapData;

                _beatmapDataModel.beatmapData = BeatDataTransformHelper.CreateTransformedBeatmapData(data, levelInfo.modifiers.ToGameplayModifiers(), PracticeSettings.defaultPracticeSettings, PlayerSpecificSettings.defaultSettings);
                HandleBeatmapDataModelDidChangeBeatmapData();

                Plugin.log.Info($"Set custom BeatmapDataModel for difficulty {levelInfo.difficulty}");
            }
        }
Exemple #25
0
        public static void SaveRecord(IDifficultyBeatmap beatmap, LevelCompletionResults result, bool submissionDisabled = false)
        {
            // We now keep failed records.
            var cleared = result.levelEndStateType == LevelCompletionResults.LevelEndStateType.Cleared;

            // If submissionDisabled = true, we assume custom gameplay modifiers are applied.
            var param = ModsToParam(result.gameplayModifiers);

            param |= submissionDisabled ? Param.SubmissionDisabled : 0;

            var record = new Record
            {
                Date          = DateTimeOffset.Now.ToUnixTimeMilliseconds(),
                ModifiedScore = result.modifiedScore,
                RawScore      = result.rawScore,
                LastNote      = cleared ? -1 : result.goodCutsCount + result.badCutsCount + result.missedCount,
                Param         = (int)param
            };

            var beatmapCharacteristicName = beatmap.parentDifficultyBeatmapSet.beatmapCharacteristic.serializedName;
            var difficulty = $"{beatmap.level.levelID}___{(int)beatmap.difficulty}___{beatmapCharacteristicName}";

            if (!Records.ContainsKey(difficulty))
            {
                Records.Add(difficulty, new List <Record>());
            }
            Records[difficulty].Add(record);

            // Save to a file. We do this synchronously because the overhead is small. (400 ms / 15 MB, 60 ms / 1 MB)
            SaveRecordsToFile();

            Plugin.Log?.Info($"Saved a new record {difficulty} ({result.modifiedScore}).");
        }
Exemple #26
0
        private async void SetContent(IBeatmapLevel level)
        {
            if (level.beatmapLevelData.difficultyBeatmapSets.Any(x => x.beatmapCharacteristic == _playerDataModel.playerData.lastSelectedBeatmapCharacteristic))
            {
                _selectedDifficultyBeatmap = level.GetDifficultyBeatmap(_playerDataModel.playerData.lastSelectedBeatmapCharacteristic, _playerDataModel.playerData.lastSelectedBeatmapDifficulty);
            }
            else if (level.beatmapLevelData.difficultyBeatmapSets.Length > 0)
            {
                _selectedDifficultyBeatmap = level.GetDifficultyBeatmap(level.beatmapLevelData.difficultyBeatmapSets[0].beatmapCharacteristic, _playerDataModel.playerData.lastSelectedBeatmapDifficulty);
            }
            else
            {
                Plugin.log.Critical("Unable to set level! No beatmap characteristics found!");
            }

            UpdateContent();

            _playerDataModel.playerData.SetLastSelectedBeatmapCharacteristic(_selectedDifficultyBeatmap.parentDifficultyBeatmapSet.beatmapCharacteristic);
            _playerDataModel.playerData.SetLastSelectedBeatmapDifficulty(_selectedDifficultyBeatmap.difficulty);

            SetControlData(_selectedLevel.beatmapLevelData.difficultyBeatmapSets, _playerDataModel.playerData.lastSelectedBeatmapCharacteristic);

            levelCoverImage.texture = await level.GetCoverImageTexture2DAsync(cancellationToken.Token);

            SetLoadingState(false);
        }
 internal static void Patch(IDifficultyBeatmap difficultyBeatmap)
 {
     if (difficultyBeatmap.beatmapData is CustomBeatmapData customBeatmapData)
     {
         BasicPatch(customBeatmapData);
     }
 }
Exemple #28
0
        public static IDifficultyBeatmap GetDifficultyBeatmap(this BeatmapLevelSO level, BeatmapCharacteristicSO characteristic, BeatmapDifficulty difficulty, bool strictDifficulty = false)
        {
            IDifficultyBeatmapSet difficultySet = null;

            if (characteristic == null)
            {
                difficultySet = level.difficultyBeatmapSets.FirstOrDefault();
            }
            else
            {
                difficultySet = level.difficultyBeatmapSets.FirstOrDefault(x => x.beatmapCharacteristic == characteristic);
            }

            if (difficultySet == null)
            {
                return(null);
            }

            IDifficultyBeatmap beatmap = difficultySet.difficultyBeatmaps.FirstOrDefault(x => x.difficulty == difficulty);

            if (beatmap == null && !strictDifficulty)
            {
                return(difficultySet.difficultyBeatmaps[GetClosestDifficultyIndex(difficultySet.difficultyBeatmaps, difficulty)]);
            }
            else
            {
                return(beatmap);
            }
        }
        private static void Prefix(ref IDifficultyBeatmap difficultyBeatmap, ref ColorScheme?overrideColorScheme)
        {
            var environmentInfoSO = difficultyBeatmap.GetEnvironmentInfo();
            var fallbackScheme    = overrideColorScheme ?? new ColorScheme(environmentInfoSO.colorScheme);

            var songData = Collections.RetrieveDifficultyData(difficultyBeatmap);

            if (songData == null)
            {
                return;
            }

            if (songData._colorLeft == null && songData._colorRight == null && songData._envColorLeft == null && songData._envColorRight == null && songData._obstacleColor == null)
            {
                return;
            }

            if (Plugin.CustomSongColors)
            {
                Logging.Logger.Info("Custom Song Colors On");
                var saberLeft  = songData._colorLeft == null ? fallbackScheme.saberAColor : Utils.ColorFromMapColor(songData._colorLeft);
                var saberRight = songData._colorRight == null ? fallbackScheme.saberBColor : Utils.ColorFromMapColor(songData._colorRight);
                var envLeft    = songData._envColorLeft == null
                    ? songData._colorLeft == null ? fallbackScheme.environmentColor0 : Utils.ColorFromMapColor(songData._colorLeft)
                    : Utils.ColorFromMapColor(songData._envColorLeft);
                var envRight = songData._envColorRight == null
                    ? songData._colorRight == null ? fallbackScheme.environmentColor1 : Utils.ColorFromMapColor(songData._colorRight)
                    : Utils.ColorFromMapColor(songData._envColorRight);
                var envLeftBoost  = songData._envColorLeftBoost == null ? envLeft : Utils.ColorFromMapColor(songData._envColorLeftBoost);
                var envRightBoost = songData._envColorRightBoost == null ? envRight : Utils.ColorFromMapColor(songData._envColorRightBoost);
                var obstacle      = songData._obstacleColor == null ? fallbackScheme.obstaclesColor : Utils.ColorFromMapColor(songData._obstacleColor);
                overrideColorScheme = new ColorScheme("SongCoreMapColorScheme", "SongCore Map Color Scheme", true, "SongCore Map Color Scheme", false, saberLeft, saberRight, envLeft,
                                                      envRight, true, envLeftBoost, envRightBoost, obstacle);
            }
        }
 internal CustomNoteManager([InjectOptional] Submission submission, NoteAssetLoader noteAssetLoader, IDifficultyBeatmap difficultyBeatmap, GameplayCoreSceneSetupData gameplayCoreSceneSetupData)
 {
     _submission                 = submission;
     _noteAssetLoader            = noteAssetLoader;
     _difficultyBeatmap          = difficultyBeatmap;
     _gameplayCoreSceneSetupData = gameplayCoreSceneSetupData;
 }