1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-24 06:43:03 +08:00
osu-lazer/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

100 lines
4.0 KiB
C#
Raw Normal View History

2021-02-03 22:08:59 +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.
2022-03-09 05:47:54 +08:00
using System;
2021-02-03 22:08:59 +08:00
using System.Linq;
2021-02-05 14:23:03 +08:00
using osu.Framework.Bindables;
using osu.Framework.Graphics;
2021-02-05 14:23:03 +08:00
using osu.Game.Configuration;
2021-02-03 22:08:59 +08:00
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects;
2021-02-05 15:59:13 +08:00
using osu.Game.Rulesets.Objects.Drawables;
2021-02-03 22:08:59 +08:00
using osu.Game.Rulesets.Osu.Objects;
2021-02-05 15:59:13 +08:00
using osu.Game.Rulesets.Osu.Objects.Drawables;
2021-02-05 14:23:03 +08:00
using osu.Game.Rulesets.Osu.UI;
using osu.Game.Rulesets.Scoring;
2021-02-05 14:23:03 +08:00
using osu.Game.Rulesets.UI;
2021-02-03 22:08:59 +08:00
namespace osu.Game.Rulesets.Osu.Mods
{
public class OsuModClassic : ModClassic, IApplicableToHitObject, IApplicableToDrawableHitObject, IApplicableToDrawableRuleset<OsuHitObject>
2021-02-03 22:08:59 +08:00
{
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(OsuModStrictTracking)).ToArray();
2022-03-09 05:47:54 +08: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 14:23:03 +08:00
[SettingSource("No slider head movement", "Pins slider heads at their starting position, regardless of time.")]
public Bindable<bool> NoSliderHeadMovement { get; } = new BindableBool(true);
2021-02-05 14:23:03 +08: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 14:23:03 +08: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);
[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);
private bool usingHiddenFading;
2021-02-03 22:08:59 +08:00
public void ApplyToHitObject(HitObject hitObject)
{
switch (hitObject)
{
case Slider slider:
slider.OnlyJudgeNestedObjects = !NoSliderHeadAccuracy.Value;
2021-02-03 22:08:59 +08:00
foreach (var head in slider.NestedHitObjects.OfType<SliderHeadCircle>())
head.JudgeAsNormalHitCircle = !NoSliderHeadAccuracy.Value;
2021-02-03 22:08:59 +08:00
break;
}
}
2021-02-05 14:23:03 +08:00
public void ApplyToDrawableRuleset(DrawableRuleset<OsuHitObject> drawableRuleset)
{
var osuRuleset = (DrawableOsuRuleset)drawableRuleset;
if (ClassicNoteLock.Value)
2021-02-05 14:23:03 +08:00
osuRuleset.Playfield.HitPolicy = new ObjectOrderedHitPolicy();
2023-02-19 23:12:10 +08:00
usingHiddenFading = drawableRuleset.Mods.OfType<OsuModHidden>().SingleOrDefault()?.OnlyFadeApproachCircles.Value == false;
2021-02-05 14:23:03 +08:00
}
2021-02-05 15:59:13 +08:00
public void ApplyToDrawableHitObject(DrawableHitObject obj)
2021-02-05 15:59:13 +08:00
{
switch (obj)
2021-02-05 15:59:13 +08:00
{
case DrawableSliderHead head:
head.TrackFollowCircle = !NoSliderHeadMovement.Value;
if (FadeHitCircleEarly.Value && !usingHiddenFading)
applyEarlyFading(head);
break;
case DrawableSliderTail tail:
tail.SamplePlaysOnlyOnHit = !AlwaysPlayTailSample.Value;
break;
case DrawableHitCircle circle:
if (FadeHitCircleEarly.Value && !usingHiddenFading)
applyEarlyFading(circle);
break;
2021-02-05 15:59:13 +08:00
}
}
private void applyEarlyFading(DrawableHitCircle circle)
{
circle.ApplyCustomUpdateState += (o, _) =>
{
using (o.BeginAbsoluteSequence(o.StateUpdateTime))
{
double okWindow = o.HitObject.HitWindows.WindowFor(HitResult.Ok);
double lateMissFadeTime = o.HitObject.HitWindows.WindowFor(HitResult.Meh) - okWindow;
o.Delay(okWindow).FadeOut(lateMissFadeTime);
}
};
}
2021-02-03 22:08:59 +08:00
}
}