Tidy up kiai time access

This commit is contained in:
Dean Herbert 2022-08-02 18:18:40 +09:00
parent cc4cde2c79
commit 258ad7c6b9
4 changed files with 16 additions and 12 deletions

View File

@ -21,6 +21,11 @@ namespace osu.Game.Beatmaps
/// </summary>
public bool BeatSyncAvailable => Clock != null;
/// <summary>
/// Whether the beat sync provider is currently in a kiai section. Should make everything more epic.
/// </summary>
public bool IsKiaiTime => Clock != null && (ControlPoints?.EffectPointAt(Clock.CurrentTime).KiaiMode ?? false);
/// <summary>
/// Access any available control points from a beatmap providing beat sync. If <c>null</c>, no current provider is available.
/// </summary>

View File

@ -26,8 +26,10 @@ namespace osu.Game.Graphics.Containers
{
private int lastBeat;
protected TimingControlPoint? LastTimingPoint { get; private set; }
protected EffectControlPoint? LastEffectPoint { get; private set; }
private TimingControlPoint? lastTimingPoint { get; set; }
private EffectControlPoint? lastEffectPoint { get; set; }
public bool IsKiaiTime { get; private set; }
/// <summary>
/// The amount of time before a beat we should fire <see cref="OnNewBeat(int, TimingControlPoint, EffectControlPoint, ChannelAmplitudes)"/>.
@ -125,7 +127,7 @@ namespace osu.Game.Graphics.Containers
TimeSinceLastBeat = beatLength - TimeUntilNextBeat;
if (ReferenceEquals(timingPoint, LastTimingPoint) && beatIndex == lastBeat)
if (ReferenceEquals(timingPoint, lastTimingPoint) && beatIndex == lastBeat)
return;
// as this event is sometimes used for sound triggers where `BeginDelayedSequence` has no effect, avoid firing it if too far away from the beat.
@ -137,8 +139,10 @@ namespace osu.Game.Graphics.Containers
}
lastBeat = beatIndex;
LastTimingPoint = timingPoint;
LastEffectPoint = effectPoint;
lastTimingPoint = timingPoint;
lastEffectPoint = effectPoint;
IsKiaiTime = lastEffectPoint?.KiaiMode ?? false;
}
}
}

View File

@ -100,23 +100,18 @@ namespace osu.Game.Screens.Menu
private void updateAmplitudes()
{
bool isKiaiTime = false;
for (int i = 0; i < temporalAmplitudes.Length; i++)
temporalAmplitudes[i] = 0;
if (beatSyncProvider.Clock != null)
{
isKiaiTime = beatSyncProvider.ControlPoints?.EffectPointAt(beatSyncProvider.Clock.CurrentTime).KiaiMode ?? false;
addAmplitudesFromSource(beatSyncProvider);
}
foreach (var source in amplitudeSources)
addAmplitudesFromSource(source);
for (int i = 0; i < bars_per_visualiser; i++)
{
float targetAmplitude = (temporalAmplitudes[(i + indexOffset) % bars_per_visualiser]) * (isKiaiTime ? 1 : 0.5f);
float targetAmplitude = (temporalAmplitudes[(i + indexOffset) % bars_per_visualiser]) * (beatSyncProvider.IsKiaiTime ? 1 : 0.5f);
if (targetAmplitude > frequencyAmplitudes[i])
frequencyAmplitudes[i] = targetAmplitude;
}

View File

@ -353,7 +353,7 @@ namespace osu.Game.Screens.Menu
float maxAmplitude = lastBeatIndex >= 0 ? musicController.CurrentTrack.CurrentAmplitudes.Maximum : 0;
logoAmplitudeContainer.Scale = new Vector2((float)Interpolation.Damp(logoAmplitudeContainer.Scale.X, 1 - Math.Max(0, maxAmplitude - scale_adjust_cutoff) * 0.04f, 0.9f, Time.Elapsed));
triangles.Velocity = (float)Interpolation.Damp(triangles.Velocity, triangles_paused_velocity * (LastEffectPoint.KiaiMode ? 4 : 2), 0.995f, Time.Elapsed);
triangles.Velocity = (float)Interpolation.Damp(triangles.Velocity, triangles_paused_velocity * (IsKiaiTime ? 4 : 2), 0.995f, Time.Elapsed);
}
else
{