2019-01-24 17:43:03 +09: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.
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2022-06-17 16:37:17 +09:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2020-10-02 13:41:22 +09:00
|
|
|
|
using System.Diagnostics;
|
2023-10-24 18:00:48 +09:00
|
|
|
|
using System.Linq;
|
2020-12-03 14:28:37 +09:00
|
|
|
|
using JetBrains.Annotations;
|
2020-10-02 13:41:22 +09:00
|
|
|
|
using osu.Framework.Allocation;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
using osu.Framework.Graphics;
|
2020-10-02 13:41:22 +09:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2023-09-29 16:08:28 +09:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2020-10-02 13:41:22 +09:00
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2021-05-26 23:21:05 +03:00
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
2020-10-02 13:41:22 +09:00
|
|
|
|
using osu.Game.Skinning;
|
2018-11-20 16:51:59 +09:00
|
|
|
|
using osuTK;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|
|
|
|
{
|
2022-11-24 14:32:20 +09:00
|
|
|
|
public partial class DrawableSliderTail : DrawableOsuHitObject, IRequireTracking
|
2018-04-13 18:19:50 +09:00
|
|
|
|
{
|
2020-11-12 15:59:48 +09:00
|
|
|
|
public new SliderTailCircle HitObject => (SliderTailCircle)base.HitObject;
|
2018-10-29 15:36:43 +09:00
|
|
|
|
|
2020-12-03 14:28:37 +09:00
|
|
|
|
[CanBeNull]
|
2020-12-03 20:10:16 +09:00
|
|
|
|
public Slider Slider => DrawableSlider?.HitObject;
|
|
|
|
|
|
|
|
|
|
protected DrawableSlider DrawableSlider => (DrawableSlider)ParentHitObject;
|
2020-12-03 14:28:37 +09:00
|
|
|
|
|
2018-04-13 18:19:50 +09:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The judgement text is provided by the <see cref="DrawableSlider"/>.
|
|
|
|
|
/// </summary>
|
2018-08-06 11:31:46 +09:00
|
|
|
|
public override bool DisplayResult => false;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2021-04-02 02:54:35 -05:00
|
|
|
|
/// <summary>
|
2021-04-02 18:00:28 +09:00
|
|
|
|
/// Whether the hit samples only play on successful hits.
|
|
|
|
|
/// If <c>false</c>, the hit samples will also play on misses.
|
2021-04-02 02:54:35 -05:00
|
|
|
|
/// </summary>
|
2021-04-02 03:56:23 -05:00
|
|
|
|
public bool SamplePlaysOnlyOnHit { get; set; } = true;
|
2021-04-02 02:54:35 -05:00
|
|
|
|
|
2018-04-13 18:19:50 +09:00
|
|
|
|
public bool Tracking { get; set; }
|
|
|
|
|
|
2021-04-26 15:22:17 +09:00
|
|
|
|
public SkinnableDrawable CirclePiece { get; private set; }
|
|
|
|
|
|
2020-11-05 13:51:46 +09:00
|
|
|
|
private Container scaleContainer;
|
2020-10-02 13:41:22 +09:00
|
|
|
|
|
2020-11-12 15:59:48 +09:00
|
|
|
|
public DrawableSliderTail()
|
|
|
|
|
: base(null)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-05 13:51:46 +09:00
|
|
|
|
public DrawableSliderTail(SliderTailCircle tailCircle)
|
2020-10-02 14:20:55 +09:00
|
|
|
|
: base(tailCircle)
|
2018-04-13 18:19:50 +09:00
|
|
|
|
{
|
2020-11-05 13:51:46 +09:00
|
|
|
|
}
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2020-11-05 13:51:46 +09:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.Centre;
|
2023-09-20 12:48:15 +09:00
|
|
|
|
Size = OsuHitObject.OBJECT_DIMENSIONS;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2022-09-22 14:46:37 +09:00
|
|
|
|
AddRangeInternal(new Drawable[]
|
2020-10-02 13:41:22 +09:00
|
|
|
|
{
|
|
|
|
|
scaleContainer = new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
// no default for this; only visible in legacy skins.
|
2022-11-09 16:04:56 +09:00
|
|
|
|
CirclePiece = new SkinnableDrawable(new OsuSkinComponentLookup(OsuSkinComponents.SliderTailHitCircle), _ => Empty())
|
2020-10-02 13:41:22 +09:00
|
|
|
|
}
|
|
|
|
|
},
|
2022-09-22 14:46:37 +09:00
|
|
|
|
});
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2020-11-12 15:59:48 +09:00
|
|
|
|
ScaleBindable.BindValueChanged(scale => scaleContainer.Scale = new Vector2(scale.NewValue));
|
2020-10-02 13:41:22 +09:00
|
|
|
|
}
|
2018-11-14 14:29:22 +09:00
|
|
|
|
|
2022-03-14 17:08:26 +09:00
|
|
|
|
protected override void LoadSamples()
|
|
|
|
|
{
|
|
|
|
|
// Tail models don't actually get samples, as the playback is handled by DrawableSlider.
|
|
|
|
|
// This override is only here for visibility in explaining this weird flow.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void PlaySamples()
|
|
|
|
|
{
|
|
|
|
|
// Tail models don't actually get samples, as the playback is handled by DrawableSlider.
|
|
|
|
|
// This override is only here for visibility in explaining this weird flow.
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-02 13:41:22 +09:00
|
|
|
|
protected override void UpdateInitialTransforms()
|
|
|
|
|
{
|
|
|
|
|
base.UpdateInitialTransforms();
|
2019-10-08 17:56:56 +09:00
|
|
|
|
|
2023-05-02 16:27:17 +09:00
|
|
|
|
// When snaking in is enabled, the first end circle needs to be delayed until the snaking completes.
|
2023-05-02 16:36:43 +09:00
|
|
|
|
bool delayFadeIn = DrawableSlider.SliderBody?.SnakingIn.Value == true && HitObject.RepeatIndex == 0;
|
2023-05-02 16:27:17 +09:00
|
|
|
|
|
|
|
|
|
CirclePiece
|
|
|
|
|
.FadeOut()
|
2023-05-02 16:36:43 +09:00
|
|
|
|
.Delay(delayFadeIn ? (Slider?.TimePreempt ?? 0) / 3 : 0)
|
2023-05-02 16:27:17 +09:00
|
|
|
|
.FadeIn(HitObject.TimeFadeIn);
|
2020-10-02 13:41:22 +09:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-04 16:19:07 +09:00
|
|
|
|
protected override void UpdateHitStateTransforms(ArmedState state)
|
2020-10-02 13:41:22 +09:00
|
|
|
|
{
|
2020-11-04 16:19:07 +09:00
|
|
|
|
base.UpdateHitStateTransforms(state);
|
2020-10-02 13:41:22 +09:00
|
|
|
|
|
|
|
|
|
Debug.Assert(HitObject.HitWindows != null);
|
|
|
|
|
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case ArmedState.Idle:
|
|
|
|
|
this.Delay(HitObject.TimePreempt).FadeOut(500);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ArmedState.Miss:
|
|
|
|
|
this.FadeOut(100);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ArmedState.Hit:
|
|
|
|
|
// todo: temporary / arbitrary
|
|
|
|
|
this.Delay(800).FadeOut();
|
|
|
|
|
break;
|
|
|
|
|
}
|
2018-04-13 18:19:50 +09:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-06 11:31:46 +09:00
|
|
|
|
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
2018-04-13 18:19:50 +09:00
|
|
|
|
{
|
2023-09-29 16:08:28 +09:00
|
|
|
|
if (userTriggered)
|
|
|
|
|
return;
|
|
|
|
|
|
2023-10-24 18:00:48 +09:00
|
|
|
|
// Ensure the tail can only activate after all previous ticks/repeats already have.
|
2023-10-03 18:36:13 +09:00
|
|
|
|
//
|
|
|
|
|
// This covers the edge case where the lenience may allow the tail to activate before
|
|
|
|
|
// the last tick, changing ordering of score/combo awarding.
|
2023-10-24 18:00:48 +09:00
|
|
|
|
var lastTick = DrawableSlider.NestedHitObjects.LastOrDefault(o => o.HitObject is SliderTick || o.HitObject is SliderRepeat);
|
|
|
|
|
if (lastTick?.Judged == false)
|
2023-10-03 18:36:13 +09:00
|
|
|
|
return;
|
|
|
|
|
|
2023-10-25 15:44:42 +09:00
|
|
|
|
if (timeOffset < SliderEventGenerator.TAIL_LENIENCY)
|
|
|
|
|
return;
|
|
|
|
|
|
2023-10-24 18:40:12 +09:00
|
|
|
|
// Attempt to preserve correct ordering of judgements as best we can by forcing
|
|
|
|
|
// an un-judged head to be missed when the user has clearly skipped it.
|
2023-10-25 15:44:51 +09:00
|
|
|
|
//
|
|
|
|
|
// This check is applied to all nested slider objects apart from the head (ticks, repeats, tail).
|
2023-10-24 18:40:12 +09:00
|
|
|
|
if (Tracking && !DrawableSlider.HeadCircle.Judged)
|
|
|
|
|
DrawableSlider.HeadCircle.MissForcefully();
|
|
|
|
|
|
2023-09-29 16:20:21 +09:00
|
|
|
|
// The player needs to have engaged in tracking at any point after the tail leniency cutoff.
|
|
|
|
|
// An actual tick miss should only occur if reaching the tick itself.
|
2023-10-25 15:44:42 +09:00
|
|
|
|
if (Tracking)
|
2023-09-29 16:08:28 +09:00
|
|
|
|
ApplyResult(r => r.Type = r.Judgement.MaxResult);
|
2023-10-02 15:30:33 +09:00
|
|
|
|
else if (timeOffset > 0)
|
2023-09-29 16:08:28 +09:00
|
|
|
|
ApplyResult(r => r.Type = r.Judgement.MinResult);
|
2018-04-13 18:19:50 +09:00
|
|
|
|
}
|
2018-10-29 15:36:43 +09:00
|
|
|
|
|
2021-05-26 23:21:05 +03:00
|
|
|
|
protected override void OnApply()
|
|
|
|
|
{
|
|
|
|
|
base.OnApply();
|
|
|
|
|
|
|
|
|
|
if (Slider != null)
|
|
|
|
|
Position = Slider.CurvePositionAt(HitObject.RepeatIndex % 2 == 0 ? 1 : 0);
|
|
|
|
|
}
|
2018-04-13 18:19:50 +09:00
|
|
|
|
}
|
|
|
|
|
}
|