2022-03-09 05:47:54 +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.
|
|
|
|
|
|
|
|
using System;
|
2022-03-20 02:29:44 +08:00
|
|
|
using System.Linq;
|
2022-03-20 23:56:41 +08:00
|
|
|
using System.Threading;
|
2022-08-11 04:09:11 +08:00
|
|
|
using osu.Framework.Localisation;
|
2022-03-09 05:47:54 +08:00
|
|
|
using osu.Game.Beatmaps;
|
2022-03-20 23:56:41 +08:00
|
|
|
using osu.Game.Rulesets.Judgements;
|
2022-03-09 05:47:54 +08:00
|
|
|
using osu.Game.Rulesets.Mods;
|
2022-03-20 23:56:41 +08:00
|
|
|
using osu.Game.Rulesets.Objects;
|
2022-03-09 05:47:54 +08:00
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2022-03-20 23:56:41 +08:00
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
2022-03-20 02:29:44 +08:00
|
|
|
using osu.Game.Rulesets.Osu.Beatmaps;
|
2022-03-20 23:56:41 +08:00
|
|
|
using osu.Game.Rulesets.Osu.Judgements;
|
2022-03-09 05:47:54 +08:00
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
2022-03-20 02:29:44 +08:00
|
|
|
using osu.Game.Rulesets.UI;
|
2022-03-09 05:47:54 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Mods
|
|
|
|
{
|
2022-03-20 02:29:44 +08:00
|
|
|
public class OsuModStrictTracking : Mod, IApplicableAfterBeatmapConversion, IApplicableToDrawableHitObject, IApplicableToDrawableRuleset<OsuHitObject>
|
2022-03-09 05:47:54 +08:00
|
|
|
{
|
|
|
|
public override string Name => @"Strict Tracking";
|
|
|
|
public override string Acronym => @"ST";
|
|
|
|
public override ModType Type => ModType.DifficultyIncrease;
|
2022-08-11 04:09:11 +08:00
|
|
|
public override LocalisableString Description => @"Once you start a slider, follow precisely or get a miss.";
|
2022-03-09 05:47:54 +08:00
|
|
|
public override double ScoreMultiplier => 1.0;
|
2022-11-01 18:47:20 +08:00
|
|
|
public override Type[] IncompatibleMods => new[] { typeof(ModClassic), typeof(OsuModTargetPractice) };
|
2022-03-09 05:47:54 +08:00
|
|
|
|
|
|
|
public void ApplyToDrawableHitObject(DrawableHitObject drawable)
|
|
|
|
{
|
|
|
|
if (drawable is DrawableSlider slider)
|
|
|
|
{
|
|
|
|
slider.Tracking.ValueChanged += e =>
|
|
|
|
{
|
|
|
|
if (e.NewValue || slider.Judged) return;
|
|
|
|
|
2022-03-20 07:42:12 +08:00
|
|
|
var tail = slider.NestedHitObjects.OfType<StrictTrackingDrawableSliderTail>().First();
|
2022-03-09 05:47:54 +08:00
|
|
|
|
2022-03-20 07:42:12 +08:00
|
|
|
if (!tail.Judged)
|
|
|
|
tail.MissForcefully();
|
2022-03-09 05:47:54 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-20 02:29:44 +08:00
|
|
|
public void ApplyToBeatmap(IBeatmap beatmap)
|
2022-03-09 05:47:54 +08:00
|
|
|
{
|
2022-03-20 02:29:44 +08:00
|
|
|
var osuBeatmap = (OsuBeatmap)beatmap;
|
|
|
|
|
|
|
|
if (osuBeatmap.HitObjects.Count == 0) return;
|
|
|
|
|
|
|
|
var hitObjects = osuBeatmap.HitObjects.Select(ho =>
|
2022-03-09 05:47:54 +08:00
|
|
|
{
|
2022-03-20 02:29:44 +08:00
|
|
|
if (ho is Slider slider)
|
|
|
|
{
|
|
|
|
var newSlider = new StrictTrackingSlider(slider);
|
|
|
|
return newSlider;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ho;
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
osuBeatmap.HitObjects = hitObjects;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void ApplyToDrawableRuleset(DrawableRuleset<OsuHitObject> drawableRuleset)
|
|
|
|
{
|
|
|
|
drawableRuleset.Playfield.RegisterPool<StrictTrackingSliderTailCircle, StrictTrackingDrawableSliderTail>(10, 100);
|
2022-03-09 05:47:54 +08:00
|
|
|
}
|
2022-03-20 23:56:41 +08:00
|
|
|
|
|
|
|
private class StrictTrackingSliderTailCircle : SliderTailCircle
|
|
|
|
{
|
|
|
|
public StrictTrackingSliderTailCircle(Slider slider)
|
|
|
|
: base(slider)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public override Judgement CreateJudgement() => new OsuJudgement();
|
|
|
|
}
|
|
|
|
|
|
|
|
private class StrictTrackingDrawableSliderTail : DrawableSliderTail
|
|
|
|
{
|
|
|
|
public override bool DisplayResult => true;
|
|
|
|
}
|
|
|
|
|
|
|
|
private class StrictTrackingSlider : Slider
|
|
|
|
{
|
|
|
|
public StrictTrackingSlider(Slider original)
|
|
|
|
{
|
|
|
|
StartTime = original.StartTime;
|
|
|
|
Samples = original.Samples;
|
|
|
|
Path = original.Path;
|
|
|
|
NodeSamples = original.NodeSamples;
|
|
|
|
RepeatCount = original.RepeatCount;
|
|
|
|
Position = original.Position;
|
|
|
|
NewCombo = original.NewCombo;
|
|
|
|
ComboOffset = original.ComboOffset;
|
|
|
|
LegacyLastTickOffset = original.LegacyLastTickOffset;
|
|
|
|
TickDistanceMultiplier = original.TickDistanceMultiplier;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void CreateNestedHitObjects(CancellationToken cancellationToken)
|
|
|
|
{
|
|
|
|
var sliderEvents = SliderEventGenerator.Generate(StartTime, SpanDuration, Velocity, TickDistance, Path.Distance, this.SpanCount(), LegacyLastTickOffset, cancellationToken);
|
|
|
|
|
|
|
|
foreach (var e in sliderEvents)
|
|
|
|
{
|
|
|
|
switch (e.Type)
|
|
|
|
{
|
2022-05-04 19:55:22 +08:00
|
|
|
case SliderEventType.Tick:
|
2022-05-05 20:37:57 +08:00
|
|
|
AddNested(new SliderTick
|
2022-05-04 19:55:22 +08:00
|
|
|
{
|
|
|
|
SpanIndex = e.SpanIndex,
|
|
|
|
SpanStartTime = e.SpanStartTime,
|
|
|
|
StartTime = e.Time,
|
|
|
|
Position = Position + Path.PositionAt(e.PathProgress),
|
|
|
|
StackHeight = StackHeight,
|
|
|
|
Scale = Scale,
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
|
2022-03-20 23:56:41 +08:00
|
|
|
case SliderEventType.Head:
|
|
|
|
AddNested(HeadCircle = new SliderHeadCircle
|
|
|
|
{
|
|
|
|
StartTime = e.Time,
|
|
|
|
Position = Position,
|
|
|
|
StackHeight = StackHeight,
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SliderEventType.LegacyLastTick:
|
|
|
|
AddNested(TailCircle = new StrictTrackingSliderTailCircle(this)
|
|
|
|
{
|
|
|
|
RepeatIndex = e.SpanIndex,
|
|
|
|
StartTime = e.Time,
|
|
|
|
Position = EndPosition,
|
|
|
|
StackHeight = StackHeight
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SliderEventType.Repeat:
|
|
|
|
AddNested(new SliderRepeat(this)
|
|
|
|
{
|
|
|
|
RepeatIndex = e.SpanIndex,
|
|
|
|
StartTime = StartTime + (e.SpanIndex + 1) * SpanDuration,
|
|
|
|
Position = Position + Path.PositionAt(e.PathProgress),
|
|
|
|
StackHeight = StackHeight,
|
|
|
|
Scale = Scale,
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdateNestedSamples();
|
|
|
|
}
|
|
|
|
}
|
2022-03-09 05:47:54 +08:00
|
|
|
}
|
|
|
|
}
|