2021-02-03 14:08:59 +00: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.
|
|
|
|
|
2022-03-08 21:47:54 +00:00
|
|
|
using System;
|
2021-02-03 14:08:59 +00:00
|
|
|
using System.Linq;
|
2021-02-05 06:23:03 +00:00
|
|
|
using osu.Framework.Bindables;
|
2023-02-09 17:15:21 +00:00
|
|
|
using osu.Framework.Graphics;
|
2021-02-05 06:23:03 +00:00
|
|
|
using osu.Game.Configuration;
|
2021-02-03 14:08:59 +00:00
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2021-02-05 07:59:13 +00:00
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2021-02-03 14:08:59 +00:00
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
2021-02-05 07:59:13 +00:00
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
2023-08-23 11:37:39 +00:00
|
|
|
using osu.Game.Rulesets.Osu.Scoring;
|
2021-02-05 06:23:03 +00:00
|
|
|
using osu.Game.Rulesets.Osu.UI;
|
2023-02-09 17:15:21 +00:00
|
|
|
using osu.Game.Rulesets.Scoring;
|
2021-02-05 06:23:03 +00:00
|
|
|
using osu.Game.Rulesets.UI;
|
2021-02-03 14:08:59 +00:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Mods
|
|
|
|
{
|
2023-12-17 10:33:02 +00:00
|
|
|
public class OsuModClassic : ModClassic, IApplicableToHitObject, IApplicableToDrawableHitObject, IApplicableToDrawableRuleset<OsuHitObject>, IApplicableHealthProcessor
|
2021-02-03 14:08:59 +00:00
|
|
|
{
|
2022-04-28 20:31:48 +00:00
|
|
|
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(OsuModStrictTracking)).ToArray();
|
2022-03-08 21:47:54 +00:00
|
|
|
|
2021-02-10 09:41:28 +00:00
|
|
|
[SettingSource("No slider head accuracy requirement", "Scores sliders proportionally to the number of ticks hit.")]
|
|
|
|
public Bindable<bool> NoSliderHeadAccuracy { get; } = new BindableBool(true);
|
2021-02-05 06:23:03 +00:00
|
|
|
|
2021-02-10 09:41:28 +00:00
|
|
|
[SettingSource("Apply classic note lock", "Applies note lock to the full hit window.")]
|
|
|
|
public Bindable<bool> ClassicNoteLock { get; } = new BindableBool(true);
|
2021-02-05 06:23:03 +00:00
|
|
|
|
2021-04-02 08:10:28 +00:00
|
|
|
[SettingSource("Always play a slider's tail sample", "Always plays a slider's tail sample regardless of whether it was hit or not.")]
|
|
|
|
public Bindable<bool> AlwaysPlayTailSample { get; } = new BindableBool(true);
|
|
|
|
|
2023-02-09 17:15:21 +00:00
|
|
|
[SettingSource("Fade out hit circles earlier", "Make hit circles fade out into a miss, rather than after it.")]
|
|
|
|
public Bindable<bool> FadeHitCircleEarly { get; } = new Bindable<bool>(true);
|
|
|
|
|
2023-12-17 10:33:02 +00:00
|
|
|
[SettingSource("Classic health", "More closely resembles the original HP drain mechanics.")]
|
|
|
|
public Bindable<bool> ClassicHealth { get; } = new Bindable<bool>(true);
|
|
|
|
|
2023-02-16 22:31:42 +00:00
|
|
|
private bool usingHiddenFading;
|
2023-02-15 06:45:58 +00:00
|
|
|
|
2021-02-03 14:08:59 +00:00
|
|
|
public void ApplyToHitObject(HitObject hitObject)
|
|
|
|
{
|
|
|
|
switch (hitObject)
|
|
|
|
{
|
|
|
|
case Slider slider:
|
2023-11-02 08:04:49 +00:00
|
|
|
slider.ClassicSliderBehaviour = NoSliderHeadAccuracy.Value;
|
2021-02-03 14:08:59 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-02-05 06:23:03 +00:00
|
|
|
|
|
|
|
public void ApplyToDrawableRuleset(DrawableRuleset<OsuHitObject> drawableRuleset)
|
|
|
|
{
|
|
|
|
var osuRuleset = (DrawableOsuRuleset)drawableRuleset;
|
|
|
|
|
2021-02-10 11:27:47 +00:00
|
|
|
if (ClassicNoteLock.Value)
|
2023-08-23 11:37:39 +00:00
|
|
|
{
|
|
|
|
double hittableRange = OsuHitWindows.MISS_WINDOW - (drawableRuleset.Mods.OfType<OsuModAutopilot>().Any() ? 200 : 0);
|
|
|
|
osuRuleset.Playfield.HitPolicy = new LegacyHitPolicy(hittableRange);
|
|
|
|
}
|
2023-02-15 06:45:58 +00:00
|
|
|
|
2023-02-19 15:12:10 +00:00
|
|
|
usingHiddenFading = drawableRuleset.Mods.OfType<OsuModHidden>().SingleOrDefault()?.OnlyFadeApproachCircles.Value == false;
|
2021-02-05 06:23:03 +00:00
|
|
|
}
|
2021-02-05 07:59:13 +00:00
|
|
|
|
2021-06-16 09:52:01 +00:00
|
|
|
public void ApplyToDrawableHitObject(DrawableHitObject obj)
|
2021-02-05 07:59:13 +00:00
|
|
|
{
|
2021-06-16 09:52:01 +00:00
|
|
|
switch (obj)
|
2021-02-05 07:59:13 +00:00
|
|
|
{
|
2021-06-16 09:52:01 +00:00
|
|
|
case DrawableSliderHead head:
|
2023-02-16 22:31:42 +00:00
|
|
|
if (FadeHitCircleEarly.Value && !usingHiddenFading)
|
2023-02-09 17:15:21 +00:00
|
|
|
applyEarlyFading(head);
|
2023-09-08 09:08:25 +00:00
|
|
|
|
|
|
|
if (ClassicNoteLock.Value)
|
|
|
|
blockInputToObjectsUnderSliderHead(head);
|
|
|
|
|
2021-06-16 09:52:01 +00:00
|
|
|
break;
|
2021-04-02 07:54:35 +00:00
|
|
|
|
2021-06-16 09:52:01 +00:00
|
|
|
case DrawableSliderTail tail:
|
|
|
|
tail.SamplePlaysOnlyOnHit = !AlwaysPlayTailSample.Value;
|
|
|
|
break;
|
2023-02-09 17:15:21 +00:00
|
|
|
|
|
|
|
case DrawableHitCircle circle:
|
2023-02-16 22:31:42 +00:00
|
|
|
if (FadeHitCircleEarly.Value && !usingHiddenFading)
|
2023-02-09 17:15:21 +00:00
|
|
|
applyEarlyFading(circle);
|
2023-09-08 09:08:25 +00:00
|
|
|
|
2023-02-09 17:15:21 +00:00
|
|
|
break;
|
2021-02-05 07:59:13 +00:00
|
|
|
}
|
|
|
|
}
|
2023-02-09 17:15:21 +00:00
|
|
|
|
2023-09-08 09:08:25 +00:00
|
|
|
/// <summary>
|
|
|
|
/// On stable, slider heads that have already been hit block input from reaching objects that may be underneath them
|
|
|
|
/// until the sliders they're part of have been fully judged.
|
|
|
|
/// The purpose of this method is to restore that behaviour.
|
|
|
|
/// In order to avoid introducing yet another confusing config option, this behaviour is roped into the general notion of "note lock".
|
|
|
|
/// </summary>
|
|
|
|
private static void blockInputToObjectsUnderSliderHead(DrawableSliderHead slider)
|
|
|
|
{
|
|
|
|
var oldHitAction = slider.HitArea.Hit;
|
|
|
|
slider.HitArea.Hit = () =>
|
|
|
|
{
|
|
|
|
oldHitAction?.Invoke();
|
|
|
|
return !slider.DrawableSlider.AllJudged;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-02-09 17:15:21 +00:00
|
|
|
private void applyEarlyFading(DrawableHitCircle circle)
|
|
|
|
{
|
2023-08-30 18:42:47 +00:00
|
|
|
circle.ApplyCustomUpdateState += (dho, state) =>
|
2023-02-09 17:15:21 +00:00
|
|
|
{
|
2023-08-30 18:42:47 +00:00
|
|
|
using (dho.BeginAbsoluteSequence(dho.StateUpdateTime))
|
2023-02-09 17:15:21 +00:00
|
|
|
{
|
2023-08-30 18:42:47 +00:00
|
|
|
if (state != ArmedState.Hit)
|
|
|
|
{
|
|
|
|
double okWindow = dho.HitObject.HitWindows.WindowFor(HitResult.Ok);
|
|
|
|
double lateMissFadeTime = dho.HitObject.HitWindows.WindowFor(HitResult.Meh) - okWindow;
|
|
|
|
dho.Delay(okWindow).FadeOut(lateMissFadeTime);
|
|
|
|
}
|
2023-02-09 17:15:21 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2023-12-17 10:33:02 +00:00
|
|
|
|
|
|
|
public HealthProcessor? CreateHealthProcessor(double drainStartTime) => ClassicHealth.Value ? new OsuLegacyHealthProcessor(drainStartTime) : null;
|
2021-02-03 14:08:59 +00:00
|
|
|
}
|
|
|
|
}
|