Ejemplo n.º 1
0
        private void SwitchToNextMap()
        {
            if (nextSong == null || nextBeatmap == null || nextMapDiffInfo == null)
            {
                return;
            }
            if (BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.playerSpecificSettings.environmentEffectsFilterDefaultPreset == EnvironmentEffectsFilterPreset.NoEffects)
            {
                nextBeatmap.SetField <BeatmapData, List <BeatmapEventData> >("_beatmapEventsData", new BeatmapEventData[0].ToList());
            }

            AudioClip oldClip = GameObjects.songAudio.clip;

            TwitchPowers.ResetTimeSync(nextSong, 0f, nextSongInfo.songTimeOffset, 1f);
            TwitchPowers.ManuallySetNJSOffset(GameObjects.spawnController, nextMapDiffInfo.noteJumpMovementSpeed,
                                              nextMapDiffInfo.noteJumpStartBeatOffset, nextSongInfo.beatsPerMinute);



            //    TwitchPowers.ClearCallbackItemDataList(callBackDataList);
            // DestroyNotes();
            TwitchPowers.DestroyObjectsRaw();
            TwitchPowers.ResetNoteCutSoundEffects(seManager);
            callbackController.SetField("_spawningStartTime", 0f);
            callbackController.SetNewBeatmapData(nextBeatmap);
            UpdatePauseMenu();
            ClearSoundEffects();
            //Destroying audio clip is actually bad idea
            //   IPA.Utilities.Async.UnityMainThreadTaskScheduler.Factory.StartNew(() => { oldClip.UnloadAudioData(); AudioClip.Destroy(oldClip); });
            Task.Run(PrepareNextSong);
            CheckIntroSkip();
            ResetProgressUI();
        }
Ejemplo n.º 2
0
        private async void ReloadBeatmap()
        {
            string filePath  = Path.Combine(_currentLevel.customLevelPath, _currentDiffBeatmap.beatmapFilename);
            string leveljson = File.ReadAllText(filePath);
            //Load new beatmapdata asynchronously
            BeatmapData newBeatmap = await _levelLoader.LoadBeatmapDataAsync(_currentLevel.customLevelPath, _currentDiffBeatmap.beatmapFilename, _currentLevel.standardLevelInfoSaveData, _cancelSource.Token);

            GameplayCoreSceneSetupData     gameSetup = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData;
            EnvironmentEffectsFilterPreset environmentEffectsFilterPreset = ((BeatmapDifficulty)(Enum.Parse(typeof(BeatmapDifficulty), _currentDiffBeatmap.difficulty)) == BeatmapDifficulty.ExpertPlus) ? gameSetup.playerSpecificSettings.environmentEffectsFilterExpertPlusPreset : gameSetup.playerSpecificSettings.environmentEffectsFilterDefaultPreset;

            newBeatmap = (BeatmapData)BeatmapDataTransformHelper.CreateTransformedBeatmapData(newBeatmap, _currentLevel, gameSetup.gameplayModifiers, gameSetup.practiceSettings, gameSetup.playerSpecificSettings.leftHanded, environmentEffectsFilterPreset, gameSetup.environmentInfo.environmentIntensityReductionOptions);
            //Hotswap Beatmap

            ResetTimeSync();
            DestroyObjects();
            ResetNoteCutSoundEffects();
            _callbackController.SetField("_spawningStartTime", _songStartTime);
            _callbackController.SetNewBeatmapData(newBeatmap);
            //Unpause
            if (_pauseController.GetField <bool>("_paused"))
            {
                CheckPracticePlugin();
                _pauseController.HandlePauseMenuManagerDidPressContinueButton();
            }
            _queuedLoad = false;
        }
Ejemplo n.º 3
0
        private IEnumerator TransformMap()
        {
            yield return(new WaitForSecondsRealtime(0.01f));

            if (BS_Utils.Plugin.LevelData.Mode == BS_Utils.Gameplay.Mode.Multiplayer)
            {
                yield break;
            }

            var config = Configuration.instance.ConfigurationData;

            // Set up for One Color
            if (config.OneColor && !config.NoArrowsRandom)
            {
                this.useLeft =
                    (config.PlayMode == PlayMode.BeatSaber && config.UseLeftSaber) ||
                    (config.PlayMode == PlayMode.DarthMaul && config.UseLeftController) ||
                    (config.PlayMode == PlayMode.BeatSpear && config.UseLeftSpear);

                this.undesiredNoteType = this.useLeft ? ColorType.ColorB : ColorType.ColorA;
            }

            try
            {
                BeatmapObjectCallbackController callbackController = null;
                BeatmapData beatmapData = null;
                BeatmapObjectCallbackController[] callbackControllers = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>();
                foreach (BeatmapObjectCallbackController cbc in callbackControllers)
                {
                    if (cbc.GetField <BeatmapData>("_beatmapData") != null)
                    {
                        callbackController = cbc;
                        beatmapData        = callbackController.GetField <BeatmapData>("_beatmapData");
                    }
                }
                if (config.NoArrowsRandom)
                {
                    // Transform the map to No Arrows Random using the ingame algorithm first
                    AlternativePlay.Logger.Info($"Transforming NoArrowsRandom for song: {this.currentBeatmap.level.songName}");
                    var transformedBeatmap = BeatmapDataNoArrowsTransform.CreateTransformedData(beatmapData);
                    callbackController.SetNewBeatmapData(transformedBeatmap);
                }

                // Transform every note
                this.TransformNotes(beatmapData);

                // Touch Notes speed detection is not handled here but in the HarmonyPatches
            }
            catch (Exception e)
            {
                AlternativePlay.Logger.Error($"Transforming Error: {this.currentBeatmap.level.songName}");
                AlternativePlay.Logger.Error($"Error Message: {e.Message}");
                AlternativePlay.Logger.Error($"Stack Trace: {e.StackTrace}");
            }
        }
Ejemplo n.º 4
0
        private IEnumerator TransformMap()
        {
            yield return(new WaitForSecondsRealtime(0.1f));

            // Set up for One Color
            if (ConfigOptions.instance.OneColor && !ConfigOptions.instance.NoArrowsRandom)
            {
                this.useLeft =
                    (ConfigOptions.instance.PlayMode == PlayMode.BeatSaber && ConfigOptions.instance.UseLeftSaber) ||
                    (ConfigOptions.instance.PlayMode == PlayMode.DarthMaul && ConfigOptions.instance.UseLeftController) ||
                    (ConfigOptions.instance.PlayMode == PlayMode.BeatSpear && ConfigOptions.instance.UseLeftSpear);

                this.undesiredNoteType = this.useLeft ? NoteType.NoteB : NoteType.NoteA;

                // Change the other saber to desired type
                Saber.SaberType desiredSaberType = this.useLeft ? Saber.SaberType.SaberA : Saber.SaberType.SaberB;
                var             saberObject      = new GameObject("SaberTypeObject").AddComponent <SaberTypeObject>();
                saberObject.SetField("_saberType", desiredSaberType);

                var   player      = Resources.FindObjectsOfTypeAll <PlayerController>().FirstOrDefault();
                Saber saberToSwap = this.useLeft ? player.rightSaber : player.leftSaber;
                saberToSwap.SetField("_saberType", saberObject);

                if (ConfigOptions.instance.RemoveOtherSaber && ConfigOptions.instance.PlayMode == PlayMode.BeatSaber)
                {
                    // Hide the off color saber
                    Saber saberToHide = ConfigOptions.instance.UseLeftSaber ? this.playerController.rightSaber : this.playerController.leftSaber;
                    saberToHide.gameObject.SetActive(false);
                }
            }

            // Get the in memory beat map
            BeatmapObjectCallbackController callbackController = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().First();
            BeatmapData beatmapData = callbackController.GetField <BeatmapData>("_beatmapData");

            if (ConfigOptions.instance.NoArrowsRandom)
            {
                // Transform the map to No Arrows Random using the ingame algorithm first
                Logging.Info($"Transforming NoArrowsRandom for song: {this.currentBeatmap.level.songName}");
                var transformedBeatmap = BeatmapDataNoArrowsTransform.CreateTransformedData(beatmapData, true);
                callbackController.SetNewBeatmapData(transformedBeatmap);
            }

            // Transform every note
            var allNoteObjects = beatmapData.beatmapLinesData
                                 .SelectMany(line => line.beatmapObjectsData)
                                 .Where(objectData => objectData.beatmapObjectType == BeatmapObjectType.Note)
                                 .ToList();

            allNoteObjects.ForEach(beatmapObject =>
            {
                var note = beatmapObject as NoteData;

                // Transform for NoArrows or TouchNotes here but do not if NoArrowsRandom was already applied
                if ((ConfigOptions.instance.NoArrows || ConfigOptions.instance.TouchNotes) && !ConfigOptions.instance.NoArrowsRandom)
                {
                    note.SetNoteToAnyCutDirection();
                }

                // Transform for One Color if this is the other note type
                if (ConfigOptions.instance.OneColor && note.noteType == undesiredNoteType)
                {
                    note.SwitchNoteType();
                }
            });

            // Touch Notes speed detection is not handled here but in the HarmonyPatches
        }
