mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-10 03:35:10 +00:00
Better timeline handling for song offset
This commit is contained in:
parent
e5e25fa2ab
commit
47a9c807bb
1 changed files with 45 additions and 3 deletions
|
@ -79,8 +79,24 @@ namespace RhythmHeavenMania
|
|||
|
||||
public void Play(float beat)
|
||||
{
|
||||
bool negativeOffset = firstBeatOffset < 0f;
|
||||
bool negativeStartTime = false;
|
||||
|
||||
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;
|
||||
|
||||
isPlaying = true;
|
||||
|
@ -88,8 +104,34 @@ namespace RhythmHeavenMania
|
|||
|
||||
if (SongPosLessThanClipLength(startPos))
|
||||
{
|
||||
musicSource.time = startPos;
|
||||
musicSource.PlayScheduled(AudioSettings.dspTime);
|
||||
if (negativeOffset)
|
||||
{
|
||||
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);
|
||||
|
|
Loading…
Reference in a new issue