make certain uses of the beat never go below 0
fix loop of superb music
This commit is contained in:
parent
aed594b427
commit
3f6fef7c9b
Binary file not shown.
|
|
@ -86,6 +86,6 @@ Material:
|
|||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _ColorAlpha: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _ColorBravo: {r: 1, g: 0, b: 0, a: 1}
|
||||
- _ColorDelta: {r: 0.7647867, g: 0.7568468, b: 0.8092505, a: 1}
|
||||
- _ColorDelta: {r: 0.82210875, g: 0.6714016, b: 0.7016807, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
|
|
|
|||
|
|
@ -444,32 +444,27 @@ namespace HeavenStudio
|
|||
return result;
|
||||
}
|
||||
|
||||
public float GetLoopPositionFromBeat(float beatOffset, float length)
|
||||
public float GetLoopPositionFromBeat(float beatOffset, float length, bool beatClamp = true)
|
||||
{
|
||||
return Mathf.Repeat((songPositionInBeats / length) + beatOffset, 1);
|
||||
float beat = songPositionInBeats;
|
||||
if (beatClamp)
|
||||
{
|
||||
beat = Mathf.Max(beat, 0);
|
||||
}
|
||||
return Mathf.Repeat((beat / length) + beatOffset, 1);
|
||||
}
|
||||
|
||||
public float GetPositionFromBeat(double startBeat, double length)
|
||||
public float GetPositionFromBeat(double startBeat, double length, bool beatClamp = true)
|
||||
{
|
||||
float a = Mathp.Normalize(songPositionInBeats, (float)startBeat, (float)(startBeat + length));
|
||||
float beat = songPositionInBeats;
|
||||
if (beatClamp)
|
||||
{
|
||||
beat = Mathf.Max(beat, 0);
|
||||
}
|
||||
float a = Mathp.Normalize(beat, (float)startBeat, (float)(startBeat + length));
|
||||
return a;
|
||||
}
|
||||
|
||||
public float GetBeatFromPosition(float position, float startBeat, float length)
|
||||
{
|
||||
return Mathp.DeNormalize(position, (float)startBeat, (float)(startBeat + length));
|
||||
}
|
||||
|
||||
public float GetPositionFromMargin(float targetBeat, float margin)
|
||||
{
|
||||
return GetPositionFromBeat(targetBeat - margin, margin);
|
||||
}
|
||||
|
||||
public float GetBeatFromPositionAndMargin(float position, float targetBeat, float margin)
|
||||
{
|
||||
return GetBeatFromPosition(position, targetBeat - margin, margin);
|
||||
}
|
||||
|
||||
private List<RiqEntity> GetSortedTempoChanges()
|
||||
{
|
||||
GameManager.instance.SortEventsList();
|
||||
|
|
|
|||
|
|
@ -481,10 +481,11 @@ namespace HeavenStudio
|
|||
if (!Conductor.instance.isPlaying)
|
||||
return;
|
||||
Conductor cond = Conductor.instance;
|
||||
double beat = Math.Max(cond.songPositionInBeatsAsDouble, 0);
|
||||
|
||||
if (currentTempoEvent < Beatmap.TempoChanges.Count && currentTempoEvent >= 0)
|
||||
{
|
||||
if (cond.songPositionInBeatsAsDouble >= tempoBeats[currentTempoEvent])
|
||||
if (beat >= tempoBeats[currentTempoEvent])
|
||||
{
|
||||
cond.SetBpm(Beatmap.TempoChanges[currentTempoEvent]["tempo"]);
|
||||
currentTempoEvent++;
|
||||
|
|
@ -493,7 +494,7 @@ namespace HeavenStudio
|
|||
|
||||
if (currentVolumeEvent < Beatmap.VolumeChanges.Count && currentVolumeEvent >= 0)
|
||||
{
|
||||
if (cond.songPositionInBeatsAsDouble >= volumeBeats[currentVolumeEvent])
|
||||
if (beat >= volumeBeats[currentVolumeEvent])
|
||||
{
|
||||
cond.SetVolume(Beatmap.VolumeChanges[currentVolumeEvent]["volume"]);
|
||||
currentVolumeEvent++;
|
||||
|
|
@ -502,7 +503,7 @@ namespace HeavenStudio
|
|||
|
||||
if (currentSectionEvent < Beatmap.SectionMarkers.Count && currentSectionEvent >= 0)
|
||||
{
|
||||
if (cond.songPositionInBeatsAsDouble >= sectionBeats[currentSectionEvent])
|
||||
if (beat >= sectionBeats[currentSectionEvent])
|
||||
{
|
||||
Debug.Log("Section " + Beatmap.SectionMarkers[currentSectionEvent]["sectionName"] + " started");
|
||||
lastSection = currentSection;
|
||||
|
|
@ -519,7 +520,7 @@ namespace HeavenStudio
|
|||
}
|
||||
}
|
||||
|
||||
if (cond.songPositionInBeatsAsDouble >= Math.Ceiling(_playStartBeat) + _pulseTally)
|
||||
if (beat >= Math.Ceiling(_playStartBeat) + _pulseTally)
|
||||
{
|
||||
if (_currentMinigame != null) _currentMinigame.OnBeatPulse(Math.Ceiling(_playStartBeat) + _pulseTally);
|
||||
onBeatPulse?.Invoke(Math.Ceiling(_playStartBeat) + _pulseTally);
|
||||
|
|
@ -528,12 +529,12 @@ namespace HeavenStudio
|
|||
|
||||
float seekTime = 8f;
|
||||
//seek ahead to preload games that have assetbundles
|
||||
SeekAheadAndPreload(cond.songPositionInBeatsAsDouble, seekTime);
|
||||
SeekAheadAndDoPreEvent(cond.songPositionInBeatsAsDouble);
|
||||
SeekAheadAndPreload(beat, seekTime);
|
||||
SeekAheadAndDoPreEvent(beat);
|
||||
|
||||
if (currentEvent < Beatmap.Entities.Count && currentEvent >= 0)
|
||||
{
|
||||
if (cond.songPositionInBeatsAsDouble >= eventBeats[currentEvent])
|
||||
if (beat >= eventBeats[currentEvent])
|
||||
{
|
||||
List<RiqEntity> entitiesAtSameBeat = ListPool<RiqEntity>.Get();
|
||||
List<RiqEntity> fxEntities = ListPool<RiqEntity>.Get();
|
||||
|
|
@ -975,7 +976,7 @@ namespace HeavenStudio
|
|||
if (miniGame != null)
|
||||
miniGame.OnGameSwitch(beat);
|
||||
|
||||
while (beat + 0.25 > Conductor.instance.songPositionInBeats)
|
||||
while (beat + 0.25 > Math.Max(Conductor.instance.songPositionInBeatsAsDouble, 0))
|
||||
{
|
||||
if (!Conductor.instance.isPlaying)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ namespace HeavenStudio.Games.Global
|
|||
|
||||
private void Update()
|
||||
{
|
||||
var songPosBeat = Conductor.instance.songPositionInBeatsAsDouble;
|
||||
var songPosBeat = Math.Max(Conductor.instance.songPositionInBeatsAsDouble, 0);
|
||||
|
||||
foreach (var e in allFilterEvents)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -100,9 +100,8 @@ namespace HeavenStudio.Games.Global
|
|||
|
||||
private void Update()
|
||||
{
|
||||
FindFadeFromBeat(Conductor.instance.songPositionInBeatsAsDouble);
|
||||
FindFadeFromBeat(Math.Max(Conductor.instance.songPositionInBeatsAsDouble, 0));
|
||||
float normalizedBeat = Conductor.instance.GetPositionFromBeat(startBeat, length);
|
||||
// normalizedBeat = Mathf.Clamp01(normalizedBeat);
|
||||
|
||||
currentCol = new Color(func(startColor.r, endColor.r, normalizedBeat), func(startColor.g, endColor.g, normalizedBeat), func(startColor.b, endColor.b, normalizedBeat), func(startColor.a, endColor.a, normalizedBeat));
|
||||
spriteRenderer.color = currentCol;
|
||||
|
|
|
|||
|
|
@ -61,9 +61,9 @@ namespace HeavenStudio.Common
|
|||
currentBlink++;
|
||||
}
|
||||
}
|
||||
else if (cond.songPositionInBeats < lastReportedBeat)
|
||||
else if (cond.songPositionInBeatsAsDouble < lastReportedBeat)
|
||||
{
|
||||
lastReportedBeat = Mathf.Round(cond.songPositionInBeats);
|
||||
lastReportedBeat = System.Math.Round(cond.songPositionInBeatsAsDouble);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ namespace HeavenStudio.Common
|
|||
isPaused = true;
|
||||
canPick = false;
|
||||
optionSelected = 0;
|
||||
ChooseOption((Options)optionSelected, false);
|
||||
}
|
||||
|
||||
void UnPause(bool instant = false)
|
||||
|
|
|
|||
Loading…
Reference in a new issue