Example #1
0
    private IEnumerator DelayedUpdate()
    {
        while (true)
        {
            yield return(new WaitForSeconds(1)); //I wouldn't want to update this every single frame.

            List <BeatmapObjectContainer> sel = SelectionController.SelectedObjects.OrderBy(x => x.objectData._time).ToList();
            int notesel = SelectionController.SelectedObjects.Where(x => x is BeatmapNoteContainer).Count(); // only active when notes are selected
            if (SelectionController.HasSelectedObjects() && notesel > 0)
            {
                notesMesh.text = $"Selected Notes: {notesel}";
                float beatTimeDiff = sel.Last().objectData._time - sel.First().objectData._time;
                float secDiff      = atsc.GetSecondsFromBeat(beatTimeDiff);
                notesPSMesh.text = $"Selected NPS: {(notesel / secDiff).ToString("F2")}";
            }
            else
            {
                notesMesh.text   = $"Notes: {notes.LoadedContainers.Count}";
                notesPSMesh.text = $"Notes Per Second: {(notes.LoadedContainers.Count / cameraAudioSource.clip.length).ToString("F2")}";
            }
            obstaclesMesh.text = $"Obstacles: {obstacles.LoadedContainers.Count}";
            eventsMesh.text    = $"Events: {events.LoadedContainers.Count}";
            bpmMesh.text       = $"BPM Changes: {bpm.LoadedContainers.Count}";

            float timeMapping = BeatSaberSongContainer.Instance.map._time;
            int   seconds     = Mathf.Abs(Mathf.FloorToInt(timeMapping * 60 % 60));
            int   minutes     = Mathf.FloorToInt(timeMapping % 60);
            int   hours       = Mathf.FloorToInt(timeMapping / 60);
            timeMappingMesh.text = string.Format("Time Mapping: {0:0}:{1:00}:{2:00}", hours, minutes, seconds);
        }
    }
    private IEnumerator DelayedUpdate()
    {
        while (true)
        {
            yield return(new WaitForSeconds(1)); //I wouldn't want to update this every single frame.

            List <BeatmapObjectContainer> sel = SelectionController.SelectedObjects.OrderBy(x => x.objectData._time).ToList();
            int notesel = SelectionController.SelectedObjects.Where(x => x is BeatmapNoteContainer).Count(); // only active when notes are selected
            if (SelectionController.HasSelectedObjects() && notesel > 0)
            {
                notesMesh.text = $"Selected Notes: {notesel}";
                float beatTimeDiff = sel.Last().objectData._time - sel.First().objectData._time;
                float secDiff      = atsc.GetSecondsFromBeat(beatTimeDiff);
                notesPSMesh.text = $"Selected NPS: {(notesel / secDiff).ToString("F2")}";
            }
            else
            {
                notesMesh.text   = $"Notes: {notes.LoadedContainers.Count}";
                notesPSMesh.text = $"Notes Per Second: {(notes.LoadedContainers.Count / cameraAudioSource.clip.length).ToString("F2")}";
            }
            obstaclesMesh.text = $"Obstacles: {obstacles.LoadedContainers.Count}";
            eventsMesh.text    = $"Events: {events.LoadedContainers.Count}";
            bpmMesh.text       = $"BPM Changes: {bpm.LoadedContainers.Count}";
        }
    }
 private void Start()
 { 
     secondPerChunk = atsc.GetSecondsFromBeat(BeatmapObjectContainerCollection.ChunkSize);
     spectroParent.position = new Vector3(spectroParent.position.x, 0, -atsc.offsetBeat * EditorScaleController.EditorScale * 2);
     if (Settings.Instance.WaveformGenerator) StartCoroutine(GenerateAllWaveforms());
     else gameObject.SetActive(false);
 }
 private void Start()
 {
     WaveformType = Settings.Instance.Waveform;
     waveformData = new WaveformData();
     audioManager.SetSecondPerChunk(atsc.GetSecondsFromBeat(BeatmapObjectContainerCollection.ChunkSize));
     spectroParent.localPosition = new Vector3(0, 0, -atsc.offsetBeat * EditorScaleController.EditorScale * 2);
     if (WaveformType > 0)
     {
         StartCoroutine(GenerateAllWaveforms());
     }
     else
     {
         gameObject.SetActive(false);
     }
 }
Example #5
0
    void PlaySound(bool initial, int index, BeatmapObject objectData)
    {
        // Filter notes that are too far behind the current beat
        // (Commonly occurs when Unity freezes for some unrelated f*****g reason)
        if (objectData._time - container.AudioTimeSyncController.CurrentBeat <= -0.5f)
        {
            return;
        }

        //actual ding stuff
        if (objectData._time == lastCheckedTime || !NoteTypeToDing[((BeatmapNote)objectData)._type])
        {
            return;
        }

        /*
         * As for why we are not using "initial", it is so notes that are not supposed to ding do not prevent notes at
         * the same time that are supposed to ding from triggering the sound effects.
         */
        lastCheckedTime = objectData._time;
        var soundListId = Settings.Instance.NoteHitSound;
        var list        = soundLists[soundListId];

        var shortCut = false;

        if (index - DensityCheckOffset > 0 && index + DensityCheckOffset < container.LoadedObjects.Count)
        {
            BeatmapObject first  = container.LoadedObjects.ElementAt(index + DensityCheckOffset);
            BeatmapObject second = container.LoadedObjects.ElementAt(index - DensityCheckOffset);
            if (first != null && second != null)
            {
                if (first._time - objectData._time <= ThresholdInNoteTime && objectData._time - second._time <= ThresholdInNoteTime)
                {
                    shortCut = true;
                }
            }
        }

        var timeUntilDing = objectData._time - atsc.GetBeatFromSeconds(atsc.songAudioSource.time);
        var hitTime       = (atsc.GetSecondsFromBeat(timeUntilDing) / songSpeed) - offset;

        audioUtil.PlayOneShotSound(list.GetRandomClip(shortCut), Settings.Instance.NoteHitVolume, 1, hitTime);
    }