Exemple #1
0
        public static void OnSongTimeChanged(float newSongTime, float aheadTime)
        {
            foreach (var callbackData in CallbackList)
            {
                for (var i = 0; i < _beatmapData.beatmapLinesData.Length; i++)
                {
                    callbackData.nextObjectIndexInLine[i] = 0;
                    while (callbackData.nextObjectIndexInLine[i] < _beatmapData.beatmapLinesData[i].beatmapObjectsData.Length)
                    {
                        var beatmapObjectData = _beatmapData.beatmapLinesData[i].beatmapObjectsData[callbackData.nextObjectIndexInLine[i]];
                        if (beatmapObjectData.time - aheadTime >= newSongTime)
                        {
                            break;
                        }

                        callbackData.nextObjectIndexInLine[i]++;
                    }
                }
            }

            var newNextEventIndex = 0;

            while (newNextEventIndex < _beatmapData.beatmapEventData.Length)
            {
                var beatmapEventData = _beatmapData.beatmapEventData[newNextEventIndex];
                if (beatmapEventData.time >= newSongTime)
                {
                    break;
                }

                newNextEventIndex++;
            }

            _beatmapObjectCallbackController.SetPrivateField("_nextEventIndex", newNextEventIndex);

            var notesA = _noteAPool.activeItems.ToList();

            foreach (var noteA in notesA)
            {
                _beatmapObjectSpawnController.Despawn(noteA);
            }

            var notesB = _noteBPool.activeItems.ToList();

            foreach (var noteB in notesB)
            {
                _beatmapObjectSpawnController.Despawn(noteB);
            }

            var bombs = _bombNotePool.activeItems.ToList();

            foreach (var bomb in bombs)
            {
                _beatmapObjectSpawnController.Despawn(bomb);
            }

            var fullHeights = _fullHeightObstaclePool.activeItems.ToList();

            foreach (var fullHeight in fullHeights)
            {
                _beatmapObjectSpawnController.Despawn(fullHeight);
            }

            var tops = _topObstaclePool.activeItems.ToList();

            foreach (var top in tops)
            {
                _beatmapObjectSpawnController.Despawn(top);
            }

            Plugin.AudioTimeSync.SetPrivateField("_prevAudioSamplePos", -1);
            Plugin.AudioTimeSync.GetPrivateField <FloatSO>("_songTime").value = newSongTime;
            _noteCutSoundEffectManager.SetPrivateField("_prevNoteATime", -1);
            _noteCutSoundEffectManager.SetPrivateField("_prevNoteBTime", -1);
        }
        public static void OnSongTimeChanged(float newSongTime, float aheadTime)
        {
            if (_beatmapObjectCallbackController)
            {
                _beatmapData = _beatmapObjectCallbackController.GetPrivateField <BeatmapData>("_beatmapData");
            }
            foreach (var callbackData in CallbackList)
            {
                for (var i = 0; i < _beatmapData.beatmapLinesData.Count; i++)
                {
                    callbackData.nextObjectIndexInLine[i] = 0;
                    while (callbackData.nextObjectIndexInLine[i] < _beatmapData.beatmapLinesData[i].beatmapObjectsData.Count)
                    {
                        var beatmapObjectData = _beatmapData.beatmapLinesData[i].beatmapObjectsData[callbackData.nextObjectIndexInLine[i]];
                        if (beatmapObjectData.time - aheadTime >= newSongTime)
                        {
                            break;
                        }

                        callbackData.nextObjectIndexInLine[i]++;
                    }
                }
            }

            var newNextEventIndex = 0;

            while (newNextEventIndex < _beatmapData.beatmapEventsData.Count)
            {
                var beatmapEventData = _beatmapData.beatmapEventsData[newNextEventIndex];
                if (beatmapEventData.time >= newSongTime)
                {
                    break;
                }

                newNextEventIndex++;
            }

            _beatmapObjectCallbackController.SetPrivateField("_nextEventIndex", newNextEventIndex);
            _beatmapObjectManager.DissolveAllObjects();

            /*
             * var notesA = _notePool.activeItems.ToList();
             * foreach (var noteA in notesA)
             * {
             *  //               Console.WriteLine("Despawning, Length: " + notesA.Count);
             *  _beatmapObjectManager.DissolveAllObjects(noteA);
             * }
             *
             * var notesB = _noteBPool.activeItems.ToList();
             * foreach (var noteB in notesB)
             * {
             *  _beatmapObjectManager.Despawn(noteB);
             * }
             *
             * var bombs = _bombNotePool.activeItems.ToList();
             * foreach (var bomb in bombs)
             * {
             *  _beatmapObjectManager.Despawn(bomb);
             * }
             *
             * var obstacles = _obstaclePool.activeItems.ToList();
             * foreach (var obstacle in obstacles)
             * {
             *  _beatmapObjectManager.Despawn(obstacle);
             * }
             */

            Plugin.AudioTimeSync.SetPrivateField("_prevAudioSamplePos", -1);
            Plugin.AudioTimeSync.SetPrivateField("_songTime", newSongTime);
            _noteCutSoundEffectManager.SetPrivateField("_prevNoteATime", -1);
            _noteCutSoundEffectManager.SetPrivateField("_prevNoteBTime", -1);
        }