mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-13 13:57:43 +02:00
Better timeline handling for song offset
This commit is contained in:
@ -79,8 +79,24 @@ namespace RhythmHeavenMania
|
|||||||
|
|
||||||
public void Play(float beat)
|
public void Play(float beat)
|
||||||
{
|
{
|
||||||
|
bool negativeOffset = firstBeatOffset < 0f;
|
||||||
|
bool negativeStartTime = false;
|
||||||
|
|
||||||
var startPos = GetSongPosFromBeat(beat);
|
var startPos = GetSongPosFromBeat(beat);
|
||||||
this.time = startPos - firstBeatOffset;
|
if (negativeOffset)
|
||||||
|
{
|
||||||
|
time = startPos;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
negativeStartTime = startPos - firstBeatOffset < 0f;
|
||||||
|
|
||||||
|
if (negativeStartTime)
|
||||||
|
time = startPos - firstBeatOffset;
|
||||||
|
else
|
||||||
|
time = startPos;
|
||||||
|
}
|
||||||
|
|
||||||
songPosBeat = time / secPerBeat;
|
songPosBeat = time / secPerBeat;
|
||||||
|
|
||||||
isPlaying = true;
|
isPlaying = true;
|
||||||
@ -88,8 +104,34 @@ namespace RhythmHeavenMania
|
|||||||
|
|
||||||
if (SongPosLessThanClipLength(startPos))
|
if (SongPosLessThanClipLength(startPos))
|
||||||
{
|
{
|
||||||
musicSource.time = startPos;
|
if (negativeOffset)
|
||||||
musicSource.PlayScheduled(AudioSettings.dspTime);
|
{
|
||||||
|
var musicStartTime = startPos + firstBeatOffset;
|
||||||
|
|
||||||
|
if (musicStartTime < 0f)
|
||||||
|
{
|
||||||
|
musicSource.time = startPos;
|
||||||
|
musicSource.PlayScheduled(AudioSettings.dspTime - firstBeatOffset);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
musicSource.time = musicStartTime;
|
||||||
|
musicSource.PlayScheduled(AudioSettings.dspTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (negativeStartTime)
|
||||||
|
{
|
||||||
|
musicSource.time = startPos;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
musicSource.time = startPos + firstBeatOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
musicSource.PlayScheduled(AudioSettings.dspTime);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GameManager.instance.SetCurrentEventToClosest(songPositionInBeats);
|
// GameManager.instance.SetCurrentEventToClosest(songPositionInBeats);
|
||||||
|
Reference in New Issue
Block a user