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 static BeatmapData InjectCustomData(BeatmapLineData[] beatmapLineData, BeatmapEventData[] beatmapEventData,
                                                    BeatmapDataLoader beatmapDataLoader, dynamic RawBPMChanges, float shuffle, float shufflePeriod)
        {
            List <CustomBeatmapSaveData.CustomEventData> customEventsSaveData = customBeatmapSaveData.customEvents;
            List <CustomEventData> customEvents = new List <CustomEventData>(customEventsSaveData.Count);

            foreach (CustomBeatmapSaveData.CustomEventData customEventData in customEventsSaveData)
            {
                int   num  = 0;
                float time = customEventData.time;

                // BeatmapDataLoader's BPMChangeData is private so we get to do a crap top of reflection to convert it to our BPMChangeData
                Type BPMChangeData = Type.GetType("BeatmapDataLoader+BPMChangeData,Main");
                List <BPMChangeData> BPMChanges = new List <BPMChangeData>();
                foreach (object i in RawBPMChanges as IEnumerable)
                {
                    float bpmChangeStartTime    = (float)BPMChangeData.GetField("bpmChangeStartTime").GetValue(i);
                    float bpmChangeStartBPMTime = (float)BPMChangeData.GetField("bpmChangeStartBPMTime").GetValue(i);
                    float bpm = (float)BPMChangeData.GetField("bpm").GetValue(i);

                    BPMChanges.Add(new BPMChangeData(bpmChangeStartTime, bpmChangeStartBPMTime, bpm));
                }

                while (num < BPMChanges.Count - 1 && BPMChanges[num + 1].bpmChangeStartBPMTime < time)
                {
                    num++;
                }
                BPMChangeData bpmchangeData = BPMChanges[num];
                float         realTime      = bpmchangeData.bpmChangeStartTime + beatmapDataLoader.GetRealTimeFromBPMTime(time - bpmchangeData.bpmChangeStartBPMTime, bpmchangeData.bpm, shuffle, shufflePeriod);

                customEvents.Add(new CustomEventData(realTime, customEventData.type, customEventData.data ?? Tree()));
            }
            customEvents = customEvents.OrderBy(x => x.time).ToList();
            var data = new BeatmapData(beatmapLineData.Length);

            data.SetField("_beatmapLinesData", beatmapLineData);
            foreach (var d in beatmapEventData)
            {
                data.AddBeatmapEventData(d);
            }
            return(new CustomBeatmapData(data, customEvents.ToArray(), customBeatmapSaveData.customData ?? Tree(), Tree(), Tree()));
        }