mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 10:03:05 +08:00
Merge pull request #17356 from apollo-dw/strict-tracking
Implement "Strict Tracking" mod in osu!
This commit is contained in:
commit
36772ec652
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
@ -16,6 +17,8 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
{
|
{
|
||||||
public class OsuModClassic : ModClassic, IApplicableToHitObject, IApplicableToDrawableHitObject, IApplicableToDrawableRuleset<OsuHitObject>
|
public class OsuModClassic : ModClassic, IApplicableToHitObject, IApplicableToDrawableHitObject, IApplicableToDrawableRuleset<OsuHitObject>
|
||||||
{
|
{
|
||||||
|
public override Type[] IncompatibleMods => new[] { typeof(OsuModStrictTracking) };
|
||||||
|
|
||||||
[SettingSource("No slider head accuracy requirement", "Scores sliders proportionally to the number of ticks hit.")]
|
[SettingSource("No slider head accuracy requirement", "Scores sliders proportionally to the number of ticks hit.")]
|
||||||
public Bindable<bool> NoSliderHeadAccuracy { get; } = new BindableBool(true);
|
public Bindable<bool> NoSliderHeadAccuracy { get; } = new BindableBool(true);
|
||||||
|
|
||||||
|
148
osu.Game.Rulesets.Osu/Mods/OsuModStrictTracking.cs
Normal file
148
osu.Game.Rulesets.Osu/Mods/OsuModStrictTracking.cs
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
// 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;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Rulesets.Judgements;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
|
using osu.Game.Rulesets.Osu.Beatmaps;
|
||||||
|
using osu.Game.Rulesets.Osu.Judgements;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Mods
|
||||||
|
{
|
||||||
|
public class OsuModStrictTracking : Mod, IApplicableAfterBeatmapConversion, IApplicableToDrawableHitObject, IApplicableToDrawableRuleset<OsuHitObject>
|
||||||
|
{
|
||||||
|
public override string Name => @"Strict Tracking";
|
||||||
|
public override string Acronym => @"ST";
|
||||||
|
public override IconUsage? Icon => FontAwesome.Solid.PenFancy;
|
||||||
|
public override ModType Type => ModType.DifficultyIncrease;
|
||||||
|
public override string Description => @"Follow circles just got serious...";
|
||||||
|
public override double ScoreMultiplier => 1.0;
|
||||||
|
public override Type[] IncompatibleMods => new[] { typeof(ModClassic) };
|
||||||
|
|
||||||
|
public void ApplyToDrawableHitObject(DrawableHitObject drawable)
|
||||||
|
{
|
||||||
|
if (drawable is DrawableSlider slider)
|
||||||
|
{
|
||||||
|
slider.Tracking.ValueChanged += e =>
|
||||||
|
{
|
||||||
|
if (e.NewValue || slider.Judged) return;
|
||||||
|
|
||||||
|
var tail = slider.NestedHitObjects.OfType<StrictTrackingDrawableSliderTail>().First();
|
||||||
|
|
||||||
|
if (!tail.Judged)
|
||||||
|
tail.MissForcefully();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ApplyToBeatmap(IBeatmap beatmap)
|
||||||
|
{
|
||||||
|
var osuBeatmap = (OsuBeatmap)beatmap;
|
||||||
|
|
||||||
|
if (osuBeatmap.HitObjects.Count == 0) return;
|
||||||
|
|
||||||
|
var hitObjects = osuBeatmap.HitObjects.Select(ho =>
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -154,7 +154,7 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
|
|
||||||
public Slider()
|
public Slider()
|
||||||
{
|
{
|
||||||
SamplesBindable.CollectionChanged += (_, __) => updateNestedSamples();
|
SamplesBindable.CollectionChanged += (_, __) => UpdateNestedSamples();
|
||||||
Path.Version.ValueChanged += _ => updateNestedPositions();
|
Path.Version.ValueChanged += _ => updateNestedPositions();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateNestedSamples();
|
UpdateNestedSamples();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateNestedPositions()
|
private void updateNestedPositions()
|
||||||
@ -241,7 +241,7 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
TailCircle.Position = EndPosition;
|
TailCircle.Position = EndPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateNestedSamples()
|
protected void UpdateNestedSamples()
|
||||||
{
|
{
|
||||||
var firstSample = Samples.FirstOrDefault(s => s.Name == HitSampleInfo.HIT_NORMAL)
|
var firstSample = Samples.FirstOrDefault(s => s.Name == HitSampleInfo.HIT_NORMAL)
|
||||||
?? Samples.FirstOrDefault(); // TODO: remove this when guaranteed sort is present for samples (https://github.com/ppy/osu/issues/1933)
|
?? Samples.FirstOrDefault(); // TODO: remove this when guaranteed sort is present for samples (https://github.com/ppy/osu/issues/1933)
|
||||||
|
@ -159,6 +159,7 @@ namespace osu.Game.Rulesets.Osu
|
|||||||
new MultiMod(new OsuModDoubleTime(), new OsuModNightcore()),
|
new MultiMod(new OsuModDoubleTime(), new OsuModNightcore()),
|
||||||
new OsuModHidden(),
|
new OsuModHidden(),
|
||||||
new MultiMod(new OsuModFlashlight(), new OsuModBlinds()),
|
new MultiMod(new OsuModFlashlight(), new OsuModBlinds()),
|
||||||
|
new OsuModStrictTracking()
|
||||||
};
|
};
|
||||||
|
|
||||||
case ModType.Conversion:
|
case ModType.Conversion:
|
||||||
|
@ -323,7 +323,7 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// </param>
|
/// </param>
|
||||||
/// <typeparam name="TObject">The <see cref="HitObject"/> type.</typeparam>
|
/// <typeparam name="TObject">The <see cref="HitObject"/> type.</typeparam>
|
||||||
/// <typeparam name="TDrawable">The <see cref="DrawableHitObject"/> receiver for <typeparamref name="TObject"/>s.</typeparam>
|
/// <typeparam name="TDrawable">The <see cref="DrawableHitObject"/> receiver for <typeparamref name="TObject"/>s.</typeparam>
|
||||||
protected void RegisterPool<TObject, TDrawable>(int initialSize, int? maximumSize = null)
|
public void RegisterPool<TObject, TDrawable>(int initialSize, int? maximumSize = null)
|
||||||
where TObject : HitObject
|
where TObject : HitObject
|
||||||
where TDrawable : DrawableHitObject, new()
|
where TDrawable : DrawableHitObject, new()
|
||||||
=> RegisterPool<TObject, TDrawable>(new DrawablePool<TDrawable>(initialSize, maximumSize));
|
=> RegisterPool<TObject, TDrawable>(new DrawablePool<TDrawable>(initialSize, maximumSize));
|
||||||
|
Loading…
Reference in New Issue
Block a user