public void Init(OnlinePlayerController newOwner, OnlineAudioTimeController onlineSyncController) { BeatmapObjectCallbackController original = FindObjectsOfType <BeatmapObjectCallbackController>().First(x => !(x is OnlineBeatmapCallbackController)); transform.position = original.transform.position; owner = newOwner; _audioTimeSource = onlineSyncController; _initData = original.GetPrivateField <InitData>("_initData"); _beatmapData = original.GetPrivateField <BeatmapData>("_beatmapData"); }
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); }