Ejemplo n.º 5
0
        private IEnumerator TransformMap()
        {
            yield return(new WaitForSecondsRealtime(0.1f));

            var config = Configuration.instance.ConfigurationData;

            // Set up for One Color
            if (config.OneColor && !config.NoArrowsRandom)
            {
                this.useLeft =
                    (config.PlayMode == PlayMode.BeatSaber && config.UseLeftSaber) ||
                    (config.PlayMode == PlayMode.DarthMaul && config.UseLeftController) ||
                    (config.PlayMode == PlayMode.BeatSpear && config.UseLeftSpear);

                this.undesiredNoteType = this.useLeft ? ColorType.ColorB : ColorType.ColorA;

                // Change the other saber to desired type
                SaberType desiredSaberType = this.useLeft ? SaberType.SaberA : SaberType.SaberB;
                var       saberObject      = new GameObject("SaberTypeObject").AddComponent <SaberTypeObject>();
                saberObject.SetField("_saberType", desiredSaberType);

                var   player      = Resources.FindObjectsOfTypeAll <SaberManager>().FirstOrDefault();
                Saber saberToSwap = this.useLeft ? player.rightSaber : player.leftSaber;
                saberToSwap.SetField("_saberType", saberObject);
            }

            try
            {
                BeatmapObjectCallbackController callbackController = null;
                BeatmapData beatmapData = null;
                BeatmapObjectCallbackController[] callbackControllers = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>();
                foreach (BeatmapObjectCallbackController cbc in callbackControllers)
                {
                    if (cbc.GetField <BeatmapData>("_beatmapData") != null)
                    {
                        callbackController = cbc;
                        beatmapData        = callbackController.GetField <BeatmapData>("_beatmapData");
                    }
                }
                //BeatmapObjectCallbackController callbackController = Resources.FindObjectsOfTypeAll<BeatmapObjectCallbackController>().FirstOrDefault();
                // BeatmapData beatmapData = callbackController.GetField<BeatmapData>("_beatmapData");
                if (config.NoArrowsRandom)
                {
                    // Transform the map to No Arrows Random using the ingame algorithm first
                    AlternativePlay.Logger.Info($"Transforming NoArrowsRandom for song: {this.currentBeatmap.level.songName}");
                    var transformedBeatmap = BeatmapDataNoArrowsTransform.CreateTransformedData(beatmapData);
                    callbackController.SetNewBeatmapData(transformedBeatmap);
                }

                // Transform every note
                var allNoteObjects = beatmapData.beatmapLinesData
                                     .SelectMany(line => line.beatmapObjectsData)
                                     .Where(objectData => objectData.beatmapObjectType == BeatmapObjectType.Note)
                                     .ToList();
                allNoteObjects.ForEach(beatmapObject =>
                {
                    var note = beatmapObject as NoteData;

                    // Transform for NoArrows or TouchNotes here but do not if NoArrowsRandom was already applied
                    if ((config.NoArrows || config.TouchNotes) && !config.NoArrowsRandom)
                    {
                        note.SetNoteToAnyCutDirection();
                    }

                    // Transform for One Color if this is the other note type
                    if (config.OneColor && note.colorType == this.undesiredNoteType)
                    {
                        note.SwitchNoteColorType();
                    }
                });
                // Touch Notes speed detection is not handled here but in the HarmonyPatches
            }
            catch
            {
                AlternativePlay.Logger.Info($"Transforming Error: {this.currentBeatmap.level.songName}");
            }

            // Touch Notes speed detection is not handled here but in the HarmonyPatches
        }