2021-10-15 06:30:55 +08:00
|
|
|
|
// 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.
|
|
|
|
|
|
2021-10-15 11:34:43 +08:00
|
|
|
|
using System;
|
2021-10-23 05:10:53 +08:00
|
|
|
|
using System.Linq;
|
2021-10-15 13:25:50 +08:00
|
|
|
|
using osu.Framework.Utils;
|
2021-10-23 05:10:53 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
|
using osu.Game.Rulesets.UI;
|
|
|
|
|
using osu.Game.Utils;
|
2021-10-15 06:30:55 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Mods
|
|
|
|
|
{
|
2021-11-09 22:11:19 +08:00
|
|
|
|
public class OsuModNoScope : ModNoScope, IUpdatableByPlayfield, IApplicableToBeatmap
|
2021-10-15 06:30:55 +08:00
|
|
|
|
{
|
|
|
|
|
public override string Description => "Where's the cursor?";
|
2021-10-15 13:25:50 +08:00
|
|
|
|
|
2021-10-23 05:10:53 +08:00
|
|
|
|
private PeriodTracker spinnerPeriods;
|
2021-10-15 06:30:55 +08:00
|
|
|
|
|
2021-10-23 05:10:53 +08:00
|
|
|
|
public void ApplyToBeatmap(IBeatmap beatmap)
|
|
|
|
|
{
|
2021-11-09 22:11:19 +08:00
|
|
|
|
spinnerPeriods = new PeriodTracker(beatmap.HitObjects.OfType<Spinner>().Select(b => new Period(b.StartTime - TRANSITION_DURATION, b.EndTime)));
|
2021-10-15 06:30:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual void Update(Playfield playfield)
|
|
|
|
|
{
|
2021-11-09 22:11:19 +08:00
|
|
|
|
bool shouldAlwaysShowCursor = IsBreakTime.Value || spinnerPeriods.IsInAny(playfield.Clock.CurrentTime);
|
|
|
|
|
float targetAlpha = shouldAlwaysShowCursor ? 1 : ComboBasedAlpha;
|
|
|
|
|
playfield.Cursor.Alpha = (float)Interpolation.Lerp(playfield.Cursor.Alpha, targetAlpha, Math.Clamp(playfield.Time.Elapsed / TRANSITION_DURATION, 0, 1));
|
2021-10-15 06:30:55 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|