mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-10 11:45:09 +00:00
BTSDS: Piano notes will now stop properly even if the game switches during them.
This commit is contained in:
parent
5a56ecf261
commit
84c4e8fc9f
3 changed files with 27 additions and 4 deletions
|
@ -190,10 +190,7 @@ namespace RhythmHeavenMania.Games.BuiltToScaleDS
|
|||
var pianoPitch = Mathf.Pow(2f, (1f / 12f) * semiTones) *Conductor.instance.musicSource.pitch;
|
||||
var pianoSource = Jukebox.PlayOneShotGame("builtToScaleDS/Piano", -1, pianoPitch, 0.8f, true);
|
||||
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat + length, delegate { Jukebox.KillLoop(pianoSource, 0.1f); })
|
||||
});
|
||||
Jukebox.SetLoopParams(pianoSource, beat + length, 0.1f);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -107,6 +107,17 @@ namespace RhythmHeavenMania.Util
|
|||
return null;
|
||||
}
|
||||
|
||||
// Loops play forever by default unless you set their params via this method.
|
||||
public static void SetLoopParams(AudioSource source, float endBeat, float fadeTime)
|
||||
{
|
||||
if (source == null)
|
||||
return;
|
||||
|
||||
var snd = source.GetComponent<Sound>();
|
||||
snd.loopEndBeat = endBeat;
|
||||
snd.fadeTime = fadeTime;
|
||||
}
|
||||
|
||||
public static void KillLoop(AudioSource source, float fadeTime)
|
||||
{
|
||||
// Safeguard against previously-destroyed sounds.
|
||||
|
|
|
@ -15,6 +15,9 @@ namespace RhythmHeavenMania.Util
|
|||
public double scheduledTime;
|
||||
|
||||
public bool looping;
|
||||
public float loopEndBeat = -1;
|
||||
public float fadeTime;
|
||||
int loopIndex = 0;
|
||||
|
||||
private AudioSource audioSource;
|
||||
|
||||
|
@ -73,6 +76,18 @@ namespace RhythmHeavenMania.Util
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (loopIndex < 1)
|
||||
{
|
||||
if (looping && loopEndBeat != -1)
|
||||
{
|
||||
if (Conductor.instance.songPositionInBeats > loopEndBeat)
|
||||
{
|
||||
KillLoop(fadeTime);
|
||||
loopIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator NotRelyOnBeatSound()
|
||||
|
|
Loading…
Reference in a new issue