mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 19:12:56 +08:00
Convert interface methods to extension methods
This commit is contained in:
parent
16ff8d5c38
commit
a32149fda1
18
osu.Game/Beatmaps/BeatSyncProviderExtensions.cs
Normal file
18
osu.Game/Beatmaps/BeatSyncProviderExtensions.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
namespace osu.Game.Beatmaps
|
||||||
|
{
|
||||||
|
public static class BeatSyncProviderExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Check whether beat sync is currently available.
|
||||||
|
/// </summary>
|
||||||
|
public static bool CheckBeatSyncAvailable(this IBeatSyncProvider provider) => provider.Clock != null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the beat sync provider is currently in a kiai section. Should make everything more epic.
|
||||||
|
/// </summary>
|
||||||
|
public static bool CheckIsKiaiTime(this IBeatSyncProvider provider) => provider.Clock != null && (provider.ControlPoints?.EffectPointAt(provider.Clock.CurrentTime).KiaiMode ?? false);
|
||||||
|
}
|
||||||
|
}
|
@ -16,16 +16,6 @@ namespace osu.Game.Beatmaps
|
|||||||
[Cached]
|
[Cached]
|
||||||
public interface IBeatSyncProvider : IHasAmplitudes
|
public interface IBeatSyncProvider : IHasAmplitudes
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Check whether beat sync is currently available.
|
|
||||||
/// </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>
|
/// <summary>
|
||||||
/// Access any available control points from a beatmap providing beat sync. If <c>null</c>, no current provider is available.
|
/// Access any available control points from a beatmap providing beat sync. If <c>null</c>, no current provider is available.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -27,7 +27,6 @@ namespace osu.Game.Graphics.Containers
|
|||||||
private int lastBeat;
|
private int lastBeat;
|
||||||
|
|
||||||
private TimingControlPoint? lastTimingPoint { get; set; }
|
private TimingControlPoint? lastTimingPoint { get; set; }
|
||||||
private EffectControlPoint? lastEffectPoint { get; set; }
|
|
||||||
|
|
||||||
protected bool IsKiaiTime { get; private set; }
|
protected bool IsKiaiTime { get; private set; }
|
||||||
|
|
||||||
@ -87,7 +86,7 @@ namespace osu.Game.Graphics.Containers
|
|||||||
TimingControlPoint timingPoint;
|
TimingControlPoint timingPoint;
|
||||||
EffectControlPoint effectPoint;
|
EffectControlPoint effectPoint;
|
||||||
|
|
||||||
IsBeatSyncedWithTrack = BeatSyncSource.BeatSyncAvailable && BeatSyncSource.Clock?.IsRunning == true;
|
IsBeatSyncedWithTrack = BeatSyncSource.CheckBeatSyncAvailable() && BeatSyncSource.Clock?.IsRunning == true;
|
||||||
|
|
||||||
double currentTrackTime;
|
double currentTrackTime;
|
||||||
|
|
||||||
@ -140,9 +139,8 @@ namespace osu.Game.Graphics.Containers
|
|||||||
|
|
||||||
lastBeat = beatIndex;
|
lastBeat = beatIndex;
|
||||||
lastTimingPoint = timingPoint;
|
lastTimingPoint = timingPoint;
|
||||||
lastEffectPoint = effectPoint;
|
|
||||||
|
|
||||||
IsKiaiTime = effectPoint?.KiaiMode ?? false;
|
IsKiaiTime = effectPoint.KiaiMode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
|
|
||||||
for (int i = 0; i < bars_per_visualiser; i++)
|
for (int i = 0; i < bars_per_visualiser; i++)
|
||||||
{
|
{
|
||||||
float targetAmplitude = (temporalAmplitudes[(i + indexOffset) % bars_per_visualiser]) * (beatSyncProvider.IsKiaiTime ? 1 : 0.5f);
|
float targetAmplitude = (temporalAmplitudes[(i + indexOffset) % bars_per_visualiser]) * (beatSyncProvider.CheckIsKiaiTime() ? 1 : 0.5f);
|
||||||
if (targetAmplitude > frequencyAmplitudes[i])
|
if (targetAmplitude > frequencyAmplitudes[i])
|
||||||
frequencyAmplitudes[i] = targetAmplitude;
|
frequencyAmplitudes[i] = targetAmplitude;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user