2021-10-14 18:30:55 -04: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-14 23:34:43 -04:00
|
|
|
|
using System;
|
2022-10-15 16:42:33 +03:00
|
|
|
|
using System.Diagnostics;
|
2021-10-22 17:10:53 -04:00
|
|
|
|
using System.Linq;
|
2021-11-10 03:57:22 +03:00
|
|
|
|
using osu.Framework.Bindables;
|
2022-08-10 16:09:11 -04:00
|
|
|
|
using osu.Framework.Localisation;
|
2021-10-15 14:25:50 +09:00
|
|
|
|
using osu.Framework.Utils;
|
2021-10-22 17:10:53 -04:00
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
2022-10-14 22:14:23 +03:00
|
|
|
|
using osu.Game.Rulesets.Osu.UI;
|
2021-10-22 17:10:53 -04:00
|
|
|
|
using osu.Game.Rulesets.UI;
|
|
|
|
|
using osu.Game.Utils;
|
2021-10-14 18:30:55 -04:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Mods
|
|
|
|
|
{
|
2021-11-09 17:11:19 +03:00
|
|
|
|
public class OsuModNoScope : ModNoScope, IUpdatableByPlayfield, IApplicableToBeatmap
|
2021-10-14 18:30:55 -04:00
|
|
|
|
{
|
2022-08-10 16:09:11 -04:00
|
|
|
|
public override LocalisableString Description => "Where's the cursor?";
|
2021-10-15 14:25:50 +09:00
|
|
|
|
|
2022-07-31 21:43:16 +08:00
|
|
|
|
private PeriodTracker spinnerPeriods = null!;
|
2021-10-14 18:30:55 -04:00
|
|
|
|
|
2022-09-25 15:49:22 -04:00
|
|
|
|
public override BindableInt HiddenComboCount { get; } = new BindableInt(10)
|
2021-11-10 03:57:22 +03:00
|
|
|
|
{
|
|
|
|
|
MinValue = 0,
|
|
|
|
|
MaxValue = 50,
|
|
|
|
|
};
|
|
|
|
|
|
2021-10-22 17:10:53 -04:00
|
|
|
|
public void ApplyToBeatmap(IBeatmap beatmap)
|
|
|
|
|
{
|
2021-11-09 17:11:19 +03:00
|
|
|
|
spinnerPeriods = new PeriodTracker(beatmap.HitObjects.OfType<Spinner>().Select(b => new Period(b.StartTime - TRANSITION_DURATION, b.EndTime)));
|
2021-10-14 18:30:55 -04:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-10 12:00:36 +01:00
|
|
|
|
public void Update(Playfield playfield)
|
2021-10-14 18:30:55 -04:00
|
|
|
|
{
|
2022-10-15 16:42:33 +03:00
|
|
|
|
var osuPlayfield = (OsuPlayfield)playfield;
|
|
|
|
|
Debug.Assert(osuPlayfield.Cursor != null);
|
|
|
|
|
|
|
|
|
|
bool shouldAlwaysShowCursor = IsBreakTime.Value || spinnerPeriods.IsInAny(osuPlayfield.Clock.CurrentTime);
|
2021-11-09 17:11:19 +03:00
|
|
|
|
float targetAlpha = shouldAlwaysShowCursor ? 1 : ComboBasedAlpha;
|
2022-10-15 16:42:33 +03:00
|
|
|
|
float currentAlpha = (float)Interpolation.Lerp(osuPlayfield.Cursor.Alpha, targetAlpha, Math.Clamp(osuPlayfield.Time.Elapsed / TRANSITION_DURATION, 0, 1));
|
2022-10-14 22:14:23 +03:00
|
|
|
|
|
|
|
|
|
osuPlayfield.Cursor.Alpha = currentAlpha;
|
|
|
|
|
osuPlayfield.Smoke.Alpha = currentAlpha;
|
2021-10-14 18:30:55 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|