1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-20 09:03:00 +08:00

Convert interface methods to extension methods

This commit is contained in:
Dean Herbert 2022-08-03 20:07:54 +09:00
parent 16ff8d5c38
commit a32149fda1
4 changed files with 21 additions and 15 deletions

View 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);
}
}

View File

@ -16,16 +16,6 @@ namespace osu.Game.Beatmaps
[Cached]
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>
/// Access any available control points from a beatmap providing beat sync. If <c>null</c>, no current provider is available.
/// </summary>

View File

@ -27,7 +27,6 @@ namespace osu.Game.Graphics.Containers
private int lastBeat;
private TimingControlPoint? lastTimingPoint { get; set; }
private EffectControlPoint? lastEffectPoint { get; set; }
protected bool IsKiaiTime { get; private set; }
@ -87,7 +86,7 @@ namespace osu.Game.Graphics.Containers
TimingControlPoint timingPoint;
EffectControlPoint effectPoint;
IsBeatSyncedWithTrack = BeatSyncSource.BeatSyncAvailable && BeatSyncSource.Clock?.IsRunning == true;
IsBeatSyncedWithTrack = BeatSyncSource.CheckBeatSyncAvailable() && BeatSyncSource.Clock?.IsRunning == true;
double currentTrackTime;
@ -140,9 +139,8 @@ namespace osu.Game.Graphics.Containers
lastBeat = beatIndex;
lastTimingPoint = timingPoint;
lastEffectPoint = effectPoint;
IsKiaiTime = effectPoint?.KiaiMode ?? false;
IsKiaiTime = effectPoint.KiaiMode;
}
}
}

View File

@ -111,7 +111,7 @@ namespace osu.Game.Screens.Menu
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])
frequencyAmplitudes[i] = targetAmplitude;
}