예제 #1
0
    public float GetSecondsFromBeat(float beat)
    {
        //return (60 / bpmchanges.lastBPM) * beat;
        if (bpmchanges.LoadedContainers.Count == 0 || beat <= bpmchanges.LoadedContainers[0].objectData._time)
        {
            return(60 / song.beatsPerMinute * beat);
        }
        float totalSeconds       = 60 / song.beatsPerMinute * bpmchanges.LoadedContainers[0].objectData._time;
        int   lastBPMChangeIndex = 0;

        if (bpmchanges.LoadedContainers.Count >= 2)
        {
            for (int i = 0; i < bpmchanges.LoadedContainers.Count - 1; i++)
            {
                BeatmapBPMChangeContainer change = bpmchanges.LoadedContainers[i + 1] as BeatmapBPMChangeContainer;
                float distance = bpmchanges.LoadedContainers[i + 1].objectData._time - bpmchanges.LoadedContainers[i].objectData._time;
                if (i >= bpmchanges.lastCheckedBPMIndex)
                {
                    break;
                }
                totalSeconds += (60 / change.bpmData._BPM) * distance;
                lastBPMChangeIndex++;
            }
        }
        BeatmapBPMChangeContainer lastChange = bpmchanges.LoadedContainers[lastBPMChangeIndex] as BeatmapBPMChangeContainer;

        totalSeconds += (60 / lastChange.bpmData._BPM) *
                        (beat - bpmchanges.LoadedContainers[lastBPMChangeIndex].objectData._time);
        return(totalSeconds);
    }
예제 #2
0
 public override void SortObjects()
 {
     float[] bpmChangeTimes = new float[ShaderArrayMaxSize];
     float[] bpmChangeBPMS  = new float[ShaderArrayMaxSize];
     bpmChangeTimes[0] = 0;
     bpmChangeBPMS[0]  = BeatSaberSongContainer.Instance.song.beatsPerMinute;
     LoadedContainers  = LoadedContainers.OrderBy(x => x.objectData._time).ToList();
     for (int i = 0; i < LoadedContainers.Count; i++)
     {
         if (i >= ShaderArrayMaxSize - 1)
         {
             Debug.LogError($":hyperPepega: :mega: THE CAP FOR BPM CHANGES IS {ShaderArrayMaxSize - 1}, WHY TF DO YOU HAVE THIS MANY BPM CHANGES!?!?");
             break;
         }
         BeatmapBPMChangeContainer con = LoadedContainers[i] as BeatmapBPMChangeContainer;
         con.UpdateGridPosition();
         BeatmapBPMChange bpmChange = con.objectData as BeatmapBPMChange;
         bpmChangeTimes[i + 1] = bpmChange._time;
         bpmChangeBPMS[i + 1]  = bpmChange._BPM;
     }
     foreach (Renderer renderer in allGridRenderers)
     {
         renderer.material.SetFloatArray(Times, bpmChangeTimes);
         renderer.material.SetFloatArray(BPMs, bpmChangeBPMS);
         renderer.material.SetInt(BPMCount, LoadedContainers.Count + 1);
     }
     measureLinesController.RefreshMeasureLines();
 }
예제 #3
0
    public float GetBeatFromSeconds(float seconds)
    {
        //return (bpmchanges.FindLastBPM(seconds) / 60) * seconds;
        float unmodifiedBeatTime = song.beatsPerMinute / 60 * seconds;

        bpmchanges.FindLastBPM(unmodifiedBeatTime, out int lastBPMChangeIndex);
        if (bpmchanges.LoadedContainers.Count == 0 || lastBPMChangeIndex == 0)
        {
            return(unmodifiedBeatTime);
        }
        float totalBeat = bpmchanges.LoadedContainers[0].objectData._time;

        if (bpmchanges.LoadedContainers.Count >= 2)
        {
            for (int i = 0; i < bpmchanges.LoadedContainers.Count - 1; i++)
            {
                BeatmapBPMChangeContainer change = bpmchanges.LoadedContainers[i + 1] as BeatmapBPMChangeContainer;
                if (i >= lastBPMChangeIndex)
                {
                    break;
                }
                float distance = change.bpmData._time - (bpmchanges.LoadedContainers[i] as BeatmapBPMChangeContainer).bpmData._time;
                totalBeat += (60 / song.beatsPerMinute * distance) * (change.bpmData._BPM / 60);
            }
        }
        BeatmapBPMChangeContainer lastChange = bpmchanges.LoadedContainers[lastBPMChangeIndex] as BeatmapBPMChangeContainer;

        totalBeat += (seconds - (60 / song.beatsPerMinute * bpmchanges.LoadedContainers[lastBPMChangeIndex].objectData._time)) *
                     (lastChange.bpmData._BPM / 60);
        return(totalBeat);
    }
    public static BeatmapBPMChangeContainer SpawnBPMChange(BeatmapBPMChange data, ref GameObject prefab)
    {
        BeatmapBPMChangeContainer container = Instantiate(prefab).GetComponent <BeatmapBPMChangeContainer>();

        container.bpmData = data;
        container.GetComponentInChildren <TextMeshProUGUI>().text = data._BPM.ToString();
        return(container);
    }
예제 #5
0
    public override BeatmapObjectContainer SpawnObject(BeatmapObject obj)
    {
        BeatmapBPMChangeContainer beatmapBPMChange = BeatmapBPMChangeContainer.SpawnBPMChange(obj as BeatmapBPMChange, ref bpmPrefab);

        beatmapBPMChange.transform.SetParent(GridTransform);
        beatmapBPMChange.UpdateGridPosition();
        LoadedContainers.Add(beatmapBPMChange);
        return(beatmapBPMChange);
    }
예제 #6
0
    public override BeatmapObjectContainer SpawnObject(BeatmapObject obj, out BeatmapObjectContainer conflicting, bool removeConflicting = true)
    {
        conflicting = null;
        BeatmapBPMChangeContainer beatmapBPMChange = BeatmapBPMChangeContainer.SpawnBPMChange(obj as BeatmapBPMChange, ref bpmPrefab);

        beatmapBPMChange.transform.SetParent(GridTransform);
        beatmapBPMChange.UpdateGridPosition();
        LoadedContainers.Add(beatmapBPMChange);
        SelectionController.RefreshMap();
        return(beatmapBPMChange);
    }
예제 #7
0
    public override BeatmapObjectContainer SpawnObject(BeatmapObject obj, out BeatmapObjectContainer conflicting, bool removeConflicting = true, bool refreshMap = true)
    {
        if (LoadedContainers.Count >= ShaderArrayMaxSize)
        {
            Debug.LogError("Something's wrong, I can feel it!\nMore BPM Changes are present then what Unity shaders allow!");
        }
        conflicting = null;
        BeatmapBPMChangeContainer beatmapBPMChange = BeatmapBPMChangeContainer.SpawnBPMChange(obj as BeatmapBPMChange, ref bpmPrefab);

        beatmapBPMChange.transform.SetParent(GridTransform);
        beatmapBPMChange.UpdateGridPosition();
        LoadedContainers.Add(beatmapBPMChange);
        if (refreshMap)
        {
            SelectionController.RefreshMap();
        }
        return(beatmapBPMChange);
    }
예제 #8
0
    protected override void UpdateContainerData(BeatmapObjectContainer con, BeatmapObject obj)
    {
        BeatmapBPMChangeContainer container = con as BeatmapBPMChangeContainer;

        container.UpdateBPMText();
    }
예제 #9
0
 public override BeatmapObjectContainer CreateContainer() => BeatmapBPMChangeContainer.SpawnBPMChange(null, ref bpmPrefab);