Conductor: refactor ReportBeat
this fixes issues with using crop stomp alongside tempo changes
This commit is contained in:
parent
c5e0f53c4a
commit
ecb7b3d16e
|
@ -189,23 +189,20 @@ namespace HeavenStudio
|
||||||
{
|
{
|
||||||
Util.Jukebox.PlayOneShot("metronome");
|
Util.Jukebox.PlayOneShot("metronome");
|
||||||
}
|
}
|
||||||
else if (songPosition <= lastReportedBeat)
|
else if (songPositionInBeats < lastReportedBeat)
|
||||||
{
|
{
|
||||||
lastReportedBeat = (songPosition - (songPosition % secPerBeat));
|
lastReportedBeat = Mathf.Round(songPositionInBeats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ReportBeat(ref float lastReportedBeat, float offset = 0, bool shiftBeatToOffset = false)
|
public bool ReportBeat(ref float lastReportedBeat, float offset = 0, bool shiftBeatToOffset = true)
|
||||||
{
|
{
|
||||||
bool result = songPosition > (lastReportedBeat + offset) + secPerBeat;
|
bool result = songPositionInBeats + (shiftBeatToOffset ? offset : 0f) >= (lastReportedBeat) + 1f;
|
||||||
if (result == true)
|
if (result)
|
||||||
{
|
{
|
||||||
lastReportedBeat = (songPosition - (songPosition % secPerBeat));
|
lastReportedBeat += 1f;
|
||||||
|
|
||||||
if (!shiftBeatToOffset)
|
|
||||||
lastReportedBeat += offset;
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,6 +159,18 @@ namespace HeavenStudio
|
||||||
List<float> entities = Beatmap.entities.Select(c => c.beat).ToList();
|
List<float> entities = Beatmap.entities.Select(c => c.beat).ToList();
|
||||||
List<float> tempoChanges = Beatmap.tempoChanges.Select(c => c.beat).ToList();
|
List<float> tempoChanges = Beatmap.tempoChanges.Select(c => c.beat).ToList();
|
||||||
|
|
||||||
|
if (currentTempoEvent < Beatmap.tempoChanges.Count && currentTempoEvent >= 0)
|
||||||
|
{
|
||||||
|
// Debug.Log("Checking Tempo Change at " + tempoChanges[currentTempoEvent] + ", current beat " + Conductor.instance.songPositionInBeats);
|
||||||
|
if (Conductor.instance.songPositionInBeats >= tempoChanges[currentTempoEvent])
|
||||||
|
{
|
||||||
|
// Debug.Log("Tempo Change at " + Conductor.instance.songPositionInBeats + " of bpm " + Beatmap.tempoChanges[currentTempoEvent].tempo);
|
||||||
|
Conductor.instance.SetBpm(Beatmap.tempoChanges[currentTempoEvent].tempo);
|
||||||
|
Conductor.instance.timeSinceLastTempoChange = Time.time;
|
||||||
|
currentTempoEvent++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (currentEvent < Beatmap.entities.Count && currentEvent >= 0)
|
if (currentEvent < Beatmap.entities.Count && currentEvent >= 0)
|
||||||
{
|
{
|
||||||
if (Conductor.instance.songPositionInBeats >= entities[currentEvent] /*&& SongPosLessThanClipLength(Conductor.instance.songPositionInBeats)*/)
|
if (Conductor.instance.songPositionInBeats >= entities[currentEvent] /*&& SongPosLessThanClipLength(Conductor.instance.songPositionInBeats)*/)
|
||||||
|
@ -194,18 +206,6 @@ namespace HeavenStudio
|
||||||
// currentEvent += gameManagerEntities.Count;
|
// currentEvent += gameManagerEntities.Count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentTempoEvent < Beatmap.tempoChanges.Count && currentTempoEvent >= 0)
|
|
||||||
{
|
|
||||||
// Debug.Log("Checking Tempo Change at " + tempoChanges[currentTempoEvent] + ", current beat " + Conductor.instance.songPositionInBeats);
|
|
||||||
if (Conductor.instance.songPositionInBeats >= tempoChanges[currentTempoEvent])
|
|
||||||
{
|
|
||||||
// Debug.Log("Tempo Change at " + Conductor.instance.songPositionInBeats + " of bpm " + Beatmap.tempoChanges[currentTempoEvent].tempo);
|
|
||||||
Conductor.instance.SetBpm(Beatmap.tempoChanges[currentTempoEvent].tempo);
|
|
||||||
Conductor.instance.timeSinceLastTempoChange = Time.time;
|
|
||||||
currentTempoEvent++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ToggleInputs(bool inputs)
|
public void ToggleInputs(bool inputs)
|
||||||
|
|
|
@ -270,7 +270,7 @@ namespace HeavenStudio.Games
|
||||||
public void StartMarching(float beat)
|
public void StartMarching(float beat)
|
||||||
{
|
{
|
||||||
marchStartBeat = beat;
|
marchStartBeat = beat;
|
||||||
marchOffset = (marchStartBeat % 1) * Conductor.instance.secPerBeat / Conductor.instance.musicSource.pitch;
|
marchOffset = marchStartBeat % 1;
|
||||||
currentMarchBeat = 0;
|
currentMarchBeat = 0;
|
||||||
stepCount = 0;
|
stepCount = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue